diff --git a/src/loadpath/architecture/snapshot.py b/src/loadpath/architecture/snapshot.py index fbedac1..8cb50dd 100644 --- a/src/loadpath/architecture/snapshot.py +++ b/src/loadpath/architecture/snapshot.py @@ -8,7 +8,7 @@ from loadpath.architecture.depth import deepening_candidates from loadpath.architecture.rules import evaluate from loadpath.config import LoadpathConfig, load_config -from loadpath.graph.store import GraphStore +from loadpath.graph.store import GraphStore, linked_edges from loadpath.index import default_db_path, index_drift from loadpath.types import NodeType @@ -18,6 +18,7 @@ NodeType.ROUTE.value, NodeType.VIEW.value, NodeType.SERIALIZER.value, + NodeType.FORM.value, NodeType.MODEL.value, NodeType.TASK.value, NodeType.MANAGEMENT_COMMAND.value, @@ -77,9 +78,7 @@ def summarize_index(store: GraphStore, config: LoadpathConfig) -> dict[str, Any] def architecture_graph(store: GraphStore) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: nodes = [n for n in store.nodes() if n["type"] in ARCHITECTURE_NODE_TYPES] - ids = {n["id"] for n in nodes} - edges = [e for e in store.edges() if e["src"] in ids and e["dst"] in ids] - return nodes, edges + return nodes, linked_edges(nodes, store.edges()) def architecture_report(repo_root: Path, db_path: Path | None = None) -> dict[str, Any]: diff --git a/src/loadpath/detect.py b/src/loadpath/detect.py index 4d1447c..92b95a2 100644 --- a/src/loadpath/detect.py +++ b/src/loadpath/detect.py @@ -23,6 +23,8 @@ "site-packages", } +TESTISH_PARTS = {"test", "tests", "testing"} + def _skip(path: Path) -> bool: return any(part in SKIP_DIRS or part.startswith(".") for part in path.parts) @@ -115,15 +117,36 @@ def _first(repo_root: Path, name: str) -> str | None: return None +def _is_testish(rel: Path) -> bool: + return any(part in TESTISH_PARTS for part in rel.parts) + + def _detect_django_root(repo_root: Path) -> str: - manage = None - for path in repo_root.rglob("manage.py"): - if _skip(path): + """Prefer the package that holds real apps, not a nested test project's manage.py.""" + parents: list[tuple[str, ...]] = [] + for marker in repo_root.rglob("apps.py"): + if _skip(marker): + continue + app_dir = marker.parent + if app_dir.name in {"migrations", "tests", "management"}: + continue + rel = app_dir.relative_to(repo_root) + if _is_testish(rel): continue - manage = path - break - if manage is not None: - rel = manage.parent.relative_to(repo_root) + parents.append(rel.parent.parts) + if parents: + common: list[str] = [] + for items in zip(*parents): + if len(set(items)) == 1: + common.append(items[0]) + else: + break + return "/".join(common) if common else "." + + manages = [p for p in repo_root.rglob("manage.py") if not _skip(p)] + manages.sort(key=lambda p: (_is_testish(p.relative_to(repo_root)), len(p.relative_to(repo_root).parts))) + if manages: + rel = manages[0].parent.relative_to(repo_root) return rel.as_posix() if rel.parts else "." for candidate in ("backend", "server", "api", "app"): if (repo_root / candidate).is_dir(): @@ -152,14 +175,15 @@ def _django_apps(repo_root: Path, django_root: str) -> list[str]: for marker in root.rglob("apps.py"): if _skip(marker): continue - if marker.parent.name in {"migrations", "tests", "management"}: + rel = marker.relative_to(repo_root) + if _is_testish(rel) or marker.parent.name in {"migrations", "tests", "management"}: continue name = marker.parent.name if name not in apps and name not in {"config", "project", "settings"}: apps.append(name) if not apps: for marker in root.rglob("models.py"): - if _skip(marker): + if _skip(marker) or _is_testish(marker.relative_to(repo_root)): continue name = marker.parent.name if name not in apps and name not in {"migrations", "config"}: diff --git a/src/loadpath/extractors/django.py b/src/loadpath/extractors/django.py index ab81687..a200bf1 100644 --- a/src/loadpath/extractors/django.py +++ b/src/loadpath/extractors/django.py @@ -30,6 +30,7 @@ } SERIALIZER_BASES = {"Serializer", "ModelSerializer", "HyperlinkedModelSerializer", "ListSerializer"} +FORM_BASES = {"Form", "ModelForm", "BaseForm", "BaseModelForm"} MODEL_BASES = {"Model"} ADMIN_BASES = {"ModelAdmin", "StackedInline", "TabularInline"} CELERY_DECORATORS = {"shared_task", "task", "periodic_task"} @@ -141,7 +142,18 @@ def _app_from_path(rel: str) -> str | None: if idx > 0: return parts[idx - 1] for i, part in enumerate(parts): - if part in {"models.py", "views.py", "serializers.py", "urls.py", "signals.py", "tasks.py", "admin.py", "apps.py"}: + if part in { + "models.py", + "views.py", + "serializers.py", + "urls.py", + "signals.py", + "signal_handlers.py", + "forms.py", + "tasks.py", + "admin.py", + "apps.py", + }: return parts[i - 1] if i > 0 else None if part == "management" and i > 0: return parts[i - 1] @@ -216,6 +228,12 @@ def visit_ClassDef(self, node: ast.ClassDef) -> None: self._model(node) elif _has_base(node, SERIALIZER_BASES): self._serializer(node) + elif _has_base(node, FORM_BASES) or ( + node.name.endswith("Form") + and not node.name.startswith("Test") + and not _has_base(node, {"TestCase", "SimpleTestCase", "TransactionTestCase", "LiveServerTestCase", "APITestCase"}) + ): + self._serializer(node, ntype=NodeType.FORM) elif _has_base(node, DJANGO_VIEW_BASES) or node.name.endswith(("View", "ViewSet")): self._view(node) elif any(b.split(".")[-1] in {"BaseCommand", "AppCommand", "LabelCommand"} for b in _bases(node)): @@ -240,6 +258,7 @@ def visit_ClassDef(self, node: ast.ClassDef) -> None: def visit_FunctionDef(self, node: ast.FunctionDef) -> None: self._maybe_task(node) self._maybe_receiver(node) + self._maybe_plain_signal_handler(node) self._maybe_command(node) self._maybe_test(node) self._maybe_service_fn(node) @@ -282,8 +301,14 @@ def visit_Call(self, node: ast.Call) -> None: self.graph.residuals.append(f"Raw SQL ({fname}) in {self.rel_path}:{node.lineno}") elif short in {"select_related", "prefetch_related"}: pass - elif short == "connect" and any(s in fname for s in SIGNAL_NAMES | {"signal"}): - self._signal_connect(node, fname) + elif short == "connect": + handler = node.args[0] if node.args else _kw(node, "receiver") + stem = Path(self.rel_path).stem + looks_signal = stem in {"apps", "signals", "signal_handlers", "handlers"} or any( + token in fname.lower() for token in {n.lower() for n in SIGNAL_NAMES} | {"signal"} + ) + if looks_signal and isinstance(handler, (ast.Name, ast.Attribute)): + self._signal_connect(node, fname) elif short == "reverse": self._reverse(node) self.generic_visit(node) @@ -344,9 +369,12 @@ def _model(self, node: ast.ClassDef) -> None: if extra.get("on_delete") == "CASCADE": self.add_edge(model.id, rel_id, EdgeType.RELATES_TO, extra={"cascade": True}) - def _serializer(self, node: ast.ClassDef) -> None: + def _serializer(self, node: ast.ClassDef, ntype: NodeType = NodeType.SERIALIZER) -> None: qname = f"{self.app}.{node.name}" - ser = self.add_node(NodeType.SERIALIZER, node.name, qname, node.lineno, {"app": self.app}) + extra: dict = {"app": self.app} + if ntype is NodeType.FORM: + extra["django_form"] = True + ser = self.add_node(ntype, node.name, qname, node.lineno, extra) meta_model = None meta_fields: list[str] | None = None meta_exclude: list[str] | None = None @@ -805,6 +833,27 @@ def _maybe_receiver(self, node: ast.FunctionDef) -> None: model_q = sender if "." in sender else f"{self.app}.{sender.split('.')[-1]}" self.add_edge(recv.id, node_id(NodeType.MODEL, model_q), EdgeType.EMITS_SIGNAL) + def _maybe_plain_signal_handler(self, node: ast.FunctionDef) -> None: + if self.class_stack: + return + if Path(self.rel_path).stem not in {"signals", "signal_handlers", "handlers"}: + return + for dec in node.decorator_list: + dname = _name(dec.func if isinstance(dec, ast.Call) else dec) or "" + if dname.split(".")[-1] == "receiver": + return + args = [a.arg for a in node.args.args] + if not (node.args.kwarg or "instance" in args or "sender" in args): + return + qname = f"{self.app}.{node.name}" + self.add_node( + NodeType.RECEIVER, + node.name, + qname, + node.lineno, + {"app": self.app, "plain_handler": True}, + ) + def _maybe_command(self, node: ast.FunctionDef) -> None: if "management/commands" in self.rel_path and node.name == "handle": cmd = Path(self.rel_path).stem @@ -833,7 +882,7 @@ def _maybe_test(self, node: ast.FunctionDef) -> None: # crude: referenced class names in the test become tested_by for child in ast.walk(node): if isinstance(child, ast.Name) and child.id[:1].isupper(): - for ntype in (NodeType.SERIALIZER, NodeType.VIEW, NodeType.MODEL, NodeType.SERVICE): + for ntype in (NodeType.SERIALIZER, NodeType.FORM, NodeType.VIEW, NodeType.MODEL, NodeType.SERVICE, NodeType.RECEIVER): self.add_edge( node_id(ntype, f"{self.app}.{child.id}"), test.id, @@ -915,7 +964,39 @@ def _get_model(self, node: ast.Call) -> None: self.add_node(NodeType.MODEL, label.split(".")[-1], label, node.lineno, {"string_ref": True}) def _signal_connect(self, node: ast.Call, fname: str) -> None: - self.graph.residuals.append(f"signal.connect() at {self.rel_path}:{node.lineno} ({fname})") + handler_ast = node.args[0] if node.args else _kw(node, "receiver") + handler = _name(handler_ast) + signal = fname.rsplit(".", 1)[0] if "." in fname else None + sender = _name(_kw(node, "sender")) + if not handler: + self.graph.residuals.append(f"signal.connect() at {self.rel_path}:{node.lineno} ({fname})") + return + handler_short = handler.split(".")[-1] + qname = handler if "." in handler else f"{self.app}.{handler_short}" + extra = { + "app": self.app, + "signal": signal, + "sender": sender, + "referenced": True, + "via": "connect", + } + recv = self.add_node(NodeType.RECEIVER, handler_short, qname, node.lineno, extra) + if signal: + sig_short = signal.split(".")[-1] + sig_id = node_id(NodeType.SIGNAL, sig_short) + self.graph.nodes.append( + Node( + id=sig_id, + type=NodeType.SIGNAL, + name=sig_short, + qualified_name=sig_short, + extra={"referenced": True}, + ) + ) + self.add_edge(sig_id, recv.id, EdgeType.RECEIVES) + if sender: + model_q = sender if "." in sender else f"{self.app}.{sender.split('.')[-1]}" + self.add_edge(recv.id, node_id(NodeType.MODEL, model_q), EdgeType.EMITS_SIGNAL) def _reverse(self, node: ast.Call) -> None: name = _const_str(node.args[0]) if node.args else None diff --git a/src/loadpath/graph/store.py b/src/loadpath/graph/store.py index 2252872..de2cd58 100644 --- a/src/loadpath/graph/store.py +++ b/src/loadpath/graph/store.py @@ -59,6 +59,12 @@ """ +def linked_edges(nodes: Iterable[dict[str, Any]], edges: Iterable[dict[str, Any]]) -> list[dict[str, Any]]: + """Keep only edges whose src and dst both exist in `nodes`.""" + ids = {n["id"] for n in nodes if n and n.get("id")} + return [e for e in edges if e.get("src") in ids and e.get("dst") in ids] + + class GraphStore: def __init__(self, db_path: Path) -> None: self.db_path = Path(db_path) @@ -248,7 +254,8 @@ def nodes_in_files(self, paths: Iterable[str]) -> list[dict[str, Any]]: return [self._node_from_row(r) for r in rows] def subgraph(self, seed_ids: Iterable[str], hops: int = 6) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: - frontier = set(seed_ids) + known = {r["id"] for r in self.conn.execute("SELECT id FROM nodes")} + frontier = set(seed_ids) & known seen_nodes = set(frontier) seen_edges: dict[str, dict[str, Any]] = {} for _ in range(hops): @@ -257,14 +264,16 @@ def subgraph(self, seed_ids: Iterable[str], hops: int = 6) -> tuple[list[dict[st nxt: set[str] = set() for nid in frontier: for edge in self.neighbors(nid, "both"): - seen_edges[edge["id"]] = edge other = edge["dst"] if edge["src"] == nid else edge["src"] + if other not in known: + continue + seen_edges[edge["id"]] = edge if other not in seen_nodes: seen_nodes.add(other) nxt.add(other) frontier = nxt - nodes = [self.get_node(i) for i in seen_nodes] - return [n for n in nodes if n], list(seen_edges.values()) + nodes = [n for n in (self.get_node(i) for i in seen_nodes) if n] + return nodes, linked_edges(nodes, list(seen_edges.values())) def iter_nodes(self) -> Iterator[dict[str, Any]]: for row in self.conn.execute("SELECT * FROM nodes"): diff --git a/src/loadpath/index.py b/src/loadpath/index.py index 4a80eb7..f68434e 100644 --- a/src/loadpath/index.py +++ b/src/loadpath/index.py @@ -15,7 +15,7 @@ PY_SKIP = {"migrations"} # still extract migrations, just not skip INDEX_EXTENSIONS = {".py", ".ts", ".tsx", ".js", ".jsx"} # Bump when extractor/stitch node identity changes so incremental indexes rebuild. -INDEX_REVISION = "3" +INDEX_REVISION = "4" def default_db_path(repo_root: Path) -> Path: @@ -143,7 +143,8 @@ def index_repo( store.set_meta("repo_root", str(repo_root)) drift = index_drift(store, repo_root, config) - if incremental and store.file_count() > 0 and not drift["stale"]: + revision_changed = (store.get_meta("index_revision") or "") != INDEX_REVISION + if incremental and store.file_count() > 0 and not drift["stale"] and not revision_changed: store.set_meta("reindex_skipped", "1") store.set_meta("files_extracted", "0") store.set_meta("files_skipped", str(drift["indexed_count"])) @@ -161,7 +162,7 @@ def index_repo( for path in files: rel = path.relative_to(repo_root).as_posix() digest = file_hash(path) - if incremental and store.file_hash(rel) == digest: + if incremental and not revision_changed and store.file_hash(rel) == digest: skipped.add(rel) continue store.delete_file_nodes(rel, drop_incoming=False) @@ -214,6 +215,7 @@ def index_repo( store.set_meta("django_boot_detail", boot_detail) store.set_meta("config_hash", _config_digest(repo_root)) store.set_meta("sidecar_hash", _sidecar_digest(repo_root, config)) + store.set_meta("index_revision", INDEX_REVISION) store.conn.commit() return store diff --git a/src/loadpath/report/graph.html b/src/loadpath/report/graph.html index 27fc3a1..cc4b7fa 100644 --- a/src/loadpath/report/graph.html +++ b/src/loadpath/report/graph.html @@ -89,8 +89,9 @@

Loadpath

title: n.qualified_name + "\\n" + (n.file_path || ""), shape: n.type && n.type.startsWith("react.") ? "box" : "dot", }))); + const nodeIds = new Set(nodes.map(n => n.id)); const weightColor = { cheap: "#4a5568", expensive: "#f4a261", critical: "#e85d04" }; - const dataEdges = new vis.DataSet(edges.map(e => ({ + const dataEdges = new vis.DataSet(edges.filter(e => nodeIds.has(e.src) && nodeIds.has(e.dst)).map(e => ({ id: e.id, from: e.src, to: e.dst, diff --git a/src/loadpath/review/cluster.py b/src/loadpath/review/cluster.py index 32fc8d0..005a798 100644 --- a/src/loadpath/review/cluster.py +++ b/src/loadpath/review/cluster.py @@ -2,13 +2,14 @@ from collections import defaultdict -from loadpath.graph.store import GraphStore +from loadpath.graph.store import GraphStore, linked_edges from loadpath.review.diff import DiffSet from loadpath.types import NodeType, SINK_TYPES CLUSTER_SEED_PRIORITY = [ NodeType.SERIALIZER, NodeType.SERIALIZER_FIELD, + NodeType.FORM, NodeType.MODEL, NodeType.FIELD, NodeType.ROUTE, @@ -113,6 +114,8 @@ def include(nid: str, expand: bool) -> None: if e["type"] not in FORWARD_TYPES: continue other = e["dst"] + if other not in by_id: + continue other_node = by_id.get(other) or {} expand = other_node.get("type") not in BRIDGE_TYPES if ( @@ -143,6 +146,8 @@ def include(nid: str, expand: bool) -> None: if e["type"] == "belongs_to" and node.get("type") != NodeType.FEATURE_MODULE.value: continue other = e["src"] + if other not in by_id: + continue other_node = by_id.get(other) or {} if other_node.get("type") in BRIDGE_TYPES: kept_edges[e["id"]] = e @@ -155,7 +160,7 @@ def include(nid: str, expand: bool) -> None: frontier = {i for i in nxt if i not in working} nodes = [by_id[i] for i in seen if i in by_id] - return nodes, list(kept_edges.values()) + return nodes, linked_edges(nodes, list(kept_edges.values())) def cluster_diff( diff --git a/src/loadpath/review/engine.py b/src/loadpath/review/engine.py index 8477d97..4d1e340 100644 --- a/src/loadpath/review/engine.py +++ b/src/loadpath/review/engine.py @@ -8,7 +8,7 @@ from loadpath.architecture.depth import deepening_candidates from loadpath.architecture.rules import _related_accesses, evaluate from loadpath.config import LoadpathConfig, load_config -from loadpath.graph.store import GraphStore +from loadpath.graph.store import GraphStore, linked_edges from loadpath.index import default_db_path, index_drift, index_repo from loadpath.review.cluster import cluster_diff from loadpath.review.confidence import score_confidence @@ -24,6 +24,7 @@ READ_ORDER = [ NodeType.SERIALIZER, NodeType.SERIALIZER_FIELD, + NodeType.FORM, NodeType.ROUTE, NodeType.OPENAPI_PATH, NodeType.FORM_SCHEMA, @@ -54,6 +55,7 @@ def classify_change(impact_nodes: list[dict], findings: list, seeds: list[dict] if ( NodeType.SERIALIZER.value in seed_types or NodeType.SERIALIZER_FIELD.value in seed_types + or NodeType.FORM.value in seed_types or NodeType.OPENAPI_PATH.value in seed_types or NodeType.FORM_SCHEMA.value in seed_types or NodeType.ROUTE.value in seed_types @@ -368,6 +370,7 @@ def run_review( diff = diff or git_diff(repo_root, base, head, three_dot=three_dot) dirty = git_dirty_paths(repo_root) clusters, impact_nodes, impact_edges = cluster_diff(store, diff) + impact_edges = linked_edges(impact_nodes, impact_edges) seed_ids = {n["id"] for n in store.nodes_in_files(diff.paths)} findings = evaluate(store, config, changed_ids=seed_ids) # keep findings that touch the impact subgraph or changed files @@ -492,6 +495,7 @@ def _sink_summaries(nodes: list[dict], store: GraphStore) -> list[dict]: NodeType.TASK.value, NodeType.PAGE.value, NodeType.FORM_SCHEMA.value, + NodeType.FORM.value, NodeType.PERMISSION.value, NodeType.MIGRATION_OP.value, NodeType.RECEIVER.value, diff --git a/src/loadpath/static/assets/LayeredGraph3D-D12B4Z17.js b/src/loadpath/static/assets/LayeredGraph3D-D12B4Z17.js new file mode 100644 index 0000000..1232a29 --- /dev/null +++ b/src/loadpath/static/assets/LayeredGraph3D-D12B4Z17.js @@ -0,0 +1,4116 @@ +import{r as bn,l as tc,c as nc,a as ic,L as sc,j as jn,t as rc}from"./index-DVQVwbDy.js";/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const ya="185",Mi={ROTATE:0,DOLLY:1,PAN:2},vi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ac=0,eo=1,oc=2,ys=1,lc=2,Gi=3,Nn=0,It=1,nn=2,gn=0,Si=1,to=2,no=3,io=4,cc=5,Wn=100,hc=101,uc=102,dc=103,fc=104,pc=200,mc=201,_c=202,gc=203,Pr=204,Dr=205,xc=206,vc=207,Mc=208,Sc=209,Ec=210,yc=211,bc=212,Tc=213,Ac=214,Lr=0,Ir=1,Ur=2,bi=3,Nr=4,Fr=5,Or=6,Br=7,hl=0,Rc=1,wc=2,on=0,ul=1,dl=2,fl=3,pl=4,ml=5,_l=6,gl=7,xl=300,Zn=301,Ti=302,Zs=303,Ks=304,Gs=306,zr=1e3,_n=1001,Gr=1002,yt=1003,Cc=1004,Ki=1005,Rt=1006,$s=1007,Yn=1008,Bt=1009,vl=1010,Ml=1011,ki=1012,ba=1013,cn=1014,rn=1015,vn=1016,Ta=1017,Aa=1018,Wi=1020,Sl=35902,El=35899,yl=1021,bl=1022,qt=1023,Mn=1026,qn=1027,Tl=1028,Ra=1029,Kn=1030,wa=1031,Ca=1033,bs=33776,Ts=33777,As=33778,Rs=33779,Vr=35840,Hr=35841,kr=35842,Wr=35843,Xr=36196,Yr=37492,qr=37496,Zr=37488,Kr=37489,Ps=37490,$r=37491,Jr=37808,Qr=37809,jr=37810,ea=37811,ta=37812,na=37813,ia=37814,sa=37815,ra=37816,aa=37817,oa=37818,la=37819,ca=37820,ha=37821,ua=36492,da=36494,fa=36495,pa=36283,ma=36284,Ds=36285,_a=36286,Pc=3200,ga=0,Dc=1,Ln="",Vt="srgb",Ls="srgb-linear",Is="linear",$e="srgb",ei=7680,so=519,Lc=512,Ic=513,Uc=514,Pa=515,Nc=516,Fc=517,Da=518,Oc=519,xa=35044,ro="300 es",an=2e3,Xi=2001;function Bc(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Us(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function zc(){const i=Us("canvas");return i.style.display="block",i}const ao={};function Ns(...i){const e="THREE."+i.shift();console.log(e,...i)}function Al(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Pe(...i){i=Al(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=Al(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ei(...i){const e=i.join(" ");e in ao||(ao[e]=!0,Pe(...i))}function Gc(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Vc={[Lr]:Ir,[Ur]:Or,[Nr]:Br,[bi]:Fr,[Ir]:Lr,[Or]:Ur,[Br]:Nr,[Fr]:bi};class Bn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r>8&255]+Tt[i>>16&255]+Tt[i>>24&255]+"-"+Tt[e&255]+Tt[e>>8&255]+"-"+Tt[e>>16&15|64]+Tt[e>>24&255]+"-"+Tt[t&63|128]+Tt[t>>8&255]+"-"+Tt[t>>16&255]+Tt[t>>24&255]+Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]).toLowerCase()}function He(i,e,t){return Math.max(e,Math.min(t,i))}function Hc(i,e){return(i%e+e)%e}function Js(i,e,t){return(1-t)*i+t*e}function sn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Qe(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const kc={DEG2RAD:ws},Ga=class Ga{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ga.prototype.isVector2=!0;let Re=Ga;class Fn{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],f=n[s+2],m=n[s+3],h=r[a+0],_=r[a+1],v=r[a+2],S=r[a+3];if(m!==S||c!==h||l!==_||f!==v){let p=c*h+l*_+f*v+m*S;p<0&&(h=-h,_=-_,v=-v,S=-S,p=-p);let u=1-o;if(p<.9995){const T=Math.acos(p),R=Math.sin(T);u=Math.sin(u*T)/R,o=Math.sin(o*T)/R,c=c*u+h*o,l=l*u+_*o,f=f*u+v*o,m=m*u+S*o}else{c=c*u+h*o,l=l*u+_*o,f=f*u+v*o,m=m*u+S*o;const T=1/Math.sqrt(c*c+l*l+f*f+m*m);c*=T,l*=T,f*=T,m*=T}}e[t]=c,e[t+1]=l,e[t+2]=f,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],f=n[s+3],m=r[a],h=r[a+1],_=r[a+2],v=r[a+3];return e[t]=o*v+f*m+c*_-l*h,e[t+1]=c*v+f*h+l*m-o*_,e[t+2]=l*v+f*_+o*h-c*m,e[t+3]=f*v-o*m-c*h-l*_,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),f=o(s/2),m=o(r/2),h=c(n/2),_=c(s/2),v=c(r/2);switch(a){case"XYZ":this._x=h*f*m+l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m-h*_*v;break;case"YXZ":this._x=h*f*m+l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m+h*_*v;break;case"ZXY":this._x=h*f*m-l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m-h*_*v;break;case"ZYX":this._x=h*f*m-l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m+h*_*v;break;case"YZX":this._x=h*f*m+l*_*v,this._y=l*_*m+h*f*v,this._z=l*f*v-h*_*m,this._w=l*f*m-h*_*v;break;case"XZY":this._x=h*f*m-l*_*v,this._y=l*_*m-h*f*v,this._z=l*f*v+h*_*m,this._w=l*f*m+h*_*v;break;default:Pe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],f=t[6],m=t[10],h=n+o+m;if(h>0){const _=.5/Math.sqrt(h+1);this._w=.25/_,this._x=(f-c)*_,this._y=(r-l)*_,this._z=(a-s)*_}else if(n>o&&n>m){const _=2*Math.sqrt(1+n-o-m);this._w=(f-c)/_,this._x=.25*_,this._y=(s+a)/_,this._z=(r+l)/_}else if(o>m){const _=2*Math.sqrt(1+o-n-m);this._w=(r-l)/_,this._x=(s+a)/_,this._y=.25*_,this._z=(c+f)/_}else{const _=2*Math.sqrt(1+m-n-o);this._w=(a-s)/_,this._x=(r+l)/_,this._y=(c+f)/_,this._z=.25*_}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(He(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,f=t._w;return this._x=n*f+a*o+s*l-r*c,this._y=s*f+a*c+r*o-n*l,this._z=r*f+a*l+n*c-s*o,this._w=a*f-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),f=Math.sin(l);c=Math.sin(c*l)/f,t=Math.sin(t*l)/f,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Va=class Va{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(oo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(oo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),f=2*(o*t-r*s),m=2*(r*n-a*t);return this.x=t+c*l+a*m-o*f,this.y=n+c*f+o*l-r*m,this.z=s+c*m+r*f-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Qs.copy(this).projectOnVector(e),this.sub(Qs)}reflect(e){return this.sub(Qs.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Va.prototype.isVector3=!0;let I=Va;const Qs=new I,oo=new Fn,Ha=class Ha{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const f=this.elements;return f[0]=e,f[1]=s,f[2]=o,f[3]=t,f[4]=r,f[5]=c,f[6]=n,f[7]=a,f[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],f=n[4],m=n[7],h=n[2],_=n[5],v=n[8],S=s[0],p=s[3],u=s[6],T=s[1],R=s[4],M=s[7],A=s[2],y=s[5],w=s[8];return r[0]=a*S+o*T+c*A,r[3]=a*p+o*R+c*y,r[6]=a*u+o*M+c*w,r[1]=l*S+f*T+m*A,r[4]=l*p+f*R+m*y,r[7]=l*u+f*M+m*w,r[2]=h*S+_*T+v*A,r[5]=h*p+_*R+v*y,r[8]=h*u+_*M+v*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8];return t*a*f-t*o*l-n*r*f+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],f=e[8],m=f*a-o*l,h=o*c-f*r,_=l*r-a*c,v=t*m+n*h+s*_;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=m*S,e[1]=(s*l-f*n)*S,e[2]=(o*n-s*a)*S,e[3]=h*S,e[4]=(f*t-s*c)*S,e[5]=(s*r-o*t)*S,e[6]=_*S,e[7]=(n*c-l*t)*S,e[8]=(a*t-n*r)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Ei("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(js.makeScale(e,t)),this}rotate(e){return Ei("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(js.makeRotation(-e)),this}translate(e,t){return Ei("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(js.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ha.prototype.isMatrix3=!0;let Ie=Ha;const js=new Ie,lo=new Ie().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),co=new Ie().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Wc(){const i={enabled:!0,workingColorSpace:Ls,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===$e&&(s.r=xn(s.r),s.g=xn(s.g),s.b=xn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$e&&(s.r=yi(s.r),s.g=yi(s.g),s.b=yi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Ln?Is:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ei("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ei("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Ls]:{primaries:e,whitePoint:n,transfer:Is,toXYZ:lo,fromXYZ:co,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Vt},outputColorSpaceConfig:{drawingBufferColorSpace:Vt}},[Vt]:{primaries:e,whitePoint:n,transfer:$e,toXYZ:lo,fromXYZ:co,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Vt}}}),i}const Xe=Wc();function xn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function yi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ti;class Xc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ti===void 0&&(ti=Us("canvas")),ti.width=e.width,ti.height=e.height;const s=ti.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ti}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Us("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(tr).x}get height(){return this.source.getSize(tr).y}get depth(){return this.source.getSize(tr).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Pe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Pe(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zr:e.x=e.x-Math.floor(e.x);break;case _n:e.x=e.x<0?0:1;break;case Gr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case zr:e.y=e.y-Math.floor(e.y);break;case _n:e.y=e.y<0?0:1;break;case Gr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}wt.DEFAULT_IMAGE=null;wt.DEFAULT_MAPPING=xl;wt.DEFAULT_ANISOTROPY=1;const ka=class ka{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const c=e.elements,l=c[0],f=c[4],m=c[8],h=c[1],_=c[5],v=c[9],S=c[2],p=c[6],u=c[10];if(Math.abs(f-h)<.01&&Math.abs(m-S)<.01&&Math.abs(v-p)<.01){if(Math.abs(f+h)<.1&&Math.abs(m+S)<.1&&Math.abs(v+p)<.1&&Math.abs(l+_+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(l+1)/2,M=(_+1)/2,A=(u+1)/2,y=(f+h)/4,w=(m+S)/4,g=(v+p)/4;return R>M&&R>A?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=y/n,r=w/n):M>A?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=y/s,r=g/s):A<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),n=w/r,s=g/r),this.set(n,s,r,t),this}let T=Math.sqrt((p-v)*(p-v)+(m-S)*(m-S)+(h-f)*(h-f));return Math.abs(T)<.001&&(T=1),this.x=(p-v)/T,this.y=(m-S)/T,this.z=(h-f)/T,this.w=Math.acos((l+_+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this.w=He(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this.w=He(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};ka.prototype.isVector4=!0;let ct=ka;class Zc extends Bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new wt(s),a=n.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,f=c.length;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),f.length>0&&(n.images=f),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),_.length>0&&(n.animations=_),v.length>0&&(n.nodes=v)}return n.object=s,n;function a(o){const c=[];for(const l in o){const f=o[l];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n_+v?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=_-v&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(nh)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Vi;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const wl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},An={h:0,s:0,l:0},Qi={h:0,s:0,l:0};function sr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Be{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Xe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Xe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Xe.workingColorSpace){if(e=Hc(e,1),t=He(t,0,1),n=He(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=sr(a,r,e+1/3),this.g=sr(a,r,e),this.b=sr(a,r,e-1/3)}return Xe.colorSpaceToWorking(this,s),this}setStyle(e,t=Vt){function n(r){r!==void 0&&parseFloat(r)<1&&Pe("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Pe("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Pe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vt){const n=wl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Pe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xn(e.r),this.g=xn(e.g),this.b=xn(e.b),this}copyLinearToSRGB(e){return this.r=yi(e.r),this.g=yi(e.g),this.b=yi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vt){return Xe.workingToColorSpace(At.copy(this),e),Math.round(He(At.r*255,0,255))*65536+Math.round(He(At.g*255,0,255))*256+Math.round(He(At.b*255,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Xe.workingColorSpace){Xe.workingToColorSpace(At.copy(this),t);const n=At.r,s=At.g,r=At.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let c,l;const f=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=f<=.5?m/(a+o):m/(2-a-o),a){case n:c=(s-r)/m+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Xt=new I,dn=new I,rr=new I,fn=new I,ri=new I,ai=new I,xo=new I,ar=new I,or=new I,lr=new I,cr=new ct,hr=new ct,ur=new ct;class kt{constructor(e=new I,t=new I,n=new I){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),Xt.subVectors(e,t),s.cross(Xt);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){Xt.subVectors(s,t),dn.subVectors(n,t),rr.subVectors(e,t);const a=Xt.dot(Xt),o=Xt.dot(dn),c=Xt.dot(rr),l=dn.dot(dn),f=dn.dot(rr),m=a*l-o*o;if(m===0)return r.set(0,0,0),null;const h=1/m,_=(l*c-o*f)*h,v=(a*f-o*c)*h;return r.set(1-_-v,v,_)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,fn)===null?!1:fn.x>=0&&fn.y>=0&&fn.x+fn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,fn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,fn.x),c.addScaledVector(a,fn.y),c.addScaledVector(o,fn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return cr.setScalar(0),hr.setScalar(0),ur.setScalar(0),cr.fromBufferAttribute(e,t),hr.fromBufferAttribute(e,n),ur.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(cr,r.x),a.addScaledVector(hr,r.y),a.addScaledVector(ur,r.z),a}static isFrontFacing(e,t,n,s){return Xt.subVectors(n,t),dn.subVectors(e,t),Xt.cross(dn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Xt.subVectors(this.c,this.b),dn.subVectors(this.a,this.b),Xt.cross(dn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return kt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return kt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return kt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;ri.subVectors(s,n),ai.subVectors(r,n),ar.subVectors(e,n);const c=ri.dot(ar),l=ai.dot(ar);if(c<=0&&l<=0)return t.copy(n);or.subVectors(e,s);const f=ri.dot(or),m=ai.dot(or);if(f>=0&&m<=f)return t.copy(s);const h=c*m-f*l;if(h<=0&&c>=0&&f<=0)return a=c/(c-f),t.copy(n).addScaledVector(ri,a);lr.subVectors(e,r);const _=ri.dot(lr),v=ai.dot(lr);if(v>=0&&_<=v)return t.copy(r);const S=_*l-c*v;if(S<=0&&l>=0&&v<=0)return o=l/(l-v),t.copy(n).addScaledVector(ai,o);const p=f*v-_*m;if(p<=0&&m-f>=0&&_-v>=0)return xo.subVectors(r,s),o=(m-f)/(m-f+(_-v)),t.copy(s).addScaledVector(xo,o);const u=1/(p+S+h);return a=S*u,o=h*u,t.copy(n).addScaledVector(ri,a).addScaledVector(ai,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class wi{constructor(e=new I(1/0,1/0,1/0),t=new I(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Yt),Yt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Di),es.subVectors(this.max,Di),oi.subVectors(e.a,Di),li.subVectors(e.b,Di),ci.subVectors(e.c,Di),Rn.subVectors(li,oi),wn.subVectors(ci,li),Gn.subVectors(oi,ci);let t=[0,-Rn.z,Rn.y,0,-wn.z,wn.y,0,-Gn.z,Gn.y,Rn.z,0,-Rn.x,wn.z,0,-wn.x,Gn.z,0,-Gn.x,-Rn.y,Rn.x,0,-wn.y,wn.x,0,-Gn.y,Gn.x,0];return!dr(t,oi,li,ci,es)||(t=[1,0,0,0,1,0,0,0,1],!dr(t,oi,li,ci,es))?!1:(ts.crossVectors(Rn,wn),t=[ts.x,ts.y,ts.z],dr(t,oi,li,ci,es))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yt).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const pn=[new I,new I,new I,new I,new I,new I,new I,new I],Yt=new I,ji=new wi,oi=new I,li=new I,ci=new I,Rn=new I,wn=new I,Gn=new I,Di=new I,es=new I,ts=new I,Vn=new I;function dr(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Vn.fromArray(i,r);const o=s.x*Math.abs(Vn.x)+s.y*Math.abs(Vn.y)+s.z*Math.abs(Vn.z),c=e.dot(Vn),l=t.dot(Vn),f=n.dot(Vn);if(Math.max(-Math.max(c,l,f),Math.min(c,l,f))>o)return!1}return!0}const _t=new I,ns=new Re;let sh=0;class Zt extends Bn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:sh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=xa,this.updateRanges=[],this.gpuType=rn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Li.subVectors(e,this.center);const t=Li.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Li,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(fr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Li.copy(e.center).add(fr)),this.expandByPoint(Li.copy(e.center).sub(fr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let ah=0;const Gt=new ot,pr=new Et,hi=new I,Ot=new wi,Ii=new wi,St=new I;class Ut extends Bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ah++}),this.uuid=Un(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bc(e)?Pl:Cl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Ie().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Gt.makeRotationFromQuaternion(e),this.applyMatrix4(Gt),this}rotateX(e){return Gt.makeRotationX(e),this.applyMatrix4(Gt),this}rotateY(e){return Gt.makeRotationY(e),this.applyMatrix4(Gt),this}rotateZ(e){return Gt.makeRotationZ(e),this.applyMatrix4(Gt),this}translate(e,t,n){return Gt.makeTranslation(e,t,n),this.applyMatrix4(Gt),this}scale(e,t,n){return Gt.makeScale(e,t,n),this.applyMatrix4(Gt),this}lookAt(e){return pr.lookAt(e),pr.updateMatrix(),this.applyMatrix4(pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hi).negate(),this.translate(hi.x,hi.y,hi.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;st.count&&Pe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],f=[];for(let m=0,h=l.length;m0&&(s[c]=f,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const l in s){const f=s[l];this.setAttribute(l,f.clone(t))}const r=e.morphAttributes;for(const l in r){const f=[],m=r[l];for(let h=0,_=m.length;h<_;h++)f.push(m[h].clone(t));this.morphAttributes[l]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,f=a.length;l0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Pe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Pe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Si&&(n.blending=this.blending),this.side!==Nn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Pr&&(n.blendSrc=this.blendSrc),this.blendDst!==Dr&&(n.blendDst=this.blendDst),this.blendEquation!==Wn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==bi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==so&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ei&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ei&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ei&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Be().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Re().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Re().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Dl extends $n{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Be(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ui;const Ui=new I,di=new I,fi=new I,pi=new Re,Ni=new Re,Ll=new ot,is=new I,Fi=new I,ss=new I,vo=new Re,mr=new Re,Mo=new Re;class ch extends Et{constructor(e=new Dl){if(super(),this.isSprite=!0,this.type="Sprite",ui===void 0){ui=new Ut;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new oh(t,5);ui.setIndex([0,1,2,0,2,3]),ui.setAttribute("position",new Fs(n,3,0,!1)),ui.setAttribute("uv",new Fs(n,2,3,!1))}this.geometry=ui,this.material=e,this.center=new Re(.5,.5),this.count=1}raycast(e,t){e.camera===null&&We('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),di.setFromMatrixScale(this.matrixWorld),Ll.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),fi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&di.multiplyScalar(-fi.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;rs(is.set(-.5,-.5,0),fi,a,di,s,r),rs(Fi.set(.5,-.5,0),fi,a,di,s,r),rs(ss.set(.5,.5,0),fi,a,di,s,r),vo.set(0,0),mr.set(1,0),Mo.set(1,1);let o=e.ray.intersectTriangle(is,Fi,ss,!1,Ui);if(o===null&&(rs(Fi.set(-.5,.5,0),fi,a,di,s,r),mr.set(0,1),o=e.ray.intersectTriangle(is,ss,Fi,!1,Ui),o===null))return;const c=e.ray.origin.distanceTo(Ui);ce.far||t.push({distance:c,point:Ui.clone(),uv:kt.getInterpolation(Ui,is,Fi,ss,vo,mr,Mo,new Re),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function rs(i,e,t,n,s,r){pi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Ni.x=r*pi.x-s*pi.y,Ni.y=s*pi.x+r*pi.y):Ni.copy(pi),i.copy(e),i.x+=Ni.x,i.y+=Ni.y,i.applyMatrix4(Ll)}const mn=new I,_r=new I,as=new I,Cn=new I,gr=new I,os=new I,xr=new I;class Hs{constructor(e=new I,t=new I(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,mn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=mn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(mn.copy(this.origin).addScaledVector(this.direction,t),mn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){_r.copy(e).add(t).multiplyScalar(.5),as.copy(t).sub(e).normalize(),Cn.copy(this.origin).sub(_r);const r=e.distanceTo(t)*.5,a=-this.direction.dot(as),o=Cn.dot(this.direction),c=-Cn.dot(as),l=Cn.lengthSq(),f=Math.abs(1-a*a);let m,h,_,v;if(f>0)if(m=a*c-o,h=a*o-c,v=r*f,m>=0)if(h>=-v)if(h<=v){const S=1/f;m*=S,h*=S,_=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h=-r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;else h<=-v?(m=Math.max(0,-(-a*r+o)),h=m>0?-r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l):h<=v?(m=0,h=Math.min(Math.max(-r,-c),r),_=h*(h+2*c)+l):(m=Math.max(0,-(a*r+o)),h=m>0?r:Math.min(Math.max(-r,-c),r),_=-m*m+h*(h+2*c)+l);else h=a>0?-r:r,m=Math.max(0,-(a*h+o)),_=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),s&&s.copy(_r).addScaledVector(as,h),_}intersectSphere(e,t){mn.subVectors(e.center,this.origin);const n=mn.dot(this.direction),s=mn.dot(mn)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c;const l=1/this.direction.x,f=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,s=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,s=(e.min.x-h.x)*l),f>=0?(r=(e.min.y-h.y)*f,a=(e.max.y-h.y)*f):(r=(e.max.y-h.y)*f,a=(e.min.y-h.y)*f),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>s)||((o>n||n!==n)&&(n=o),(c=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,mn)!==null}intersectTriangle(e,t,n,s,r){gr.subVectors(t,e),os.subVectors(n,e),xr.crossVectors(gr,os);let a=this.direction.dot(xr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Cn.subVectors(this.origin,e);const c=o*this.direction.dot(os.crossVectors(Cn,os));if(c<0)return null;const l=o*this.direction.dot(gr.cross(Cn));if(l<0||c+l>a)return null;const f=-o*Cn.dot(xr);return f<0?null:this.at(f/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ua extends $n{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=hl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const So=new ot,Hn=new Hs,ls=new Vs,Eo=new I,cs=new I,hs=new I,us=new I,vr=new I,ds=new I,yo=new I,fs=new I;class Kt extends Et{constructor(e=new Ut,t=new Ua){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(So.copy(r).invert(),Hn.copy(e.ray).applyMatrix4(So),!(n.boundingBox!==null&&Hn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,f=r.attributes.uv1,m=r.attributes.normal,h=r.groups,_=r.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,S=h.length;vt.far?null:{distance:l,point:fs.clone(),object:i}}function ps(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,cs),i.getVertexPosition(c,hs),i.getVertexPosition(l,us);const f=hh(i,e,t,n,cs,hs,us,yo);if(f){const m=new I;kt.getBarycoord(yo,cs,hs,us,m),s&&(f.uv=kt.getInterpolatedAttribute(s,o,c,l,m,new Re)),r&&(f.uv1=kt.getInterpolatedAttribute(r,o,c,l,m,new Re)),a&&(f.normal=kt.getInterpolatedAttribute(a,o,c,l,m,new I),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new I,materialIndex:0};kt.getNormal(cs,hs,us,h.normal),f.face=h,f.barycoord=m}return f}class uh extends wt{constructor(e=null,t=1,n=1,s,r,a,o,c,l=yt,f=yt,m,h){super(null,a,o,c,l,f,s,r,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Mr=new I,dh=new I,fh=new Ie;class Dn{constructor(e=new I(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=Mr.subVectors(n,t).cross(dh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(Mr),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||fh.getNormalMatrix(e),s=this.coplanarPoint(Mr).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const kn=new Vs,ph=new Re(.5,.5),ms=new I;class Na{constructor(e=new Dn,t=new Dn,n=new Dn,s=new Dn,r=new Dn,a=new Dn){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=an,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],f=r[4],m=r[5],h=r[6],_=r[7],v=r[8],S=r[9],p=r[10],u=r[11],T=r[12],R=r[13],M=r[14],A=r[15];if(s[0].setComponents(l-a,_-f,u-v,A-T).normalize(),s[1].setComponents(l+a,_+f,u+v,A+T).normalize(),s[2].setComponents(l+o,_+m,u+S,A+R).normalize(),s[3].setComponents(l-o,_-m,u-S,A-R).normalize(),n)s[4].setComponents(c,h,p,M).normalize(),s[5].setComponents(l-c,_-h,u-p,A-M).normalize();else if(s[4].setComponents(l-c,_-h,u-p,A-M).normalize(),t===an)s[5].setComponents(l+c,_+h,u+p,A+M).normalize();else if(t===Xi)s[5].setComponents(c,h,p,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),kn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),kn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(kn)}intersectsSprite(e){kn.center.set(0,0,0);const t=ph.distanceTo(e.center);return kn.radius=.7071067811865476+t,kn.applyMatrix4(e.matrixWorld),this.intersectsSphere(kn)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,ms.y=s.normal.y>0?e.max.y:e.min.y,ms.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ms)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Il extends $n{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Be(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Os=new I,Bs=new I,bo=new ot,Oi=new Hs,_s=new Vs,Sr=new I,To=new I;class mh extends Et{constructor(e=new Ut,t=new Il){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;rn)return;Sr.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Sr);if(!(le.far))return{distance:l,point:To.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Ao=new I,Ro=new I;class _h extends mh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s0?1:-1,f.push(j.x,j.y,j.z),m.push(ge/w),m.push(1-re/g),H+=1}}for(let re=0;re0)&&_.push(R,M,y),(u!==n-1||c0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Be().setHex(s.value);break;case"v2":this.uniforms[n].value=new Re().fromArray(s.value);break;case"v3":this.uniforms[n].value=new I().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ct().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ie().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ot().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class yh extends hn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class bh extends $n{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Be(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ga,this.normalScale=new Re(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Th extends $n{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Pc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ah extends $n{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Ol extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Be(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const Er=new ot,Co=new I,Po=new I;class Rh{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Re(512,512),this.mapType=Bt,this.map=null,this.mapPass=null,this.matrix=new ot,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Na,this._frameExtents=new Re(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Co.setFromMatrixPosition(e.matrixWorld),t.position.copy(Co),Po.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Po),t.updateMatrixWorld(),Er.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Er,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Xi||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Er)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const xs=new I,vs=new Fn,jt=new I;class Bl extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot,this.coordinateSystem=an,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(xs,vs,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xs,vs,jt.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(xs,vs,jt),jt.x===1&&jt.y===1&&jt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xs,vs,jt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Pn=new I,Do=new Re,Lo=new Re;class Ht extends Bl{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=va*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ws*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return va*2*Math.atan(Math.tan(ws*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Pn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Pn.x,Pn.y).multiplyScalar(-e/Pn.z),Pn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Pn.x,Pn.y).multiplyScalar(-e/Pn.z)}getViewSize(e,t){return this.getViewBounds(e,Do,Lo),t.subVectors(Lo,Do)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ws*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Ba extends Bl{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=f*this.view.offsetY,c=o-f*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class wh extends Rh{constructor(){super(new Ba(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ch extends Ol{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new wh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Ph extends Ol{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}const mi=-90,_i=1;class Dh extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Ht(mi,_i,e,t);s.layers=this.layers,this.add(s);const r=new Ht(mi,_i,e,t);r.layers=this.layers,this.add(r);const a=new Ht(mi,_i,e,t);a.layers=this.layers,this.add(a);const o=new Ht(mi,_i,e,t);o.layers=this.layers,this.add(o);const c=new Ht(mi,_i,e,t);c.layers=this.layers,this.add(c);const l=new Ht(mi,_i,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===an)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Xi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,f]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),_=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,f),e.setRenderTarget(m,h,_),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class Lh extends Ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Io=new ot;class Ih{constructor(e,t,n=0,s=1/0){this.ray=new Hs(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Ia,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):We("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Io.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Io),this}intersectObject(e,t=!0,n=[]){return Ma(e,this,n,t),n.sort(Uo),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s_.start-v.start);let h=0;for(let _=1;_ 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,jh=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,eu=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,tu=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,nu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,iu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,su=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,ru=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,au=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,ou=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,lu=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,cu=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,hu=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,uu=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,du=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,fu="gl_FragColor = linearToOutputTexel( gl_FragColor );",pu=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,mu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,_u=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,gu=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,xu=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,vu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Mu=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Su=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Eu=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,yu=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,bu=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,Tu=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Au=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Ru=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,wu=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Cu=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Pu=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Du=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Lu=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Iu=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Uu=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,Nu=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,Fu=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Ou=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,Bu=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,zu=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,Gu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,Vu=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Hu=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,ku=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,Wu=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,Xu=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,Yu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,qu=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,Zu=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,Ku=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,$u=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,Ju=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,Qu=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,ju=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,ed=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,td=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,nd=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,id=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,sd=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,rd=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,ad=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,od=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,ld=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,cd=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,hd=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,ud=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,dd=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,fd=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,pd=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,md=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,_d=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,gd=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,xd=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,vd=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,Md=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Sd=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,Ed=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,yd=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,bd=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Td=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Ad=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,Rd=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,wd=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Cd=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Pd=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Dd=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Ld=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Id=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Ud=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Nd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,Fd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Od=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,Bd=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,zd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Gd=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Vd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Hd=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,kd=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,Wd=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,Xd=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,Yd=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,qd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,Zd=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,Kd=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,$d=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Jd=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Qd=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,jd=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,ef=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,tf=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,nf=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,sf=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,rf=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,af=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,of=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,lf=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,cf=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,hf=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,uf=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,df=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,ff=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,pf=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,mf=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,_f=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,gf=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Oe={alphahash_fragment:Oh,alphahash_pars_fragment:Bh,alphamap_fragment:zh,alphamap_pars_fragment:Gh,alphatest_fragment:Vh,alphatest_pars_fragment:Hh,aomap_fragment:kh,aomap_pars_fragment:Wh,batching_pars_vertex:Xh,batching_vertex:Yh,begin_vertex:qh,beginnormal_vertex:Zh,bsdfs:Kh,iridescence_fragment:$h,bumpmap_pars_fragment:Jh,clipping_planes_fragment:Qh,clipping_planes_pars_fragment:jh,clipping_planes_pars_vertex:eu,clipping_planes_vertex:tu,color_fragment:nu,color_pars_fragment:iu,color_pars_vertex:su,color_vertex:ru,common:au,cube_uv_reflection_fragment:ou,defaultnormal_vertex:lu,displacementmap_pars_vertex:cu,displacementmap_vertex:hu,emissivemap_fragment:uu,emissivemap_pars_fragment:du,colorspace_fragment:fu,colorspace_pars_fragment:pu,envmap_fragment:mu,envmap_common_pars_fragment:_u,envmap_pars_fragment:gu,envmap_pars_vertex:xu,envmap_physical_pars_fragment:Cu,envmap_vertex:vu,fog_vertex:Mu,fog_pars_vertex:Su,fog_fragment:Eu,fog_pars_fragment:yu,gradientmap_pars_fragment:bu,lightmap_pars_fragment:Tu,lights_lambert_fragment:Au,lights_lambert_pars_fragment:Ru,lights_pars_begin:wu,lights_toon_fragment:Pu,lights_toon_pars_fragment:Du,lights_phong_fragment:Lu,lights_phong_pars_fragment:Iu,lights_physical_fragment:Uu,lights_physical_pars_fragment:Nu,lights_fragment_begin:Fu,lights_fragment_maps:Ou,lights_fragment_end:Bu,lightprobes_pars_fragment:zu,logdepthbuf_fragment:Gu,logdepthbuf_pars_fragment:Vu,logdepthbuf_pars_vertex:Hu,logdepthbuf_vertex:ku,map_fragment:Wu,map_pars_fragment:Xu,map_particle_fragment:Yu,map_particle_pars_fragment:qu,metalnessmap_fragment:Zu,metalnessmap_pars_fragment:Ku,morphinstance_vertex:$u,morphcolor_vertex:Ju,morphnormal_vertex:Qu,morphtarget_pars_vertex:ju,morphtarget_vertex:ed,normal_fragment_begin:td,normal_fragment_maps:nd,normal_pars_fragment:id,normal_pars_vertex:sd,normal_vertex:rd,normalmap_pars_fragment:ad,clearcoat_normal_fragment_begin:od,clearcoat_normal_fragment_maps:ld,clearcoat_pars_fragment:cd,iridescence_pars_fragment:hd,opaque_fragment:ud,packing:dd,premultiplied_alpha_fragment:fd,project_vertex:pd,dithering_fragment:md,dithering_pars_fragment:_d,roughnessmap_fragment:gd,roughnessmap_pars_fragment:xd,shadowmap_pars_fragment:vd,shadowmap_pars_vertex:Md,shadowmap_vertex:Sd,shadowmask_pars_fragment:Ed,skinbase_vertex:yd,skinning_pars_vertex:bd,skinning_vertex:Td,skinnormal_vertex:Ad,specularmap_fragment:Rd,specularmap_pars_fragment:wd,tonemapping_fragment:Cd,tonemapping_pars_fragment:Pd,transmission_fragment:Dd,transmission_pars_fragment:Ld,uv_pars_fragment:Id,uv_pars_vertex:Ud,uv_vertex:Nd,worldpos_vertex:Fd,background_vert:Od,background_frag:Bd,backgroundCube_vert:zd,backgroundCube_frag:Gd,cube_vert:Vd,cube_frag:Hd,depth_vert:kd,depth_frag:Wd,distance_vert:Xd,distance_frag:Yd,equirect_vert:qd,equirect_frag:Zd,linedashed_vert:Kd,linedashed_frag:$d,meshbasic_vert:Jd,meshbasic_frag:Qd,meshlambert_vert:jd,meshlambert_frag:ef,meshmatcap_vert:tf,meshmatcap_frag:nf,meshnormal_vert:sf,meshnormal_frag:rf,meshphong_vert:af,meshphong_frag:of,meshphysical_vert:lf,meshphysical_frag:cf,meshtoon_vert:hf,meshtoon_frag:uf,points_vert:df,points_frag:ff,shadow_vert:pf,shadow_frag:mf,sprite_vert:_f,sprite_frag:gf},ue={common:{diffuse:{value:new Be(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ie}},envmap:{envMap:{value:null},envMapRotation:{value:new Ie},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ie}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ie}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ie},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ie},normalScale:{value:new Re(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ie},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ie}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ie}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ie}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new I},probesMax:{value:new I},probesResolution:{value:new I}},points:{diffuse:{value:new Be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0},uvTransform:{value:new Ie}},sprite:{diffuse:{value:new Be(16777215)},opacity:{value:1},center:{value:new Re(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}}},tn={basic:{uniforms:Pt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.fog]),vertexShader:Oe.meshbasic_vert,fragmentShader:Oe.meshbasic_frag},lambert:{uniforms:Pt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Be(0)},envMapIntensity:{value:1}}]),vertexShader:Oe.meshlambert_vert,fragmentShader:Oe.meshlambert_frag},phong:{uniforms:Pt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Be(0)},specular:{value:new Be(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Oe.meshphong_vert,fragmentShader:Oe.meshphong_frag},standard:{uniforms:Pt([ue.common,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.roughnessmap,ue.metalnessmap,ue.fog,ue.lights,{emissive:{value:new Be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Oe.meshphysical_vert,fragmentShader:Oe.meshphysical_frag},toon:{uniforms:Pt([ue.common,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.gradientmap,ue.fog,ue.lights,{emissive:{value:new Be(0)}}]),vertexShader:Oe.meshtoon_vert,fragmentShader:Oe.meshtoon_frag},matcap:{uniforms:Pt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,{matcap:{value:null}}]),vertexShader:Oe.meshmatcap_vert,fragmentShader:Oe.meshmatcap_frag},points:{uniforms:Pt([ue.points,ue.fog]),vertexShader:Oe.points_vert,fragmentShader:Oe.points_frag},dashed:{uniforms:Pt([ue.common,ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Oe.linedashed_vert,fragmentShader:Oe.linedashed_frag},depth:{uniforms:Pt([ue.common,ue.displacementmap]),vertexShader:Oe.depth_vert,fragmentShader:Oe.depth_frag},normal:{uniforms:Pt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,{opacity:{value:1}}]),vertexShader:Oe.meshnormal_vert,fragmentShader:Oe.meshnormal_frag},sprite:{uniforms:Pt([ue.sprite,ue.fog]),vertexShader:Oe.sprite_vert,fragmentShader:Oe.sprite_frag},background:{uniforms:{uvTransform:{value:new Ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Oe.background_vert,fragmentShader:Oe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ie}},vertexShader:Oe.backgroundCube_vert,fragmentShader:Oe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Oe.cube_vert,fragmentShader:Oe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Oe.equirect_vert,fragmentShader:Oe.equirect_frag},distance:{uniforms:Pt([ue.common,ue.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Oe.distance_vert,fragmentShader:Oe.distance_frag},shadow:{uniforms:Pt([ue.lights,ue.fog,{color:{value:new Be(0)},opacity:{value:1}}]),vertexShader:Oe.shadow_vert,fragmentShader:Oe.shadow_frag}};tn.physical={uniforms:Pt([tn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ie},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ie},clearcoatNormalScale:{value:new Re(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ie},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ie},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ie},sheen:{value:0},sheenColor:{value:new Be(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ie},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ie},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ie},transmissionSamplerSize:{value:new Re},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ie},attenuationDistance:{value:0},attenuationColor:{value:new Be(0)},specularColor:{value:new Be(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ie},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ie},anisotropyVector:{value:new Re},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ie}}]),vertexShader:Oe.meshphysical_vert,fragmentShader:Oe.meshphysical_frag};const Ms={r:0,b:0,g:0},xf=new ot,Gl=new Ie;Gl.set(-1,0,0,0,1,0,0,0,1);function vf(i,e,t,n,s,r){const a=new Be(0);let o=s===!0?0:1,c,l,f=null,m=0,h=null;function _(T){let R=T.isScene===!0?T.background:null;if(R&&R.isTexture){const M=T.backgroundBlurriness>0;R=e.get(R,M)}return R}function v(T){let R=!1;const M=_(T);M===null?p(a,o):M&&M.isColor&&(p(M,1),R=!0);const A=i.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(T,R){const M=_(R);M&&(M.isCubeTexture||M.mapping===Gs)?(l===void 0&&(l=new Kt(new Yi(1,1,1),new hn({name:"BackgroundCubeMaterial",uniforms:Ri(tn.backgroundCube.uniforms),vertexShader:tn.backgroundCube.vertexShader,fragmentShader:tn.backgroundCube.fragmentShader,side:It,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(A,y,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(xf.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Gl),l.material.toneMapped=Xe.getTransfer(M.colorSpace)!==$e,(f!==M||m!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,f=M,m=M.version,h=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Kt(new ks(2,2),new hn({name:"BackgroundMaterial",uniforms:Ri(tn.background.uniforms),vertexShader:tn.background.vertexShader,fragmentShader:tn.background.fragmentShader,side:Nn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.toneMapped=Xe.getTransfer(M.colorSpace)!==$e,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||m!==M.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,f=M,m=M.version,h=i.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function p(T,R){T.getRGB(Ms,Fl(i)),t.buffers.color.setClear(Ms.r,Ms.g,Ms.b,R,r)}function u(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(T,R=1){a.set(T),o=R,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(T){o=T,p(a,o)},render:v,addToRenderList:S,dispose:u}}function Mf(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null);let r=s,a=!1;function o(P,O,Y,K,z){let X=!1;const H=m(P,K,Y,O);r!==H&&(r=H,l(r.object)),X=_(P,K,Y,z),X&&v(P,K,Y,z),z!==null&&e.update(z,i.ELEMENT_ARRAY_BUFFER),(X||a)&&(a=!1,M(P,O,Y,K),z!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(z).buffer))}function c(){return i.createVertexArray()}function l(P){return i.bindVertexArray(P)}function f(P){return i.deleteVertexArray(P)}function m(P,O,Y,K){const z=K.wireframe===!0;let X=n[O.id];X===void 0&&(X={},n[O.id]=X);const H=P.isInstancedMesh===!0?P.id:0;let J=X[H];J===void 0&&(J={},X[H]=J);let j=J[Y.id];j===void 0&&(j={},J[Y.id]=j);let re=j[z];return re===void 0&&(re=h(c()),j[z]=re),re}function h(P){const O=[],Y=[],K=[];for(let z=0;z=0){const ae=z[j];let ge=X[j];if(ge===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(ge=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(ge=P.instanceColor)),ae===void 0||ae.attribute!==ge||ge&&ae.data!==ge.data)return!0;H++}return r.attributesNum!==H||r.index!==K}function v(P,O,Y,K){const z={},X=O.attributes;let H=0;const J=Y.getAttributes();for(const j in J)if(J[j].location>=0){let ae=X[j];ae===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(ae=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(ae=P.instanceColor));const ge={};ge.attribute=ae,ae&&ae.data&&(ge.data=ae.data),z[j]=ge,H++}r.attributes=z,r.attributesNum=H,r.index=K}function S(){const P=r.newAttributes;for(let O=0,Y=P.length;O=0){let re=z[J];if(re===void 0&&(J==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),J==="instanceColor"&&P.instanceColor&&(re=P.instanceColor)),re!==void 0){const ae=re.normalized,ge=re.itemSize,ke=e.get(re);if(ke===void 0)continue;const nt=ke.buffer,Ye=ke.type,q=ke.bytesPerElement,ne=Ye===i.INT||Ye===i.UNSIGNED_INT||re.gpuType===ba;if(re.isInterleavedBufferAttribute){const ee=re.data,De=ee.stride,Le=re.offset;if(ee.isInstancedInterleavedBuffer){for(let we=0;we0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const f=c(l);f!==l&&(Pe("WebGLRenderer:",l,"not supported, using",f,"instead."),l=f);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Pe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const _=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),A=i.getParameter(i.MAX_SAMPLES),y=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:_,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:p,maxAttributes:u,maxVertexUniforms:T,maxVaryings:R,maxFragmentUniforms:M,maxSamples:A,samples:y}}function yf(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Dn,o=new Ie,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const _=m.length!==0||h||n!==0||s;return s=h,n=m.length,_},this.beginShadows=function(){r=!0,f(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(m,h){t=f(m,h,0)},this.setState=function(m,h,_){const v=m.clippingPlanes,S=m.clipIntersection,p=m.clipShadows,u=i.get(m);if(!s||v===null||v.length===0||r&&!p)r?f(null):l();else{const T=r?0:n,R=T*4;let M=u.clippingState||null;c.value=M,M=f(v,h,R,_);for(let A=0;A!==R;++A)M[A]=t[A];u.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function f(m,h,_,v){const S=m!==null?m.length:0;let p=null;if(S!==0){if(p=c.value,v!==!0||p===null){const u=_+S*4,T=h.matrixWorldInverse;o.getNormalMatrix(T),(p===null||p.length0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ko(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ho(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),m.setRenderTarget(s),u&&m.render(S,c),m.render(e,c)}m.toneMapping=_,m.autoClear=h,e.background=T}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Zn||e.mapping===Ti;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ko()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ho());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;gi(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Bi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rv-In?n-v+In:0),u=4*(this._cubeSize-S);c.envMap.value=e.texture,c.roughness.value=_,c.mipInt.value=v-t,gi(r,p,u,3*S,2*S),s.setRenderTarget(r),s.render(o,Bi),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=v-n,gi(e,p,u,3*S,2*S),s.setRenderTarget(e),s.render(o,Bi)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&We("blur direction must be either latitudinal or longitudinal!");const f=3,m=this._lodMeshes[s];m.material=l;const h=l.uniforms,_=this._sizeLods[n]-1,v=isFinite(r)?Math.PI/(2*_):2*Math.PI/(2*Xn-1),S=r/v,p=isFinite(r)?1+Math.floor(f*S):Xn;p>Xn&&Pe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Xn}`);const u=[];let T=0;for(let w=0;wR-In?s-R+In:0),y=4*(this._cubeSize-M);gi(t,A,y,3*M,2*M),c.setRenderTarget(t),c.render(m,Bi)}}function Af(i){const e=[],t=[],n=[];let s=i;const r=i-In+1+Bo.length;for(let a=0;ai-In?c=Bo[a-i+In-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),f=-l,m=1+l,h=[f,f,m,f,m,m,f,f,m,m,f,m],_=6,v=6,S=3,p=2,u=1,T=new Float32Array(S*v*_),R=new Float32Array(p*v*_),M=new Float32Array(u*v*_);for(let y=0;y<_;y++){const w=y%3*2/3-1,g=y>2?0:-1,b=[w,g,0,w+2/3,g,0,w+2/3,g+1,0,w,g,0,w+2/3,g+1,0,w,g+1,0];T.set(b,S*v*y),R.set(h,p*v*y);const U=[y,y,y,y,y,y];M.set(U,u*v*y)}const A=new Ut;A.setAttribute("position",new Zt(T,S)),A.setAttribute("uv",new Zt(R,p)),A.setAttribute("faceIndex",new Zt(M,u)),n.push(new Kt(A,null)),s>In&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Vo(i,e,t){const n=new ln(i,e,t);return n.texture.mapping=Gs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function gi(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function Rf(i,e,t){return new hn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:bf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ws(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:gn,depthTest:!1,depthWrite:!1})}function wf(i,e,t){const n=new Float32Array(Xn),s=new I(0,1,0);return new hn({name:"SphericalGaussianBlur",defines:{n:Xn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ws(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:gn,depthTest:!1,depthWrite:!1})}function Ho(){return new hn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ws(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:gn,depthTest:!1,depthWrite:!1})}function ko(){return new hn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ws(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:gn,depthTest:!1,depthWrite:!1})}function Ws(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Vl extends ln{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Ul(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Yi(5,5,5),r=new hn({name:"CubemapFromEquirect",uniforms:Ri(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:It,blending:gn});r.uniforms.tEquirect.value=t;const a=new Kt(s,r),o=t.minFilter;return t.minFilter===Yn&&(t.minFilter=Rt),new Dh(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function Cf(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,_=!1){return h==null?null:_?a(h):r(h)}function r(h){if(h&&h.isTexture){const _=h.mapping;if(_===Zs||_===Ks)if(e.has(h)){const v=e.get(h).texture;return o(v,h.mapping)}else{const v=h.image;if(v&&v.height>0){const S=new Vl(v.height);return S.fromEquirectangularTexture(i,h),e.set(h,S),h.addEventListener("dispose",l),o(S.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const _=h.mapping,v=_===Zs||_===Ks,S=_===Zn||_===Ti;if(v||S){let p=t.get(h);const u=p!==void 0?p.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==u)return n===null&&(n=new Go(i)),p=v?n.fromEquirectangular(h,p):n.fromCubemap(h,p),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),p.texture;if(p!==void 0)return p.texture;{const T=h.image;return v&&T&&T.height>0||S&&T&&c(T)?(n===null&&(n=new Go(i)),p=v?n.fromEquirectangular(h):n.fromCubemap(h),p.texture.pmremVersion=h.pmremVersion,t.set(h,p),h.addEventListener("dispose",f),p.texture):null}}}return h}function o(h,_){return _===Zs?h.mapping=Zn:_===Ks&&(h.mapping=Ti),h}function c(h){let _=0;const v=6;for(let S=0;S=65535?Pl:Cl)(h,1);p.version=S;const u=r.get(m);u&&e.remove(u),r.set(m,p)}function f(m){const h=r.get(m);if(h){const _=m.index;_!==null&&h.version<_.version&&l(m)}else l(m);return r.get(m)}return{get:o,update:c,getWireframeAttribute:f}}function Lf(i,e,t){let n;function s(m){n=m}let r,a;function o(m){r=m.type,a=m.bytesPerElement}function c(m,h){i.drawElements(n,h,r,m*a),t.update(h,n,1)}function l(m,h,_){_!==0&&(i.drawElementsInstanced(n,h,r,m*a,_),t.update(h,n,_))}function f(m,h,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,h,0,r,m,0,_);let S=0;for(let p=0;p<_;p++)S+=h[p];t.update(S,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=f}function If(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:We("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Uf(i,e,t){const n=new WeakMap,s=new ct;function r(a,o,c){const l=a.morphTargetInfluences,f=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,m=f!==void 0?f.length:0;let h=n.get(o);if(h===void 0||h.count!==m){let b=function(){w.dispose(),n.delete(o),o.removeEventListener("dispose",b)};h!==void 0&&h.texture.dispose();const _=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],T=o.morphAttributes.color||[];let R=0;_===!0&&(R=1),v===!0&&(R=2),S===!0&&(R=3);let M=o.attributes.position.count*R,A=1;M>e.maxTextureSize&&(A=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const y=new Float32Array(M*A*4*m),w=new Rl(y,M,A,m);w.type=rn,w.needsUpdate=!0;const g=R*4;for(let U=0;U + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),f=new Kt(c,l),m=new Ba(-1,1,1,-1,0,1);let h=null,_=null,v=!1,S,p=null,u=[],T=!1;this.setSize=function(R,M){a.setSize(R,M),o.setSize(R,M);for(let A=0;A0&&u[0].isRenderPass===!0;const M=a.width,A=a.height;for(let y=0;y0)return i;const s=e*t;let r=Wo[s];if(r===void 0&&(r=new Float32Array(s),Wo[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function vt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function $o(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const wp=37297;let Cp=0;function Pp(i,e){const t=i.split(` +`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return n.join(` +`)}const Jo=new Ie;function Dp(i){Xe._getMatrix(Jo,Xe.workingColorSpace,i);const e=`mat3( ${Jo.elements.map(t=>t.toFixed(4))} )`;switch(Xe.getTransfer(i)){case Is:return[e,"LinearTransferOETF"];case $e:return[e,"sRGBTransferOETF"];default:return Pe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Qo(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+Pp(i.getShaderSource(e),o)}else return r}function Lp(i,e){const t=Dp(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const Ip={[ul]:"Linear",[dl]:"Reinhard",[fl]:"Cineon",[pl]:"ACESFilmic",[_l]:"AgX",[gl]:"Neutral",[ml]:"Custom"};function Up(i,e){const t=Ip[e];return t===void 0?(Pe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ss=new I;function Np(){Xe.getLuminanceCoefficients(Ss);const i=Ss.x.toFixed(4),e=Ss.y.toFixed(4),t=Ss.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Fp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hi).join(` +`)}function Op(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function Bp(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Ea(i){return i.replace(zp,Vp)}const Gp=new Map;function Vp(i,e){let t=Oe[e];if(t===void 0){const n=Gp.get(e);if(n!==void 0)t=Oe[n],Pe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ea(t)}const Hp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function tl(i){return i.replace(Hp,kp)}function kp(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(p+=` +`),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Hi).join(` +`),u.length>0&&(u+=` +`)):(p=[nl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+f:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Hi).join(` +`),u=[nl(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+f:"",t.envMap?"#define "+m:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==on?"#define TONE_MAPPING":"",t.toneMapping!==on?Oe.tonemapping_pars_fragment:"",t.toneMapping!==on?Up("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Oe.colorspace_pars_fragment,Lp("linearToOutputTexel",t.outputColorSpace),Np(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(Hi).join(` +`)),a=Ea(a),a=jo(a,t),a=el(a,t),o=Ea(o),o=jo(o,t),o=el(o,t),a=tl(a),o=tl(o),t.isRawShaderMaterial!==!0&&(T=`#version 300 es +`,p=[_,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+p,u=["#define varying in",t.glslVersion===ro?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ro?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+u);const R=T+p+a,M=T+u+o,A=$o(s,s.VERTEX_SHADER,R),y=$o(s,s.FRAGMENT_SHADER,M);s.attachShader(S,A),s.attachShader(S,y),t.index0AttributeName!==void 0?s.bindAttribLocation(S,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(S,0,"position"),s.linkProgram(S);function w(P){if(i.debug.checkShaderErrors){const O=s.getProgramInfoLog(S)||"",Y=s.getShaderInfoLog(A)||"",K=s.getShaderInfoLog(y)||"",z=O.trim(),X=Y.trim(),H=K.trim();let J=!0,j=!0;if(s.getProgramParameter(S,s.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,S,A,y);else{const re=Qo(s,A,"vertex"),ae=Qo(s,y,"fragment");We("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(S,s.VALIDATE_STATUS)+` + +Material Name: `+P.name+` +Material Type: `+P.type+` + +Program Info Log: `+z+` +`+re+` +`+ae)}else z!==""?Pe("WebGLProgram: Program Info Log:",z):(X===""||H==="")&&(j=!1);j&&(P.diagnostics={runnable:J,programLog:z,vertexShader:{log:X,prefix:p},fragmentShader:{log:H,prefix:u}})}s.deleteShader(A),s.deleteShader(y),g=new Cs(s,S),b=Bp(s,S)}let g;this.getUniforms=function(){return g===void 0&&w(this),g};let b;this.getAttributes=function(){return b===void 0&&w(this),b};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=s.getProgramParameter(S,wp)),U},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Cp++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=A,this.fragmentShader=y,this}let em=0;class tm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new nm(e),t.set(e,n)),n}}class nm{constructor(e){this.id=em++,this.code=e,this.usedTimes=0}}function im(i){return i===Kn||i===Ps||i===Ds}function sm(i,e,t,n,s,r){const a=new Ia,o=new tm,c=new Set,l=[],f=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(g){return c.add(g),g===0?"uv":`uv${g}`}function S(g,b,U,P,O,Y){const K=P.fog,z=O.geometry,X=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?P.environment:null,H=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,J=e.get(g.envMap||X,H),j=J&&J.mapping===Gs?J.image.height:null,re=_[g.type];g.precision!==null&&(h=n.getMaxPrecision(g.precision),h!==g.precision&&Pe("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead."));const ae=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,ge=ae!==void 0?ae.length:0;let ke=0;z.morphAttributes.position!==void 0&&(ke=1),z.morphAttributes.normal!==void 0&&(ke=2),z.morphAttributes.color!==void 0&&(ke=3);let nt,Ye,q,ne;if(re){const Me=tn[re];nt=Me.vertexShader,Ye=Me.fragmentShader}else{nt=g.vertexShader,Ye=g.fragmentShader;const Me=o.getVertexShaderStage(g),ht=o.getFragmentShaderStage(g);o.update(g,Me,ht),q=Me.id,ne=ht.id}const ee=i.getRenderTarget(),De=i.state.buffers.depth.getReversed(),Le=O.isInstancedMesh===!0,we=O.isBatchedMesh===!0,lt=!!g.map,ze=!!g.matcap,Ze=!!J,fe=!!g.aoMap,_e=!!g.lightMap,Fe=!!g.bumpMap&&g.wireframe===!1,Ve=!!g.normalMap,dt=!!g.displacementMap,ft=!!g.emissiveMap,rt=!!g.metalnessMap,at=!!g.roughnessMap,D=g.anisotropy>0,Dt=g.clearcoat>0,Ke=g.dispersion>0,E=g.iridescence>0,d=g.sheen>0,N=g.transmission>0,G=D&&!!g.anisotropyMap,k=Dt&&!!g.clearcoatMap,te=Dt&&!!g.clearcoatNormalMap,se=Dt&&!!g.clearcoatRoughnessMap,W=E&&!!g.iridescenceMap,$=E&&!!g.iridescenceThicknessMap,oe=d&&!!g.sheenColorMap,ye=d&&!!g.sheenRoughnessMap,he=!!g.specularMap,le=!!g.specularColorMap,Ae=!!g.specularIntensityMap,Ce=N&&!!g.transmissionMap,Ue=N&&!!g.thicknessMap,C=!!g.gradientMap,ie=!!g.alphaMap,Z=g.alphaTest>0,ce=!!g.alphaHash,me=!!g.extensions;let Q=on;g.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(Q=i.toneMapping);const Ee={shaderID:re,shaderType:g.type,shaderName:g.name,vertexShader:nt,fragmentShader:Ye,defines:g.defines,customVertexShaderID:q,customFragmentShaderID:ne,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:we,batchingColor:we&&O._colorsTexture!==null,instancing:Le,instancingColor:Le&&O.instanceColor!==null,instancingMorph:Le&&O.morphTexture!==null,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Xe.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:lt,matcap:ze,envMap:Ze,envMapMode:Ze&&J.mapping,envMapCubeUVHeight:j,aoMap:fe,lightMap:_e,bumpMap:Fe,normalMap:Ve,displacementMap:dt,emissiveMap:ft,normalMapObjectSpace:Ve&&g.normalMapType===Dc,normalMapTangentSpace:Ve&&g.normalMapType===ga,packedNormalMap:Ve&&g.normalMapType===ga&&im(g.normalMap.format),metalnessMap:rt,roughnessMap:at,anisotropy:D,anisotropyMap:G,clearcoat:Dt,clearcoatMap:k,clearcoatNormalMap:te,clearcoatRoughnessMap:se,dispersion:Ke,iridescence:E,iridescenceMap:W,iridescenceThicknessMap:$,sheen:d,sheenColorMap:oe,sheenRoughnessMap:ye,specularMap:he,specularColorMap:le,specularIntensityMap:Ae,transmission:N,transmissionMap:Ce,thicknessMap:Ue,gradientMap:C,opaque:g.transparent===!1&&g.blending===Si&&g.alphaToCoverage===!1,alphaMap:ie,alphaTest:Z,alphaHash:ce,combine:g.combine,mapUv:lt&&v(g.map.channel),aoMapUv:fe&&v(g.aoMap.channel),lightMapUv:_e&&v(g.lightMap.channel),bumpMapUv:Fe&&v(g.bumpMap.channel),normalMapUv:Ve&&v(g.normalMap.channel),displacementMapUv:dt&&v(g.displacementMap.channel),emissiveMapUv:ft&&v(g.emissiveMap.channel),metalnessMapUv:rt&&v(g.metalnessMap.channel),roughnessMapUv:at&&v(g.roughnessMap.channel),anisotropyMapUv:G&&v(g.anisotropyMap.channel),clearcoatMapUv:k&&v(g.clearcoatMap.channel),clearcoatNormalMapUv:te&&v(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&v(g.clearcoatRoughnessMap.channel),iridescenceMapUv:W&&v(g.iridescenceMap.channel),iridescenceThicknessMapUv:$&&v(g.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:ye&&v(g.sheenRoughnessMap.channel),specularMapUv:he&&v(g.specularMap.channel),specularColorMapUv:le&&v(g.specularColorMap.channel),specularIntensityMapUv:Ae&&v(g.specularIntensityMap.channel),transmissionMapUv:Ce&&v(g.transmissionMap.channel),thicknessMapUv:Ue&&v(g.thicknessMap.channel),alphaMapUv:ie&&v(g.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Ve||D),vertexNormals:!!z.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!z.attributes.uv&&(lt||ie),fog:!!K,useFog:g.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||z.attributes.normal===void 0&&Ve===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:De,skinning:O.isSkinnedMesh===!0,hasPositionAttribute:z.attributes.position!==void 0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:ke,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:lt&&g.map.isVideoTexture===!0&&Xe.getTransfer(g.map.colorSpace)===$e,decodeVideoTextureEmissive:ft&&g.emissiveMap.isVideoTexture===!0&&Xe.getTransfer(g.emissiveMap.colorSpace)===$e,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===nn,flipSided:g.side===It,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:me&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&g.extensions.multiDraw===!0||we)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Ee.vertexUv1s=c.has(1),Ee.vertexUv2s=c.has(2),Ee.vertexUv3s=c.has(3),c.clear(),Ee}function p(g){const b=[];if(g.shaderID?b.push(g.shaderID):(b.push(g.customVertexShaderID),b.push(g.customFragmentShaderID)),g.defines!==void 0)for(const U in g.defines)b.push(U),b.push(g.defines[U]);return g.isRawShaderMaterial===!1&&(u(b,g),T(b,g),b.push(i.outputColorSpace)),b.push(g.customProgramCacheKey),b.join()}function u(g,b){g.push(b.precision),g.push(b.outputColorSpace),g.push(b.envMapMode),g.push(b.envMapCubeUVHeight),g.push(b.mapUv),g.push(b.alphaMapUv),g.push(b.lightMapUv),g.push(b.aoMapUv),g.push(b.bumpMapUv),g.push(b.normalMapUv),g.push(b.displacementMapUv),g.push(b.emissiveMapUv),g.push(b.metalnessMapUv),g.push(b.roughnessMapUv),g.push(b.anisotropyMapUv),g.push(b.clearcoatMapUv),g.push(b.clearcoatNormalMapUv),g.push(b.clearcoatRoughnessMapUv),g.push(b.iridescenceMapUv),g.push(b.iridescenceThicknessMapUv),g.push(b.sheenColorMapUv),g.push(b.sheenRoughnessMapUv),g.push(b.specularMapUv),g.push(b.specularColorMapUv),g.push(b.specularIntensityMapUv),g.push(b.transmissionMapUv),g.push(b.thicknessMapUv),g.push(b.combine),g.push(b.fogExp2),g.push(b.sizeAttenuation),g.push(b.morphTargetsCount),g.push(b.morphAttributeCount),g.push(b.numDirLights),g.push(b.numPointLights),g.push(b.numSpotLights),g.push(b.numSpotLightMaps),g.push(b.numHemiLights),g.push(b.numRectAreaLights),g.push(b.numDirLightShadows),g.push(b.numPointLightShadows),g.push(b.numSpotLightShadows),g.push(b.numSpotLightShadowsWithMaps),g.push(b.numLightProbes),g.push(b.shadowMapType),g.push(b.toneMapping),g.push(b.numClippingPlanes),g.push(b.numClipIntersection),g.push(b.depthPacking)}function T(g,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function R(g){const b=_[g.type];let U;if(b){const P=tn[b];U=Mh.clone(P.uniforms)}else U=g.uniforms;return U}function M(g,b){let U=f.get(b);return U!==void 0?++U.usedTimes:(U=new jp(i,b,g,s),l.push(U),f.set(b,U)),U}function A(g){if(--g.usedTimes===0){const b=l.indexOf(g);l[b]=l[l.length-1],l.pop(),f.delete(g.cacheKey),g.destroy()}}function y(g){o.remove(g)}function w(){o.dispose()}return{getParameters:S,getProgramCacheKey:p,getUniforms:R,acquireProgram:M,releaseProgram:A,releaseShaderCache:y,programs:l,dispose:w}}function rm(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function am(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function il(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function sl(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(h){let _=0;return h.isInstancedMesh&&(_+=2),h.isSkinnedMesh&&(_+=1),_}function o(h,_,v,S,p,u){let T=i[e];return T===void 0?(T={id:h.id,object:h,geometry:_,material:v,materialVariant:a(h),groupOrder:S,renderOrder:h.renderOrder,z:p,group:u},i[e]=T):(T.id=h.id,T.object=h,T.geometry=_,T.material=v,T.materialVariant=a(h),T.groupOrder=S,T.renderOrder=h.renderOrder,T.z=p,T.group=u),e++,T}function c(h,_,v,S,p,u){const T=o(h,_,v,S,p,u);v.transmission>0?n.push(T):v.transparent===!0?s.push(T):t.push(T)}function l(h,_,v,S,p,u){const T=o(h,_,v,S,p,u);v.transmission>0?n.unshift(T):v.transparent===!0?s.unshift(T):t.unshift(T)}function f(h,_,v){t.length>1&&t.sort(h||am),n.length>1&&n.sort(_||il),s.length>1&&s.sort(_||il),v&&(t.reverse(),n.reverse(),s.reverse())}function m(){for(let h=e,_=i.length;h<_;h++){const v=i[h];if(v.id===null)break;v.id=null,v.object=null,v.geometry=null,v.material=null,v.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:m,sort:f}}function om(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new sl,i.set(n,[a])):s>=r.length?(a=new sl,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function lm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new I,color:new Be};break;case"SpotLight":t={position:new I,direction:new I,color:new Be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new I,color:new Be,distance:0,decay:0};break;case"HemisphereLight":t={direction:new I,skyColor:new Be,groundColor:new Be};break;case"RectAreaLight":t={color:new Be,position:new I,halfWidth:new I,halfHeight:new I};break}return i[e.id]=t,t}}}function cm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Re,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let hm=0;function um(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function dm(i){const e=new lm,t=cm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new I);const s=new I,r=new ot,a=new ot;function o(l){let f=0,m=0,h=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let _=0,v=0,S=0,p=0,u=0,T=0,R=0,M=0,A=0,y=0,w=0;l.sort(um);for(let b=0,U=l.length;b0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ue.LTC_FLOAT_1,n.rectAreaLTC2=ue.LTC_FLOAT_2):(n.rectAreaLTC1=ue.LTC_HALF_1,n.rectAreaLTC2=ue.LTC_HALF_2)),n.ambient[0]=f,n.ambient[1]=m,n.ambient[2]=h;const g=n.hash;(g.directionalLength!==_||g.pointLength!==v||g.spotLength!==S||g.rectAreaLength!==p||g.hemiLength!==u||g.numDirectionalShadows!==T||g.numPointShadows!==R||g.numSpotShadows!==M||g.numSpotMaps!==A||g.numLightProbes!==w)&&(n.directional.length=_,n.spot.length=S,n.rectArea.length=p,n.point.length=v,n.hemi.length=u,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=M+A-y,n.spotLightMap.length=A,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=w,g.directionalLength=_,g.pointLength=v,g.spotLength=S,g.rectAreaLength=p,g.hemiLength=u,g.numDirectionalShadows=T,g.numPointShadows=R,g.numSpotShadows=M,g.numSpotMaps=A,g.numLightProbes=w,n.version=hm++)}function c(l,f){let m=0,h=0,_=0,v=0,S=0;const p=f.matrixWorldInverse;for(let u=0,T=l.length;u=a.length?(o=new rl(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const pm=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,mm=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,_m=[new I(1,0,0),new I(-1,0,0),new I(0,1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1)],gm=[new I(0,-1,0),new I(0,-1,0),new I(0,0,1),new I(0,0,-1),new I(0,-1,0),new I(0,-1,0)],al=new ot,zi=new I,wr=new I;function xm(i,e,t){let n=new Na;const s=new Re,r=new Re,a=new ct,o=new Th,c=new Ah,l={},f=t.maxTextureSize,m={[Nn]:It,[It]:Nn,[nn]:nn},h=new hn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Re},radius:{value:4}},vertexShader:pm,fragmentShader:mm}),_=h.clone();_.defines.HORIZONTAL_PASS=1;const v=new Ut;v.setAttribute("position",new Zt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Kt(v,h),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ys;let u=this.type;this.render=function(y,w,g){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||y.length===0)return;this.type===lc&&(Pe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ys);const b=i.getRenderTarget(),U=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),O=i.state;O.setBlending(gn),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const Y=u!==this.type;Y&&w.traverse(function(K){K.material&&(Array.isArray(K.material)?K.material.forEach(z=>z.needsUpdate=!0):K.material.needsUpdate=!0)});for(let K=0,z=y.length;Kf||s.y>f)&&(s.x>f&&(r.x=Math.floor(f/J.x),s.x=r.x*J.x,H.mapSize.x=r.x),s.y>f&&(r.y=Math.floor(f/J.y),s.y=r.y*J.y,H.mapSize.y=r.y));const j=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=j,H.map===null||Y===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===Gi){if(X.isPointLight){Pe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new ln(s.x,s.y,{format:Kn,type:vn,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),H.map.texture.name=X.name+".shadowMap",H.map.depthTexture=new Ai(s.x,s.y,rn),H.map.depthTexture.name=X.name+".shadowMapDepth",H.map.depthTexture.format=Mn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=yt,H.map.depthTexture.magFilter=yt}else X.isPointLight?(H.map=new Vl(s.x),H.map.depthTexture=new xh(s.x,cn)):(H.map=new ln(s.x,s.y),H.map.depthTexture=new Ai(s.x,s.y,cn)),H.map.depthTexture.name=X.name+".shadowMap",H.map.depthTexture.format=Mn,this.type===ys?(H.map.depthTexture.compareFunction=j?Da:Pa,H.map.depthTexture.minFilter=Rt,H.map.depthTexture.magFilter=Rt):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=yt,H.map.depthTexture.magFilter=yt);H.camera.updateProjectionMatrix()}const re=H.map.isWebGLCubeRenderTarget?6:1;for(let ae=0;ae0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){const O=U.uuid,Y=w.uuid;let K=l[O];K===void 0&&(K={},l[O]=K);let z=K[Y];z===void 0&&(z=U.clone(),K[Y]=z,w.addEventListener("dispose",A)),U=z}if(U.visible=w.visible,U.wireframe=w.wireframe,b===Gi?U.side=w.shadowSide!==null?w.shadowSide:w.side:U.side=w.shadowSide!==null?w.shadowSide:m[w.side],U.alphaMap=w.alphaMap,U.alphaTest=w.alphaToCoverage===!0?.5:w.alphaTest,U.map=w.map,U.clipShadows=w.clipShadows,U.clippingPlanes=w.clippingPlanes,U.clipIntersection=w.clipIntersection,U.displacementMap=w.displacementMap,U.displacementScale=w.displacementScale,U.displacementBias=w.displacementBias,U.wireframeLinewidth=w.wireframeLinewidth,U.linewidth=w.linewidth,g.isPointLight===!0&&U.isMeshDistanceMaterial===!0){const O=i.properties.get(U);O.light=g}return U}function M(y,w,g,b,U){if(y.visible===!1)return;if(y.layers.test(w.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&U===Gi)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,y.matrixWorld);const Y=e.update(y),K=y.material;if(Array.isArray(K)){const z=Y.groups;for(let X=0,H=z.length;X=1):j.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),H=J>=2);let re=null,ae={};const ge=i.getParameter(i.SCISSOR_BOX),ke=i.getParameter(i.VIEWPORT),nt=new ct().fromArray(ge),Ye=new ct().fromArray(ke);function q(C,ie,Z,ce){const me=new Uint8Array(4),Q=i.createTexture();i.bindTexture(C,Q),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ee=0;Ee"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Re,f=new WeakMap,m=new Set;let h;const _=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(E,d){return v?new OffscreenCanvas(E,d):Us("canvas")}function p(E,d,N){let G=1;const k=Ke(E);if((k.width>N||k.height>N)&&(G=N/Math.max(k.width,k.height)),G<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const te=Math.floor(G*k.width),se=Math.floor(G*k.height);h===void 0&&(h=S(te,se));const W=d?S(te,se):h;return W.width=te,W.height=se,W.getContext("2d").drawImage(E,0,0,te,se),Pe("WebGLRenderer: Texture has been resized from ("+k.width+"x"+k.height+") to ("+te+"x"+se+")."),W}else return"data"in E&&Pe("WebGLRenderer: Image in DataTexture is too big ("+k.width+"x"+k.height+")."),E;return E}function u(E){return E.generateMipmaps}function T(E){i.generateMipmap(E)}function R(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(E,d,N,G,k,te=!1){if(E!==null){if(i[E]!==void 0)return i[E];Pe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let se;G&&(se=e.get("EXT_texture_norm16"),se||Pe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let W=d;if(d===i.RED&&(N===i.FLOAT&&(W=i.R32F),N===i.HALF_FLOAT&&(W=i.R16F),N===i.UNSIGNED_BYTE&&(W=i.R8),N===i.UNSIGNED_SHORT&&se&&(W=se.R16_EXT),N===i.SHORT&&se&&(W=se.R16_SNORM_EXT)),d===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.R8UI),N===i.UNSIGNED_SHORT&&(W=i.R16UI),N===i.UNSIGNED_INT&&(W=i.R32UI),N===i.BYTE&&(W=i.R8I),N===i.SHORT&&(W=i.R16I),N===i.INT&&(W=i.R32I)),d===i.RG&&(N===i.FLOAT&&(W=i.RG32F),N===i.HALF_FLOAT&&(W=i.RG16F),N===i.UNSIGNED_BYTE&&(W=i.RG8),N===i.UNSIGNED_SHORT&&se&&(W=se.RG16_EXT),N===i.SHORT&&se&&(W=se.RG16_SNORM_EXT)),d===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RG8UI),N===i.UNSIGNED_SHORT&&(W=i.RG16UI),N===i.UNSIGNED_INT&&(W=i.RG32UI),N===i.BYTE&&(W=i.RG8I),N===i.SHORT&&(W=i.RG16I),N===i.INT&&(W=i.RG32I)),d===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RGB8UI),N===i.UNSIGNED_SHORT&&(W=i.RGB16UI),N===i.UNSIGNED_INT&&(W=i.RGB32UI),N===i.BYTE&&(W=i.RGB8I),N===i.SHORT&&(W=i.RGB16I),N===i.INT&&(W=i.RGB32I)),d===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(W=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(W=i.RGBA16UI),N===i.UNSIGNED_INT&&(W=i.RGBA32UI),N===i.BYTE&&(W=i.RGBA8I),N===i.SHORT&&(W=i.RGBA16I),N===i.INT&&(W=i.RGBA32I)),d===i.RGB&&(N===i.UNSIGNED_SHORT&&se&&(W=se.RGB16_EXT),N===i.SHORT&&se&&(W=se.RGB16_SNORM_EXT),N===i.UNSIGNED_INT_5_9_9_9_REV&&(W=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(W=i.R11F_G11F_B10F)),d===i.RGBA){const $=te?Is:Xe.getTransfer(k);N===i.FLOAT&&(W=i.RGBA32F),N===i.HALF_FLOAT&&(W=i.RGBA16F),N===i.UNSIGNED_BYTE&&(W=$===$e?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT&&se&&(W=se.RGBA16_EXT),N===i.SHORT&&se&&(W=se.RGBA16_SNORM_EXT),N===i.UNSIGNED_SHORT_4_4_4_4&&(W=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(W=i.RGB5_A1)}return(W===i.R16F||W===i.R32F||W===i.RG16F||W===i.RG32F||W===i.RGBA16F||W===i.RGBA32F)&&e.get("EXT_color_buffer_float"),W}function A(E,d){let N;return E?d===null||d===cn||d===Wi?N=i.DEPTH24_STENCIL8:d===rn?N=i.DEPTH32F_STENCIL8:d===ki&&(N=i.DEPTH24_STENCIL8,Pe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):d===null||d===cn||d===Wi?N=i.DEPTH_COMPONENT24:d===rn?N=i.DEPTH_COMPONENT32F:d===ki&&(N=i.DEPTH_COMPONENT16),N}function y(E,d){return u(E)===!0||E.isFramebufferTexture&&E.minFilter!==yt&&E.minFilter!==Rt?Math.log2(Math.max(d.width,d.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?d.mipmaps.length:1}function w(E){const d=E.target;d.removeEventListener("dispose",w),b(d),d.isVideoTexture&&f.delete(d),d.isHTMLTexture&&m.delete(d)}function g(E){const d=E.target;d.removeEventListener("dispose",g),P(d)}function b(E){const d=n.get(E);if(d.__webglInit===void 0)return;const N=E.source,G=_.get(N);if(G){const k=G[d.__cacheKey];k.usedTimes--,k.usedTimes===0&&U(E),Object.keys(G).length===0&&_.delete(N)}n.remove(E)}function U(E){const d=n.get(E);i.deleteTexture(d.__webglTexture);const N=E.source,G=_.get(N);delete G[d.__cacheKey],a.memory.textures--}function P(E){const d=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(d.__webglFramebuffer[G]))for(let k=0;k=s.maxTextures&&Pe("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),O+=1,E}function H(E){const d=[];return d.push(E.wrapS),d.push(E.wrapT),d.push(E.wrapR||0),d.push(E.magFilter),d.push(E.minFilter),d.push(E.anisotropy),d.push(E.internalFormat),d.push(E.format),d.push(E.type),d.push(E.generateMipmaps),d.push(E.premultiplyAlpha),d.push(E.flipY),d.push(E.unpackAlignment),d.push(E.colorSpace),d.join()}function J(E,d){const N=n.get(E);if(E.isVideoTexture&&D(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){const G=E.image;if(G===null)Pe("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Pe("WebGLRenderer: Texture marked for update but image is incomplete");else{De(N,E,d);return}}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+d)}function j(E,d){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){De(N,E,d);return}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+d)}function re(E,d){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){De(N,E,d);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+d)}function ae(E,d){const N=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Le(N,E,d);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+d)}const ge={[zr]:i.REPEAT,[_n]:i.CLAMP_TO_EDGE,[Gr]:i.MIRRORED_REPEAT},ke={[yt]:i.NEAREST,[Cc]:i.NEAREST_MIPMAP_NEAREST,[Ki]:i.NEAREST_MIPMAP_LINEAR,[Rt]:i.LINEAR,[$s]:i.LINEAR_MIPMAP_NEAREST,[Yn]:i.LINEAR_MIPMAP_LINEAR},nt={[Lc]:i.NEVER,[Oc]:i.ALWAYS,[Ic]:i.LESS,[Pa]:i.LEQUAL,[Uc]:i.EQUAL,[Da]:i.GEQUAL,[Nc]:i.GREATER,[Fc]:i.NOTEQUAL};function Ye(E,d){if(d.type===rn&&e.has("OES_texture_float_linear")===!1&&(d.magFilter===Rt||d.magFilter===$s||d.magFilter===Ki||d.magFilter===Yn||d.minFilter===Rt||d.minFilter===$s||d.minFilter===Ki||d.minFilter===Yn)&&Pe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,ge[d.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,ge[d.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,ge[d.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,ke[d.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,ke[d.minFilter]),d.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,nt[d.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(d.magFilter===yt||d.minFilter!==Ki&&d.minFilter!==Yn||d.type===rn&&e.has("OES_texture_float_linear")===!1)return;if(d.anisotropy>1||n.get(d).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(d.anisotropy,s.getMaxAnisotropy())),n.get(d).__currentAnisotropy=d.anisotropy}}}function q(E,d){let N=!1;E.__webglInit===void 0&&(E.__webglInit=!0,d.addEventListener("dispose",w));const G=d.source;let k=_.get(G);k===void 0&&(k={},_.set(G,k));const te=H(d);if(te!==E.__cacheKey){k[te]===void 0&&(k[te]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),k[te].usedTimes++;const se=k[E.__cacheKey];se!==void 0&&(k[E.__cacheKey].usedTimes--,se.usedTimes===0&&U(d)),E.__cacheKey=te,E.__webglTexture=k[te].texture}return N}function ne(E,d,N){return Math.floor(Math.floor(E/N)/d)}function ee(E,d,N,G){const te=E.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,d.width,d.height,N,G,d.data);else{te.sort((ye,he)=>ye.start-he.start);let se=0;for(let ye=1;ye0){Ce&&Ue&&t.texStorage2D(i.TEXTURE_2D,ie,he,Ae[0].width,Ae[0].height);for(let Z=0,ce=Ae.length;Z0){const me=Oo(le.width,le.height,d.format,d.type);for(const Q of d.layerUpdates){const Ee=le.data.subarray(Q*me/le.data.BYTES_PER_ELEMENT,(Q+1)*me/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,Q,le.width,le.height,1,oe,Ee)}d.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,le.width,le.height,$.depth,oe,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,he,le.width,le.height,$.depth,0,le.data,0,0);else Pe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ce?C&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,le.width,le.height,$.depth,oe,ye,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,he,le.width,le.height,$.depth,0,oe,ye,le.data)}else{Ce&&Ue&&t.texStorage2D(i.TEXTURE_2D,ie,he,Ae[0].width,Ae[0].height);for(let Z=0,ce=Ae.length;Z0){const Z=Oo($.width,$.height,d.format,d.type);for(const ce of d.layerUpdates){const me=$.data.subarray(ce*Z/$.data.BYTES_PER_ELEMENT,(ce+1)*Z/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ce,$.width,$.height,1,oe,ye,me)}d.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,oe,ye,$.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,he,$.width,$.height,$.depth,0,oe,ye,$.data);else if(d.isData3DTexture)Ce?(Ue&&t.texStorage3D(i.TEXTURE_3D,ie,he,$.width,$.height,$.depth),C&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,oe,ye,$.data)):t.texImage3D(i.TEXTURE_3D,0,he,$.width,$.height,$.depth,0,oe,ye,$.data);else if(d.isFramebufferTexture){if(Ue)if(Ce)t.texStorage2D(i.TEXTURE_2D,ie,he,$.width,$.height);else{let Z=$.width,ce=$.height;for(let me=0;me>=1,ce>>=1}}else if(d.isHTMLTexture){if("texElementImage2D"in i){const Z=i.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),$.parentNode!==Z){Z.appendChild($),m.add(d),Z.onpaint=ce=>{const me=ce.changedElements;for(const Q of m)me.includes(Q.image)&&(Q.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,$);else{const me=i.RGBA,Q=i.RGBA,Ee=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,Q,Ee,$)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ae.length>0){if(Ce&&Ue){const Z=Ke(Ae[0]);t.texStorage2D(i.TEXTURE_2D,ie,he,Z.width,Z.height)}for(let Z=0,ce=Ae.length;Z0&&ce++;const Q=Ke(he[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ce,Ue,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(ye){C?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,he[Q].width,he[Q].height,Ae,Ce,he[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Ue,he[Q].width,he[Q].height,0,Ae,Ce,he[Q].data);for(let Ee=0;Ee>te),le=Math.max(1,d.height>>te);k===i.TEXTURE_3D||k===i.TEXTURE_2D_ARRAY?t.texImage3D(k,te,$,he,le,d.depth,0,se,W,null):t.texImage2D(k,te,$,he,le,0,se,W,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),at(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,k,ye.__webglTexture,0,rt(d)):(k===i.TEXTURE_2D||k>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&k<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,k,ye.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function lt(E,d,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),d.depthBuffer){const G=d.depthTexture,k=G&&G.isDepthTexture?G.type:null,te=A(d.stencilBuffer,k),se=d.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;at(d)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rt(d),te,d.width,d.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,rt(d),te,d.width,d.height):i.renderbufferStorage(i.RENDERBUFFER,te,d.width,d.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,E)}else{const G=d.textures;for(let k=0;k{delete d.__boundDepthTexture,delete d.__depthDisposeCallback,G.removeEventListener("dispose",k)};G.addEventListener("dispose",k),d.__depthDisposeCallback=k}d.__boundDepthTexture=G}if(E.depthTexture&&!d.__autoAllocateDepthBuffer)if(N)for(let G=0;G<6;G++)ze(d.__webglFramebuffer[G],E,G);else{const G=E.texture.mipmaps;G&&G.length>0?ze(d.__webglFramebuffer[0],E,0):ze(d.__webglFramebuffer,E,0)}else if(N){d.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[G]),d.__webglDepthbuffer[G]===void 0)d.__webglDepthbuffer[G]=i.createRenderbuffer(),lt(d.__webglDepthbuffer[G],E,!1);else{const k=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}else{const G=E.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,d.__webglFramebuffer),d.__webglDepthbuffer===void 0)d.__webglDepthbuffer=i.createRenderbuffer(),lt(d.__webglDepthbuffer,E,!1);else{const k=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=d.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function fe(E,d,N){const G=n.get(E);d!==void 0&&we(G.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&Ze(E)}function _e(E){const d=E.texture,N=n.get(E),G=n.get(d);E.addEventListener("dispose",g);const k=E.textures,te=E.isWebGLCubeRenderTarget===!0,se=k.length>1;if(se||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=d.version,a.memory.textures++),te){N.__webglFramebuffer=[];for(let W=0;W<6;W++)if(d.mipmaps&&d.mipmaps.length>0){N.__webglFramebuffer[W]=[];for(let $=0;$0){N.__webglFramebuffer=[];for(let W=0;W0&&at(E)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let W=0;W0)for(let $=0;$0)for(let $=0;$0){if(at(E)===!1){const d=E.textures,N=E.width,G=E.height;let k=i.COLOR_BUFFER_BIT;const te=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=n.get(E),W=d.length>1;if(W)for(let oe=0;oe0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer);for(let oe=0;oe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&d.__useRenderToTexture!==!1}function D(E){const d=a.render.frame;f.get(E)!==d&&(f.set(E,d),E.update())}function Dt(E,d){const N=E.colorSpace,G=E.format,k=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Ls&&N!==Ln&&(Xe.getTransfer(N)===$e?(G!==qt||k!==Bt)&&Pe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",N)),d}function Ke(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=X,this.resetTextureUnits=Y,this.getTextureUnits=K,this.setTextureUnits=z,this.setTexture2D=J,this.setTexture2DArray=j,this.setTexture3D=re,this.setTextureCube=ae,this.rebindTextures=fe,this.setupRenderTarget=_e,this.updateRenderTargetMipmap=Fe,this.updateMultisampleRenderTarget=ft,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=we,this.useMultisampledRTT=at,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Sm(i,e){function t(n,s=Ln){let r;const a=Xe.getTransfer(s);if(n===Bt)return i.UNSIGNED_BYTE;if(n===Ta)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Aa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Sl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===El)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===vl)return i.BYTE;if(n===Ml)return i.SHORT;if(n===ki)return i.UNSIGNED_SHORT;if(n===ba)return i.INT;if(n===cn)return i.UNSIGNED_INT;if(n===rn)return i.FLOAT;if(n===vn)return i.HALF_FLOAT;if(n===yl)return i.ALPHA;if(n===bl)return i.RGB;if(n===qt)return i.RGBA;if(n===Mn)return i.DEPTH_COMPONENT;if(n===qn)return i.DEPTH_STENCIL;if(n===Tl)return i.RED;if(n===Ra)return i.RED_INTEGER;if(n===Kn)return i.RG;if(n===wa)return i.RG_INTEGER;if(n===Ca)return i.RGBA_INTEGER;if(n===bs||n===Ts||n===As||n===Rs)if(a===$e)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===bs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ts)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===As)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Rs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===bs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ts)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===As)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Rs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Vr||n===Hr||n===kr||n===Wr)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Vr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Hr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===kr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Wr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Xr||n===Yr||n===qr||n===Zr||n===Kr||n===Ps||n===$r)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Xr||n===Yr)return a===$e?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===qr)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Zr)return r.COMPRESSED_R11_EAC;if(n===Kr)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ps)return r.COMPRESSED_RG11_EAC;if(n===$r)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Jr||n===Qr||n===jr||n===ea||n===ta||n===na||n===ia||n===sa||n===ra||n===aa||n===oa||n===la||n===ca||n===ha)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Jr)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Qr)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===jr)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ea)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ta)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===na)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ia)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sa)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ra)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===aa)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===oa)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===la)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ca)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ha)return a===$e?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ua||n===da||n===fa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ua)return a===$e?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===da)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===pa||n===ma||n===Ds||n===_a)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===pa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ma)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ds)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===_a)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Wi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Em=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,ym=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class bm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Nl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new hn({vertexShader:Em,fragmentShader:ym,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kt(new ks(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Tm extends Bn{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,f=null,m=null,h=null,_=null,v=null;const S=typeof XRWebGLBinding<"u",p=new bm,u={},T=t.getContextAttributes();let R=null,M=null;const A=[],y=[],w=new Re;let g=null;const b=new Ht;b.viewport=new ct;const U=new Ht;U.viewport=new ct;const P=[b,U],O=new Lh;let Y=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ne=A[q];return ne===void 0&&(ne=new ir,A[q]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(q){let ne=A[q];return ne===void 0&&(ne=new ir,A[q]=ne),ne.getGripSpace()},this.getHand=function(q){let ne=A[q];return ne===void 0&&(ne=new ir,A[q]=ne),ne.getHandSpace()};function z(q){const ne=y.indexOf(q.inputSource);if(ne===-1)return;const ee=A[ne];ee!==void 0&&(ee.update(q.inputSource,q.frame,l||a),ee.dispatchEvent({type:q.type,data:q.inputSource}))}function X(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",X),s.removeEventListener("inputsourceschange",H);for(let q=0;q=0&&(y[De]=null,A[De].disconnect(ee))}for(let ne=0;ne=y.length){y.push(ee),De=we;break}else if(y[we]===null){y[we]=ee,De=we;break}if(De===-1)break}const Le=A[De];Le&&Le.connect(ee)}}const J=new I,j=new I;function re(q,ne,ee){J.setFromMatrixPosition(ne.matrixWorld),j.setFromMatrixPosition(ee.matrixWorld);const De=J.distanceTo(j),Le=ne.projectionMatrix.elements,we=ee.projectionMatrix.elements,lt=Le[14]/(Le[10]-1),ze=Le[14]/(Le[10]+1),Ze=(Le[9]+1)/Le[5],fe=(Le[9]-1)/Le[5],_e=(Le[8]-1)/Le[0],Fe=(we[8]+1)/we[0],Ve=lt*_e,dt=lt*Fe,ft=De/(-_e+Fe),rt=ft*-_e;if(ne.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(rt),q.translateZ(ft),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Le[10]===-1)q.projectionMatrix.copy(ne.projectionMatrix),q.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const at=lt+ft,D=ze+ft,Dt=Ve-rt,Ke=dt+(De-rt),E=Ze*ze/D*at,d=fe*ze/D*at;q.projectionMatrix.makePerspective(Dt,Ke,E,d,at,D),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function ae(q,ne){ne===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(ne.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let ne=q.near,ee=q.far;p.texture!==null&&(p.depthNear>0&&(ne=p.depthNear),p.depthFar>0&&(ee=p.depthFar)),O.near=U.near=b.near=ne,O.far=U.far=b.far=ee,(Y!==O.near||K!==O.far)&&(s.updateRenderState({depthNear:O.near,depthFar:O.far}),Y=O.near,K=O.far),O.layers.mask=q.layers.mask|6,b.layers.mask=O.layers.mask&-5,U.layers.mask=O.layers.mask&-3;const De=q.parent,Le=O.cameras;ae(O,De);for(let we=0;we0&&(p.alphaTest.value=u.alphaTest);const T=e.get(u),R=T.envMap,M=T.envMapRotation;R&&(p.envMap.value=R,p.envMapRotation.value.setFromMatrix4(Am.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(Yl),p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap&&(p.lightMap.value=u.lightMap,p.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,p.lightMapTransform)),u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function c(p,u,T,R){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*T,p.scale.value=R*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function l(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function f(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function m(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function h(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),u.envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function _(p,u,T){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===It&&p.clearcoatNormalScale.value.negate())),u.dispersion>0&&(p.dispersion.value=u.dispersion),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=T.texture,p.transmissionSamplerSize.value.set(T.width,T.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,u){u.matcap&&(p.matcap.value=u.matcap)}function S(p,u){const T=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(T.matrixWorld),p.nearDistance.value=T.shadow.camera.near,p.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function wm(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,A){const y=A.program;n.uniformBlockBinding(M,y)}function l(M,A){let y=s[M.id];y===void 0&&(p(M),y=f(M),s[M.id]=y,M.addEventListener("dispose",T));const w=A.program;n.updateUBOMapping(M,w);const g=e.render.frame;r[M.id]!==g&&(h(M),r[M.id]=g)}function f(M){const A=m();M.__bindingPointIndex=A;const y=i.createBuffer(),w=M.__size,g=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,w,g),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,A,y),y}function m(){for(let M=0;M0&&(y+=w-g),M.__size=y,M.__cache={},this}function u(M){const A={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(A.boundary=4,A.storage=4):M.isVector2?(A.boundary=8,A.storage=8):M.isVector3||M.isColor?(A.boundary=16,A.storage=12):M.isVector4?(A.boundary=16,A.storage=16):M.isMatrix3?(A.boundary=48,A.storage=48):M.isMatrix4?(A.boundary=64,A.storage=64):M.isTexture?Pe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(A.boundary=16,A.storage=M.byteLength):Pe("WebGLRenderer: Unsupported uniform value type.",M),A}function T(M){const A=M.target;A.removeEventListener("dispose",T);const y=a.indexOf(A.__bindingPointIndex);a.splice(y,1),i.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function R(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:R}}const Cm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let en=null;function Pm(){return en===null&&(en=new uh(Cm,16,16,Kn,vn),en.name="DFG_LUT",en.minFilter=Rt,en.magFilter=Rt,en.wrapS=_n,en.wrapT=_n,en.generateMipmaps=!1,en.needsUpdate=!0),en}class Dm{constructor(e={}){const{canvas:t=zc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:f="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:_=Bt}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const S=_,p=new Set([Ca,wa,Ra]),u=new Set([Bt,cn,ki,Wi,Ta,Aa]),T=new Uint32Array(4),R=new Int32Array(4),M=new I;let A=null,y=null;const w=[],g=[];let b=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=on,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const U=this;let P=!1,O=null,Y=null,K=null,z=null;this._outputColorSpace=Vt;let X=0,H=0,J=null,j=-1,re=null;const ae=new ct,ge=new ct;let ke=null;const nt=new Be(0);let Ye=0,q=t.width,ne=t.height,ee=1,De=null,Le=null;const we=new ct(0,0,q,ne),lt=new ct(0,0,q,ne);let ze=!1;const Ze=new Na;let fe=!1,_e=!1;const Fe=new ot,Ve=new I,dt=new ct,ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let rt=!1;function at(){return J===null?ee:1}let D=n;function Dt(x,L){return t.getContext(x,L)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:f,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ya}`),t.addEventListener("webglcontextlost",ht,!1),t.addEventListener("webglcontextrestored",it,!1),t.addEventListener("webglcontextcreationerror",$t,!1),D===null){const L="webgl2";if(D=Dt(L,x),D===null)throw Dt(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw We("WebGLRenderer: "+x.message),x}let Ke,E,d,N,G,k,te,se,W,$,oe,ye,he,le,Ae,Ce,Ue,C,ie,Z,ce,me,Q;function Ee(){Ke=new Pf(D),Ke.init(),ce=new Sm(D,Ke),E=new Ef(D,Ke,e,ce),d=new vm(D,Ke),E.reversedDepthBuffer&&h&&d.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),K=D.createFramebuffer(),z=D.createFramebuffer(),N=new If(D),G=new rm,k=new Mm(D,Ke,d,G,E,ce,N),te=new Cf(U),se=new Fh(D),me=new Mf(D,se),W=new Df(D,se,N,me),$=new Nf(D,W,se,me,N),C=new Uf(D,E,k),Ae=new yf(G),oe=new sm(U,te,Ke,E,me,Ae),ye=new Rm(U,G),he=new om,le=new fm(Ke),Ue=new vf(U,te,d,$,v,c),Ce=new xm(U,$,E),Q=new wm(D,N,E,d),ie=new Sf(D,Ke,N),Z=new Lf(D,Ke,N),N.programs=oe.programs,U.capabilities=E,U.extensions=Ke,U.properties=G,U.renderLists=he,U.shadowMap=Ce,U.state=d,U.info=N}Ee(),S!==Bt&&(b=new Of(S,t.width,t.height,o,s,r));const Me=new Tm(U,D);this.xr=Me,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const x=Ke.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ke.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(x){x!==void 0&&(ee=x,this.setSize(q,ne,!1))},this.getSize=function(x){return x.set(q,ne)},this.setSize=function(x,L,V=!0){if(Me.isPresenting){Pe("WebGLRenderer: Can't change size while VR device is presenting.");return}q=x,ne=L,t.width=Math.floor(x*ee),t.height=Math.floor(L*ee),V===!0&&(t.style.width=x+"px",t.style.height=L+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,x,L)},this.getDrawingBufferSize=function(x){return x.set(q*ee,ne*ee).floor()},this.setDrawingBufferSize=function(x,L,V){q=x,ne=L,ee=V,t.width=Math.floor(x*V),t.height=Math.floor(L*V),this.setViewport(0,0,x,L)},this.setEffects=function(x){if(S===Bt){We("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let L=0;L{function pe(){if(F.forEach(function(ve){G.get(ve).currentProgram.isReady()&&F.delete(ve)}),F.size===0){B(x);return}setTimeout(pe,10)}Ke.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let Ys=null;function $l(x){Ys&&Ys(x)}function Ya(){zn.stop()}function qa(){zn.start()}const zn=new zl;zn.setAnimationLoop($l),typeof self<"u"&&zn.setContext(self),this.setAnimationLoop=function(x){Ys=x,Me.setAnimationLoop(x),x===null?zn.stop():zn.start()},Me.addEventListener("sessionstart",Ya),Me.addEventListener("sessionend",qa),this.render=function(x,L){if(L!==void 0&&L.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;O!==null&&O.renderStart(x,L);const V=Me.enabled===!0&&Me.isPresenting===!0,F=b!==null&&(J===null||V)&&b.begin(U,J);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(L),L=Me.getCamera()),x.isScene===!0&&x.onBeforeRender(U,x,L,J),y=le.get(x,g.length),y.init(L),y.state.textureUnits=k.getTextureUnits(),g.push(y),Fe.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Ze.setFromProjectionMatrix(Fe,an,L.reversedDepth),_e=this.localClippingEnabled,fe=Ae.init(this.clippingPlanes,_e),A=he.get(x,w.length),A.init(),w.push(A),Me.enabled===!0&&Me.isPresenting===!0){const ve=U.xr.getDepthSensingMesh();ve!==null&&qs(ve,L,-1/0,U.sortObjects)}qs(x,L,0,U.sortObjects),A.finish(),U.sortObjects===!0&&A.sort(De,Le,L.reversedDepth),rt=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,rt&&Ue.addToRenderList(A,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),fe===!0&&Ae.beginShadows();const B=y.state.shadowsArray;if(Ce.render(B,x,L),fe===!0&&Ae.endShadows(),(F&&b.hasRenderPass())===!1){const ve=A.opaque,de=A.transmissive;if(y.setupLights(),L.isArrayCamera){const Se=L.cameras;if(de.length>0)for(let be=0,Ne=Se.length;be0&&Ka(ve,de,x,L),rt&&Ue.render(x),Za(A,x,L)}J!==null&&H===0&&(k.updateMultisampleRenderTarget(J),k.updateRenderTargetMipmap(J)),F&&b.end(U),x.isScene===!0&&x.onAfterRender(U,x,L),me.resetDefaultState(),j=-1,re=null,g.pop(),g.length>0?(y=g[g.length-1],k.setTextureUnits(y.state.textureUnits),fe===!0&&Ae.setGlobalState(U.clippingPlanes,y.state.camera)):y=null,w.pop(),w.length>0?A=w[w.length-1]:A=null,O!==null&&O.renderEnd()};function qs(x,L,V,F){if(x.visible===!1)return;if(x.layers.test(L.layers)){if(x.isGroup)V=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(L);else if(x.isLightProbeGrid)y.pushLightProbeGrid(x);else if(x.isLight)y.pushLight(x),x.castShadow&&y.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Ze.intersectsSprite(x)){F&&dt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Fe);const ve=$.update(x),de=x.material;de.visible&&A.push(x,ve,de,V,dt.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Ze.intersectsObject(x))){const ve=$.update(x),de=x.material;if(F&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),dt.copy(x.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),dt.copy(ve.boundingSphere.center)),dt.applyMatrix4(x.matrixWorld).applyMatrix4(Fe)),Array.isArray(de)){const Se=ve.groups;for(let be=0,Ne=Se.length;be0&&qi(B,L,V),pe.length>0&&qi(pe,L,V),ve.length>0&&qi(ve,L,V),d.buffers.depth.setTest(!0),d.buffers.depth.setMask(!0),d.buffers.color.setMask(!0),d.setPolygonOffset(!1)}function Ka(x,L,V,F){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[F.id]===void 0){const Te=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[F.id]=new ln(1,1,{generateMipmaps:!0,type:Te?vn:Bt,minFilter:Yn,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xe.workingColorSpace})}const pe=y.state.transmissionRenderTarget[F.id],ve=F.viewport||ae;pe.setSize(ve.z*U.transmissionResolutionScale,ve.w*U.transmissionResolutionScale);const de=U.getRenderTarget(),Se=U.getActiveCubeFace(),be=U.getActiveMipmapLevel();U.setRenderTarget(pe),U.getClearColor(nt),Ye=U.getClearAlpha(),Ye<1&&U.setClearColor(16777215,.5),U.clear(),rt&&Ue.render(V);const Ne=U.toneMapping;U.toneMapping=on;const Ge=F.viewport;if(F.viewport!==void 0&&(F.viewport=void 0),y.setupLightsView(F),fe===!0&&Ae.setGlobalState(U.clippingPlanes,F),qi(x,V,F),k.updateMultisampleRenderTarget(pe),k.updateRenderTargetMipmap(pe),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let Te=!1;for(let Je=0,pt=L.length;Je0,F.currentProgram=Ge,F.uniformsList=null,Ge}function Ja(x){if(x.uniformsList===null){const L=x.currentProgram.getUniforms();x.uniformsList=Cs.seqWithValue(L.seq,x.uniforms)}return x.uniformsList}function Qa(x,L){const V=G.get(x);V.outputColorSpace=L.outputColorSpace,V.batching=L.batching,V.batchingColor=L.batchingColor,V.instancing=L.instancing,V.instancingColor=L.instancingColor,V.instancingMorph=L.instancingMorph,V.skinning=L.skinning,V.morphTargets=L.morphTargets,V.morphNormals=L.morphNormals,V.morphColors=L.morphColors,V.morphTargetsCount=L.morphTargetsCount,V.numClippingPlanes=L.numClippingPlanes,V.numIntersection=L.numClipIntersection,V.vertexAlphas=L.vertexAlphas,V.vertexTangents=L.vertexTangents,V.toneMapping=L.toneMapping}function Jl(x,L){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;M.setFromMatrixPosition(L.matrixWorld);for(let V=0,F=x.length;V0),Te=!!V.morphAttributes.position,Je=!!V.morphAttributes.normal,pt=!!V.morphAttributes.color;let ut=on;F.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(ut=U.toneMapping);const et=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,bt=et!==void 0?et.length:0,xe=G.get(F),Nt=y.state.lights;if(fe===!0&&(_e===!0||x!==re)){const st=x===re&&F.id===j;Ae.setState(F,x,st)}let qe=!1;F.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==Nt.state.version||xe.outputColorSpace!==de||B.isBatchedMesh&&xe.batching===!1||!B.isBatchedMesh&&xe.batching===!0||B.isBatchedMesh&&xe.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&xe.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&xe.instancing===!1||!B.isInstancedMesh&&xe.instancing===!0||B.isSkinnedMesh&&xe.skinning===!1||!B.isSkinnedMesh&&xe.skinning===!0||B.isInstancedMesh&&xe.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&xe.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&xe.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&xe.instancingMorph===!1&&B.morphTexture!==null||xe.envMap!==be||F.fog===!0&&xe.fog!==pe||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==Ae.numPlanes||xe.numIntersection!==Ae.numIntersection)||xe.vertexAlphas!==Ne||xe.vertexTangents!==Ge||xe.morphTargets!==Te||xe.morphNormals!==Je||xe.morphColors!==pt||xe.toneMapping!==ut||xe.morphTargetsCount!==bt||!!xe.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&(qe=!0):(qe=!0,xe.__version=F.version);let zt=xe.currentProgram;qe===!0&&(zt=Zi(F,L,B),O&&F.isNodeMaterial&&O.onUpdateProgram(F,zt,xe));let Qt=!1,Sn=!1,Jn=!1;const tt=zt.getUniforms(),mt=xe.uniforms;if(d.useProgram(zt.program)&&(Qt=!0,Sn=!0,Jn=!0),F.id!==j&&(j=F.id,Sn=!0),xe.needsLights){const st=Jl(y.state.lightProbeGridArray,B);xe.lightProbeGrid!==st&&(xe.lightProbeGrid=st,Sn=!0)}if(Qt||re!==x){d.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),tt.setValue(D,"projectionMatrix",x.projectionMatrix),tt.setValue(D,"viewMatrix",x.matrixWorldInverse);const yn=tt.map.cameraPosition;yn!==void 0&&yn.setValue(D,Ve.setFromMatrixPosition(x.matrixWorld)),E.logarithmicDepthBuffer&&tt.setValue(D,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(F.isMeshPhongMaterial||F.isMeshToonMaterial||F.isMeshLambertMaterial||F.isMeshBasicMaterial||F.isMeshStandardMaterial||F.isShaderMaterial)&&tt.setValue(D,"isOrthographic",x.isOrthographicCamera===!0),re!==x&&(re=x,Sn=!0,Jn=!0)}if(xe.needsLights&&(Nt.state.directionalShadowMap.length>0&&tt.setValue(D,"directionalShadowMap",Nt.state.directionalShadowMap,k),Nt.state.spotShadowMap.length>0&&tt.setValue(D,"spotShadowMap",Nt.state.spotShadowMap,k),Nt.state.pointShadowMap.length>0&&tt.setValue(D,"pointShadowMap",Nt.state.pointShadowMap,k)),B.isSkinnedMesh){tt.setOptional(D,B,"bindMatrix"),tt.setOptional(D,B,"bindMatrixInverse");const st=B.skeleton;st&&(st.boneTexture===null&&st.computeBoneTexture(),tt.setValue(D,"boneTexture",st.boneTexture,k))}B.isBatchedMesh&&(tt.setOptional(D,B,"batchingTexture"),tt.setValue(D,"batchingTexture",B._matricesTexture,k),tt.setOptional(D,B,"batchingIdTexture"),tt.setValue(D,"batchingIdTexture",B._indirectTexture,k),tt.setOptional(D,B,"batchingColorTexture"),B._colorsTexture!==null&&tt.setValue(D,"batchingColorTexture",B._colorsTexture,k));const En=V.morphAttributes;if((En.position!==void 0||En.normal!==void 0||En.color!==void 0)&&C.update(B,V,zt),(Sn||xe.receiveShadow!==B.receiveShadow)&&(xe.receiveShadow=B.receiveShadow,tt.setValue(D,"receiveShadow",B.receiveShadow)),(F.isMeshStandardMaterial||F.isMeshLambertMaterial||F.isMeshPhongMaterial)&&F.envMap===null&&L.environment!==null&&(mt.envMapIntensity.value=L.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Pm()),Sn){if(tt.setValue(D,"toneMappingExposure",U.toneMappingExposure),xe.needsLights&&jl(mt,Jn),pe&&F.fog===!0&&ye.refreshFogUniforms(mt,pe),ye.refreshMaterialUniforms(mt,F,ee,ne,y.state.transmissionRenderTarget[x.id]),xe.needsLights&&xe.lightProbeGrid){const st=xe.lightProbeGrid;mt.probesSH.value=st.texture,mt.probesMin.value.copy(st.boundingBox.min),mt.probesMax.value.copy(st.boundingBox.max),mt.probesResolution.value.copy(st.resolution)}Cs.upload(D,Ja(xe),mt,k)}if(F.isShaderMaterial&&F.uniformsNeedUpdate===!0&&(Cs.upload(D,Ja(xe),mt,k),F.uniformsNeedUpdate=!1),F.isSpriteMaterial&&tt.setValue(D,"center",B.center),tt.setValue(D,"modelViewMatrix",B.modelViewMatrix),tt.setValue(D,"normalMatrix",B.normalMatrix),tt.setValue(D,"modelMatrix",B.matrixWorld),F.uniformsGroups!==void 0){const st=F.uniformsGroups;for(let yn=0,Qn=st.length;yn0&&k.useMultisampledRTT(x)===!1?F=G.get(x).__webglMultisampledFramebuffer:Array.isArray(be)?F=be[V]:F=be,ae.copy(x.viewport),ge.copy(x.scissor),ke=x.scissorTest}else ae.copy(we).multiplyScalar(ee).floor(),ge.copy(lt).multiplyScalar(ee).floor(),ke=ze;if(V!==0&&(F=Y),d.bindFramebuffer(D.FRAMEBUFFER,F)&&d.drawBuffers(x,F),d.viewport(ae),d.scissor(ge),d.setScissorTest(ke),B){const de=G.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,de.__webglTexture,V)}else if(pe){const de=L;for(let Se=0;Se1&&D.readBuffer(D.COLOR_ATTACHMENT0+de),!E.textureFormatReadable(Ne)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Ge)){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-F&&V>=0&&V<=x.height-B&&D.readPixels(L,V,F,B,ce.convert(Ne),ce.convert(Ge),pe)}finally{const be=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,be)}}},this.readRenderTargetPixelsAsync=async function(x,L,V,F,B,pe,ve,de=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ve!==void 0&&(Se=Se[ve]),Se)if(L>=0&&L<=x.width-F&&V>=0&&V<=x.height-B){d.bindFramebuffer(D.FRAMEBUFFER,Se);const be=x.textures[de],Ne=be.format,Ge=be.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+de),!E.textureFormatReadable(Ne))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Ge))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Te=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Te),D.bufferData(D.PIXEL_PACK_BUFFER,pe.byteLength,D.STREAM_READ),D.readPixels(L,V,F,B,ce.convert(Ne),ce.convert(Ge),0);const Je=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,Je);const pt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Gc(D,pt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Te),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,pe),D.deleteBuffer(Te),D.deleteSync(pt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,L=null,V=0){const F=Math.pow(2,-V),B=Math.floor(x.image.width*F),pe=Math.floor(x.image.height*F),ve=L!==null?L.x:0,de=L!==null?L.y:0;k.setTexture2D(x,0),D.copyTexSubImage2D(D.TEXTURE_2D,V,0,0,ve,de,B,pe),d.unbindTexture()},this.copyTextureToTexture=function(x,L,V=null,F=null,B=0,pe=0){let ve,de,Se,be,Ne,Ge,Te,Je,pt;const ut=x.isCompressedTexture?x.mipmaps[pe]:x.image;if(V!==null)ve=V.max.x-V.min.x,de=V.max.y-V.min.y,Se=V.isBox3?V.max.z-V.min.z:1,be=V.min.x,Ne=V.min.y,Ge=V.isBox3?V.min.z:0;else{const mt=Math.pow(2,-B);ve=Math.floor(ut.width*mt),de=Math.floor(ut.height*mt),x.isDataArrayTexture?Se=ut.depth:x.isData3DTexture?Se=Math.floor(ut.depth*mt):Se=1,be=0,Ne=0,Ge=0}F!==null?(Te=F.x,Je=F.y,pt=F.z):(Te=0,Je=0,pt=0);const et=ce.convert(L.format),bt=ce.convert(L.type);let xe;L.isData3DTexture?(k.setTexture3D(L,0),xe=D.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(k.setTexture2DArray(L,0),xe=D.TEXTURE_2D_ARRAY):(k.setTexture2D(L,0),xe=D.TEXTURE_2D),d.activeTexture(D.TEXTURE0),d.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,L.flipY),d.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),d.pixelStorei(D.UNPACK_ALIGNMENT,L.unpackAlignment);const Nt=d.getParameter(D.UNPACK_ROW_LENGTH),qe=d.getParameter(D.UNPACK_IMAGE_HEIGHT),zt=d.getParameter(D.UNPACK_SKIP_PIXELS),Qt=d.getParameter(D.UNPACK_SKIP_ROWS),Sn=d.getParameter(D.UNPACK_SKIP_IMAGES);d.pixelStorei(D.UNPACK_ROW_LENGTH,ut.width),d.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ut.height),d.pixelStorei(D.UNPACK_SKIP_PIXELS,be),d.pixelStorei(D.UNPACK_SKIP_ROWS,Ne),d.pixelStorei(D.UNPACK_SKIP_IMAGES,Ge);const Jn=x.isDataArrayTexture||x.isData3DTexture,tt=L.isDataArrayTexture||L.isData3DTexture;if(x.isDepthTexture){const mt=G.get(x),En=G.get(L),st=G.get(mt.__renderTarget),yn=G.get(En.__renderTarget);d.bindFramebuffer(D.READ_FRAMEBUFFER,st.__webglFramebuffer),d.bindFramebuffer(D.DRAW_FRAMEBUFFER,yn.__webglFramebuffer);for(let Qn=0;QnMath.PI&&(n-=Lt),s<-Math.PI?s+=Lt:s>Math.PI&&(s-=Lt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(gt.setFromSpherical(this._spherical),gt.applyQuaternion(this._quatInverse),t.copy(this.target).add(gt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=gt.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){const o=new I(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;const l=new I(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=gt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Es.origin.copy(this.object.position),Es.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Es.direction))Cr||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Cr||this._lastTargetPosition.distanceToSquared(this.target)>Cr?(this.dispatchEvent(ol),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Lt/60*this.autoRotateSpeed*e:Lt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){gt.setFromMatrixColumn(t,0),gt.multiplyScalar(-e),this._panOffset.add(gt)}_panUp(e,t){this.screenSpacePanning===!0?gt.setFromMatrixColumn(t,1):(gt.setFromMatrixColumn(t,0),gt.crossVectors(this.object.up,gt)),gt.multiplyScalar(e),this._panOffset.add(gt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;gt.copy(s).sub(this.target);let r=gt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Lt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Lt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Lt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t"u"?e:getComputedStyle(document.documentElement).getPropertyValue(i).trim()||e}function cl(i){return Math.max(40,26*Math.sqrt(Math.max(i,1)))}function Ym(i,e){const t=document.createElement("canvas");t.width=512,t.height=64;const n=t.getContext("2d");n&&(n.clearRect(0,0,512,64),n.fillStyle=e,n.font="600 28px sans-serif",n.textAlign="center",n.textBaseline="middle",n.fillText(i,256,32));const s=new gh(t),r=new ch(new Dl({map:s,transparent:!0,depthTest:!1}));return r.scale.set(110,14,1),r}function Zm({nodes:i,edges:e,selectedId:t,neighborIds:n,onSelect:s}){const r=bn.useRef(null),a=bn.useRef(null),[o,c]=bn.useState(null),[l,f]=bn.useState(null),m=bn.useRef(s);m.current=s;const h=bn.useRef({selectedId:t,neighborIds:n});return h.current={selectedId:t,neighborIds:n},bn.useEffect(()=>{const _=a.current;if(!_)return;const v=window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=new ih;S.background=new Be(xi("--graph-bg","#0b0f14"));const p=new Ht(50,1,1,8e3);let u;try{u=new Dm({antialias:!0,failIfMajorPerformanceCaveat:!1,powerPreference:"low-power"})}catch{f("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}if(!u.getContext()){u.dispose(),f("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}f(null),u.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),u.domElement.dataset.testid="graph-3d-canvas",_.appendChild(u.domElement);const T=new Im(p,u.domElement);T.enableDamping=!v,T.dampingFactor=.08,T.minDistance=80,T.maxDistance=2400,S.add(new Ph(16777215,.7));const R=new Ch(16777215,.85);R.position.set(200,320,180),S.add(R);const M=tc(i),A=new Map(i.map(fe=>[fe.id,fe])),y=new Map,w=new Vi;S.add(w);const g=new Oa(11,18,14);for(const fe of i){const _e=M.get(fe.id)??{x:0,y:0,z:0},Fe=new bh({color:nc(fe.type),roughness:.45,metalness:.05,transparent:!0,opacity:1}),Ve=new Kt(g,Fe);Ve.position.set(_e.x,_e.y,_e.z),Ve.userData.id=fe.id,w.add(Ve),y.set(fe.id,Ve)}const b=new Ut,U=[],P=[],O=new Be(xi("--edge-cheap","#4a5568")),Y=new Be(xi("--edge-expensive","#f4a261")),K=new Be(xi("--edge-critical","#e85d04"));for(const fe of e){const _e=M.get(fe.src),Fe=M.get(fe.dst);if(!_e||!Fe)continue;U.push(_e.x,_e.y,_e.z,Fe.x,Fe.y,Fe.z);const Ve=fe.weight==="critical"?K:fe.weight==="expensive"?Y:O;P.push(Ve.r,Ve.g,Ve.b,Ve.r,Ve.g,Ve.b)}b.setAttribute("position",new xt(U,3)),b.setAttribute("color",new xt(P,3));const z=new _h(b,new Il({vertexColors:!0,transparent:!0,opacity:.55}));w.add(z);const X=new Ua({color:new Be(xi("--muted","#8b9bb0")),transparent:!0,opacity:.07,side:nn,depthWrite:!1}),H=xi("--muted","#8b9bb0"),J=[],j=[];for(const fe of ic(i)){const _e=new Fa(cl(fe.count),48);j.push(_e);const Fe=new Kt(_e,X);Fe.rotation.y=Math.PI/2,Fe.position.x=fe.x,w.add(Fe);const Ve=Ym(sc[fe.layer]??`layer ${fe.layer}`,H);Ve.position.set(fe.x,cl(fe.count)+18,0),w.add(Ve),J.push(Ve)}const re=new wi().setFromObject(w),ae=re.getCenter(new I),ge=re.getSize(new I);T.target.copy(ae),p.position.set(ae.x+ge.x*.15,ae.y+Math.max(140,ge.y*.45),ae.z+Math.max(280,ge.z*.9+180)),p.lookAt(ae);const ke=new Ih;ke.params.Mesh={...ke.params.Mesh,threshold:2};const nt=new Re,Ye=[...y.values()],q=(fe,_e)=>{const Fe=!!(fe&&_e.size);for(const[Ve,dt]of y){const ft=dt.material,rt=!Fe||_e.has(Ve),at=Ve===fe;ft.opacity=at?1:rt?.95:.12,dt.scale.setScalar(at?1.7:rt?1:.7),ft.emissive.setHex(at?16777215:0),ft.emissiveIntensity=at?.18:0}z.material.opacity=Fe?.85:.5},ne=fe=>{const _e=u.domElement.getBoundingClientRect();nt.x=(fe.clientX-_e.left)/_e.width*2-1,nt.y=-((fe.clientY-_e.top)/_e.height)*2+1},ee=()=>{ke.setFromCamera(nt,p);const fe=ke.intersectObjects(Ye,!1)[0],_e=fe==null?void 0:fe.object.userData.id;return _e?A.get(_e)??null:null},De=fe=>{ne(fe);const _e=ee();if(!_e){c(null),u.domElement.style.cursor="grab";return}u.domElement.style.cursor="pointer";const Fe=(r.current??_).getBoundingClientRect();c({node:_e,x:fe.clientX-Fe.left,y:fe.clientY-Fe.top})},Le=fe=>{ne(fe);const _e=ee();m.current(_e?_e.id:null)},we=()=>{const fe=_.clientWidth||1,_e=_.clientHeight||1;p.aspect=fe/_e,p.updateProjectionMatrix(),u.setSize(fe,_e,!1)};we();const lt=new ResizeObserver(we);lt.observe(_);let ze=0;const Ze=()=>{ze=requestAnimationFrame(Ze),T.update(),u.render(S,p)};return Ze(),u.domElement.addEventListener("pointermove",De),u.domElement.addEventListener("click",Le),_.__paint=q,q(h.current.selectedId,h.current.neighborIds),()=>{var fe;cancelAnimationFrame(ze),lt.disconnect(),u.domElement.removeEventListener("pointermove",De),u.domElement.removeEventListener("click",Le),delete _.__paint,T.dispose(),g.dispose(),b.dispose(),X.dispose();for(const _e of j)_e.dispose();z.material.dispose();for(const _e of J){const Fe=_e.material;(fe=Fe.map)==null||fe.dispose(),Fe.dispose()}for(const _e of y.values())_e.material.dispose();try{u.forceContextLoss()}catch{}u.dispose(),u.domElement.remove(),c(null)}},[i,e]),bn.useEffect(()=>{var _,v;(v=(_=a.current)==null?void 0:_.__paint)==null||v.call(_,t,n)},[t,n]),jn.jsxs("div",{className:"graph-3d-host",ref:r,children:[jn.jsx("div",{className:"graph-3d-canvas-host",ref:a}),l?jn.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-3d-fallback",children:l}):null,o?jn.jsxs("div",{className:"graph-3d-tip",style:{left:o.x+12,top:o.y+12},children:[jn.jsx("div",{className:"t",children:rc(o.node.type)}),jn.jsx("div",{className:"n",children:o.node.name})]}):null]})}export{Zm as LayeredGraph3D}; diff --git a/src/loadpath/static/assets/index-DNN4KyeU.css b/src/loadpath/static/assets/index-Bh26i1BD.css similarity index 73% rename from src/loadpath/static/assets/index-DNN4KyeU.css rename to src/loadpath/static/assets/index-Bh26i1BD.css index 41bdabd..22a5f84 100644 --- a/src/loadpath/static/assets/index-DNN4KyeU.css +++ b/src/loadpath/static/assets/index-Bh26i1BD.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:132px;flex:0 0 132px}.field.workspace{width:180px;flex:0 0 180px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item .why{color:var(--muted);font-size:12px;margin-top:2px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:260px;max-width:calc(100% - 24px);overflow-x:hidden;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow)}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:180px;max-width:100%;height:56px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:hidden}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:132px;flex:0 0 132px}.field.workspace{width:180px;flex:0 0 180px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item .why{color:var(--muted);font-size:12px;margin-top:2px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:260px;max-width:calc(100% - 24px);overflow-x:hidden;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow)}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:180px;max-width:100%;height:56px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} diff --git a/src/loadpath/static/assets/index-COu_6ith.js b/src/loadpath/static/assets/index-COu_6ith.js deleted file mode 100644 index 43e09b7..0000000 --- a/src/loadpath/static/assets/index-COu_6ith.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function l(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function op(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mu={exports:{}},Ji={},yu={exports:{}},je={};/** - * @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 Of;function T0(){if(Of)return je;Of=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),x=Symbol.iterator;function g(j){return j===null||typeof j!="object"?null:(j=x&&j[x]||j["@@iterator"],typeof j=="function"?j:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,M={};function k(j,z,re){this.props=j,this.context=z,this.refs=M,this.updater=re||S}k.prototype.isReactComponent={},k.prototype.setState=function(j,z){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,z,"setState")},k.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function E(){}E.prototype=k.prototype;function T(j,z,re){this.props=j,this.context=z,this.refs=M,this.updater=re||S}var N=T.prototype=new E;N.constructor=T,_(N,k.prototype),N.isPureReactComponent=!0;var P=Array.isArray,b=Object.prototype.hasOwnProperty,$={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function X(j,z,re){var te,ae={},de=null,ce=null;if(z!=null)for(te in z.ref!==void 0&&(ce=z.ref),z.key!==void 0&&(de=""+z.key),z)b.call(z,te)&&!H.hasOwnProperty(te)&&(ae[te]=z[te]);var Q=arguments.length-2;if(Q===1)ae.children=re;else if(1>>1,z=A[j];if(0>>1;ja(ae,O))dea(ce,ae)?(A[j]=ce,A[de]=O,j=de):(A[j]=ae,A[te]=O,j=te);else if(dea(ce,O))A[j]=ce,A[de]=O,j=de;else break e}}return L}function a(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 u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var p=[],v=[],m=1,x=null,g=3,S=!1,_=!1,M=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(A){for(var L=o(v);L!==null;){if(L.callback===null)l(v);else if(L.startTime<=A)l(v),L.sortIndex=L.expirationTime,r(p,L);else break;L=o(v)}}function P(A){if(M=!1,N(A),!_)if(o(p)!==null)_=!0,F(b);else{var L=o(v);L!==null&&V(P,L.startTime-A)}}function b(A,L){_=!1,M&&(M=!1,E(X),X=-1),S=!0;var O=g;try{for(N(L),x=o(p);x!==null&&(!(x.expirationTime>L)||A&&!q());){var j=x.callback;if(typeof j=="function"){x.callback=null,g=x.priorityLevel;var z=j(x.expirationTime<=L);L=t.unstable_now(),typeof z=="function"?x.callback=z:x===o(p)&&l(p),N(L)}else l(p);x=o(p)}if(x!==null)var re=!0;else{var te=o(v);te!==null&&V(P,te.startTime-L),re=!1}return re}finally{x=null,g=O,S=!1}}var $=!1,H=null,X=-1,K=5,ne=-1;function q(){return!(t.unstable_now()-neA||125j?(A.sortIndex=O,r(v,A),o(p)===null&&A===o(v)&&(M?(E(X),X=-1):M=!0,V(P,O-j))):(A.sortIndex=z,r(p,A),_||S||(_=!0,F(b))),A},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(A){var L=g;return function(){var O=g;g=L;try{return A.apply(this,arguments)}finally{g=O}}}})(wu)),wu}var Bf;function $0(){return Bf||(Bf=1,xu.exports=A0()),xu.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 Uf;function D0(){if(Uf)return _t;Uf=1;var t=mo(),r=$0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},x={};function g(e){return p.call(x,e)?!0:p.call(m,e)?!1:v.test(e)?x[e]=!0:(m[e]=!0,!1)}function S(e,n,i,s){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return s?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function _(e,n,i,s){if(n===null||typeof n>"u"||S(e,n,i,s))return!0;if(s)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function M(e,n,i,s,c,f,w){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=s,this.attributeNamespace=c,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=f,this.removeEmptyString=w}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){k[e]=new M(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];k[n]=new M(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){k[e]=new M(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){k[e]=new M(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){k[e]=new M(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){k[e]=new M(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){k[e]=new M(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){k[e]=new M(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){k[e]=new M(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(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,T);k[n]=new M(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,T);k[n]=new M(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,T);k[n]=new M(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){k[e]=new M(e,1,!1,e.toLowerCase(),null,!1,!1)}),k.xlinkHref=new M("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){k[e]=new M(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,s){var c=k.hasOwnProperty(n)?k[n]:null;(c!==null?c.type!==0:s||!(2I||c[w]!==f[I]){var R=` -`+c[w].replace(" at new "," at ");return e.displayName&&R.includes("")&&(R=R.replace("",e.displayName)),R}while(1<=w&&0<=I);break}}}finally{re=!1,Error.prepareStackTrace=i}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=te(e.type,!1),e;case 11:return e=te(e.type.render,!1),e;case 1:return e=te(e.type,!0),e;default:return""}}function de(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 H:return"Fragment";case $:return"Portal";case K:return"Profiler";case X:return"StrictMode";case J:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case q:return(e.displayName||"Context")+".Consumer";case ne: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 B:return n=e.displayName||null,n!==null?n:de(e.type)||"Memo";case F:n=e._payload,e=e._init;try{return de(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 de(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function he(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),s=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,f=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return c.call(this)},set:function(w){s=""+w,f.call(this,w)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return s},setValue:function(w){s=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function we(e){e._valueTracker||(e._valueTracker=he(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),s="";return e&&(s=se(e)?e.checked?"true":"false":e.value),e=s,e!==i?(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 i=n.checked;return O({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;i=Q(n.value!=null?n.value:i),e._wrapperState={initialChecked:s,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Pe(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Re(e,n){Pe(e,n);var i=Q(n.value),s=n.type;if(i!=null)s==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?rt(e,n.type,i):n.hasOwnProperty("defaultValue")&&rt(e,n.type,Q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function nt(e,n,i){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,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function rt(e,n,i){(n!=="number"||me(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function Ge(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=ht.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function $t(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var rn={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},Z=["Webkit","ms","Moz","O"];Object.keys(rn).forEach(function(e){Z.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),rn[n]=rn[e]})});function Ee(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||rn.hasOwnProperty(e)&&rn[e]?(""+n).trim():n+"px"}function $e(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=Ee(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Cn=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 mt(e,n){if(n){if(Cn[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function di(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 fi=null;function hi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var pi=null,jn=null,Mn=null;function Eo(e){if(e=Oi(e)){if(typeof pi!="function")throw Error(o(280));var n=e.stateNode;n&&(n=es(n),pi(e.stateNode,e.type,n))}}function No(e){jn?Mn?Mn.push(e):Mn=[e]:jn=e}function Co(){if(jn){var e=jn,n=Mn;if(Mn=jn=null,Eo(e),n)for(e=0;e>>=0,e===0?32:31-(Al(e)/$l|0)|0}var Ir=64,Tr=4194304;function nr(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 pn(e,n){var i=e.pendingLanes;if(i===0)return 0;var s=0,c=e.suspendedLanes,f=e.pingedLanes,w=i&268435455;if(w!==0){var I=w&~c;I!==0?s=nr(I):(f&=w,f!==0&&(s=nr(f)))}else w=i&~c,w!==0?s=nr(w):f!==0&&(s=nr(f));if(s===0)return 0;if(n!==0&&n!==s&&(n&c)===0&&(c=s&-s,f=n&-n,c>=f||c===16&&(f&4194240)!==0))return n;if((s&4)!==0&&(s|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=s;0i;i++)n.push(e);return n}function ir(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Ct(n),e[n]=i}function bl(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Pi),Ic=" ",Tc=!1;function zc(e,n){switch(e){case"keyup":return Cm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Rc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ar=!1;function Mm(e,n){switch(e){case"compositionend":return Rc(n);case"keypress":return n.which!==32?null:(Tc=!0,Ic);case"textInput":return e=n.data,e===Ic&&Tc?null:e;default:return null}}function Pm(e,n){if(Ar)return e==="compositionend"||!Gl&&zc(e,n)?(e=Ec(),Bo=Ul=Rn=null,Ar=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=s}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Fc(i)}}function Vc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Vc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Bc(){for(var e=window,n=me();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=me(e.document)}return n}function Jl(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 Om(e){var n=Bc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Vc(i.ownerDocument.documentElement,i)){if(s!==null&&Jl(i)){if(n=s.start,e=s.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var c=i.textContent.length,f=Math.min(s.start,c);s=s.end===void 0?f:Math.min(s.end,c),!e.extend&&f>s&&(c=s,s=f,f=c),c=Hc(i,f);var w=Hc(i,s);c&&w&&(e.rangeCount!==1||e.anchorNode!==c.node||e.anchorOffset!==c.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(n=n.createRange(),n.setStart(c.node,c.offset),e.removeAllRanges(),f>s?(e.addRange(n),e.extend(w.node,w.offset)):(n.setEnd(w.node,w.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,$r=null,ea=null,Ri=null,ta=!1;function Uc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ta||$r==null||$r!==me(s)||(s=$r,"selectionStart"in s&&Jl(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}),Ri&&zi(Ri,s)||(Ri=s,s=qo(ea,"onSelect"),0Hr||(e.current=ha[Hr],ha[Hr]=null,Hr--)}function Ae(e,n){Hr++,ha[Hr]=e.current,e.current=n}var Dn={},at=$n(Dn),yt=$n(!1),sr=Dn;function Vr(e,n){var i=e.type.contextTypes;if(!i)return Dn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===n)return s.__reactInternalMemoizedMaskedChildContext;var c={},f;for(f in i)c[f]=n[f];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=c),c}function vt(e){return e=e.childContextTypes,e!=null}function ts(){Oe(yt),Oe(at)}function od(e,n,i){if(at.current!==Dn)throw Error(o(168));Ae(at,n),Ae(yt,i)}function sd(e,n,i){var s=e.stateNode;if(n=n.childContextTypes,typeof s.getChildContext!="function")return i;s=s.getChildContext();for(var c in s)if(!(c in n))throw Error(o(108,ce(e)||"Unknown",c));return O({},i,s)}function ns(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Dn,sr=at.current,Ae(at,e),Ae(yt,yt.current),!0}function ld(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=sd(e,n,sr),s.__reactInternalMemoizedMergedChildContext=e,Oe(yt),Oe(at),Ae(at,e)):Oe(yt),Ae(yt,i)}var mn=null,rs=!1,pa=!1;function ad(e){mn===null?mn=[e]:mn.push(e)}function Gm(e){rs=!0,ad(e)}function On(){if(!pa&&mn!==null){pa=!0;var e=0,n=Le;try{var i=mn;for(Le=1;e>=w,c-=w,yn=1<<32-Ct(n)+c|i<Ne?(tt=ke,ke=null):tt=ke.sibling;var ze=ie(U,ke,Y[Ne],ue);if(ze===null){ke===null&&(ke=tt);break}e&&ke&&ze.alternate===null&&n(U,ke),D=f(ze,D,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze,ke=tt}if(Ne===Y.length)return i(U,ke),Fe&&ar(U,Ne),xe;if(ke===null){for(;NeNe?(tt=ke,ke=null):tt=ke.sibling;var Xn=ie(U,ke,ze.value,ue);if(Xn===null){ke===null&&(ke=tt);break}e&&ke&&Xn.alternate===null&&n(U,ke),D=f(Xn,D,Ne),_e===null?xe=Xn:_e.sibling=Xn,_e=Xn,ke=tt}if(ze.done)return i(U,ke),Fe&&ar(U,Ne),xe;if(ke===null){for(;!ze.done;Ne++,ze=Y.next())ze=le(U,ze.value,ue),ze!==null&&(D=f(ze,D,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze);return Fe&&ar(U,Ne),xe}for(ke=s(U,ke);!ze.done;Ne++,ze=Y.next())ze=fe(ke,U,Ne,ze.value,ue),ze!==null&&(e&&ze.alternate!==null&&ke.delete(ze.key===null?Ne:ze.key),D=f(ze,D,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze);return e&&ke.forEach(function(I0){return n(U,I0)}),Fe&&ar(U,Ne),xe}function Ye(U,D,Y,ue){if(typeof Y=="object"&&Y!==null&&Y.type===H&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case b:e:{for(var xe=Y.key,_e=D;_e!==null;){if(_e.key===xe){if(xe=Y.type,xe===H){if(_e.tag===7){i(U,_e.sibling),D=c(_e,Y.props.children),D.return=U,U=D;break e}}else if(_e.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===F&&pd(xe)===_e.type){i(U,_e.sibling),D=c(_e,Y.props),D.ref=bi(U,_e,Y),D.return=U,U=D;break e}i(U,_e);break}else n(U,_e);_e=_e.sibling}Y.type===H?(D=mr(Y.props.children,U.mode,ue,Y.key),D.return=U,U=D):(ue=Ts(Y.type,Y.key,Y.props,null,U.mode,ue),ue.ref=bi(U,D,Y),ue.return=U,U=ue)}return w(U);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){i(U,D.sibling),D=c(D,Y.children||[]),D.return=U,U=D;break e}else{i(U,D);break}else n(U,D);D=D.sibling}D=du(Y,U.mode,ue),D.return=U,U=D}return w(U);case F:return _e=Y._init,Ye(U,D,_e(Y._payload),ue)}if(Xe(Y))return ge(U,D,Y,ue);if(L(Y))return ye(U,D,Y,ue);ls(U,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"?(Y=""+Y,D!==null&&D.tag===6?(i(U,D.sibling),D=c(D,Y),D.return=U,U=D):(i(U,D),D=cu(Y,U.mode,ue),D.return=U,U=D),w(U)):i(U,D)}return Ye}var Yr=gd(!0),md=gd(!1),as=$n(null),us=null,Xr=null,wa=null;function Sa(){wa=Xr=us=null}function _a(e){var n=as.current;Oe(as),e._currentValue=n}function ka(e,n,i){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===i)break;e=e.return}}function Qr(e,n){us=e,wa=Xr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(xt=!0),e.firstContext=null)}function bt(e){var n=e._currentValue;if(wa!==e)if(e={context:e,memoizedValue:n,next:null},Xr===null){if(us===null)throw Error(o(308));Xr=e,us.dependencies={lanes:0,firstContext:e}}else Xr=Xr.next=e;return n}var ur=null;function Ea(e){ur===null?ur=[e]:ur.push(e)}function yd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ea(n)):(i.next=c.next,c.next=i),n.interleaved=i,xn(e,s)}function xn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var bn=!1;function Na(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vd(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 wn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Fn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Ie&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,xn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ea(s)):(n.next=c.next,c.next=n),s.interleaved=n,xn(e,i)}function cs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,zr(e,i)}}function xd(e,n){var i=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,i===s)){var c=null,f=null;if(i=i.firstBaseUpdate,i!==null){do{var w={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};f===null?c=f=w:f=f.next=w,i=i.next}while(i!==null);f===null?c=f=n:f=f.next=n}else c=f=n;i={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:f,shared:s.shared,effects:s.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function ds(e,n,i,s){var c=e.updateQueue;bn=!1;var f=c.firstBaseUpdate,w=c.lastBaseUpdate,I=c.shared.pending;if(I!==null){c.shared.pending=null;var R=I,G=R.next;R.next=null,w===null?f=G:w.next=G,w=R;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,I=oe.lastBaseUpdate,I!==w&&(I===null?oe.firstBaseUpdate=G:I.next=G,oe.lastBaseUpdate=R))}if(f!==null){var le=c.baseState;w=0,oe=G=R=null,I=f;do{var ie=I.lane,fe=I.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:fe,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var ge=e,ye=I;switch(ie=n,fe=i,ye.tag){case 1:if(ge=ye.payload,typeof ge=="function"){le=ge.call(fe,le,ie);break e}le=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=ye.payload,ie=typeof ge=="function"?ge.call(fe,le,ie):ge,ie==null)break e;le=O({},le,ie);break e;case 2:bn=!0}}I.callback!==null&&I.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[I]:ie.push(I))}else fe={eventTime:fe,lane:ie,tag:I.tag,payload:I.payload,callback:I.callback,next:null},oe===null?(G=oe=fe,R=le):oe=oe.next=fe,w|=ie;if(I=I.next,I===null){if(I=c.shared.pending,I===null)break;ie=I,I=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(R=le),c.baseState=R,c.firstBaseUpdate=G,c.lastBaseUpdate=oe,n=c.shared.interleaved,n!==null){c=n;do w|=c.lane,c=c.next;while(c!==n)}else f===null&&(c.shared.lanes=0);fr|=w,e.lanes=w,e.memoizedState=le}}function wd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Ia.transition;Ia.transition={};try{e(!1),n()}finally{Le=i,Ia.transition=s}}function bd(){return Ft().memoizedState}function e0(e,n,i){var s=Un(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Fd(e))Hd(n,i);else if(i=yd(e,n,i,s),i!==null){var c=gt();Kt(i,e,s,c),Vd(i,n,s)}}function t0(e,n,i){var s=Un(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Fd(e))Hd(n,c);else{var f=e.alternate;if(e.lanes===0&&(f===null||f.lanes===0)&&(f=n.lastRenderedReducer,f!==null))try{var w=n.lastRenderedState,I=f(w,i);if(c.hasEagerState=!0,c.eagerState=I,Ut(I,w)){var R=n.interleaved;R===null?(c.next=c,Ea(n)):(c.next=R.next,R.next=c),n.interleaved=c;return}}catch{}finally{}i=yd(e,n,c,s),i!==null&&(c=gt(),Kt(i,e,s,c),Vd(i,n,s))}}function Fd(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function Hd(e,n){Bi=ps=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Vd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,zr(e,i)}}var ys={readContext:bt,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},n0={readContext:bt,useCallback:function(e,n){return an().memoizedState=[e,n===void 0?null:n],e},useContext:bt,useEffect:Td,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,gs(4194308,4,Ld.bind(null,n,e),i)},useLayoutEffect:function(e,n){return gs(4194308,4,e,n)},useInsertionEffect:function(e,n){return gs(4,2,e,n)},useMemo:function(e,n){var i=an();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=an();return n=i!==void 0?i(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=e0.bind(null,Be,e),[s.memoizedState,e]},useRef:function(e){var n=an();return e={current:e},n.memoizedState=e},useState:Pd,useDebugValue:Da,useDeferredValue:function(e){return an().memoizedState=e},useTransition:function(){var e=Pd(!1),n=e[0];return e=Jm.bind(null,e[1]),an().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Be,c=an();if(Fe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),et===null)throw Error(o(349));(dr&30)!==0||Ed(s,n,i)}c.memoizedState=i;var f={value:i,getSnapshot:n};return c.queue=f,Td(Cd.bind(null,s,f,e),[e]),s.flags|=2048,Yi(9,Nd.bind(null,s,f,i,n),void 0,null),i},useId:function(){var e=an(),n=et.identifierPrefix;if(Fe){var i=vn,s=yn;i=(s&~(1<<32-Ct(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ui++,0<\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=w.createElement(i,{is:s.is}):(e=w.createElement(i),i==="select"&&(w=e,s.multiple?w.multiple=!0:s.size&&(w.size=s.size))):e=w.createElementNS(e,i),e[sn]=n,e[Di]=s,uf(e,n,!1,!1),n.stateNode=e;e:{switch(w=di(i,s),i){case"dialog":De("cancel",e),De("close",e),c=s;break;case"iframe":case"object":case"embed":De("load",e),c=s;break;case"video":case"audio":for(c=0;cJr&&(n.flags|=128,s=!0,Xi(f,!1),n.lanes=4194304)}else{if(!s)if(e=fs(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Xi(f,!0),f.tail===null&&f.tailMode==="hidden"&&!w.alternate&&!Fe)return ct(n),null}else 2*He()-f.renderingStartTime>Jr&&i!==1073741824&&(n.flags|=128,s=!0,Xi(f,!1),n.lanes=4194304);f.isBackwards?(w.sibling=n.child,n.child=w):(i=f.last,i!==null?i.sibling=w:n.child=w,f.last=w)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=He(),n.sibling=null,i=Ve.current,Ae(Ve,s?i&1|2:i&1),n):(ct(n),null);case 22:case 23:return lu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(It&1073741824)!==0&&(ct(n),n.subtreeFlags&6&&(n.flags|=8192)):ct(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function c0(e,n){switch(ma(n),n.tag){case 1:return vt(n.type)&&ts(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Kr(),Oe(yt),Oe(at),Pa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return ja(n),null;case 13:if(Oe(Ve),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Wr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Oe(Ve),null;case 4:return Kr(),null;case 10:return _a(n.type._context),null;case 22:case 23:return lu(),null;case 24:return null;default:return null}}var Ss=!1,dt=!1,d0=typeof WeakSet=="function"?WeakSet:Set,pe=null;function qr(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){We(e,n,s)}else i.current=null}function Ka(e,n,i){try{i()}catch(s){We(e,n,s)}}var ff=!1;function f0(e,n){if(la=Ho,e=Bc(),Jl(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var s=i.getSelection&&i.getSelection();if(s&&s.rangeCount!==0){i=s.anchorNode;var c=s.anchorOffset,f=s.focusNode;s=s.focusOffset;try{i.nodeType,f.nodeType}catch{i=null;break e}var w=0,I=-1,R=-1,G=0,oe=0,le=e,ie=null;t:for(;;){for(var fe;le!==i||c!==0&&le.nodeType!==3||(I=w+c),le!==f||s!==0&&le.nodeType!==3||(R=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(fe=le.firstChild)!==null;)ie=le,le=fe;for(;;){if(le===e)break t;if(ie===i&&++G===c&&(I=w),ie===f&&++oe===s&&(R=w),(fe=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=fe}i=I===-1||R===-1?null:{start:I,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(aa={focusedElem:e,selectionRange:i},Ho=!1,pe=n;pe!==null;)if(n=pe,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,pe=e;else for(;pe!==null;){n=pe;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,Ye=ge.memoizedState,U=n.stateNode,D=U.getSnapshotBeforeUpdate(n.elementType===n.type?ye:Yt(n.type,ye),Ye);U.__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(o(163))}}catch(ue){We(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,pe=e;break}pe=n.return}return ge=ff,ff=!1,ge}function Qi(e,n,i){var s=n.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var c=s=s.next;do{if((c.tag&e)===e){var f=c.destroy;c.destroy=void 0,f!==void 0&&Ka(n,i,f)}c=c.next}while(c!==s)}}function _s(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function Ga(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function hf(e){var n=e.alternate;n!==null&&(e.alternate=null,hf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[sn],delete n[Di],delete n[fa],delete n[Qm],delete n[Km])),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 pf(e){return e.tag===5||e.tag===3||e.tag===4}function gf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||pf(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 qa(e,n,i){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Jo));else if(s!==4&&(e=e.child,e!==null))for(qa(e,n,i),e=e.sibling;e!==null;)qa(e,n,i),e=e.sibling}function Za(e,n,i){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(Za(e,n,i),e=e.sibling;e!==null;)Za(e,n,i),e=e.sibling}var ot=null,Xt=!1;function Hn(e,n,i){for(i=i.child;i!==null;)mf(e,n,i),i=i.sibling}function mf(e,n,i){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(Pr,i)}catch{}switch(i.tag){case 5:dt||qr(i,n);case 6:var s=ot,c=Xt;ot=null,Hn(e,n,i),ot=s,Xt=c,ot!==null&&(Xt?(e=ot,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):ot.removeChild(i.stateNode));break;case 18:ot!==null&&(Xt?(e=ot,i=i.stateNode,e.nodeType===8?da(e.parentNode,i):e.nodeType===1&&da(e,i),Ci(e)):da(ot,i.stateNode));break;case 4:s=ot,c=Xt,ot=i.stateNode.containerInfo,Xt=!0,Hn(e,n,i),ot=s,Xt=c;break;case 0:case 11:case 14:case 15:if(!dt&&(s=i.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){c=s=s.next;do{var f=c,w=f.destroy;f=f.tag,w!==void 0&&((f&2)!==0||(f&4)!==0)&&Ka(i,n,w),c=c.next}while(c!==s)}Hn(e,n,i);break;case 1:if(!dt&&(qr(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(I){We(i,n,I)}Hn(e,n,i);break;case 21:Hn(e,n,i);break;case 22:i.mode&1?(dt=(s=dt)||i.memoizedState!==null,Hn(e,n,i),dt=s):Hn(e,n,i);break;default:Hn(e,n,i)}}function yf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new d0),n.forEach(function(s){var c=S0.bind(null,e,s);i.has(s)||(i.add(s),s.then(c,c))})}}function Qt(e,n){var i=n.deletions;if(i!==null)for(var s=0;sc&&(c=w),s&=~f}if(s=c,s=He()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*p0(s/1960))-s,10e?16:e,Bn===null)var s=!1;else{if(e=Bn,Bn=null,js=0,(Ie&6)!==0)throw Error(o(331));var c=Ie;for(Ie|=4,pe=e.current;pe!==null;){var f=pe,w=f.child;if((pe.flags&16)!==0){var I=f.deletions;if(I!==null){for(var R=0;RHe()-tu?pr(e,0):eu|=i),St(e,n)}function If(e,n){n===0&&((e.mode&1)===0?n=1:(n=Tr,Tr<<=1,(Tr&130023424)===0&&(Tr=4194304)));var i=gt();e=xn(e,n),e!==null&&(ir(e,n,i),St(e,i))}function w0(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),If(e,i)}function S0(e,n){var i=0;switch(e.tag){case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(i=c.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(o(314))}s!==null&&s.delete(n),If(e,i)}var Tf;Tf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||yt.current)xt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return xt=!1,a0(e,n,i);xt=(e.flags&131072)!==0}else xt=!1,Fe&&(n.flags&1048576)!==0&&ud(n,os,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;ws(e,n),e=n.pendingProps;var c=Vr(n,at.current);Qr(n,i),c=za(null,n,s,e,c,i);var f=Ra();return n.flags|=1,typeof c=="object"&&c!==null&&typeof c.render=="function"&&c.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,vt(s)?(f=!0,ns(n)):f=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Na(n),c.updater=vs,n.stateNode=c,c._reactInternals=n,ba(n,s,e,i),n=Ba(null,n,s,!0,f,i)):(n.tag=0,Fe&&f&&ga(n),pt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(ws(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=k0(s),e=Yt(s,e),c){case 0:n=Va(null,n,s,e,i);break e;case 1:n=nf(null,n,s,e,i);break e;case 11:n=qd(null,n,s,e,i);break e;case 14:n=Zd(null,n,s,Yt(s.type,e),i);break e}throw Error(o(306,s,""))}return n;case 0:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),Va(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),nf(e,n,s,c,i);case 3:e:{if(rf(n),e===null)throw Error(o(387));s=n.pendingProps,f=n.memoizedState,c=f.element,vd(e,n),ds(n,s,null,i);var w=n.memoizedState;if(s=w.element,f.isDehydrated)if(f={element:s,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},n.updateQueue.baseState=f,n.memoizedState=f,n.flags&256){c=Gr(Error(o(423)),n),n=of(e,n,s,i,c);break e}else if(s!==c){c=Gr(Error(o(424)),n),n=of(e,n,s,i,c);break e}else for(Pt=An(n.stateNode.containerInfo.firstChild),Mt=n,Fe=!0,Wt=null,i=md(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Wr(),s===c){n=Sn(e,n,i);break e}pt(e,n,s,i)}n=n.child}return n;case 5:return Sd(n),e===null&&va(n),s=n.type,c=n.pendingProps,f=e!==null?e.memoizedProps:null,w=c.children,ua(s,c)?w=null:f!==null&&ua(s,f)&&(n.flags|=32),tf(e,n),pt(e,n,w,i),n.child;case 6:return e===null&&va(n),null;case 13:return sf(e,n,i);case 4:return Ca(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=Yr(n,null,s,i):pt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),qd(e,n,s,c,i);case 7:return pt(e,n,n.pendingProps,i),n.child;case 8:return pt(e,n,n.pendingProps.children,i),n.child;case 12:return pt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(s=n.type._context,c=n.pendingProps,f=n.memoizedProps,w=c.value,Ae(as,s._currentValue),s._currentValue=w,f!==null)if(Ut(f.value,w)){if(f.children===c.children&&!yt.current){n=Sn(e,n,i);break e}}else for(f=n.child,f!==null&&(f.return=n);f!==null;){var I=f.dependencies;if(I!==null){w=f.child;for(var R=I.firstContext;R!==null;){if(R.context===s){if(f.tag===1){R=wn(-1,i&-i),R.tag=2;var G=f.updateQueue;if(G!==null){G=G.shared;var oe=G.pending;oe===null?R.next=R:(R.next=oe.next,oe.next=R),G.pending=R}}f.lanes|=i,R=f.alternate,R!==null&&(R.lanes|=i),ka(f.return,i,n),I.lanes|=i;break}R=R.next}}else if(f.tag===10)w=f.type===n.type?null:f.child;else if(f.tag===18){if(w=f.return,w===null)throw Error(o(341));w.lanes|=i,I=w.alternate,I!==null&&(I.lanes|=i),ka(w,i,n),w=f.sibling}else w=f.child;if(w!==null)w.return=f;else for(w=f;w!==null;){if(w===n){w=null;break}if(f=w.sibling,f!==null){f.return=w.return,w=f;break}w=w.return}f=w}pt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,Qr(n,i),c=bt(c),s=s(c),n.flags|=1,pt(e,n,s,i),n.child;case 14:return s=n.type,c=Yt(s,n.pendingProps),c=Yt(s.type,c),Zd(e,n,s,c,i);case 15:return Jd(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),ws(e,n),n.tag=1,vt(s)?(e=!0,ns(n)):e=!1,Qr(n,i),Ud(n,s,c),ba(n,s,c,i),Ba(null,n,s,!0,e,i);case 19:return af(e,n,i);case 22:return ef(e,n,i)}throw Error(o(156,n.tag))};function zf(e,n){return zo(e,n)}function _0(e,n,i,s){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vt(e,n,i,s){return new _0(e,n,i,s)}function uu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function k0(e){if(typeof e=="function")return uu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===B)return 14}return 2}function Yn(e,n){var i=e.alternate;return i===null?(i=Vt(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function Ts(e,n,i,s,c,f){var w=2;if(s=e,typeof e=="function")uu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return mr(i.children,c,f,n);case X:w=8,c|=8;break;case K:return e=Vt(12,i,n,c|2),e.elementType=K,e.lanes=f,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=f,e;case C:return e=Vt(19,i,n,c),e.elementType=C,e.lanes=f,e;case V:return zs(i,c,f,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:w=10;break e;case q:w=9;break e;case ee:w=11;break e;case B:w=14;break e;case F:w=16,s=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=Vt(w,i,n,c),n.elementType=e,n.type=s,n.lanes=f,n}function mr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function zs(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=V,e.lanes=i,e.stateNode={isHidden:!1},e}function cu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function du(e,n,i){return n=Vt(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function E0(e,n,i,s,c){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=rr(0),this.expirationTimes=rr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function fu(e,n,i,s,c,f,w,I,R){return e=new E0(e,n,i,I,R),n===1?(n=1,f===!0&&(n|=8)):n=0,f=Vt(3,null,null,n),e.current=f,f.stateNode=e,f.memoizedState={element:s,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Na(f),e}function N0(e,n,i){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(),vu.exports=D0(),vu.exports}var Yf;function O0(){if(Yf)return bs;Yf=1;var t=sp();return bs.createRoot=t.createRoot,bs.hydrateRoot=t.hydrateRoot,bs}var b0=O0();function F0(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(d=>typeof d=="string"?d:d&&typeof d=="object"&&"msg"in d?String(d.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Tt(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const l=await o.text();throw new Error(F0(l,o.statusText||"Request failed"))}return o.json()}const H0=["github_token","bitbucket_token","ai_api_key","ai_model","ai_base_url"],kt={health:()=>Tt("/api/health"),settings:()=>Tt("/api/settings"),saveSettings:t=>{const r={...t};for(const o of H0)r[o]===""&&delete r[o];return Tt("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Tt("/api/repos"),index:(t,r=!0)=>Tt("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Tt(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Tt(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Tt("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:l,incremental:!0,three_dot:!0})}),init:(t,r=!1)=>Tt("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Tt("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Tt(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Tt("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),residual:t=>Tt("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function V0(t){return t.replaceAll("_"," ")}function B0(t){return t.replaceAll("_"," ")}function Ku(t){return t.split(".").pop()||t}function U0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function Fs(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yo({className:t,children:r}){return y.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function W0({className:t}){return y.jsxs(yo,{className:t,children:[y.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),y.jsx("path",{d:"M9.5 3.5V7H13"}),y.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function Y0({className:t}){return y.jsxs(yo,{className:t,children:[y.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),y.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),y.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),y.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function X0({className:t}){return y.jsxs(yo,{className:t,children:[y.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),y.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),y.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),y.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function Q0({className:t}){return y.jsxs(yo,{className:t,children:[y.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),y.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),y.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),y.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function K0({className:t}){return y.jsxs(yo,{className:t,children:[y.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),y.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Ke(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function pl(){for(var t=0,r=arguments.length,o={},l;t=0&&(l=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:l}})}Gs.prototype=pl.prototype={constructor:Gs,on:function(t,r){var o=this._,l=q0(t+"",o),a,u=-1,d=l.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),l=0,a,u;l=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),Qf.hasOwnProperty(r)?{space:Qf[r],local:t}:t}function J0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Au&&r.documentElement.namespaceURI===Au?r.createElement(t):r.createElementNS(o,t)}}function ey(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function lp(t){var r=gl(t);return(r.local?ey:J0)(r)}function ty(){}function Gu(t){return t==null?ty:function(){return this.querySelector(t)}}function ny(t){typeof t!="function"&&(t=Gu(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=T+1);!(b=k[N])&&++N<_;);P._next=b||null}}return d=new Rt(d,l),d._enter=h,d._exit=p,d}function _y(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function ky(){return new Rt(this._exit||this._groups.map(dp),this._parents)}function Ey(t,r,o){var l=this.enter(),a=this,u=this.exit();return typeof t=="function"?(l=t(l),l&&(l=l.selection())):l=l.append(t+""),r!=null&&(a=r(a),a&&(a=a.selection())),o==null?u.remove():o(u),l&&a?l.merge(a).order():a}function Ny(t){for(var r=t.selection?t.selection():t,o=this._groups,l=r._groups,a=o.length,u=l.length,d=Math.min(a,u),h=new Array(a),p=0;p=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function jy(t){t||(t=My);function r(x,g){return x&&g?t(x.__data__,g.__data__):!x-!g}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function Py(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Iy(){return Array.from(this)}function Ty(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?Vy:typeof r=="function"?Uy:By)(t,r,o??"")):oi(this.node(),t)}function oi(t,r){return t.style.getPropertyValue(r)||fp(t).getComputedStyle(t,null).getPropertyValue(r)}function Yy(t){return function(){delete this[t]}}function Xy(t,r){return function(){this[t]=r}}function Qy(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function Ky(t,r){return arguments.length>1?this.each((r==null?Yy:typeof r=="function"?Qy:Xy)(t,r)):this.node()[t]}function hp(t){return t.trim().split(/^|\s+/)}function qu(t){return t.classList||new pp(t)}function pp(t){this._node=t,this._names=hp(t.getAttribute("class")||"")}pp.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 gp(t,r){for(var o=qu(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function kv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function $u(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:h,dx:p,dy:v,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:m}})}$u.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Rv(t){return!t.ctrlKey&&!t.button}function Lv(){return this.parentNode}function Av(t,r){return r??{x:t.x,y:t.y}}function $v(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sp(){var t=Rv,r=Lv,o=Av,l=$v,a={},u=pl("start","drag","end"),d=0,h,p,v,m,x=0;function g(P){P.on("mousedown.drag",S).filter(l).on("touchstart.drag",k).on("touchmove.drag",E,zv).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function S(P,b){if(!(m||!t.call(this,P,b))){var $=N(this,r.call(this,P,b),P,b,"mouse");$&&(zt(P.view).on("mousemove.drag",_,so).on("mouseup.drag",M,so),xp(P.view),Su(P),v=!1,h=P.clientX,p=P.clientY,$("start",P))}}function _(P){if(ri(P),!v){var b=P.clientX-h,$=P.clientY-p;v=b*b+$*$>x}a.mouse("drag",P)}function M(P){zt(P.view).on("mousemove.drag mouseup.drag",null),wp(P.view,v),ri(P),a.mouse("end",P)}function k(P,b){if(t.call(this,P,b)){var $=P.changedTouches,H=r.call(this,P,b),X=$.length,K,ne;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Vs(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Vs(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=Ov.exec(t))?new Et(r[1],r[2],r[3],1):(r=bv.exec(t))?new Et(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Fv.exec(t))?Vs(r[1],r[2],r[3],r[4]):(r=Hv.exec(t))?Vs(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Vv.exec(t))?th(r[1],r[2]/100,r[3]/100,1):(r=Bv.exec(t))?th(r[1],r[2]/100,r[3]/100,r[4]):Kf.hasOwnProperty(t)?Zf(Kf[t]):t==="transparent"?new Et(NaN,NaN,NaN,0):null}function Zf(t){return new Et(t>>16&255,t>>8&255,t&255,1)}function Vs(t,r,o,l){return l<=0&&(t=r=o=NaN),new Et(t,r,o,l)}function Yv(t){return t instanceof xo||(t=Sr(t)),t?(t=t.rgb(),new Et(t.r,t.g,t.b,t.opacity)):new Et}function Du(t,r,o,l){return arguments.length===1?Yv(t):new Et(t,r,o,l??1)}function Et(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}Zu(Et,Du,_p(xo,{brighter(t){return t=t==null?nl:Math.pow(nl,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?lo:Math.pow(lo,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Et(xr(this.r),xr(this.g),xr(this.b),rl(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Jf,formatHex:Jf,formatHex8:Xv,formatRgb:eh,toString:eh}));function Jf(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}`}function Xv(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}${vr((isNaN(this.opacity)?1:this.opacity)*255)}`}function eh(){const t=rl(this.opacity);return`${t===1?"rgb(":"rgba("}${xr(this.r)}, ${xr(this.g)}, ${xr(this.b)}${t===1?")":`, ${t})`}`}function rl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function xr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function vr(t){return t=xr(t),(t<16?"0":"")+t.toString(16)}function th(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new qt(t,r,o,l)}function kp(t){if(t instanceof qt)return new qt(t.h,t.s,t.l,t.opacity);if(t instanceof xo||(t=Sr(t)),!t)return new qt;if(t instanceof qt)return t;t=t.rgb();var r=t.r/255,o=t.g/255,l=t.b/255,a=Math.min(r,o,l),u=Math.max(r,o,l),d=NaN,h=u-a,p=(u+a)/2;return h?(r===u?d=(o-l)/h+(o0&&p<1?0:d,new qt(d,h,p,t.opacity)}function Qv(t,r,o,l){return arguments.length===1?kp(t):new qt(t,r,o,l??1)}function qt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}Zu(qt,Qv,_p(xo,{brighter(t){return t=t==null?nl:Math.pow(nl,t),new qt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?lo:Math.pow(lo,t),new qt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,l=o+(o<.5?o:1-o)*r,a=2*o-l;return new Et(_u(t>=240?t-240:t+120,a,l),_u(t,a,l),_u(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new qt(nh(this.h),Bs(this.s),Bs(this.l),rl(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=rl(this.opacity);return`${t===1?"hsl(":"hsla("}${nh(this.h)}, ${Bs(this.s)*100}%, ${Bs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function nh(t){return t=(t||0)%360,t<0?t+360:t}function Bs(t){return Math.max(0,Math.min(1,t||0))}function _u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const Ju=t=>()=>t;function Kv(t,r){return function(o){return t+o*r}}function Gv(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(l){return Math.pow(t+l*r,o)}}function qv(t){return(t=+t)==1?Ep:function(r,o){return o-r?Gv(r,o,t):Ju(isNaN(r)?o:r)}}function Ep(t,r){var o=r-t;return o?Kv(t,o):Ju(isNaN(t)?r:t)}const il=(function t(r){var o=qv(r);function l(a,u){var d=o((a=Du(a)).r,(u=Du(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Ep(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=h(m),a.b=p(m),a.opacity=v(m),a+""}}return l.gamma=t,l})(1);function Zv(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,l=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[d]?h[d]+=u:h[++d]=u),(l=l[0])===(a=a[0])?h[d]?h[d]+=a:h[++d]=a:(h[++d]=null,p.push({i:d,x:cn(l,a)})),o=ku.lastIndex;return o180?m+=360:m-v>180&&(v+=360),g.push({i:x.push(a(x)+"rotate(",null,l)-2,x:cn(v,m)})):m&&x.push(a(x)+"rotate("+m+l)}function h(v,m,x,g){v!==m?g.push({i:x.push(a(x)+"skewX(",null,l)-2,x:cn(v,m)}):m&&x.push(a(x)+"skewX("+m+l)}function p(v,m,x,g,S,_){if(v!==x||m!==g){var M=S.push(a(S)+"scale(",null,",",null,")");_.push({i:M-4,x:cn(v,x)},{i:M-2,x:cn(m,g)})}else(x!==1||g!==1)&&S.push(a(S)+"scale("+x+","+g+")")}return function(v,m){var x=[],g=[];return v=t(v),m=t(m),u(v.translateX,v.translateY,m.translateX,m.translateY,x,g),d(v.rotate,m.rotate,x,g),h(v.skewX,m.skewX,x,g),p(v.scaleX,v.scaleY,m.scaleX,m.scaleY,x,g),v=m=null,function(S){for(var _=-1,M=g.length,k;++_=0&&t._call.call(void 0,r),t=t._next;--si}function oh(){_r=(sl=uo.now())+ml,si=no=0;try{hx()}finally{si=0,gx(),_r=0}}function px(){var t=uo.now(),r=t-sl;r>Mp&&(ml-=r,sl=t)}function gx(){for(var t,r=ol,o,l=1/0;r;)r._call?(l>r._time&&(l=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:ol=o);ro=t,Fu(l)}function Fu(t){if(!si){no&&(no=clearTimeout(no));var r=t-_r;r>24?(t<1/0&&(no=setTimeout(oh,t-uo.now()-ml)),eo&&(eo=clearInterval(eo))):(eo||(sl=uo.now(),eo=setInterval(px,Mp)),si=1,Pp(oh))}}function sh(t,r,o){var l=new ll;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var mx=pl("start","end","cancel","interrupt"),yx=[],Tp=0,lh=1,Hu=2,Zs=3,ah=4,Vu=5,Js=6;function yl(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;vx(t,o,{name:r,index:l,group:a,on:mx,tween:yx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Tp})}function tc(t,r){var o=tn(t,r);if(o.state>Tp)throw new Error("too late; already scheduled");return o}function fn(t,r){var o=tn(t,r);if(o.state>Zs)throw new Error("too late; already running");return o}function tn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function vx(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Ip(u,0,o.time);function u(v){o.state=lh,o.timer.restart(d,o.delay,o.time),o.delay<=v&&d(v-o.delay)}function d(v){var m,x,g,S;if(o.state!==lh)return p();for(m in l)if(S=l[m],S.name===o.name){if(S.state===Zs)return sh(d);S.state===ah?(S.state=Js,S.timer.stop(),S.on.call("interrupt",t,t.__data__,S.index,S.group),delete l[m]):+mHu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Qx(t,r,o){var l,a,u=Xx(r)?tc:fn;return function(){var d=u(this,t),h=d.on;h!==l&&(a=(l=h).copy()).on(r,o),d.on=a}}function Kx(t,r){var o=this._id;return arguments.length<2?tn(this.node(),o).on.on(t):this.each(Qx(o,t,r))}function Gx(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function qx(){return this.on("end.remove",Gx(this._id))}function Zx(t){var r=this._name,o=this._id;typeof t!="function"&&(t=Gu(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function kw(t,{sourceEvent:r,target:o,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function En(t,r,o){this.k=t,this.x=r,this.y=o}En.prototype={constructor:En,scale:function(t){return t===1?this:new En(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new En(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var vl=new En(1,0,0);Ap.prototype=En.prototype;function Ap(t){for(;!t.__zoom;)if(!(t=t.parentNode))return vl;return t.__zoom}function Eu(t){t.stopImmediatePropagation()}function to(t){t.preventDefault(),t.stopImmediatePropagation()}function Ew(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Nw(){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 uh(){return this.__zoom||vl}function Cw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mw(t,r,o){var l=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],d=t.invertY(r[1][1])-o[1][1];return t.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),d>u?(u+d)/2:Math.min(0,u)||Math.max(0,d))}function $p(){var t=Ew,r=Nw,o=Mw,l=Cw,a=jw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],h=250,p=qs,v=pl("start","zoom","end"),m,x,g,S=500,_=150,M=0,k=10;function E(C){C.property("__zoom",uh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",q).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,B,F,V){var A=C.selection?C.selection():C;A.property("__zoom",uh),C!==A?b(C,B,F,V):A.interrupt().each(function(){$(this,arguments).event(V).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},E.scaleBy=function(C,B,F,V){E.scaleTo(C,function(){var A=this.__zoom.k,L=typeof B=="function"?B.apply(this,arguments):B;return A*L},F,V)},E.scaleTo=function(C,B,F,V){E.transform(C,function(){var A=r.apply(this,arguments),L=this.__zoom,O=F==null?P(A):typeof F=="function"?F.apply(this,arguments):F,j=L.invert(O),z=typeof B=="function"?B.apply(this,arguments):B;return o(N(T(L,z),O,j),A,d)},F,V)},E.translateBy=function(C,B,F,V){E.transform(C,function(){return o(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof F=="function"?F.apply(this,arguments):F),r.apply(this,arguments),d)},null,V)},E.translateTo=function(C,B,F,V,A){E.transform(C,function(){var L=r.apply(this,arguments),O=this.__zoom,j=V==null?P(L):typeof V=="function"?V.apply(this,arguments):V;return o(vl.translate(j[0],j[1]).scale(O.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof F=="function"?-F.apply(this,arguments):-F),L,d)},V,A)};function T(C,B){return B=Math.max(u[0],Math.min(u[1],B)),B===C.k?C:new En(B,C.x,C.y)}function N(C,B,F){var V=B[0]-F[0]*C.k,A=B[1]-F[1]*C.k;return V===C.x&&A===C.y?C:new En(C.k,V,A)}function P(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function b(C,B,F,V){C.on("start.zoom",function(){$(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(V).end()}).tween("zoom",function(){var A=this,L=arguments,O=$(A,L).event(V),j=r.apply(A,L),z=F==null?P(j):typeof F=="function"?F.apply(A,L):F,re=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),te=A.__zoom,ae=typeof B=="function"?B.apply(A,L):B,de=p(te.invert(z).concat(re/te.k),ae.invert(z).concat(re/ae.k));return function(ce){if(ce===1)ce=ae;else{var Q=de(ce),se=re/Q[2];ce=new En(se,z[0]-Q[0]*se,z[1]-Q[1]*se)}O.zoom(null,ce)}})}function $(C,B,F){return!F&&C.__zooming||new H(C,B)}function H(C,B){this.that=C,this.args=B,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,B),this.taps=0}H.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,B){return this.mouse&&C!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var B=zt(this.that).datum();v.call(C,this.that,new kw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),B)}};function X(C,...B){if(!t.apply(this,arguments))return;var F=$(this,B).event(C),V=this.__zoom,A=Math.max(u[0],Math.min(u[1],V.k*Math.pow(2,l.apply(this,arguments)))),L=Gt(C);if(F.wheel)(F.mouse[0][0]!==L[0]||F.mouse[0][1]!==L[1])&&(F.mouse[1]=V.invert(F.mouse[0]=L)),clearTimeout(F.wheel);else{if(V.k===A)return;F.mouse=[L,V.invert(L)],el(this),F.start()}to(C),F.wheel=setTimeout(O,_),F.zoom("mouse",o(N(T(V,A),F.mouse[0],F.mouse[1]),F.extent,d));function O(){F.wheel=null,F.end()}}function K(C,...B){if(g||!t.apply(this,arguments))return;var F=C.currentTarget,V=$(this,B,!0).event(C),A=zt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",re,!0),L=Gt(C,F),O=C.clientX,j=C.clientY;xp(C.view),Eu(C),V.mouse=[L,this.__zoom.invert(L)],el(this),V.start();function z(te){if(to(te),!V.moved){var ae=te.clientX-O,de=te.clientY-j;V.moved=ae*ae+de*de>M}V.event(te).zoom("mouse",o(N(V.that.__zoom,V.mouse[0]=Gt(te,F),V.mouse[1]),V.extent,d))}function re(te){A.on("mousemove.zoom mouseup.zoom",null),wp(te.view,V.moved),to(te),V.event(te).end()}}function ne(C,...B){if(t.apply(this,arguments)){var F=this.__zoom,V=Gt(C.changedTouches?C.changedTouches[0]:C,this),A=F.invert(V),L=F.k*(C.shiftKey?.5:2),O=o(N(T(F,L),V,A),r.apply(this,B),d);to(C),h>0?zt(this).transition().duration(h).call(b,O,V,C):zt(this).call(E.transform,O,V,C)}}function q(C,...B){if(t.apply(this,arguments)){var F=C.touches,V=F.length,A=$(this,B,C.changedTouches.length===V).event(C),L,O,j,z;for(Eu(C),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:o,targetHandle:l})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o: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.`},co=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Dp=["Enter"," ","Escape"],Op={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var li;(function(t){t.Strict="strict",t.Loose="loose"})(li||(li={}));var wr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(wr||(wr={}));var fo;(function(t){t.Partial="partial",t.Full="full"})(fo||(fo={}));const bp={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var qn;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(qn||(qn={}));var al;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(al||(al={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const ch={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function Fp(t){return t===null?null:t?"valid":"invalid"}const Hp=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Pw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),rc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),wo=(t,r=[0,0])=>{const{width:o,height:l}=nn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Iw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const l=t.reduce((a,u)=>{const d=typeof u=="string";let h=!r.nodeLookup&&!d?u:void 0;return r.nodeLookup&&(h=d?r.nodeLookup.get(u):rc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,xl(a,ul(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?wl(l):{x:0,y:0,width:0,height:0}},So=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=xl(o,ul(a)),l=!0)}),l?wl(o):{x:0,y:0,width:0,height:0}},ic=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const h=(r.x-o)/a,p=(r.y-l)/a,v=r.width/a,m=r.height/a,x=[];for(const g of t.values()){const{measured:S,selectable:_=!0,hidden:M=!1}=g;if(d&&!_||M)continue;const k=S.width??g.width??g.initialWidth??0,E=S.height??g.height??g.initialHeight??0,{x:T,y:N}=g.internals.positionAbsolute,P=Wp(h,p,v,m,T,N,k,E),b=k*E,$=u&&P>0;(!g.internals.handleBounds||$||P>=b||g.dragging)&&x.push(g)}return x},Tw=(t,r)=>{const o=new Set;return t.forEach(l=>{o.add(l.id)}),r.filter(l=>o.has(l.source)||o.has(l.target))};function zw(t,r){const o=new Map,l=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:d,height:h}=nn(a);u=d>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!l||l.has(a.id))&&o.set(a.id,a)}),o}async function Rw({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const h=zw(t,d),p=So(h),v=sc(p,r,o,(d==null?void 0:d.minZoom)??a,(d==null?void 0:d.maxZoom)??u,(d==null?void 0:d.padding)??.1);return await l.setViewport(v,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function Vp({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:l=[0,0],nodeExtent:a,onError:u}){const d=o.get(t),h=d.parentId?o.get(d.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},m=d.origin??l;let x=d.extent||a;if(d.extent==="parent"&&!d.expandParent)if(!h)u==null||u("005",en.error005());else{const{width:S,height:_}=nn(h);S&&_&&(x=[[p,v],[p+S,v+_]])}else h&&Er(d.extent)&&(x=[[d.extent[0][0]+p,d.extent[0][1]+v],[d.extent[1][0]+p,d.extent[1][1]+v]]);const g=Er(x)?kr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",en.error015())),{position:{x:g.x-p+(d.measured.width??0)*m[0],y:g.y-v+(d.measured.height??0)*m[1]},positionAbsolute:g}}async function Lw({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(g=>g.id)),d=[];for(const g of o){if(g.deletable===!1)continue;const S=u.has(g.id),_=!S&&g.parentId&&d.find(M=>M.id===g.parentId);(S||_)&&d.push(g)}const h=new Set(r.map(g=>g.id)),p=l.filter(g=>g.deletable!==!1),m=Tw(d,p);for(const g of p)h.has(g.id)&&!m.find(_=>_.id===g.id)&&m.push(g);if(!a)return{edges:m,nodes:d};const x=await a({nodes:d,edges:m});return typeof x=="boolean"?x?{edges:m,nodes:d}:{edges:[],nodes:[]}:x}const ai=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),kr=(t={x:0,y:0},r,o)=>({x:ai(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:ai(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function Bp(t,r,o){const{width:l,height:a}=nn(o),{x:u,y:d}=o.internals.positionAbsolute;return kr(t,[[u,d],[u+l,d+a]],r)}const dh=(t,r,o)=>to?-ai(Math.abs(t-o),1,r)/r:0,oc=(t,r,o=15,l=40)=>{const a=dh(t.x,l,r.width-l)*o,u=dh(t.y,l,r.height-l)*o;return[a,u]},xl=(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)}),Bu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),wl=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),ho=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=rc(t)?t.internals.positionAbsolute:wo(t,r);return{x:o,y:l,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},ul=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=rc(t)?t.internals.positionAbsolute:wo(t,r);return{x:o,y:l,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:l+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},Up=(t,r)=>wl(xl(Bu(t),Bu(r))),Wp=(t,r,o,l,a,u,d,h)=>{const p=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),v=Math.max(0,Math.min(r+l,u+h)-Math.max(r,u));return Math.ceil(p*v)},cl=(t,r)=>Wp(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),fh=t=>Zt(t.width)&&Zt(t.height)&&Zt(t.x)&&Zt(t.y),Zt=t=>!isNaN(t)&&isFinite(t),Yp=(t,r)=>(o,l)=>{},_o=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ko=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const h={x:(t-o)/a,y:(r-l)/a};return u?_o(h,d):h},ui=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function ti(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Aw(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=ti(t,o),a=ti(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=ti(t.top??t.y??0,o),a=ti(t.bottom??t.y??0,o),u=ti(t.left??t.x??0,r),d=ti(t.right??t.x??0,r);return{top:l,right:d,bottom:a,left:u,x:u+d,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function $w(t,r,o,l,a,u){const{x:d,y:h}=ui(t,[r,o,l]),{x:p,y:v}=ui({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-p,x=u-v;return{left:Math.floor(d),top:Math.floor(h),right:Math.floor(m),bottom:Math.floor(x)}}const sc=(t,r,o,l,a,u)=>{const d=Aw(u,r,o),h=(r-d.x)/t.width,p=(o-d.y)/t.height,v=Math.min(h,p),m=ai(v,l,a),x=t.x+t.width/2,g=t.y+t.height/2,S=r/2-x*m,_=o/2-g*m,M=$w(t,S,_,m,r,o),k={left:Math.min(M.left-d.left,0),top:Math.min(M.top-d.top,0),right:Math.min(M.right-d.right,0),bottom:Math.min(M.bottom-d.bottom,0)};return{x:S-k.left+k.right,y:_-k.top+k.bottom,zoom:m}},po=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Er(t){return t!=null&&t!=="parent"}function nn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function Xp(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function Qp(t,r={width:0,height:0},o,l,a){const u={...t},d=l.get(o);if(d){const h=d.origin||a;u.x+=d.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=d.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function hh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function Dw(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function Ow(t){return{...Op,...t||{}}}function oo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=Jt(t),h=ko({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:p,y:v}=o?_o(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const lc=t=>({width:t.offsetWidth,height:t.offsetHeight}),Kp=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},bw=["INPUT","SELECT","TEXTAREA"];function Gp(t){var l,a;const r=((a=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:bw.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const qp=t=>"clientX"in t,Jt=(t,r)=>{var u,d;const o=qp(t),l=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(d=t.touches)==null?void 0:d[0].clientY;return{x:l-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},ph=(t,r,o,l,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),type:t,nodeId:a,position:d.getAttribute("data-handlepos"),x:(h.left-o.left)/l,y:(h.top-o.top)/l,...lc(d)}})};function Zp({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:h}){const p=t*.125+a*.375+d*.375+o*.125,v=r*.125+u*.375+h*.375+l*.125,m=Math.abs(p-t),x=Math.abs(v-r);return[p,v,m,x]}function Ys(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function gh({pos:t,x1:r,y1:o,x2:l,y2:a,c:u}){switch(t){case Se.Left:return[r-Ys(r-l,u),o];case Se.Right:return[r+Ys(l-r,u),o];case Se.Top:return[r,o-Ys(o-a,u)];case Se.Bottom:return[r,o+Ys(a-o,u)]}}function Jp({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[h,p]=gh({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[v,m]=gh({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,g,S,_]=Zp({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:m});return[`M${t},${r} C${h},${p} ${v},${m} ${l},${a}`,x,g,S,_]}function eg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const Vw=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,Bw=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),Uw=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",en.error006()),r;const l=o.getEdgeId||Vw;let a;return Hp(t)?a={...t}:a={...t,id:l(t)},Bw(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function tg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,h]=eg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,h]}const mh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},Ww=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function Yw({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const h=mh[r],p=mh[l],v={x:t.x+h.x*u,y:t.y+h.y*u},m={x:o.x+p.x*u,y:o.y+p.y*u},x=Ww({source:v,sourcePosition:r,target:m}),g=x.x!==0?"x":"y",S=x[g];let _=[],M,k;const E={x:0,y:0},T={x:0,y:0},[,,N,P]=eg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[g]*p[g]===-1){g==="x"?(M=a.x??v.x+(m.x-v.x)*d,k=a.y??(v.y+m.y)/2):(M=a.x??(v.x+m.x)/2,k=a.y??v.y+(m.y-v.y)*d);const X=[{x:M,y:v.y},{x:M,y:m.y}],K=[{x:v.x,y:k},{x:m.x,y:k}];h[g]===S?_=g==="x"?X:K:_=g==="x"?K:X}else{const X=[{x:v.x,y:m.y}],K=[{x:m.x,y:v.y}];if(g==="x"?_=h.x===S?K:X:_=h.y===S?X:K,r===l){const C=Math.abs(t[g]-o[g]);if(C<=u){const B=Math.min(u-1,u-C);h[g]===S?E[g]=(v[g]>t[g]?-1:1)*B:T[g]=(m[g]>o[g]?-1:1)*B}}if(r!==l){const C=g==="x"?"y":"x",B=h[g]===p[C],F=v[C]>m[C],V=v[C]=J?(M=(ne.x+q.x)/2,k=_[0].y):(M=_[0].x,k=(ne.y+q.y)/2)}const b={x:v.x+E.x,y:v.y+E.y},$={x:m.x+T.x,y:m.y+T.y};return[[t,...b.x!==_[0].x||b.y!==_[0].y?[b]:[],..._,...$.x!==_[_.length-1].x||$.y!==_[_.length-1].y?[$]:[],o],M,k,N,P]}function Xw(t,r,o,l){const a=Math.min(yh(t,r)/2,yh(r,o)/2,l),{x:u,y:d}=r;if(t.x===u&&u===o.x||t.y===d&&d===o.y)return`L${u} ${d}`;if(t.y===d){const v=t.xo.id===r):t[0])||null}function Wu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function Kw(t,{id:r,defaultColor:o,defaultMarkerStart:l,defaultMarkerEnd:a}){const u=new Set;return t.reduce((d,h)=>([h.markerStart||l,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=Wu(p,r);u.has(v)||(d.push({id:v,color:p.color||o,...p}),u.add(v))}}),d),[]).sort((d,h)=>d.id.localeCompare(h.id))}const ng=1e3,Gw=10,ac={nodeOrigin:[0,0],nodeExtent:co,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},qw={...ac,checkEquality:!0};function uc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function Zw(t,r,o){const l=uc(ac,o);for(const a of t.values())if(a.parentId)dc(a,t,r,l);else{const u=wo(a,l.nodeOrigin),d=Er(a.extent)?a.extent:l.nodeExtent,h=kr(u,d,nn(a));a.internals.positionAbsolute=h}}function Jw(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],l=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&l.push(u)}return{source:o,target:l}}function cc(t){return t==="manual"}function Yu(t,r,o,l={}){var m,x;const a=uc(qw,l),u={i:0},d=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!cc(a.zIndexMode)?ng:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const g of t){let S=d.get(g.id);if(a.checkEquality&&g===(S==null?void 0:S.internals.userNode))r.set(g.id,S);else{const _=wo(g,a.nodeOrigin),M=Er(g.extent)?g.extent:a.nodeExtent,k=kr(_,M,nn(g));S={...a.defaults,...g,measured:{width:(m=g.measured)==null?void 0:m.width,height:(x=g.measured)==null?void 0:x.height},internals:{positionAbsolute:k,handleBounds:Jw(g,S),z:rg(g,h,a.zIndexMode),userNode:g}},r.set(g.id,S)}(S.measured===void 0||S.measured.width===void 0||S.measured.height===void 0)&&!S.hidden&&(p=!1),g.parentId&&dc(S,r,o,l,u),v||(v=g.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function e1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function dc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:h,zIndexMode:p}=uc(ac,l),v=t.parentId,m=r.get(v);if(!m){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}e1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&p==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*Gw),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!cc(p)?ng:0,{x:g,y:S,z:_}=t1(t,m,d,h,x,p),{positionAbsolute:M}=t.internals,k=g!==M.x||S!==M.y;(k||_!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:k?{x:g,y:S}:M,z:_}})}function rg(t,r,o){const l=Zt(t.zIndex)?t.zIndex:0;return cc(o)?l:l+(t.selected?r:0)}function t1(t,r,o,l,a,u){const{x:d,y:h}=r.internals.positionAbsolute,p=nn(t),v=wo(t,o),m=Er(t.extent)?kr(v,t.extent,p):v;let x=kr({x:d+m.x,y:h+m.y},l,p);t.extent==="parent"&&(x=Bp(x,p,r));const g=rg(t,a,u),S=r.internals.z??0;return{x:x.x,y:x.y,z:S>=g?S+1:g}}function fc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((d=u.get(h.parentId))==null?void 0:d.expandedRect)??ho(p),m=Up(v,h.rect);u.set(h.parentId,{expandedRect:m,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var N;const m=p.internals.positionAbsolute,x=nn(p),g=p.origin??l,S=h.x0||_>0||E||T)&&(a.push({id:v,type:"position",position:{x:p.position.x-S+E,y:p.position.y-_+T}}),(N=o.get(v))==null||N.forEach(P=>{t.some(b=>b.id===P.id)||a.push({id:P.id,type:"position",position:{x:P.position.x+S,y:P.position.y+_}})})),(x.width0){const S=fc(g,r,o,a);v.push(...S)}return{changes:v,updatedInternals:p}}async function r1({delta:t,panZoom:r,transform:o,translateExtent:l,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const d=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],l);return!!d&&(d.x!==o[0]||d.y!==o[1]||d.k!==o[2])}function Sh(t,r,o,l,a,u){let d=a;const h=l.get(d)||new Map;l.set(d,h.set(o,r)),d=`${a}-${t}`;const p=l.get(d)||new Map;if(l.set(d,p.set(o,r)),u){d=`${a}-${t}-${u}`;const v=l.get(d)||new Map;l.set(d,v.set(o,r))}}function ig(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:h=null}=l,p={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:h},v=`${a}-${d}--${u}-${h}`,m=`${u}-${h}--${a}-${d}`;Sh("source",p,m,t,a,d),Sh("target",p,v,t,u,h),r.set(l.id,l)}}function og(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:og(o,r):!1}function _h(t,r,o){var a;let l=t;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,r))return!0;if(l===o)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function i1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!og(d,t))&&(d.draggable||r&&typeof d.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Nu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,h,p;const a=[];for(const[v,m]of r){const x=(d=o.get(v))==null?void 0:d.internals.userNode;x&&a.push({...x,position:m.position,dragging:l})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:l}:a[0],a]}function o1({dragItems:t,snapGrid:r,x:o,y:l}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:l-a.distance.y},d=_o(u,r);return{x:d.x-u.x,y:d.y-u.y}}function s1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,h=new Map,p=!1,v={x:0,y:0},m=null,x=!1,g=null,S=!1,_=!1,M=null;function k({noDragClassName:T,handleSelector:N,domNode:P,isSelectable:b,nodeId:$,nodeClickDistance:H=0}){g=zt(P);function X({x:ee,y:J}){const{nodeLookup:C,nodeExtent:B,snapGrid:F,snapToGrid:V,nodeOrigin:A,onNodeDrag:L,onSelectionDrag:O,onError:j,updateNodePositions:z}=r();u={x:ee,y:J};let re=!1;const te=h.size>1,ae=te&&B?Bu(So(h)):null,de=te&&V?o1({dragItems:h,snapGrid:F,x:ee,y:J}):null;for(const[ce,Q]of h){if(!C.has(ce))continue;let se={x:ee-Q.distance.x,y:J-Q.distance.y};V&&(se=de?{x:Math.round(se.x+de.x),y:Math.round(se.y+de.y)}:_o(se,F));let he=null;if(te&&B&&!Q.extent&&ae){const{positionAbsolute:me}=Q.internals,Ce=me.x-ae.x+B[0][0],Me=me.x+Q.measured.width-ae.x2+B[1][0],Pe=me.y-ae.y+B[0][1],Re=me.y+Q.measured.height-ae.y2+B[1][1];he=[[Ce,Pe],[Me,Re]]}const{position:we,positionAbsolute:ve}=Vp({nodeId:ce,nextPosition:se,nodeLookup:C,nodeExtent:he||B,nodeOrigin:A,onError:j});re=re||Q.position.x!==we.x||Q.position.y!==we.y,Q.position=we,Q.internals.positionAbsolute=ve}if(_=_||re,!!re&&(z(h,!0),M&&(l||L||!$&&O))){const[ce,Q]=Nu({nodeId:$,dragItems:h,nodeLookup:C});l==null||l(M,h,ce,Q),L==null||L(M,ce,Q),$||O==null||O(M,Q)}}async function K(){if(!m)return;const{transform:ee,panBy:J,autoPanSpeed:C,autoPanOnNodeDrag:B}=r();if(!B){p=!1,cancelAnimationFrame(d);return}const[F,V]=oc(v,m,C);(F!==0||V!==0)&&(u.x=(u.x??0)-F/ee[2],u.y=(u.y??0)-V/ee[2],await J({x:F,y:V})&&X(u)),d=requestAnimationFrame(K)}function ne(ee){var te;const{nodeLookup:J,multiSelectionActive:C,nodesDraggable:B,transform:F,snapGrid:V,snapToGrid:A,selectNodesOnDrag:L,onNodeDragStart:O,onSelectionDragStart:j,unselectNodesAndEdges:z}=r();x=!0,(!L||!b)&&!C&&$&&((te=J.get($))!=null&&te.selected||z()),b&&L&&$&&(t==null||t($));const re=oo(ee.sourceEvent,{transform:F,snapGrid:V,snapToGrid:A,containerBounds:m});if(u=re,h=i1(J,B,re,$),h.size>0&&(o||O||!$&&j)){const[ae,de]=Nu({nodeId:$,dragItems:h,nodeLookup:J});o==null||o(ee.sourceEvent,h,ae,de),O==null||O(ee.sourceEvent,ae,de),$||j==null||j(ee.sourceEvent,de)}}const q=Sp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:C,transform:B,snapGrid:F,snapToGrid:V}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,S=!1,_=!1,M=ee.sourceEvent,C===0&&ne(ee),u=oo(ee.sourceEvent,{transform:B,snapGrid:F,snapToGrid:V,containerBounds:m}),v=Jt(ee.sourceEvent,m)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:C,snapGrid:B,snapToGrid:F,nodeDragThreshold:V,nodeLookup:A}=r(),L=oo(ee.sourceEvent,{transform:C,snapGrid:B,snapToGrid:F,containerBounds:m});if(M=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||$&&!A.has($))&&(S=!0),!S){if(!p&&J&&x&&(p=!0,K()),!x){const O=Jt(ee.sourceEvent,m),j=O.x-v.x,z=O.y-v.y;Math.sqrt(j*j+z*z)>V&&ne(ee)}(u.x!==L.xSnapped||u.y!==L.ySnapped)&&h&&x&&(v=Jt(ee.sourceEvent,m),X(L))}}).on("end",ee=>{if(!x||S){S&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,x=!1,cancelAnimationFrame(d),h.size>0){const{nodeLookup:J,updateNodePositions:C,onNodeDragStop:B,onSelectionDragStop:F}=r();if(_&&(C(h,!1),_=!1),a||B||!$&&F){const[V,A]=Nu({nodeId:$,dragItems:h,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,h,V,A),B==null||B(ee.sourceEvent,V,A),$||F==null||F(ee.sourceEvent,A)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!T||!_h(J,`.${T}`,P))&&(!N||_h(J,N,P))});g.call(q)}function E(){g==null||g.on(".drag",null)}return{update:k,destroy:E}}function l1(t,r,o){const l=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())cl(a,ho(u))>0&&l.push(u);return l}const a1=250;function u1(t,r,o,l){var h,p;let a=[],u=1/0;const d=l1(t,o,r+a1);for(const v of d){const m=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:g,y:S}=Nr(v,x,x.position,!0),_=Math.sqrt(Math.pow(g-t.x,2)+Math.pow(S-t.y,2));_>r||(_1){const v=l.type==="source"?"target":"source";return a.find(m=>m.type===v)??a[0]}return a[0]}function sg(t,r,o,l,a,u=!1){var v,m,x;const d=l.get(t);if(!d)return null;const h=a==="strict"?(v=d.internals.handleBounds)==null?void 0:v[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],p=(o?h==null?void 0:h.find(g=>g.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...Nr(d,p,p.position,!0)}:p}function lg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function c1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const ag=()=>!0;function d1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:m,flowId:x,panBy:g,cancelConnection:S,onConnectStart:_,onConnect:M,onConnectEnd:k,isValidConnection:E=ag,onReconnectEnd:T,updateConnection:N,getTransform:P,getFromHandle:b,autoPanSpeed:$,dragThreshold:H=1,handleDomNode:X}){const K=Kp(t.target);let ne=0,q;const{x:ee,y:J}=Jt(t),C=lg(u,X),B=h==null?void 0:h.getBoundingClientRect();let F=!1;if(!B||!C)return;const V=sg(a,C,l,p,r);if(!V)return;let A=Jt(t,B),L=!1,O=null,j=!1,z=null;function re(){if(!m||!B)return;const[we,ve]=oc(A,B,$);g({x:we,y:ve}),ne=requestAnimationFrame(re)}const te={...V,nodeId:a,type:C,position:V.position},ae=p.get(a);let ce={inProgress:!0,isValid:null,from:Nr(ae,te,Se.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:ae,to:A,toHandle:null,toPosition:ch[te.position],toNode:null,pointer:A};function Q(){F=!0,N(ce),_==null||_(t,{nodeId:a,handleId:l,handleType:C})}H===0&&Q();function se(we){if(!F){const{x:Re,y:nt}=Jt(we),rt=Re-ee,Xe=nt-J;if(!(rt*rt+Xe*Xe>H*H))return;Q()}if(!b()||!te){he(we);return}const ve=P();A=Jt(we,B),q=u1(ko(A,ve,!1,[1,1]),o,p,te),L||(re(),L=!0);const me=ug(we,{handle:q,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:v,flowId:x,nodeLookup:p});z=me.handleDomNode,O=me.connection,j=c1(!!q,me.isValid);const Ce=p.get(a),Me=Ce?Nr(Ce,te,Se.Left,!0):ce.from,Pe={...ce,from:Me,isValid:j,to:me.toHandle&&j?ui({x:me.toHandle.x,y:me.toHandle.y},ve):A,toHandle:me.toHandle,toPosition:j&&me.toHandle?me.toHandle.position:ch[te.position],toNode:me.toHandle?p.get(me.toHandle.nodeId):null,pointer:A};N(Pe),ce=Pe}function he(we){if(!("touches"in we&&we.touches.length>0)){if(F){(q||z)&&O&&j&&(M==null||M(O));const{inProgress:ve,...me}=ce,Ce={...me,toPosition:ce.toHandle?ce.toPosition:null};k==null||k(we,Ce),u&&(T==null||T(we,Ce))}S(),cancelAnimationFrame(ne),L=!1,j=!1,O=null,z=null,K.removeEventListener("mousemove",se),K.removeEventListener("mouseup",he),K.removeEventListener("touchmove",se),K.removeEventListener("touchend",he)}}K.addEventListener("mousemove",se),K.addEventListener("mouseup",he),K.addEventListener("touchmove",se),K.addEventListener("touchend",he)}function ug(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:h,flowId:p,isValidConnection:v=ag,nodeLookup:m}){const x=u==="target",g=r?d.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:S,y:_}=Jt(t),M=d.elementFromPoint(S,_),k=M!=null&&M.classList.contains(`${h}-flow__handle`)?M:g,E={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const T=lg(void 0,k),N=k.getAttribute("data-nodeid"),P=k.getAttribute("data-handleid"),b=k.classList.contains("connectable"),$=k.classList.contains("connectableend");if(!N||!T)return E;const H={source:x?N:l,sourceHandle:x?P:a,target:x?l:N,targetHandle:x?a:P};E.connection=H;const K=b&&$&&(o===li.Strict?x&&T==="source"||!x&&T==="target":N!==l||P!==a);E.isValid=K&&v(H),E.toHandle=sg(N,T,P,m,o,!0)}return E}const Xu={onPointerDown:d1,isValid:ug};function f1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=zt(t);function u({translateExtent:h,width:p,height:v,zoomStep:m=1,pannable:x=!0,zoomable:g=!0,inversePan:S=!1}){const _=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const P=o(),b=N.sourceEvent.ctrlKey&&po()?10:1,$=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=P[2]*Math.pow(2,$*b);r.scaleTo(H)};let M=[0,0];const k=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(M=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},E=N=>{const P=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const b=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],$=[b[0]-M[0],b[1]-M[1]];M=b;const H=l()*Math.max(P[2],Math.log(P[2]))*(S?-1:1),X={x:P[0]-$[0]*H,y:P[1]-$[1]*H},K=[[0,0],[p,v]];r.setViewportConstrained({x:X.x,y:X.y,zoom:P[2]},K,h)},T=$p().on("start",k).on("zoom",x?E:null).on("zoom.wheel",g?_:null);a.call(T,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Gt}}const Sl=t=>({x:t.x,y:t.y,zoom:t.k}),Cu=({x:t,y:r,zoom:o})=>vl.translate(t,r).scale(o),Gn=(t,r)=>t.target.closest(`.${r}`),cg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),h1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,ju=(t,r=0,o=h1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},dg=t=>{const r=t.ctrlKey&&po()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function p1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return m=>{if(Gn(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const k=Gt(m),E=dg(m),T=x*Math.pow(2,E);l.scaleTo(o,T,k,m);return}const g=m.deltaMode===1?20:1;let S=a===wr.Vertical?0:m.deltaX*g,_=a===wr.Horizontal?0:m.deltaY*g;!po()&&m.shiftKey&&a!==wr.Vertical&&(S=m.deltaY*g,_=0),l.translateBy(o,-(S/x)*u,-(_/x)*u,{internal:!0});const M=Sl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(m,M):(t.isPanScrolling=!0,h==null||h(m,M)),t.panScrollTimeout=setTimeout(()=>{v==null||v(m,M),t.isPanScrolling=!1},150)}}function g1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,h=Gn(l,t);if(l.ctrlKey&&u&&h&&l.preventDefault(),d||h)return null;l.preventDefault(),o.call(this,l,a)}}function m1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,h;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Sl(l.transform);t.mouseButton=((d=l.sourceEvent)==null?void 0:d.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=l.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(l.sourceEvent,a))}}function y1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,h;t.usedRightMouseButton=!!(o&&cg(r,t.mouseButton??0)),(d=u.sourceEvent)!=null&&d.sync||l([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Sl(u.transform)))}}function v1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:u}){return d=>{var h;if(!((h=d.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&cg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const p=Sl(d.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,p)},o?150:0)}}}function x1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:m,connectionInProgress:x}){return g=>{var E;const S=r||o,_=l&&g.ctrlKey,M=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Gn(g,`${m}-flow__node`)||Gn(g,`${m}-flow__edge`)||Gn(g,`${m}-flow__selection`)||Gn(g,`${m}-flow__nodesselection`)))return!0;if(!a&&!S&&!u&&!d&&!l||h||x&&!M||Gn(g,p)&&M||Gn(g,v)&&(!M||u&&M&&!r)||!l&&g.ctrlKey&&M)return!1;if(!l&&g.type==="touchstart"&&((E=g.touches)==null?void 0:E.length)>1)return g.preventDefault(),!1;if(!S&&!u&&!_&&M||!a&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(a)&&!a.includes(g.button)&&g.type==="mousedown")return!1;const k=Array.isArray(a)&&a.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||M||t)&&k}}function w1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let x=[[0,0],[m.width,m.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const C=J[0];C&&(x=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(t);const S=$p().extent(()=>x).scaleExtent([r,o]).translateExtent(l),_=zt(t).call(S);P({x:a.x,y:a.y,zoom:ai(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const M=_.on("wheel.zoom"),k=_.on("dblclick.zoom");S.wheelDelta(dg);async function E(J,C){return _?new Promise(B=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?io:qs).transform(ju(_,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>B(!0)),J)}):!1}function T({noWheelClassName:J,noPanClassName:C,onPaneContextMenu:B,userSelectionActive:F,panOnScroll:V,panOnDrag:A,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:j,zoomOnPinch:z,zoomOnScroll:re,zoomOnDoubleClick:te,panActivationKeyPressed:ae=!1,zoomActivationKeyPressed:de,lib:ce,onTransformChange:Q,connectionInProgress:se,paneClickDistance:he,selectionOnDrag:we}){F&&!v.isZoomingOrPanning&&N();const ve=V&&!de&&!F;S.clickDistance(we?1/0:!Zt(he)||he<0?0:he);const me=ve?p1({zoomPanValues:v,noWheelClassName:J,d3Selection:_,d3Zoom:S,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:z,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:h}):g1({noWheelClassName:J,preventScrolling:j,d3ZoomHandler:M});_.on("wheel.zoom",me,{passive:!1});const Ce=m1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:d});S.on("start",Ce);const Me=y1({zoomPanValues:v,panOnDrag:A,onPaneContextMenu:!!B,onPanZoom:u,onTransformChange:Q});S.on("zoom",Me);const Pe=v1({zoomPanValues:v,panOnDrag:A,panOnScroll:V,onPaneContextMenu:B,onPanZoomEnd:h,onDraggingChange:p});S.on("end",Pe);const Re=x1({panActivationKeyPressed:ae,zoomActivationKeyPressed:de,panOnDrag:A,zoomOnScroll:re,panOnScroll:V,zoomOnDoubleClick:te,zoomOnPinch:z,userSelectionActive:F,noPanClassName:C,noWheelClassName:J,lib:ce,connectionInProgress:se});S.filter(Re),te?_.on("dblclick.zoom",k):_.on("dblclick.zoom",null)}function N(){S.on("zoom",null)}async function P(J,C,B){const F=Cu(J),V=S==null?void 0:S.constrain()(F,C,B);return V&&await E(V),V}async function b(J,C){const B=Cu(J);return await E(B,C),B}function $(J){if(_){const C=Cu(J),B=_.property("__zoom");(B.k!==J.zoom||B.x!==J.x||B.y!==J.y)&&(S==null||S.transform(_,C,null,{sync:!0}))}}function H(){const J=_?Ap(_.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function X(J,C){return _?new Promise(B=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?io:qs).scaleTo(ju(_,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>B(!0)),J)}):!1}async function K(J,C){return _?new Promise(B=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?io:qs).scaleBy(ju(_,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>B(!0)),J)}):!1}function ne(J){S==null||S.scaleExtent(J)}function q(J){S==null||S.translateExtent(J)}function ee(J){const C=!Zt(J)||J<0?0:J;S==null||S.clickDistance(C)}return{update:T,destroy:N,setViewport:b,setViewportConstrained:P,getViewport:H,scaleTo:X,scaleBy:K,setScaleExtent:ne,setTranslateExtent:q,syncViewport:$,setClickDistance:ee}}var ci;(function(t){t.Line="line",t.Handle="handle"})(ci||(ci={}));function S1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,h=o-l,p=[d>0?1:d<0?-1:0,h>0?1:h<0?-1:0];return d&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function kh(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),l=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:l,affectsY:a}}function Qn(t,r){return Math.max(0,r-t)}function Kn(t,r){return Math.max(0,t-r)}function Xs(t,r,o){return Math.max(0,r-t,t-o)}function Eh(t,r){return t?!r:r}function _1(t,r,o,l,a,u,d,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:m,isVertical:x}=r,g=m&&x,{xSnapped:S,ySnapped:_}=o,{minWidth:M,maxWidth:k,minHeight:E,maxHeight:T}=l,{x:N,y:P,width:b,height:$,aspectRatio:H}=t;let X=Math.floor(m?S-t.pointerX:0),K=Math.floor(x?_-t.pointerY:0);const ne=b+(p?-X:X),q=$+(v?-K:K),ee=-u[0]*b,J=-u[1]*$;let C=Xs(ne,M,k),B=Xs(q,E,T);if(d){let A=0,L=0;p&&X<0?A=Qn(N+X+ee,d[0][0]):!p&&X>0&&(A=Kn(N+ne+ee,d[1][0])),v&&K<0?L=Qn(P+K+J,d[0][1]):!v&&K>0&&(L=Kn(P+q+J,d[1][1])),C=Math.max(C,A),B=Math.max(B,L)}if(h){let A=0,L=0;p&&X>0?A=Kn(N+X,h[0][0]):!p&&X<0&&(A=Qn(N+ne,h[1][0])),v&&K>0?L=Kn(P+K,h[0][1]):!v&&K<0&&(L=Qn(P+q,h[1][1])),C=Math.max(C,A),B=Math.max(B,L)}if(a){if(m){const A=Xs(ne/H,E,T)*H;if(C=Math.max(C,A),d){let L=0;!p&&!v||p&&!v&&g?L=Kn(P+J+ne/H,d[1][1])*H:L=Qn(P+J+(p?X:-X)/H,d[0][1])*H,C=Math.max(C,L)}if(h){let L=0;!p&&!v||p&&!v&&g?L=Qn(P+ne/H,h[1][1])*H:L=Kn(P+(p?X:-X)/H,h[0][1])*H,C=Math.max(C,L)}}if(x){const A=Xs(q*H,M,k)/H;if(B=Math.max(B,A),d){let L=0;!p&&!v||v&&!p&&g?L=Kn(N+q*H+ee,d[1][0])/H:L=Qn(N+(v?K:-K)*H+ee,d[0][0])/H,B=Math.max(B,L)}if(h){let L=0;!p&&!v||v&&!p&&g?L=Qn(N+q*H,h[1][0])/H:L=Kn(N+(v?K:-K)*H,h[0][0])/H,B=Math.max(B,L)}}}K=K+(K<0?B:-B),X=X+(X<0?C:-C),a&&(g?ne>q*H?K=(Eh(p,v)?-X:X)/H:X=(Eh(p,v)?-K:K)*H:m?(K=X/H,v=p):(X=K*H,p=v));const F=p?N+X:N,V=v?P+K:P;return{width:b+(p?-X:X),height:$+(v?-K:K),x:u[0]*X*(p?-1:1)+F,y:u[1]*K*(v?-1:1)+V}}const fg={width:0,height:0,x:0,y:0},k1={...fg,pointerX:0,pointerY:0,aspectRatio:1};function E1(t,r,o){const l=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,d=t.measured.height??0,h=o[0]*u,p=o[1]*d;return[[l-h,a-p],[l+u-h,a+d-p]]}function N1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=zt(t);let d={controlDirection:kh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:m,keepAspectRatio:x,resizeDirection:g,onResizeStart:S,onResize:_,onResizeEnd:M,shouldResize:k}){let E={...fg},T={...k1};d={boundaries:m,resizeDirection:g,keepAspectRatio:x,controlDirection:kh(v)};let N,P=null,b=[],$,H,X,K=!1;const ne=Sp().on("start",q=>{const{nodeLookup:ee,transform:J,snapGrid:C,snapToGrid:B,nodeOrigin:F,paneDomNode:V}=o();if(N=ee.get(r),!N)return;P=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:L}=oo(q.sourceEvent,{transform:J,snapGrid:C,snapToGrid:B,containerBounds:P});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},T={...E,pointerX:A,pointerY:L,aspectRatio:E.width/E.height},$=void 0,H=Er(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&($=ee.get(N.parentId)),$&&N.extent==="parent"&&(H=[[0,0],[$.measured.width,$.measured.height]]),b=[],X=void 0;for(const[O,j]of ee)if(j.parentId===r&&(b.push({id:O,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const z=E1(j,N,j.origin??F);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}S==null||S(q,{...E})}).on("drag",q=>{const{transform:ee,snapGrid:J,snapToGrid:C,nodeOrigin:B}=o(),F=oo(q.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:C,containerBounds:P}),V=[];if(!N)return;const{x:A,y:L,width:O,height:j}=E,z={},re=N.origin??B,{width:te,height:ae,x:de,y:ce}=_1(T,d.controlDirection,F,d.boundaries,d.keepAspectRatio,re,H,X),Q=te!==O,se=ae!==j,he=de!==A&&Q,we=ce!==L&&se;if(!he&&!we&&!Q&&!se)return;if((he||we||re[0]===1||re[1]===1)&&(z.x=he?de:E.x,z.y=we?ce:E.y,E.x=z.x,E.y=z.y,b.length>0)){const Me=de-A,Pe=ce-L;for(const Re of b)Re.position={x:Re.position.x-Me+re[0]*(te-O),y:Re.position.y-Pe+re[1]*(ae-j)},V.push(Re)}if((Q||se)&&(z.width=Q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?te:E.width,z.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ae:E.height,E.width=z.width,E.height=z.height),$&&N.expandParent){const Me=re[0]*(z.width??0);z.x&&z.x{K&&(M==null||M(q,{...E}),a==null||a({...E}),K=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Mu={exports:{}},Pu={},Iu={exports:{}},Tu={};/** - * @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 Nh;function C1(){if(Nh)return Tu;Nh=1;var t=mo();function r(x,g){return x===g&&(x!==0||1/x===1/g)||x!==x&&g!==g}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function h(x,g){var S=g(),_=l({inst:{value:S,getSnapshot:g}}),M=_[0].inst,k=_[1];return u(function(){M.value=S,M.getSnapshot=g,p(M)&&k({inst:M})},[x,S,g]),a(function(){return p(M)&&k({inst:M}),x(function(){p(M)&&k({inst:M})})},[x]),d(S),S}function p(x){var g=x.getSnapshot;x=x.value;try{var S=g();return!o(x,S)}catch{return!0}}function v(x,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Tu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Tu}var Ch;function j1(){return Ch||(Ch=1,Iu.exports=C1()),Iu.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 jh;function M1(){if(jh)return Pu;jh=1;var t=mo(),r=j1();function o(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Pu.useSyncExternalStoreWithSelector=function(v,m,x,g,S){var _=u(null);if(_.current===null){var M={hasValue:!1,value:null};_.current=M}else M=_.current;_=h(function(){function E($){if(!T){if(T=!0,N=$,$=g($),S!==void 0&&M.hasValue){var H=M.value;if(S(H,$))return P=H}return P=$}if(H=P,l(N,$))return H;var X=g($);return S!==void 0&&S(H,X)?(N=$,H):(N=$,P=X)}var T=!1,N,P,b=x===void 0?null:x;return[function(){return E(m())},b===null?void 0:function(){return E(b())}]},[m,x,g,S]);var k=a(v,_[0],_[1]);return d(function(){M.hasValue=!0,M.value=k},[k]),p(k),k},Pu}var Mh;function P1(){return Mh||(Mh=1,Mu.exports=M1()),Mu.exports}var I1=P1();const T1=op(I1),z1={},Ph=t=>{let r;const o=new Set,l=(m,x)=>{const g=typeof m=="function"?m(r):m;if(!Object.is(g,r)){const S=r;r=x??(typeof g!="object"||g===null)?g:Object.assign({},r,g),o.forEach(_=>_(r,S))}},a=()=>r,p={setState:l,getState:a,getInitialState:()=>v,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(z1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},v=r=t(l,a,p);return p},R1=t=>t?Ph(t):Ph,{useDebugValue:L1}=L0,{useSyncExternalStoreWithSelector:A1}=T1,$1=t=>t;function hg(t,r=$1,o){const l=A1(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return L1(l),l}const Ih=(t,r)=>{const o=R1(t),l=(a,u=r)=>hg(o,a,u);return Object.assign(l,o),l},D1=(t,r)=>t?Ih(t,r):Ih;function Ue(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,a]of t)if(!Object.is(a,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 o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const l of o)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(t[l],r[l]))return!1;return!0}sp();const _l=W.createContext(null),O1=_l.Provider,pg=en.error001("react");function Te(t,r){const o=W.useContext(_l);if(o===null)throw new Error(pg);return hg(o,t,r)}function be(){const t=W.useContext(_l);if(t===null)throw new Error(pg);return W.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Th={display:"none"},b1={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},gg="react-flow__node-desc",mg="react-flow__edge-desc",F1="react-flow__aria-live",H1=t=>t.ariaLiveMessage,V1=t=>t.ariaLabelConfig;function B1({rfId:t}){const r=Te(H1);return y.jsx("div",{id:`${F1}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:b1,children:r})}function U1({rfId:t,disableKeyboardA11y:r}){const o=Te(V1);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${gg}-${t}`,style:Th,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${mg}-${t}`,style:Th,children:o["edge.a11yDescription.default"]}),!r&&y.jsx(B1,{rfId:t})]})}const kl=W.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return y.jsx("div",{className:Ke(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});kl.displayName="Panel";const zh="https://reactflow.dev?utm_source=attribution";function W1({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:y.jsx(kl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${zh}`,children:y.jsx("a",{href:zh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Y1=t=>{const r=[],o=[];for(const[,l]of t.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of t.edgeLookup)l.selected&&o.push(l);return{selectedNodes:r,selectedEdges:o}},Qs=t=>t.id;function X1(t,r){return Ue(t.selectedNodes.map(Qs),r.selectedNodes.map(Qs))&&Ue(t.selectedEdges.map(Qs),r.selectedEdges.map(Qs))}function Q1({onSelectionChange:t}){const r=be(),{selectedNodes:o,selectedEdges:l}=Te(Y1,X1);return W.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const K1=t=>!!t.onSelectionChangeHandlers;function G1({onSelectionChange:t}){const r=Te(K1);return t||r?y.jsx(Q1,{onSelectionChange:t}):null}const yg=[0,0],q1={x:0,y:0,zoom:1},Z1=["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"],Rh=[...Z1,"rfId"],J1=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}),Lh={translateExtent:co,nodeOrigin:yg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function eS(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:h,setDefaultNodesAndEdges:p}=Te(J1,Ue),v=be();W.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{m.current=Lh,h()}),[]);const m=W.useRef(Lh);return W.useEffect(()=>{for(const x of Rh){const g=t[x],S=m.current[x];g!==S&&(typeof t[x]>"u"||(x==="nodes"?r(g):x==="edges"?o(g):x==="minZoom"?l(g):x==="maxZoom"?a(g):x==="translateExtent"?u(g):x==="nodeExtent"?d(g):x==="ariaLabelConfig"?v.setState({ariaLabelConfig:Ow(g)}):x==="fitView"?v.setState({fitViewQueued:g}):x==="fitViewOptions"?v.setState({fitViewOptions:g}):v.setState({[x]:g})))}m.current=t},Rh.map(x=>t[x])),null}function Ah(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function tS(t){var l;const[r,o]=W.useState(t==="system"?null:t);return W.useEffect(()=>{if(t!=="system"){o(t);return}const a=Ah(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(l=Ah())!=null&&l.matches?"dark":"light"}const $h=typeof document<"u"?document:null;function go(t=null,r={target:$h,actInsideInputWithModifier:!0}){const[o,l]=W.useState(!1),a=W.useRef(!1),u=W.useRef(new Set([])),[d,h]=W.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),m=v.reduce((x,g)=>x.concat(...g),[]);return[v,m]}return[[],[]]},[t]);return W.useEffect(()=>{const p=(r==null?void 0:r.target)??$h,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=S=>{var k,E;if(a.current=S.ctrlKey||S.metaKey||S.shiftKey||S.altKey,(!a.current||a.current&&!v)&&Gp(S))return!1;const M=Oh(S.code,h);if(u.current.add(S[M]),Dh(d,u.current,!1)){const T=((E=(k=S.composedPath)==null?void 0:k.call(S))==null?void 0:E[0])||S.target,N=(T==null?void 0:T.nodeName)==="BUTTON"||(T==null?void 0:T.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&S.preventDefault(),l(!0)}},x=S=>{const _=Oh(S.code,h);Dh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(S[_]),S.key==="Meta"&&u.current.clear(),a.current=!1},g=()=>{u.current.clear(),l(!1)};return p==null||p.addEventListener("keydown",m),p==null||p.addEventListener("keyup",x),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{p==null||p.removeEventListener("keydown",m),p==null||p.removeEventListener("keyup",x),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[t,l]),o}function Dh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Oh(t,r){return r.includes(t)?"code":"key"}const nS=()=>{const t=be();return W.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:l}=t.getState();return l?l.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[l,a,u],panZoom:d}=t.getState();return d?(await d.setViewport({x:r.x??l,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,l]=t.getState().transform;return{x:r,y:o,zoom:l}},setCenter:async(r,o,l)=>t.getState().setCenter(r,o,l),fitBounds:async(r,o)=>{const{width:l,height:a,minZoom:u,maxZoom:d,panZoom:h}=t.getState(),p=sc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:h,y:p}=d.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},m=o.snapGrid??a,x=o.snapToGrid??u;return ko(v,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=ui(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function vg(t,r){const o=[],l=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")l.set(u.id,[u]);else{const d=l.get(u.id);d?d.push(u):l.set(u.id,[u])}for(const u of r){const d=l.get(u.id);if(!d){o.push(u);continue}if(d[0].type==="remove")continue;if(d[0].type==="replace"){o.push({...d[0].item});continue}const h={...u};for(const p of d)rS(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function rS(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 iS(t,r){return vg(t,r)}function oS(t,r){return vg(t,r)}function yr(t,r){return{id:t,type:"select",selected:r}}function ni(t,r=new Set,o=!1){const l=[];for(const[a,u]of t){const d=r.has(a);!(u.selected===void 0&&!d)&&u.selected!==d&&(o&&(u.selected=d),l.push(yr(u.id,d)))}return l}function bh({items:t=[],lookup:r}){var a;const o=[],l=new Map(t.map(u=>[u.id,u]));for(const[u,d]of t.entries()){const h=r.get(d.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==d&&o.push({id:d.id,item:d,type:"replace"}),p===void 0&&o.push({item:d,type:"add",index:u})}for(const[u]of r)l.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Fh(t){return{id:t.id,type:"remove"}}const sS=Yp();function lS(t,r,o={}){return Uw(t,r,{...o,onError:o.onError??sS})}const Hh=t=>Pw(t),aS=t=>Hp(t);function xg(t){return W.forwardRef(t)}const wg=typeof window<"u"?W.useLayoutEffect:W.useEffect;function Vh(t){const[r,o]=W.useState(BigInt(0)),[l]=W.useState(()=>uS(()=>o(a=>a+BigInt(1))));return wg(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function uS(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Sg=W.createContext(null);function cS({children:t}){const r=be(),o=W.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:m,onNodesChange:x,nodeLookup:g,fitViewQueued:S,onNodesChangeMiddlewareMap:_}=r.getState();let M=p;for(const E of h)M=typeof E=="function"?E(M):E;let k=bh({items:M,lookup:g});for(const E of _.values())k=E(k);m&&v(M),k.length>0?x==null||x(k):S&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:T,setNodes:N}=r.getState();E&&N(T)})},[]),l=Vh(o),a=W.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:g}=r.getState();let S=p;for(const _ of h)S=typeof _=="function"?_(S):_;m?v(S):x&&x(bh({items:S,lookup:g}))},[]),u=Vh(a),d=W.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return y.jsx(Sg.Provider,{value:d,children:t})}function dS(){const t=W.useContext(Sg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const fS=t=>!!t.panZoom;function hc(){const t=nS(),r=be(),o=dS(),l=Te(fS),a=W.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},h=x=>{o.edgeQueue.push(x)},p=x=>{var E,T;const{nodeLookup:g,nodeOrigin:S}=r.getState(),_=Hh(x)?x:g.get(x.id),M=_.parentId?Qp(_.position,_.measured,_.parentId,g,S):_.position,k={..._,position:M,width:((E=_.measured)==null?void 0:E.width)??_.width,height:((T=_.measured)==null?void 0:T.height)??_.height};return ho(k)},v=(x,g,S={replace:!1})=>{d(_=>_.map(M=>{if(M.id===x){const k=typeof g=="function"?g(M):g;return S.replace&&Hh(k)?k:{...M,...k}}return M}))},m=(x,g,S={replace:!1})=>{h(_=>_.map(M=>{if(M.id===x){const k=typeof g=="function"?g(M):g;return S.replace&&aS(k)?k:{...M,...k}}return M}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var g;return(g=u(x))==null?void 0:g.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(g=>({...g}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:h,addNodes:x=>{const g=Array.isArray(x)?x:[x];o.nodeQueue.push(S=>[...S,...g])},addEdges:x=>{const g=Array.isArray(x)?x:[x];o.edgeQueue.push(S=>[...S,...g])},toObject:()=>{const{nodes:x=[],edges:g=[],transform:S}=r.getState(),[_,M,k]=S;return{nodes:x.map(E=>({...E})),edges:g.map(E=>({...E})),viewport:{x:_,y:M,zoom:k}}},deleteElements:async({nodes:x=[],edges:g=[]})=>{const{nodes:S,edges:_,onNodesDelete:M,onEdgesDelete:k,triggerNodeChanges:E,triggerEdgeChanges:T,onDelete:N,onBeforeDelete:P}=r.getState(),{nodes:b,edges:$}=await Lw({nodesToRemove:x,edgesToRemove:g,nodes:S,edges:_,onBeforeDelete:P}),H=$.length>0,X=b.length>0;if(H){const K=$.map(Fh);k==null||k($),T(K)}if(X){const K=b.map(Fh);M==null||M(b),E(K)}return(X||H)&&(N==null||N({nodes:b,edges:$})),{deletedNodes:b,deletedEdges:$}},getIntersectingNodes:(x,g=!0,S)=>{const _=fh(x),M=_?x:p(x),k=S!==void 0;return M?(S||r.getState().nodes).filter(E=>{const T=r.getState().nodeLookup.get(E.id);if(T&&!_&&(E.id===x.id||!T.internals.positionAbsolute))return!1;const N=ho(k?E:T),P=cl(N,M);return g&&P>0||P>=N.width*N.height||P>=M.width*M.height}):[]},isNodeIntersecting:(x,g,S=!0)=>{const M=fh(x)?x:p(x);if(!M)return!1;const k=cl(M,g);return S&&k>0||k>=g.width*g.height||k>=M.width*M.height},updateNode:v,updateNodeData:(x,g,S={replace:!1})=>{v(x,_=>{const M=typeof g=="function"?g(_):g;return S.replace?{..._,data:M}:{..._,data:{..._.data,...M}}},S)},updateEdge:m,updateEdgeData:(x,g,S={replace:!1})=>{m(x,_=>{const M=typeof g=="function"?g(_):g;return S.replace?{..._,data:M}:{..._,data:{..._.data,...M}}},S)},getNodesBounds:x=>{const{nodeLookup:g,nodeOrigin:S}=r.getState();return Iw(x,{nodeLookup:g,nodeOrigin:S})},getHandleConnections:({type:x,id:g,nodeId:S})=>{var _;return Array.from(((_=r.getState().connectionLookup.get(`${S}-${x}${g?`-${g}`:""}`))==null?void 0:_.values())??[])},getNodeConnections:({type:x,handleId:g,nodeId:S})=>{var _;return Array.from(((_=r.getState().connectionLookup.get(`${S}${x?g?`-${x}-${g}`:`-${x}`:""}`))==null?void 0:_.values())??[])},fitView:async x=>{const g=r.getState().fitViewResolver??Dw();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:g}),o.nodeQueue.push(S=>[...S]),g.promise}}},[]);return W.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Bh=t=>t.selected,hS=typeof window<"u"?window:void 0;function pS({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=be(),{deleteElements:l}=hc(),a=go(t,{actInsideInputWithModifier:!1}),u=go(r,{target:hS});W.useEffect(()=>{if(a){const{edges:d,nodes:h}=o.getState();l({nodes:h.filter(Bh),edges:d.filter(Bh)}),o.setState({nodesSelectionActive:!1})}},[a]),W.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function gS(t){const r=be();W.useEffect(()=>{const o=()=>{var a,u,d,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const l=lc(t.current);(l.height===0||l.width===0)&&((h=(d=r.getState()).onError)==null||h.call(d,"004",en.error004())),r.setState({width:l.width||500,height:l.height||500})};if(t.current){o(),window.addEventListener("resize",o);const l=new ResizeObserver(()=>o());return l.observe(t.current),()=>{window.removeEventListener("resize",o),l&&t.current&&l.unobserve(t.current)}}},[])}const El={position:"absolute",width:"100%",height:"100%",top:0,left:0},mS=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function yS({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=wr.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:m,minZoom:x,maxZoom:g,zoomActivationKeyCode:S,preventScrolling:_=!0,children:M,noWheelClassName:k,noPanClassName:E,onViewportChange:T,isControlledViewport:N,paneClickDistance:P,selectionOnDrag:b}){const $=be(),H=W.useRef(null),{userSelectionActive:X,lib:K,connectionInProgress:ne}=Te(mS,Ue),q=go(S),ee=W.useRef();gS(H);const J=W.useCallback(C=>{T==null||T({x:C[0],y:C[1],zoom:C[2]}),N||$.setState({transform:C})},[T,N]);return W.useEffect(()=>{if(H.current){ee.current=w1({domNode:H.current,minZoom:x,maxZoom:g,translateExtent:m,viewport:v,onDraggingChange:V=>$.setState(A=>A.paneDragging===V?A:{paneDragging:V}),onPanZoomStart:(V,A)=>{const{onViewportChangeStart:L,onMoveStart:O}=$.getState();O==null||O(V,A),L==null||L(A)},onPanZoom:(V,A)=>{const{onViewportChange:L,onMove:O}=$.getState();O==null||O(V,A),L==null||L(A)},onPanZoomEnd:(V,A)=>{const{onViewportChangeEnd:L,onMoveEnd:O}=$.getState();O==null||O(V,A),L==null||L(A)}});const{x:C,y:B,zoom:F}=ee.current.getViewport();return $.setState({panZoom:ee.current,transform:[C,B,F],domNode:H.current.closest(".react-flow")}),()=>{var V;(V=ee.current)==null||V.destroy()}}},[]),W.useEffect(()=>{var C;(C=ee.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:q,preventScrolling:_,noPanClassName:E,userSelectionActive:X,noWheelClassName:k,lib:K,onTransformChange:J,connectionInProgress:ne,selectionOnDrag:b,paneClickDistance:P})},[t,r,o,l,a,u,d,h,p,q,_,E,X,k,K,J,ne,b,P]),y.jsx("div",{className:"react-flow__renderer",ref:H,style:El,children:M})}const vS=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function xS(){const{userSelectionActive:t,userSelectionRect:r}=Te(vS,Ue);return t&&r?y.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 zu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},wS=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function SS({isSelecting:t,selectionKeyPressed:r,selectionMode:o=fo.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:g,onPaneMouseMove:S,onPaneMouseLeave:_,children:M}){const k=W.useRef(0),E=be(),{userSelectionActive:T,elementsSelectable:N,dragging:P,panBy:b,autoPanSpeed:$}=Te(wS,Ue),H=N&&(t||T),X=W.useRef(null),K=W.useRef(),ne=W.useRef(new Set),q=W.useRef(new Set),ee=W.useRef(!1),J=W.useRef(!1),C=W.useRef({x:0,y:0}),B=W.useRef(!1),F=Q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}v==null||v(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},V=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}m==null||m(Q)},A=x?Q=>x(Q):void 0,L=Q=>{J.current&&(Q.stopPropagation(),J.current=!1)},O=Q=>{var Re,nt;if(Q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:he}=E.getState();if(K.current=se==null?void 0:se.getBoundingClientRect(),!K.current)return;const we=Q.target===X.current;if(!we&&!!Q.target.closest(".nokey")||!t||!(d&&we||r)||Q.button!==0||!Q.isPrimary)return;(nt=(Re=Q.target)==null?void 0:Re.setPointerCapture)==null||nt.call(Re,Q.pointerId),J.current=!1;const{x:Ce,y:Me}=Jt(Q.nativeEvent,K.current),Pe=ko({x:Ce,y:Me},he);E.setState({userSelectionRect:{width:0,height:0,startX:Pe.x,startY:Pe.y,x:Ce,y:Me}}),we||(Q.stopPropagation(),Q.preventDefault())};function j(Q,se){const{userSelectionRect:he}=E.getState();if(!he)return;const{transform:we,nodeLookup:ve,edgeLookup:me,connectionLookup:Ce,triggerNodeChanges:Me,triggerEdgeChanges:Pe,defaultEdgeOptions:Re}=E.getState(),nt={x:he.startX,y:he.startY},{x:rt,y:Xe}=ui(nt,we),Ge={startX:nt.x,startY:nt.y,x:Qit.id)),q.current=new Set;const At=(Re==null?void 0:Re.selectable)??!0;for(const it of ne.current){const ft=Ce.get(it);if(ft)for(const{edgeId:lt}of ft.values()){const ht=me.get(lt);ht&&(ht.selectable??At)&&q.current.add(lt)}}if(!hh(Bt,ne.current)){const it=ni(ve,ne.current,!0);Me(it)}if(!hh(Lt,q.current)){const it=ni(me,q.current);Pe(it)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!K.current)return;const[Q,se]=oc(C.current,K.current,$);b({x:Q,y:se}).then(he=>{if(!J.current||!he){k.current=requestAnimationFrame(z);return}const{x:we,y:ve}=C.current;j(we,ve),k.current=requestAnimationFrame(z)})}const re=()=>{cancelAnimationFrame(k.current),k.current=0,B.current=!1};W.useEffect(()=>()=>re(),[]);const te=Q=>{const{userSelectionRect:se,transform:he,resetSelectedElements:we}=E.getState();if(!K.current||!se)return;const{x:ve,y:me}=Jt(Q.nativeEvent,K.current);C.current={x:ve,y:me};const Ce=ui({x:se.startX,y:se.startY},he);if(!J.current){const Me=r?0:u;if(Math.hypot(ve-Ce.x,me-Ce.y)<=Me)return;we(),h==null||h(Q)}J.current=!0,B.current||(z(),B.current=!0),j(ve,me)},ae=Q=>{var se,he;if(!H){Q.target===X.current&&E.getState().connection.inProgress&&(ee.current=!0);return}Q.button===0&&((he=(se=Q.target)==null?void 0:se.releasePointerCapture)==null||he.call(se,Q.pointerId),!T&&Q.target===X.current&&E.getState().userSelectionRect&&(F==null||F(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(p==null||p(Q),E.setState({nodesSelectionActive:ne.current.size>0})),re())},de=Q=>{var se,he;(he=(se=Q.target)==null?void 0:se.releasePointerCapture)==null||he.call(se,Q.pointerId),re()},ce=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:Ke(["react-flow__pane",{draggable:ce,dragging:P,selection:t}]),onClick:H?void 0:zu(F,X),onContextMenu:zu(V,X),onWheel:zu(A,X),onPointerEnter:H?void 0:g,onPointerMove:H?te:S,onPointerUp:ae,onPointerCancel:H?de:void 0,onPointerDownCapture:H?O:void 0,onClickCapture:H?L:void 0,onPointerLeave:_,ref:X,style:El,children:[M,y.jsx(xS,{})]})}function Qu({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",en.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&d)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function _g({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const h=be(),[p,v]=W.useState(!1),m=W.useRef();return W.useEffect(()=>{if(!r)return m.current=s1({getStoreItems:()=>h.getState(),onNodeMouseDown:x=>{Qu({id:x,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,h,t]),W.useEffect(()=>{r||!t.current||!m.current||m.current.update({noDragClassName:o,handleSelector:l,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:d})},[o,l,r,u,t,a,d]),p}const _S=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function kg(){const t=be();return W.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:m}=t.getState(),x=new Map,g=_S(d),S=a?u[0]:5,_=a?u[1]:5,M=o.direction.x*S*o.factor,k=o.direction.y*_*o.factor;for(const[,E]of v){if(!g(E))continue;let T={x:E.internals.positionAbsolute.x+M,y:E.internals.positionAbsolute.y+k};a&&(T=_o(T,u));const{position:N,positionAbsolute:P}=Vp({nodeId:E.id,nextPosition:T,nodeLookup:v,nodeExtent:l,nodeOrigin:m,onError:h});E.position=N,E.internals.positionAbsolute=P,x.set(E.id,E)}p(x)},[])}const pc=W.createContext(null),kS=pc.Provider;pc.Consumer;const Eg=()=>W.useContext(pc),ES=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ng=W.createContext(null);function NS({children:t}){const r=Te(ES,Ue);return y.jsx(Ng.Provider,{value:r,children:t})}function CS(){const t=W.useContext(Ng);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const jS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},MS=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:h,toHandle:p,isValid:v}=d;if(!h&&!a)return jS;const m=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===li.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:m&&v}};function PS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:h,children:p,className:v,onMouseDown:m,onTouchStart:x,...g},S){var B,F;const _=d||null,M=t==="target",k=be(),E=Eg(),{connectOnClick:T,noPanClassName:N,rfId:P}=CS(),{connectingFrom:b,connectingTo:$,clickConnecting:H,isPossibleEndHandle:X,connectionInProcess:K,clickConnectionInProcess:ne,valid:q}=Te(MS(E,_,t),Ue);E||(F=(B=k.getState()).onError)==null||F.call(B,"010",en.error010());const ee=V=>{const{defaultEdgeOptions:A,onConnect:L,hasDefaultEdges:O}=k.getState(),j={...A,...V};if(O){const{edges:z,setEdges:re,onError:te}=k.getState();re(lS(j,z,{onError:te}))}L==null||L(j),h==null||h(j)},J=V=>{if(!E)return;const A=qp(V.nativeEvent);if(a&&(A&&V.button===0||!A)){const L=k.getState();Xu.onPointerDown(V.nativeEvent,{handleDomNode:V.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:M,handleId:_,nodeId:E,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...O)=>{var j,z;return(z=(j=k.getState()).onConnectEnd)==null?void 0:z.call(j,...O)},updateConnection:L.updateConnection,onConnect:ee,isValidConnection:o||((...O)=>{var j,z;return((z=(j=k.getState()).isValidConnection)==null?void 0:z.call(j,...O))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}A?m==null||m(V):x==null||x(V)},C=V=>{const{onClickConnectStart:A,onClickConnectEnd:L,connectionClickStartHandle:O,connectionMode:j,isValidConnection:z,lib:re,rfId:te,nodeLookup:ae,connection:de}=k.getState();if(!E||!O&&!a)return;if(!O){A==null||A(V.nativeEvent,{nodeId:E,handleId:_,handleType:t}),k.setState({connectionClickStartHandle:{nodeId:E,type:t,id:_}});return}const ce=Kp(V.target),Q=o||z,{connection:se,isValid:he}=Xu.isValid(V.nativeEvent,{handle:{nodeId:E,id:_,type:t},connectionMode:j,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:Q,flowId:te,doc:ce,lib:re,nodeLookup:ae});he&&se&&ee(se);const we=structuredClone(de);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,L==null||L(V,we),k.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":_,"data-nodeid":E,"data-handlepos":r,"data-id":`${P}-${E}-${_}-${t}`,className:Ke(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,v,{source:!M,target:M,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:b,connectingto:$,valid:q,connectionindicator:l&&(!K||X)&&(K||ne?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:T?C:void 0,ref:S,...g,children:p})}const dl=W.memo(xg(PS));function IS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return y.jsxs(y.Fragment,{children:[t==null?void 0:t.label,y.jsx(dl,{type:"source",position:o,isConnectable:r})]})}function TS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(dl,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,y.jsx(dl,{type:"source",position:l,isConnectable:r})]})}function zS(){return null}function RS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(dl,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const fl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Uh={input:IS,default:TS,output:RS,group:zS};function LS(t){var r,o,l,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((l=t.style)==null?void 0:l.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const AS=t=>{const{width:r,height:o,x:l,y:a}=So(t.nodeLookup,{filter:u=>!!u.selected});return{width:Zt(r)?r:null,height:Zt(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${l}px,${a}px)`}};function $S({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=be(),{width:a,height:u,transformString:d,userSelectionActive:h}=Te(AS,Ue),p=kg(),v=W.useRef(null);W.useEffect(()=>{var S;o||(S=v.current)==null||S.focus({preventScroll:!0})},[o]);const m=!h&&a!==null&&u!==null;if(_g({nodeRef:v,disabled:!m}),!m)return null;const x=t?S=>{const _=l.getState().nodes.filter(M=>M.selected);t(S,_)}:void 0,g=S=>{Object.prototype.hasOwnProperty.call(fl,S.key)&&(S.preventDefault(),p({direction:fl[S.key],factor:S.shiftKey?4:1}))};return y.jsx("div",{className:Ke(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:y.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:g,style:{width:a,height:u}})})}const Wh=typeof window<"u"?window:void 0,DS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Cg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:m,selectionMode:x,onSelectionStart:g,onSelectionEnd:S,multiSelectionKeyCode:_,panActivationKeyCode:M,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:P,panOnScrollSpeed:b,panOnScrollMode:$,zoomOnDoubleClick:H,panOnDrag:X,autoPanOnSelection:K,defaultViewport:ne,translateExtent:q,minZoom:ee,maxZoom:J,preventScrolling:C,onSelectionContextMenu:B,noWheelClassName:F,noPanClassName:V,disableKeyboardA11y:A,onViewportChange:L,isControlledViewport:O}){const{nodesSelectionActive:j,userSelectionActive:z}=Te(DS,Ue),re=go(v,{target:Wh}),te=go(M,{target:Wh}),ae=te||X,de=te||P,ce=m&&ae!==!0,Q=re||z||ce;return pS({deleteKeyCode:p,multiSelectionKeyCode:_}),y.jsx(yS,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:de,panActivationKeyPressed:te,panOnScrollSpeed:b,panOnScrollMode:$,zoomOnDoubleClick:H,panOnDrag:!re&&ae,defaultViewport:ne,translateExtent:q,minZoom:ee,maxZoom:J,zoomActivationKeyCode:k,preventScrolling:C,noWheelClassName:F,noPanClassName:V,onViewportChange:L,isControlledViewport:O,paneClickDistance:h,selectionOnDrag:ce,children:y.jsxs(SS,{onSelectionStart:g,onSelectionEnd:S,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ae,autoPanOnSelection:K,isSelecting:!!Q,selectionMode:x,selectionKeyPressed:re,paneClickDistance:h,selectionOnDrag:ce,children:[t,j&&y.jsx($S,{onSelectionContextMenu:B,noPanClassName:V,disableKeyboardA11y:A})]})})}Cg.displayName="FlowRenderer";const OS=W.memo(Cg),bS=t=>r=>t?ic(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function FS(t){return Te(W.useCallback(bS(t),[t]),Ue)}const HS=t=>t.updateNodeInternals;function VS(){const t=Te(HS),[r]=W.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const l=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");l.set(u,{id:u,nodeElement:a.target,force:!0})}),t(l)}));return W.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function BS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=be(),u=W.useRef(null),d=W.useRef(null),h=W.useRef(t.sourcePosition),p=W.useRef(t.targetPosition),v=W.useRef(r),m=o&&!!t.internals.handleBounds;return W.useEffect(()=>{u.current&&!t.hidden&&(!m||d.current!==u.current)&&(d.current&&(l==null||l.unobserve(d.current)),l==null||l.observe(u.current),d.current=u.current)},[m,t.hidden]),W.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),W.useEffect(()=>{if(u.current){const x=v.current!==r,g=h.current!==t.sourcePosition,S=p.current!==t.targetPosition;(x||g||S)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function US({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:m,resizeObserver:x,noDragClassName:g,noPanClassName:S,disableKeyboardA11y:_,rfId:M,nodeTypes:k,nodeClickDistance:E,onError:T}){const{node:N,internals:P,isParent:b}=Te(Q=>{const se=Q.nodeLookup.get(t),he=Q.parentLookup.has(t);return{node:se,internals:se.internals,isParent:he}},Ue);let $=N.type||"default",H=(k==null?void 0:k[$])||Uh[$];H===void 0&&(T==null||T("003",en.error003($)),$="default",H=(k==null?void 0:k.default)||Uh.default);const X=!!(N.draggable||h&&typeof N.draggable>"u"),K=!!(N.selectable||p&&typeof N.selectable>"u"),ne=!!(N.connectable||v&&typeof N.connectable>"u"),q=!!(N.focusable||m&&typeof N.focusable>"u"),ee=be(),J=Xp(N),C=BS({node:N,nodeType:$,hasDimensions:J,resizeObserver:x}),B=_g({nodeRef:C,disabled:N.hidden||!X,noDragClassName:g,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),F=kg();if(N.hidden)return null;const V=nn(N),A=LS(N),L=K||X||r||o||l||a,O=o?Q=>o(Q,{...P.userNode}):void 0,j=l?Q=>l(Q,{...P.userNode}):void 0,z=a?Q=>a(Q,{...P.userNode}):void 0,re=u?Q=>u(Q,{...P.userNode}):void 0,te=d?Q=>d(Q,{...P.userNode}):void 0,ae=Q=>{const{selectNodesOnDrag:se,nodeDragThreshold:he}=ee.getState();K&&(!se||!X||he>0)&&Qu({id:t,store:ee,nodeRef:C}),r&&r(Q,{...P.userNode})},de=Q=>{if(!(Gp(Q.nativeEvent)||_)){if(Dp.includes(Q.key)&&K){const se=Q.key==="Escape";Qu({id:t,store:ee,unselect:se,nodeRef:C})}else if(X&&N.selected&&Object.prototype.hasOwnProperty.call(fl,Q.key)){Q.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Q.key.replace("Arrow","").toLowerCase(),x:~~P.positionAbsolute.x,y:~~P.positionAbsolute.y})}),F({direction:fl[Q.key],factor:Q.shiftKey?4:1})}}},ce=()=>{var Ce;if(_||!((Ce=C.current)!=null&&Ce.matches(":focus-visible")))return;const{transform:Q,width:se,height:he,autoPanOnNodeFocus:we,setCenter:ve}=ee.getState();if(!we)return;ic(new Map([[t,N]]),{x:0,y:0,width:se,height:he},Q,!0).length>0||ve(N.position.x+V.width/2,N.position.y+V.height/2,{zoom:Q[2]})};return y.jsx("div",{className:Ke(["react-flow__node",`react-flow__node-${$}`,{[S]:X},N.className,{selected:N.selected,selectable:K,parent:b,draggable:X,dragging:B}]),ref:C,style:{zIndex:P.z,transform:`translate(${P.positionAbsolute.x}px,${P.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:J?"visible":"hidden",...N.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:O,onMouseMove:j,onMouseLeave:z,onContextMenu:re,onClick:ae,onDoubleClick:te,onKeyDown:q?de:void 0,tabIndex:q?0:void 0,onFocus:q?ce:void 0,role:N.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":_?void 0:`${gg}-${M}`,"aria-label":N.ariaLabel,...N.domAttributes,children:y.jsx(kS,{value:t,children:y.jsx(H,{id:t,data:N.data,type:$,positionAbsoluteX:P.positionAbsolute.x,positionAbsoluteY:P.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:X,deletable:N.deletable??!0,isConnectable:ne,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:B,dragHandle:N.dragHandle,zIndex:P.z,parentId:N.parentId,...V})})})}var WS=W.memo(US);const YS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function jg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Te(YS,Ue),u=FS(t.onlyRenderVisibleElements),d=VS();return y.jsx("div",{className:"react-flow__nodes",style:El,children:u.map(h=>y.jsx(WS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:d,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}jg.displayName="NodeRenderer";const XS=W.memo(jg);function QS(t){return Te(W.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const l=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),d=o.nodeLookup.get(a.target);u&&d&&Hw({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Ue)}const KS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return y.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},GS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return y.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Yh={[al.Arrow]:KS,[al.ArrowClosed]:GS};function qS(t){const r=be();return W.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Yh,t)?Yh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",en.error009(t)),null)},[t])}const ZS=({id:t,type:r,color:o,width:l=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:d,orient:h="auto-start-reverse"})=>{const p=qS(r);return p?y.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:y.jsx(p,{color:o,strokeWidth:d})}):null},Mg=({defaultColor:t,rfId:r})=>{const o=Te(u=>u.edges),l=Te(u=>u.defaultEdgeOptions),a=W.useMemo(()=>Kw(o,{id:r,defaultColor:t,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[o,l,r,t]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(u=>y.jsx(ZS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Mg.displayName="MarkerDefinitions";var JS=W.memo(Mg);function Pg({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...m}){const[x,g]=W.useState({x:1,y:0,width:0,height:0}),S=Ke(["react-flow__edge-textwrapper",v]),_=W.useRef(null);return W.useEffect(()=>{if(_.current){const M=_.current.getBBox();g({x:M.x,y:M.y,width:M.width,height:M.height})}},[o]),o?y.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:S,visibility:x.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:x.width+2*d[0],x:-d[0],y:-d[1],height:x.height+2*d[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),y.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:_,style:l,children:o}),p]}):null}Pg.displayName="EdgeText";const e_=W.memo(Pg);function Nl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:t,fill:"none",className:Ke(["react-flow__edge-path",m.className])}),v?y.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,l&&Zt(r)&&Zt(o)?y.jsx(e_,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function Xh({pos:t,x1:r,y1:o,x2:l,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+l),o]:[r,.5*(o+a)]}function Ig({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,h]=Xh({pos:o,x1:t,y1:r,x2:l,y2:a}),[p,v]=Xh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,g,S]=Zp({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${d},${h} ${p},${v} ${l},${a}`,m,x,g,S]}function Tg(t){return W.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:h,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:S,style:_,markerEnd:M,markerStart:k,interactionWidth:E})=>{const[T,N,P]=Ig({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:h}),b=t.isInternal?void 0:r;return y.jsx(Nl,{id:b,path:T,labelX:N,labelY:P,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:S,style:_,markerEnd:M,markerStart:k,interactionWidth:E})})}const t_=Tg({isInternal:!1}),zg=Tg({isInternal:!0});t_.displayName="SimpleBezierEdge";zg.displayName="SimpleBezierEdgeInternal";function Rg(t){return W.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:g,sourcePosition:S=Se.Bottom,targetPosition:_=Se.Top,markerEnd:M,markerStart:k,pathOptions:E,interactionWidth:T})=>{const[N,P,b]=Uu({sourceX:o,sourceY:l,sourcePosition:S,targetX:a,targetY:u,targetPosition:_,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 y.jsx(Nl,{id:$,path:N,labelX:P,labelY:b,label:d,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:g,markerEnd:M,markerStart:k,interactionWidth:T})})}const Lg=Rg({isInternal:!1}),Ag=Rg({isInternal:!0});Lg.displayName="SmoothStepEdge";Ag.displayName="SmoothStepEdgeInternal";function $g(t){return W.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return y.jsx(Lg,{...o,id:l,pathOptions:W.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const n_=$g({isInternal:!1}),Dg=$g({isInternal:!0});n_.displayName="StepEdge";Dg.displayName="StepEdgeInternal";function Og(t){return W.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:g,markerEnd:S,markerStart:_,interactionWidth:M})=>{const[k,E,T]=tg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return y.jsx(Nl,{id:N,path:k,labelX:E,labelY:T,label:d,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:g,markerEnd:S,markerStart:_,interactionWidth:M})})}const r_=Og({isInternal:!1}),bg=Og({isInternal:!0});r_.displayName="StraightEdge";bg.displayName="StraightEdgeInternal";function Fg(t){return W.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:S,style:_,markerEnd:M,markerStart:k,pathOptions:E,interactionWidth:T})=>{const[N,P,b]=Jp({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return y.jsx(Nl,{id:$,path:N,labelX:P,labelY:b,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:S,style:_,markerEnd:M,markerStart:k,interactionWidth:T})})}const i_=Fg({isInternal:!1}),Hg=Fg({isInternal:!0});i_.displayName="BezierEdge";Hg.displayName="BezierEdgeInternal";const Qh={default:Hg,straight:bg,step:Dg,smoothstep:Ag,simplebezier:zg},Kh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},o_=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,s_=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,Gh="react-flow__edgeupdater";function qh({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:h}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:Ke([Gh,`${Gh}-${h}`]),cx:o_(r,l,t),cy:s_(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function l_({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:m,onReconnectEnd:x,setReconnecting:g,setUpdateHover:S}){const _=be(),M=(P,b)=>{if(P.button!==0)return;const{autoPanOnConnect:$,domNode:H,connectionMode:X,connectionRadius:K,lib:ne,onConnectStart:q,cancelConnection:ee,nodeLookup:J,rfId:C,panBy:B,updateConnection:F}=_.getState(),V=b.type==="target",A=(j,z)=>{g(!1),x==null||x(j,o,b.type,z)},L=j=>v==null?void 0:v(o,j),O=(j,z)=>{g(!0),m==null||m(P,o,b.type),q==null||q(j,z)};Xu.onPointerDown(P.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:K,domNode:H,handleId:b.id,nodeId:b.nodeId,nodeLookup:J,isTarget:V,edgeUpdaterType:b.type,lib:ne,flowId:C,cancelConnection:ee,panBy:B,isValidConnection:(...j)=>{var z,re;return((re=(z=_.getState()).isValidConnection)==null?void 0:re.call(z,...j))??!0},onConnect:L,onConnectStart:O,onConnectEnd:(...j)=>{var z,re;return(re=(z=_.getState()).onConnectEnd)==null?void 0:re.call(z,...j)},onReconnectEnd:A,updateConnection:F,getTransform:()=>_.getState().transform,getFromHandle:()=>_.getState().connection.fromHandle,dragThreshold:_.getState().connectionDragThreshold,handleDomNode:P.currentTarget})},k=P=>M(P,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=P=>M(P,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),T=()=>S(!0),N=()=>S(!1);return y.jsxs(y.Fragment,{children:[(t===!0||t==="source")&&y.jsx(qh,{position:h,centerX:l,centerY:a,radius:r,onMouseDown:k,onMouseEnter:T,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&y.jsx(qh,{position:p,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:T,onMouseOut:N,type:"target"})]})}function a_({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:m,onReconnect:x,onReconnectStart:g,onReconnectEnd:S,rfId:_,edgeTypes:M,noPanClassName:k,onError:E,disableKeyboardA11y:T}){let N=Te(ve=>ve.edgeLookup.get(t));const P=Te(ve=>ve.defaultEdgeOptions);N=P?{...P,...N}:N;let b=N.type||"default",$=(M==null?void 0:M[b])||Qh[b];$===void 0&&(E==null||E("011",en.error011(b)),b="default",$=(M==null?void 0:M.default)||Qh.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),X=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),ne=W.useRef(null),[q,ee]=W.useState(!1),[J,C]=W.useState(!1),B=be(),{zIndex:F=N.zIndex,sourceX:V,sourceY:A,targetX:L,targetY:O,sourcePosition:j,targetPosition:z}=Te(W.useCallback(ve=>{const me=ve.nodeLookup.get(N.source),Ce=ve.nodeLookup.get(N.target);if(!me||!Ce)return Kh;const Me=Qw({id:t,sourceNode:me,targetNode:Ce,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Pe=Fw({selected:N.selected,zIndex:N.zIndex,sourceNode:me,targetNode:Ce,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||Kh,zIndex:Pe}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Ue),re=W.useMemo(()=>N.markerStart?`url('#${Wu(N.markerStart,_)}')`:void 0,[N.markerStart,_]),te=W.useMemo(()=>N.markerEnd?`url('#${Wu(N.markerEnd,_)}')`:void 0,[N.markerEnd,_]);if(N.hidden||V===null||A===null||L===null||O===null)return null;const ae=ve=>{var Pe;const{addSelectedEdges:me,unselectNodesAndEdges:Ce,multiSelectionActive:Me}=B.getState();K&&(B.setState({nodesSelectionActive:!1}),N.selected&&Me?(Ce({nodes:[],edges:[N]}),(Pe=ne.current)==null||Pe.blur()):me([t])),a&&a(ve,N)},de=u?ve=>{u(ve,{...N})}:void 0,ce=d?ve=>{d(ve,{...N})}:void 0,Q=h?ve=>{h(ve,{...N})}:void 0,se=p?ve=>{p(ve,{...N})}:void 0,he=v?ve=>{v(ve,{...N})}:void 0,we=ve=>{var me;if(!T&&Dp.includes(ve.key)&&K){const{unselectNodesAndEdges:Ce,addSelectedEdges:Me}=B.getState();ve.key==="Escape"?((me=ne.current)==null||me.blur(),Ce({edges:[N]})):Me([t])}};return y.jsx("svg",{style:{zIndex:F},children:y.jsxs("g",{className:Ke(["react-flow__edge",`react-flow__edge-${b}`,N.className,k,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:q,selectable:K}]),onClick:ae,onDoubleClick:de,onContextMenu:ce,onMouseEnter:Q,onMouseMove:se,onMouseLeave:he,onKeyDown:H?we:void 0,tabIndex:H?0:void 0,role:N.ariaRole??(H?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":H?`${mg}-${_}`:void 0,ref:ne,...N.domAttributes,children:[!J&&y.jsx($,{id:t,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:K,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:V,sourceY:A,targetX:L,targetY:O,sourcePosition:j,targetPosition:z,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:re,markerEnd:te,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),X&&y.jsx(l_,{edge:N,isReconnectable:X,reconnectRadius:m,onReconnect:x,onReconnectStart:g,onReconnectEnd:S,sourceX:V,sourceY:A,targetX:L,targetY:O,sourcePosition:j,targetPosition:z,setUpdateHover:ee,setReconnecting:C})]})})}var u_=W.memo(a_);const c_=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function Vg({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:g,onReconnectStart:S,onReconnectEnd:_,disableKeyboardA11y:M}){const{edgesFocusable:k,edgesReconnectable:E,elementsSelectable:T,onError:N}=Te(c_,Ue),P=QS(r);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(JS,{defaultColor:t,rfId:o}),P.map(b=>y.jsx(u_,{id:b,edgesFocusable:k,edgesReconnectable:E,elementsSelectable:T,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:m,reconnectRadius:x,onDoubleClick:g,onReconnectStart:S,onReconnectEnd:_,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:M},b))]})}Vg.displayName="EdgeRenderer";const d_=W.memo(Vg),Zh=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function f_({children:t}){const r=be(),o=W.useRef(null),[l]=W.useState(()=>r.getState().transform);return wg(()=>{let a=null;const u=()=>{const d=r.getState().transform;a&&d[0]===a[0]&&d[1]===a[1]&&d[2]===a[2]||(a=d,o.current&&(o.current.style.transform=Zh(d)))};return u(),r.subscribe(u)},[r]),y.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Zh(l)},children:t})}function h_(t){const r=hc(),o=W.useRef(!1);W.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const p_=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function g_(t){const r=Te(p_),o=be();return W.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function m_(t){return t.connection.inProgress?{...t.connection,to:ko(t.connection.to,t.transform)}:{...t.connection}}function y_(t){return m_}function v_(t){const r=y_();return Te(r,Ue)}const x_=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function w_({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:h,inProgress:p}=Te(x_,Ue);return!(u&&a&&p)?null:y.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:Ke(["react-flow__connection",Fp(h)]),children:y.jsx(Bg,{style:r,type:o,CustomComponent:l,isValid:h})})})}const Bg=({style:t,type:r=qn.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:h,fromPosition:p,to:v,toNode:m,toHandle:x,toPosition:g,pointer:S}=v_();if(!a)return;if(o)return y.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:g,connectionStatus:Fp(l),toNode:m,toHandle:x,pointer:S});let _="";const M={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:g};switch(r){case qn.Bezier:[_]=Jp(M);break;case qn.SimpleBezier:[_]=Ig(M);break;case qn.Step:[_]=Uu({...M,borderRadius:0});break;case qn.SmoothStep:[_]=Uu(M);break;default:[_]=tg(M)}return y.jsx("path",{d:_,fill:"none",className:"react-flow__connection-path",style:t})};Bg.displayName="ConnectionLine";const S_={};function Jh(t=S_){W.useRef(t),be(),W.useEffect(()=>{},[t])}function __(){be(),W.useRef(!1),W.useEffect(()=>{},[])}function Ug({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:g,onSelectionEnd:S,connectionLineType:_,connectionLineStyle:M,connectionLineComponent:k,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:N,selectionMode:P,multiSelectionKeyCode:b,panActivationKeyCode:$,zoomActivationKeyCode:H,deleteKeyCode:X,onlyRenderVisibleElements:K,elementsSelectable:ne,defaultViewport:q,translateExtent:ee,minZoom:J,maxZoom:C,preventScrolling:B,defaultMarkerColor:F,zoomOnScroll:V,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:j,zoomOnDoubleClick:z,panOnDrag:re,autoPanOnSelection:te,onPaneClick:ae,onPaneMouseEnter:de,onPaneMouseMove:ce,onPaneMouseLeave:Q,onPaneScroll:se,onPaneContextMenu:he,paneClickDistance:we,nodeClickDistance:ve,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Me,onEdgeMouseLeave:Pe,reconnectRadius:Re,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:Xe,noDragClassName:Ge,noWheelClassName:Bt,noPanClassName:Lt,disableKeyboardA11y:At,nodeExtent:it,rfId:ft,viewport:lt,onViewportChange:ht,nodesDraggable:hn}){return Jh(t),Jh(r),__(),h_(o),g_(lt),y.jsx(OS,{onPaneClick:ae,onPaneMouseEnter:de,onPaneMouseMove:ce,onPaneMouseLeave:Q,onPaneContextMenu:he,onPaneScroll:se,paneClickDistance:we,deleteKeyCode:X,selectionKeyCode:T,selectionOnDrag:N,selectionMode:P,onSelectionStart:g,onSelectionEnd:S,multiSelectionKeyCode:b,panActivationKeyCode:$,zoomActivationKeyCode:H,elementsSelectable:ne,zoomOnScroll:V,zoomOnPinch:A,zoomOnDoubleClick:z,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:j,panOnDrag:re,autoPanOnSelection:te,defaultViewport:q,translateExtent:ee,minZoom:J,maxZoom:C,onSelectionContextMenu:x,preventScrolling:B,noDragClassName:Ge,noWheelClassName:Bt,noPanClassName:Lt,disableKeyboardA11y:At,onViewportChange:ht,isControlledViewport:!!lt,children:y.jsxs(f_,{children:[y.jsx(d_,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:Xe,onlyRenderVisibleElements:K,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Me,onEdgeMouseLeave:Pe,reconnectRadius:Re,defaultMarkerColor:F,noPanClassName:Lt,disableKeyboardA11y:At,rfId:ft}),y.jsx(w_,{style:M,type:_,component:k,containerStyle:E}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(XS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:m,nodeClickDistance:ve,onlyRenderVisibleElements:K,noPanClassName:Lt,noDragClassName:Ge,disableKeyboardA11y:At,nodeExtent:it,rfId:ft,nodesDraggable:hn}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}Ug.displayName="GraphView";const k_=W.memo(Ug),E_=Yp(),ep=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:m,nodeExtent:x,zIndexMode:g="basic"}={})=>{const S=new Map,_=new Map,M=new Map,k=new Map,E=l??r??[],T=o??t??[],N=m??[0,0],P=x??co;ig(M,k,E);const{nodesInitialized:b}=Yu(T,S,_,{nodeOrigin:N,nodeExtent:P,zIndexMode:g});let $=[0,0,1];if(d&&a&&u){const H=So(S,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:X,y:K,zoom:ne}=sc(H,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[X,K,ne]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:T,nodesInitialized:b,nodeLookup:S,parentLookup:_,edges:E,edgeLookup:k,connectionLookup:M,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:co,nodeExtent:P,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:li.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:h,fitViewResolver:null,connection:{...bp},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:E_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Op,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},N_=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:m,nodeExtent:x,zIndexMode:g})=>D1((S,_)=>{async function M(){const{nodeLookup:k,panZoom:E,fitViewOptions:T,fitViewResolver:N,width:P,height:b,minZoom:$,maxZoom:H}=_();E&&(await Rw({nodes:k,width:P,height:b,panZoom:E,minZoom:$,maxZoom:H},T),N==null||N.resolve(!0),S({fitViewResolver:null}))}return{...ep({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:g}),setNodes:k=>{const{nodeLookup:E,parentLookup:T,nodeOrigin:N,nodeExtent:P,elevateNodesOnSelect:b,fitViewQueued:$,zIndexMode:H,nodesSelectionActive:X}=_(),{nodesInitialized:K,hasSelectedNodes:ne}=Yu(k,E,T,{nodeOrigin:N,nodeExtent:P,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:H}),q=X&≠$&&K?(M(),S({nodes:k,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):S({nodes:k,nodesInitialized:K,nodesSelectionActive:q})},setEdges:k=>{const{connectionLookup:E,edgeLookup:T}=_();ig(E,T,k),S({edges:k})},setDefaultNodesAndEdges:(k,E)=>{if(k){const{setNodes:T}=_();T(k),S({hasDefaultNodes:!0})}if(E){const{setEdges:T}=_();T(E),S({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:E,nodeLookup:T,parentLookup:N,domNode:P,nodeOrigin:b,nodeExtent:$,debug:H,fitViewQueued:X,zIndexMode:K}=_(),{changes:ne,updatedInternals:q}=n1(k,T,N,P,b,$,K);q&&(Zw(T,N,{nodeOrigin:b,nodeExtent:$,zIndexMode:K}),X?(M(),S({fitViewQueued:!1,fitViewOptions:void 0})):S({}),(ne==null?void 0:ne.length)>0&&(H&&console.log("React Flow: trigger node changes",ne),E==null||E(ne)))},updateNodePositions:(k,E=!1)=>{const T=[];let N=[];const{nodeLookup:P,triggerNodeChanges:b,connection:$,updateConnection:H,onNodesChangeMiddlewareMap:X}=_();for(const[K,ne]of k){const q=P.get(K),ee=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(ne!=null&&ne.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:E};if(q&&$.inProgress&&$.fromNode.id===q.id){const C=Nr(q,$.fromHandle,Se.Left,!0);H({...$,from:C})}ee&&q.parentId&&T.push({id:K,parentId:q.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),N.push(J)}if(T.length>0){const{parentLookup:K,nodeOrigin:ne}=_(),q=fc(T,P,K,ne);N.push(...q)}for(const K of X.values())N=K(N);b(N)},triggerNodeChanges:k=>{const{onNodesChange:E,setNodes:T,nodes:N,hasDefaultNodes:P,debug:b}=_();if(k!=null&&k.length){if(P){const $=iS(k,N);T($)}b&&console.log("React Flow: trigger node changes",k),E==null||E(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:E,setEdges:T,edges:N,hasDefaultEdges:P,debug:b}=_();if(k!=null&&k.length){if(P){const $=oS(k,N);T($)}b&&console.log("React Flow: trigger edge changes",k),E==null||E(k)}},addSelectedNodes:k=>{const{multiSelectionActive:E,edgeLookup:T,nodeLookup:N,triggerNodeChanges:P,triggerEdgeChanges:b}=_();if(E){const $=k.map(H=>yr(H,!0));P($);return}P(ni(N,new Set([...k]),!0)),b(ni(T))},addSelectedEdges:k=>{const{multiSelectionActive:E,edgeLookup:T,nodeLookup:N,triggerNodeChanges:P,triggerEdgeChanges:b}=_();if(E){const $=k.map(H=>yr(H,!0));b($);return}b(ni(T,new Set([...k]))),P(ni(N,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:E}={})=>{const{edges:T,nodes:N,nodeLookup:P,triggerNodeChanges:b,triggerEdgeChanges:$}=_(),H=k||N,X=E||T,K=[];for(const q of H){if(!q.selected)continue;const ee=P.get(q.id);ee&&(ee.selected=!1),K.push(yr(q.id,!1))}const ne=[];for(const q of X)q.selected&&ne.push(yr(q.id,!1));b(K),$(ne)},setMinZoom:k=>{const{panZoom:E,maxZoom:T}=_();E==null||E.setScaleExtent([k,T]),S({minZoom:k})},setMaxZoom:k=>{const{panZoom:E,minZoom:T}=_();E==null||E.setScaleExtent([T,k]),S({maxZoom:k})},setTranslateExtent:k=>{var E;(E=_().panZoom)==null||E.setTranslateExtent(k),S({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:E,triggerNodeChanges:T,triggerEdgeChanges:N,elementsSelectable:P}=_();if(!P)return;const b=E.reduce((H,X)=>X.selected?[...H,yr(X.id,!1)]:H,[]),$=k.reduce((H,X)=>X.selected?[...H,yr(X.id,!1)]:H,[]);T(b),N($)},setNodeExtent:k=>{const{nodes:E,nodeLookup:T,parentLookup:N,nodeOrigin:P,elevateNodesOnSelect:b,nodeExtent:$,zIndexMode:H}=_();k[0][0]===$[0][0]&&k[0][1]===$[0][1]&&k[1][0]===$[1][0]&&k[1][1]===$[1][1]||(Yu(E,T,N,{nodeOrigin:P,nodeExtent:k,elevateNodesOnSelect:b,checkEquality:!1,zIndexMode:H}),S({nodeExtent:k}))},panBy:k=>{const{transform:E,width:T,height:N,panZoom:P,translateExtent:b}=_();return r1({delta:k,panZoom:P,transform:E,translateExtent:b,width:T,height:N})},setCenter:async(k,E,T)=>{const{width:N,height:P,maxZoom:b,panZoom:$}=_();if(!$)return!1;const H=typeof(T==null?void 0:T.zoom)<"u"?T.zoom:b;return await $.setViewport({x:N/2-k*H,y:P/2-E*H,zoom:H},{duration:T==null?void 0:T.duration,ease:T==null?void 0:T.ease,interpolate:T==null?void 0:T.interpolate}),!0},cancelConnection:()=>{S({connection:{...bp}})},updateConnection:k=>{S({connection:k})},reset:()=>S({...ep()})}},Object.is);function Wg({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:m,nodeExtent:x,zIndexMode:g,children:S}){const[_]=W.useState(()=>N_({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:v,minZoom:d,maxZoom:h,fitViewOptions:p,nodeOrigin:m,nodeExtent:x,zIndexMode:g}));return y.jsx(O1,{value:_,children:y.jsx(cS,{children:y.jsx(NS,{children:S})})})}function C_({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:m,nodeOrigin:x,nodeExtent:g,zIndexMode:S}){return W.useContext(_l)?y.jsx(y.Fragment,{children:t}):y.jsx(Wg,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:m,nodeOrigin:x,nodeExtent:g,zIndexMode:S,children:t})}const j_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function M_({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:m,onMoveStart:x,onMoveEnd:g,onConnect:S,onConnectStart:_,onConnectEnd:M,onClickConnectStart:k,onClickConnectEnd:E,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:P,onNodeContextMenu:b,onNodeDoubleClick:$,onNodeDragStart:H,onNodeDrag:X,onNodeDragStop:K,onNodesDelete:ne,onEdgesDelete:q,onDelete:ee,onSelectionChange:J,onSelectionDragStart:C,onSelectionDrag:B,onSelectionDragStop:F,onSelectionContextMenu:V,onSelectionStart:A,onSelectionEnd:L,onBeforeDelete:O,connectionMode:j,connectionLineType:z=qn.Bezier,connectionLineStyle:re,connectionLineComponent:te,connectionLineContainerStyle:ae,deleteKeyCode:de="Backspace",selectionKeyCode:ce="Shift",selectionOnDrag:Q=!1,selectionMode:se=fo.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:we=po()?"Meta":"Control",zoomActivationKeyCode:ve=po()?"Meta":"Control",snapToGrid:me,snapGrid:Ce,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Pe,nodesDraggable:Re,autoPanOnNodeFocus:nt,nodesConnectable:rt,nodesFocusable:Xe,nodeOrigin:Ge=yg,edgesFocusable:Bt,edgesReconnectable:Lt,elementsSelectable:At=!0,defaultViewport:it=q1,minZoom:ft=.5,maxZoom:lt=2,translateExtent:ht=co,preventScrolling:hn=!0,nodeExtent:$t,defaultMarkerColor:rn="#b1b1b7",zoomOnScroll:Z=!0,zoomOnPinch:Ee=!0,panOnScroll:$e=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:mt=wr.Free,zoomOnDoubleClick:di=!0,panOnDrag:fi=!0,onPaneClick:hi,onPaneMouseEnter:pi,onPaneMouseMove:jn,onPaneMouseLeave:Mn,onPaneScroll:Eo,onPaneContextMenu:No,paneClickDistance:Co=1,nodeClickDistance:jo=0,children:Mo,onReconnect:gi,onReconnectStart:Po,onReconnectEnd:Jn,onEdgeContextMenu:mi,onEdgeDoubleClick:er,onEdgeMouseEnter:Cl,onEdgeMouseMove:tr,onEdgeMouseLeave:Cr,reconnectRadius:jr=10,onNodesChange:yi,onEdgesChange:jl,noDragClassName:Ml="nodrag",noWheelClassName:Pl="nowheel",noPanClassName:on="nopan",fitView:vi,fitViewOptions:xi,connectOnClick:Il,attributionPosition:Io,proOptions:To,defaultEdgeOptions:zo,elevateNodesOnSelect:Ro=!0,elevateEdgesOnSelect:Tl=!1,disableKeyboardA11y:Lo=!1,autoPanOnConnect:He,autoPanOnNodeDrag:zl,autoPanOnSelection:wi=!0,autoPanSpeed:Ao,connectionRadius:Mr,isValidConnection:Rl,onError:$o,style:Pr,id:Nt,nodeDragThreshold:Ll,connectionDragThreshold:Ct,viewport:Al,onViewportChange:$l,width:Dl,height:Ir,colorMode:Tr="light",debug:nr,onScroll:pn,ariaLabelConfig:Ol,zIndexMode:Do="basic",...Si},Oo){const rr=Nt||"1",ir=tS(Tr),bl=W.useCallback(zr=>{zr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),pn==null||pn(zr)},[pn]);return y.jsx("div",{"data-testid":"rf__wrapper",...Si,onScroll:bl,style:{...Pr,...j_},ref:Oo,className:Ke(["react-flow",a,ir]),id:Nt,role:"application",children:y.jsxs(C_,{nodes:t,edges:r,width:Dl,height:Ir,fitView:vi,fitViewOptions:xi,minZoom:ft,maxZoom:lt,nodeOrigin:Ge,nodeExtent:$t,zIndexMode:Do,children:[y.jsx(eS,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:S,onConnectStart:_,onConnectEnd:M,onClickConnectStart:k,onClickConnectEnd:E,nodesDraggable:Re,autoPanOnNodeFocus:nt,nodesConnectable:rt,nodesFocusable:Xe,edgesFocusable:Bt,edgesReconnectable:Lt,elementsSelectable:At,elevateNodesOnSelect:Ro,elevateEdgesOnSelect:Tl,minZoom:ft,maxZoom:lt,nodeExtent:$t,onNodesChange:yi,onEdgesChange:jl,snapToGrid:me,snapGrid:Ce,connectionMode:j,translateExtent:ht,connectOnClick:Il,defaultEdgeOptions:zo,fitView:vi,fitViewOptions:xi,onNodesDelete:ne,onEdgesDelete:q,onDelete:ee,onNodeDragStart:H,onNodeDrag:X,onNodeDragStop:K,onSelectionDrag:B,onSelectionDragStart:C,onSelectionDragStop:F,onMove:m,onMoveStart:x,onMoveEnd:g,noPanClassName:on,nodeOrigin:Ge,rfId:rr,autoPanOnConnect:He,autoPanOnNodeDrag:zl,autoPanSpeed:Ao,onError:$o,connectionRadius:Mr,isValidConnection:Rl,selectNodesOnDrag:Pe,nodeDragThreshold:Ll,connectionDragThreshold:Ct,onBeforeDelete:O,debug:nr,ariaLabelConfig:Ol,zIndexMode:Do}),y.jsx(k_,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:P,onNodeContextMenu:b,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:d,connectionLineType:z,connectionLineStyle:re,connectionLineComponent:te,connectionLineContainerStyle:ae,selectionKeyCode:ce,selectionOnDrag:Q,selectionMode:se,deleteKeyCode:de,multiSelectionKeyCode:we,panActivationKeyCode:he,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:it,translateExtent:ht,minZoom:ft,maxZoom:lt,preventScrolling:hn,zoomOnScroll:Z,zoomOnPinch:Ee,zoomOnDoubleClick:di,panOnScroll:$e,panOnScrollSpeed:Cn,panOnScrollMode:mt,panOnDrag:fi,autoPanOnSelection:wi,onPaneClick:hi,onPaneMouseEnter:pi,onPaneMouseMove:jn,onPaneMouseLeave:Mn,onPaneScroll:Eo,onPaneContextMenu:No,paneClickDistance:Co,nodeClickDistance:jo,onSelectionContextMenu:V,onSelectionStart:A,onSelectionEnd:L,onReconnect:gi,onReconnectStart:Po,onReconnectEnd:Jn,onEdgeContextMenu:mi,onEdgeDoubleClick:er,onEdgeMouseEnter:Cl,onEdgeMouseMove:tr,onEdgeMouseLeave:Cr,reconnectRadius:jr,defaultMarkerColor:rn,noDragClassName:Ml,noWheelClassName:Pl,noPanClassName:on,rfId:rr,disableKeyboardA11y:Lo,nodeExtent:$t,viewport:Al,onViewportChange:$l,nodesDraggable:Re}),y.jsx(G1,{onSelectionChange:J}),Mo,y.jsx(W1,{proOptions:To,position:Io}),y.jsx(U1,{rfId:rr,disableKeyboardA11y:Lo})]})})}var P_=xg(M_);function I_({dimensions:t,lineWidth:r,variant:o,className:l}){return y.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Ke(["react-flow__background-pattern",o,l])})}function T_({radius:t,className:r}){return y.jsx("circle",{cx:t,cy:t,r:t,className:Ke(["react-flow__background-pattern","dots",r])})}var Zn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Zn||(Zn={}));const z_={[Zn.Dots]:1,[Zn.Lines]:1,[Zn.Cross]:6},R_=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Yg({id:t,variant:r=Zn.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:h,style:p,className:v,patternClassName:m}){const x=W.useRef(null),{transform:g,patternId:S}=Te(R_,Ue),_=l||z_[r],M=r===Zn.Dots,k=r===Zn.Cross,E=Array.isArray(o)?o:[o,o],T=[E[0]*g[2]||1,E[1]*g[2]||1],N=_*g[2],P=Array.isArray(u)?u:[u,u],b=k?[N,N]:T,$=[P[0]*g[2]+b[0]/2,P[1]*g[2]+b[1]/2],H=`${S}${t||""}`;return y.jsxs("svg",{className:Ke(["react-flow__background",v]),style:{...p,...El,"--xy-background-color-props":h,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[y.jsx("pattern",{id:H,x:g[0]%T[0],y:g[1]%T[1],width:T[0],height:T[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:M?y.jsx(T_,{radius:N/2,className:m}):y.jsx(I_,{dimensions:b,lineWidth:a,variant:r,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}Yg.displayName="Background";const L_=W.memo(Yg);function A_(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function $_(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function D_(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function O_(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function b_(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Ks({children:t,className:r,...o}){return y.jsx("button",{type:"button",className:Ke(["react-flow__controls-button",r]),...o,children:t})}const F_=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function Xg({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:h,onInteractiveChange:p,className:v,children:m,position:x="bottom-left",orientation:g="vertical","aria-label":S}){const _=be(),{isInteractive:M,minZoomReached:k,maxZoomReached:E,ariaLabelConfig:T}=Te(F_,Ue),{zoomIn:N,zoomOut:P,fitView:b}=hc(),$=()=>{N(),u==null||u()},H=()=>{P(),d==null||d()},X=()=>{b(a),h==null||h()},K=()=>{_.setState({nodesDraggable:!M,nodesConnectable:!M,elementsSelectable:!M}),p==null||p(!M)},ne=g==="horizontal"?"horizontal":"vertical";return y.jsxs(kl,{className:Ke(["react-flow__controls",ne,v]),position:x,style:t,"data-testid":"rf__controls","aria-label":S??T["controls.ariaLabel"],children:[r&&y.jsxs(y.Fragment,{children:[y.jsx(Ks,{onClick:$,className:"react-flow__controls-zoomin",title:T["controls.zoomIn.ariaLabel"],"aria-label":T["controls.zoomIn.ariaLabel"],disabled:E,children:y.jsx(A_,{})}),y.jsx(Ks,{onClick:H,className:"react-flow__controls-zoomout",title:T["controls.zoomOut.ariaLabel"],"aria-label":T["controls.zoomOut.ariaLabel"],disabled:k,children:y.jsx($_,{})})]}),o&&y.jsx(Ks,{className:"react-flow__controls-fitview",onClick:X,title:T["controls.fitView.ariaLabel"],"aria-label":T["controls.fitView.ariaLabel"],children:y.jsx(D_,{})}),l&&y.jsx(Ks,{className:"react-flow__controls-interactive",onClick:K,title:T["controls.interactive.ariaLabel"],"aria-label":T["controls.interactive.ariaLabel"],children:M?y.jsx(b_,{}):y.jsx(O_,{})}),m]})}Xg.displayName="Controls";const H_=W.memo(Xg);function V_({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:h,strokeWidth:p,className:v,borderRadius:m,shapeRendering:x,selected:g,onClick:S}){const{background:_,backgroundColor:M}=u||{},k=d||_||M;return y.jsx("rect",{className:Ke(["react-flow__minimap-node",{selected:g},v]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:k,stroke:h,strokeWidth:p},shapeRendering:x,onClick:S?E=>S(E,t):void 0})}const B_=W.memo(V_),U_=t=>t.nodes.map(r=>r.id),Ru=t=>t instanceof Function?t:()=>t;function W_({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=B_,onClick:d}){const h=Te(U_,Ue),p=Ru(r),v=Ru(t),m=Ru(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:h.map(g=>y.jsx(X_,{id:g,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},g))})}function Y_({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:h,onClick:p}){const{node:v,x:m,y:x,width:g,height:S}=Te(_=>{const M=_.nodeLookup.get(t);if(!M)return{node:void 0,x:0,y:0,width:0,height:0};const k=M.internals.userNode,{x:E,y:T}=M.internals.positionAbsolute,{width:N,height:P}=nn(k);return{node:k,x:E,y:T,width:N,height:P}},Ue);return!v||v.hidden||!Xp(v)?null:y.jsx(h,{x:m,y:x,width:g,height:S,style:v.style,selected:!!v.selected,className:l(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:d,onClick:p,id:v.id})}const X_=W.memo(Y_);var Q_=W.memo(W_);const K_=200,G_=150,q_=t=>!t.hidden,Z_=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?Up(So(t.nodeLookup,{filter:q_}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},tp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,J_=(t,r)=>tp(t.viewBB,r.viewBB)&&tp(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,ek="react-flow__minimap-desc";function Qg({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:m,maskStrokeWidth:x,position:g="bottom-right",onClick:S,onNodeClick:_,pannable:M=!1,zoomable:k=!1,ariaLabel:E,inversePan:T,zoomStep:N=1,offsetScale:P=5}){const b=be(),$=W.useRef(null),{boundingRect:H,viewBB:X,rfId:K,panZoom:ne,translateExtent:q,flowWidth:ee,flowHeight:J,ariaLabelConfig:C}=Te(Z_,J_),B=(t==null?void 0:t.width)??K_,F=(t==null?void 0:t.height)??G_,V=H.width/B,A=H.height/F,L=Math.max(V,A),O=L*B,j=L*F,z=P*L,re=H.x-(O-H.width)/2-z,te=H.y-(j-H.height)/2-z,ae=O+z*2,de=j+z*2,ce=`${ek}-${K}`,Q=W.useRef(0),se=W.useRef();Q.current=L,W.useEffect(()=>{if($.current&&ne)return se.current=f1({domNode:$.current,panZoom:ne,getTransform:()=>b.getState().transform,getViewScale:()=>Q.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[ne]),W.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:q,width:ee,height:J,inversePan:T,pannable:M,zoomStep:N,zoomable:k})},[M,k,T,N,q,ee,J]);const he=S?me=>{var Pe;const[Ce,Me]=((Pe=se.current)==null?void 0:Pe.pointer(me))||[0,0];S(me,{x:Ce,y:Me})}:void 0,we=_?W.useCallback((me,Ce)=>{const Me=b.getState().nodeLookup.get(Ce).internals.userNode;_(me,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return y.jsx(kl,{position:g,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*L:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof d=="number"?d:void 0},className:Ke(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:B,height:F,viewBox:`${re} ${te} ${ae} ${de}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ce,ref:$,onClick:he,children:[ve&&y.jsx("title",{id:ce,children:ve}),y.jsx(Q_,{onClick:we,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:h}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${re-z},${te-z}h${ae+z*2}v${de+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"})]})})}Qg.displayName="MiniMap";const tk=W.memo(Qg),nk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,rk={[ci.Line]:"right",[ci.Handle]:"bottom-right"};function ik({nodeId:t,position:r,variant:o=ci.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:g,autoScale:S=!0,shouldResize:_,onResizeStart:M,onResize:k,onResizeEnd:E}){const T=Eg(),N=typeof t=="string"?t:T,P=be(),b=W.useRef(null),$=o===ci.Handle,H=Te(W.useCallback(nk($&&S),[$,S]),Ue),X=W.useRef(null),K=r??rk[o];W.useEffect(()=>{if(!(!b.current||!N))return X.current||(X.current=N1({domNode:b.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:q,transform:ee,snapGrid:J,snapToGrid:C,nodeOrigin:B,domNode:F}=P.getState();return{nodeLookup:q,transform:ee,snapGrid:J,snapToGrid:C,nodeOrigin:B,paneDomNode:F}},onChange:(q,ee)=>{const{triggerNodeChanges:J,nodeLookup:C,parentLookup:B,nodeOrigin:F}=P.getState(),V=[],A={x:q.x,y:q.y},L=C.get(N);if(L&&L.expandParent&&L.parentId){const O=L.origin??F,j=q.width??L.measured.width??0,z=q.height??L.measured.height??0,re={id:L.id,parentId:L.parentId,rect:{width:j,height:z,...Qp({x:q.x??L.position.x,y:q.y??L.position.y},{width:j,height:z},L.parentId,C,O)}},te=fc([re],C,B,F);V.push(...te),A.x=q.x?Math.max(O[0]*j,q.x):void 0,A.y=q.y?Math.max(O[1]*z,q.y):void 0}if(A.x!==void 0&&A.y!==void 0){const O={id:N,type:"position",position:{...A}};V.push(O)}if(q.width!==void 0&&q.height!==void 0){const j={id:N,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};V.push(j)}for(const O of ee){const j={...O,type:"position"};V.push(j)}J(V)},onEnd:({width:q,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:q,height:ee}};P.getState().triggerNodeChanges([J])}})),X.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:m},keepAspectRatio:x,resizeDirection:g,onResizeStart:M,onResize:k,onResizeEnd:E,shouldResize:_}),()=>{var q;(q=X.current)==null||q.destroy()}},[K,h,p,v,m,x,M,k,E,_]);const ne=K.split("-");return y.jsx("div",{className:Ke(["react-flow__resize-control","nodrag",...ne,o,l]),ref:b,style:{...a,scale:H,...d&&{[$?"backgroundColor":"borderColor"]:d}},children:u})}W.memo(ik);const ok={"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 sk(t){return ok[t]??8}function lk(t){const r=new Map;for(const l of t){const a=sk(l.type),u=r.get(a)??[];u.push(l),r.set(a,u)}const o=new Map;for(const[l,a]of r)a.sort((u,d)=>u.name.localeCompare(d.name)),a.forEach((u,d)=>{o.set(u.id,{x:l*260,y:d*108})});return o}const ak={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uk({data:t,selected:r}){return y.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[y.jsx("div",{className:"t",children:Ku(t.type)}),y.jsx("div",{className:"n",title:t.name,children:t.name})]})}const ck={load:uk},np=180,rp=56;function Lu({nodes:t,edges:r}){const[o,l]=W.useState(null),a=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,u=W.useMemo(()=>new Map(t.map(x=>[x.id,x])),[t]),d=o?u.get(o)??null:null,h=lk(t),p=t.map(x=>({id:x.id,type:"load",position:h.get(x.id)??{x:0,y:0},data:{name:x.name,type:x.type,file:x.file_path},selected:o===x.id,width:np,height:rp,style:{width:np,height:rp}})),v=r.filter(x=>u.has(x.src)&&u.has(x.dst)).map(x=>({id:x.id,source:x.src,target:x.dst,animated:!a&&x.weight==="critical",style:{stroke:ak[x.weight]||"var(--edge-cheap)",strokeWidth:x.weight==="critical"?2.4:1.2,strokeDasharray:x.confidence<.8?"6 4":void 0},label:x.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:10}})),m=(x,g)=>{l(g.id)};return y.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[y.jsx(Wg,{children:y.jsxs(P_,{nodes:p,edges:v,nodeTypes:ck,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.15},minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:m,onPaneClick:()=>l(null),proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[y.jsx(L_,{}),y.jsx(tk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),y.jsx(H_,{})]})}),d?y.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[y.jsx("div",{className:"t",children:Ku(d.type)}),y.jsx("div",{className:"n",children:Fs(d.name)}),d.context?y.jsx("div",{className:"muted",children:Fs(d.context)}):null,d.file_path?y.jsx("div",{className:"file",children:Fs(`${d.file_path}${d.start_line?`:${d.start_line}`:""}`)}):null,y.jsx("div",{className:"muted",children:Fs(d.qualified_name)})]}):null]})}const hl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"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"}],dk="obsidian",Kg="loadpath.theme";function fk(t){return hl.some(r=>r.id===t)}function Gg(){try{const t=localStorage.getItem(Kg)||"";if(fk(t))return t}catch{}return dk}function hk(t){var r;return((r=hl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function qg(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=hk(t);try{localStorage.setItem(Kg,t)}catch{}}const ip=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:W0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:Y0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:X0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:Q0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:K0}];function pk(){var it,ft,lt,ht,hn,$t,rn;const[t,r]=W.useState("review"),[o,l]=W.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=W.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,h]=W.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=W.useState(null),[m,x]=W.useState(null),[g,S]=W.useState([]),[_,M]=W.useState("review"),[k,E]=W.useState(""),[T,N]=W.useState(""),[P,b]=W.useState(""),[$,H]=W.useState({}),[X,K]=W.useState([]),[ne,q]=W.useState(localStorage.getItem("loadpath.scmRepo")||""),[ee,J]=W.useState(localStorage.getItem("loadpath.provider")||"github"),[C,B]=W.useState(localStorage.getItem("loadpath.prNumber")||""),[F,V]=W.useState(""),[A,L]=W.useState(Gg),[O,j]=W.useState(!1),z=W.useRef(o);z.current=o;const re=Z=>{L(Z),qg(Z)},te=W.useRef(""),ae=Z=>{te.current=Z,N(Z)};W.useEffect(()=>{kt.settings().then(H).catch(()=>{}).finally(()=>j(!0)),kt.repos().then(Z=>S(Z.repos)).catch(()=>{})},[]);const de=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);W.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const Z=o;let Ee=!1;return kt.architecture(Z).then($e=>{!Ee&&z.current===Z&&x($e)}).catch(()=>{}),()=>{Ee=!0}},[t,o]);const ce=Z=>{l(Z),localStorage.setItem("loadpath.repo",Z)},Q=(Z,Ee)=>{u(Z),h(Ee),localStorage.setItem("loadpath.base",Z),localStorage.setItem("loadpath.head",Ee)},se=(Z,Ee,$e)=>{J(Z),q(Ee),localStorage.setItem("loadpath.provider",Z),localStorage.setItem("loadpath.scmRepo",Ee),$e!==void 0&&(B($e),localStorage.setItem("loadpath.prNumber",$e))},he=async(Z=o)=>{if(!Z.trim())return null;const Ee=await kt.architecture(Z);return z.current===Z&&x(Ee),Ee},we=async()=>{if(!te.current&&de()){E(""),b(""),ae("Tracing load path…"),ce(o),Q(a,d);try{const Z=await kt.review(o,a,d,!0);v(Z),M("review"),r("review"),await kt.repos().then(Ee=>S(Ee.repos)).catch(()=>{}),await he(o)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},ve=async(Z=!0)=>{if(!te.current&&de()){E(""),b(""),ae(Z?"Indexing…":"Full reindex…"),ce(o);try{await kt.index(o,Z);const Ee=await he(o);await kt.repos().then($e=>S($e.repos)).catch(()=>{}),Ee!=null&&Ee.indexed&&(M("architecture"),r("architecture"))}catch(Ee){E(Ee instanceof Error?Ee.message:String(Ee))}finally{ae("")}}},me=async()=>{if(!te.current&&de()){E(""),b(""),ae("Detecting layout…"),ce(o);try{const Z=await kt.init(o);b(Z.message),await kt.repos().then(Ee=>S(Ee.repos)).catch(()=>{})}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Ce=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),b("Copied markdown brief")}catch(Z){E(Z instanceof Error?Z.message:String(Z))}},Me=async()=>{if(!te.current){if(!(p!=null&&p.markdown)||!ne||!C){E("Pick a pull request first (Pull requests tab), then post the brief.");return}ae("Posting Loadpath brief…");try{const Z=await kt.postComment(ee,ne,Number(C),p.markdown);b(Z.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Pe=async()=>{if(!te.current){E(""),ae("Fetching pull requests…");try{const Z=await kt.prs(ee,ne);K(Z.pull_requests)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Re=async Z=>{Z.preventDefault();const Ee=new FormData(Z.currentTarget),$e={github_token:String(Ee.get("github_token")||""),bitbucket_token:String(Ee.get("bitbucket_token")||""),bitbucket_username:String(Ee.get("bitbucket_username")||""),ai_provider:String(Ee.get("ai_provider")||"none"),ai_api_key:String(Ee.get("ai_api_key")||""),ai_model:String(Ee.get("ai_model")||""),ai_base_url:String(Ee.get("ai_base_url")||"")},Cn=g.length?{...$e,workspaces:g.map(mt=>({path:mt.path,name:mt.name}))}:$e;try{H(await kt.saveSettings(Cn)),b("Settings saved on this machine")}catch(mt){E(mt instanceof Error?mt.message:String(mt))}},nt=async()=>{if(!(!p||te.current)){ae("Residual analysis…");try{const Z=await kt.residual(p);V(Z.note)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},rt=W.useRef(we);rt.current=we;const Xe=W.useRef(t);Xe.current=t,W.useEffect(()=>{const Z=Ee=>{const $e=Ee.target;if($e&&($e.tagName==="INPUT"||$e.tagName==="TEXTAREA"||$e.tagName==="SELECT"||$e.isContentEditable)){Ee.key==="Escape"&&$e.blur();return}if(Ee.key==="Escape"){E(""),b("");return}const Cn=ip.find(mt=>mt.shortcut===Ee.key);if(Cn&&!Ee.metaKey&&!Ee.ctrlKey&&!Ee.altKey&&r(Cn.id),(Ee.metaKey||Ee.ctrlKey)&&Ee.key==="Enter"){if(Xe.current==="settings"||Xe.current==="prs"||te.current)return;Ee.preventDefault(),rt.current()}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[]);const Ge=W.useMemo(()=>_==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[_,m,p]),Bt=W.useMemo(()=>_==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[_,m,p]),Lt=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",At=((p==null?void 0:p.findings)||[]).filter(Z=>!Z.waived);return y.jsxs("div",{className:"app",children:[y.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),y.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[y.jsxs("div",{className:"brand",children:[y.jsx("div",{className:"brand-mark",children:"Loadpath"}),y.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),ip.map(Z=>{const Ee=Z.icon,$e=t===Z.id;return y.jsxs("button",{type:"button","data-testid":Z.testId,className:$e?"nav-item active":"nav-item","aria-current":$e?"page":void 0,"aria-label":Z.label,onClick:()=>r(Z.id),children:[y.jsx(Ee,{}),y.jsx("span",{children:Z.label})]},Z.id)}),y.jsxs("div",{className:"theme-pick",children:[y.jsx("label",{htmlFor:"theme-select",children:"Theme"}),y.jsx("select",{id:"theme-select","data-testid":"theme-select",value:A,onChange:Z=>re(Z.target.value),children:hl.map(Z=>y.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),y.jsxs("div",{className:"rail-foot",children:[y.jsx("div",{className:"muted",role:"status",children:T||Lt}),y.jsxs("div",{className:"kbd-hint",children:[y.jsx("kbd",{children:"1"}),"–",y.jsx("kbd",{children:"5"})," tabs · ",y.jsx("kbd",{children:"Ctrl"}),"+",y.jsx("kbd",{children:"Enter"})," review"]})]})]}),y.jsxs("div",{className:"main",id:"main",children:[T?y.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[y.jsx("i",{}),y.jsx("span",{className:"sr-only",children:T})]}):null,y.jsxs("header",{className:"topbar","data-testid":"topbar",children:[g.length>0?y.jsxs("label",{className:"field workspace",children:[y.jsx("span",{children:"Workspace"}),y.jsxs("select",{"data-testid":"workspace-select",value:g.some(Z=>Z.path===o)?o:"",onChange:Z=>{Z.target.value&&ce(Z.target.value)},children:[y.jsx("option",{value:"",children:"Indexed repos…"}),g.map(Z=>y.jsxs("option",{value:Z.path,children:[Z.name,Z.indexed?` (${Z.counts.nodes})`:""]},Z.path))]})]}):null,y.jsxs("label",{className:"field path",children:[y.jsx("span",{children:"Repository"}),y.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:Z=>l(Z.target.value),spellCheck:!1})]}),y.jsxs("label",{className:"field ref",children:[y.jsx("span",{children:"Base"}),y.jsx("input",{"data-testid":"base-ref",value:a,onChange:Z=>Q(Z.target.value,d),placeholder:"base",spellCheck:!1})]}),y.jsxs("label",{className:"field ref",children:[y.jsx("span",{children:"Head"}),y.jsx("input",{"data-testid":"head-ref",value:d,onChange:Z=>Q(a,Z.target.value),placeholder:"head",spellCheck:!1})]}),y.jsxs("div",{className:"topbar-actions",children:[y.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!T,onClick:me,children:"Draft config"}),y.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!T,onClick:()=>ve(!0),children:"Index"}),y.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!T,onClick:we,children:"Review"})]})]}),y.jsxs("div",{className:"alerts",children:[k?y.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[y.jsx("span",{children:k}),y.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,P?y.jsxs("div",{className:"banner","data-testid":"status-note",children:[y.jsx("span",{children:P}),y.jsx("button",{type:"button",className:"dismiss",onClick:()=>b(""),"aria-label":"Dismiss",children:"×"})]}):null,((it=p==null?void 0:p.index)!=null&&it.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?y.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,((ft=p==null?void 0:p.index)==null?void 0:ft.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?y.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((lt=p==null?void 0:p.index)==null?void 0:lt.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ht=p==null?void 0:p.workspace)!=null&&ht.dirty_overlaps_review&&t==="review"?y.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),y.jsxs("div",{className:"stage",children:[t==="review"&&y.jsxs("div",{className:"content","data-testid":"review-layout",children:[y.jsx("aside",{className:"brief","data-testid":"brief",children:p?y.jsx(gk,{review:p,findings:At,aiNote:F,busy:!!T,onAskAi:nt,onCopy:Ce,onPost:Me}):y.jsxs("div",{className:"empty","data-testid":"review-empty",children:[y.jsx("h2",{children:"Trace the force of this diff"}),y.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),y.jsxs("ol",{children:[y.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),y.jsxs("li",{children:["Index it. Missing ",y.jsx("code",{children:"loadpath.yml"})," is drafted from ",y.jsx("code",{children:"manage.py"})," and"," ",y.jsx("code",{children:"src/features"}),"."]}),y.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),y.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?y.jsx(Lu,{nodes:p.nodes,edges:p.edges}):null})]}),t==="architecture"&&y.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[y.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?y.jsx(mk,{architecture:m,busy:!!T,onReindex:()=>ve(!1),onReview:we}):y.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."})}),y.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?y.jsx(Lu,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&y.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[y.jsxs("div",{className:"graph-modes",children:[y.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[y.jsx("button",{type:"button","aria-pressed":_==="review","data-testid":"graph-mode-review",className:_==="review"?"active":"",onClick:()=>M("review"),children:"This review"}),y.jsx("button",{type:"button","aria-pressed":_==="architecture","data-testid":"graph-mode-architecture",className:_==="architecture"?"active":"",onClick:()=>M("architecture"),children:"Indexed architecture"})]}),y.jsxs("div",{className:"legend","aria-hidden":"true",children:[y.jsxs("span",{children:[y.jsx("i",{})," cheap"]}),y.jsxs("span",{children:[y.jsx("i",{className:"exp"})," expensive"]}),y.jsxs("span",{children:[y.jsx("i",{className:"crit"})," critical"]}),y.jsxs("span",{children:[y.jsx("i",{className:"dash"})," inferred"]})]})]}),Ge.length?y.jsx(Lu,{nodes:Ge,edges:Bt}):y.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&y.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[y.jsxs("div",{className:"pr-toolbar",children:[y.jsxs("label",{className:"field provider",children:[y.jsx("span",{children:"Provider"}),y.jsxs("select",{"data-testid":"pr-provider",value:ee,onChange:Z=>se(Z.target.value,ne,C),children:[y.jsx("option",{value:"github",children:"GitHub"}),y.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),y.jsxs("label",{className:"field",children:[y.jsx("span",{children:"Repository"}),y.jsx("input",{"data-testid":"pr-repo",placeholder:"owner/repo",value:ne,onChange:Z=>se(ee,Z.target.value,C),spellCheck:!1})]}),y.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!T,onClick:Pe,children:"List PRs"})]}),X.length===0?y.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[y.jsx("h2",{children:"No pull requests loaded"}),y.jsx("p",{children:"Enter an owner/repo, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):X.map(Z=>y.jsxs("article",{className:"pr","data-testid":`pr-${Z.number}`,children:[y.jsxs("h3",{children:["#",Z.number," ",Z.title]}),y.jsxs("div",{className:"pr-meta muted",children:[y.jsx("span",{className:`chip ${Z.draft?"":"open"}`,children:Z.draft?"draft":Z.state}),y.jsx("span",{children:Z.author}),y.jsxs("span",{children:[Z.source_branch," → ",Z.target_branch]})]}),y.jsxs("div",{className:"pr-actions",children:[y.jsxs("a",{href:Z.url,target:"_blank",rel:"noreferrer",children:["Open on ",Z.provider]}),y.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${Z.number}`,onClick:()=>{Q(Z.base_sha||Z.target_branch,Z.head_sha||Z.source_branch),se(Z.provider,Z.repo,String(Z.number)),r("review")},children:"Review this range"})]})]},`${Z.provider}-${Z.number}`))]}),t==="settings"&&O&&y.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Re,children:[y.jsxs("div",{children:[y.jsx("h1",{children:"Settings"}),y.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),y.jsxs("section",{className:"settings-card",children:[y.jsx("h2",{children:"Appearance"}),y.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),y.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:hl.map(Z=>y.jsxs("button",{type:"button",className:A===Z.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${Z.id}`,onClick:()=>re(Z.id),children:[y.jsx("div",{className:"name",children:Z.label}),y.jsx("div",{className:"group",children:Z.group})]},Z.id))})]}),y.jsxs("section",{className:"settings-card",children:[y.jsx("h2",{children:"Source control"}),y.jsx("label",{htmlFor:"github_token",children:"GitHub token"}),y.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),y.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token"}),y.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),y.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),y.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String($.bitbucket_username||"")})]}),y.jsxs("section",{className:"settings-card",children:[y.jsx("h2",{children:"Residual AI"}),y.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),y.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((hn=$.ai)==null?void 0:hn.provider)||"none"),children:[y.jsx("option",{value:"none",children:"none (graph only)"}),y.jsx("option",{value:"anthropic",children:"Anthropic"}),y.jsx("option",{value:"openai",children:"OpenAI"}),y.jsx("option",{value:"grok",children:"Grok / xAI"}),y.jsx("option",{value:"deepseek",children:"DeepSeek"}),y.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),y.jsx("option",{value:"ollama",children:"Ollama local"})]}),y.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),y.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),y.jsx("label",{htmlFor:"ai_model",children:"Model"}),y.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String((($t=$.ai)==null?void 0:$t.model)||"")}),y.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),y.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((rn=$.ai)==null?void 0:rn.base_url)||"")}),y.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]})]})}function gk({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var p,v,m,x,g,S,_,M;const h=[...new Set(t.confidence.reasons||[])];return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[y.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),h.length?y.jsx("ul",{className:"reasons",children:h.map(k=>y.jsx("li",{children:k},k))}):null,t.low_risk?y.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(k=>y.jsx("span",{className:"chip",children:V0(k)},k))]}),y.jsxs("div",{className:"metrics",children:[y.jsxs("div",{className:"metric",children:[y.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),y.jsx("div",{className:"l",children:"Sinks tested"})]}),y.jsxs("div",{className:"metric",children:[y.jsx("div",{className:"n",children:r.length}),y.jsx("div",{className:"l",children:"Findings"})]}),y.jsxs("div",{className:"metric",children:[y.jsx("div",{className:"n",children:t.residuals.length}),y.jsx("div",{className:"l",children:"Residuals"})]})]}),y.jsx("pre",{className:"headline",children:t.headline}),t.index?y.jsxs("details",{className:"section",open:!0,children:[y.jsxs("summary",{children:["Index ",y.jsx("span",{className:"count",children:t.index.counts.nodes})]}),y.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(p=t.workspace)!=null&&p.three_dot?" · three-dot range":""]})]}):null,y.jsxs("details",{className:"section",open:!0,children:[y.jsxs("summary",{children:["Read this ",y.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((k,E)=>y.jsxs("div",{className:"read-item",children:[y.jsxs("span",{className:"file",children:[E+1,". ",k.path]}),y.jsx("div",{className:"why",children:k.why})]},k.path))]}),y.jsxs("details",{className:"section",children:[y.jsxs("summary",{children:["Clusters ",y.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(k=>y.jsxs("div",{className:"muted",children:[y.jsx("strong",{children:k.title})," — ",k.files.join(", ")]},k.id))]}),y.jsxs("details",{className:"section",open:!0,children:[y.jsxs("summary",{children:["Architecture ",y.jsx("span",{className:"count",children:r.length})]}),r.length===0?y.jsx("div",{className:"muted",children:t.architecture_note}):r.map(k=>y.jsxs("div",{className:"finding",children:[y.jsx("span",{className:`chip ${k.severity}`,children:k.severity}),k.message]},k.rule+k.message))]}),y.jsx(Zg,{cards:t.deepening}),y.jsxs("details",{className:"section",open:!0,children:[y.jsxs("summary",{children:["Residual ",y.jsx("span",{className:"count",children:t.residuals.length})]}),y.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(k=>y.jsx("div",{className:"residual muted",children:k},k))]}),(m=(v=t.evolution)==null?void 0:v.notes)!=null&&m.length||(g=(x=t.evolution)==null?void 0:x.hotspots)!=null&&g.some(k=>k.commits)?y.jsxs("details",{className:"section",children:[y.jsx("summary",{children:"Churn & coupling"}),(((S=t.evolution)==null?void 0:S.notes)||[]).map(k=>y.jsx("div",{className:"muted",children:k},k)),(((_=t.evolution)==null?void 0:_.hotspots)||[]).filter(k=>k.commits).slice(0,6).map(k=>y.jsxs("div",{className:"muted",children:[y.jsx("span",{className:"file",children:k.path})," — ",k.commits," commits, bus factor ",k.bus_factor]},k.path))]}):null,y.jsxs("div",{className:"btn-row",children:[y.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),y.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),y.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?y.jsx("pre",{className:"headline",children:o}):null,y.jsx("div",{className:"kicker",children:"Reviewers"}),y.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(M=t.knowledge_owners)!=null&&M.length?y.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function mk({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"merge-box high",children:[y.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),y.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${U0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),y.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?y.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),y.jsxs("details",{className:"section",open:!0,children:[y.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>y.jsxs("div",{className:"muted",children:[y.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),y.jsxs("details",{className:"section",children:[y.jsxs("summary",{children:["Rules ",y.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>y.jsx("div",{className:"muted",children:u},u))]}),y.jsxs("details",{className:"section",open:!0,children:[y.jsxs("summary",{children:["Findings ",y.jsx("span",{className:"count",children:a.length})]}),a.length===0?y.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>y.jsxs("div",{className:"finding",children:[y.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),y.jsx(Zg,{cards:t.deepening}),y.jsxs("details",{className:"section",open:!0,children:[y.jsx("summary",{children:"Types"}),y.jsx("table",{className:"type-table",children:y.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>y.jsxs("tr",{children:[y.jsx("td",{children:Ku(u)}),y.jsx("td",{children:d})]},u))})})]}),y.jsxs("div",{className:"btn-row",children:[y.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),y.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function Zg({cards:t}){const r=t||[];return r.length?y.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[y.jsxs("summary",{children:["Depth ",y.jsx("span",{className:"count",children:r.length})]}),y.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>y.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[y.jsx("span",{className:`chip ${o.strength}`,children:B0(o.strength)}),o.top?y.jsx("span",{className:"chip",children:"top"}):null,y.jsx("strong",{children:o.title}),y.jsx("div",{className:"why",children:o.message}),o.deletion_test?y.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?y.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}qg(Gg());b0.createRoot(document.getElementById("root")).render(y.jsx(W.StrictMode,{children:y.jsx(pk,{})})); diff --git a/src/loadpath/static/assets/index-DVQVwbDy.js b/src/loadpath/static/assets/index-DVQVwbDy.js new file mode 100644 index 0000000..fe55e45 --- /dev/null +++ b/src/loadpath/static/assets/index-DVQVwbDy.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))l(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function l(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function up(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mu={exports:{}},eo={},yu={exports:{}},je={};/** + * @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 Of;function b0(){if(Of)return je;Of=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),x=Symbol.iterator;function y(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,C={};function k(M,z,re){this.props=M,this.context=z,this.refs=C,this.updater=re||S}k.prototype.isReactComponent={},k.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")},k.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=k.prototype;function T(M,z,re){this.props=M,this.context=z,this.refs=C,this.updater=re||S}var N=T.prototype=new E;N.constructor=T,_(N,k.prototype),N.isPureReactComponent=!0;var P=Array.isArray,O=Object.prototype.hasOwnProperty,D={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function F(M,z,re){var ne,ae={},de=null,ce=null;if(z!=null)for(ne in z.ref!==void 0&&(ce=z.ref),z.key!==void 0&&(de=""+z.key),z)O.call(z,ne)&&!H.hasOwnProperty(ne)&&(ae[ne]=z[ne]);var G=arguments.length-2;if(G===1)ae.children=re;else if(1>>1,z=A[M];if(0>>1;Ma(ae,b))dea(ce,ae)?(A[M]=ce,A[de]=b,M=de):(A[M]=ae,A[ne]=b,M=ne);else if(dea(ce,b))A[M]=ce,A[de]=b,M=de;else break e}}return L}function a(A,L){var b=A.sortIndex-L.sortIndex;return b!==0?b:A.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,f=d.now();t.unstable_now=function(){return d.now()-f}}var p=[],v=[],m=1,x=null,y=3,S=!1,_=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(A){for(var L=o(v);L!==null;){if(L.callback===null)l(v);else if(L.startTime<=A)l(v),L.sortIndex=L.expirationTime,r(p,L);else break;L=o(v)}}function P(A){if(C=!1,N(A),!_)if(o(p)!==null)_=!0,V(O);else{var L=o(v);L!==null&&B(P,L.startTime-A)}}function O(A,L){_=!1,C&&(C=!1,E(F),F=-1),S=!0;var b=y;try{for(N(L),x=o(p);x!==null&&(!(x.expirationTime>L)||A&&!q());){var M=x.callback;if(typeof M=="function"){x.callback=null,y=x.priorityLevel;var z=M(x.expirationTime<=L);L=t.unstable_now(),typeof z=="function"?x.callback=z:x===o(p)&&l(p),N(L)}else l(p);x=o(p)}if(x!==null)var re=!0;else{var ne=o(v);ne!==null&&B(P,ne.startTime-L),re=!1}return re}finally{x=null,y=b,S=!1}}var D=!1,H=null,F=-1,X=5,ee=-1;function q(){return!(t.unstable_now()-eeA||125M?(A.sortIndex=b,r(v,A),o(p)===null&&A===o(v)&&(C?(E(F),F=-1):C=!0,B(P,b-M))):(A.sortIndex=z,r(p,A),_||S||(_=!0,V(O))),A},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(A){var L=y;return function(){var b=y;y=L;try{return A.apply(this,arguments)}finally{y=b}}}})(wu)),wu}var Wf;function B0(){return Wf||(Wf=1,xu.exports=V0()),xu.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 Uf;function W0(){if(Uf)return _t;Uf=1;var t=vo(),r=B0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},x={};function y(e){return p.call(x,e)?!0:p.call(m,e)?!1:v.test(e)?x[e]=!0:(m[e]=!0,!1)}function S(e,n,i,s){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return s?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function _(e,n,i,s){if(n===null||typeof n>"u"||S(e,n,i,s))return!0;if(s)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function C(e,n,i,s,c,h,w){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=s,this.attributeNamespace=c,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=h,this.removeEmptyString=w}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){k[e]=new C(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];k[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){k[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){k[e]=new C(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){k[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){k[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){k[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){k[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){k[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function T(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,T);k[n]=new C(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,T);k[n]=new C(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,T);k[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){k[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),k.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){k[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,s){var c=k.hasOwnProperty(n)?k[n]:null;(c!==null?c.type!==0:s||!(2I||c[w]!==h[I]){var R=` +`+c[w].replace(" at new "," at ");return e.displayName&&R.includes("")&&(R=R.replace("",e.displayName)),R}while(1<=w&&0<=I);break}}}finally{re=!1,Error.prepareStackTrace=i}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=ne(e.type,!1),e;case 11:return e=ne(e.type.render,!1),e;case 1:return e=ne(e.type,!0),e;default:return""}}function de(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 H:return"Fragment";case D:return"Portal";case X:return"Profiler";case F:return"StrictMode";case J:return"Suspense";case j:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case q:return(e.displayName||"Context")+".Consumer";case ee:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:de(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return de(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 de(n);case 8:return n===F?"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 G(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 he(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),s=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var c=i.get,h=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return c.call(this)},set:function(w){s=""+w,h.call(this,w)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return s},setValue:function(w){s=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function we(e){e._valueTracker||(e._valueTracker=he(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),s="";return e&&(s=se(e)?e.checked?"true":"false":e.value),e=s,e!==i?(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 i=n.checked;return b({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;i=G(n.value!=null?n.value:i),e._wrapperState={initialChecked:s,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Pe(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Re(e,n){Pe(e,n);var i=G(n.value),s=n.type;if(i!=null)s==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?rt(e,n.type,i):n.hasOwnProperty("defaultValue")&&rt(e,n.type,G(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function nt(e,n,i){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,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function rt(e,n,i){(n!=="number"||me(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function Ke(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=ht.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Dt(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var rn={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},Z=["Webkit","ms","Moz","O"];Object.keys(rn).forEach(function(e){Z.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),rn[n]=rn[e]})});function Ee(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||rn.hasOwnProperty(e)&&rn[e]?(""+n).trim():n+"px"}function De(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=Ee(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Cn=b({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function mt(e,n){if(n){if(Cn[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function fi(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 hi=null;function pi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gi=null,jn=null,Mn=null;function Co(e){if(e=Oi(e)){if(typeof gi!="function")throw Error(o(280));var n=e.stateNode;n&&(n=ns(n),gi(e.stateNode,e.type,n))}}function jo(e){jn?Mn?Mn.push(e):Mn=[e]:jn=e}function Mo(){if(jn){var e=jn,n=Mn;if(Mn=jn=null,Co(e),n)for(e=0;e>>=0,e===0?32:31-(Al(e)/Dl|0)|0}var Ir=64,Tr=4194304;function nr(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 pn(e,n){var i=e.pendingLanes;if(i===0)return 0;var s=0,c=e.suspendedLanes,h=e.pingedLanes,w=i&268435455;if(w!==0){var I=w&~c;I!==0?s=nr(I):(h&=w,h!==0&&(s=nr(h)))}else w=i&~c,w!==0?s=nr(w):h!==0&&(s=nr(h));if(s===0)return 0;if(n!==0&&n!==s&&(n&c)===0&&(c=s&-s,h=n&-n,c>=h||c===16&&(h&4194240)!==0))return n;if((s&4)!==0&&(s|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=s;0i;i++)n.push(e);return n}function ir(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Ct(n),e[n]=i}function Ol(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Ii),Tc=" ",zc=!1;function Rc(e,n){switch(e){case"keyup":return Rm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ar=!1;function Am(e,n){switch(e){case"compositionend":return Lc(n);case"keypress":return n.which!==32?null:(zc=!0,Tc);case"textInput":return e=n.data,e===Tc&&zc?null:e;default:return null}}function Dm(e,n){if(Ar)return e==="compositionend"||!Kl&&Rc(e,n)?(e=Nc(),Uo=Wl=Rn=null,Ar=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=s}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Hc(i)}}function Bc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Bc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Wc(){for(var e=window,n=me();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=me(e.document)}return n}function Jl(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 Um(e){var n=Wc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Bc(i.ownerDocument.documentElement,i)){if(s!==null&&Jl(i)){if(n=s.start,e=s.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var c=i.textContent.length,h=Math.min(s.start,c);s=s.end===void 0?h:Math.min(s.end,c),!e.extend&&h>s&&(c=s,s=h,h=c),c=Vc(i,h);var w=Vc(i,s);c&&w&&(e.rangeCount!==1||e.anchorNode!==c.node||e.anchorOffset!==c.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(n=n.createRange(),n.setStart(c.node,c.offset),e.removeAllRanges(),h>s?(e.addRange(n),e.extend(w.node,w.offset)):(n.setEnd(w.node,w.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Dr=null,ea=null,Li=null,ta=!1;function Uc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ta||Dr==null||Dr!==me(s)||(s=Dr,"selectionStart"in s&&Jl(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}),Li&&Ri(Li,s)||(Li=s,s=Jo(ea,"onSelect"),0Hr||(e.current=ha[Hr],ha[Hr]=null,Hr--)}function Ae(e,n){Hr++,ha[Hr]=e.current,e.current=n}var $n={},at=Dn($n),yt=Dn(!1),sr=$n;function Vr(e,n){var i=e.type.contextTypes;if(!i)return $n;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===n)return s.__reactInternalMemoizedMaskedChildContext;var c={},h;for(h in i)c[h]=n[h];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=c),c}function vt(e){return e=e.childContextTypes,e!=null}function rs(){be(yt),be(at)}function sd(e,n,i){if(at.current!==$n)throw Error(o(168));Ae(at,n),Ae(yt,i)}function ld(e,n,i){var s=e.stateNode;if(n=n.childContextTypes,typeof s.getChildContext!="function")return i;s=s.getChildContext();for(var c in s)if(!(c in n))throw Error(o(108,ce(e)||"Unknown",c));return b({},i,s)}function is(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$n,sr=at.current,Ae(at,e),Ae(yt,yt.current),!0}function ad(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=ld(e,n,sr),s.__reactInternalMemoizedMergedChildContext=e,be(yt),be(at),Ae(at,e)):be(yt),Ae(yt,i)}var mn=null,os=!1,pa=!1;function ud(e){mn===null?mn=[e]:mn.push(e)}function r0(e){os=!0,ud(e)}function bn(){if(!pa&&mn!==null){pa=!0;var e=0,n=Le;try{var i=mn;for(Le=1;e>=w,c-=w,yn=1<<32-Ct(n)+c|i<Ne?(tt=ke,ke=null):tt=ke.sibling;var ze=ie(Y,ke,Q[Ne],ue);if(ze===null){ke===null&&(ke=tt);break}e&&ke&&ze.alternate===null&&n(Y,ke),$=h(ze,$,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze,ke=tt}if(Ne===Q.length)return i(Y,ke),Fe&&ar(Y,Ne),xe;if(ke===null){for(;NeNe?(tt=ke,ke=null):tt=ke.sibling;var Xn=ie(Y,ke,ze.value,ue);if(Xn===null){ke===null&&(ke=tt);break}e&&ke&&Xn.alternate===null&&n(Y,ke),$=h(Xn,$,Ne),_e===null?xe=Xn:_e.sibling=Xn,_e=Xn,ke=tt}if(ze.done)return i(Y,ke),Fe&&ar(Y,Ne),xe;if(ke===null){for(;!ze.done;Ne++,ze=Q.next())ze=le(Y,ze.value,ue),ze!==null&&($=h(ze,$,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze);return Fe&&ar(Y,Ne),xe}for(ke=s(Y,ke);!ze.done;Ne++,ze=Q.next())ze=fe(ke,Y,Ne,ze.value,ue),ze!==null&&(e&&ze.alternate!==null&&ke.delete(ze.key===null?Ne:ze.key),$=h(ze,$,Ne),_e===null?xe=ze:_e.sibling=ze,_e=ze);return e&&ke.forEach(function($0){return n(Y,$0)}),Fe&&ar(Y,Ne),xe}function Ye(Y,$,Q,ue){if(typeof Q=="object"&&Q!==null&&Q.type===H&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case O:e:{for(var xe=Q.key,_e=$;_e!==null;){if(_e.key===xe){if(xe=Q.type,xe===H){if(_e.tag===7){i(Y,_e.sibling),$=c(_e,Q.props.children),$.return=Y,Y=$;break e}}else if(_e.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===V&&gd(xe)===_e.type){i(Y,_e.sibling),$=c(_e,Q.props),$.ref=Fi(Y,_e,Q),$.return=Y,Y=$;break e}i(Y,_e);break}else n(Y,_e);_e=_e.sibling}Q.type===H?($=mr(Q.props.children,Y.mode,ue,Q.key),$.return=Y,Y=$):(ue=Rs(Q.type,Q.key,Q.props,null,Y.mode,ue),ue.ref=Fi(Y,$,Q),ue.return=Y,Y=ue)}return w(Y);case D:e:{for(_e=Q.key;$!==null;){if($.key===_e)if($.tag===4&&$.stateNode.containerInfo===Q.containerInfo&&$.stateNode.implementation===Q.implementation){i(Y,$.sibling),$=c($,Q.children||[]),$.return=Y,Y=$;break e}else{i(Y,$);break}else n(Y,$);$=$.sibling}$=du(Q,Y.mode,ue),$.return=Y,Y=$}return w(Y);case V:return _e=Q._init,Ye(Y,$,_e(Q._payload),ue)}if(Xe(Q))return ge(Y,$,Q,ue);if(L(Q))return ye(Y,$,Q,ue);us(Y,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,$!==null&&$.tag===6?(i(Y,$.sibling),$=c($,Q),$.return=Y,Y=$):(i(Y,$),$=cu(Q,Y.mode,ue),$.return=Y,Y=$),w(Y)):i(Y,$)}return Ye}var Yr=md(!0),yd=md(!1),cs=Dn(null),ds=null,Xr=null,wa=null;function Sa(){wa=Xr=ds=null}function _a(e){var n=cs.current;be(cs),e._currentValue=n}function ka(e,n,i){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===i)break;e=e.return}}function Qr(e,n){ds=e,wa=Xr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(xt=!0),e.firstContext=null)}function Ot(e){var n=e._currentValue;if(wa!==e)if(e={context:e,memoizedValue:n,next:null},Xr===null){if(ds===null)throw Error(o(308));Xr=e,ds.dependencies={lanes:0,firstContext:e}}else Xr=Xr.next=e;return n}var ur=null;function Ea(e){ur===null?ur=[e]:ur.push(e)}function vd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ea(n)):(i.next=c.next,c.next=i),n.interleaved=i,xn(e,s)}function xn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var On=!1;function Na(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xd(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 wn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Fn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Ie&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,xn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ea(s)):(n.next=c.next,c.next=n),s.interleaved=n,xn(e,i)}function fs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,zr(e,i)}}function wd(e,n){var i=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,i===s)){var c=null,h=null;if(i=i.firstBaseUpdate,i!==null){do{var w={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};h===null?c=h=w:h=h.next=w,i=i.next}while(i!==null);h===null?c=h=n:h=h.next=n}else c=h=n;i={baseState:s.baseState,firstBaseUpdate:c,lastBaseUpdate:h,shared:s.shared,effects:s.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function hs(e,n,i,s){var c=e.updateQueue;On=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,I=c.shared.pending;if(I!==null){c.shared.pending=null;var R=I,K=R.next;R.next=null,w===null?h=K:w.next=K,w=R;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,I=oe.lastBaseUpdate,I!==w&&(I===null?oe.firstBaseUpdate=K:I.next=K,oe.lastBaseUpdate=R))}if(h!==null){var le=c.baseState;w=0,oe=K=R=null,I=h;do{var ie=I.lane,fe=I.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:fe,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var ge=e,ye=I;switch(ie=n,fe=i,ye.tag){case 1:if(ge=ye.payload,typeof ge=="function"){le=ge.call(fe,le,ie);break e}le=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=ye.payload,ie=typeof ge=="function"?ge.call(fe,le,ie):ge,ie==null)break e;le=b({},le,ie);break e;case 2:On=!0}}I.callback!==null&&I.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[I]:ie.push(I))}else fe={eventTime:fe,lane:ie,tag:I.tag,payload:I.payload,callback:I.callback,next:null},oe===null?(K=oe=fe,R=le):oe=oe.next=fe,w|=ie;if(I=I.next,I===null){if(I=c.shared.pending,I===null)break;ie=I,I=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(R=le),c.baseState=R,c.firstBaseUpdate=K,c.lastBaseUpdate=oe,n=c.shared.interleaved,n!==null){c=n;do w|=c.lane,c=c.next;while(c!==n)}else h===null&&(c.shared.lanes=0);fr|=w,e.lanes=w,e.memoizedState=le}}function Sd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Ia.transition;Ia.transition={};try{e(!1),n()}finally{Le=i,Ia.transition=s}}function Fd(){return Ft().memoizedState}function l0(e,n,i){var s=Wn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Hd(e))Vd(n,i);else if(i=vd(e,n,i,s),i!==null){var c=gt();Gt(i,e,s,c),Bd(i,n,s)}}function a0(e,n,i){var s=Wn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Hd(e))Vd(n,c);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=n.lastRenderedReducer,h!==null))try{var w=n.lastRenderedState,I=h(w,i);if(c.hasEagerState=!0,c.eagerState=I,Wt(I,w)){var R=n.interleaved;R===null?(c.next=c,Ea(n)):(c.next=R.next,R.next=c),n.interleaved=c;return}}catch{}finally{}i=vd(e,n,c,s),i!==null&&(c=gt(),Gt(i,e,s,c),Bd(i,n,s))}}function Hd(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function Vd(e,n){Wi=ms=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Bd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,zr(e,i)}}var xs={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},u0={readContext:Ot,useCallback:function(e,n){return an().memoizedState=[e,n===void 0?null:n],e},useContext:Ot,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ys(4194308,4,Ad.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return ys(4,2,e,n)},useMemo:function(e,n){var i=an();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=an();return n=i!==void 0?i(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=l0.bind(null,Be,e),[s.memoizedState,e]},useRef:function(e){var n=an();return e={current:e},n.memoizedState=e},useState:Id,useDebugValue:$a,useDeferredValue:function(e){return an().memoizedState=e},useTransition:function(){var e=Id(!1),n=e[0];return e=s0.bind(null,e[1]),an().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Be,c=an();if(Fe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),et===null)throw Error(o(349));(dr&30)!==0||Nd(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(jd.bind(null,s,h,e),[e]),s.flags|=2048,Xi(9,Cd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=an(),n=et.identifierPrefix;if(Fe){var i=vn,s=yn;i=(s&~(1<<32-Ct(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ui++,0<\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=w.createElement(i,{is:s.is}):(e=w.createElement(i),i==="select"&&(w=e,s.multiple?w.multiple=!0:s.size&&(w.size=s.size))):e=w.createElementNS(e,i),e[sn]=n,e[bi]=s,cf(e,n,!1,!1),n.stateNode=e;e:{switch(w=fi(i,s),i){case"dialog":$e("cancel",e),$e("close",e),c=s;break;case"iframe":case"object":case"embed":$e("load",e),c=s;break;case"video":case"audio":for(c=0;cJr&&(n.flags|=128,s=!0,Qi(h,!1),n.lanes=4194304)}else{if(!s)if(e=ps(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Qi(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Fe)return ct(n),null}else 2*He()-h.renderingStartTime>Jr&&i!==1073741824&&(n.flags|=128,s=!0,Qi(h,!1),n.lanes=4194304);h.isBackwards?(w.sibling=n.child,n.child=w):(i=h.last,i!==null?i.sibling=w:n.child=w,h.last=w)}return h.tail!==null?(n=h.tail,h.rendering=n,h.tail=n.sibling,h.renderingStartTime=He(),n.sibling=null,i=Ve.current,Ae(Ve,s?i&1|2:i&1),n):(ct(n),null);case 22:case 23:return lu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(It&1073741824)!==0&&(ct(n),n.subtreeFlags&6&&(n.flags|=8192)):ct(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function y0(e,n){switch(ma(n),n.tag){case 1:return vt(n.type)&&rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Gr(),be(yt),be(at),Pa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return ja(n),null;case 13:if(be(Ve),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Ur()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return be(Ve),null;case 4:return Gr(),null;case 10:return _a(n.type._context),null;case 22:case 23:return lu(),null;case 24:return null;default:return null}}var ks=!1,dt=!1,v0=typeof WeakSet=="function"?WeakSet:Set,pe=null;function qr(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Ue(e,n,s)}else i.current=null}function Ga(e,n,i){try{i()}catch(s){Ue(e,n,s)}}var hf=!1;function x0(e,n){if(la=Bo,e=Wc(),Jl(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var s=i.getSelection&&i.getSelection();if(s&&s.rangeCount!==0){i=s.anchorNode;var c=s.anchorOffset,h=s.focusNode;s=s.focusOffset;try{i.nodeType,h.nodeType}catch{i=null;break e}var w=0,I=-1,R=-1,K=0,oe=0,le=e,ie=null;t:for(;;){for(var fe;le!==i||c!==0&&le.nodeType!==3||(I=w+c),le!==h||s!==0&&le.nodeType!==3||(R=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(fe=le.firstChild)!==null;)ie=le,le=fe;for(;;){if(le===e)break t;if(ie===i&&++K===c&&(I=w),ie===h&&++oe===s&&(R=w),(fe=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=fe}i=I===-1||R===-1?null:{start:I,end:R}}else i=null}i=i||{start:0,end:0}}else i=null;for(aa={focusedElem:e,selectionRange:i},Bo=!1,pe=n;pe!==null;)if(n=pe,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,pe=e;else for(;pe!==null;){n=pe;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,Ye=ge.memoizedState,Y=n.stateNode,$=Y.getSnapshotBeforeUpdate(n.elementType===n.type?ye:Yt(n.type,ye),Ye);Y.__reactInternalSnapshotBeforeUpdate=$}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ue){Ue(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,pe=e;break}pe=n.return}return ge=hf,hf=!1,ge}function Gi(e,n,i){var s=n.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var c=s=s.next;do{if((c.tag&e)===e){var h=c.destroy;c.destroy=void 0,h!==void 0&&Ga(n,i,h)}c=c.next}while(c!==s)}}function Es(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function Ka(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function pf(e){var n=e.alternate;n!==null&&(e.alternate=null,pf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[sn],delete n[bi],delete n[fa],delete n[t0],delete n[n0])),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 gf(e){return e.tag===5||e.tag===3||e.tag===4}function mf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gf(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 qa(e,n,i){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=ts));else if(s!==4&&(e=e.child,e!==null))for(qa(e,n,i),e=e.sibling;e!==null;)qa(e,n,i),e=e.sibling}function Za(e,n,i){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(Za(e,n,i),e=e.sibling;e!==null;)Za(e,n,i),e=e.sibling}var ot=null,Xt=!1;function Hn(e,n,i){for(i=i.child;i!==null;)yf(e,n,i),i=i.sibling}function yf(e,n,i){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(Pr,i)}catch{}switch(i.tag){case 5:dt||qr(i,n);case 6:var s=ot,c=Xt;ot=null,Hn(e,n,i),ot=s,Xt=c,ot!==null&&(Xt?(e=ot,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):ot.removeChild(i.stateNode));break;case 18:ot!==null&&(Xt?(e=ot,i=i.stateNode,e.nodeType===8?da(e.parentNode,i):e.nodeType===1&&da(e,i),ji(e)):da(ot,i.stateNode));break;case 4:s=ot,c=Xt,ot=i.stateNode.containerInfo,Xt=!0,Hn(e,n,i),ot=s,Xt=c;break;case 0:case 11:case 14:case 15:if(!dt&&(s=i.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){c=s=s.next;do{var h=c,w=h.destroy;h=h.tag,w!==void 0&&((h&2)!==0||(h&4)!==0)&&Ga(i,n,w),c=c.next}while(c!==s)}Hn(e,n,i);break;case 1:if(!dt&&(qr(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(I){Ue(i,n,I)}Hn(e,n,i);break;case 21:Hn(e,n,i);break;case 22:i.mode&1?(dt=(s=dt)||i.memoizedState!==null,Hn(e,n,i),dt=s):Hn(e,n,i);break;default:Hn(e,n,i)}}function vf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new v0),n.forEach(function(s){var c=M0.bind(null,e,s);i.has(s)||(i.add(s),s.then(c,c))})}}function Qt(e,n){var i=n.deletions;if(i!==null)for(var s=0;sc&&(c=w),s&=~h}if(s=c,s=He()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*S0(s/1960))-s,10e?16:e,Bn===null)var s=!1;else{if(e=Bn,Bn=null,Ps=0,(Ie&6)!==0)throw Error(o(331));var c=Ie;for(Ie|=4,pe=e.current;pe!==null;){var h=pe,w=h.child;if((pe.flags&16)!==0){var I=h.deletions;if(I!==null){for(var R=0;RHe()-tu?pr(e,0):eu|=i),St(e,n)}function Tf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Tr,Tr<<=1,(Tr&130023424)===0&&(Tr=4194304)));var i=gt();e=xn(e,n),e!==null&&(ir(e,n,i),St(e,i))}function j0(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Tf(e,i)}function M0(e,n){var i=0;switch(e.tag){case 13:var s=e.stateNode,c=e.memoizedState;c!==null&&(i=c.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(o(314))}s!==null&&s.delete(n),Tf(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||yt.current)xt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return xt=!1,g0(e,n,i);xt=(e.flags&131072)!==0}else xt=!1,Fe&&(n.flags&1048576)!==0&&cd(n,ls,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;_s(e,n),e=n.pendingProps;var c=Vr(n,at.current);Qr(n,i),c=za(null,n,s,e,c,i);var h=Ra();return n.flags|=1,typeof c=="object"&&c!==null&&typeof c.render=="function"&&c.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,vt(s)?(h=!0,is(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Na(n),c.updater=ws,n.stateNode=c,c._reactInternals=n,Oa(n,s,e,i),n=Ba(null,n,s,!0,h,i)):(n.tag=0,Fe&&h&&ga(n),pt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(_s(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=I0(s),e=Yt(s,e),c){case 0:n=Va(null,n,s,e,i);break e;case 1:n=rf(null,n,s,e,i);break e;case 11:n=Zd(null,n,s,e,i);break e;case 14:n=Jd(null,n,s,Yt(s.type,e),i);break e}throw Error(o(306,s,""))}return n;case 0:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),Va(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),rf(e,n,s,c,i);case 3:e:{if(of(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,xd(e,n),hs(n,s,null,i);var w=n.memoizedState;if(s=w.element,h.isDehydrated)if(h={element:s,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},n.updateQueue.baseState=h,n.memoizedState=h,n.flags&256){c=Kr(Error(o(423)),n),n=sf(e,n,s,i,c);break e}else if(s!==c){c=Kr(Error(o(424)),n),n=sf(e,n,s,i,c);break e}else for(Pt=An(n.stateNode.containerInfo.firstChild),Mt=n,Fe=!0,Ut=null,i=yd(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Ur(),s===c){n=Sn(e,n,i);break e}pt(e,n,s,i)}n=n.child}return n;case 5:return _d(n),e===null&&va(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,ua(s,c)?w=null:h!==null&&ua(s,h)&&(n.flags|=32),nf(e,n),pt(e,n,w,i),n.child;case 6:return e===null&&va(n),null;case 13:return lf(e,n,i);case 4:return Ca(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=Yr(n,null,s,i):pt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),Zd(e,n,s,c,i);case 7:return pt(e,n,n.pendingProps,i),n.child;case 8:return pt(e,n,n.pendingProps.children,i),n.child;case 12:return pt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(s=n.type._context,c=n.pendingProps,h=n.memoizedProps,w=c.value,Ae(cs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!yt.current){n=Sn(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var I=h.dependencies;if(I!==null){w=h.child;for(var R=I.firstContext;R!==null;){if(R.context===s){if(h.tag===1){R=wn(-1,i&-i),R.tag=2;var K=h.updateQueue;if(K!==null){K=K.shared;var oe=K.pending;oe===null?R.next=R:(R.next=oe.next,oe.next=R),K.pending=R}}h.lanes|=i,R=h.alternate,R!==null&&(R.lanes|=i),ka(h.return,i,n),I.lanes|=i;break}R=R.next}}else if(h.tag===10)w=h.type===n.type?null:h.child;else if(h.tag===18){if(w=h.return,w===null)throw Error(o(341));w.lanes|=i,I=w.alternate,I!==null&&(I.lanes|=i),ka(w,i,n),w=h.sibling}else w=h.child;if(w!==null)w.return=h;else for(w=h;w!==null;){if(w===n){w=null;break}if(h=w.sibling,h!==null){h.return=w.return,w=h;break}w=w.return}h=w}pt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,Qr(n,i),c=Ot(c),s=s(c),n.flags|=1,pt(e,n,s,i),n.child;case 14:return s=n.type,c=Yt(s,n.pendingProps),c=Yt(s.type,c),Jd(e,n,s,c,i);case 15:return ef(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Yt(s,c),_s(e,n),n.tag=1,vt(s)?(e=!0,is(n)):e=!1,Qr(n,i),Ud(n,s,c),Oa(n,s,c,i),Ba(null,n,s,!0,e,i);case 19:return uf(e,n,i);case 22:return tf(e,n,i)}throw Error(o(156,n.tag))};function Rf(e,n){return Lo(e,n)}function P0(e,n,i,s){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vt(e,n,i,s){return new P0(e,n,i,s)}function uu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function I0(e){if(typeof e=="function")return uu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===W)return 14}return 2}function Yn(e,n){var i=e.alternate;return i===null?(i=Vt(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function Rs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")uu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return mr(i.children,c,h,n);case F:w=8,c|=8;break;case X:return e=Vt(12,i,n,c|2),e.elementType=X,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case j:return e=Vt(19,i,n,c),e.elementType=j,e.lanes=h,e;case B:return Ls(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ee:w=10;break e;case q:w=9;break e;case te:w=11;break e;case W:w=14;break e;case V:w=16,s=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=Vt(w,i,n,c),n.elementType=e,n.type=s,n.lanes=h,n}function mr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ls(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=B,e.lanes=i,e.stateNode={isHidden:!1},e}function cu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function du(e,n,i){return n=Vt(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function T0(e,n,i,s,c){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=rr(0),this.expirationTimes=rr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function fu(e,n,i,s,c,h,w,I,R){return e=new T0(e,n,i,I,R),n===1?(n=1,h===!0&&(n|=8)):n=0,h=Vt(3,null,null,n),e.current=h,h.stateNode=e,h.memoizedState={element:s,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Na(h),e}function z0(e,n,i){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(),vu.exports=W0(),vu.exports}var Xf;function U0(){if(Xf)return Hs;Xf=1;var t=cp();return Hs.createRoot=t.createRoot,Hs.hydrateRoot=t.hydrateRoot,Hs}var Y0=U0();function X0(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(d=>typeof d=="string"?d:d&&typeof d=="object"&&"msg"in d?String(d.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Tt(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const l=await o.text();throw new Error(X0(l,o.statusText||"Request failed"))}return o.json()}const Q0=["github_token","bitbucket_token","ai_api_key","ai_model","ai_base_url"],kt={health:()=>Tt("/api/health"),settings:()=>Tt("/api/settings"),saveSettings:t=>{const r={...t};for(const o of Q0)r[o]===""&&delete r[o];return Tt("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Tt("/api/repos"),index:(t,r=!0)=>Tt("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Tt(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Tt(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Tt("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:l,incremental:!0,three_dot:!0})}),init:(t,r=!1)=>Tt("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Tt("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Tt(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Tt("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),residual:t=>Tt("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function G0(t){return t.replaceAll("_"," ")}function K0(t){return t.replaceAll("_"," ")}function Gu(t){return t.split(".").pop()||t}function q0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function Vs(t){return t.replace(/([/\\._:@-])/g,"$1​")}function xo({className:t,children:r}){return g.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function Z0({className:t}){return g.jsxs(xo,{className:t,children:[g.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),g.jsx("path",{d:"M9.5 3.5V7H13"}),g.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function J0({className:t}){return g.jsxs(xo,{className:t,children:[g.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),g.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),g.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),g.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function ey({className:t}){return g.jsxs(xo,{className:t,children:[g.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),g.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),g.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),g.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function ty({className:t}){return g.jsxs(xo,{className:t,children:[g.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),g.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),g.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),g.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function ny({className:t}){return g.jsxs(xo,{className:t,children:[g.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),g.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}const ry="modulepreload",iy=function(t,r){return new URL(t,r).href},Qf={},oy=function(r,o,l){let a=Promise.resolve();if(o&&o.length>0){let d=function(m){return Promise.all(m.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};const f=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=d(o.map(m=>{if(m=iy(m,l),m in Qf)return;Qf[m]=!0;const x=m.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const k=f[C];if(k.href===m&&(!x||k.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${y}`))return;const _=document.createElement("link");if(_.rel=x?"stylesheet":ry,x||(_.as="script"),_.crossOrigin="",_.href=m,v&&_.setAttribute("nonce",v),document.head.appendChild(_),x)return new Promise((C,k)=>{_.addEventListener("load",C),_.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return a.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return r().catch(u)})};function Ge(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function pl(){for(var t=0,r=arguments.length,o={},l;t=0&&(l=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:l}})}Zs.prototype=pl.prototype={constructor:Zs,on:function(t,r){var o=this._,l=ly(t+"",o),a,u=-1,d=l.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),l=0,a,u;l=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),Kf.hasOwnProperty(r)?{space:Kf[r],local:t}:t}function uy(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Au&&r.documentElement.namespaceURI===Au?r.createElement(t):r.createElementNS(o,t)}}function cy(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function dp(t){var r=gl(t);return(r.local?cy:uy)(r)}function dy(){}function Ku(t){return t==null?dy:function(){return this.querySelector(t)}}function fy(t){typeof t!="function"&&(t=Ku(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=T+1);!(O=k[N])&&++N<_;);P._next=O||null}}return d=new Rt(d,l),d._enter=f,d._exit=p,d}function zy(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Ry(){return new Rt(this._exit||this._groups.map(gp),this._parents)}function Ly(t,r,o){var l=this.enter(),a=this,u=this.exit();return typeof t=="function"?(l=t(l),l&&(l=l.selection())):l=l.append(t+""),r!=null&&(a=r(a),a&&(a=a.selection())),o==null?u.remove():o(u),l&&a?l.merge(a).order():a}function Ay(t){for(var r=t.selection?t.selection():t,o=this._groups,l=r._groups,a=o.length,u=l.length,d=Math.min(a,u),f=new Array(a),p=0;p=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function $y(t){t||(t=by);function r(x,y){return x&&y?t(x.__data__,y.__data__):!x-!y}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function Oy(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Fy(){return Array.from(this)}function Hy(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?Zy:typeof r=="function"?ev:Jy)(t,r,o??"")):oi(this.node(),t)}function oi(t,r){return t.style.getPropertyValue(r)||mp(t).getComputedStyle(t,null).getPropertyValue(r)}function nv(t){return function(){delete this[t]}}function rv(t,r){return function(){this[t]=r}}function iv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function ov(t,r){return arguments.length>1?this.each((r==null?nv:typeof r=="function"?iv:rv)(t,r)):this.node()[t]}function yp(t){return t.trim().split(/^|\s+/)}function qu(t){return t.classList||new vp(t)}function vp(t){this._node=t,this._names=yp(t.getAttribute("class")||"")}vp.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 xp(t,r){for(var o=qu(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Rv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Du(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:p,dy:v,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:f,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:m}})}Du.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Bv(t){return!t.ctrlKey&&!t.button}function Wv(){return this.parentNode}function Uv(t,r){return r??{x:t.x,y:t.y}}function Yv(){return navigator.maxTouchPoints||"ontouchstart"in this}function Np(){var t=Bv,r=Wv,o=Uv,l=Yv,a={},u=pl("start","drag","end"),d=0,f,p,v,m,x=0;function y(P){P.on("mousedown.drag",S).filter(l).on("touchstart.drag",k).on("touchmove.drag",E,Vv).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function S(P,O){if(!(m||!t.call(this,P,O))){var D=N(this,r.call(this,P,O),P,O,"mouse");D&&(zt(P.view).on("mousemove.drag",_,lo).on("mouseup.drag",C,lo),kp(P.view),Su(P),v=!1,f=P.clientX,p=P.clientY,D("start",P))}}function _(P){if(ri(P),!v){var O=P.clientX-f,D=P.clientY-p;v=O*O+D*D>x}a.mouse("drag",P)}function C(P){zt(P.view).on("mousemove.drag mouseup.drag",null),Ep(P.view,v),ri(P),a.mouse("end",P)}function k(P,O){if(t.call(this,P,O)){var D=P.changedTouches,H=r.call(this,P,O),F=D.length,X,ee;for(X=0;X>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ws(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ws(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=Qv.exec(t))?new Et(r[1],r[2],r[3],1):(r=Gv.exec(t))?new Et(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Kv.exec(t))?Ws(r[1],r[2],r[3],r[4]):(r=qv.exec(t))?Ws(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Zv.exec(t))?rh(r[1],r[2]/100,r[3]/100,1):(r=Jv.exec(t))?rh(r[1],r[2]/100,r[3]/100,r[4]):qf.hasOwnProperty(t)?eh(qf[t]):t==="transparent"?new Et(NaN,NaN,NaN,0):null}function eh(t){return new Et(t>>16&255,t>>8&255,t&255,1)}function Ws(t,r,o,l){return l<=0&&(t=r=o=NaN),new Et(t,r,o,l)}function nx(t){return t instanceof So||(t=Sr(t)),t?(t=t.rgb(),new Et(t.r,t.g,t.b,t.opacity)):new Et}function $u(t,r,o,l){return arguments.length===1?nx(t):new Et(t,r,o,l??1)}function Et(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}Zu(Et,$u,Cp(So,{brighter(t){return t=t==null?il:Math.pow(il,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ao:Math.pow(ao,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Et(xr(this.r),xr(this.g),xr(this.b),ol(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:th,formatHex:th,formatHex8:rx,formatRgb:nh,toString:nh}));function th(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}`}function rx(){return`#${vr(this.r)}${vr(this.g)}${vr(this.b)}${vr((isNaN(this.opacity)?1:this.opacity)*255)}`}function nh(){const t=ol(this.opacity);return`${t===1?"rgb(":"rgba("}${xr(this.r)}, ${xr(this.g)}, ${xr(this.b)}${t===1?")":`, ${t})`}`}function ol(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function xr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function vr(t){return t=xr(t),(t<16?"0":"")+t.toString(16)}function rh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new qt(t,r,o,l)}function jp(t){if(t instanceof qt)return new qt(t.h,t.s,t.l,t.opacity);if(t instanceof So||(t=Sr(t)),!t)return new qt;if(t instanceof qt)return t;t=t.rgb();var r=t.r/255,o=t.g/255,l=t.b/255,a=Math.min(r,o,l),u=Math.max(r,o,l),d=NaN,f=u-a,p=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&p<1?0:d,new qt(d,f,p,t.opacity)}function ix(t,r,o,l){return arguments.length===1?jp(t):new qt(t,r,o,l??1)}function qt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}Zu(qt,ix,Cp(So,{brighter(t){return t=t==null?il:Math.pow(il,t),new qt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ao:Math.pow(ao,t),new qt(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,l=o+(o<.5?o:1-o)*r,a=2*o-l;return new Et(_u(t>=240?t-240:t+120,a,l),_u(t,a,l),_u(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new qt(ih(this.h),Us(this.s),Us(this.l),ol(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=ol(this.opacity);return`${t===1?"hsl(":"hsla("}${ih(this.h)}, ${Us(this.s)*100}%, ${Us(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ih(t){return t=(t||0)%360,t<0?t+360:t}function Us(t){return Math.max(0,Math.min(1,t||0))}function _u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const Ju=t=>()=>t;function ox(t,r){return function(o){return t+o*r}}function sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(l){return Math.pow(t+l*r,o)}}function lx(t){return(t=+t)==1?Mp:function(r,o){return o-r?sx(r,o,t):Ju(isNaN(r)?o:r)}}function Mp(t,r){var o=r-t;return o?ox(t,o):Ju(isNaN(t)?r:t)}const sl=(function t(r){var o=lx(r);function l(a,u){var d=o((a=$u(a)).r,(u=$u(u)).r),f=o(a.g,u.g),p=o(a.b,u.b),v=Mp(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=p(m),a.opacity=v(m),a+""}}return l.gamma=t,l})(1);function ax(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,l=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),f[d]?f[d]+=u:f[++d]=u),(l=l[0])===(a=a[0])?f[d]?f[d]+=a:f[++d]=a:(f[++d]=null,p.push({i:d,x:cn(l,a)})),o=ku.lastIndex;return o180?m+=360:m-v>180&&(v+=360),y.push({i:x.push(a(x)+"rotate(",null,l)-2,x:cn(v,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(v,m,x,y){v!==m?y.push({i:x.push(a(x)+"skewX(",null,l)-2,x:cn(v,m)}):m&&x.push(a(x)+"skewX("+m+l)}function p(v,m,x,y,S,_){if(v!==x||m!==y){var C=S.push(a(S)+"scale(",null,",",null,")");_.push({i:C-4,x:cn(v,x)},{i:C-2,x:cn(m,y)})}else(x!==1||y!==1)&&S.push(a(S)+"scale("+x+","+y+")")}return function(v,m){var x=[],y=[];return v=t(v),m=t(m),u(v.translateX,v.translateY,m.translateX,m.translateY,x,y),d(v.rotate,m.rotate,x,y),f(v.skewX,m.skewX,x,y),p(v.scaleX,v.scaleY,m.scaleX,m.scaleY,x,y),v=m=null,function(S){for(var _=-1,C=y.length,k;++_=0&&t._call.call(void 0,r),t=t._next;--si}function lh(){_r=(al=co.now())+ml,si=ro=0;try{kx()}finally{si=0,Nx(),_r=0}}function Ex(){var t=co.now(),r=t-al;r>zp&&(ml-=r,al=t)}function Nx(){for(var t,r=ll,o,l=1/0;r;)r._call?(l>r._time&&(l=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:ll=o);io=t,Fu(l)}function Fu(t){if(!si){ro&&(ro=clearTimeout(ro));var r=t-_r;r>24?(t<1/0&&(ro=setTimeout(lh,t-co.now()-ml)),to&&(to=clearInterval(to))):(to||(al=co.now(),to=setInterval(Ex,zp)),si=1,Rp(lh))}}function ah(t,r,o){var l=new ul;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Cx=pl("start","end","cancel","interrupt"),jx=[],Ap=0,uh=1,Hu=2,el=3,ch=4,Vu=5,tl=6;function yl(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Mx(t,o,{name:r,index:l,group:a,on:Cx,tween:jx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Ap})}function tc(t,r){var o=tn(t,r);if(o.state>Ap)throw new Error("too late; already scheduled");return o}function fn(t,r){var o=tn(t,r);if(o.state>el)throw new Error("too late; already running");return o}function tn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Mx(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Lp(u,0,o.time);function u(v){o.state=uh,o.timer.restart(d,o.delay,o.time),o.delay<=v&&d(v-o.delay)}function d(v){var m,x,y,S;if(o.state!==uh)return p();for(m in l)if(S=l[m],S.name===o.name){if(S.state===el)return ah(d);S.state===ch?(S.state=tl,S.timer.stop(),S.on.call("interrupt",t,t.__data__,S.index,S.group),delete l[m]):+mHu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function iw(t,r,o){var l,a,u=rw(r)?tc:fn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function ow(t,r){var o=this._id;return arguments.length<2?tn(this.node(),o).on.on(t):this.each(iw(o,t,r))}function sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function lw(){return this.on("end.remove",sw(this._id))}function aw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=Ku(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Rw(t,{sourceEvent:r,target:o,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function En(t,r,o){this.k=t,this.x=r,this.y=o}En.prototype={constructor:En,scale:function(t){return t===1?this:new En(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new En(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var vl=new En(1,0,0);Op.prototype=En.prototype;function Op(t){for(;!t.__zoom;)if(!(t=t.parentNode))return vl;return t.__zoom}function Eu(t){t.stopImmediatePropagation()}function no(t){t.preventDefault(),t.stopImmediatePropagation()}function Lw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Aw(){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 dh(){return this.__zoom||vl}function Dw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function $w(){return navigator.maxTouchPoints||"ontouchstart"in this}function bw(t,r,o){var l=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],d=t.invertY(r[1][1])-o[1][1];return t.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),d>u?(u+d)/2:Math.min(0,u)||Math.max(0,d))}function Fp(){var t=Lw,r=Aw,o=bw,l=Dw,a=$w,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,p=Js,v=pl("start","zoom","end"),m,x,y,S=500,_=150,C=0,k=10;function E(j){j.property("__zoom",dh).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",X).on("dblclick.zoom",ee).filter(a).on("touchstart.zoom",q).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(j,W,V,B){var A=j.selection?j.selection():j;A.property("__zoom",dh),j!==A?O(j,W,V,B):A.interrupt().each(function(){D(this,arguments).event(B).start().zoom(null,typeof W=="function"?W.apply(this,arguments):W).end()})},E.scaleBy=function(j,W,V,B){E.scaleTo(j,function(){var A=this.__zoom.k,L=typeof W=="function"?W.apply(this,arguments):W;return A*L},V,B)},E.scaleTo=function(j,W,V,B){E.transform(j,function(){var A=r.apply(this,arguments),L=this.__zoom,b=V==null?P(A):typeof V=="function"?V.apply(this,arguments):V,M=L.invert(b),z=typeof W=="function"?W.apply(this,arguments):W;return o(N(T(L,z),b,M),A,d)},V,B)},E.translateBy=function(j,W,V,B){E.transform(j,function(){return o(this.__zoom.translate(typeof W=="function"?W.apply(this,arguments):W,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,B)},E.translateTo=function(j,W,V,B,A){E.transform(j,function(){var L=r.apply(this,arguments),b=this.__zoom,M=B==null?P(L):typeof B=="function"?B.apply(this,arguments):B;return o(vl.translate(M[0],M[1]).scale(b.k).translate(typeof W=="function"?-W.apply(this,arguments):-W,typeof V=="function"?-V.apply(this,arguments):-V),L,d)},B,A)};function T(j,W){return W=Math.max(u[0],Math.min(u[1],W)),W===j.k?j:new En(W,j.x,j.y)}function N(j,W,V){var B=W[0]-V[0]*j.k,A=W[1]-V[1]*j.k;return B===j.x&&A===j.y?j:new En(j.k,B,A)}function P(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function O(j,W,V,B){j.on("start.zoom",function(){D(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(B).end()}).tween("zoom",function(){var A=this,L=arguments,b=D(A,L).event(B),M=r.apply(A,L),z=V==null?P(M):typeof V=="function"?V.apply(A,L):V,re=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),ne=A.__zoom,ae=typeof W=="function"?W.apply(A,L):W,de=p(ne.invert(z).concat(re/ne.k),ae.invert(z).concat(re/ae.k));return function(ce){if(ce===1)ce=ae;else{var G=de(ce),se=re/G[2];ce=new En(se,z[0]-G[0]*se,z[1]-G[1]*se)}b.zoom(null,ce)}})}function D(j,W,V){return!V&&j.__zooming||new H(j,W)}function H(j,W){this.that=j,this.args=W,this.active=0,this.sourceEvent=null,this.extent=r.apply(j,W),this.taps=0}H.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,W){return this.mouse&&j!=="mouse"&&(this.mouse[1]=W.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=W.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=W.invert(this.touch1[0])),this.that.__zoom=W,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var W=zt(this.that).datum();v.call(j,this.that,new Rw(j,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),W)}};function F(j,...W){if(!t.apply(this,arguments))return;var V=D(this,W).event(j),B=this.__zoom,A=Math.max(u[0],Math.min(u[1],B.k*Math.pow(2,l.apply(this,arguments)))),L=Kt(j);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)],nl(this),V.start()}no(j),V.wheel=setTimeout(b,_),V.zoom("mouse",o(N(T(B,A),V.mouse[0],V.mouse[1]),V.extent,d));function b(){V.wheel=null,V.end()}}function X(j,...W){if(y||!t.apply(this,arguments))return;var V=j.currentTarget,B=D(this,W,!0).event(j),A=zt(j.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",re,!0),L=Kt(j,V),b=j.clientX,M=j.clientY;kp(j.view),Eu(j),B.mouse=[L,this.__zoom.invert(L)],nl(this),B.start();function z(ne){if(no(ne),!B.moved){var ae=ne.clientX-b,de=ne.clientY-M;B.moved=ae*ae+de*de>C}B.event(ne).zoom("mouse",o(N(B.that.__zoom,B.mouse[0]=Kt(ne,V),B.mouse[1]),B.extent,d))}function re(ne){A.on("mousemove.zoom mouseup.zoom",null),Ep(ne.view,B.moved),no(ne),B.event(ne).end()}}function ee(j,...W){if(t.apply(this,arguments)){var V=this.__zoom,B=Kt(j.changedTouches?j.changedTouches[0]:j,this),A=V.invert(B),L=V.k*(j.shiftKey?.5:2),b=o(N(T(V,L),B,A),r.apply(this,W),d);no(j),f>0?zt(this).transition().duration(f).call(O,b,B,j):zt(this).call(E.transform,b,B,j)}}function q(j,...W){if(t.apply(this,arguments)){var V=j.touches,B=V.length,A=D(this,W,j.changedTouches.length===B).event(j),L,b,M,z;for(Eu(j),b=0;b`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:l})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o: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.`},fo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Hp=["Enter"," ","Escape"],Vp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var li;(function(t){t.Strict="strict",t.Loose="loose"})(li||(li={}));var wr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(wr||(wr={}));var ho;(function(t){t.Partial="partial",t.Full="full"})(ho||(ho={}));const Bp={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var qn;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(qn||(qn={}));var po;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(po||(po={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const fh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function Wp(t){return t===null?null:t?"valid":"invalid"}const Up=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Ow=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),rc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),_o=(t,r=[0,0])=>{const{width:o,height:l}=nn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Fw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const l=t.reduce((a,u)=>{const d=typeof u=="string";let f=!r.nodeLookup&&!d?u:void 0;return r.nodeLookup&&(f=d?r.nodeLookup.get(u):rc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,xl(a,cl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?wl(l):{x:0,y:0,width:0,height:0}},ko=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=xl(o,cl(a)),l=!0)}),l?wl(o):{x:0,y:0,width:0,height:0}},ic=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,p=(r.y-l)/a,v=r.width/a,m=r.height/a,x=[];for(const y of t.values()){const{measured:S,selectable:_=!0,hidden:C=!1}=y;if(d&&!_||C)continue;const k=S.width??y.width??y.initialWidth??0,E=S.height??y.height??y.initialHeight??0,{x:T,y:N}=y.internals.positionAbsolute,P=Gp(f,p,v,m,T,N,k,E),O=k*E,D=u&&P>0;(!y.internals.handleBounds||D||P>=O||y.dragging)&&x.push(y)}return x},Hw=(t,r)=>{const o=new Set;return t.forEach(l=>{o.add(l.id)}),r.filter(l=>o.has(l.source)||o.has(l.target))};function Vw(t,r){const o=new Map,l=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:d,height:f}=nn(a);u=d>0&&f>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!l||l.has(a.id))&&o.set(a.id,a)}),o}async function Bw({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Vw(t,d),p=ko(f),v=sc(p,r,o,(d==null?void 0:d.minZoom)??a,(d==null?void 0:d.maxZoom)??u,(d==null?void 0:d.padding)??.1);return await l.setViewport(v,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function Yp({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:l=[0,0],nodeExtent:a,onError:u}){const d=o.get(t),f=d.parentId?o.get(d.parentId):void 0,{x:p,y:v}=f?f.internals.positionAbsolute:{x:0,y:0},m=d.origin??l;let x=d.extent||a;if(d.extent==="parent"&&!d.expandParent)if(!f)u==null||u("005",en.error005());else{const{width:S,height:_}=nn(f);S&&_&&(x=[[p,v],[p+S,v+_]])}else f&&Er(d.extent)&&(x=[[d.extent[0][0]+p,d.extent[0][1]+v],[d.extent[1][0]+p,d.extent[1][1]+v]]);const y=Er(x)?kr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",en.error015())),{position:{x:y.x-p+(d.measured.width??0)*m[0],y:y.y-v+(d.measured.height??0)*m[1]},positionAbsolute:y}}async function Ww({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(y=>y.id)),d=[];for(const y of o){if(y.deletable===!1)continue;const S=u.has(y.id),_=!S&&y.parentId&&d.find(C=>C.id===y.parentId);(S||_)&&d.push(y)}const f=new Set(r.map(y=>y.id)),p=l.filter(y=>y.deletable!==!1),m=Hw(d,p);for(const y of p)f.has(y.id)&&!m.find(_=>_.id===y.id)&&m.push(y);if(!a)return{edges:m,nodes:d};const x=await a({nodes:d,edges:m});return typeof x=="boolean"?x?{edges:m,nodes:d}:{edges:[],nodes:[]}:x}const ai=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),kr=(t={x:0,y:0},r,o)=>({x:ai(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:ai(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function Xp(t,r,o){const{width:l,height:a}=nn(o),{x:u,y:d}=o.internals.positionAbsolute;return kr(t,[[u,d],[u+l,d+a]],r)}const hh=(t,r,o)=>to?-ai(Math.abs(t-o),1,r)/r:0,oc=(t,r,o=15,l=40)=>{const a=hh(t.x,l,r.width-l)*o,u=hh(t.y,l,r.height-l)*o;return[a,u]},xl=(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)}),Bu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),wl=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),go=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=rc(t)?t.internals.positionAbsolute:_o(t,r);return{x:o,y:l,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},cl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=rc(t)?t.internals.positionAbsolute:_o(t,r);return{x:o,y:l,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:l+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},Qp=(t,r)=>wl(xl(Bu(t),Bu(r))),Gp=(t,r,o,l,a,u,d,f)=>{const p=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),v=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(p*v)},dl=(t,r)=>Gp(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),ph=t=>Zt(t.width)&&Zt(t.height)&&Zt(t.x)&&Zt(t.y),Zt=t=>!isNaN(t)&&isFinite(t),Kp=(t,r)=>(o,l)=>{},Eo=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),No=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Eo(f,d):f},ui=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function ti(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Uw(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=ti(t,o),a=ti(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=ti(t.top??t.y??0,o),a=ti(t.bottom??t.y??0,o),u=ti(t.left??t.x??0,r),d=ti(t.right??t.x??0,r);return{top:l,right:d,bottom:a,left:u,x:u+d,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Yw(t,r,o,l,a,u){const{x:d,y:f}=ui(t,[r,o,l]),{x:p,y:v}=ui({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-p,x=u-v;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const sc=(t,r,o,l,a,u)=>{const d=Uw(u,r,o),f=(r-d.x)/t.width,p=(o-d.y)/t.height,v=Math.min(f,p),m=ai(v,l,a),x=t.x+t.width/2,y=t.y+t.height/2,S=r/2-x*m,_=o/2-y*m,C=Yw(t,S,_,m,r,o),k={left:Math.min(C.left-d.left,0),top:Math.min(C.top-d.top,0),right:Math.min(C.right-d.right,0),bottom:Math.min(C.bottom-d.bottom,0)};return{x:S-k.left+k.right,y:_-k.top+k.bottom,zoom:m}},mo=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Er(t){return t!=null&&t!=="parent"}function nn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function qp(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function Zp(t,r={width:0,height:0},o,l,a){const u={...t},d=l.get(o);if(d){const f=d.origin||a;u.x+=d.internals.positionAbsolute.x-(r.width??0)*f[0],u.y+=d.internals.positionAbsolute.y-(r.height??0)*f[1]}return u}function gh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function Xw(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function Qw(t){return{...Vp,...t||{}}}function so(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=Jt(t),f=No({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:p,y:v}=o?Eo(f,r):f;return{xSnapped:p,ySnapped:v,...f}}const lc=t=>({width:t.offsetWidth,height:t.offsetHeight}),Jp=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},Gw=["INPUT","SELECT","TEXTAREA"];function eg(t){var l,a;const r=((a=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:Gw.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const tg=t=>"clientX"in t,Jt=(t,r)=>{var u,d;const o=tg(t),l=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(d=t.touches)==null?void 0:d[0].clientY;return{x:l-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},mh=(t,r,o,l,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(d=>{const f=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),type:t,nodeId:a,position:d.getAttribute("data-handlepos"),x:(f.left-o.left)/l,y:(f.top-o.top)/l,...lc(d)}})};function ng({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const p=t*.125+a*.375+d*.375+o*.125,v=r*.125+u*.375+f*.375+l*.125,m=Math.abs(p-t),x=Math.abs(v-r);return[p,v,m,x]}function Qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function yh({pos:t,x1:r,y1:o,x2:l,y2:a,c:u}){switch(t){case Se.Left:return[r-Qs(r-l,u),o];case Se.Right:return[r+Qs(l-r,u),o];case Se.Top:return[r,o-Qs(o-a,u)];case Se.Bottom:return[r,o+Qs(a-o,u)]}}function rg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,p]=yh({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[v,m]=yh({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,y,S,_]=ng({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:p,targetControlX:v,targetControlY:m});return[`M${t},${r} C${f},${p} ${v},${m} ${l},${a}`,x,y,S,_]}function ig({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const Zw=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,Jw=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),e1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",en.error006()),r;const l=o.getEdgeId||Zw;let a;return Up(t)?a={...t}:a={...t,id:l(t)},Jw(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function og({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=ig({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const vh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},t1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function n1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=vh[r],p=vh[l],v={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+p.x*u,y:o.y+p.y*u},x=t1({source:v,sourcePosition:r,target:m}),y=x.x!==0?"x":"y",S=x[y];let _=[],C,k;const E={x:0,y:0},T={x:0,y:0},[,,N,P]=ig({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[y]*p[y]===-1){y==="x"?(C=a.x??v.x+(m.x-v.x)*d,k=a.y??(v.y+m.y)/2):(C=a.x??(v.x+m.x)/2,k=a.y??v.y+(m.y-v.y)*d);const F=[{x:C,y:v.y},{x:C,y:m.y}],X=[{x:v.x,y:k},{x:m.x,y:k}];f[y]===S?_=y==="x"?F:X:_=y==="x"?X:F}else{const F=[{x:v.x,y:m.y}],X=[{x:m.x,y:v.y}];if(y==="x"?_=f.x===S?X:F:_=f.y===S?F:X,r===l){const j=Math.abs(t[y]-o[y]);if(j<=u){const W=Math.min(u-1,u-j);f[y]===S?E[y]=(v[y]>t[y]?-1:1)*W:T[y]=(m[y]>o[y]?-1:1)*W}}if(r!==l){const j=y==="x"?"y":"x",W=f[y]===p[j],V=v[j]>m[j],B=v[j]=J?(C=(ee.x+q.x)/2,k=_[0].y):(C=_[0].x,k=(ee.y+q.y)/2)}const O={x:v.x+E.x,y:v.y+E.y},D={x:m.x+T.x,y:m.y+T.y};return[[t,...O.x!==_[0].x||O.y!==_[0].y?[O]:[],..._,...D.x!==_[_.length-1].x||D.y!==_[_.length-1].y?[D]:[],o],C,k,N,P]}function r1(t,r,o,l){const a=Math.min(xh(t,r)/2,xh(r,o)/2,l),{x:u,y:d}=r;if(t.x===u&&u===o.x||t.y===d&&d===o.y)return`L${u} ${d}`;if(t.y===d){const v=t.xo.id===r):t[0])||null}function Uu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function o1(t,{id:r,defaultColor:o,defaultMarkerStart:l,defaultMarkerEnd:a}){const u=new Set;return t.reduce((d,f)=>([f.markerStart||l,f.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=Uu(p,r);u.has(v)||(d.push({id:v,color:p.color||o,...p}),u.add(v))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const sg=1e3,s1=10,ac={nodeOrigin:[0,0],nodeExtent:fo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},l1={...ac,checkEquality:!0};function uc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function a1(t,r,o){const l=uc(ac,o);for(const a of t.values())if(a.parentId)dc(a,t,r,l);else{const u=_o(a,l.nodeOrigin),d=Er(a.extent)?a.extent:l.nodeExtent,f=kr(u,d,nn(a));a.internals.positionAbsolute=f}}function u1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],l=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&l.push(u)}return{source:o,target:l}}function cc(t){return t==="manual"}function Yu(t,r,o,l={}){var m,x;const a=uc(l1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!cc(a.zIndexMode)?sg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const y of t){let S=d.get(y.id);if(a.checkEquality&&y===(S==null?void 0:S.internals.userNode))r.set(y.id,S);else{const _=_o(y,a.nodeOrigin),C=Er(y.extent)?y.extent:a.nodeExtent,k=kr(_,C,nn(y));S={...a.defaults,...y,measured:{width:(m=y.measured)==null?void 0:m.width,height:(x=y.measured)==null?void 0:x.height},internals:{positionAbsolute:k,handleBounds:u1(y,S),z:lg(y,f,a.zIndexMode),userNode:y}},r.set(y.id,S)}(S.measured===void 0||S.measured.width===void 0||S.measured.height===void 0)&&!S.hidden&&(p=!1),y.parentId&&dc(S,r,o,l,u),v||(v=y.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function c1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function dc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}=uc(ac,l),v=t.parentId,m=r.get(v);if(!m){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}c1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&p==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*s1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!cc(p)?sg:0,{x:y,y:S,z:_}=d1(t,m,d,f,x,p),{positionAbsolute:C}=t.internals,k=y!==C.x||S!==C.y;(k||_!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:k?{x:y,y:S}:C,z:_}})}function lg(t,r,o){const l=Zt(t.zIndex)?t.zIndex:0;return cc(o)?l:l+(t.selected?r:0)}function d1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,p=nn(t),v=_o(t,o),m=Er(t.extent)?kr(v,t.extent,p):v;let x=kr({x:d+m.x,y:f+m.y},l,p);t.extent==="parent"&&(x=Xp(x,p,r));const y=lg(t,a,u),S=r.internals.z??0;return{x:x.x,y:x.y,z:S>=y?S+1:y}}function fc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const p=r.get(f.parentId);if(!p)continue;const v=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??go(p),m=Qp(v,f.rect);u.set(f.parentId,{expandedRect:m,parent:p})}return u.size>0&&u.forEach(({expandedRect:f,parent:p},v)=>{var N;const m=p.internals.positionAbsolute,x=nn(p),y=p.origin??l,S=f.x0||_>0||E||T)&&(a.push({id:v,type:"position",position:{x:p.position.x-S+E,y:p.position.y-_+T}}),(N=o.get(v))==null||N.forEach(P=>{t.some(O=>O.id===P.id)||a.push({id:P.id,type:"position",position:{x:P.position.x+S,y:P.position.y+_}})})),(x.width0){const S=fc(y,r,o,a);v.push(...S)}return{changes:v,updatedInternals:p}}async function h1({delta:t,panZoom:r,transform:o,translateExtent:l,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const d=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],l);return!!d&&(d.x!==o[0]||d.y!==o[1]||d.k!==o[2])}function kh(t,r,o,l,a,u){let d=a;const f=l.get(d)||new Map;l.set(d,f.set(o,r)),d=`${a}-${t}`;const p=l.get(d)||new Map;if(l.set(d,p.set(o,r)),u){d=`${a}-${t}-${u}`;const v=l.get(d)||new Map;l.set(d,v.set(o,r))}}function ag(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,p={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},v=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;kh("source",p,m,t,a,d),kh("target",p,v,t,u,f),r.set(l.id,l)}}function ug(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:ug(o,r):!1}function Eh(t,r,o){var a;let l=t;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,r))return!0;if(l===o)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function p1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!ug(d,t))&&(d.draggable||r&&typeof d.draggable>"u")){const f=t.get(u);f&&a.set(u,{id:u,position:f.position||{x:0,y:0},distance:{x:o.x-f.internals.positionAbsolute.x,y:o.y-f.internals.positionAbsolute.y},extent:f.extent,parentId:f.parentId,origin:f.origin,expandParent:f.expandParent,internals:{positionAbsolute:f.internals.positionAbsolute||{x:0,y:0}},measured:{width:f.measured.width??0,height:f.measured.height??0}})}return a}function Nu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,p;const a=[];for(const[v,m]of r){const x=(d=o.get(v))==null?void 0:d.internals.userNode;x&&a.push({...x,position:m.position,dragging:l})}if(!t)return[a[0],a];const u=(f=o.get(t))==null?void 0:f.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:l}:a[0],a]}function g1({dragItems:t,snapGrid:r,x:o,y:l}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:l-a.distance.y},d=Eo(u,r);return{x:d.x-u.x,y:d.y-u.y}}function m1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,p=!1,v={x:0,y:0},m=null,x=!1,y=null,S=!1,_=!1,C=null;function k({noDragClassName:T,handleSelector:N,domNode:P,isSelectable:O,nodeId:D,nodeClickDistance:H=0}){y=zt(P);function F({x:te,y:J}){const{nodeLookup:j,nodeExtent:W,snapGrid:V,snapToGrid:B,nodeOrigin:A,onNodeDrag:L,onSelectionDrag:b,onError:M,updateNodePositions:z}=r();u={x:te,y:J};let re=!1;const ne=f.size>1,ae=ne&&W?Bu(ko(f)):null,de=ne&&B?g1({dragItems:f,snapGrid:V,x:te,y:J}):null;for(const[ce,G]of f){if(!j.has(ce))continue;let se={x:te-G.distance.x,y:J-G.distance.y};B&&(se=de?{x:Math.round(se.x+de.x),y:Math.round(se.y+de.y)}:Eo(se,V));let he=null;if(ne&&W&&!G.extent&&ae){const{positionAbsolute:me}=G.internals,Ce=me.x-ae.x+W[0][0],Me=me.x+G.measured.width-ae.x2+W[1][0],Pe=me.y-ae.y+W[0][1],Re=me.y+G.measured.height-ae.y2+W[1][1];he=[[Ce,Pe],[Me,Re]]}const{position:we,positionAbsolute:ve}=Yp({nodeId:ce,nextPosition:se,nodeLookup:j,nodeExtent:he||W,nodeOrigin:A,onError:M});re=re||G.position.x!==we.x||G.position.y!==we.y,G.position=we,G.internals.positionAbsolute=ve}if(_=_||re,!!re&&(z(f,!0),C&&(l||L||!D&&b))){const[ce,G]=Nu({nodeId:D,dragItems:f,nodeLookup:j});l==null||l(C,f,ce,G),L==null||L(C,ce,G),D||b==null||b(C,G)}}async function X(){if(!m)return;const{transform:te,panBy:J,autoPanSpeed:j,autoPanOnNodeDrag:W}=r();if(!W){p=!1,cancelAnimationFrame(d);return}const[V,B]=oc(v,m,j);(V!==0||B!==0)&&(u.x=(u.x??0)-V/te[2],u.y=(u.y??0)-B/te[2],await J({x:V,y:B})&&F(u)),d=requestAnimationFrame(X)}function ee(te){var ne;const{nodeLookup:J,multiSelectionActive:j,nodesDraggable:W,transform:V,snapGrid:B,snapToGrid:A,selectNodesOnDrag:L,onNodeDragStart:b,onSelectionDragStart:M,unselectNodesAndEdges:z}=r();x=!0,(!L||!O)&&!j&&D&&((ne=J.get(D))!=null&&ne.selected||z()),O&&L&&D&&(t==null||t(D));const re=so(te.sourceEvent,{transform:V,snapGrid:B,snapToGrid:A,containerBounds:m});if(u=re,f=p1(J,W,re,D),f.size>0&&(o||b||!D&&M)){const[ae,de]=Nu({nodeId:D,dragItems:f,nodeLookup:J});o==null||o(te.sourceEvent,f,ae,de),b==null||b(te.sourceEvent,ae,de),D||M==null||M(te.sourceEvent,de)}}const q=Np().clickDistance(H).on("start",te=>{const{domNode:J,nodeDragThreshold:j,transform:W,snapGrid:V,snapToGrid:B}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,S=!1,_=!1,C=te.sourceEvent,j===0&&ee(te),u=so(te.sourceEvent,{transform:W,snapGrid:V,snapToGrid:B,containerBounds:m}),v=Jt(te.sourceEvent,m)}).on("drag",te=>{const{autoPanOnNodeDrag:J,transform:j,snapGrid:W,snapToGrid:V,nodeDragThreshold:B,nodeLookup:A}=r(),L=so(te.sourceEvent,{transform:j,snapGrid:W,snapToGrid:V,containerBounds:m});if(C=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||D&&!A.has(D))&&(S=!0),!S){if(!p&&J&&x&&(p=!0,X()),!x){const b=Jt(te.sourceEvent,m),M=b.x-v.x,z=b.y-v.y;Math.sqrt(M*M+z*z)>B&&ee(te)}(u.x!==L.xSnapped||u.y!==L.ySnapped)&&f&&x&&(v=Jt(te.sourceEvent,m),F(L))}}).on("end",te=>{if(!x||S){S&&f.size>0&&r().updateNodePositions(f,!1);return}if(p=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:j,onNodeDragStop:W,onSelectionDragStop:V}=r();if(_&&(j(f,!1),_=!1),a||W||!D&&V){const[B,A]=Nu({nodeId:D,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(te.sourceEvent,f,B,A),W==null||W(te.sourceEvent,B,A),D||V==null||V(te.sourceEvent,A)}}}).filter(te=>{const J=te.target;return!te.button&&(!T||!Eh(J,`.${T}`,P))&&(!N||Eh(J,N,P))});y.call(q)}function E(){y==null||y.on(".drag",null)}return{update:k,destroy:E}}function y1(t,r,o){const l=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())dl(a,go(u))>0&&l.push(u);return l}const v1=250;function x1(t,r,o,l){var f,p;let a=[],u=1/0;const d=y1(t,o,r+v1);for(const v of d){const m=[...((f=v.internals.handleBounds)==null?void 0:f.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:y,y:S}=Nr(v,x,x.position,!0),_=Math.sqrt(Math.pow(y-t.x,2)+Math.pow(S-t.y,2));_>r||(_1){const v=l.type==="source"?"target":"source";return a.find(m=>m.type===v)??a[0]}return a[0]}function cg(t,r,o,l,a,u=!1){var v,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(v=d.internals.handleBounds)==null?void 0:v[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],p=(o?f==null?void 0:f.find(y=>y.id===o):f==null?void 0:f[0])??null;return p&&u?{...p,...Nr(d,p,p.position,!0)}:p}function dg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function w1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const fg=()=>!0;function S1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:p,lib:v,autoPanOnConnect:m,flowId:x,panBy:y,cancelConnection:S,onConnectStart:_,onConnect:C,onConnectEnd:k,isValidConnection:E=fg,onReconnectEnd:T,updateConnection:N,getTransform:P,getFromHandle:O,autoPanSpeed:D,dragThreshold:H=1,handleDomNode:F}){const X=Jp(t.target);let ee=0,q;const{x:te,y:J}=Jt(t),j=dg(u,F),W=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!W||!j)return;const B=cg(a,j,l,p,r);if(!B)return;let A=Jt(t,W),L=!1,b=null,M=!1,z=null;function re(){if(!m||!W)return;const[we,ve]=oc(A,W,D);y({x:we,y:ve}),ee=requestAnimationFrame(re)}const ne={...B,nodeId:a,type:j,position:B.position},ae=p.get(a);let ce={inProgress:!0,isValid:null,from:Nr(ae,ne,Se.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:ae,to:A,toHandle:null,toPosition:fh[ne.position],toNode:null,pointer:A};function G(){V=!0,N(ce),_==null||_(t,{nodeId:a,handleId:l,handleType:j})}H===0&&G();function se(we){if(!V){const{x:Re,y:nt}=Jt(we),rt=Re-te,Xe=nt-J;if(!(rt*rt+Xe*Xe>H*H))return;G()}if(!O()||!ne){he(we);return}const ve=P();A=Jt(we,W),q=x1(No(A,ve,!1,[1,1]),o,p,ne),L||(re(),L=!0);const me=hg(we,{handle:q,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:X,lib:v,flowId:x,nodeLookup:p});z=me.handleDomNode,b=me.connection,M=w1(!!q,me.isValid);const Ce=p.get(a),Me=Ce?Nr(Ce,ne,Se.Left,!0):ce.from,Pe={...ce,from:Me,isValid:M,to:me.toHandle&&M?ui({x:me.toHandle.x,y:me.toHandle.y},ve):A,toHandle:me.toHandle,toPosition:M&&me.toHandle?me.toHandle.position:fh[ne.position],toNode:me.toHandle?p.get(me.toHandle.nodeId):null,pointer:A};N(Pe),ce=Pe}function he(we){if(!("touches"in we&&we.touches.length>0)){if(V){(q||z)&&b&&M&&(C==null||C(b));const{inProgress:ve,...me}=ce,Ce={...me,toPosition:ce.toHandle?ce.toPosition:null};k==null||k(we,Ce),u&&(T==null||T(we,Ce))}S(),cancelAnimationFrame(ee),L=!1,M=!1,b=null,z=null,X.removeEventListener("mousemove",se),X.removeEventListener("mouseup",he),X.removeEventListener("touchmove",se),X.removeEventListener("touchend",he)}}X.addEventListener("mousemove",se),X.addEventListener("mouseup",he),X.addEventListener("touchmove",se),X.addEventListener("touchend",he)}function hg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:p,isValidConnection:v=fg,nodeLookup:m}){const x=u==="target",y=r?d.querySelector(`.${f}-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:S,y:_}=Jt(t),C=d.elementFromPoint(S,_),k=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:y,E={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const T=dg(void 0,k),N=k.getAttribute("data-nodeid"),P=k.getAttribute("data-handleid"),O=k.classList.contains("connectable"),D=k.classList.contains("connectableend");if(!N||!T)return E;const H={source:x?N:l,sourceHandle:x?P:a,target:x?l:N,targetHandle:x?a:P};E.connection=H;const X=O&&D&&(o===li.Strict?x&&T==="source"||!x&&T==="target":N!==l||P!==a);E.isValid=X&&v(H),E.toHandle=cg(N,T,P,m,o,!0)}return E}const Xu={onPointerDown:S1,isValid:hg};function _1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=zt(t);function u({translateExtent:f,width:p,height:v,zoomStep:m=1,pannable:x=!0,zoomable:y=!0,inversePan:S=!1}){const _=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const P=o(),O=N.sourceEvent.ctrlKey&&mo()?10:1,D=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=P[2]*Math.pow(2,D*O);r.scaleTo(H)};let C=[0,0];const k=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(C=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},E=N=>{const P=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const O=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],D=[O[0]-C[0],O[1]-C[1]];C=O;const H=l()*Math.max(P[2],Math.log(P[2]))*(S?-1:1),F={x:P[0]-D[0]*H,y:P[1]-D[1]*H},X=[[0,0],[p,v]];r.setViewportConstrained({x:F.x,y:F.y,zoom:P[2]},X,f)},T=Fp().on("start",k).on("zoom",x?E:null).on("zoom.wheel",y?_:null);a.call(T,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Kt}}const Sl=t=>({x:t.x,y:t.y,zoom:t.k}),Cu=({x:t,y:r,zoom:o})=>vl.translate(t,r).scale(o),Kn=(t,r)=>t.target.closest(`.${r}`),pg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),k1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,ju=(t,r=0,o=k1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},gg=t=>{const r=t.ctrlKey&&mo()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function E1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:p,onPanZoomEnd:v}){return m=>{if(Kn(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const k=Kt(m),E=gg(m),T=x*Math.pow(2,E);l.scaleTo(o,T,k,m);return}const y=m.deltaMode===1?20:1;let S=a===wr.Vertical?0:m.deltaX*y,_=a===wr.Horizontal?0:m.deltaY*y;!mo()&&m.shiftKey&&a!==wr.Vertical&&(S=m.deltaY*y,_=0),l.translateBy(o,-(S/x)*u,-(_/x)*u,{internal:!0});const C=Sl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{v==null||v(m,C),t.isPanScrolling=!1},150)}}function N1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=Kn(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function C1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Sl(l.transform);t.mouseButton=((d=l.sourceEvent)==null?void 0:d.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((f=l.sourceEvent)==null?void 0:f.type)==="mousedown"&&r(!0),o&&(o==null||o(l.sourceEvent,a))}}function j1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&pg(r,t.mouseButton??0)),(d=u.sourceEvent)!=null&&d.sync||l([u.transform.x,u.transform.y,u.transform.k]),a&&!((f=u.sourceEvent)!=null&&f.internal)&&(a==null||a(u.sourceEvent,Sl(u.transform)))}}function M1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:u}){return d=>{var f;if(!((f=d.sourceEvent)!=null&&f.internal)&&(t.isZoomingOrPanning=!1,u&&pg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const p=Sl(d.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,p)},o?150:0)}}}function P1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:p,noPanClassName:v,lib:m,connectionInProgress:x}){return y=>{var E;const S=r||o,_=l&&y.ctrlKey,C=y.type==="wheel";if(y.button===1&&y.type==="mousedown"&&(Kn(y,`${m}-flow__node`)||Kn(y,`${m}-flow__edge`)||Kn(y,`${m}-flow__selection`)||Kn(y,`${m}-flow__nodesselection`)))return!0;if(!a&&!S&&!u&&!d&&!l||f||x&&!C||Kn(y,p)&&C||Kn(y,v)&&(!C||u&&C&&!r)||!l&&y.ctrlKey&&C)return!1;if(!l&&y.type==="touchstart"&&((E=y.touches)==null?void 0:E.length)>1)return y.preventDefault(),!1;if(!S&&!u&&!_&&C||!a&&(y.type==="mousedown"||y.type==="touchstart")||Array.isArray(a)&&!a.includes(y.button)&&y.type==="mousedown")return!1;const k=Array.isArray(a)&&a.includes(y.button)||!y.button||y.button<=1;return(!y.ctrlKey||C||t)&&k}}function I1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let x=[[0,0],[m.width,m.height]];const y=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const j=J[0];j&&(x=[[0,0],[j.contentRect.width,j.contentRect.height]])}):null;y==null||y.observe(t);const S=Fp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),_=zt(t).call(S);P({x:a.x,y:a.y,zoom:ai(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=_.on("wheel.zoom"),k=_.on("dblclick.zoom");S.wheelDelta(gg);async function E(J,j){return _?new Promise(W=>{S==null||S.interpolate((j==null?void 0:j.interpolate)==="linear"?oo:Js).transform(ju(_,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>W(!0)),J)}):!1}function T({noWheelClassName:J,noPanClassName:j,onPaneContextMenu:W,userSelectionActive:V,panOnScroll:B,panOnDrag:A,panOnScrollMode:L,panOnScrollSpeed:b,preventScrolling:M,zoomOnPinch:z,zoomOnScroll:re,zoomOnDoubleClick:ne,panActivationKeyPressed:ae=!1,zoomActivationKeyPressed:de,lib:ce,onTransformChange:G,connectionInProgress:se,paneClickDistance:he,selectionOnDrag:we}){V&&!v.isZoomingOrPanning&&N();const ve=B&&!de&&!V;S.clickDistance(we?1/0:!Zt(he)||he<0?0:he);const me=ve?E1({zoomPanValues:v,noWheelClassName:J,d3Selection:_,d3Zoom:S,panOnScrollMode:L,panOnScrollSpeed:b,zoomOnPinch:z,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):N1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});_.on("wheel.zoom",me,{passive:!1});const Ce=C1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:d});S.on("start",Ce);const Me=j1({zoomPanValues:v,panOnDrag:A,onPaneContextMenu:!!W,onPanZoom:u,onTransformChange:G});S.on("zoom",Me);const Pe=M1({zoomPanValues:v,panOnDrag:A,panOnScroll:B,onPaneContextMenu:W,onPanZoomEnd:f,onDraggingChange:p});S.on("end",Pe);const Re=P1({panActivationKeyPressed:ae,zoomActivationKeyPressed:de,panOnDrag:A,zoomOnScroll:re,panOnScroll:B,zoomOnDoubleClick:ne,zoomOnPinch:z,userSelectionActive:V,noPanClassName:j,noWheelClassName:J,lib:ce,connectionInProgress:se});S.filter(Re),ne?_.on("dblclick.zoom",k):_.on("dblclick.zoom",null)}function N(){S.on("zoom",null)}async function P(J,j,W){const V=Cu(J),B=S==null?void 0:S.constrain()(V,j,W);return B&&await E(B),B}async function O(J,j){const W=Cu(J);return await E(W,j),W}function D(J){if(_){const j=Cu(J),W=_.property("__zoom");(W.k!==J.zoom||W.x!==J.x||W.y!==J.y)&&(S==null||S.transform(_,j,null,{sync:!0}))}}function H(){const J=_?Op(_.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function F(J,j){return _?new Promise(W=>{S==null||S.interpolate((j==null?void 0:j.interpolate)==="linear"?oo:Js).scaleTo(ju(_,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>W(!0)),J)}):!1}async function X(J,j){return _?new Promise(W=>{S==null||S.interpolate((j==null?void 0:j.interpolate)==="linear"?oo:Js).scaleBy(ju(_,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>W(!0)),J)}):!1}function ee(J){S==null||S.scaleExtent(J)}function q(J){S==null||S.translateExtent(J)}function te(J){const j=!Zt(J)||J<0?0:J;S==null||S.clickDistance(j)}return{update:T,destroy:N,setViewport:O,setViewportConstrained:P,getViewport:H,scaleTo:F,scaleBy:X,setScaleExtent:ee,setTranslateExtent:q,syncViewport:D,setClickDistance:te}}var ci;(function(t){t.Line="line",t.Handle="handle"})(ci||(ci={}));function T1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,p=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(p[0]=p[0]*-1),f&&u&&(p[1]=p[1]*-1),p}function Nh(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),l=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:l,affectsY:a}}function Qn(t,r){return Math.max(0,r-t)}function Gn(t,r){return Math.max(0,t-r)}function Gs(t,r,o){return Math.max(0,r-t,t-o)}function Ch(t,r){return t?!r:r}function z1(t,r,o,l,a,u,d,f){let{affectsX:p,affectsY:v}=r;const{isHorizontal:m,isVertical:x}=r,y=m&&x,{xSnapped:S,ySnapped:_}=o,{minWidth:C,maxWidth:k,minHeight:E,maxHeight:T}=l,{x:N,y:P,width:O,height:D,aspectRatio:H}=t;let F=Math.floor(m?S-t.pointerX:0),X=Math.floor(x?_-t.pointerY:0);const ee=O+(p?-F:F),q=D+(v?-X:X),te=-u[0]*O,J=-u[1]*D;let j=Gs(ee,C,k),W=Gs(q,E,T);if(d){let A=0,L=0;p&&F<0?A=Qn(N+F+te,d[0][0]):!p&&F>0&&(A=Gn(N+ee+te,d[1][0])),v&&X<0?L=Qn(P+X+J,d[0][1]):!v&&X>0&&(L=Gn(P+q+J,d[1][1])),j=Math.max(j,A),W=Math.max(W,L)}if(f){let A=0,L=0;p&&F>0?A=Gn(N+F,f[0][0]):!p&&F<0&&(A=Qn(N+ee,f[1][0])),v&&X>0?L=Gn(P+X,f[0][1]):!v&&X<0&&(L=Qn(P+q,f[1][1])),j=Math.max(j,A),W=Math.max(W,L)}if(a){if(m){const A=Gs(ee/H,E,T)*H;if(j=Math.max(j,A),d){let L=0;!p&&!v||p&&!v&&y?L=Gn(P+J+ee/H,d[1][1])*H:L=Qn(P+J+(p?F:-F)/H,d[0][1])*H,j=Math.max(j,L)}if(f){let L=0;!p&&!v||p&&!v&&y?L=Qn(P+ee/H,f[1][1])*H:L=Gn(P+(p?F:-F)/H,f[0][1])*H,j=Math.max(j,L)}}if(x){const A=Gs(q*H,C,k)/H;if(W=Math.max(W,A),d){let L=0;!p&&!v||v&&!p&&y?L=Gn(N+q*H+te,d[1][0])/H:L=Qn(N+(v?X:-X)*H+te,d[0][0])/H,W=Math.max(W,L)}if(f){let L=0;!p&&!v||v&&!p&&y?L=Qn(N+q*H,f[1][0])/H:L=Gn(N+(v?X:-X)*H,f[0][0])/H,W=Math.max(W,L)}}}X=X+(X<0?W:-W),F=F+(F<0?j:-j),a&&(y?ee>q*H?X=(Ch(p,v)?-F:F)/H:F=(Ch(p,v)?-X:X)*H:m?(X=F/H,v=p):(F=X*H,p=v));const V=p?N+F:N,B=v?P+X:P;return{width:O+(p?-F:F),height:D+(v?-X:X),x:u[0]*F*(p?-1:1)+V,y:u[1]*X*(v?-1:1)+B}}const mg={width:0,height:0,x:0,y:0},R1={...mg,pointerX:0,pointerY:0,aspectRatio:1};function L1(t,r,o){const l=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,d=t.measured.height??0,f=o[0]*u,p=o[1]*d;return[[l-f,a-p],[l+u-f,a+d-p]]}function A1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=zt(t);let d={controlDirection:Nh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:v,boundaries:m,keepAspectRatio:x,resizeDirection:y,onResizeStart:S,onResize:_,onResizeEnd:C,shouldResize:k}){let E={...mg},T={...R1};d={boundaries:m,resizeDirection:y,keepAspectRatio:x,controlDirection:Nh(v)};let N,P=null,O=[],D,H,F,X=!1;const ee=Np().on("start",q=>{const{nodeLookup:te,transform:J,snapGrid:j,snapToGrid:W,nodeOrigin:V,paneDomNode:B}=o();if(N=te.get(r),!N)return;P=(B==null?void 0:B.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:L}=so(q.sourceEvent,{transform:J,snapGrid:j,snapToGrid:W,containerBounds:P});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},T={...E,pointerX:A,pointerY:L,aspectRatio:E.width/E.height},D=void 0,H=Er(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(D=te.get(N.parentId)),D&&N.extent==="parent"&&(H=[[0,0],[D.measured.width,D.measured.height]]),O=[],F=void 0;for(const[b,M]of te)if(M.parentId===r&&(O.push({id:b,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const z=L1(M,N,M.origin??V);F?F=[[Math.min(z[0][0],F[0][0]),Math.min(z[0][1],F[0][1])],[Math.max(z[1][0],F[1][0]),Math.max(z[1][1],F[1][1])]]:F=z}S==null||S(q,{...E})}).on("drag",q=>{const{transform:te,snapGrid:J,snapToGrid:j,nodeOrigin:W}=o(),V=so(q.sourceEvent,{transform:te,snapGrid:J,snapToGrid:j,containerBounds:P}),B=[];if(!N)return;const{x:A,y:L,width:b,height:M}=E,z={},re=N.origin??W,{width:ne,height:ae,x:de,y:ce}=z1(T,d.controlDirection,V,d.boundaries,d.keepAspectRatio,re,H,F),G=ne!==b,se=ae!==M,he=de!==A&&G,we=ce!==L&&se;if(!he&&!we&&!G&&!se)return;if((he||we||re[0]===1||re[1]===1)&&(z.x=he?de:E.x,z.y=we?ce:E.y,E.x=z.x,E.y=z.y,O.length>0)){const Me=de-A,Pe=ce-L;for(const Re of O)Re.position={x:Re.position.x-Me+re[0]*(ne-b),y:Re.position.y-Pe+re[1]*(ae-M)},B.push(Re)}if((G||se)&&(z.width=G&&(!d.resizeDirection||d.resizeDirection==="horizontal")?ne:E.width,z.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ae:E.height,E.width=z.width,E.height=z.height),D&&N.expandParent){const Me=re[0]*(z.width??0);z.x&&z.x{X&&(C==null||C(q,{...E}),a==null||a({...E}),X=!1)});u.call(ee)}function p(){u.on(".drag",null)}return{update:f,destroy:p}}var Mu={exports:{}},Pu={},Iu={exports:{}},Tu={};/** + * @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 jh;function D1(){if(jh)return Tu;jh=1;var t=vo();function r(x,y){return x===y&&(x!==0||1/x===1/y)||x!==x&&y!==y}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,y){var S=y(),_=l({inst:{value:S,getSnapshot:y}}),C=_[0].inst,k=_[1];return u(function(){C.value=S,C.getSnapshot=y,p(C)&&k({inst:C})},[x,S,y]),a(function(){return p(C)&&k({inst:C}),x(function(){p(C)&&k({inst:C})})},[x]),d(S),S}function p(x){var y=x.getSnapshot;x=x.value;try{var S=y();return!o(x,S)}catch{return!0}}function v(x,y){return y()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:f;return Tu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Tu}var Mh;function $1(){return Mh||(Mh=1,Iu.exports=D1()),Iu.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 Ph;function b1(){if(Ph)return Pu;Ph=1;var t=vo(),r=$1();function o(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,p=t.useDebugValue;return Pu.useSyncExternalStoreWithSelector=function(v,m,x,y,S){var _=u(null);if(_.current===null){var C={hasValue:!1,value:null};_.current=C}else C=_.current;_=f(function(){function E(D){if(!T){if(T=!0,N=D,D=y(D),S!==void 0&&C.hasValue){var H=C.value;if(S(H,D))return P=H}return P=D}if(H=P,l(N,D))return H;var F=y(D);return S!==void 0&&S(H,F)?(N=D,H):(N=D,P=F)}var T=!1,N,P,O=x===void 0?null:x;return[function(){return E(m())},O===null?void 0:function(){return E(O())}]},[m,x,y,S]);var k=a(v,_[0],_[1]);return d(function(){C.hasValue=!0,C.value=k},[k]),p(k),k},Pu}var Ih;function O1(){return Ih||(Ih=1,Mu.exports=b1()),Mu.exports}var F1=O1();const H1=up(F1),V1={},Th=t=>{let r;const o=new Set,l=(m,x)=>{const y=typeof m=="function"?m(r):m;if(!Object.is(y,r)){const S=r;r=x??(typeof y!="object"||y===null)?y:Object.assign({},r,y),o.forEach(_=>_(r,S))}},a=()=>r,p={setState:l,getState:a,getInitialState:()=>v,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(V1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},v=r=t(l,a,p);return p},B1=t=>t?Th(t):Th,{useDebugValue:W1}=H0,{useSyncExternalStoreWithSelector:U1}=H1,Y1=t=>t;function yg(t,r=Y1,o){const l=U1(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return W1(l),l}const zh=(t,r)=>{const o=B1(t),l=(a,u=r)=>yg(o,a,u);return Object.assign(l,o),l},X1=(t,r)=>t?zh(t,r):zh;function We(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,a]of t)if(!Object.is(a,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 o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const l of o)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(t[l],r[l]))return!1;return!0}cp();const _l=U.createContext(null),Q1=_l.Provider,vg=en.error001("react");function Te(t,r){const o=U.useContext(_l);if(o===null)throw new Error(vg);return yg(o,t,r)}function Oe(){const t=U.useContext(_l);if(t===null)throw new Error(vg);return U.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Rh={display:"none"},G1={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},xg="react-flow__node-desc",wg="react-flow__edge-desc",K1="react-flow__aria-live",q1=t=>t.ariaLiveMessage,Z1=t=>t.ariaLabelConfig;function J1({rfId:t}){const r=Te(q1);return g.jsx("div",{id:`${K1}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:G1,children:r})}function eS({rfId:t,disableKeyboardA11y:r}){const o=Te(Z1);return g.jsxs(g.Fragment,{children:[g.jsx("div",{id:`${xg}-${t}`,style:Rh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),g.jsx("div",{id:`${wg}-${t}`,style:Rh,children:o["edge.a11yDescription.default"]}),!r&&g.jsx(J1,{rfId:t})]})}const kl=U.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return g.jsx("div",{className:Ge(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});kl.displayName="Panel";const Lh="https://reactflow.dev?utm_source=attribution";function tS({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:g.jsx(kl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Lh}`,children:g.jsx("a",{href:Lh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const nS=t=>{const r=[],o=[];for(const[,l]of t.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of t.edgeLookup)l.selected&&o.push(l);return{selectedNodes:r,selectedEdges:o}},Ks=t=>t.id;function rS(t,r){return We(t.selectedNodes.map(Ks),r.selectedNodes.map(Ks))&&We(t.selectedEdges.map(Ks),r.selectedEdges.map(Ks))}function iS({onSelectionChange:t}){const r=Oe(),{selectedNodes:o,selectedEdges:l}=Te(nS,rS);return U.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const oS=t=>!!t.onSelectionChangeHandlers;function sS({onSelectionChange:t}){const r=Te(oS);return t||r?g.jsx(iS,{onSelectionChange:t}):null}const Sg=[0,0],lS={x:0,y:0,zoom:1},aS=["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"],Ah=[...aS,"rfId"],uS=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}),Dh={translateExtent:fo,nodeOrigin:Sg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function cS(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:p}=Te(uS,We),v=Oe();U.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{m.current=Dh,f()}),[]);const m=U.useRef(Dh);return U.useEffect(()=>{for(const x of Ah){const y=t[x],S=m.current[x];y!==S&&(typeof t[x]>"u"||(x==="nodes"?r(y):x==="edges"?o(y):x==="minZoom"?l(y):x==="maxZoom"?a(y):x==="translateExtent"?u(y):x==="nodeExtent"?d(y):x==="ariaLabelConfig"?v.setState({ariaLabelConfig:Qw(y)}):x==="fitView"?v.setState({fitViewQueued:y}):x==="fitViewOptions"?v.setState({fitViewOptions:y}):v.setState({[x]:y})))}m.current=t},Ah.map(x=>t[x])),null}function $h(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function dS(t){var l;const[r,o]=U.useState(t==="system"?null:t);return U.useEffect(()=>{if(t!=="system"){o(t);return}const a=$h(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(l=$h())!=null&&l.matches?"dark":"light"}const bh=typeof document<"u"?document:null;function yo(t=null,r={target:bh,actInsideInputWithModifier:!0}){const[o,l]=U.useState(!1),a=U.useRef(!1),u=U.useRef(new Set([])),[d,f]=U.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),m=v.reduce((x,y)=>x.concat(...y),[]);return[v,m]}return[[],[]]},[t]);return U.useEffect(()=>{const p=(r==null?void 0:r.target)??bh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=S=>{var k,E;if(a.current=S.ctrlKey||S.metaKey||S.shiftKey||S.altKey,(!a.current||a.current&&!v)&&eg(S))return!1;const C=Fh(S.code,f);if(u.current.add(S[C]),Oh(d,u.current,!1)){const T=((E=(k=S.composedPath)==null?void 0:k.call(S))==null?void 0:E[0])||S.target,N=(T==null?void 0:T.nodeName)==="BUTTON"||(T==null?void 0:T.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&S.preventDefault(),l(!0)}},x=S=>{const _=Fh(S.code,f);Oh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(S[_]),S.key==="Meta"&&u.current.clear(),a.current=!1},y=()=>{u.current.clear(),l(!1)};return p==null||p.addEventListener("keydown",m),p==null||p.addEventListener("keyup",x),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",m),p==null||p.removeEventListener("keyup",x),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[t,l]),o}function Oh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Fh(t,r){return r.includes(t)?"code":"key"}const fS=()=>{const t=Oe();return U.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:l}=t.getState();return l?l.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[l,a,u],panZoom:d}=t.getState();return d?(await d.setViewport({x:r.x??l,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,l]=t.getState().transform;return{x:r,y:o,zoom:l}},setCenter:async(r,o,l)=>t.getState().setCenter(r,o,l),fitBounds:async(r,o)=>{const{width:l,height:a,minZoom:u,maxZoom:d,panZoom:f}=t.getState(),p=sc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:p}=d.getBoundingClientRect(),v={x:r.x-f,y:r.y-p},m=o.snapGrid??a,x=o.snapToGrid??u;return No(v,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=ui(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function _g(t,r){const o=[],l=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")l.set(u.id,[u]);else{const d=l.get(u.id);d?d.push(u):l.set(u.id,[u])}for(const u of r){const d=l.get(u.id);if(!d){o.push(u);continue}if(d[0].type==="remove")continue;if(d[0].type==="replace"){o.push({...d[0].item});continue}const f={...u};for(const p of d)hS(p,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function hS(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 pS(t,r){return _g(t,r)}function gS(t,r){return _g(t,r)}function yr(t,r){return{id:t,type:"select",selected:r}}function ni(t,r=new Set,o=!1){const l=[];for(const[a,u]of t){const d=r.has(a);!(u.selected===void 0&&!d)&&u.selected!==d&&(o&&(u.selected=d),l.push(yr(u.id,d)))}return l}function Hh({items:t=[],lookup:r}){var a;const o=[],l=new Map(t.map(u=>[u.id,u]));for(const[u,d]of t.entries()){const f=r.get(d.id),p=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;p!==void 0&&p!==d&&o.push({id:d.id,item:d,type:"replace"}),p===void 0&&o.push({item:d,type:"add",index:u})}for(const[u]of r)l.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Vh(t){return{id:t.id,type:"remove"}}const mS=Kp();function yS(t,r,o={}){return e1(t,r,{...o,onError:o.onError??mS})}const Bh=t=>Ow(t),vS=t=>Up(t);function kg(t){return U.forwardRef(t)}const Eg=typeof window<"u"?U.useLayoutEffect:U.useEffect;function Wh(t){const[r,o]=U.useState(BigInt(0)),[l]=U.useState(()=>xS(()=>o(a=>a+BigInt(1))));return Eg(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function xS(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Ng=U.createContext(null);function wS({children:t}){const r=Oe(),o=U.useCallback(f=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:m,onNodesChange:x,nodeLookup:y,fitViewQueued:S,onNodesChangeMiddlewareMap:_}=r.getState();let C=p;for(const E of f)C=typeof E=="function"?E(C):E;let k=Hh({items:C,lookup:y});for(const E of _.values())k=E(k);m&&v(C),k.length>0?x==null||x(k):S&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:T,setNodes:N}=r.getState();E&&N(T)})},[]),l=Wh(o),a=U.useCallback(f=>{const{edges:p=[],setEdges:v,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:y}=r.getState();let S=p;for(const _ of f)S=typeof _=="function"?_(S):_;m?v(S):x&&x(Hh({items:S,lookup:y}))},[]),u=Wh(a),d=U.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return g.jsx(Ng.Provider,{value:d,children:t})}function SS(){const t=U.useContext(Ng);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const _S=t=>!!t.panZoom;function hc(){const t=fS(),r=Oe(),o=SS(),l=Te(_S),a=U.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},p=x=>{var E,T;const{nodeLookup:y,nodeOrigin:S}=r.getState(),_=Bh(x)?x:y.get(x.id),C=_.parentId?Zp(_.position,_.measured,_.parentId,y,S):_.position,k={..._,position:C,width:((E=_.measured)==null?void 0:E.width)??_.width,height:((T=_.measured)==null?void 0:T.height)??_.height};return go(k)},v=(x,y,S={replace:!1})=>{d(_=>_.map(C=>{if(C.id===x){const k=typeof y=="function"?y(C):y;return S.replace&&Bh(k)?k:{...C,...k}}return C}))},m=(x,y,S={replace:!1})=>{f(_=>_.map(C=>{if(C.id===x){const k=typeof y=="function"?y(C):y;return S.replace&&vS(k)?k:{...C,...k}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var y;return(y=u(x))==null?void 0:y.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(y=>({...y}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const y=Array.isArray(x)?x:[x];o.nodeQueue.push(S=>[...S,...y])},addEdges:x=>{const y=Array.isArray(x)?x:[x];o.edgeQueue.push(S=>[...S,...y])},toObject:()=>{const{nodes:x=[],edges:y=[],transform:S}=r.getState(),[_,C,k]=S;return{nodes:x.map(E=>({...E})),edges:y.map(E=>({...E})),viewport:{x:_,y:C,zoom:k}}},deleteElements:async({nodes:x=[],edges:y=[]})=>{const{nodes:S,edges:_,onNodesDelete:C,onEdgesDelete:k,triggerNodeChanges:E,triggerEdgeChanges:T,onDelete:N,onBeforeDelete:P}=r.getState(),{nodes:O,edges:D}=await Ww({nodesToRemove:x,edgesToRemove:y,nodes:S,edges:_,onBeforeDelete:P}),H=D.length>0,F=O.length>0;if(H){const X=D.map(Vh);k==null||k(D),T(X)}if(F){const X=O.map(Vh);C==null||C(O),E(X)}return(F||H)&&(N==null||N({nodes:O,edges:D})),{deletedNodes:O,deletedEdges:D}},getIntersectingNodes:(x,y=!0,S)=>{const _=ph(x),C=_?x:p(x),k=S!==void 0;return C?(S||r.getState().nodes).filter(E=>{const T=r.getState().nodeLookup.get(E.id);if(T&&!_&&(E.id===x.id||!T.internals.positionAbsolute))return!1;const N=go(k?E:T),P=dl(N,C);return y&&P>0||P>=N.width*N.height||P>=C.width*C.height}):[]},isNodeIntersecting:(x,y,S=!0)=>{const C=ph(x)?x:p(x);if(!C)return!1;const k=dl(C,y);return S&&k>0||k>=y.width*y.height||k>=C.width*C.height},updateNode:v,updateNodeData:(x,y,S={replace:!1})=>{v(x,_=>{const C=typeof y=="function"?y(_):y;return S.replace?{..._,data:C}:{..._,data:{..._.data,...C}}},S)},updateEdge:m,updateEdgeData:(x,y,S={replace:!1})=>{m(x,_=>{const C=typeof y=="function"?y(_):y;return S.replace?{..._,data:C}:{..._,data:{..._.data,...C}}},S)},getNodesBounds:x=>{const{nodeLookup:y,nodeOrigin:S}=r.getState();return Fw(x,{nodeLookup:y,nodeOrigin:S})},getHandleConnections:({type:x,id:y,nodeId:S})=>{var _;return Array.from(((_=r.getState().connectionLookup.get(`${S}-${x}${y?`-${y}`:""}`))==null?void 0:_.values())??[])},getNodeConnections:({type:x,handleId:y,nodeId:S})=>{var _;return Array.from(((_=r.getState().connectionLookup.get(`${S}${x?y?`-${x}-${y}`:`-${x}`:""}`))==null?void 0:_.values())??[])},fitView:async x=>{const y=r.getState().fitViewResolver??Xw();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:y}),o.nodeQueue.push(S=>[...S]),y.promise}}},[]);return U.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Uh=t=>t.selected,kS=typeof window<"u"?window:void 0;function ES({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Oe(),{deleteElements:l}=hc(),a=yo(t,{actInsideInputWithModifier:!1}),u=yo(r,{target:kS});U.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Uh),edges:d.filter(Uh)}),o.setState({nodesSelectionActive:!1})}},[a]),U.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function NS(t){const r=Oe();U.useEffect(()=>{const o=()=>{var a,u,d,f;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const l=lc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",en.error004())),r.setState({width:l.width||500,height:l.height||500})};if(t.current){o(),window.addEventListener("resize",o);const l=new ResizeObserver(()=>o());return l.observe(t.current),()=>{window.removeEventListener("resize",o),l&&t.current&&l.unobserve(t.current)}}},[])}const El={position:"absolute",width:"100%",height:"100%",top:0,left:0},CS=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function jS({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=wr.Free,zoomOnDoubleClick:f=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:m,minZoom:x,maxZoom:y,zoomActivationKeyCode:S,preventScrolling:_=!0,children:C,noWheelClassName:k,noPanClassName:E,onViewportChange:T,isControlledViewport:N,paneClickDistance:P,selectionOnDrag:O}){const D=Oe(),H=U.useRef(null),{userSelectionActive:F,lib:X,connectionInProgress:ee}=Te(CS,We),q=yo(S),te=U.useRef();NS(H);const J=U.useCallback(j=>{T==null||T({x:j[0],y:j[1],zoom:j[2]}),N||D.setState({transform:j})},[T,N]);return U.useEffect(()=>{if(H.current){te.current=I1({domNode:H.current,minZoom:x,maxZoom:y,translateExtent:m,viewport:v,onDraggingChange:B=>D.setState(A=>A.paneDragging===B?A:{paneDragging:B}),onPanZoomStart:(B,A)=>{const{onViewportChangeStart:L,onMoveStart:b}=D.getState();b==null||b(B,A),L==null||L(A)},onPanZoom:(B,A)=>{const{onViewportChange:L,onMove:b}=D.getState();b==null||b(B,A),L==null||L(A)},onPanZoomEnd:(B,A)=>{const{onViewportChangeEnd:L,onMoveEnd:b}=D.getState();b==null||b(B,A),L==null||L(A)}});const{x:j,y:W,zoom:V}=te.current.getViewport();return D.setState({panZoom:te.current,transform:[j,W,V],domNode:H.current.closest(".react-flow")}),()=>{var B;(B=te.current)==null||B.destroy()}}},[]),U.useEffect(()=>{var j;(j=te.current)==null||j.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:p,zoomActivationKeyPressed:q,preventScrolling:_,noPanClassName:E,userSelectionActive:F,noWheelClassName:k,lib:X,onTransformChange:J,connectionInProgress:ee,selectionOnDrag:O,paneClickDistance:P})},[t,r,o,l,a,u,d,f,p,q,_,E,F,k,X,J,ee,O,P]),g.jsx("div",{className:"react-flow__renderer",ref:H,style:El,children:C})}const MS=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function PS(){const{userSelectionActive:t,userSelectionRect:r}=Te(MS,We);return t&&r?g.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 zu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},IS=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function TS({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ho.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:y,onPaneMouseMove:S,onPaneMouseLeave:_,children:C}){const k=U.useRef(0),E=Oe(),{userSelectionActive:T,elementsSelectable:N,dragging:P,panBy:O,autoPanSpeed:D}=Te(IS,We),H=N&&(t||T),F=U.useRef(null),X=U.useRef(),ee=U.useRef(new Set),q=U.useRef(new Set),te=U.useRef(!1),J=U.useRef(!1),j=U.useRef({x:0,y:0}),W=U.useRef(!1),V=G=>{if(J.current||te.current||E.getState().connection.inProgress){J.current=!1,te.current=!1;return}v==null||v(G),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=G=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){G.preventDefault();return}m==null||m(G)},A=x?G=>x(G):void 0,L=G=>{J.current&&(G.stopPropagation(),J.current=!1)},b=G=>{var Re,nt;if(G.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:he}=E.getState();if(X.current=se==null?void 0:se.getBoundingClientRect(),!X.current)return;const we=G.target===F.current;if(!we&&!!G.target.closest(".nokey")||!t||!(d&&we||r)||G.button!==0||!G.isPrimary)return;(nt=(Re=G.target)==null?void 0:Re.setPointerCapture)==null||nt.call(Re,G.pointerId),J.current=!1;const{x:Ce,y:Me}=Jt(G.nativeEvent,X.current),Pe=No({x:Ce,y:Me},he);E.setState({userSelectionRect:{width:0,height:0,startX:Pe.x,startY:Pe.y,x:Ce,y:Me}}),we||(G.stopPropagation(),G.preventDefault())};function M(G,se){const{userSelectionRect:he}=E.getState();if(!he)return;const{transform:we,nodeLookup:ve,edgeLookup:me,connectionLookup:Ce,triggerNodeChanges:Me,triggerEdgeChanges:Pe,defaultEdgeOptions:Re}=E.getState(),nt={x:he.startX,y:he.startY},{x:rt,y:Xe}=ui(nt,we),Ke={startX:nt.x,startY:nt.y,x:Git.id)),q.current=new Set;const At=(Re==null?void 0:Re.selectable)??!0;for(const it of ee.current){const ft=Ce.get(it);if(ft)for(const{edgeId:lt}of ft.values()){const ht=me.get(lt);ht&&(ht.selectable??At)&&q.current.add(lt)}}if(!gh(Bt,ee.current)){const it=ni(ve,ee.current,!0);Me(it)}if(!gh(Lt,q.current)){const it=ni(me,q.current);Pe(it)}E.setState({userSelectionRect:Ke,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!X.current)return;const[G,se]=oc(j.current,X.current,D);O({x:G,y:se}).then(he=>{if(!J.current||!he){k.current=requestAnimationFrame(z);return}const{x:we,y:ve}=j.current;M(we,ve),k.current=requestAnimationFrame(z)})}const re=()=>{cancelAnimationFrame(k.current),k.current=0,W.current=!1};U.useEffect(()=>()=>re(),[]);const ne=G=>{const{userSelectionRect:se,transform:he,resetSelectedElements:we}=E.getState();if(!X.current||!se)return;const{x:ve,y:me}=Jt(G.nativeEvent,X.current);j.current={x:ve,y:me};const Ce=ui({x:se.startX,y:se.startY},he);if(!J.current){const Me=r?0:u;if(Math.hypot(ve-Ce.x,me-Ce.y)<=Me)return;we(),f==null||f(G)}J.current=!0,W.current||(z(),W.current=!0),M(ve,me)},ae=G=>{var se,he;if(!H){G.target===F.current&&E.getState().connection.inProgress&&(te.current=!0);return}G.button===0&&((he=(se=G.target)==null?void 0:se.releasePointerCapture)==null||he.call(se,G.pointerId),!T&&G.target===F.current&&E.getState().userSelectionRect&&(V==null||V(G)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(p==null||p(G),E.setState({nodesSelectionActive:ee.current.size>0})),re())},de=G=>{var se,he;(he=(se=G.target)==null?void 0:se.releasePointerCapture)==null||he.call(se,G.pointerId),re()},ce=l===!0||Array.isArray(l)&&l.includes(0);return g.jsxs("div",{className:Ge(["react-flow__pane",{draggable:ce,dragging:P,selection:t}]),onClick:H?void 0:zu(V,F),onContextMenu:zu(B,F),onWheel:zu(A,F),onPointerEnter:H?void 0:y,onPointerMove:H?ne:S,onPointerUp:ae,onPointerCancel:H?de:void 0,onPointerDownCapture:H?b:void 0,onClickCapture:H?L:void 0,onPointerLeave:_,ref:F,style:El,children:[C,g.jsx(PS,{})]})}function Qu({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:p}=r.getState(),v=f.get(t);if(!v){p==null||p("012",en.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&d)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Cg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=Oe(),[p,v]=U.useState(!1),m=U.useRef();return U.useEffect(()=>{if(!r)return m.current=m1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Qu({id:x,store:f,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),U.useEffect(()=>{r||!t.current||!m.current||m.current.update({noDragClassName:o,handleSelector:l,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:d})},[o,l,r,u,t,a,d]),p}const zS=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function jg(){const t=Oe();return U.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:p,nodeLookup:v,nodeOrigin:m}=t.getState(),x=new Map,y=zS(d),S=a?u[0]:5,_=a?u[1]:5,C=o.direction.x*S*o.factor,k=o.direction.y*_*o.factor;for(const[,E]of v){if(!y(E))continue;let T={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+k};a&&(T=Eo(T,u));const{position:N,positionAbsolute:P}=Yp({nodeId:E.id,nextPosition:T,nodeLookup:v,nodeExtent:l,nodeOrigin:m,onError:f});E.position=N,E.internals.positionAbsolute=P,x.set(E.id,E)}p(x)},[])}const pc=U.createContext(null),RS=pc.Provider;pc.Consumer;const Mg=()=>U.useContext(pc),LS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Pg=U.createContext(null);function AS({children:t}){const r=Te(LS,We);return g.jsx(Pg.Provider,{value:r,children:t})}function DS(){const t=U.useContext(Pg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const $S={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},bS=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:p,isValid:v}=d;if(!f&&!a)return $S;const m=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===li.Strict?(f==null?void 0:f.type)!==o:t!==(f==null?void 0:f.nodeId)||r!==(f==null?void 0:f.id),connectionInProcess:!!f,clickConnectionInProcess:!!a,valid:m&&v}};function OS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:p,className:v,onMouseDown:m,onTouchStart:x,...y},S){var W,V;const _=d||null,C=t==="target",k=Oe(),E=Mg(),{connectOnClick:T,noPanClassName:N,rfId:P}=DS(),{connectingFrom:O,connectingTo:D,clickConnecting:H,isPossibleEndHandle:F,connectionInProcess:X,clickConnectionInProcess:ee,valid:q}=Te(bS(E,_,t),We);E||(V=(W=k.getState()).onError)==null||V.call(W,"010",en.error010());const te=B=>{const{defaultEdgeOptions:A,onConnect:L,hasDefaultEdges:b}=k.getState(),M={...A,...B};if(b){const{edges:z,setEdges:re,onError:ne}=k.getState();re(yS(M,z,{onError:ne}))}L==null||L(M),f==null||f(M)},J=B=>{if(!E)return;const A=tg(B.nativeEvent);if(a&&(A&&B.button===0||!A)){const L=k.getState();Xu.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:C,handleId:_,nodeId:E,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...b)=>{var M,z;return(z=(M=k.getState()).onConnectEnd)==null?void 0:z.call(M,...b)},updateConnection:L.updateConnection,onConnect:te,isValidConnection:o||((...b)=>{var M,z;return((z=(M=k.getState()).isValidConnection)==null?void 0:z.call(M,...b))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}A?m==null||m(B):x==null||x(B)},j=B=>{const{onClickConnectStart:A,onClickConnectEnd:L,connectionClickStartHandle:b,connectionMode:M,isValidConnection:z,lib:re,rfId:ne,nodeLookup:ae,connection:de}=k.getState();if(!E||!b&&!a)return;if(!b){A==null||A(B.nativeEvent,{nodeId:E,handleId:_,handleType:t}),k.setState({connectionClickStartHandle:{nodeId:E,type:t,id:_}});return}const ce=Jp(B.target),G=o||z,{connection:se,isValid:he}=Xu.isValid(B.nativeEvent,{handle:{nodeId:E,id:_,type:t},connectionMode:M,fromNodeId:b.nodeId,fromHandleId:b.id||null,fromType:b.type,isValidConnection:G,flowId:ne,doc:ce,lib:re,nodeLookup:ae});he&&se&&te(se);const we=structuredClone(de);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,L==null||L(B,we),k.setState({connectionClickStartHandle:null})};return g.jsx("div",{"data-handleid":_,"data-nodeid":E,"data-handlepos":r,"data-id":`${P}-${E}-${_}-${t}`,className:Ge(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,v,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:O,connectingto:D,valid:q,connectionindicator:l&&(!X||F)&&(X||ee?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:T?j:void 0,ref:S,...y,children:p})}const di=U.memo(kg(OS));function FS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return g.jsxs(g.Fragment,{children:[t==null?void 0:t.label,g.jsx(di,{type:"source",position:o,isConnectable:r})]})}function HS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(di,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,g.jsx(di,{type:"source",position:l,isConnectable:r})]})}function VS(){return null}function BS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(di,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const fl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Yh={input:FS,default:HS,output:BS,group:VS};function WS(t){var r,o,l,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((l=t.style)==null?void 0:l.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const US=t=>{const{width:r,height:o,x:l,y:a}=ko(t.nodeLookup,{filter:u=>!!u.selected});return{width:Zt(r)?r:null,height:Zt(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${l}px,${a}px)`}};function YS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=Oe(),{width:a,height:u,transformString:d,userSelectionActive:f}=Te(US,We),p=jg(),v=U.useRef(null);U.useEffect(()=>{var S;o||(S=v.current)==null||S.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Cg({nodeRef:v,disabled:!m}),!m)return null;const x=t?S=>{const _=l.getState().nodes.filter(C=>C.selected);t(S,_)}:void 0,y=S=>{Object.prototype.hasOwnProperty.call(fl,S.key)&&(S.preventDefault(),p({direction:fl[S.key],factor:S.shiftKey?4:1}))};return g.jsx("div",{className:Ge(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:g.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:y,style:{width:a,height:u}})})}const Xh=typeof window<"u"?window:void 0,XS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Ig({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:m,selectionMode:x,onSelectionStart:y,onSelectionEnd:S,multiSelectionKeyCode:_,panActivationKeyCode:C,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:P,panOnScrollSpeed:O,panOnScrollMode:D,zoomOnDoubleClick:H,panOnDrag:F,autoPanOnSelection:X,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,preventScrolling:j,onSelectionContextMenu:W,noWheelClassName:V,noPanClassName:B,disableKeyboardA11y:A,onViewportChange:L,isControlledViewport:b}){const{nodesSelectionActive:M,userSelectionActive:z}=Te(XS,We),re=yo(v,{target:Xh}),ne=yo(C,{target:Xh}),ae=ne||F,de=ne||P,ce=m&&ae!==!0,G=re||z||ce;return ES({deleteKeyCode:p,multiSelectionKeyCode:_}),g.jsx(jS,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:de,panActivationKeyPressed:ne,panOnScrollSpeed:O,panOnScrollMode:D,zoomOnDoubleClick:H,panOnDrag:!re&&ae,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,zoomActivationKeyCode:k,preventScrolling:j,noWheelClassName:V,noPanClassName:B,onViewportChange:L,isControlledViewport:b,paneClickDistance:f,selectionOnDrag:ce,children:g.jsxs(TS,{onSelectionStart:y,onSelectionEnd:S,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ae,autoPanOnSelection:X,isSelecting:!!G,selectionMode:x,selectionKeyPressed:re,paneClickDistance:f,selectionOnDrag:ce,children:[t,M&&g.jsx(YS,{onSelectionContextMenu:W,noPanClassName:B,disableKeyboardA11y:A})]})})}Ig.displayName="FlowRenderer";const QS=U.memo(Ig),GS=t=>r=>t?ic(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function KS(t){return Te(U.useCallback(GS(t),[t]),We)}const qS=t=>t.updateNodeInternals;function ZS(){const t=Te(qS),[r]=U.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const l=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");l.set(u,{id:u,nodeElement:a.target,force:!0})}),t(l)}));return U.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function JS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=Oe(),u=U.useRef(null),d=U.useRef(null),f=U.useRef(t.sourcePosition),p=U.useRef(t.targetPosition),v=U.useRef(r),m=o&&!!t.internals.handleBounds;return U.useEffect(()=>{u.current&&!t.hidden&&(!m||d.current!==u.current)&&(d.current&&(l==null||l.unobserve(d.current)),l==null||l.observe(u.current),d.current=u.current)},[m,t.hidden]),U.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),U.useEffect(()=>{if(u.current){const x=v.current!==r,y=f.current!==t.sourcePosition,S=p.current!==t.targetPosition;(x||y||S)&&(v.current=r,f.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function e_({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:p,nodesConnectable:v,nodesFocusable:m,resizeObserver:x,noDragClassName:y,noPanClassName:S,disableKeyboardA11y:_,rfId:C,nodeTypes:k,nodeClickDistance:E,onError:T}){const{node:N,internals:P,isParent:O}=Te(G=>{const se=G.nodeLookup.get(t),he=G.parentLookup.has(t);return{node:se,internals:se.internals,isParent:he}},We);let D=N.type||"default",H=(k==null?void 0:k[D])||Yh[D];H===void 0&&(T==null||T("003",en.error003(D)),D="default",H=(k==null?void 0:k.default)||Yh.default);const F=!!(N.draggable||f&&typeof N.draggable>"u"),X=!!(N.selectable||p&&typeof N.selectable>"u"),ee=!!(N.connectable||v&&typeof N.connectable>"u"),q=!!(N.focusable||m&&typeof N.focusable>"u"),te=Oe(),J=qp(N),j=JS({node:N,nodeType:D,hasDimensions:J,resizeObserver:x}),W=Cg({nodeRef:j,disabled:N.hidden||!F,noDragClassName:y,handleSelector:N.dragHandle,nodeId:t,isSelectable:X,nodeClickDistance:E}),V=jg();if(N.hidden)return null;const B=nn(N),A=WS(N),L=X||F||r||o||l||a,b=o?G=>o(G,{...P.userNode}):void 0,M=l?G=>l(G,{...P.userNode}):void 0,z=a?G=>a(G,{...P.userNode}):void 0,re=u?G=>u(G,{...P.userNode}):void 0,ne=d?G=>d(G,{...P.userNode}):void 0,ae=G=>{const{selectNodesOnDrag:se,nodeDragThreshold:he}=te.getState();X&&(!se||!F||he>0)&&Qu({id:t,store:te,nodeRef:j}),r&&r(G,{...P.userNode})},de=G=>{if(!(eg(G.nativeEvent)||_)){if(Hp.includes(G.key)&&X){const se=G.key==="Escape";Qu({id:t,store:te,unselect:se,nodeRef:j})}else if(F&&N.selected&&Object.prototype.hasOwnProperty.call(fl,G.key)){G.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:G.key.replace("Arrow","").toLowerCase(),x:~~P.positionAbsolute.x,y:~~P.positionAbsolute.y})}),V({direction:fl[G.key],factor:G.shiftKey?4:1})}}},ce=()=>{var Ce;if(_||!((Ce=j.current)!=null&&Ce.matches(":focus-visible")))return;const{transform:G,width:se,height:he,autoPanOnNodeFocus:we,setCenter:ve}=te.getState();if(!we)return;ic(new Map([[t,N]]),{x:0,y:0,width:se,height:he},G,!0).length>0||ve(N.position.x+B.width/2,N.position.y+B.height/2,{zoom:G[2]})};return g.jsx("div",{className:Ge(["react-flow__node",`react-flow__node-${D}`,{[S]:F},N.className,{selected:N.selected,selectable:X,parent:O,draggable:F,dragging:W}]),ref:j,style:{zIndex:P.z,transform:`translate(${P.positionAbsolute.x}px,${P.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:J?"visible":"hidden",...N.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:b,onMouseMove:M,onMouseLeave:z,onContextMenu:re,onClick:ae,onDoubleClick:ne,onKeyDown:q?de:void 0,tabIndex:q?0:void 0,onFocus:q?ce:void 0,role:N.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":_?void 0:`${xg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:g.jsx(RS,{value:t,children:g.jsx(H,{id:t,data:N.data,type:D,positionAbsoluteX:P.positionAbsolute.x,positionAbsoluteY:P.positionAbsolute.y,selected:N.selected??!1,selectable:X,draggable:F,deletable:N.deletable??!0,isConnectable:ee,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:W,dragHandle:N.dragHandle,zIndex:P.z,parentId:N.parentId,...B})})})}var t_=U.memo(e_);const n_=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Tg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Te(n_,We),u=KS(t.onlyRenderVisibleElements),d=ZS();return g.jsx("div",{className:"react-flow__nodes",style:El,children:u.map(f=>g.jsx(t_,{id:f,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:d,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,nodeClickDistance:t.nodeClickDistance,onError:a},f))})}Tg.displayName="NodeRenderer";const r_=U.memo(Tg);function i_(t){return Te(U.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const l=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),d=o.nodeLookup.get(a.target);u&&d&&qw({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),We)}const o_=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return g.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},s_=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return g.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Qh={[po.Arrow]:o_,[po.ArrowClosed]:s_};function l_(t){const r=Oe();return U.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Qh,t)?Qh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",en.error009(t)),null)},[t])}const a_=({id:t,type:r,color:o,width:l=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:d,orient:f="auto-start-reverse"})=>{const p=l_(r);return p?g.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:f,refX:"0",refY:"0",children:g.jsx(p,{color:o,strokeWidth:d})}):null},zg=({defaultColor:t,rfId:r})=>{const o=Te(u=>u.edges),l=Te(u=>u.defaultEdgeOptions),a=U.useMemo(()=>o1(o,{id:r,defaultColor:t,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[o,l,r,t]);return a.length?g.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:g.jsx("defs",{children:a.map(u=>g.jsx(a_,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};zg.displayName="MarkerDefinitions";var u_=U.memo(zg);function Rg({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:p,className:v,...m}){const[x,y]=U.useState({x:1,y:0,width:0,height:0}),S=Ge(["react-flow__edge-textwrapper",v]),_=U.useRef(null);return U.useEffect(()=>{if(_.current){const C=_.current.getBBox();y({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?g.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:S,visibility:x.width?"visible":"hidden",...m,children:[a&&g.jsx("rect",{width:x.width+2*d[0],x:-d[0],y:-d[1],height:x.height+2*d[1],className:"react-flow__edge-textbg",style:u,rx:f,ry:f}),g.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:_,style:l,children:o}),p]}):null}Rg.displayName="EdgeText";const c_=U.memo(Rg);function Nl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,interactionWidth:v=20,...m}){return g.jsxs(g.Fragment,{children:[g.jsx("path",{...m,d:t,fill:"none",className:Ge(["react-flow__edge-path",m.className])}),v?g.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,l&&Zt(r)&&Zt(o)?g.jsx(c_,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p}):null]})}function Gh({pos:t,x1:r,y1:o,x2:l,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+l),o]:[r,.5*(o+a)]}function Lg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Gh({pos:o,x1:t,y1:r,x2:l,y2:a}),[p,v]=Gh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,y,S]=ng({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:p,targetControlY:v});return[`M${t},${r} C${d},${f} ${p},${v} ${l},${a}`,m,x,y,S]}function Ag(t){return U.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:y,labelBgBorderRadius:S,style:_,markerEnd:C,markerStart:k,interactionWidth:E})=>{const[T,N,P]=Lg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),O=t.isInternal?void 0:r;return g.jsx(Nl,{id:O,path:T,labelX:N,labelY:P,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:y,labelBgBorderRadius:S,style:_,markerEnd:C,markerStart:k,interactionWidth:E})})}const d_=Ag({isInternal:!1}),Dg=Ag({isInternal:!0});d_.displayName="SimpleBezierEdge";Dg.displayName="SimpleBezierEdgeInternal";function $g(t){return U.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:y,sourcePosition:S=Se.Bottom,targetPosition:_=Se.Top,markerEnd:C,markerStart:k,pathOptions:E,interactionWidth:T})=>{const[N,P,O]=Wu({sourceX:o,sourceY:l,sourcePosition:S,targetX:a,targetY:u,targetPosition:_,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),D=t.isInternal?void 0:r;return g.jsx(Nl,{id:D,path:N,labelX:P,labelY:O,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:y,markerEnd:C,markerStart:k,interactionWidth:T})})}const bg=$g({isInternal:!1}),Og=$g({isInternal:!0});bg.displayName="SmoothStepEdge";Og.displayName="SmoothStepEdgeInternal";function Fg(t){return U.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return g.jsx(bg,{...o,id:l,pathOptions:U.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const f_=Fg({isInternal:!1}),Hg=Fg({isInternal:!0});f_.displayName="StepEdge";Hg.displayName="StepEdgeInternal";function Vg(t){return U.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:_,interactionWidth:C})=>{const[k,E,T]=og({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return g.jsx(Nl,{id:N,path:k,labelX:E,labelY:T,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:_,interactionWidth:C})})}const h_=Vg({isInternal:!1}),Bg=Vg({isInternal:!0});h_.displayName="StraightEdge";Bg.displayName="StraightEdgeInternal";function Wg(t){return U.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:y,labelBgBorderRadius:S,style:_,markerEnd:C,markerStart:k,pathOptions:E,interactionWidth:T})=>{const[N,P,O]=rg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),D=t.isInternal?void 0:r;return g.jsx(Nl,{id:D,path:N,labelX:P,labelY:O,label:p,labelStyle:v,labelShowBg:m,labelBgStyle:x,labelBgPadding:y,labelBgBorderRadius:S,style:_,markerEnd:C,markerStart:k,interactionWidth:T})})}const p_=Wg({isInternal:!1}),Ug=Wg({isInternal:!0});p_.displayName="BezierEdge";Ug.displayName="BezierEdgeInternal";const Kh={default:Ug,straight:Bg,step:Hg,smoothstep:Og,simplebezier:Dg},qh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},g_=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,m_=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,Zh="react-flow__edgeupdater";function Jh({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return g.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:Ge([Zh,`${Zh}-${f}`]),cx:g_(r,l,t),cy:m_(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function y_({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:p,onReconnect:v,onReconnectStart:m,onReconnectEnd:x,setReconnecting:y,setUpdateHover:S}){const _=Oe(),C=(P,O)=>{if(P.button!==0)return;const{autoPanOnConnect:D,domNode:H,connectionMode:F,connectionRadius:X,lib:ee,onConnectStart:q,cancelConnection:te,nodeLookup:J,rfId:j,panBy:W,updateConnection:V}=_.getState(),B=O.type==="target",A=(M,z)=>{y(!1),x==null||x(M,o,O.type,z)},L=M=>v==null?void 0:v(o,M),b=(M,z)=>{y(!0),m==null||m(P,o,O.type),q==null||q(M,z)};Xu.onPointerDown(P.nativeEvent,{autoPanOnConnect:D,connectionMode:F,connectionRadius:X,domNode:H,handleId:O.id,nodeId:O.nodeId,nodeLookup:J,isTarget:B,edgeUpdaterType:O.type,lib:ee,flowId:j,cancelConnection:te,panBy:W,isValidConnection:(...M)=>{var z,re;return((re=(z=_.getState()).isValidConnection)==null?void 0:re.call(z,...M))??!0},onConnect:L,onConnectStart:b,onConnectEnd:(...M)=>{var z,re;return(re=(z=_.getState()).onConnectEnd)==null?void 0:re.call(z,...M)},onReconnectEnd:A,updateConnection:V,getTransform:()=>_.getState().transform,getFromHandle:()=>_.getState().connection.fromHandle,dragThreshold:_.getState().connectionDragThreshold,handleDomNode:P.currentTarget})},k=P=>C(P,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=P=>C(P,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),T=()=>S(!0),N=()=>S(!1);return g.jsxs(g.Fragment,{children:[(t===!0||t==="source")&&g.jsx(Jh,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:k,onMouseEnter:T,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&g.jsx(Jh,{position:p,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:T,onMouseOut:N,type:"target"})]})}function v_({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:p,onMouseLeave:v,reconnectRadius:m,onReconnect:x,onReconnectStart:y,onReconnectEnd:S,rfId:_,edgeTypes:C,noPanClassName:k,onError:E,disableKeyboardA11y:T}){let N=Te(ve=>ve.edgeLookup.get(t));const P=Te(ve=>ve.defaultEdgeOptions);N=P?{...P,...N}:N;let O=N.type||"default",D=(C==null?void 0:C[O])||Kh[O];D===void 0&&(E==null||E("011",en.error011(O)),O="default",D=(C==null?void 0:C.default)||Kh.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),F=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),X=!!(N.selectable||l&&typeof N.selectable>"u"),ee=U.useRef(null),[q,te]=U.useState(!1),[J,j]=U.useState(!1),W=Oe(),{zIndex:V=N.zIndex,sourceX:B,sourceY:A,targetX:L,targetY:b,sourcePosition:M,targetPosition:z}=Te(U.useCallback(ve=>{const me=ve.nodeLookup.get(N.source),Ce=ve.nodeLookup.get(N.target);if(!me||!Ce)return qh;const Me=i1({id:t,sourceNode:me,targetNode:Ce,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Pe=Kw({selected:N.selected,zIndex:N.zIndex,sourceNode:me,targetNode:Ce,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||qh,zIndex:Pe}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),We),re=U.useMemo(()=>N.markerStart?`url('#${Uu(N.markerStart,_)}')`:void 0,[N.markerStart,_]),ne=U.useMemo(()=>N.markerEnd?`url('#${Uu(N.markerEnd,_)}')`:void 0,[N.markerEnd,_]);if(N.hidden||B===null||A===null||L===null||b===null)return null;const ae=ve=>{var Pe;const{addSelectedEdges:me,unselectNodesAndEdges:Ce,multiSelectionActive:Me}=W.getState();X&&(W.setState({nodesSelectionActive:!1}),N.selected&&Me?(Ce({nodes:[],edges:[N]}),(Pe=ee.current)==null||Pe.blur()):me([t])),a&&a(ve,N)},de=u?ve=>{u(ve,{...N})}:void 0,ce=d?ve=>{d(ve,{...N})}:void 0,G=f?ve=>{f(ve,{...N})}:void 0,se=p?ve=>{p(ve,{...N})}:void 0,he=v?ve=>{v(ve,{...N})}:void 0,we=ve=>{var me;if(!T&&Hp.includes(ve.key)&&X){const{unselectNodesAndEdges:Ce,addSelectedEdges:Me}=W.getState();ve.key==="Escape"?((me=ee.current)==null||me.blur(),Ce({edges:[N]})):Me([t])}};return g.jsx("svg",{style:{zIndex:V},children:g.jsxs("g",{className:Ge(["react-flow__edge",`react-flow__edge-${O}`,N.className,k,{selected:N.selected,animated:N.animated,inactive:!X&&!a,updating:q,selectable:X}]),onClick:ae,onDoubleClick:de,onContextMenu:ce,onMouseEnter:G,onMouseMove:se,onMouseLeave:he,onKeyDown:H?we:void 0,tabIndex:H?0:void 0,role:N.ariaRole??(H?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":H?`${wg}-${_}`:void 0,ref:ee,...N.domAttributes,children:[!J&&g.jsx(D,{id:t,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:X,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:B,sourceY:A,targetX:L,targetY:b,sourcePosition:M,targetPosition:z,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:re,markerEnd:ne,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),F&&g.jsx(y_,{edge:N,isReconnectable:F,reconnectRadius:m,onReconnect:x,onReconnectStart:y,onReconnectEnd:S,sourceX:B,sourceY:A,targetX:L,targetY:b,sourcePosition:M,targetPosition:z,setUpdateHover:te,setReconnecting:j})]})})}var x_=U.memo(v_);const w_=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function Yg({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:y,onReconnectStart:S,onReconnectEnd:_,disableKeyboardA11y:C}){const{edgesFocusable:k,edgesReconnectable:E,elementsSelectable:T,onError:N}=Te(w_,We),P=i_(r);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(u_,{defaultColor:t,rfId:o}),P.map(O=>g.jsx(x_,{id:O,edgesFocusable:k,edgesReconnectable:E,elementsSelectable:T,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:p,onMouseLeave:v,onClick:m,reconnectRadius:x,onDoubleClick:y,onReconnectStart:S,onReconnectEnd:_,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},O))]})}Yg.displayName="EdgeRenderer";const S_=U.memo(Yg),ep=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function __({children:t}){const r=Oe(),o=U.useRef(null),[l]=U.useState(()=>r.getState().transform);return Eg(()=>{let a=null;const u=()=>{const d=r.getState().transform;a&&d[0]===a[0]&&d[1]===a[1]&&d[2]===a[2]||(a=d,o.current&&(o.current.style.transform=ep(d)))};return u(),r.subscribe(u)},[r]),g.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ep(l)},children:t})}function k_(t){const r=hc(),o=U.useRef(!1);U.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const E_=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function N_(t){const r=Te(E_),o=Oe();return U.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function C_(t){return t.connection.inProgress?{...t.connection,to:No(t.connection.to,t.transform)}:{...t.connection}}function j_(t){return C_}function M_(t){const r=j_();return Te(r,We)}const P_=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function I_({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:p}=Te(P_,We);return!(u&&a&&p)?null:g.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:g.jsx("g",{className:Ge(["react-flow__connection",Wp(f)]),children:g.jsx(Xg,{style:r,type:o,CustomComponent:l,isValid:f})})})}const Xg=({style:t,type:r=qn.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:p,to:v,toNode:m,toHandle:x,toPosition:y,pointer:S}=M_();if(!a)return;if(o)return g.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:y,connectionStatus:Wp(l),toNode:m,toHandle:x,pointer:S});let _="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:y};switch(r){case qn.Bezier:[_]=rg(C);break;case qn.SimpleBezier:[_]=Lg(C);break;case qn.Step:[_]=Wu({...C,borderRadius:0});break;case qn.SmoothStep:[_]=Wu(C);break;default:[_]=og(C)}return g.jsx("path",{d:_,fill:"none",className:"react-flow__connection-path",style:t})};Xg.displayName="ConnectionLine";const T_={};function tp(t=T_){U.useRef(t),Oe(),U.useEffect(()=>{},[t])}function z_(){Oe(),U.useRef(!1),U.useEffect(()=>{},[])}function Qg({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:y,onSelectionEnd:S,connectionLineType:_,connectionLineStyle:C,connectionLineComponent:k,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:N,selectionMode:P,multiSelectionKeyCode:O,panActivationKeyCode:D,zoomActivationKeyCode:H,deleteKeyCode:F,onlyRenderVisibleElements:X,elementsSelectable:ee,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:j,preventScrolling:W,defaultMarkerColor:V,zoomOnScroll:B,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:b,panOnScrollMode:M,zoomOnDoubleClick:z,panOnDrag:re,autoPanOnSelection:ne,onPaneClick:ae,onPaneMouseEnter:de,onPaneMouseMove:ce,onPaneMouseLeave:G,onPaneScroll:se,onPaneContextMenu:he,paneClickDistance:we,nodeClickDistance:ve,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Me,onEdgeMouseLeave:Pe,reconnectRadius:Re,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:Xe,noDragClassName:Ke,noWheelClassName:Bt,noPanClassName:Lt,disableKeyboardA11y:At,nodeExtent:it,rfId:ft,viewport:lt,onViewportChange:ht,nodesDraggable:hn}){return tp(t),tp(r),z_(),k_(o),N_(lt),g.jsx(QS,{onPaneClick:ae,onPaneMouseEnter:de,onPaneMouseMove:ce,onPaneMouseLeave:G,onPaneContextMenu:he,onPaneScroll:se,paneClickDistance:we,deleteKeyCode:F,selectionKeyCode:T,selectionOnDrag:N,selectionMode:P,onSelectionStart:y,onSelectionEnd:S,multiSelectionKeyCode:O,panActivationKeyCode:D,zoomActivationKeyCode:H,elementsSelectable:ee,zoomOnScroll:B,zoomOnPinch:A,zoomOnDoubleClick:z,panOnScroll:L,panOnScrollSpeed:b,panOnScrollMode:M,panOnDrag:re,autoPanOnSelection:ne,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:j,onSelectionContextMenu:x,preventScrolling:W,noDragClassName:Ke,noWheelClassName:Bt,noPanClassName:Lt,disableKeyboardA11y:At,onViewportChange:ht,isControlledViewport:!!lt,children:g.jsxs(__,{children:[g.jsx(S_,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:nt,onReconnectStart:rt,onReconnectEnd:Xe,onlyRenderVisibleElements:X,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Me,onEdgeMouseLeave:Pe,reconnectRadius:Re,defaultMarkerColor:V,noPanClassName:Lt,disableKeyboardA11y:At,rfId:ft}),g.jsx(I_,{style:C,type:_,component:k,containerStyle:E}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx(r_,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:m,nodeClickDistance:ve,onlyRenderVisibleElements:X,noPanClassName:Lt,noDragClassName:Ke,disableKeyboardA11y:At,nodeExtent:it,rfId:ft,nodesDraggable:hn}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}Qg.displayName="GraphView";const R_=U.memo(Qg),L_=Kp(),np=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:p=.5,maxZoom:v=2,nodeOrigin:m,nodeExtent:x,zIndexMode:y="basic"}={})=>{const S=new Map,_=new Map,C=new Map,k=new Map,E=l??r??[],T=o??t??[],N=m??[0,0],P=x??fo;ag(C,k,E);const{nodesInitialized:O}=Yu(T,S,_,{nodeOrigin:N,nodeExtent:P,zIndexMode:y});let D=[0,0,1];if(d&&a&&u){const H=ko(S,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:F,y:X,zoom:ee}=sc(H,a,u,p,v,(f==null?void 0:f.padding)??.1);D=[F,X,ee]}return{rfId:"1",width:a??0,height:u??0,transform:D,nodes:T,nodesInitialized:O,nodeLookup:S,parentLookup:_,edges:E,edgeLookup:k,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:fo,nodeExtent:P,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:li.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:f,fitViewResolver:null,connection:{...Bp},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:Vp,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},A_=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:p,maxZoom:v,nodeOrigin:m,nodeExtent:x,zIndexMode:y})=>X1((S,_)=>{async function C(){const{nodeLookup:k,panZoom:E,fitViewOptions:T,fitViewResolver:N,width:P,height:O,minZoom:D,maxZoom:H}=_();E&&(await Bw({nodes:k,width:P,height:O,panZoom:E,minZoom:D,maxZoom:H},T),N==null||N.resolve(!0),S({fitViewResolver:null}))}return{...np({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:p,maxZoom:v,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:y}),setNodes:k=>{const{nodeLookup:E,parentLookup:T,nodeOrigin:N,nodeExtent:P,elevateNodesOnSelect:O,fitViewQueued:D,zIndexMode:H,nodesSelectionActive:F}=_(),{nodesInitialized:X,hasSelectedNodes:ee}=Yu(k,E,T,{nodeOrigin:N,nodeExtent:P,elevateNodesOnSelect:O,checkEquality:!0,zIndexMode:H}),q=F&ⅇD&&X?(C(),S({nodes:k,nodesInitialized:X,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):S({nodes:k,nodesInitialized:X,nodesSelectionActive:q})},setEdges:k=>{const{connectionLookup:E,edgeLookup:T}=_();ag(E,T,k),S({edges:k})},setDefaultNodesAndEdges:(k,E)=>{if(k){const{setNodes:T}=_();T(k),S({hasDefaultNodes:!0})}if(E){const{setEdges:T}=_();T(E),S({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:E,nodeLookup:T,parentLookup:N,domNode:P,nodeOrigin:O,nodeExtent:D,debug:H,fitViewQueued:F,zIndexMode:X}=_(),{changes:ee,updatedInternals:q}=f1(k,T,N,P,O,D,X);q&&(a1(T,N,{nodeOrigin:O,nodeExtent:D,zIndexMode:X}),F?(C(),S({fitViewQueued:!1,fitViewOptions:void 0})):S({}),(ee==null?void 0:ee.length)>0&&(H&&console.log("React Flow: trigger node changes",ee),E==null||E(ee)))},updateNodePositions:(k,E=!1)=>{const T=[];let N=[];const{nodeLookup:P,triggerNodeChanges:O,connection:D,updateConnection:H,onNodesChangeMiddlewareMap:F}=_();for(const[X,ee]of k){const q=P.get(X),te=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(ee!=null&&ee.position)),J={id:X,type:"position",position:te?{x:Math.max(0,ee.position.x),y:Math.max(0,ee.position.y)}:ee.position,dragging:E};if(q&&D.inProgress&&D.fromNode.id===q.id){const j=Nr(q,D.fromHandle,Se.Left,!0);H({...D,from:j})}te&&q.parentId&&T.push({id:X,parentId:q.parentId,rect:{...ee.internals.positionAbsolute,width:ee.measured.width??0,height:ee.measured.height??0}}),N.push(J)}if(T.length>0){const{parentLookup:X,nodeOrigin:ee}=_(),q=fc(T,P,X,ee);N.push(...q)}for(const X of F.values())N=X(N);O(N)},triggerNodeChanges:k=>{const{onNodesChange:E,setNodes:T,nodes:N,hasDefaultNodes:P,debug:O}=_();if(k!=null&&k.length){if(P){const D=pS(k,N);T(D)}O&&console.log("React Flow: trigger node changes",k),E==null||E(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:E,setEdges:T,edges:N,hasDefaultEdges:P,debug:O}=_();if(k!=null&&k.length){if(P){const D=gS(k,N);T(D)}O&&console.log("React Flow: trigger edge changes",k),E==null||E(k)}},addSelectedNodes:k=>{const{multiSelectionActive:E,edgeLookup:T,nodeLookup:N,triggerNodeChanges:P,triggerEdgeChanges:O}=_();if(E){const D=k.map(H=>yr(H,!0));P(D);return}P(ni(N,new Set([...k]),!0)),O(ni(T))},addSelectedEdges:k=>{const{multiSelectionActive:E,edgeLookup:T,nodeLookup:N,triggerNodeChanges:P,triggerEdgeChanges:O}=_();if(E){const D=k.map(H=>yr(H,!0));O(D);return}O(ni(T,new Set([...k]))),P(ni(N,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:E}={})=>{const{edges:T,nodes:N,nodeLookup:P,triggerNodeChanges:O,triggerEdgeChanges:D}=_(),H=k||N,F=E||T,X=[];for(const q of H){if(!q.selected)continue;const te=P.get(q.id);te&&(te.selected=!1),X.push(yr(q.id,!1))}const ee=[];for(const q of F)q.selected&&ee.push(yr(q.id,!1));O(X),D(ee)},setMinZoom:k=>{const{panZoom:E,maxZoom:T}=_();E==null||E.setScaleExtent([k,T]),S({minZoom:k})},setMaxZoom:k=>{const{panZoom:E,minZoom:T}=_();E==null||E.setScaleExtent([T,k]),S({maxZoom:k})},setTranslateExtent:k=>{var E;(E=_().panZoom)==null||E.setTranslateExtent(k),S({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:E,triggerNodeChanges:T,triggerEdgeChanges:N,elementsSelectable:P}=_();if(!P)return;const O=E.reduce((H,F)=>F.selected?[...H,yr(F.id,!1)]:H,[]),D=k.reduce((H,F)=>F.selected?[...H,yr(F.id,!1)]:H,[]);T(O),N(D)},setNodeExtent:k=>{const{nodes:E,nodeLookup:T,parentLookup:N,nodeOrigin:P,elevateNodesOnSelect:O,nodeExtent:D,zIndexMode:H}=_();k[0][0]===D[0][0]&&k[0][1]===D[0][1]&&k[1][0]===D[1][0]&&k[1][1]===D[1][1]||(Yu(E,T,N,{nodeOrigin:P,nodeExtent:k,elevateNodesOnSelect:O,checkEquality:!1,zIndexMode:H}),S({nodeExtent:k}))},panBy:k=>{const{transform:E,width:T,height:N,panZoom:P,translateExtent:O}=_();return h1({delta:k,panZoom:P,transform:E,translateExtent:O,width:T,height:N})},setCenter:async(k,E,T)=>{const{width:N,height:P,maxZoom:O,panZoom:D}=_();if(!D)return!1;const H=typeof(T==null?void 0:T.zoom)<"u"?T.zoom:O;return await D.setViewport({x:N/2-k*H,y:P/2-E*H,zoom:H},{duration:T==null?void 0:T.duration,ease:T==null?void 0:T.ease,interpolate:T==null?void 0:T.interpolate}),!0},cancelConnection:()=>{S({connection:{...Bp}})},updateConnection:k=>{S({connection:k})},reset:()=>S({...np()})}},Object.is);function Gg({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:p,fitView:v,nodeOrigin:m,nodeExtent:x,zIndexMode:y,children:S}){const[_]=U.useState(()=>A_({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:v,minZoom:d,maxZoom:f,fitViewOptions:p,nodeOrigin:m,nodeExtent:x,zIndexMode:y}));return g.jsx(Q1,{value:_,children:g.jsx(wS,{children:g.jsx(AS,{children:S})})})}function D_({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:p,minZoom:v,maxZoom:m,nodeOrigin:x,nodeExtent:y,zIndexMode:S}){return U.useContext(_l)?g.jsx(g.Fragment,{children:t}):g.jsx(Gg,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:m,nodeOrigin:x,nodeExtent:y,zIndexMode:S,children:t})}const $_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function b_({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:p,onInit:v,onMove:m,onMoveStart:x,onMoveEnd:y,onConnect:S,onConnectStart:_,onConnectEnd:C,onClickConnectStart:k,onClickConnectEnd:E,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:P,onNodeContextMenu:O,onNodeDoubleClick:D,onNodeDragStart:H,onNodeDrag:F,onNodeDragStop:X,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onSelectionChange:J,onSelectionDragStart:j,onSelectionDrag:W,onSelectionDragStop:V,onSelectionContextMenu:B,onSelectionStart:A,onSelectionEnd:L,onBeforeDelete:b,connectionMode:M,connectionLineType:z=qn.Bezier,connectionLineStyle:re,connectionLineComponent:ne,connectionLineContainerStyle:ae,deleteKeyCode:de="Backspace",selectionKeyCode:ce="Shift",selectionOnDrag:G=!1,selectionMode:se=ho.Full,panActivationKeyCode:he="Space",multiSelectionKeyCode:we=mo()?"Meta":"Control",zoomActivationKeyCode:ve=mo()?"Meta":"Control",snapToGrid:me,snapGrid:Ce,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Pe,nodesDraggable:Re,autoPanOnNodeFocus:nt,nodesConnectable:rt,nodesFocusable:Xe,nodeOrigin:Ke=Sg,edgesFocusable:Bt,edgesReconnectable:Lt,elementsSelectable:At=!0,defaultViewport:it=lS,minZoom:ft=.5,maxZoom:lt=2,translateExtent:ht=fo,preventScrolling:hn=!0,nodeExtent:Dt,defaultMarkerColor:rn="#b1b1b7",zoomOnScroll:Z=!0,zoomOnPinch:Ee=!0,panOnScroll:De=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:mt=wr.Free,zoomOnDoubleClick:fi=!0,panOnDrag:hi=!0,onPaneClick:pi,onPaneMouseEnter:gi,onPaneMouseMove:jn,onPaneMouseLeave:Mn,onPaneScroll:Co,onPaneContextMenu:jo,paneClickDistance:Mo=1,nodeClickDistance:Po=0,children:Io,onReconnect:mi,onReconnectStart:To,onReconnectEnd:Jn,onEdgeContextMenu:yi,onEdgeDoubleClick:er,onEdgeMouseEnter:Cl,onEdgeMouseMove:tr,onEdgeMouseLeave:Cr,reconnectRadius:jr=10,onNodesChange:vi,onEdgesChange:jl,noDragClassName:Ml="nodrag",noWheelClassName:Pl="nowheel",noPanClassName:on="nopan",fitView:xi,fitViewOptions:wi,connectOnClick:Il,attributionPosition:zo,proOptions:Ro,defaultEdgeOptions:Lo,elevateNodesOnSelect:Ao=!0,elevateEdgesOnSelect:Tl=!1,disableKeyboardA11y:Do=!1,autoPanOnConnect:He,autoPanOnNodeDrag:zl,autoPanOnSelection:Si=!0,autoPanSpeed:$o,connectionRadius:Mr,isValidConnection:Rl,onError:bo,style:Pr,id:Nt,nodeDragThreshold:Ll,connectionDragThreshold:Ct,viewport:Al,onViewportChange:Dl,width:$l,height:Ir,colorMode:Tr="light",debug:nr,onScroll:pn,ariaLabelConfig:bl,zIndexMode:Oo="basic",..._i},Fo){const rr=Nt||"1",ir=dS(Tr),Ol=U.useCallback(zr=>{zr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),pn==null||pn(zr)},[pn]);return g.jsx("div",{"data-testid":"rf__wrapper",..._i,onScroll:Ol,style:{...Pr,...$_},ref:Fo,className:Ge(["react-flow",a,ir]),id:Nt,role:"application",children:g.jsxs(D_,{nodes:t,edges:r,width:$l,height:Ir,fitView:xi,fitViewOptions:wi,minZoom:ft,maxZoom:lt,nodeOrigin:Ke,nodeExtent:Dt,zIndexMode:Oo,children:[g.jsx(cS,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:S,onConnectStart:_,onConnectEnd:C,onClickConnectStart:k,onClickConnectEnd:E,nodesDraggable:Re,autoPanOnNodeFocus:nt,nodesConnectable:rt,nodesFocusable:Xe,edgesFocusable:Bt,edgesReconnectable:Lt,elementsSelectable:At,elevateNodesOnSelect:Ao,elevateEdgesOnSelect:Tl,minZoom:ft,maxZoom:lt,nodeExtent:Dt,onNodesChange:vi,onEdgesChange:jl,snapToGrid:me,snapGrid:Ce,connectionMode:M,translateExtent:ht,connectOnClick:Il,defaultEdgeOptions:Lo,fitView:xi,fitViewOptions:wi,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onNodeDragStart:H,onNodeDrag:F,onNodeDragStop:X,onSelectionDrag:W,onSelectionDragStart:j,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:y,noPanClassName:on,nodeOrigin:Ke,rfId:rr,autoPanOnConnect:He,autoPanOnNodeDrag:zl,autoPanSpeed:$o,onError:bo,connectionRadius:Mr,isValidConnection:Rl,selectNodesOnDrag:Pe,nodeDragThreshold:Ll,connectionDragThreshold:Ct,onBeforeDelete:b,debug:nr,ariaLabelConfig:bl,zIndexMode:Oo}),g.jsx(R_,{onInit:v,onNodeClick:f,onEdgeClick:p,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:P,onNodeContextMenu:O,onNodeDoubleClick:D,nodeTypes:u,edgeTypes:d,connectionLineType:z,connectionLineStyle:re,connectionLineComponent:ne,connectionLineContainerStyle:ae,selectionKeyCode:ce,selectionOnDrag:G,selectionMode:se,deleteKeyCode:de,multiSelectionKeyCode:we,panActivationKeyCode:he,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:it,translateExtent:ht,minZoom:ft,maxZoom:lt,preventScrolling:hn,zoomOnScroll:Z,zoomOnPinch:Ee,zoomOnDoubleClick:fi,panOnScroll:De,panOnScrollSpeed:Cn,panOnScrollMode:mt,panOnDrag:hi,autoPanOnSelection:Si,onPaneClick:pi,onPaneMouseEnter:gi,onPaneMouseMove:jn,onPaneMouseLeave:Mn,onPaneScroll:Co,onPaneContextMenu:jo,paneClickDistance:Mo,nodeClickDistance:Po,onSelectionContextMenu:B,onSelectionStart:A,onSelectionEnd:L,onReconnect:mi,onReconnectStart:To,onReconnectEnd:Jn,onEdgeContextMenu:yi,onEdgeDoubleClick:er,onEdgeMouseEnter:Cl,onEdgeMouseMove:tr,onEdgeMouseLeave:Cr,reconnectRadius:jr,defaultMarkerColor:rn,noDragClassName:Ml,noWheelClassName:Pl,noPanClassName:on,rfId:rr,disableKeyboardA11y:Do,nodeExtent:Dt,viewport:Al,onViewportChange:Dl,nodesDraggable:Re}),g.jsx(sS,{onSelectionChange:J}),Io,g.jsx(tS,{proOptions:Ro,position:zo}),g.jsx(eS,{rfId:rr,disableKeyboardA11y:Do})]})})}var O_=kg(b_);function F_({dimensions:t,lineWidth:r,variant:o,className:l}){return g.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Ge(["react-flow__background-pattern",o,l])})}function H_({radius:t,className:r}){return g.jsx("circle",{cx:t,cy:t,r:t,className:Ge(["react-flow__background-pattern","dots",r])})}var Zn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Zn||(Zn={}));const V_={[Zn.Dots]:1,[Zn.Lines]:1,[Zn.Cross]:6},B_=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Kg({id:t,variant:r=Zn.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:p,className:v,patternClassName:m}){const x=U.useRef(null),{transform:y,patternId:S}=Te(B_,We),_=l||V_[r],C=r===Zn.Dots,k=r===Zn.Cross,E=Array.isArray(o)?o:[o,o],T=[E[0]*y[2]||1,E[1]*y[2]||1],N=_*y[2],P=Array.isArray(u)?u:[u,u],O=k?[N,N]:T,D=[P[0]*y[2]+O[0]/2,P[1]*y[2]+O[1]/2],H=`${S}${t||""}`;return g.jsxs("svg",{className:Ge(["react-flow__background",v]),style:{...p,...El,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[g.jsx("pattern",{id:H,x:y[0]%T[0],y:y[1]%T[1],width:T[0],height:T[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:C?g.jsx(H_,{radius:N/2,className:m}):g.jsx(F_,{dimensions:O,lineWidth:a,variant:r,className:m})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}Kg.displayName="Background";const W_=U.memo(Kg);function U_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:g.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Y_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:g.jsx("path",{d:"M0 0h32v4.2H0z"})})}function X_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:g.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 Q_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 G_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 qs({children:t,className:r,...o}){return g.jsx("button",{type:"button",className:Ge(["react-flow__controls-button",r]),...o,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 qg({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:p,className:v,children:m,position:x="bottom-left",orientation:y="vertical","aria-label":S}){const _=Oe(),{isInteractive:C,minZoomReached:k,maxZoomReached:E,ariaLabelConfig:T}=Te(K_,We),{zoomIn:N,zoomOut:P,fitView:O}=hc(),D=()=>{N(),u==null||u()},H=()=>{P(),d==null||d()},F=()=>{O(a),f==null||f()},X=()=>{_.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),p==null||p(!C)},ee=y==="horizontal"?"horizontal":"vertical";return g.jsxs(kl,{className:Ge(["react-flow__controls",ee,v]),position:x,style:t,"data-testid":"rf__controls","aria-label":S??T["controls.ariaLabel"],children:[r&&g.jsxs(g.Fragment,{children:[g.jsx(qs,{onClick:D,className:"react-flow__controls-zoomin",title:T["controls.zoomIn.ariaLabel"],"aria-label":T["controls.zoomIn.ariaLabel"],disabled:E,children:g.jsx(U_,{})}),g.jsx(qs,{onClick:H,className:"react-flow__controls-zoomout",title:T["controls.zoomOut.ariaLabel"],"aria-label":T["controls.zoomOut.ariaLabel"],disabled:k,children:g.jsx(Y_,{})})]}),o&&g.jsx(qs,{className:"react-flow__controls-fitview",onClick:F,title:T["controls.fitView.ariaLabel"],"aria-label":T["controls.fitView.ariaLabel"],children:g.jsx(X_,{})}),l&&g.jsx(qs,{className:"react-flow__controls-interactive",onClick:X,title:T["controls.interactive.ariaLabel"],"aria-label":T["controls.interactive.ariaLabel"],children:C?g.jsx(G_,{}):g.jsx(Q_,{})}),m]})}qg.displayName="Controls";const q_=U.memo(qg);function Z_({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:p,className:v,borderRadius:m,shapeRendering:x,selected:y,onClick:S}){const{background:_,backgroundColor:C}=u||{},k=d||_||C;return g.jsx("rect",{className:Ge(["react-flow__minimap-node",{selected:y},v]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:k,stroke:f,strokeWidth:p},shapeRendering:x,onClick:S?E=>S(E,t):void 0})}const J_=U.memo(Z_),ek=t=>t.nodes.map(r=>r.id),Ru=t=>t instanceof Function?t:()=>t;function tk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=J_,onClick:d}){const f=Te(ek,We),p=Ru(r),v=Ru(t),m=Ru(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:f.map(y=>g.jsx(rk,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},y))})}function nk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:p}){const{node:v,x:m,y:x,width:y,height:S}=Te(_=>{const C=_.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const k=C.internals.userNode,{x:E,y:T}=C.internals.positionAbsolute,{width:N,height:P}=nn(k);return{node:k,x:E,y:T,width:N,height:P}},We);return!v||v.hidden||!qp(v)?null:g.jsx(f,{x:m,y:x,width:y,height:S,style:v.style,selected:!!v.selected,className:l(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:d,onClick:p,id:v.id})}const rk=U.memo(nk);var ik=U.memo(tk);const ok=200,sk=150,lk=t=>!t.hidden,ak=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?Qp(ko(t.nodeLookup,{filter:lk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},rp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,uk=(t,r)=>rp(t.viewBB,r.viewBB)&&rp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,ck="react-flow__minimap-desc";function Zg({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:p,maskColor:v,maskStrokeColor:m,maskStrokeWidth:x,position:y="bottom-right",onClick:S,onNodeClick:_,pannable:C=!1,zoomable:k=!1,ariaLabel:E,inversePan:T,zoomStep:N=1,offsetScale:P=5}){const O=Oe(),D=U.useRef(null),{boundingRect:H,viewBB:F,rfId:X,panZoom:ee,translateExtent:q,flowWidth:te,flowHeight:J,ariaLabelConfig:j}=Te(ak,uk),W=(t==null?void 0:t.width)??ok,V=(t==null?void 0:t.height)??sk,B=H.width/W,A=H.height/V,L=Math.max(B,A),b=L*W,M=L*V,z=P*L,re=H.x-(b-H.width)/2-z,ne=H.y-(M-H.height)/2-z,ae=b+z*2,de=M+z*2,ce=`${ck}-${X}`,G=U.useRef(0),se=U.useRef();G.current=L,U.useEffect(()=>{if(D.current&&ee)return se.current=_1({domNode:D.current,panZoom:ee,getTransform:()=>O.getState().transform,getViewScale:()=>G.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[ee]),U.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:q,width:te,height:J,inversePan:T,pannable:C,zoomStep:N,zoomable:k})},[C,k,T,N,q,te,J]);const he=S?me=>{var Pe;const[Ce,Me]=((Pe=se.current)==null?void 0:Pe.pointer(me))||[0,0];S(me,{x:Ce,y:Me})}:void 0,we=_?U.useCallback((me,Ce)=>{const Me=O.getState().nodeLookup.get(Ce).internals.userNode;_(me,Me)},[]):void 0,ve=E??j["minimap.ariaLabel"];return g.jsx(kl,{position:y,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*L:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof d=="number"?d:void 0},className:Ge(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:g.jsxs("svg",{width:W,height:V,viewBox:`${re} ${ne} ${ae} ${de}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ce,ref:D,onClick:he,children:[ve&&g.jsx("title",{id:ce,children:ve}),g.jsx(ik,{onClick:we,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),g.jsx("path",{className:"react-flow__minimap-mask",d:`M${re-z},${ne-z}h${ae+z*2}v${de+z*2}h${-ae-z*2}z + M${F.x},${F.y}h${F.width}v${F.height}h${-F.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Zg.displayName="MiniMap";const dk=U.memo(Zg),fk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,hk={[ci.Line]:"right",[ci.Handle]:"bottom-right"};function pk({nodeId:t,position:r,variant:o=ci.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:y,autoScale:S=!0,shouldResize:_,onResizeStart:C,onResize:k,onResizeEnd:E}){const T=Mg(),N=typeof t=="string"?t:T,P=Oe(),O=U.useRef(null),D=o===ci.Handle,H=Te(U.useCallback(fk(D&&S),[D,S]),We),F=U.useRef(null),X=r??hk[o];U.useEffect(()=>{if(!(!O.current||!N))return F.current||(F.current=A1({domNode:O.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:j,nodeOrigin:W,domNode:V}=P.getState();return{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:j,nodeOrigin:W,paneDomNode:V}},onChange:(q,te)=>{const{triggerNodeChanges:J,nodeLookup:j,parentLookup:W,nodeOrigin:V}=P.getState(),B=[],A={x:q.x,y:q.y},L=j.get(N);if(L&&L.expandParent&&L.parentId){const b=L.origin??V,M=q.width??L.measured.width??0,z=q.height??L.measured.height??0,re={id:L.id,parentId:L.parentId,rect:{width:M,height:z,...Zp({x:q.x??L.position.x,y:q.y??L.position.y},{width:M,height:z},L.parentId,j,b)}},ne=fc([re],j,W,V);B.push(...ne),A.x=q.x?Math.max(b[0]*M,q.x):void 0,A.y=q.y?Math.max(b[1]*z,q.y):void 0}if(A.x!==void 0&&A.y!==void 0){const b={id:N,type:"position",position:{...A}};B.push(b)}if(q.width!==void 0&&q.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};B.push(M)}for(const b of te){const M={...b,type:"position"};B.push(M)}J(B)},onEnd:({width:q,height:te})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:q,height:te}};P.getState().triggerNodeChanges([J])}})),F.current.update({controlPosition:X,boundaries:{minWidth:f,minHeight:p,maxWidth:v,maxHeight:m},keepAspectRatio:x,resizeDirection:y,onResizeStart:C,onResize:k,onResizeEnd:E,shouldResize:_}),()=>{var q;(q=F.current)==null||q.destroy()}},[X,f,p,v,m,x,C,k,E,_]);const ee=X.split("-");return g.jsx("div",{className:Ge(["react-flow__resize-control","nodrag",...ee,o,l]),ref:O,style:{...a,scale:H,...d&&{[D?"backgroundColor":"borderColor"]:d}},children:u})}U.memo(pk);const gk={"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.form":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 gc(t){return gk[t]??8}function mk(t){const r=new Map;for(const l of t){const a=gc(l.type),u=r.get(a)??[];u.push(l),r.set(a,u)}const o=new Map;for(const[l,a]of r)a.sort((u,d)=>u.name.localeCompare(d.name)),a.forEach((u,d)=>{o.set(u.id,{x:l*260,y:d*108})});return o}const Jg=90,yk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ip={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},vk=Math.PI*(3-Math.sqrt(5)),em=220,xk=26,Dk={0:"context",1:"routes",2:"views",3:"serializers",4:"services",5:"models",6:"fields",7:"jobs / signals",8:"openapi",9:"api client",10:"hooks",11:"pages",12:"components",13:"forms / tests"};function tm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function $k(t){return ip[t]?ip[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function wk(t){return t>=Jg?"3d":"2d"}function Sk(t){return t>=Jg?"overview":"full"}function _k(t,r,o=1){const l=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(tm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!yk.has(f.type)));const a=new Set(l.map(f=>f.id)),u=r.filter(f=>a.has(f.src)&&a.has(f.dst)),d=o.focusId?_k(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&d.size){l=l.filter(p=>d.has(p.id));const f=new Set(l.map(p=>p.id));return{nodes:l,edges:u.filter(p=>f.has(p.src)&&f.has(p.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function bk(t){const r=new Map;for(const l of t){const a=gc(l.type),u=r.get(a)??[];u.push(l),r.set(a,u)}const o=new Map;for(const[l,a]of r){a.sort((d,f)=>d.name.localeCompare(f.name));const u=l*em;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const p=xk*Math.sqrt(f+1),v=f*vk;o.set(d.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function Ok(t){const r=new Map;for(const o of t){const l=gc(o.type);r.set(l,(r.get(l)||0)+1)}return[...r.entries()].sort((o,l)=>o[0]-l[0]).map(([o,l])=>({layer:o,x:o*em,count:l}))}const Ek=U.lazy(()=>oy(()=>import("./LayeredGraph3D-D12B4Z17.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Nk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Ck({data:t,selected:r}){return g.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[g.jsx(di,{type:"target",position:Se.Left,isConnectable:!1}),g.jsx("div",{className:"t",children:Gu(t.type)}),g.jsx("div",{className:"n",title:t.name,children:t.name}),g.jsx(di,{type:"source",position:Se.Right,isConnectable:!1})]})}const jk={load:Ck},op=180,sp=56,Mk=new Set(["django","react","stitch","arch"]);function Pk(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=mk(t),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:op,height:sp,style:{width:op,height:sp}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const p=Nk[f.weight]||"var(--edge-cheap)";return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:p,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:po.ArrowClosed,width:14,height:14,color:p},label:f.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:10}}});return{rfNodes:u,rfEdges:d}}function lp({node:t}){return g.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[g.jsx("div",{className:"t",children:Gu(t.type)}),g.jsx("div",{className:"n",children:Vs(t.name)}),t.context?g.jsx("div",{className:"muted",children:Vs(t.context)}):null,t.file_path?g.jsx("div",{className:"file",children:Vs(`${t.file_path}${t.start_line?`:${t.start_line}`:""}`)}):null,g.jsx("div",{className:"muted",children:Vs(t.qualified_name)})]})}function Lu({nodes:t,edges:r}){const[o,l]=U.useState(null),[a,u]=U.useState(null),[d,f]=U.useState(null),[p,v]=U.useState(new Set(Mk)),[m,x]=U.useState(!1),y=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,S=a??wk(t.length),_=d??Sk(t.length),C=U.useMemo(()=>kk(t,r,{detail:_,families:p,focusId:o,neighborhoodOnly:m&&S==="3d"}),[t,r,_,p,o,m,S]),k=U.useMemo(()=>new Map(C.nodes.map(F=>[F.id,F])),[C.nodes]),E=o?k.get(o)??null:null,{rfNodes:T,rfEdges:N}=U.useMemo(()=>{const F=Pk(C.nodes,C.edges,o);return y&&(F.rfEdges=F.rfEdges.map(X=>({...X,animated:!1}))),F},[C.nodes,C.edges,o,y]);U.useEffect(()=>{o&&!k.has(o)&&l(null)},[k,o]);const P=(F,X)=>{l(X.id)},O=F=>{v(X=>{const ee=new Set(X);if(ee.has(F)){if(ee.size===1)return X;ee.delete(F)}else ee.add(F);return ee})},D=U.useMemo(()=>{const F=new Set;for(const X of t)F.add(tm(X.type));return F},[t]),H=t.length-C.nodes.length;return g.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[g.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[g.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[g.jsx("button",{type:"button","data-testid":"graph-view-2d",className:S==="2d"?"active":"","aria-pressed":S==="2d",onClick:()=>u("2d"),children:"2D map"}),g.jsx("button",{type:"button","data-testid":"graph-view-3d",className:S==="3d"?"active":"","aria-pressed":S==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),g.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[g.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:_==="overview"?"active":"","aria-pressed":_==="overview",onClick:()=>f("overview"),children:"Overview"}),g.jsx("button",{type:"button","data-testid":"graph-detail-full",className:_==="full"?"active":"","aria-pressed":_==="full",onClick:()=>f("full"),children:"Full"})]}),g.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(F=>D.has(F)).map(F=>g.jsx("button",{type:"button","data-testid":`graph-family-${F}`,className:p.has(F)?"active":"","aria-pressed":p.has(F),onClick:()=>O(F),children:F},F))}),S==="3d"?g.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(F=>!F),children:m?"Neighborhood":"Focus neighbors"}):null,g.jsxs("span",{className:"muted graph-count",children:[C.nodes.length," nodes · ",C.edges.length," edges",H?` · ${H} hidden`:""]})]}),g.jsx("div",{className:"graph-stage",children:S==="3d"?g.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[g.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),g.jsx(U.Suspense,{fallback:g.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:g.jsx(Ek,{nodes:C.nodes,edges:C.edges,selectedId:o,neighborIds:C.neighborIds,onSelect:F=>{l(F),F||x(!1)}})}),E?g.jsx(lp,{node:E}):null]}):g.jsxs(Gg,{children:[g.jsxs(O_,{nodes:T,edges:N,nodeTypes:jk,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.15},minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:P,onPaneClick:()=>l(null),proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[g.jsx(W_,{}),g.jsx(dk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),g.jsx(q_,{})]}),E?g.jsx(lp,{node:E}):null]})})]})}const hl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"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"}],Ik="obsidian",nm="loadpath.theme";function Tk(t){return hl.some(r=>r.id===t)}function rm(){try{const t=localStorage.getItem(nm)||"";if(Tk(t))return t}catch{}return Ik}function zk(t){var r;return((r=hl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function im(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=zk(t);try{localStorage.setItem(nm,t)}catch{}}const ap=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:Z0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:J0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:ey},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:ty},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:ny}];function Rk(){var it,ft,lt,ht,hn,Dt,rn;const[t,r]=U.useState("review"),[o,l]=U.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=U.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=U.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=U.useState(null),[m,x]=U.useState(null),[y,S]=U.useState([]),[_,C]=U.useState("review"),[k,E]=U.useState(""),[T,N]=U.useState(""),[P,O]=U.useState(""),[D,H]=U.useState({}),[F,X]=U.useState([]),[ee,q]=U.useState(localStorage.getItem("loadpath.scmRepo")||""),[te,J]=U.useState(localStorage.getItem("loadpath.provider")||"github"),[j,W]=U.useState(localStorage.getItem("loadpath.prNumber")||""),[V,B]=U.useState(""),[A,L]=U.useState(rm),[b,M]=U.useState(!1),z=U.useRef(o);z.current=o;const re=Z=>{L(Z),im(Z)},ne=U.useRef(""),ae=Z=>{ne.current=Z,N(Z)};U.useEffect(()=>{kt.settings().then(H).catch(()=>{}).finally(()=>M(!0)),kt.repos().then(Z=>S(Z.repos)).catch(()=>{})},[]);const de=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);U.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const Z=o;let Ee=!1;return kt.architecture(Z).then(De=>{!Ee&&z.current===Z&&x(De)}).catch(()=>{}),()=>{Ee=!0}},[t,o]);const ce=Z=>{l(Z),localStorage.setItem("loadpath.repo",Z)},G=(Z,Ee)=>{u(Z),f(Ee),localStorage.setItem("loadpath.base",Z),localStorage.setItem("loadpath.head",Ee)},se=(Z,Ee,De)=>{J(Z),q(Ee),localStorage.setItem("loadpath.provider",Z),localStorage.setItem("loadpath.scmRepo",Ee),De!==void 0&&(W(De),localStorage.setItem("loadpath.prNumber",De))},he=async(Z=o)=>{if(!Z.trim())return null;const Ee=await kt.architecture(Z);return z.current===Z&&x(Ee),Ee},we=async()=>{if(!ne.current&&de()){E(""),O(""),ae("Tracing load path…"),ce(o),G(a,d);try{const Z=await kt.review(o,a,d,!0);v(Z),C("review"),r("review"),await kt.repos().then(Ee=>S(Ee.repos)).catch(()=>{}),await he(o)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},ve=async(Z=!0)=>{if(!ne.current&&de()){E(""),O(""),ae(Z?"Indexing…":"Full reindex…"),ce(o);try{await kt.index(o,Z);const Ee=await he(o);await kt.repos().then(De=>S(De.repos)).catch(()=>{}),Ee!=null&&Ee.indexed&&(C("architecture"),r("architecture"))}catch(Ee){E(Ee instanceof Error?Ee.message:String(Ee))}finally{ae("")}}},me=async()=>{if(!ne.current&&de()){E(""),O(""),ae("Detecting layout…"),ce(o);try{const Z=await kt.init(o);O(Z.message),await kt.repos().then(Ee=>S(Ee.repos)).catch(()=>{})}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Ce=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),O("Copied markdown brief")}catch(Z){E(Z instanceof Error?Z.message:String(Z))}},Me=async()=>{if(!ne.current){if(!(p!=null&&p.markdown)||!ee||!j){E("Pick a pull request first (Pull requests tab), then post the brief.");return}ae("Posting Loadpath brief…");try{const Z=await kt.postComment(te,ee,Number(j),p.markdown);O(Z.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Pe=async()=>{if(!ne.current){E(""),ae("Fetching pull requests…");try{const Z=await kt.prs(te,ee);X(Z.pull_requests)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},Re=async Z=>{Z.preventDefault();const Ee=new FormData(Z.currentTarget),De={github_token:String(Ee.get("github_token")||""),bitbucket_token:String(Ee.get("bitbucket_token")||""),bitbucket_username:String(Ee.get("bitbucket_username")||""),ai_provider:String(Ee.get("ai_provider")||"none"),ai_api_key:String(Ee.get("ai_api_key")||""),ai_model:String(Ee.get("ai_model")||""),ai_base_url:String(Ee.get("ai_base_url")||"")},Cn=y.length?{...De,workspaces:y.map(mt=>({path:mt.path,name:mt.name}))}:De;try{H(await kt.saveSettings(Cn)),O("Settings saved on this machine")}catch(mt){E(mt instanceof Error?mt.message:String(mt))}},nt=async()=>{if(!(!p||ne.current)){ae("Residual analysis…");try{const Z=await kt.residual(p);B(Z.note)}catch(Z){E(Z instanceof Error?Z.message:String(Z))}finally{ae("")}}},rt=U.useRef(we);rt.current=we;const Xe=U.useRef(t);Xe.current=t,U.useEffect(()=>{const Z=Ee=>{const De=Ee.target;if(De&&(De.tagName==="INPUT"||De.tagName==="TEXTAREA"||De.tagName==="SELECT"||De.isContentEditable)){Ee.key==="Escape"&&De.blur();return}if(Ee.key==="Escape"){E(""),O("");return}const Cn=ap.find(mt=>mt.shortcut===Ee.key);if(Cn&&!Ee.metaKey&&!Ee.ctrlKey&&!Ee.altKey&&r(Cn.id),(Ee.metaKey||Ee.ctrlKey)&&Ee.key==="Enter"){if(Xe.current==="settings"||Xe.current==="prs"||ne.current)return;Ee.preventDefault(),rt.current()}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[]);const Ke=U.useMemo(()=>_==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[_,m,p]),Bt=U.useMemo(()=>_==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[_,m,p]),Lt=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",At=((p==null?void 0:p.findings)||[]).filter(Z=>!Z.waived);return g.jsxs("div",{className:"app",children:[g.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),g.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[g.jsxs("div",{className:"brand",children:[g.jsx("div",{className:"brand-mark",children:"Loadpath"}),g.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),ap.map(Z=>{const Ee=Z.icon,De=t===Z.id;return g.jsxs("button",{type:"button","data-testid":Z.testId,className:De?"nav-item active":"nav-item","aria-current":De?"page":void 0,"aria-label":Z.label,onClick:()=>r(Z.id),children:[g.jsx(Ee,{}),g.jsx("span",{children:Z.label})]},Z.id)}),g.jsxs("div",{className:"theme-pick",children:[g.jsx("label",{htmlFor:"theme-select",children:"Theme"}),g.jsx("select",{id:"theme-select","data-testid":"theme-select",value:A,onChange:Z=>re(Z.target.value),children:hl.map(Z=>g.jsx("option",{value:Z.id,children:Z.label},Z.id))})]}),g.jsxs("div",{className:"rail-foot",children:[g.jsx("div",{className:"muted",role:"status",children:T||Lt}),g.jsxs("div",{className:"kbd-hint",children:[g.jsx("kbd",{children:"1"}),"–",g.jsx("kbd",{children:"5"})," tabs · ",g.jsx("kbd",{children:"Ctrl"}),"+",g.jsx("kbd",{children:"Enter"})," review"]})]})]}),g.jsxs("div",{className:"main",id:"main",children:[T?g.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[g.jsx("i",{}),g.jsx("span",{className:"sr-only",children:T})]}):null,g.jsxs("header",{className:"topbar","data-testid":"topbar",children:[y.length>0?g.jsxs("label",{className:"field workspace",children:[g.jsx("span",{children:"Workspace"}),g.jsxs("select",{"data-testid":"workspace-select",value:y.some(Z=>Z.path===o)?o:"",onChange:Z=>{Z.target.value&&ce(Z.target.value)},children:[g.jsx("option",{value:"",children:"Indexed repos…"}),y.map(Z=>g.jsxs("option",{value:Z.path,children:[Z.name,Z.indexed?` (${Z.counts.nodes})`:""]},Z.path))]})]}):null,g.jsxs("label",{className:"field path",children:[g.jsx("span",{children:"Repository"}),g.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:Z=>l(Z.target.value),spellCheck:!1})]}),g.jsxs("label",{className:"field ref",children:[g.jsx("span",{children:"Base"}),g.jsx("input",{"data-testid":"base-ref",value:a,onChange:Z=>G(Z.target.value,d),placeholder:"base",spellCheck:!1})]}),g.jsxs("label",{className:"field ref",children:[g.jsx("span",{children:"Head"}),g.jsx("input",{"data-testid":"head-ref",value:d,onChange:Z=>G(a,Z.target.value),placeholder:"head",spellCheck:!1})]}),g.jsxs("div",{className:"topbar-actions",children:[g.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!T,onClick:me,children:"Draft config"}),g.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!T,onClick:()=>ve(!0),children:"Index"}),g.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!T,onClick:we,children:"Review"})]})]}),g.jsxs("div",{className:"alerts",children:[k?g.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[g.jsx("span",{children:k}),g.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,P?g.jsxs("div",{className:"banner","data-testid":"status-note",children:[g.jsx("span",{children:P}),g.jsx("button",{type:"button",className:"dismiss",onClick:()=>O(""),"aria-label":"Dismiss",children:"×"})]}):null,((it=p==null?void 0:p.index)!=null&&it.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?g.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,((ft=p==null?void 0:p.index)==null?void 0:ft.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?g.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((lt=p==null?void 0:p.index)==null?void 0:lt.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ht=p==null?void 0:p.workspace)!=null&&ht.dirty_overlaps_review&&t==="review"?g.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),g.jsxs("div",{className:"stage",children:[t==="review"&&g.jsxs("div",{className:"content","data-testid":"review-layout",children:[g.jsx("aside",{className:"brief","data-testid":"brief",children:p?g.jsx(Lk,{review:p,findings:At,aiNote:V,busy:!!T,onAskAi:nt,onCopy:Ce,onPost:Me}):g.jsxs("div",{className:"empty","data-testid":"review-empty",children:[g.jsx("h2",{children:"Trace the force of this diff"}),g.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),g.jsxs("ol",{children:[g.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),g.jsxs("li",{children:["Index it. Missing ",g.jsx("code",{children:"loadpath.yml"})," is drafted from ",g.jsx("code",{children:"manage.py"})," and"," ",g.jsx("code",{children:"src/features"}),"."]}),g.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),g.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?g.jsx(Lu,{nodes:p.nodes,edges:p.edges}):null})]}),t==="architecture"&&g.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[g.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?g.jsx(Ak,{architecture:m,busy:!!T,onReindex:()=>ve(!1),onReview:we}):g.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."})}),g.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?g.jsx(Lu,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&g.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[g.jsxs("div",{className:"graph-modes",children:[g.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[g.jsx("button",{type:"button","aria-pressed":_==="review","data-testid":"graph-mode-review",className:_==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),g.jsx("button",{type:"button","aria-pressed":_==="architecture","data-testid":"graph-mode-architecture",className:_==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),g.jsxs("div",{className:"legend","aria-hidden":"true",children:[g.jsxs("span",{children:[g.jsx("i",{})," cheap"]}),g.jsxs("span",{children:[g.jsx("i",{className:"exp"})," expensive"]}),g.jsxs("span",{children:[g.jsx("i",{className:"crit"})," critical"]}),g.jsxs("span",{children:[g.jsx("i",{className:"dash"})," inferred"]})]})]}),Ke.length?g.jsx(Lu,{nodes:Ke,edges:Bt}):g.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&g.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[g.jsxs("div",{className:"pr-toolbar",children:[g.jsxs("label",{className:"field provider",children:[g.jsx("span",{children:"Provider"}),g.jsxs("select",{"data-testid":"pr-provider",value:te,onChange:Z=>se(Z.target.value,ee,j),children:[g.jsx("option",{value:"github",children:"GitHub"}),g.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),g.jsxs("label",{className:"field",children:[g.jsx("span",{children:"Repository"}),g.jsx("input",{"data-testid":"pr-repo",placeholder:"owner/repo",value:ee,onChange:Z=>se(te,Z.target.value,j),spellCheck:!1})]}),g.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!T,onClick:Pe,children:"List PRs"})]}),F.length===0?g.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[g.jsx("h2",{children:"No pull requests loaded"}),g.jsx("p",{children:"Enter an owner/repo, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):F.map(Z=>g.jsxs("article",{className:"pr","data-testid":`pr-${Z.number}`,children:[g.jsxs("h3",{children:["#",Z.number," ",Z.title]}),g.jsxs("div",{className:"pr-meta muted",children:[g.jsx("span",{className:`chip ${Z.draft?"":"open"}`,children:Z.draft?"draft":Z.state}),g.jsx("span",{children:Z.author}),g.jsxs("span",{children:[Z.source_branch," → ",Z.target_branch]})]}),g.jsxs("div",{className:"pr-actions",children:[g.jsxs("a",{href:Z.url,target:"_blank",rel:"noreferrer",children:["Open on ",Z.provider]}),g.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${Z.number}`,onClick:()=>{G(Z.base_sha||Z.target_branch,Z.head_sha||Z.source_branch),se(Z.provider,Z.repo,String(Z.number)),r("review")},children:"Review this range"})]})]},`${Z.provider}-${Z.number}`))]}),t==="settings"&&b&&g.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Re,children:[g.jsxs("div",{children:[g.jsx("h1",{children:"Settings"}),g.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),g.jsxs("section",{className:"settings-card",children:[g.jsx("h2",{children:"Appearance"}),g.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),g.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:hl.map(Z=>g.jsxs("button",{type:"button",className:A===Z.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${Z.id}`,onClick:()=>re(Z.id),children:[g.jsx("div",{className:"name",children:Z.label}),g.jsx("div",{className:"group",children:Z.group})]},Z.id))})]}),g.jsxs("section",{className:"settings-card",children:[g.jsx("h2",{children:"Source control"}),g.jsx("label",{htmlFor:"github_token",children:"GitHub token"}),g.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),g.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token"}),g.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),g.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),g.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(D.bitbucket_username||"")})]}),g.jsxs("section",{className:"settings-card",children:[g.jsx("h2",{children:"Residual AI"}),g.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),g.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((hn=D.ai)==null?void 0:hn.provider)||"none"),children:[g.jsx("option",{value:"none",children:"none (graph only)"}),g.jsx("option",{value:"anthropic",children:"Anthropic"}),g.jsx("option",{value:"openai",children:"OpenAI"}),g.jsx("option",{value:"grok",children:"Grok / xAI"}),g.jsx("option",{value:"deepseek",children:"DeepSeek"}),g.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),g.jsx("option",{value:"ollama",children:"Ollama local"})]}),g.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),g.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),g.jsx("label",{htmlFor:"ai_model",children:"Model"}),g.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Dt=D.ai)==null?void 0:Dt.model)||"")}),g.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),g.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((rn=D.ai)==null?void 0:rn.base_url)||"")}),g.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]})]})}function Lk({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var p,v,m,x,y,S,_,C;const f=[...new Set(t.confidence.reasons||[])];return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[g.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?g.jsx("ul",{className:"reasons",children:f.map(k=>g.jsx("li",{children:k},k))}):null,t.low_risk?g.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(k=>g.jsx("span",{className:"chip",children:G0(k)},k))]}),g.jsxs("div",{className:"metrics",children:[g.jsxs("div",{className:"metric",children:[g.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),g.jsx("div",{className:"l",children:"Sinks tested"})]}),g.jsxs("div",{className:"metric",children:[g.jsx("div",{className:"n",children:r.length}),g.jsx("div",{className:"l",children:"Findings"})]}),g.jsxs("div",{className:"metric",children:[g.jsx("div",{className:"n",children:t.residuals.length}),g.jsx("div",{className:"l",children:"Residuals"})]})]}),g.jsx("pre",{className:"headline",children:t.headline}),t.index?g.jsxs("details",{className:"section",open:!0,children:[g.jsxs("summary",{children:["Index ",g.jsx("span",{className:"count",children:t.index.counts.nodes})]}),g.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(p=t.workspace)!=null&&p.three_dot?" · three-dot range":""]})]}):null,g.jsxs("details",{className:"section",open:!0,children:[g.jsxs("summary",{children:["Read this ",g.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((k,E)=>g.jsxs("div",{className:"read-item",children:[g.jsxs("span",{className:"file",children:[E+1,". ",k.path]}),g.jsx("div",{className:"why",children:k.why})]},k.path))]}),g.jsxs("details",{className:"section",children:[g.jsxs("summary",{children:["Clusters ",g.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(k=>g.jsxs("div",{className:"muted",children:[g.jsx("strong",{children:k.title})," — ",k.files.join(", ")]},k.id))]}),g.jsxs("details",{className:"section",open:!0,children:[g.jsxs("summary",{children:["Architecture ",g.jsx("span",{className:"count",children:r.length})]}),r.length===0?g.jsx("div",{className:"muted",children:t.architecture_note}):r.map(k=>g.jsxs("div",{className:"finding",children:[g.jsx("span",{className:`chip ${k.severity}`,children:k.severity}),k.message]},k.rule+k.message))]}),g.jsx(om,{cards:t.deepening}),g.jsxs("details",{className:"section",open:!0,children:[g.jsxs("summary",{children:["Residual ",g.jsx("span",{className:"count",children:t.residuals.length})]}),g.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(k=>g.jsx("div",{className:"residual muted",children:k},k))]}),(m=(v=t.evolution)==null?void 0:v.notes)!=null&&m.length||(y=(x=t.evolution)==null?void 0:x.hotspots)!=null&&y.some(k=>k.commits)?g.jsxs("details",{className:"section",children:[g.jsx("summary",{children:"Churn & coupling"}),(((S=t.evolution)==null?void 0:S.notes)||[]).map(k=>g.jsx("div",{className:"muted",children:k},k)),(((_=t.evolution)==null?void 0:_.hotspots)||[]).filter(k=>k.commits).slice(0,6).map(k=>g.jsxs("div",{className:"muted",children:[g.jsx("span",{className:"file",children:k.path})," — ",k.commits," commits, bus factor ",k.bus_factor]},k.path))]}):null,g.jsxs("div",{className:"btn-row",children:[g.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),g.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),g.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?g.jsx("pre",{className:"headline",children:o}):null,g.jsx("div",{className:"kicker",children:"Reviewers"}),g.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?g.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function Ak({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"merge-box high",children:[g.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),g.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${q0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),g.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?g.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),g.jsxs("details",{className:"section",open:!0,children:[g.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>g.jsxs("div",{className:"muted",children:[g.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),g.jsxs("details",{className:"section",children:[g.jsxs("summary",{children:["Rules ",g.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>g.jsx("div",{className:"muted",children:u},u))]}),g.jsxs("details",{className:"section",open:!0,children:[g.jsxs("summary",{children:["Findings ",g.jsx("span",{className:"count",children:a.length})]}),a.length===0?g.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>g.jsxs("div",{className:"finding",children:[g.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),g.jsx(om,{cards:t.deepening}),g.jsxs("details",{className:"section",open:!0,children:[g.jsx("summary",{children:"Types"}),g.jsx("table",{className:"type-table",children:g.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>g.jsxs("tr",{children:[g.jsx("td",{children:Gu(u)}),g.jsx("td",{children:d})]},u))})})]}),g.jsxs("div",{className:"btn-row",children:[g.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),g.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function om({cards:t}){const r=t||[];return r.length?g.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[g.jsxs("summary",{children:["Depth ",g.jsx("span",{className:"count",children:r.length})]}),g.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>g.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[g.jsx("span",{className:`chip ${o.strength}`,children:K0(o.strength)}),o.top?g.jsx("span",{className:"chip",children:"top"}):null,g.jsx("strong",{children:o.title}),g.jsx("div",{className:"why",children:o.message}),o.deletion_test?g.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?g.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}im(rm());Y0.createRoot(document.getElementById("root")).render(g.jsx(U.StrictMode,{children:g.jsx(Rk,{})}));export{Dk as L,Ok as a,$k as c,g as j,bk as l,U as r,Gu as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 65fb42f..e3c1049 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/src/loadpath/types.py b/src/loadpath/types.py index f0eed83..4aa148c 100644 --- a/src/loadpath/types.py +++ b/src/loadpath/types.py @@ -24,6 +24,7 @@ class NodeType(StrEnum): VIEWSET_ACTION = "django.viewset_action" SERIALIZER = "django.serializer" SERIALIZER_FIELD = "django.serializer_field" + FORM = "django.form" SERVICE = "django.service" MODEL = "django.model" FIELD = "django.field" @@ -128,6 +129,7 @@ class EdgeWeight(StrEnum): CONTRACT_TYPES = { NodeType.SERIALIZER, NodeType.SERIALIZER_FIELD, + NodeType.FORM, NodeType.OPENAPI_PATH, NodeType.FORM_SCHEMA, NodeType.ROUTE, diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index c4f6eea..a972e50 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -56,7 +56,10 @@ def browser_page(): try: pw = sync_playwright().start() - browser = pw.chromium.launch(headless=True) + browser = pw.chromium.launch( + headless=True, + args=["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist"], + ) except Exception as exc: # noqa: BLE001 pytest.skip(f"Chromium not available: {exc}") context = browser.new_context(viewport={"width": 1440, "height": 900}) diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 5035066..a9cc1f0 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -103,11 +103,13 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): assert "billing-team" in brief assert "MePage" not in brief page.locator(".react-flow__node").filter(has_text="InvoicePage").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) assert page.locator(".react-flow__node").filter(has_text="MePage").count() == 0 page.get_by_test_id("tab-graph").click() page.get_by_test_id("graph-full").wait_for() page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) page.locator(".react-flow__minimap-node").first.wait_for(timeout=10_000) page.locator(".react-flow__node").first.click() inspector = page.get_by_test_id("graph-inspector") @@ -127,9 +129,17 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): assert overflow["content"], "selected-node inspector overflows horizontally" assert overflow["in_pane"], "selected-node inspector extends outside the graph pane" + page.get_by_test_id("graph-view-3d").click() + assert page.get_by_test_id("graph-view-3d").get_attribute("aria-pressed") == "true" + page.get_by_test_id("graph-3d").wait_for(timeout=15_000) + page.locator("[data-testid='graph-3d-canvas'], [data-testid='graph-3d-fallback']").first.wait_for(timeout=20_000) + page.get_by_test_id("graph-view-2d").click() + page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.get_by_test_id("graph-mode-architecture").click() assert page.get_by_test_id("graph-mode-architecture").get_attribute("aria-pressed") == "true" page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) page.get_by_test_id("tab-review").click() page.context.grant_permissions(["clipboard-read", "clipboard-write"], origin=base_url) diff --git a/tests/e2e/test_ui_screenshots.py b/tests/e2e/test_ui_screenshots.py index c3ee6dc..55cb392 100644 --- a/tests/e2e/test_ui_screenshots.py +++ b/tests/e2e/test_ui_screenshots.py @@ -41,6 +41,7 @@ def test_ui_review_graph_prs_settings(live_app, tmp_path: Path, browser_page): page.get_by_test_id("architecture-brief").wait_for(timeout=15_000) page.get_by_test_id("architecture-brief").locator(".level").wait_for(timeout=15_000) page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) page.wait_for_timeout(800) page.screenshot(path=str(dest / "architecture.png"), full_page=False) @@ -59,17 +60,29 @@ def test_ui_review_graph_prs_settings(live_app, tmp_path: Path, browser_page): brief = page.get_by_test_id("brief").inner_text() assert "MEDIUM" in brief or "LOW" in brief or "HIGH" in brief page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) page.wait_for_timeout(800) page.screenshot(path=str(dest / "review.png"), full_page=False) page.get_by_test_id("tab-graph").click() page.get_by_test_id("graph-full").wait_for() page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.locator(".react-flow__edge").first.wait_for(timeout=15_000) page.locator(".react-flow__minimap-node").first.wait_for(timeout=10_000) assert page.locator(".react-flow__minimap-node").count() > 3 + assert page.locator(".react-flow__edge").count() > 0 page.wait_for_timeout(600) page.screenshot(path=str(dest / "graph.png"), full_page=False) + page.get_by_test_id("graph-view-3d").click() + assert page.get_by_test_id("graph-view-3d").get_attribute("aria-pressed") == "true" + page.get_by_test_id("graph-3d").wait_for(timeout=15_000) + page.locator("[data-testid='graph-3d-canvas'], [data-testid='graph-3d-fallback']").first.wait_for(timeout=20_000) + page.wait_for_timeout(800) + page.screenshot(path=str(dest / "graph_3d.png"), full_page=False) + page.get_by_test_id("graph-view-2d").click() + page.locator(".react-flow__node").first.wait_for(timeout=15_000) + page.get_by_test_id("tab-prs").click() page.get_by_test_id("pr-repo").fill("acme/demo") page.get_by_test_id("btn-list-prs").click() diff --git a/tests/unit/test_detect.py b/tests/unit/test_detect.py index 96e8d01..7c84949 100644 --- a/tests/unit/test_detect.py +++ b/tests/unit/test_detect.py @@ -41,3 +41,22 @@ def test_write_draft_creates_manifest(tmp_path: Path): assert "django_root: backend" in text assert "billing" in text assert "queryset_nplusone" in text + + +def test_detect_skips_nested_test_project_manage_py(tmp_path: Path): + """Library repos (Wagtail) keep manage.py under a test project — index the package.""" + pkg = tmp_path / "pack" / "contrib" / "redirects" + pkg.mkdir(parents=True) + (pkg / "apps.py").write_text("class RedirectsConfig:\n pass\n") + images = tmp_path / "pack" / "images" + images.mkdir() + (images / "apps.py").write_text("class ImagesConfig:\n pass\n") + test_proj = tmp_path / "pack" / "test" / "testapp" + test_proj.mkdir(parents=True) + (tmp_path / "pack" / "test" / "manage.py").write_text("print(1)\n") + (test_proj / "apps.py").write_text("class TestAppConfig:\n pass\n") + layout = detect_layout(tmp_path) + assert layout["django_root"] == "pack" + assert "redirects" in layout["django_apps"] + assert "images" in layout["django_apps"] + assert "testapp" not in layout["django_apps"] diff --git a/tests/unit/test_django_extractors.py b/tests/unit/test_django_extractors.py index a19410b..854470f 100644 --- a/tests/unit/test_django_extractors.py +++ b/tests/unit/test_django_extractors.py @@ -409,3 +409,61 @@ class InvoiceViewSet(ModelViewSet): """ 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) + + +def test_extracts_django_modelform_and_links_model(): + src = """ +from django import forms +from billing.models import Invoice + +class InvoiceForm(forms.ModelForm): + class Meta: + model = Invoice + fields = ["total", "status"] +""" + g = extract_django_file("backend/billing/forms.py", src, _cfg()) + forms_found = [n for n in g.nodes if n.type is NodeType.FORM] + assert any(n.name == "InvoiceForm" for n in forms_found) + assert any(e.type.value == "serializes" for e in g.edges) + assert any(e.type.value == "has_field" for e in g.edges) + + +def test_extracts_signal_connect_and_plain_handlers(): + apps = """ +from django.apps import AppConfig +from wagtail.signals import page_slug_changed +from .signal_handlers import autocreate_redirects_on_slug_change + +class RedirectsAppConfig(AppConfig): + def ready(self): + page_slug_changed.connect(autocreate_redirects_on_slug_change) +""" + handlers = """ +def should_skip(page): + return not page.live + +def autocreate_redirects_on_slug_change(instance_before, instance, **kwargs): + return None +""" + connected = extract_django_file("wagtail/contrib/redirects/apps.py", apps, _cfg()) + assert any(n.type is NodeType.RECEIVER and n.name == "autocreate_redirects_on_slug_change" for n in connected.nodes) + assert any(e.type.value == "receives" for e in connected.edges) + plain = extract_django_file("wagtail/contrib/redirects/signal_handlers.py", handlers, _cfg()) + names = {n.name for n in plain.nodes if n.type is NodeType.RECEIVER} + assert "autocreate_redirects_on_slug_change" in names + assert "should_skip" not in names + + +def test_testcase_named_form_is_not_a_form(): + src = """ +from django.test import TestCase +from kitsune.questions.forms import NewQuestionForm + +class TestNewQuestionForm(TestCase): + def test_ok(self): + NewQuestionForm() +""" + g = extract_django_file("kitsune/questions/tests/test_forms.py", src, _cfg()) + assert not any(n.type is NodeType.FORM for n in g.nodes) + assert any(n.type is NodeType.TEST and n.name == "test_ok" for n in g.nodes) + diff --git a/tests/unit/test_graph_linking.py b/tests/unit/test_graph_linking.py new file mode 100644 index 0000000..a175717 --- /dev/null +++ b/tests/unit/test_graph_linking.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from pathlib import Path + +from loadpath.architecture.snapshot import architecture_report +from loadpath.graph.store import GraphStore, linked_edges +from loadpath.review.cluster import impact_walk +from loadpath.review.engine import run_review +from loadpath.review.render import render_html +from loadpath.types import Edge, EdgeType, Node, NodeType, node_id + +from tests.conftest import prepare_review_repo + + +def _node(ntype: NodeType, name: str, file_path: str | None = "a.py") -> Node: + return Node( + id=node_id(ntype, name), + type=ntype, + name=name, + qualified_name=name, + file_path=file_path, + ) + + +def _assert_linked(nodes: list[dict], edges: list[dict]) -> None: + ids = {n["id"] for n in nodes} + assert edges, "expected a non-empty linked graph" + for edge in edges: + assert edge["src"] in ids, f"dangling src {edge['src']} on {edge['type']}" + assert edge["dst"] in ids, f"dangling dst {edge['dst']} on {edge['type']}" + + +def test_linked_edges_drops_missing_endpoints(): + nodes = [{"id": "a"}, {"id": "b"}] + edges = [ + {"id": "ok", "src": "a", "dst": "b"}, + {"id": "ghost", "src": "a", "dst": "missing"}, + {"id": "orphan", "src": "gone", "dst": "b"}, + ] + kept = linked_edges(nodes, edges) + assert [e["id"] for e in kept] == ["ok"] + + +def test_impact_walk_and_subgraph_drop_dangling_edges(tmp_path: Path): + store = GraphStore(tmp_path / "g.sqlite3") + view = _node(NodeType.VIEW, "InvoiceView") + serializer = _node(NodeType.SERIALIZER, "InvoiceSerializer") + store.upsert_node(view) + store.upsert_node(serializer) + store.upsert_edge(Edge(src=view.id, dst=serializer.id, type=EdgeType.USES_SERIALIZER)) + store.upsert_edge(Edge(src=view.id, dst="django.model:ghost", type=EdgeType.CALLS)) + store.conn.commit() + + nodes, edges = impact_walk(store, {view.id}) + _assert_linked(nodes, edges) + assert serializer.id in {n["id"] for n in nodes} + assert not any(e["dst"] == "django.model:ghost" for e in edges) + + sub_nodes, sub_edges = store.subgraph([view.id]) + _assert_linked(sub_nodes, sub_edges) + assert not any(e["dst"] == "django.model:ghost" for e in sub_edges) + store.close() + + +def test_demo_review_and_architecture_graphs_are_linked(tmp_path: Path): + repo = prepare_review_repo(tmp_path) + review = run_review(repo, base="HEAD~1", head="HEAD") + _assert_linked(review["nodes"], review["edges"]) + assert review["headline"].startswith("Loadpath:") + assert review["confidence"]["level"] in {"high", "medium", "low"} + assert review["read_order"] + md_html = render_html(review) + assert "vis-network" in md_html + assert "nodeIds.has(e.src)" in md_html + + report = architecture_report(repo) + _assert_linked(report["nodes"], report["edges"]) diff --git a/tests/unit/test_index_and_stitch.py b/tests/unit/test_index_and_stitch.py index 23b8802..2e72812 100644 --- a/tests/unit/test_index_and_stitch.py +++ b/tests/unit/test_index_and_stitch.py @@ -83,6 +83,25 @@ def test_incremental_reindex_keeps_enqueue_edges(tmp_path: Path): store.close() +def test_index_revision_change_reextracts_unchanged_files(tmp_path: Path, monkeypatch): + import shutil + + from loadpath import index as index_mod + + root = tmp_path / "repo" + shutil.copytree(FIXTURE, root) + db = tmp_path / "g.sqlite3" + store = index_repo(root, db_path=db, incremental=False) + assert store.get_meta("index_revision") == index_mod.INDEX_REVISION + store.close() + monkeypatch.setattr(index_mod, "INDEX_REVISION", index_mod.INDEX_REVISION + "-next") + store = index_repo(root, db_path=db, incremental=True) + assert store.get_meta("reindex_skipped") != "1" + assert int(store.get_meta("files_extracted") or "0") > 0 + assert store.get_meta("index_revision") == index_mod.INDEX_REVISION + store.close() + + def test_contexts_assigned(tmp_path: Path): store = index_repo(FIXTURE, db_path=tmp_path / "g.sqlite3", incremental=False) invoice = next(n for n in store.nodes([NodeType.MODEL]) if n["name"] == "Invoice") diff --git a/ui/package-lock.json b/ui/package-lock.json index 3f9fa0b..7f7b2a1 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -10,11 +10,13 @@ "dependencies": { "@xyflow/react": "^12.6.0", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "three": "^0.185.1" }, "devDependencies": { "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", + "@types/three": "^0.185.0", "@vitejs/plugin-react": "^4.3.4", "jsdom": "^25.0.1", "typescript": "^5.6.3", @@ -440,6 +442,13 @@ "node": ">=18" } }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", @@ -1306,6 +1315,13 @@ "win32" ] }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -1435,6 +1451,35 @@ "@types/react": "^18.0.0" } }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.185.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.185.0.tgz", + "integrity": "sha512-O2Uy8Cj4Nonr8dWUUbifMdPe8B0Mq7EdOHb89S4+kjUw/KhbjTZrUuYlrQ1bpUKG+EP9QJnN7qNxbHGlGoLHMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": ">=0.5.17", + "fflate": "~0.8.2", + "meshoptimizer": "~1.1.1" + } + }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "dev": true, + "license": "MIT" + }, "node_modules/@vitejs/plugin-react": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz", @@ -2129,6 +2174,13 @@ } } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "dev": true, + "license": "MIT" + }, "node_modules/form-data": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", @@ -2458,6 +2510,13 @@ "node": ">= 0.4" } }, + "node_modules/meshoptimizer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz", + "integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==", + "dev": true, + "license": "MIT" + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -2778,6 +2837,12 @@ "dev": true, "license": "MIT" }, + "node_modules/three": { + "version": "0.185.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.185.1.tgz", + "integrity": "sha512-5aojFCXKwnjBRZvUnt3WFfEcvUJgkN5LlijRFN95hMy8WVkG4I0QNcJE+OuWvuJ0bOdStrbfXn0pkd6/QyiAlg==", + "license": "MIT" + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", diff --git a/ui/package.json b/ui/package.json index ef0c542..63a8f1e 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,11 +12,13 @@ "dependencies": { "@xyflow/react": "^12.6.0", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "three": "^0.185.1" }, "devDependencies": { "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", + "@types/three": "^0.185.0", "@vitejs/plugin-react": "^4.3.4", "jsdom": "^25.0.1", "typescript": "^5.6.3", diff --git a/ui/src/ImpactGraph.test.ts b/ui/src/ImpactGraph.test.ts new file mode 100644 index 0000000..c030f8d --- /dev/null +++ b/ui/src/ImpactGraph.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from "vitest"; +import { MarkerType, Position } from "@xyflow/react"; +import { toReactFlowElements } from "./ImpactGraph"; +import type { GraphEdge, GraphNode } from "./types"; + +const nodes: GraphNode[] = [ + { id: "view", type: "django.view", name: "InvoiceView", qualified_name: "billing.InvoiceView" }, + { id: "ser", type: "django.serializer", name: "InvoiceSerializer", qualified_name: "billing.InvoiceSerializer" }, +]; + +const edges: GraphEdge[] = [ + { id: "ok", src: "view", dst: "ser", type: "uses_serializer", weight: "cheap", confidence: 1 }, + { id: "ghost", src: "view", dst: "missing", type: "calls", weight: "cheap", confidence: 1 }, +]; + +describe("toReactFlowElements", () => { + it("drops dangling edges and attaches remaining edges left-to-right", () => { + const { rfNodes, rfEdges } = toReactFlowElements(nodes, edges); + expect(rfNodes.map((n) => n.id)).toEqual(["view", "ser"]); + expect(rfNodes.every((n) => n.sourcePosition === Position.Right)).toBe(true); + expect(rfNodes.every((n) => n.targetPosition === Position.Left)).toBe(true); + expect(rfEdges).toHaveLength(1); + expect(rfEdges[0]).toMatchObject({ + id: "ok", + source: "view", + target: "ser", + type: "smoothstep", + }); + expect(rfEdges[0].markerEnd).toMatchObject({ type: MarkerType.ArrowClosed }); + }); +}); diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index 0baf18e..ddb1b3b 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -1,8 +1,11 @@ -import { useMemo, useState } from "react"; +import { lazy, Suspense, useEffect, useMemo, useState } from "react"; import { Background, Controls, + Handle, + MarkerType, MiniMap, + Position, ReactFlow, ReactFlowProvider, type Edge, @@ -11,8 +14,21 @@ import { } from "@xyflow/react"; import "@xyflow/react/dist/style.css"; import { typeLabel, wrapHint } from "./format"; +import { + defaultDetail, + defaultProjection, + familyFor, + visibleGraph, + type GraphDetail, + type GraphFamily, + type GraphProjection, +} from "./graphView"; import { layoutNodes, type GraphEdge, type GraphNode } from "./types"; +const LayeredGraph3D = lazy(() => + import("./LayeredGraph3D").then((mod) => ({ default: mod.LayeredGraph3D })), +); + const WEIGHT_COLOR: Record = { cheap: "var(--edge-cheap)", expensive: "var(--edge-expensive)", @@ -22,10 +38,12 @@ const WEIGHT_COLOR: Record = { function LoadNode({ data, selected }: { data: { name: string; type: string }; selected?: boolean }) { return (
+
{typeLabel(data.type)}
{data.name}
+
); } @@ -33,13 +51,14 @@ function LoadNode({ data, selected }: { data: { name: string; type: string }; se const nodeTypes = { load: LoadNode }; const NODE_WIDTH = 180; const NODE_HEIGHT = 56; +const ALL_FAMILIES = new Set(["django", "react", "stitch", "arch"]); -export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: GraphEdge[] }) { - const [selectedId, setSelectedId] = useState(null); - const reduceMotion = - typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches; - const byId = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]); - const selected = selectedId ? byId.get(selectedId) ?? null : null; +export function toReactFlowElements( + nodes: GraphNode[], + edges: GraphEdge[], + selectedId: string | null = null, +): { rfNodes: Node[]; rfEdges: Edge[] } { + const byId = new Map(nodes.map((n) => [n.id, n])); const pos = layoutNodes(nodes); const rfNodes: Node[] = nodes.map((n) => ({ id: n.id, @@ -47,82 +66,250 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph position: pos.get(n.id) ?? { x: 0, y: 0 }, data: { name: n.name, type: n.type, file: n.file_path }, selected: selectedId === n.id, - // MiniMap reads width/height off the user node, not the measured DOM box. + sourcePosition: Position.Right, + targetPosition: Position.Left, width: NODE_WIDTH, height: NODE_HEIGHT, style: { width: NODE_WIDTH, height: NODE_HEIGHT }, })); const rfEdges: Edge[] = edges .filter((e) => byId.has(e.src) && byId.has(e.dst)) - .map((e) => ({ - id: e.id, - source: e.src, - target: e.dst, - animated: !reduceMotion && e.weight === "critical", - style: { - stroke: WEIGHT_COLOR[e.weight] || "var(--edge-cheap)", - strokeWidth: e.weight === "critical" ? 2.4 : 1.2, - strokeDasharray: e.confidence < 0.8 ? "6 4" : undefined, - }, - label: e.type.replaceAll("_", " "), - labelStyle: { fill: "var(--muted)", fontSize: 10 }, - })); + .map((e) => { + const stroke = WEIGHT_COLOR[e.weight] || "var(--edge-cheap)"; + return { + id: e.id, + source: e.src, + target: e.dst, + type: "smoothstep", + animated: e.weight === "critical", + style: { + stroke, + strokeWidth: e.weight === "critical" ? 2.4 : 1.2, + strokeDasharray: e.confidence < 0.8 ? "6 4" : undefined, + }, + markerEnd: { + type: MarkerType.ArrowClosed, + width: 14, + height: 14, + color: stroke, + }, + label: e.type.replaceAll("_", " "), + labelStyle: { fill: "var(--muted)", fontSize: 10 }, + }; + }); + return { rfNodes, rfEdges }; +} + +function GraphInspector({ node }: { node: GraphNode }) { + return ( + + ); +} + +export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: GraphEdge[] }) { + const [selectedId, setSelectedId] = useState(null); + const [projection, setProjection] = useState(null); + const [detail, setDetail] = useState(null); + const [families, setFamilies] = useState>(new Set(ALL_FAMILIES)); + const [neighborhoodOnly, setNeighborhoodOnly] = useState(false); + const reduceMotion = + typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches; + + const view = projection ?? defaultProjection(nodes.length); + const level = detail ?? defaultDetail(nodes.length); + const visible = useMemo( + () => + visibleGraph(nodes, edges, { + detail: level, + families, + focusId: selectedId, + neighborhoodOnly: neighborhoodOnly && view === "3d", + }), + [nodes, edges, level, families, selectedId, neighborhoodOnly, view], + ); + const byId = useMemo(() => new Map(visible.nodes.map((n) => [n.id, n])), [visible.nodes]); + const selected = selectedId ? byId.get(selectedId) ?? null : null; + const { rfNodes, rfEdges } = useMemo(() => { + const elements = toReactFlowElements(visible.nodes, visible.edges, selectedId); + if (reduceMotion) { + elements.rfEdges = elements.rfEdges.map((edge) => ({ ...edge, animated: false })); + } + return elements; + }, [visible.nodes, visible.edges, selectedId, reduceMotion]); + + useEffect(() => { + if (selectedId && !byId.has(selectedId)) setSelectedId(null); + }, [byId, selectedId]); const onNodeClick: NodeMouseHandler = (_evt, node) => { setSelectedId(node.id); }; + const toggleFamily = (family: GraphFamily) => { + setFamilies((current) => { + const next = new Set(current); + if (next.has(family)) { + if (next.size === 1) return current; + next.delete(family); + } else { + next.add(family); + } + return next; + }); + }; + + const presentFamilies = useMemo(() => { + const found = new Set(); + for (const n of nodes) found.add(familyFor(n.type)); + return found; + }, [nodes]); + + const hidden = nodes.length - visible.nodes.length; + return ( -
- - setSelectedId(null)} - proOptions={{ hideAttribution: false }} - data-testid="impact-graph" - > - - - - - - {selected ? ( - - ) : null} +
+
+
+ + +
+
+ + +
+
+ {(["django", "stitch", "react"] as const) + .filter((family) => presentFamilies.has(family)) + .map((family) => ( + + ))} +
+ {view === "3d" ? ( + + ) : null} + + {visible.nodes.length} nodes · {visible.edges.length} edges + {hidden ? ` · ${hidden} hidden` : ""} + +
+
+ {view === "3d" ? ( +
+

+ Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to + zoom, click a node to inspect it. +

+ Loading 3D layers…

}> + { + setSelectedId(id); + if (!id) setNeighborhoodOnly(false); + }} + /> +
+ {selected ? : null} +
+ ) : ( + + setSelectedId(null)} + proOptions={{ hideAttribution: false }} + data-testid="impact-graph" + > + + + + + {selected ? : null} + + )} +
); } diff --git a/ui/src/LayeredGraph3D.tsx b/ui/src/LayeredGraph3D.tsx new file mode 100644 index 0000000..3b409a7 --- /dev/null +++ b/ui/src/LayeredGraph3D.tsx @@ -0,0 +1,303 @@ +import { useEffect, useRef, useState } from "react"; +import * as THREE from "three"; +import { OrbitControls } from "three/addons/controls/OrbitControls.js"; +import { typeLabel } from "./format"; +import { colorForType, LAYER_LABELS, layoutNodes3d, layerCenters } from "./graphView"; +import type { GraphEdge, GraphNode } from "./types"; + +type Props = { + nodes: GraphNode[]; + edges: GraphEdge[]; + selectedId: string | null; + neighborIds: Set; + onSelect: (id: string | null) => void; +}; + +type HostEl = HTMLDivElement & { + __paint?: (id: string | null, neighbors: Set) => void; +}; + +function cssColor(name: string, fallback: string): string { + if (typeof window === "undefined") return fallback; + const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim(); + return value || fallback; +} + +function discRadius(count: number): number { + return Math.max(40, 26 * Math.sqrt(Math.max(count, 1))); +} + +function makeLayerLabel(text: string, color: string): THREE.Sprite { + const canvas = document.createElement("canvas"); + canvas.width = 512; + canvas.height = 64; + const ctx = canvas.getContext("2d"); + if (ctx) { + ctx.clearRect(0, 0, 512, 64); + ctx.fillStyle = color; + ctx.font = "600 28px sans-serif"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(text, 256, 32); + } + const tex = new THREE.CanvasTexture(canvas); + const sprite = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, transparent: true, depthTest: false })); + sprite.scale.set(110, 14, 1); + return sprite; +} + +export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect }: Props) { + const wrapRef = useRef(null); + const hostRef = useRef(null); + const [hover, setHover] = useState<{ node: GraphNode; x: number; y: number } | null>(null); + const [webglError, setWebglError] = useState(null); + const selectRef = useRef(onSelect); + selectRef.current = onSelect; + const focusRef = useRef({ selectedId, neighborIds }); + focusRef.current = { selectedId, neighborIds }; + + useEffect(() => { + const host = hostRef.current; + if (!host) return; + + const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches; + const scene = new THREE.Scene(); + scene.background = new THREE.Color(cssColor("--graph-bg", "#0b0f14")); + + const camera = new THREE.PerspectiveCamera(50, 1, 1, 8000); + let renderer: THREE.WebGLRenderer; + try { + renderer = new THREE.WebGLRenderer({ + antialias: true, + failIfMajorPerformanceCaveat: false, + powerPreference: "low-power", + }); + } catch { + setWebglError("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map."); + return; + } + if (!renderer.getContext()) { + renderer.dispose(); + setWebglError("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map."); + return; + } + setWebglError(null); + renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); + renderer.domElement.dataset.testid = "graph-3d-canvas"; + host.appendChild(renderer.domElement); + + const controls = new OrbitControls(camera, renderer.domElement); + controls.enableDamping = !reduceMotion; + controls.dampingFactor = 0.08; + controls.minDistance = 80; + controls.maxDistance = 2400; + + scene.add(new THREE.AmbientLight(0xffffff, 0.7)); + const key = new THREE.DirectionalLight(0xffffff, 0.85); + key.position.set(200, 320, 180); + scene.add(key); + + const pos = layoutNodes3d(nodes); + const byId = new Map(nodes.map((n) => [n.id, n])); + const meshById = new Map(); + const group = new THREE.Group(); + scene.add(group); + + const sphere = new THREE.SphereGeometry(11, 18, 14); + for (const node of nodes) { + const p = pos.get(node.id) ?? { x: 0, y: 0, z: 0 }; + const material = new THREE.MeshStandardMaterial({ + color: colorForType(node.type), + roughness: 0.45, + metalness: 0.05, + transparent: true, + opacity: 1, + }); + const mesh = new THREE.Mesh(sphere, material); + mesh.position.set(p.x, p.y, p.z); + mesh.userData.id = node.id; + group.add(mesh); + meshById.set(node.id, mesh); + } + + const edgeGeom = new THREE.BufferGeometry(); + const edgePositions: number[] = []; + const edgeColors: number[] = []; + const cheap = new THREE.Color(cssColor("--edge-cheap", "#4a5568")); + const expensive = new THREE.Color(cssColor("--edge-expensive", "#f4a261")); + const critical = new THREE.Color(cssColor("--edge-critical", "#e85d04")); + for (const edge of edges) { + const a = pos.get(edge.src); + const b = pos.get(edge.dst); + if (!a || !b) continue; + edgePositions.push(a.x, a.y, a.z, b.x, b.y, b.z); + const color = edge.weight === "critical" ? critical : edge.weight === "expensive" ? expensive : cheap; + edgeColors.push(color.r, color.g, color.b, color.r, color.g, color.b); + } + edgeGeom.setAttribute("position", new THREE.Float32BufferAttribute(edgePositions, 3)); + edgeGeom.setAttribute("color", new THREE.Float32BufferAttribute(edgeColors, 3)); + const lines = new THREE.LineSegments( + edgeGeom, + new THREE.LineBasicMaterial({ vertexColors: true, transparent: true, opacity: 0.55 }), + ); + group.add(lines); + + const planeMat = new THREE.MeshBasicMaterial({ + color: new THREE.Color(cssColor("--muted", "#8b9bb0")), + transparent: true, + opacity: 0.07, + side: THREE.DoubleSide, + depthWrite: false, + }); + const labelColor = cssColor("--muted", "#8b9bb0"); + const labels: THREE.Sprite[] = []; + const discGeoms: THREE.BufferGeometry[] = []; + for (const layer of layerCenters(nodes)) { + const discGeom = new THREE.CircleGeometry(discRadius(layer.count), 48); + discGeoms.push(discGeom); + const disc = new THREE.Mesh(discGeom, planeMat); + disc.rotation.y = Math.PI / 2; + disc.position.x = layer.x; + group.add(disc); + const label = makeLayerLabel(LAYER_LABELS[layer.layer] ?? `layer ${layer.layer}`, labelColor); + label.position.set(layer.x, discRadius(layer.count) + 18, 0); + group.add(label); + labels.push(label); + } + + const box = new THREE.Box3().setFromObject(group); + const center = box.getCenter(new THREE.Vector3()); + const size = box.getSize(new THREE.Vector3()); + controls.target.copy(center); + camera.position.set( + center.x + size.x * 0.15, + center.y + Math.max(140, size.y * 0.45), + center.z + Math.max(280, size.z * 0.9 + 180), + ); + camera.lookAt(center); + + const raycaster = new THREE.Raycaster(); + raycaster.params.Mesh = { ...raycaster.params.Mesh, threshold: 2 }; + const pointer = new THREE.Vector2(); + const meshes = [...meshById.values()]; + + const paint = (focus: string | null, neighbors: Set) => { + const isolating = Boolean(focus && neighbors.size); + for (const [id, mesh] of meshById) { + const material = mesh.material as THREE.MeshStandardMaterial; + const onPath = !isolating || neighbors.has(id); + const selected = id === focus; + material.opacity = selected ? 1 : onPath ? 0.95 : 0.12; + mesh.scale.setScalar(selected ? 1.7 : onPath ? 1 : 0.7); + material.emissive.setHex(selected ? 0xffffff : 0x000000); + material.emissiveIntensity = selected ? 0.18 : 0; + } + (lines.material as THREE.LineBasicMaterial).opacity = isolating ? 0.85 : 0.5; + }; + + const setPointer = (event: { clientX: number; clientY: number }) => { + const rect = renderer.domElement.getBoundingClientRect(); + pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; + pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; + }; + const hit = (): GraphNode | null => { + raycaster.setFromCamera(pointer, camera); + const found = raycaster.intersectObjects(meshes, false)[0]; + const id = found?.object.userData.id as string | undefined; + return id ? byId.get(id) ?? null : null; + }; + + const onMove = (event: PointerEvent) => { + setPointer(event); + const node = hit(); + if (!node) { + setHover(null); + renderer.domElement.style.cursor = "grab"; + return; + } + renderer.domElement.style.cursor = "pointer"; + const rect = (wrapRef.current ?? host).getBoundingClientRect(); + setHover({ node, x: event.clientX - rect.left, y: event.clientY - rect.top }); + }; + const onClick = (event: MouseEvent) => { + setPointer(event); + const node = hit(); + selectRef.current(node ? node.id : null); + }; + + const resize = () => { + const w = host.clientWidth || 1; + const h = host.clientHeight || 1; + camera.aspect = w / h; + camera.updateProjectionMatrix(); + renderer.setSize(w, h, false); + }; + resize(); + const ro = new ResizeObserver(resize); + ro.observe(host); + + let frame = 0; + const tick = () => { + frame = requestAnimationFrame(tick); + controls.update(); + renderer.render(scene, camera); + }; + tick(); + + renderer.domElement.addEventListener("pointermove", onMove); + renderer.domElement.addEventListener("click", onClick); + (host as HostEl).__paint = paint; + paint(focusRef.current.selectedId, focusRef.current.neighborIds); + + return () => { + cancelAnimationFrame(frame); + ro.disconnect(); + renderer.domElement.removeEventListener("pointermove", onMove); + renderer.domElement.removeEventListener("click", onClick); + delete (host as HostEl).__paint; + controls.dispose(); + sphere.dispose(); + edgeGeom.dispose(); + planeMat.dispose(); + for (const geom of discGeoms) geom.dispose(); + (lines.material as THREE.Material).dispose(); + for (const label of labels) { + const material = label.material as THREE.SpriteMaterial; + material.map?.dispose(); + material.dispose(); + } + for (const mesh of meshById.values()) { + (mesh.material as THREE.Material).dispose(); + } + try { + renderer.forceContextLoss(); + } catch { + /* already lost */ + } + renderer.dispose(); + renderer.domElement.remove(); + setHover(null); + }; + }, [nodes, edges]); + + useEffect(() => { + (hostRef.current as HostEl | null)?.__paint?.(selectedId, neighborIds); + }, [selectedId, neighborIds]); + + return ( +
+
+ {webglError ? ( +

+ {webglError} +

+ ) : null} + {hover ? ( +
+
{typeLabel(hover.node.type)}
+
{hover.node.name}
+
+ ) : null} +
+ ); +} diff --git a/ui/src/graphView.test.ts b/ui/src/graphView.test.ts new file mode 100644 index 0000000..a792c02 --- /dev/null +++ b/ui/src/graphView.test.ts @@ -0,0 +1,86 @@ +import { describe, expect, it } from "vitest"; +import { LAYER_ORDER } from "./types"; +import { + LARGE_GRAPH, + LAYER_LABELS, + defaultDetail, + defaultProjection, + layoutNodes3d, + neighborIds, + visibleGraph, +} from "./graphView"; +import type { GraphEdge, GraphNode } from "./types"; + +function node(id: string, type: string, name = id): GraphNode { + return { id, type, name, qualified_name: name }; +} + +function edge(src: string, dst: string): GraphEdge { + return { id: `${src}->${dst}`, src, dst, type: "uses", weight: "cheap", confidence: 1 }; +} + +const nodes: GraphNode[] = [ + node("a", "django.model", "A"), + node("b", "django.field", "B"), + node("c", "react.component", "C"), + node("d", "django.test", "test_a"), +]; + +const edges: GraphEdge[] = [edge("a", "b"), edge("a", "c"), edge("d", "a")]; + +const allFamilies = new Set(["django", "react", "stitch", "arch"] as const); + +describe("visibleGraph", () => { + it("overview hides fields and tests", () => { + const g = visibleGraph(nodes, edges, { detail: "overview", families: allFamilies }); + expect(g.nodes.map((n) => n.id).sort()).toEqual(["a", "c"]); + expect(g.edges).toHaveLength(1); + expect(g.edges[0].dst).toBe("c"); + }); + + it("neighborhood keeps both directions", () => { + const g = visibleGraph(nodes, edges, { + detail: "full", + families: allFamilies, + focusId: "a", + neighborhoodOnly: true, + }); + expect(g.nodes.map((n) => n.id).sort()).toEqual(["a", "b", "c", "d"]); + }); + + it("family chips drop other stacks", () => { + const g = visibleGraph(nodes, edges, { detail: "full", families: new Set(["django"]) }); + expect(g.nodes.map((n) => n.id).sort()).toEqual(["a", "b", "d"]); + expect(g.edges.map((e) => `${e.src}->${e.dst}`).sort()).toEqual(["a->b", "d->a"]); + }); +}); + +describe("layoutNodes3d", () => { + it("places later layers further along x", () => { + const laid = layoutNodes3d(nodes.filter((n) => n.id === "a" || n.id === "c")); + const django = laid.get("a")!; + const react = laid.get("c")!; + expect(react.x).toBeGreaterThan(django.x); + }); +}); + +describe("neighborIds", () => { + it("includes self and both edge directions", () => { + expect([...neighborIds("a", edges)].sort()).toEqual(["a", "b", "c", "d"]); + }); +}); + +describe("defaults", () => { + it("uses 3d overview once the graph is large", () => { + expect(defaultProjection(LARGE_GRAPH - 1)).toBe("2d"); + expect(defaultProjection(LARGE_GRAPH)).toBe("3d"); + expect(defaultDetail(LARGE_GRAPH - 1)).toBe("full"); + expect(defaultDetail(LARGE_GRAPH)).toBe("overview"); + }); + + it("names every architecture layer used in 2d layout", () => { + for (const layer of new Set(Object.values(LAYER_ORDER))) { + expect(LAYER_LABELS[layer]).toBeTruthy(); + } + }); +}); diff --git a/ui/src/graphView.ts b/ui/src/graphView.ts new file mode 100644 index 0000000..a011e7a --- /dev/null +++ b/ui/src/graphView.ts @@ -0,0 +1,178 @@ +import { layerFor, type GraphEdge, type GraphNode } from "./types"; + +export type GraphFamily = "django" | "react" | "stitch" | "arch"; +export type GraphDetail = "overview" | "full"; +export type GraphProjection = "2d" | "3d"; + +export const LARGE_GRAPH = 90; + +/** Leaf noise that turns a load-path into an unreadable field cloud. */ +export const OVERVIEW_HIDDEN_TYPES = new Set([ + "django.field", + "django.serializer_field", + "django.relation", + "django.test", + "react.test", + "django.url_name", + "django.throttle", +]); + +export const TYPE_COLOR: Record = { + "arch.context": "#edf2f4", + "django.app": "#8d99ae", + "django.route": "#4cc9f0", + "django.view": "#4895ef", + "django.viewset_action": "#4361ee", + "django.permission": "#7b8cde", + "django.serializer": "#f4a261", + "django.form": "#e9c46a", + "django.serializer_field": "#e9c46a", + "django.service": "#90be6d", + "django.model": "#2a9d8f", + "django.field": "#8ac926", + "django.task": "#e76f51", + "django.receiver": "#e85d04", + "django.signal": "#f4a261", + "django.test": "#6c757d", + "django.admin": "#adb5bd", + "django.migration_op": "#9d4edd", + "openapi.path": "#00bbf9", + "react.api_client": "#ff6b6b", + "react.query_key": "#adb5bd", + "react.hook": "#7b2cbf", + "react.feature": "#9d4edd", + "react.route": "#c77dff", + "react.page": "#c77dff", + "react.component": "#9d4edd", + "react.form_schema": "#ffd166", + "react.test": "#6c757d", +}; + +const GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5)); +const LAYER_GAP = 220; +const SPIRAL = 26; + +export const LAYER_LABELS: Record = { + 0: "context", + 1: "routes", + 2: "views", + 3: "serializers", + 4: "services", + 5: "models", + 6: "fields", + 7: "jobs / signals", + 8: "openapi", + 9: "api client", + 10: "hooks", + 11: "pages", + 12: "components", + 13: "forms / tests", +}; + +export function familyFor(type: string): GraphFamily { + if (type.startsWith("react.")) return "react"; + if (type.startsWith("openapi.")) return "stitch"; + if (type.startsWith("arch.")) return "arch"; + return "django"; +} + +export function colorForType(type: string): string { + if (TYPE_COLOR[type]) return TYPE_COLOR[type]; + if (type.startsWith("react.")) return "#9d4edd"; + if (type.startsWith("openapi.")) return "#00bbf9"; + return "#4a5568"; +} + +export function defaultProjection(nodeCount: number): GraphProjection { + return nodeCount >= LARGE_GRAPH ? "3d" : "2d"; +} + +export function defaultDetail(nodeCount: number): GraphDetail { + return nodeCount >= LARGE_GRAPH ? "overview" : "full"; +} + +export function neighborIds(seed: string, edges: GraphEdge[], hops = 1): Set { + const ids = new Set([seed]); + let frontier = new Set([seed]); + for (let i = 0; i < hops; i += 1) { + const next = new Set(); + for (const edge of edges) { + if (frontier.has(edge.src) && !ids.has(edge.dst)) { + ids.add(edge.dst); + next.add(edge.dst); + } + if (frontier.has(edge.dst) && !ids.has(edge.src)) { + ids.add(edge.src); + next.add(edge.src); + } + } + frontier = next; + if (!frontier.size) break; + } + return ids; +} + +export function visibleGraph( + nodes: GraphNode[], + edges: GraphEdge[], + opts: { + detail: GraphDetail; + families: ReadonlySet; + focusId?: string | null; + neighborhoodOnly?: boolean; + }, +): { nodes: GraphNode[]; edges: GraphEdge[]; neighborIds: Set } { + let kept = nodes.filter((n) => opts.families.has(familyFor(n.type))); + if (opts.detail === "overview") { + kept = kept.filter((n) => !OVERVIEW_HIDDEN_TYPES.has(n.type)); + } + const ids = new Set(kept.map((n) => n.id)); + const linked = edges.filter((e) => ids.has(e.src) && ids.has(e.dst)); + const neighbors = opts.focusId ? neighborIds(opts.focusId, linked, 1) : new Set(); + if (opts.neighborhoodOnly && opts.focusId && neighbors.size) { + kept = kept.filter((n) => neighbors.has(n.id)); + const focusIds = new Set(kept.map((n) => n.id)); + return { + nodes: kept, + edges: linked.filter((e) => focusIds.has(e.src) && focusIds.has(e.dst)), + neighborIds: neighbors, + }; + } + return { nodes: kept, edges: linked, neighborIds: neighbors }; +} + +export function layoutNodes3d(nodes: GraphNode[]): Map { + const columns = new Map(); + for (const n of nodes) { + const layer = layerFor(n.type); + const list = columns.get(layer) ?? []; + list.push(n); + columns.set(layer, list); + } + const pos = new Map(); + for (const [layer, list] of columns) { + list.sort((a, b) => a.name.localeCompare(b.name)); + const x = layer * LAYER_GAP; + list.forEach((n, i) => { + if (list.length === 1) { + pos.set(n.id, { x, y: 0, z: 0 }); + return; + } + const r = SPIRAL * Math.sqrt(i + 1); + const theta = i * GOLDEN_ANGLE; + pos.set(n.id, { x, y: r * Math.cos(theta), z: r * Math.sin(theta) }); + }); + } + return pos; +} + +export function layerCenters(nodes: GraphNode[]): { layer: number; x: number; count: number }[] { + const counts = new Map(); + for (const n of nodes) { + const layer = layerFor(n.type); + counts.set(layer, (counts.get(layer) || 0) + 1); + } + return [...counts.entries()] + .sort((a, b) => a[0] - b[0]) + .map(([layer, count]) => ({ layer, x: layer * LAYER_GAP, count })); +} diff --git a/ui/src/styles.css b/ui/src/styles.css index f133598..245136a 100644 --- a/ui/src/styles.css +++ b/ui/src/styles.css @@ -603,6 +603,93 @@ kbd { background: radial-gradient(circle at 0 0, color-mix(in srgb, var(--accent) 8%, transparent), transparent 42%), var(--bg); } .graph-wrap { position: relative; min-height: 0; display: flex; flex-direction: column; } +.impact-graph { + flex: 1; + min-height: 0; + position: relative; + display: flex; + flex-direction: column; +} +.graph-toolbar { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: center; + padding: 8px 14px; + border-bottom: 1px solid var(--line); + background: var(--bg-2); +} +.graph-count { margin-left: auto; font-size: 11px; } +.chip-btn { + background: var(--surface); + border: 1px solid var(--line); + border-radius: 999px; + padding: 4px 12px; + color: var(--muted); + cursor: pointer; + height: 26px; +} +.chip-btn:hover { color: var(--ink); } +.chip-btn.active { + background: var(--rail-active); + color: var(--ink); +} +.chip-btn:disabled { + opacity: 0.45; + cursor: not-allowed; +} +.graph-stage { + flex: 1; + min-height: 0; + position: relative; + display: flex; + flex-direction: column; +} +.graph-stage .react-flow, +.graph-3d, +.graph-3d-host, +.graph-3d-canvas-host { + flex: 1; + width: 100%; + height: 100%; + min-height: 280px; +} +.graph-3d { + position: relative; + background: var(--graph-bg); + display: flex; + flex-direction: column; +} +.graph-3d-host { position: relative; min-height: 0; display: flex; flex-direction: column; } +.graph-3d-canvas-host { position: relative; min-height: 0; } +.graph-3d canvas { display: block; width: 100%; height: 100%; } +.graph-3d-tip { + position: absolute; + pointer-events: none; + z-index: 2; + max-width: 320px; + padding: 6px 8px; + border-radius: var(--radius); + background: var(--surface); + border: 1px solid var(--line); + color: var(--ink); + font-size: 11px; + line-height: 1.35; + box-shadow: 0 8px 24px var(--shadow); +} +.graph-3d-tip .t { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; } +.graph-3d-tip .n { font-weight: 600; } +.graph-3d-hint { + position: absolute; + left: 10px; + bottom: 10px; + z-index: 2; + margin: 0; + font-size: 11px; + color: var(--muted); + max-width: min(420px, calc(100% - 24px)); + pointer-events: none; +} .graph-wrap .react-flow { background-color: var(--graph-bg); background-image: @@ -914,7 +1001,8 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } height: 56px; box-sizing: border-box; box-shadow: 0 0 0 1px var(--shadow); - overflow: hidden; + overflow: visible; + position: relative; } .lp-node .t { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; } .lp-node .n { @@ -925,6 +1013,13 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } white-space: nowrap; } .lp-node.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); } +.react-flow__node-load .react-flow__handle { + width: 8px; + height: 8px; + border: none; + background: transparent; + opacity: 0; +} .type-table { width: 100%; border-collapse: collapse; diff --git a/ui/src/types.ts b/ui/src/types.ts index d819b7b..163655e 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -171,6 +171,7 @@ export const LAYER_ORDER: Record = { "django.viewset_action": 2, "django.permission": 2, "django.serializer": 3, + "django.form": 3, "django.serializer_field": 4, "django.service": 4, "django.model": 5,