From 9755f385d91dd3f57c1519d37555ac9ff2152fe6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 10:20:17 +0000 Subject: [PATCH 1/7] Fix views-package collisions, regex route labels, and FilterSet nodes. A second OSS PR sweep (pretix, Weblate, NetBox, addons-server, and others) showed view/form/model nodes under app/views/*.py sharing a views.* id, so route edges were pruned and the inspector mixed apps. Name those nodes from the Django app, treat re_path("^$") / named groups as real URLs, skip GraphiQL and demo-app trees when detecting React, and extract django-filter FilterSets so filterset_class reviews have a typed graph. Co-authored-by: zord.lack.net --- src/loadpath/detect.py | 6 ++ src/loadpath/extractors/django.py | 90 ++++++++++++------- src/loadpath/index.py | 2 +- ...mUQO6wms.js => LayeredGraph3D-D8Vppi7Z.js} | 2 +- .../{index-CEZTl1rC.js => index-BAQ4x0wM.js} | 2 +- src/loadpath/static/index.html | 2 +- src/loadpath/stitch/openapi.py | 11 +-- tests/unit/test_detect.py | 27 ++++++ tests/unit/test_django_extractors.py | 74 +++++++++++++++ tests/unit/test_index_and_stitch.py | 1 + ui/src/nodeInspector.test.ts | 16 ++++ ui/src/nodeInspector.ts | 5 +- 12 files changed, 194 insertions(+), 44 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-mUQO6wms.js => LayeredGraph3D-D8Vppi7Z.js} (99%) rename src/loadpath/static/assets/{index-CEZTl1rC.js => index-BAQ4x0wM.js} (86%) diff --git a/src/loadpath/detect.py b/src/loadpath/detect.py index 998205c..2abdf9c 100644 --- a/src/loadpath/detect.py +++ b/src/loadpath/detect.py @@ -175,6 +175,7 @@ def _detect_django_root(repo_root: Path) -> str: "web/src", "client/src", "ui/src", + "ui", ) SKIP_REACT_PARTS = { @@ -186,6 +187,11 @@ def _detect_django_root(repo_root: Path) -> str: "starlight_help", "e2e", "cypress", + "graphiql", + "demo-app", + "demo", + "example", + "examples", } diff --git a/src/loadpath/extractors/django.py b/src/loadpath/extractors/django.py index c836e5d..5771aeb 100644 --- a/src/loadpath/extractors/django.py +++ b/src/loadpath/extractors/django.py @@ -31,7 +31,28 @@ SERIALIZER_BASES = {"Serializer", "ModelSerializer", "HyperlinkedModelSerializer", "ListSerializer"} FORM_BASES = {"Form", "ModelForm", "BaseForm", "BaseModelForm"} +FILTERSET_BASES = {"FilterSet"} MODEL_BASES = {"Model"} +# Subpackages that are never the Django app name (billing/views/foo.py → billing). +APP_PACKAGE_DIRS = { + "views", + "serializers", + "models", + "forms", + "tasks", + "admin", + "tests", + "templatetags", + "management", + "commands", + "migrations", + "actors", + "signals", + "receivers", + "services", + "handlers", +} +REGEX_NAMED_GROUP = re.compile(r"\(\?P<(\w+)>[^)]*\)") ADMIN_BASES = {"ModelAdmin", "StackedInline", "TabularInline"} CELERY_DECORATORS = {"shared_task", "task", "periodic_task"} DRAMATIQ_DECORATORS = {"actor"} @@ -134,32 +155,30 @@ def _truthy(node: ast.AST | None) -> bool: return isinstance(node, ast.Constant) and node.value is True +def strip_url_anchors(route: str) -> str: + route = (route or "").strip() + if route.startswith("include:"): + return "" + if route.startswith("^"): + route = route[1:] + if route.endswith("$") and not route.endswith("\\$"): + route = route[:-1] + return route + + +def pretty_url_pattern(route: str) -> str: + """Turn `^$` / `(?P…)` into a graph-readable path fragment.""" + route = REGEX_NAMED_GROUP.sub(r"{\1}", route or "") + return strip_url_anchors(route) + + def _app_from_path(rel: str) -> str | None: - parts = Path(rel).parts - # backend/billing/models.py → billing - if "migrations" in parts: - idx = parts.index("migrations") - 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", - "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] - if len(parts) >= 2 and parts[-1].endswith(".py"): - return parts[-2] - return None + parts = list(Path(rel).parts) + if parts and parts[-1].endswith(".py"): + parts = parts[:-1] + while parts and parts[-1] in APP_PACKAGE_DIRS: + parts.pop() + return parts[-1] if parts else None def _module_qual(rel: str) -> str: @@ -234,6 +253,8 @@ def visit_ClassDef(self, node: ast.ClassDef) -> None: and not _has_base(node, {"TestCase", "SimpleTestCase", "TransactionTestCase", "LiveServerTestCase", "APITestCase"}) ): self._serializer(node, ntype=NodeType.FORM) + elif _has_base(node, FILTERSET_BASES) or node.name.endswith("FilterSet"): + self._serializer(node, ntype=NodeType.FORM, filterset=True) 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)): @@ -364,11 +385,15 @@ 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, ntype: NodeType = NodeType.SERIALIZER) -> None: + def _serializer( + self, node: ast.ClassDef, ntype: NodeType = NodeType.SERIALIZER, *, filterset: bool = False + ) -> None: qname = f"{self.app}.{node.name}" extra: dict = {"app": self.app} if ntype is NodeType.FORM: - extra["django_form"] = True + extra["django_form"] = not filterset + if filterset: + extra["filterset"] = True ser = self.add_node(ntype, node.name, qname, node.lineno, extra) meta_model = None meta_fields: list[str] | None = None @@ -486,6 +511,10 @@ def _view(self, node: ast.ClassDef) -> None: else f"{self.app}.{serializer_class.split('.')[-1]}" ) self.add_edge(view.id, node_id(NodeType.SERIALIZER, ser_q), EdgeType.USES_SERIALIZER) + if extra.get("filterset") and extra["filterset"] not in {True, False}: + fs = str(extra["filterset"]) + fs_q = fs if "." in fs and not fs.startswith("filter") else f"{self.app}.{fs.split('.')[-1]}" + self.add_edge(view.id, node_id(NodeType.FORM, fs_q), EdgeType.CALLS, confidence=0.9) for perm in permissions: pid = node_id(NodeType.PERMISSION, perm) self.graph.nodes.append( @@ -899,10 +928,11 @@ def _include_target(self, call: ast.Call) -> str | None: def _route_identity( self, route: str, include_mod: str | None, name: str | None, lineno: int ) -> tuple[str, str]: - """Empty `path("", …)` must still show a label and a unique id.""" + """Empty `path("")` / `re_path(r"^$")` must still show a label and a unique id.""" stamp = f"{Path(self.rel_path).name}:{lineno}" - if route: - return route, f"{self.app}:{route}" + pretty = pretty_url_pattern(route) + if pretty: + return pretty, f"{self.app}:{route}" if include_mod: return f"include:{include_mod}", f"{self.app}:include:{include_mod}:{stamp}" if name: diff --git a/src/loadpath/index.py b/src/loadpath/index.py index 1e7abc3..a7df986 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 = "8" +INDEX_REVISION = "9" def default_db_path(repo_root: Path) -> Path: diff --git a/src/loadpath/static/assets/LayeredGraph3D-mUQO6wms.js b/src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-mUQO6wms.js rename to src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js index ba45ac8..bc8f5cc 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-mUQO6wms.js +++ b/src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js @@ -1,4 +1,4 @@ -import{r as bn,l as tc,c as nc,a as ic,L as sc,j as jn,t as rc}from"./index-CEZTl1rC.js";/** +import{r as bn,l as tc,c as nc,a as ic,L as sc,j as jn,t as rc}from"./index-BAQ4x0wM.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-CEZTl1rC.js b/src/loadpath/static/assets/index-BAQ4x0wM.js similarity index 86% rename from src/loadpath/static/assets/index-CEZTl1rC.js rename to src/loadpath/static/assets/index-BAQ4x0wM.js index 029e199..5197b6e 100644 --- a/src/loadpath/static/assets/index-CEZTl1rC.js +++ b/src/loadpath/static/assets/index-BAQ4x0wM.js @@ -59,4 +59,4 @@ Error generating stack: `+h.message+` `,` +`).split(` `)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Fh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Bh(_.code,f);if(u.current.add(_[C]),Hh(d,u.current,!1)){const I=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,k=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),l(!0)}},x=_=>{const S=Bh(_.code,f);Hh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[S]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Hh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Bh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=uc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Vh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Uh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Wh=t=>Kw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const zg=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Yh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Ag=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:S}=r.getState();let C=g;for(const N of f)C=typeof N=="function"?N(C):N;let E=Vh({items:C,lookup:v});for(const N of S.values())E=N(E);m&&y(C),E.length>0?x==null||x(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:I,setNodes:k}=r.getState();N&&k(I)})},[]),l=Yh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const S of f)_=typeof S=="function"?S(_):S;m?y(_):x&&x(Vh({items:_,lookup:v}))},[]),u=Yh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(Ag.Provider,{value:d,children:t})}function T_(){const t=$.useContext(Ag);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function mc(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var N,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),S=Wh(x)?x:v.get(x.id),C=S.parentId?ug(S.position,S.measured,S.parentId,v,_):S.position,E={...S,position:C,width:((N=S.measured)==null?void 0:N.width)??S.width,height:((I=S.measured)==null?void 0:I.height)??S.height};return No(E)},y=(x,v,_={replace:!1})=>{d(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&Wh(E)?E:{...C,...E}}return C}))},m=(x,v,_={replace:!1})=>{f(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&M_(E)?E:{...C,...E}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[S,C,E]=_;return{nodes:x.map(N=>({...N})),edges:v.map(N=>({...N})),viewport:{x:S,y:C,zoom:E}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:S,onNodesDelete:C,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:I,onDelete:k,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:S,onBeforeDelete:j}),B=T.length>0,G=R.length>0;if(B){const U=T.map(Uh);E==null||E(T),I(U)}if(G){const U=R.map(Uh);C==null||C(R),N(U)}return(G||B)&&(k==null||k({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const S=mh(x),C=S?x:g(x),E=_!==void 0;return C?(_||r.getState().nodes).filter(N=>{const I=r.getState().nodeLookup.get(N.id);if(I&&!S&&(N.id===x.id||!I.internals.positionAbsolute))return!1;const k=No(E?N:I),j=pl(k,C);return v&&j>0||j>=k.width*k.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=mh(x)?x:g(x);if(!C)return!1;const E=pl(C,v);return _&&E>0||E>=v.width*v.height||E>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return qw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:S.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Xh=t=>t.selected,L_=typeof window<"u"?window:void 0;function z_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=mc(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Xh),edges:d.filter(Xh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function A_(t){const r=He();$.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=cc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 bl={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Ir.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:S=!0,children:C,noWheelClassName:E,noPanClassName:N,onViewportChange:I,isControlledViewport:k,paneClickDistance:j,selectionOnDrag:R}){const T=He(),B=$.useRef(null),{userSelectionActive:G,lib:U,connectionInProgress:ee}=Re(D_,Xe),q=jo(_),te=$.useRef();A_(B);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),k||T.setState({transform:b})},[I,k]);return $.useEffect(()=>{if(B.current){te.current=H1({domNode:B.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:W=>T.setState(D=>D.paneDragging===W?D:{paneDragging:W}),onPanZoomStart:(W,D)=>{const{onViewportChangeStart:A,onMoveStart:H}=T.getState();H==null||H(W,D),A==null||A(D)},onPanZoom:(W,D)=>{const{onViewportChange:A,onMove:H}=T.getState();H==null||H(W,D),A==null||A(D)},onPanZoomEnd:(W,D)=>{const{onViewportChangeEnd:A,onMoveEnd:H}=T.getState();H==null||H(W,D),A==null||A(D)}});const{x:b,y:Y,zoom:V}=te.current.getViewport();return T.setState({panZoom:te.current,transform:[b,Y,V],domNode:B.current.closest(".react-flow")}),()=>{var W;(W=te.current)==null||W.destroy()}}},[]),$.useEffect(()=>{var b;(b=te.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:q,preventScrolling:S,noPanClassName:N,userSelectionActive:G,noWheelClassName:E,lib:U,onTransformChange:J,connectionInProgress:ee,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,q,S,N,G,E,U,J,ee,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:B,style:bl,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Au=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:S,children:C}){const E=$.useRef(0),N=He(),{userSelectionActive:I,elementsSelectable:k,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),B=k&&(t||I),G=$.useRef(null),U=$.useRef(),ee=$.useRef(new Set),q=$.useRef(new Set),te=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=K=>{if(J.current||te.current||N.getState().connection.inProgress){J.current=!1,te.current=!1;return}y==null||y(K),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},W=K=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){K.preventDefault();return}m==null||m(K)},D=x?K=>x(K):void 0,A=K=>{J.current&&(K.stopPropagation(),J.current=!1)},H=K=>{var Me,tt;if(K.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=N.getState();if(U.current=se==null?void 0:se.getBoundingClientRect(),!U.current)return;const _e=K.target===G.current;if(!_e&&!!K.target.closest(".nokey")||!t||!(d&&_e||r)||K.button!==0||!K.isPrimary)return;(tt=(Me=K.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,K.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(K.nativeEvent,U.current),je=Lo({x:Ne,y:Pe},pe);N.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(K.stopPropagation(),K.preventDefault())};function M(K,se){const{userSelectionRect:pe}=N.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=N.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),Ke={startX:tt.x,startY:tt.y,x:Kut.id)),q.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of ee.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&q.current.add(ht)}}if(!yh(bt,ee.current)){const ut=gi(me,ee.current,!0);Pe(ut)}if(!yh(Dt,q.current)){const ut=gi(ye,q.current);je(ut)}N.setState({userSelectionRect:Ke,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!U.current)return;const[K,se]=ac(b.current,U.current,T);R({x:K,y:se}).then(pe=>{if(!J.current||!pe){E.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),E.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(E.current),E.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=K=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=N.getState();if(!U.current||!se)return;const{x:me,y:ye}=en(K.nativeEvent,U.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(K)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=K=>{var se,pe;if(!B){K.target===G.current&&N.getState().connection.inProgress&&(te.current=!0);return}K.button===0&&((pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),!I&&K.target===G.current&&N.getState().userSelectionRect&&(V==null||V(K)),N.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(K),N.setState({nodesSelectionActive:ee.current.size>0})),ne())},fe=K=>{var se,pe;(pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:B?void 0:Au(V,G),onContextMenu:Au(W,G),onWheel:Au(D,G),onPointerEnter:B?void 0:v,onPointerMove:B?re:_,onPointerUp:ce,onPointerCancel:B?fe:void 0,onPointerDownCapture:B?H:void 0,onClickCapture:B?A:void 0,onPointerLeave:S,ref:G,style:bl,children:[C,p.jsx(F_,{})]})}function Zu({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Zu({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,S=a?u[1]:5,C=o.direction.x*_*o.factor,E=o.direction.y*S*o.factor;for(const[,N]of y){if(!v(N))continue;let I={x:N.internals.positionAbsolute.x+C,y:N.internals.positionAbsolute.y+E};a&&(I=Ro(I,u));const{position:k,positionAbsolute:j}=rg({nodeId:N.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});N.position=k,N.internals.positionAbsolute=j,x.set(N.id,N)}g(x)},[])}const yc=$.createContext(null),U_=yc.Provider;yc.Consumer;const Og=()=>$.useContext(yc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function K_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const S=d||null,C=t==="target",E=He(),N=Og(),{connectOnClick:I,noPanClassName:k,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:B,isPossibleEndHandle:G,connectionInProcess:U,clickConnectionInProcess:ee,valid:q}=Re(Q_(N,S,t),Xe);N||(V=(Y=E.getState()).onError)==null||V.call(Y,"010",tn.error010());const te=W=>{const{defaultEdgeOptions:D,onConnect:A,hasDefaultEdges:H}=E.getState(),M={...D,...W};if(H){const{edges:L,setEdges:ne,onError:re}=E.getState();ne(b_(M,L,{onError:re}))}A==null||A(M),f==null||f(M)},J=W=>{if(!N)return;const D=fg(W.nativeEvent);if(a&&(D&&W.button===0||!D)){const A=E.getState();qu.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:C,handleId:S,nodeId:N,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...H)=>{var M,L;return(L=(M=E.getState()).onConnectEnd)==null?void 0:L.call(M,...H)},updateConnection:A.updateConnection,onConnect:te,isValidConnection:o||((...H)=>{var M,L;return((L=(M=E.getState()).isValidConnection)==null?void 0:L.call(M,...H))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}D?m==null||m(W):x==null||x(W)},b=W=>{const{onClickConnectStart:D,onClickConnectEnd:A,connectionClickStartHandle:H,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=E.getState();if(!N||!H&&!a)return;if(!H){D==null||D(W.nativeEvent,{nodeId:N,handleId:S,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:S}});return}const de=cg(W.target),K=o||L,{connection:se,isValid:pe}=qu.isValid(W.nativeEvent,{handle:{nodeId:N,id:S,type:t},connectionMode:M,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:K,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&te(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,A==null||A(W,_e),E.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":S,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${S}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:R,connectingto:T,valid:q,connectionindicator:l&&(!U||G)&&(U||ee?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(K_));function q_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Gh={input:q_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const S=l.getState().nodes.filter(C=>C.selected);t(_,S)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Qh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:I,zoomOnPinch:k,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:B,panOnDrag:G,autoPanOnSelection:U,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:W,disableKeyboardA11y:D,onViewportChange:A,isControlledViewport:H}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Qh}),re=jo(C,{target:Qh}),ce=re||G,fe=re||j,de=m&&ce!==!0,K=ne||L||de;return z_({deleteKeyCode:g,multiSelectionKeyCode:S}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:I,zoomOnPinch:k,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:B,panOnDrag:!ne&&ce,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,zoomActivationKeyCode:E,preventScrolling:b,noWheelClassName:V,noPanClassName:W,onViewportChange:A,isControlledViewport:H,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:U,isSelecting:!!K,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:W,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?lc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:S,rfId:C,nodeTypes:E,nodeClickDistance:N,onError:I}){const{node:k,internals:j,isParent:R}=Re(K=>{const se=K.nodeLookup.get(t),pe=K.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=k.type||"default",B=(E==null?void 0:E[T])||Gh[T];B===void 0&&(I==null||I("003",tn.error003(T)),T="default",B=(E==null?void 0:E.default)||Gh.default);const G=!!(k.draggable||f&&typeof k.draggable>"u"),U=!!(k.selectable||g&&typeof k.selectable>"u"),ee=!!(k.connectable||y&&typeof k.connectable>"u"),q=!!(k.focusable||m&&typeof k.focusable>"u"),te=He(),J=ag(k),b=cS({node:k,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:k.hidden||!G,noDragClassName:v,handleSelector:k.dragHandle,nodeId:t,isSelectable:U,nodeClickDistance:N}),V=$g();if(k.hidden)return null;const W=rn(k),D=tS(k),A=U||G||r||o||l||a,H=o?K=>o(K,{...j.userNode}):void 0,M=l?K=>l(K,{...j.userNode}):void 0,L=a?K=>a(K,{...j.userNode}):void 0,ne=u?K=>u(K,{...j.userNode}):void 0,re=d?K=>d(K,{...j.userNode}):void 0,ce=K=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=te.getState();U&&(!se||!G||pe>0)&&Zu({id:t,store:te,nodeRef:b}),r&&r(K,{...j.userNode})},fe=K=>{if(!(dg(K.nativeEvent)||S)){if(Zp.includes(K.key)&&U){const se=K.key==="Escape";Zu({id:t,store:te,unselect:se,nodeRef:b})}else if(G&&k.selected&&Object.prototype.hasOwnProperty.call(gl,K.key)){K.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:K.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[K.key],factor:K.shiftKey?4:1})}}},de=()=>{var Ne;if(S||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:K,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=te.getState();if(!_e)return;lc(new Map([[t,k]]),{x:0,y:0,width:se,height:pe},K,!0).length>0||me(k.position.x+W.width/2,k.position.y+W.height/2,{zoom:K[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},k.className,{selected:k.selected,selectable:U,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:J?"visible":"hidden",...k.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:q?fe:void 0,tabIndex:q?0:void 0,onFocus:q?de:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Pg}-${C}`,"aria-label":k.ariaLabel,...k.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(B,{id:t,data:k.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:k.selected??!1,selectable:U,draggable:G,deletable:k.deletable??!0,isConnectable:ee,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:Y,dragHandle:k.dragHandle,zIndex:j.z,parentId:k.parentId,...W})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:bl,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Kh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Kh,t)?Kh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),S=$.useRef(null);return $.useEffect(()=>{if(S.current){const C=S.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:S,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Ml({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function qh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=qh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=qh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:N})=>{const[I,k,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Ml,{id:R,path:I,labelX:k,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:N})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:S=Se.Top,markerEnd:C,markerStart:E,pathOptions:N,interactionWidth:I})=>{const[k,j,R]=Gu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:S,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Ml,{id:T,path:k,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:E,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),Kg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";Kg.displayName="SmoothStepEdgeInternal";function qg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=qg({isInternal:!1}),Zg=qg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:S,interactionWidth:C})=>{const[E,N,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return p.jsx(Ml,{id:k,path:E,labelX:N,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:S,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,pathOptions:N,interactionWidth:I})=>{const[k,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:N==null?void 0:N.curvature}),T=t.isInternal?void 0:r;return p.jsx(Ml,{id:T,path:k,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const Zh={default:nm,straight:em,step:Zg,smoothstep:Kg,simplebezier:Xg},Jh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ep="react-flow__edgeupdater";function tp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([ep,`${ep}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const S=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:B,connectionMode:G,connectionRadius:U,lib:ee,onConnectStart:q,cancelConnection:te,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=S.getState(),W=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},A=M=>y==null?void 0:y(o,M),H=(M,L)=>{v(!0),m==null||m(j,o,R.type),q==null||q(M,L)};qu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:U,domNode:B,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:W,edgeUpdaterType:R.type,lib:ee,flowId:b,cancelConnection:te,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=S.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:A,onConnectStart:H,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=S.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),k=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(tp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&p.jsx(tp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:N,onMouseEnter:I,onMouseOut:k,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:S,edgeTypes:C,noPanClassName:E,onError:N,disableKeyboardA11y:I}){let k=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);k=j?{...j,...k}:k;let R=k.type||"default",T=(C==null?void 0:C[R])||Zh[R];T===void 0&&(N==null||N("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||Zh.default);const B=!!(k.focusable||r&&typeof k.focusable>"u"),G=typeof x<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),U=!!(k.selectable||l&&typeof k.selectable>"u"),ee=$.useRef(null),[q,te]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=k.zIndex,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(k.source),Ne=me.nodeLookup.get(k.target);if(!ye||!Ne)return Jh;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:me.connectionMode,onError:N}),je=l1({selected:k.selected,zIndex:k.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||Jh,zIndex:je}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,N]),Xe),ne=$.useMemo(()=>k.markerStart?`url('#${Qu(k.markerStart,S)}')`:void 0,[k.markerStart,S]),re=$.useMemo(()=>k.markerEnd?`url('#${Qu(k.markerEnd,S)}')`:void 0,[k.markerEnd,S]);if(k.hidden||W===null||D===null||A===null||H===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();U&&(Y.setState({nodesSelectionActive:!1}),k.selected&&Pe?(Ne({nodes:[],edges:[k]}),(je=ee.current)==null||je.blur()):ye([t])),a&&a(me,k)},fe=u?me=>{u(me,{...k})}:void 0,de=d?me=>{d(me,{...k})}:void 0,K=f?me=>{f(me,{...k})}:void 0,se=g?me=>{g(me,{...k})}:void 0,pe=y?me=>{y(me,{...k})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&U){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=ee.current)==null||ye.blur(),Ne({edges:[k]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!U&&!a,updating:q,selectable:U}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:K,onMouseMove:se,onMouseLeave:pe,onKeyDown:B?_e:void 0,tabIndex:B?0:void 0,role:k.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":B?`${Ig}-${S}`:void 0,ref:ee,...k.domAttributes,children:[!J&&p.jsx(T,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:U,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),G&&p.jsx(bS,{edge:k,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L,setUpdateHover:te,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:S,disableKeyboardA11y:C}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:I,onError:k}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:S,rfId:o,onError:k,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),np=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return zg(()=>{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=np(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:np(l)},children:t})}function LS(t){const r=mc(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const zS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function AS(t){const r=Re(zS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let S="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[S]=pg(C);break;case nr.SimpleBezier:[S]=Wg(C);break;case nr.Step:[S]=Gu({...C,borderRadius:0});break;case nr.SmoothStep:[S]=Gu(C);break;default:[S]=mg(C)}return p.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function rp(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:S,connectionLineStyle:C,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:I,selectionOnDrag:k,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:B,deleteKeyCode:G,onlyRenderVisibleElements:U,elementsSelectable:ee,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:W,zoomOnPinch:D,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:K,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:Ke,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return rp(t),rp(r),VS(),LS(o),AS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:K,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:k,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:B,elementsSelectable:ee,zoomOnScroll:W,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:Ke,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:U,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:S,component:E,containerStyle:N}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:U,noPanClassName:Dt,noDragClassName:Ke,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),ip=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,S=new Map,C=new Map,E=new Map,N=l??r??[],I=o??t??[],k=m??[0,0],j=x??So;xg(C,E,N);const{nodesInitialized:R}=Ku(I,_,S,{nodeOrigin:k,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const B=To(_,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:G,y:U,zoom:ee}=uc(B,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,U,ee]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:S,edges:N,edgeLookup:E,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:f,fitViewResolver:null,connection:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,S)=>{async function C(){const{nodeLookup:E,panZoom:N,fitViewOptions:I,fitViewResolver:k,width:j,height:R,minZoom:T,maxZoom:B}=S();N&&(await e1({nodes:E,width:j,height:R,panZoom:N,minZoom:T,maxZoom:B},I),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...ip({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:E=>{const{nodeLookup:N,parentLookup:I,nodeOrigin:k,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:B,nodesSelectionActive:G}=S(),{nodesInitialized:U,hasSelectedNodes:ee}=Ku(E,N,I,{nodeOrigin:k,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:B}),q=G&ⅇT&&U?(C(),_({nodes:E,nodesInitialized:U,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):_({nodes:E,nodesInitialized:U,nodesSelectionActive:q})},setEdges:E=>{const{connectionLookup:N,edgeLookup:I}=S();xg(N,I,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:I}=S();I(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:I}=S();I(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:I,parentLookup:k,domNode:j,nodeOrigin:R,nodeExtent:T,debug:B,fitViewQueued:G,zIndexMode:U}=S(),{changes:ee,updatedInternals:q}=k1(E,I,k,j,R,T,U);q&&(x1(I,k,{nodeOrigin:R,nodeExtent:T,zIndexMode:U}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ee==null?void 0:ee.length)>0&&(B&&console.log("React Flow: trigger node changes",ee),N==null||N(ee)))},updateNodePositions:(E,N=!1)=>{const I=[];let k=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:B,onNodesChangeMiddlewareMap:G}=S();for(const[U,ee]of E){const q=j.get(U),te=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(ee!=null&&ee.position)),J={id:U,type:"position",position:te?{x:Math.max(0,ee.position.x),y:Math.max(0,ee.position.y)}:ee.position,dragging:N};if(q&&T.inProgress&&T.fromNode.id===q.id){const b=Ar(q,T.fromHandle,Se.Left,!0);B({...T,from:b})}te&&q.parentId&&I.push({id:U,parentId:q.parentId,rect:{...ee.internals.positionAbsolute,width:ee.measured.width??0,height:ee.measured.height??0}}),k.push(J)}if(I.length>0){const{parentLookup:U,nodeOrigin:ee}=S(),q=gc(I,j,U,ee);k.push(...q)}for(const U of G.values())k=U(k);R(k)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:I,nodes:k,hasDefaultNodes:j,debug:R}=S();if(E!=null&&E.length){if(j){const T=N_(E,k);I(T)}R&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:I,edges:k,hasDefaultEdges:j,debug:R}=S();if(E!=null&&E.length){if(j){const T=C_(E,k);I(T)}R&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:I,nodeLookup:k,triggerNodeChanges:j,triggerEdgeChanges:R}=S();if(N){const T=E.map(B=>br(B,!0));j(T);return}j(gi(k,new Set([...E]),!0)),R(gi(I))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:I,nodeLookup:k,triggerNodeChanges:j,triggerEdgeChanges:R}=S();if(N){const T=E.map(B=>br(B,!0));R(T);return}R(gi(I,new Set([...E]))),j(gi(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:I,nodes:k,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=S(),B=E||k,G=N||I,U=[];for(const q of B){if(!q.selected)continue;const te=j.get(q.id);te&&(te.selected=!1),U.push(br(q.id,!1))}const ee=[];for(const q of G)q.selected&&ee.push(br(q.id,!1));R(U),T(ee)},setMinZoom:E=>{const{panZoom:N,maxZoom:I}=S();N==null||N.setScaleExtent([E,I]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:I}=S();N==null||N.setScaleExtent([I,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=S().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:I,triggerEdgeChanges:k,elementsSelectable:j}=S();if(!j)return;const R=N.reduce((B,G)=>G.selected?[...B,br(G.id,!1)]:B,[]),T=E.reduce((B,G)=>G.selected?[...B,br(G.id,!1)]:B,[]);I(R),k(T)},setNodeExtent:E=>{const{nodes:N,nodeLookup:I,parentLookup:k,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:B}=S();E[0][0]===T[0][0]&&E[0][1]===T[0][1]&&E[1][0]===T[1][0]&&E[1][1]===T[1][1]||(Ku(N,I,k,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:I,height:k,panZoom:j,translateExtent:R}=S();return E1({delta:E,panZoom:j,transform:N,translateExtent:R,width:I,height:k})},setCenter:async(E,N,I)=>{const{width:k,height:j,maxZoom:R,panZoom:T}=S();if(!T)return!1;const B=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:k/2-E*B,y:j/2-N*B,zoom:B},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...ip()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[S]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:S,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:S,onConnectEnd:C,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:I,onNodeMouseMove:k,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:U,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:W,onSelectionStart:D,onSelectionEnd:A,onBeforeDelete:H,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:K=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:Ke=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:$r=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Ir.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:Ae,onEdgeMouseLeave:Rn,reconnectRadius:Or=10,onNodesChange:ji,onEdgesChange:Il,noDragClassName:Tl="nodrag",noWheelClassName:Rl="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Ll,attributionPosition:zo,proOptions:Ao,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Al,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Fr,isValidConnection:Dl,onError:Ho,style:Hr,id:Mt,nodeDragThreshold:$l,connectionDragThreshold:Pt,viewport:Ol,onViewportChange:Fl,width:Hl,height:Br,colorMode:Vr="light",debug:hr,onScroll:yn,ariaLabelConfig:Bl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Vr),Vl=$.useCallback(Ur=>{Ur.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Ur)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Vl,style:{...Hr,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Hl,height:Br,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:Ke,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:S,onConnectEnd:C,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Il,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Ll,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:U,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:Ke,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Al,autoPanSpeed:Fo,onError:Ho,connectionRadius:Fr,isValidConnection:Dl,selectNodesOnDrag:je,nodeDragThreshold:$l,connectionDragThreshold:Pt,onBeforeDelete:H,debug:hr,ariaLabelConfig:Bl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:k,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:K,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:$r,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:W,onSelectionStart:D,onSelectionEnd:A,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:Ae,onEdgeMouseLeave:Rn,reconnectRadius:Or,defaultMarkerColor:gn,noDragClassName:Tl,noWheelClassName:Rl,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Ol,onViewportChange:Fl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:Ao,position:zo}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var KS=Lg(QS);function qS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),S=l||JS[r],C=r===rr.Dots,E=r===rr.Cross,N=Array.isArray(o)?o:[o,o],I=[N[0]*v[2]||1,N[1]*v[2]||1],k=S*v[2],j=Array.isArray(u)?u:[u,u],R=E?[k,k]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],B=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...bl,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:B,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:k/2,className:m}):p.jsx(qS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const S=He(),{isInteractive:C,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:k,zoomOut:j,fitView:R}=mc(),T=()=>{k(),u==null||u()},B=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},U=()=>{S.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},ee=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",ee,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:N,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:B,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:E,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:U,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:S,backgroundColor:C}=u||{},E=d||S||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:E,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?N=>_(N,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),Du=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=Du(r),y=Du(t),m=Du(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(S=>{const C=S.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const E=C.internals.userNode,{x:N,y:I}=C.internals.positionAbsolute,{width:k,height:j}=rn(E);return{node:E,x:N,y:I,width:k,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},op=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>op(t.viewBB,r.viewBB)&&op(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:S,pannable:C=!1,zoomable:E=!1,ariaLabel:N,inversePan:I,zoomStep:k=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:B,viewBB:G,rfId:U,panZoom:ee,translateExtent:q,flowWidth:te,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,W=B.width/Y,D=B.height/V,A=Math.max(W,D),H=A*Y,M=A*V,L=j*A,ne=B.x-(H-B.width)/2-L,re=B.y-(M-B.height)/2-L,ce=H+L*2,fe=M+L*2,de=`${_k}-${U}`,K=$.useRef(0),se=$.useRef();K.current=A,$.useEffect(()=>{if(T.current&&ee)return se.current=R1({domNode:T.current,panZoom:ee,getTransform:()=>R.getState().transform,getViewScale:()=>K.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[ee]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:q,width:te,height:J,inversePan:I,pannable:C,zoomStep:k,zoomable:E})},[C,E,I,k,q,te,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=S?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;S(ye,Pe)},[]):void 0,me=N??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*A: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:S,onResizeStart:C,onResize:E,onResizeEnd:N}){const I=Og(),k=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,B=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),U=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!k))return G.current||(G.current=Y1({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(q,te)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),W=[],D={x:q.x,y:q.y},A=b.get(k);if(A&&A.expandParent&&A.parentId){const H=A.origin??V,M=q.width??A.measured.width??0,L=q.height??A.measured.height??0,ne={id:A.id,parentId:A.parentId,rect:{width:M,height:L,...ug({x:q.x??A.position.x,y:q.y??A.position.y},{width:M,height:L},A.parentId,b,H)}},re=gc([ne],b,Y,V);W.push(...re),D.x=q.x?Math.max(H[0]*M,q.x):void 0,D.y=q.y?Math.max(H[1]*L,q.y):void 0}if(D.x!==void 0&&D.y!==void 0){const H={id:k,type:"position",position:{...D}};W.push(H)}if(q.width!==void 0&&q.height!==void 0){const M={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(M)}for(const H of te){const M={...H,type:"position"};W.push(M)}J(W)},onEnd:({width:q,height:te})=>{const J={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:te}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:U,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:E,onResizeEnd:N,shouldResize:S}),()=>{var q;(q=G.current)==null||q.destroy()}},[U,f,g,y,m,x,C,E,N,S]);const ee=U.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...ee,o,l]),ref:R,style:{...a,scale:B,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"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 Pl(t){return Ck[t]??8}function jk(t){const r=new Map;for(const l of t){const a=Pl(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 cm=90,bk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),sp={"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"},Mk=Math.PI*(3-Math.sqrt(5)),dm=220,Pk=26,Ik={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 fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function cE(t){return sp[t]?sp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Tk(t){return t>=cm?"3d":"2d"}function Rk(t){return t>=cm?"overview":"full"}function Lk(t,r,o=1){const l=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!bk.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?Lk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&d.size){l=l.filter(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function dE(t){const r=new Map;for(const l of t){const a=Pl(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Pk*Math.sqrt(f+1),y=f*Mk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function fE(t){const r=new Map;for(const o of t){const l=Pl(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*dm,count:l}))}const el=16,Ak=12,Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),$k=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),lp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form that validates submitted input.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Ok={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},ap=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],up=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Fk=new Set(["looks_idempotent_on_pk"]),Hk=new Set(["inferred","generated","mutation","fbv","ninja"]);function Bk(t){return lp[t]?lp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Vk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Dk.has(t.type)&&a.push("sink"),$k.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>cp(x,l,x.src)),y=f.slice(0,el).map(x=>cp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ik[Pl(t.type)]??"other",purpose:Bk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Uk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function cp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Uk(t){const r=[...ap.filter(a=>a in t),...Object.keys(t).filter(a=>!ap.includes(a)&&!up.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||up.has(a)||Hk.has(a))continue;l.add(a);const u=Wk(a,t[a]);u!=null&&o.push({key:a,label:Ok[a]??yo(a),value:u})}return o}function Wk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Fk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Ak),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const Yk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-mUQO6wms.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Xk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Gk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:t.name}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const Qk={load:Gk},dp=180,fp=56,Kk=new Set(["django","react","stitch","arch"]);function qk(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=jk(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:dp,height:fp,style:{width:dp,height:fp}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Xk[f.weight]||"var(--edge-cheap)";return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:f.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:10}}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Vk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:pi(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:pi(a.context)}):null,a.file?p.jsx("div",{className:"file",children:pi(a.file)}):null,p.jsx("div",{className:"muted",children:pi(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:pi(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:pi(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function $u({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(Kk)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??Tk(t.length),S=d??Rk(t.length),C=$.useMemo(()=>zk(t,r,{detail:S,families:g,focusId:o,neighborhoodOnly:m&&_==="3d"}),[t,r,S,g,o,m,_]),E=$.useMemo(()=>new Map(C.nodes.map(U=>[U.id,U])),[C.nodes]),N=o?E.get(o)??null:null,{rfNodes:I,rfEdges:k}=$.useMemo(()=>{const U=qk(C.nodes,C.edges,o);return v&&(U.rfEdges=U.rfEdges.map(ee=>({...ee,animated:!1}))),U},[C.nodes,C.edges,o,v]);$.useEffect(()=>{o&&!E.has(o)&&l(null)},[E,o]);const j=(U,ee)=>{l(ee.id)},R=()=>{l(null),x(!1)},T=U=>{y(ee=>{const q=new Set(ee);if(q.has(U)){if(q.size===1)return ee;q.delete(U)}else q.add(U);return q})},B=$.useMemo(()=>{const U=new Set;for(const ee of t)U.add(fm(ee.type));return U},[t]),G=t.length-C.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:S==="overview"?"active":"","aria-pressed":S==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:S==="full"?"active":"","aria-pressed":S==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(U=>B.has(U)).map(U=>p.jsx("button",{type:"button","data-testid":`graph-family-${U}`,className:g.has(U)?"active":"","aria-pressed":g.has(U),onClick:()=>T(U),children:U},U))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(U=>!U),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[C.nodes.length," nodes · ",C.edges.length," edges",G?` · ${G} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Yk,{nodes:C.nodes,edges:C.edges,selectedId:o,neighborIds:C.neighborIds,onSelect:U=>{l(U),U||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]}):p.jsxs(sm,{children:[p.jsxs(KS,{nodes:I,edges:k,nodeTypes:Qk,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.15},minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:j,onPaneClick:R,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],Zk=["preset","branch","tag","commit"];function Jk(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function eE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function tE(t){return Zk.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function nE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,S]=$.useState(0),C=$.useMemo(()=>{const j=Jk(u);return x===null?j:eE(j,x)},[u,x]),E=$.useMemo(()=>tE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{S(0)},[x,y]);const N=()=>{m(!1),v(null)},I=j=>{r(j.value),N()},k=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}S(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;S(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),N())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:k}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?N():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:E.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:nE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>S(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function rE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),S=$.useRef(0),C=async k=>{const j=S.current+1;S.current=j,v(!0);try{const R=await Ve.browse(k);if(S.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(S.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{S.current===j&&v(!1)}};$.useEffect(()=>{var k,j;C(t),(k=_.current)==null||k.focus(),(j=_.current)==null||j.select()},[t]);const E=f||(l==null?void 0:l.path)||u,N=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>d(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(k=>{const j=f===k.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>g(k.path),onDoubleClick:()=>void C(k.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:E,children:E}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],iE="obsidian",hm="loadpath.theme";function oE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(oE(t))return t}catch{}return iE}function sE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=sE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function lE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[S,C]=$.useState("review"),[E,N]=$.useState(""),[I,k]=$.useState(""),[j,R]=$.useState(""),[T,B]=$.useState({}),[G,U]=$.useState([]),[ee,q]=$.useState([]),[te,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,W]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,A]=$.useState(""),[H,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[K,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,k(F)};$.useEffect(()=>{Ve.settings().then(B).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(N("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),Ke=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(W(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);q(be.repos),(ae=be.user)!=null&&ae.login&&B($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{q([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||q([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!K)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(K.flow_id);if(F)return;if($e.status==="complete"){se(null);const Ae=await Ve.settings();B(Ae),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||K.interval,5)*1e3);return}se(null),N($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),N($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(K.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[K,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const Ae=await Ve.oauthStatus();if(F)return;if(Ae.bitbucket.connected){_e(!1);const Rn=await Ve.settings();B(Rn),R(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),N("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(Ae){if(F)return;_e(!1),N(Ae instanceof Error?Ae.message:String(Ae))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Tracing load path…"),Ge(o),Ke(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){N(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){N(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){N(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!te||!V){N("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,te,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){N(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,te);U(F.pull_requests);const ae=ee.find(be=>be.slug.toLowerCase()===te.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{N("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){N(F instanceof Error?F.message:String(F))}},$r=async()=>{N("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),N(F instanceof Error?F.message:String(F))}},ir=async F=>{N("");try{B(await Ve.oauthDisconnect(F)),b===F&&q([]),R(`Disconnected ${F}`)}catch(ae){N(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(Ae=>({path:Ae.path,name:Ae.name}))}:be;try{B(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(Ae){N(Ae instanceof Error?Ae.message:String(Ae))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);A(F.note)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){N(""),R("");return}const $e=yp.find(Ae=>Ae.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[S,m,g]),sr=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[S,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:H,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>Ke(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>Ke(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[E?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:E}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>N(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(aE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx($u,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(uE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx($u,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":S==="review","data-testid":"graph-mode-review",className:S==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":S==="architecture","data-testid":"graph-mode-architecture",className:S==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx($u,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,te,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:ee.length?"Search your repos":"owner/repo",value:te,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:ee.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),ee.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[ee.length," ",b," repositor",ee.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{Ke(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=ee.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:H===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!K||!T.github_oauth_ready,onClick:()=>void Ni(),children:K?"Waiting for GitHub…":"Sign in with GitHub"})})]}),K?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:K.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void $r(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(rE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function aE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,S,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(E=>p.jsx("li",{children:E},E))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(E=>p.jsx("span",{className:"chip",children:yo(E)},E))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((E,N)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[N+1,". ",E.path]}),p.jsx("div",{className:"why",children:E.why})]},E.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:E.title})," — ",E.files.join(", ")]},E.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(E=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${E.severity}`,children:E.severity}),E.message]},E.rule+E.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(E=>p.jsx("div",{className:"residual muted",children:E},E))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(E=>E.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(E=>p.jsx("div",{className:"muted",children:E},E)),(((S=t.evolution)==null?void 0:S.hotspots)||[]).filter(E=>E.commits).slice(0,6).map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:E.path})," — ",E.commits," commits, bus factor ",E.bus_factor]},E.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function uE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(lE,{})}));export{Ik as L,fE as a,cE as c,p as j,dE as l,$ as r,yl as t}; + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:S,onResizeStart:C,onResize:E,onResizeEnd:N}){const I=Og(),k=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,B=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),U=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!k))return G.current||(G.current=Y1({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(q,te)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),W=[],D={x:q.x,y:q.y},A=b.get(k);if(A&&A.expandParent&&A.parentId){const H=A.origin??V,M=q.width??A.measured.width??0,L=q.height??A.measured.height??0,ne={id:A.id,parentId:A.parentId,rect:{width:M,height:L,...ug({x:q.x??A.position.x,y:q.y??A.position.y},{width:M,height:L},A.parentId,b,H)}},re=gc([ne],b,Y,V);W.push(...re),D.x=q.x?Math.max(H[0]*M,q.x):void 0,D.y=q.y?Math.max(H[1]*L,q.y):void 0}if(D.x!==void 0&&D.y!==void 0){const H={id:k,type:"position",position:{...D}};W.push(H)}if(q.width!==void 0&&q.height!==void 0){const M={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(M)}for(const H of te){const M={...H,type:"position"};W.push(M)}J(W)},onEnd:({width:q,height:te})=>{const J={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:te}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:U,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:E,onResizeEnd:N,shouldResize:S}),()=>{var q;(q=G.current)==null||q.destroy()}},[U,f,g,y,m,x,C,E,N,S]);const ee=U.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...ee,o,l]),ref:R,style:{...a,scale:B,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"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 Pl(t){return Ck[t]??8}function jk(t){const r=new Map;for(const l of t){const a=Pl(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 cm=90,bk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),sp={"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"},Mk=Math.PI*(3-Math.sqrt(5)),dm=220,Pk=26,Ik={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 fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function cE(t){return sp[t]?sp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Tk(t){return t>=cm?"3d":"2d"}function Rk(t){return t>=cm?"overview":"full"}function Lk(t,r,o=1){const l=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!bk.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?Lk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&d.size){l=l.filter(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function dE(t){const r=new Map;for(const l of t){const a=Pl(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Pk*Math.sqrt(f+1),y=f*Mk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function fE(t){const r=new Map;for(const o of t){const l=Pl(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*dm,count:l}))}const el=16,Ak=12,Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),$k=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),lp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Ok={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},ap=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],up=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Fk=new Set(["looks_idempotent_on_pk"]),Hk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Bk(t){return lp[t]?lp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Vk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Dk.has(t.type)&&a.push("sink"),$k.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>cp(x,l,x.src)),y=f.slice(0,el).map(x=>cp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ik[Pl(t.type)]??"other",purpose:Bk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Uk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function cp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Uk(t){const r=[...ap.filter(a=>a in t),...Object.keys(t).filter(a=>!ap.includes(a)&&!up.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||up.has(a)||Hk.has(a))continue;l.add(a);const u=Wk(a,t[a]);u!=null&&o.push({key:a,label:Ok[a]??yo(a),value:u})}return o}function Wk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Fk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Ak),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const Yk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-D8Vppi7Z.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Xk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Gk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:t.name}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const Qk={load:Gk},dp=180,fp=56,Kk=new Set(["django","react","stitch","arch"]);function qk(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=jk(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:dp,height:fp,style:{width:dp,height:fp}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Xk[f.weight]||"var(--edge-cheap)";return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:f.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:10}}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Vk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:pi(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:pi(a.context)}):null,a.file?p.jsx("div",{className:"file",children:pi(a.file)}):null,p.jsx("div",{className:"muted",children:pi(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:pi(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:pi(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function $u({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(Kk)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??Tk(t.length),S=d??Rk(t.length),C=$.useMemo(()=>zk(t,r,{detail:S,families:g,focusId:o,neighborhoodOnly:m&&_==="3d"}),[t,r,S,g,o,m,_]),E=$.useMemo(()=>new Map(C.nodes.map(U=>[U.id,U])),[C.nodes]),N=o?E.get(o)??null:null,{rfNodes:I,rfEdges:k}=$.useMemo(()=>{const U=qk(C.nodes,C.edges,o);return v&&(U.rfEdges=U.rfEdges.map(ee=>({...ee,animated:!1}))),U},[C.nodes,C.edges,o,v]);$.useEffect(()=>{o&&!E.has(o)&&l(null)},[E,o]);const j=(U,ee)=>{l(ee.id)},R=()=>{l(null),x(!1)},T=U=>{y(ee=>{const q=new Set(ee);if(q.has(U)){if(q.size===1)return ee;q.delete(U)}else q.add(U);return q})},B=$.useMemo(()=>{const U=new Set;for(const ee of t)U.add(fm(ee.type));return U},[t]),G=t.length-C.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:S==="overview"?"active":"","aria-pressed":S==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:S==="full"?"active":"","aria-pressed":S==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(U=>B.has(U)).map(U=>p.jsx("button",{type:"button","data-testid":`graph-family-${U}`,className:g.has(U)?"active":"","aria-pressed":g.has(U),onClick:()=>T(U),children:U},U))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(U=>!U),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[C.nodes.length," nodes · ",C.edges.length," edges",G?` · ${G} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Yk,{nodes:C.nodes,edges:C.edges,selectedId:o,neighborIds:C.neighborIds,onSelect:U=>{l(U),U||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]}):p.jsxs(sm,{children:[p.jsxs(KS,{nodes:I,edges:k,nodeTypes:Qk,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.15},minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:j,onPaneClick:R,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],Zk=["preset","branch","tag","commit"];function Jk(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function eE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function tE(t){return Zk.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function nE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,S]=$.useState(0),C=$.useMemo(()=>{const j=Jk(u);return x===null?j:eE(j,x)},[u,x]),E=$.useMemo(()=>tE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{S(0)},[x,y]);const N=()=>{m(!1),v(null)},I=j=>{r(j.value),N()},k=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}S(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;S(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),N())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:k}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?N():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:E.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:nE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>S(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function rE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),S=$.useRef(0),C=async k=>{const j=S.current+1;S.current=j,v(!0);try{const R=await Ve.browse(k);if(S.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(S.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{S.current===j&&v(!1)}};$.useEffect(()=>{var k,j;C(t),(k=_.current)==null||k.focus(),(j=_.current)==null||j.select()},[t]);const E=f||(l==null?void 0:l.path)||u,N=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>d(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(k=>{const j=f===k.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>g(k.path),onDoubleClick:()=>void C(k.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:E,children:E}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],iE="obsidian",hm="loadpath.theme";function oE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(oE(t))return t}catch{}return iE}function sE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=sE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function lE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[S,C]=$.useState("review"),[E,N]=$.useState(""),[I,k]=$.useState(""),[j,R]=$.useState(""),[T,B]=$.useState({}),[G,U]=$.useState([]),[ee,q]=$.useState([]),[te,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,W]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,A]=$.useState(""),[H,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[K,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,k(F)};$.useEffect(()=>{Ve.settings().then(B).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(N("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),Ke=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(W(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);q(be.repos),(ae=be.user)!=null&&ae.login&&B($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{q([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||q([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!K)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(K.flow_id);if(F)return;if($e.status==="complete"){se(null);const Ae=await Ve.settings();B(Ae),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||K.interval,5)*1e3);return}se(null),N($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),N($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(K.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[K,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const Ae=await Ve.oauthStatus();if(F)return;if(Ae.bitbucket.connected){_e(!1);const Rn=await Ve.settings();B(Rn),R(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),N("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(Ae){if(F)return;_e(!1),N(Ae instanceof Error?Ae.message:String(Ae))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Tracing load path…"),Ge(o),Ke(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){N(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){N(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){N(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!te||!V){N("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,te,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){N(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,te);U(F.pull_requests);const ae=ee.find(be=>be.slug.toLowerCase()===te.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{N("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){N(F instanceof Error?F.message:String(F))}},$r=async()=>{N("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),N(F instanceof Error?F.message:String(F))}},ir=async F=>{N("");try{B(await Ve.oauthDisconnect(F)),b===F&&q([]),R(`Disconnected ${F}`)}catch(ae){N(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(Ae=>({path:Ae.path,name:Ae.name}))}:be;try{B(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(Ae){N(Ae instanceof Error?Ae.message:String(Ae))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);A(F.note)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){N(""),R("");return}const $e=yp.find(Ae=>Ae.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[S,m,g]),sr=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[S,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:H,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>Ke(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>Ke(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[E?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:E}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>N(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(aE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx($u,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(uE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx($u,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":S==="review","data-testid":"graph-mode-review",className:S==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":S==="architecture","data-testid":"graph-mode-architecture",className:S==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx($u,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,te,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:ee.length?"Search your repos":"owner/repo",value:te,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:ee.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),ee.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[ee.length," ",b," repositor",ee.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{Ke(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=ee.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:H===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!K||!T.github_oauth_ready,onClick:()=>void Ni(),children:K?"Waiting for GitHub…":"Sign in with GitHub"})})]}),K?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:K.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void $r(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(rE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function aE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,S,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(E=>p.jsx("li",{children:E},E))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(E=>p.jsx("span",{className:"chip",children:yo(E)},E))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((E,N)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[N+1,". ",E.path]}),p.jsx("div",{className:"why",children:E.why})]},E.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:E.title})," — ",E.files.join(", ")]},E.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(E=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${E.severity}`,children:E.severity}),E.message]},E.rule+E.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(E=>p.jsx("div",{className:"residual muted",children:E},E))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(E=>E.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(E=>p.jsx("div",{className:"muted",children:E},E)),(((S=t.evolution)==null?void 0:S.hotspots)||[]).filter(E=>E.commits).slice(0,6).map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:E.path})," — ",E.commits," commits, bus factor ",E.bus_factor]},E.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function uE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(lE,{})}));export{Ik as L,fE as a,cE as c,p as j,dE as l,$ as r,yl as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index ea5fecf..c0aa913 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/loadpath/stitch/openapi.py b/src/loadpath/stitch/openapi.py index 9a9136c..a640082 100644 --- a/src/loadpath/stitch/openapi.py +++ b/src/loadpath/stitch/openapi.py @@ -14,14 +14,9 @@ def _strip_regex_anchors(route: str) -> str: - route = (route or "").strip() - if route.startswith("include:"): - return "" - if route.startswith("^"): - route = route[1:] - if route.endswith("$") and not route.endswith("\\$"): - route = route[:-1] - return route + from loadpath.extractors.django import pretty_url_pattern + + return pretty_url_pattern(route) def django_route_to_template(route: str) -> str: diff --git a/tests/unit/test_detect.py b/tests/unit/test_detect.py index e0c9b56..49a2ab3 100644 --- a/tests/unit/test_detect.py +++ b/tests/unit/test_detect.py @@ -72,6 +72,33 @@ def test_detect_ignores_docs_in_checkout_parent(tmp_path: Path): assert layout["django_root"] == "api" +def test_detect_skips_graphiql_and_demo_app(tmp_path: Path): + (tmp_path / "dcim").mkdir() + (tmp_path / "dcim" / "apps.py").write_text("class DcimConfig:\n pass\n") + graphiql = tmp_path / "project-static" / "netbox-graphiql" + graphiql.mkdir(parents=True) + (graphiql / "package.json").write_text('{"dependencies":{"react":"18.0.0"}}\n') + demo = tmp_path / "demo-app" / "frontend" / "src" + demo.mkdir(parents=True) + (tmp_path / "demo-app" / "frontend" / "package.json").write_text('{"dependencies":{"react":"18.0.0"}}\n') + (tmp_path / "ui").mkdir() + (tmp_path / "ui" / "App.jsx").write_text("export default function App() { return null }\n") + layout = detect_layout(tmp_path) + assert "graphiql" not in layout["react_root"] + assert "demo-app" not in layout["react_root"] + assert layout["react_root"] == "ui" + + +def test_detect_prefers_ui_folder_over_repo_root_package(tmp_path: Path): + (tmp_path / "webapp").mkdir() + (tmp_path / "webapp" / "apps.py").write_text("class WebappConfig:\n pass\n") + (tmp_path / "package.json").write_text('{"dependencies":{"react":"18.0.0"}}\n') + (tmp_path / "ui").mkdir() + (tmp_path / "ui" / "App.jsx").write_text("export default function App() { return null }\n") + layout = detect_layout(tmp_path) + assert layout["react_root"] == "ui" + + 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" diff --git a/tests/unit/test_django_extractors.py b/tests/unit/test_django_extractors.py index 99a25de..28d5a64 100644 --- a/tests/unit/test_django_extractors.py +++ b/tests/unit/test_django_extractors.py @@ -517,4 +517,78 @@ def test_ok(self): 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) + tests = [n for n in g.nodes if n.type is NodeType.TEST] + assert tests[0].qualified_name.startswith("questions.") + + +def test_views_package_uses_django_app_not_views_namespace(): + from loadpath.extractors.django import _app_from_path + + assert _app_from_path("src/pretix/control/views/vouchers.py") == "control" + assert _app_from_path("src/pretix/presale/views/widget.py") == "presale" + assert _app_from_path("wger/nutrition/tests/test_search_api.py") == "nutrition" + assert _app_from_path("backend/billing/views.py") == "billing" + assert _app_from_path("backend/billing/migrations/0001_initial.py") == "billing" + + source = ( + "from django.views import View\n" + "class CartApplyVoucher(View):\n" + " pass\n" + ) + control = extract_django_file("src/pretix/control/views/vouchers.py", source, _cfg()) + presale = extract_django_file("src/pretix/presale/views/widget.py", source, _cfg()) + ids = {n.id for n in control.nodes + presale.nodes if n.type is NodeType.VIEW} + assert ids == {"django.view:control.CartApplyVoucher", "django.view:presale.CartApplyVoucher"} + + +def test_regex_empty_and_named_group_routes_are_readable(): + source = ( + "from django.urls import re_path, include\n" + "from . import views\n" + "urlpatterns = [\n" + " re_path(r'^$', views.home, name='home'),\n" + " re_path(r'^', include('addons.urls')),\n" + " re_path(r'^(?P[\\w-]+)/clone/$', views.clone, name='clone'),\n" + "]\n" + ) + g = extract_django_file("experimenter/nimbus_ui/urls.py", source, _cfg()) + routes = [n for n in g.nodes if n.type is NodeType.ROUTE] + names = {n.name for n in routes} + assert "home" in names or "/" in names + assert "^$" not in names + assert "^" not in names + assert any("{slug}/clone/" == n.name or n.name == "{slug}/clone" for n in routes) + assert any(e.dst == "django.view:nimbus_ui.clone" for e in g.edges if e.type.value == "publishes_route") + + +def test_filterset_is_a_form_and_links_from_the_view(): + filters = ( + "from django_filters import FilterSet\n" + "from .models import Ingredient\n" + "class IngredientFilterSet(FilterSet):\n" + " class Meta:\n" + " model = Ingredient\n" + " fields = ['name']\n" + ) + views = ( + "from rest_framework.viewsets import ModelViewSet\n" + "from .filtersets import IngredientFilterSet\n" + "from .serializers import IngredientSerializer\n" + "from .models import Ingredient\n" + "class IngredientViewSet(ModelViewSet):\n" + " serializer_class = IngredientSerializer\n" + " filterset_class = IngredientFilterSet\n" + " queryset = Ingredient.objects.all()\n" + ) + fg = extract_django_file("wger/nutrition/api/filtersets.py", filters, _cfg()) + vg = extract_django_file("wger/nutrition/api/views.py", views, _cfg()) + fs = next(n for n in fg.nodes if n.name == "IngredientFilterSet") + assert fs.type is NodeType.FORM + assert fs.extra.get("filterset") is True + assert fs.qualified_name == "api.IngredientFilterSet" + assert any(e.src == fs.id and e.type.value == "serializes" for e in fg.edges) + assert any( + e.src == "django.view:api.IngredientViewSet" and e.dst == "django.form:api.IngredientFilterSet" + for e in vg.edges + ) diff --git a/tests/unit/test_index_and_stitch.py b/tests/unit/test_index_and_stitch.py index 1328c06..6f9dd4a 100644 --- a/tests/unit/test_index_and_stitch.py +++ b/tests/unit/test_index_and_stitch.py @@ -145,6 +145,7 @@ def test_empty_include_prefix_does_not_pollute_child_paths(tmp_path: Path): assert django_route_to_template("include:zproject.tornado_urls") == "/" assert django_route_to_template("^base") == "/base" assert django_route_to_template("^$") == "/" + assert django_route_to_template(r"^(?P[\w-]+)/clone/$") == "/{slug}/clone" def test_regex_include_join_strips_anchors(tmp_path: Path): diff --git a/ui/src/nodeInspector.test.ts b/ui/src/nodeInspector.test.ts index 2aae8e3..d58c046 100644 --- a/ui/src/nodeInspector.test.ts +++ b/ui/src/nodeInspector.test.ts @@ -136,6 +136,22 @@ describe("inspectNode", () => { expect(info.roles).toEqual(["sink", "contract"]); }); + it("tags django-filter FilterSets without repeating the flag as a fact", () => { + const info = inspectNode( + node({ + id: "django.form:api.IngredientFilterSet", + type: "django.form", + name: "IngredientFilterSet", + extra: { filterset: true, fields: ["name"] }, + }), + [], + [], + ); + expect(info.roles).toContain("filterset"); + expect(info.purpose).toMatch(/FilterSet/i); + expect(info.facts.map((f) => f.key)).toEqual(["fields"]); + }); + it("keeps app when it is not the bounded context", () => { const info = inspectNode( node({ diff --git a/ui/src/nodeInspector.ts b/ui/src/nodeInspector.ts index 9c42ed0..6d24af7 100644 --- a/ui/src/nodeInspector.ts +++ b/ui/src/nodeInspector.ts @@ -37,7 +37,7 @@ const TYPE_PURPOSE: Record = { "django.permission": "Auth gate on a view — who is allowed to hit this path.", "django.throttle": "Rate-limit class attached to a view.", "django.serializer": "Request/response contract: which fields go in and come out.", - "django.form": "Django form that validates submitted input.", + "django.form": "Django form or django-filter FilterSet — the typed input contract.", "django.serializer_field": "One field on a serializer or form — the typed slot on the contract.", "django.service": "Internal service or use-case. Work that is not itself an HTTP sink.", "django.model": "ORM model. Schema and relations live here.", @@ -198,7 +198,7 @@ const HIDDEN_EXTRA_KEYS = new Set([ ]); const ALWAYS_SHOW_FALSE = new Set(["looks_idempotent_on_pk"]); -const ROLE_FACT_KEYS = new Set(["inferred", "generated", "mutation", "fbv", "ninja"]); +const ROLE_FACT_KEYS = new Set(["inferred", "generated", "mutation", "fbv", "ninja", "filterset"]); export type InspectorLink = { id: string; @@ -256,6 +256,7 @@ export function inspectNode( if (extra.mutation) roles.push("mutation"); if (extra.fbv) roles.push("function view"); if (extra.ninja) roles.push("ninja"); + if (extra.filterset === true) roles.push("filterset"); const incoming = edges.filter((e) => e.dst === node.id); const outgoing = edges.filter((e) => e.src === node.id); From 443c375b9d4414df2fae390ec596ac9d933780bc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 10:25:34 +0000 Subject: [PATCH 2/7] Skip GraphiQL and legacy-ui trees even when the folder name is prefixed. NetBox's package.json lives in netbox-graphiql, which did not match the exact graphiql path token, so detect still treated it as the React root. Co-authored-by: zord.lack.net --- src/loadpath/detect.py | 13 ++++++++++++- tests/unit/test_detect.py | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/loadpath/detect.py b/src/loadpath/detect.py index 2abdf9c..48ac662 100644 --- a/src/loadpath/detect.py +++ b/src/loadpath/detect.py @@ -192,7 +192,10 @@ def _detect_django_root(repo_root: Path) -> str: "demo", "example", "examples", + "legacy", + "legacy-ui", } +SKIP_REACT_SUBSTRINGS = ("graphiql", "storybook", "docusaurus", "demo-app") def _package_has_react(pkg: Path) -> bool: @@ -204,6 +207,14 @@ def _package_has_react(pkg: Path) -> bool: return "react" in deps or "react-dom" in deps +def _skip_react_tree(path: Path, repo_root: Path) -> bool: + parts = _rel_parts(path, repo_root) + if any(part in SKIP_REACT_PARTS for part in parts): + return True + joined = "/".join(parts).lower() + return any(token in joined for token in SKIP_REACT_SUBSTRINGS) + + def _detect_react_root(repo_root: Path) -> str: for candidate in PREFERRED_REACT_ROOTS: path = repo_root / candidate @@ -214,7 +225,7 @@ def _detect_react_root(repo_root: Path) -> str: for pkg in repo_root.rglob("package.json"): if _skip(pkg, repo_root): continue - if any(part in SKIP_REACT_PARTS for part in _rel_parts(pkg, repo_root)): + if _skip_react_tree(pkg, repo_root): continue if not _package_has_react(pkg): continue diff --git a/tests/unit/test_detect.py b/tests/unit/test_detect.py index 49a2ab3..fd7dc9a 100644 --- a/tests/unit/test_detect.py +++ b/tests/unit/test_detect.py @@ -81,11 +81,15 @@ def test_detect_skips_graphiql_and_demo_app(tmp_path: Path): demo = tmp_path / "demo-app" / "frontend" / "src" demo.mkdir(parents=True) (tmp_path / "demo-app" / "frontend" / "package.json").write_text('{"dependencies":{"react":"18.0.0"}}\n') + legacy = tmp_path / "legacy-ui" / "core" + legacy.mkdir(parents=True) + (legacy / "package.json").write_text('{"dependencies":{"react":"18.0.0"}}\n') (tmp_path / "ui").mkdir() (tmp_path / "ui" / "App.jsx").write_text("export default function App() { return null }\n") layout = detect_layout(tmp_path) assert "graphiql" not in layout["react_root"] assert "demo-app" not in layout["react_root"] + assert "legacy" not in layout["react_root"] assert layout["react_root"] == "ui" From 0de19cf8d3ae008d1319be5ca9357a10cdd95c2b Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 10:54:13 +0000 Subject: [PATCH 3/7] Make 2D graphs readable and stop 3D selection from resetting the camera. Layered layout now packs occupied columns, orders nodes by barycenter so edges line up, and clamps labels to two lines. Edge labels only appear for the selected node. Selecting a 3D node no longer rebuilds the WebGL scene, which was jumping the camera and flashing white on deselect. Co-authored-by: zord.lack.net --- ...D8Vppi7Z.js => LayeredGraph3D-D0mq8ReQ.js} | 52 ++++++------ ...{index-B5eCWnJO.css => index-DiHJRVJW.css} | 2 +- .../{index-BAQ4x0wM.js => index-dUZaA8eL.js} | 26 +++--- src/loadpath/static/index.html | 4 +- ui/src/ImpactGraph.test.ts | 19 +++++ ui/src/ImpactGraph.tsx | 63 ++++++++++---- ui/src/LayeredGraph3D.tsx | 60 ++++++++----- ui/src/graphView.test.ts | 11 +++ ui/src/styles.css | 17 ++-- ui/src/styles.test.ts | 12 ++- ui/src/types.test.ts | 62 +++++++++++++- ui/src/types.ts | 85 +++++++++++++++++-- 12 files changed, 320 insertions(+), 93 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-D8Vppi7Z.js => LayeredGraph3D-D0mq8ReQ.js} (80%) rename src/loadpath/static/assets/{index-B5eCWnJO.css => index-DiHJRVJW.css} (76%) rename src/loadpath/static/assets/{index-BAQ4x0wM.js => index-dUZaA8eL.js} (51%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js b/src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js similarity index 80% rename from src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js rename to src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js index bc8f5cc..1c8d17b 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-D8Vppi7Z.js +++ b/src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js @@ -1,12 +1,12 @@ -import{r as bn,l as tc,c as nc,a as ic,L as sc,j as jn,t as rc}from"./index-BAQ4x0wM.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-dUZaA8eL.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||c=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 Xe(...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]+At[i>>16&255]+At[i>>24&255]+"-"+At[e&255]+At[e>>8&255]+"-"+At[e>>16&15|64]+At[e>>24&255]+"-"+At[t&63|128]+At[t>>8&255]+"-"+At[t>>16&255]+At[t>>24&255]+At[n&255]+At[n>>8&255]+At[n>>16&255]+At[n>>24&255]).toLowerCase()}function Ve(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 tt(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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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(Ve(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 A=Math.acos(p),R=Math.sin(A);u=Math.sin(u*A)/R,o=Math.sin(o*A)/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 A=1/Math.sqrt(c*c+l*l+f*f+m*m);c*=A,l*=A,f*=A,m*=A}}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(Ve(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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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(Ve(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 U=Va;const Qs=new U,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],A=s[1],R=s[4],M=s[7],T=s[2],y=s[5],w=s[8];return r[0]=a*S+o*A+c*T,r[3]=a*p+o*R+c*y,r[6]=a*u+o*M+c*w,r[1]=l*S+f*A+m*T,r[4]=l*p+f*R+m*y,r[7]=l*u+f*M+m*w,r[2]=h*S+_*A+v*T,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===je&&(s.r=vn(s.r),s.g=vn(s.g),s.b=vn(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===je&&(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:je,toXYZ:lo,fromXYZ:co,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Vt}}}),i}const Ye=Wc();function vn(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 ni;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{ni===void 0&&(ni=Us("canvas")),ni.width=e.width,ni.height=e.height;const s=ni.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ni}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 gn: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 gn: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++}}Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=xl;Ct.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,T=(u+1)/2,y=(f+h)/4,w=(m+S)/4,g=(v+p)/4;return R>M&&R>T?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=y/n,r=w/n):M>T?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=y/s,r=g/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=w/r,s=g/r),this.set(n,s,r,t),this}let A=Math.sqrt((p-v)*(p-v)+(m-S)*(m-S)+(h-f)*(h-f));return Math.abs(A)<.001&&(A=1),this.x=(p-v)/A,this.y=(m-S)/A,this.z=(h-f)/A,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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this.w=Ve(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this.w=Ve(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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 ut=ka;class Kc extends Bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,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 ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Ct(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 Oe{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,Ye.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ye.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ye.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ye.workingColorSpace){if(e=Hc(e,1),t=Ve(t,0,1),n=Ve(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 Ye.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=vn(e.r),this.g=vn(e.g),this.b=vn(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 Ye.workingToColorSpace(Rt.copy(this),e),Math.round(Ve(Rt.r*255,0,255))*65536+Math.round(Ve(Rt.g*255,0,255))*256+Math.round(Ve(Rt.b*255,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ye.workingColorSpace){Ye.workingToColorSpace(Rt.copy(this),t);const n=Rt.r,s=Rt.g,r=Rt.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 U,fn=new U,rr=new U,pn=new U,ai=new U,oi=new U,xo=new U,ar=new U,or=new U,lr=new U,cr=new ut,hr=new ut,ur=new ut;class kt{constructor(e=new U,t=new U,n=new U){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),fn.subVectors(n,t),rr.subVectors(e,t);const a=Xt.dot(Xt),o=Xt.dot(fn),c=Xt.dot(rr),l=fn.dot(fn),f=fn.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,pn)===null?!1:pn.x>=0&&pn.y>=0&&pn.x+pn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,pn)===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,pn.x),c.addScaledVector(a,pn.y),c.addScaledVector(o,pn.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),fn.subVectors(e,t),Xt.cross(fn).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),fn.subVectors(this.a,this.b),Xt.cross(fn).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;ai.subVectors(s,n),oi.subVectors(r,n),ar.subVectors(e,n);const c=ai.dot(ar),l=oi.dot(ar);if(c<=0&&l<=0)return t.copy(n);or.subVectors(e,s);const f=ai.dot(or),m=oi.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(ai,a);lr.subVectors(e,r);const _=ai.dot(lr),v=oi.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(oi,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(ai,a).addScaledVector(oi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class wi{constructor(e=new U(1/0,1/0,1/0),t=new U(-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),li.subVectors(e.a,Di),ci.subVectors(e.b,Di),hi.subVectors(e.c,Di),Rn.subVectors(ci,li),wn.subVectors(hi,ci),Gn.subVectors(li,hi);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,li,ci,hi,es)||(t=[1,0,0,0,1,0,0,0,1],!dr(t,li,ci,hi,es))?!1:(ts.crossVectors(Rn,wn),t=[ts.x,ts.y,ts.z],dr(t,li,ci,hi,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:(mn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),mn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),mn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),mn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),mn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),mn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),mn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),mn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(mn),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 mn=[new U,new U,new U,new U,new U,new U,new U,new U],Yt=new U,ji=new wi,li=new U,ci=new U,hi=new U,Rn=new U,wn=new U,Gn=new U,Di=new U,es=new U,ts=new U,Vn=new U;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 U,ns=new Re;let sh=0;class Kt 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 lt,pr=new Et,ui=new U,Ot=new wi,Ii=new wi,St=new U;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(ui).negate(),this.translate(ui.x,ui.y,ui.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){Xe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(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!==Xn&&(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!==ti&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ti&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ti&&(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 Oe().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 Jn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Oe(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 di;const Ui=new U,fi=new U,pi=new U,mi=new Re,Ni=new Re,Ll=new lt,is=new U,Fi=new U,ss=new U,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",di===void 0){di=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);di.setIndex([0,1,2,0,2,3]),di.setAttribute("position",new Fs(n,3,0,!1)),di.setAttribute("uv",new Fs(n,2,3,!1))}this.geometry=di,this.material=e,this.center=new Re(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Xe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),fi.setFromMatrixScale(this.matrixWorld),Ll.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),pi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&fi.multiplyScalar(-pi.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),pi,a,fi,s,r),rs(Fi.set(.5,-.5,0),pi,a,fi,s,r),rs(ss.set(.5,.5,0),pi,a,fi,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),pi,a,fi,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){mi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Ni.x=r*mi.x-s*mi.y,Ni.y=s*mi.x+r*mi.y):Ni.copy(mi),i.copy(e),i.x+=Ni.x,i.y+=Ni.y,i.applyMatrix4(Ll)}const _n=new U,_r=new U,as=new U,Cn=new U,gr=new U,os=new U,xr=new U;class Hs{constructor(e=new U,t=new U(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,_n)),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=_n.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_n.copy(this.origin).addScaledVector(this.direction,t),_n.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){_n.subVectors(e.center,this.origin);const n=_n.dot(this.direction),s=_n.dot(_n)-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,_n)!==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 Jn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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 lt,Hn=new Hs,ls=new Vs,Eo=new U,cs=new U,hs=new U,us=new U,vr=new U,ds=new U,yo=new U,fs=new U;class Zt 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 U;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 U),f.normal.dot(n.direction)>0&&f.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new U,materialIndex:0};kt.getNormal(cs,hs,us,h.normal),f.face=h,f.barycoord=m}return f}class uh extends Ct{constructor(e=null,t=1,n=1,s,r,a,o,c,l=bt,f=bt,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 U,dh=new U,fh=new Ie;class Dn{constructor(e=new U(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 U;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],A=r[12],R=r[13],M=r[14],T=r[15];if(s[0].setComponents(l-a,_-f,u-v,T-A).normalize(),s[1].setComponents(l+a,_+f,u+v,T+A).normalize(),s[2].setComponents(l+o,_+m,u+S,T+R).normalize(),s[3].setComponents(l-o,_-m,u-S,T-R).normalize(),n)s[4].setComponents(c,h,p,M).normalize(),s[5].setComponents(l-c,_-h,u-p,T-M).normalize();else if(s[4].setComponents(l-c,_-h,u-p,T-M).normalize(),t===an)s[5].setComponents(l+c,_+h,u+p,T+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 Jn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Oe(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 U,Bs=new U,bo=new lt,Oi=new Hs,_s=new Vs,Sr=new U,To=new U;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 U,Ro=new U;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(_e/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;s0&&(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 Oe().setHex(s.value);break;case"v2":this.uniforms[n].value=new Re().fromArray(s.value);break;case"v3":this.uniforms[n].value=new U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ut().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ie().fromArray(s.value);break;case"m4":this.uniforms[n].value=new lt().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 Jn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Oe(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 Oe(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 Jn{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 Jn{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 Oe(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 lt,Co=new U,Po=new U;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 lt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Na,this._frameExtents=new Re(1,1),this._viewportCount=1,this._viewports=[new ut(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 U,vs=new Fn,jt=new U;class Bl extends Et{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,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 U,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 _i=-90,gi=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(_i,gi,e,t);s.layers=this.layers,this.add(s);const r=new Ht(_i,gi,e,t);r.layers=this.layers,this.add(r);const a=new Ht(_i,gi,e,t);a.layers=this.layers,this.add(a);const o=new Ht(_i,gi,e,t);o.layers=this.layers,this.add(o);const c=new Ht(_i,gi,e,t);c.layers=this.layers,this.add(c);const l=new Ht(_i,gi,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 lt;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):Xe("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 #include -}`,Zd=`uniform sampler2D tEquirect; +}`,Kd=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2815,7 +2815,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,Kd=`uniform float scale; +}`,Zd=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -3676,7 +3676,7 @@ void main() { #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:` +}`,Be={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:Kh,bsdfs:Zh,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:Ku,metalnessmap_pars_fragment:Zu,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:Kd,linedashed_vert:Zd,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},he={common:{diffuse:{value:new Oe(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 Oe(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 U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new Oe(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 Oe(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:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.fog]),vertexShader:Be.meshbasic_vert,fragmentShader:Be.meshbasic_frag},lambert:{uniforms:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Be.meshlambert_vert,fragmentShader:Be.meshlambert_frag},phong:{uniforms:Dt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Be.meshphong_vert,fragmentShader:Be.meshphong_frag},standard:{uniforms:Dt([he.common,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.roughnessmap,he.metalnessmap,he.fog,he.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag},toon:{uniforms:Dt([he.common,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.gradientmap,he.fog,he.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Be.meshtoon_vert,fragmentShader:Be.meshtoon_frag},matcap:{uniforms:Dt([he.common,he.bumpmap,he.normalmap,he.displacementmap,he.fog,{matcap:{value:null}}]),vertexShader:Be.meshmatcap_vert,fragmentShader:Be.meshmatcap_frag},points:{uniforms:Dt([he.points,he.fog]),vertexShader:Be.points_vert,fragmentShader:Be.points_frag},dashed:{uniforms:Dt([he.common,he.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Be.linedashed_vert,fragmentShader:Be.linedashed_frag},depth:{uniforms:Dt([he.common,he.displacementmap]),vertexShader:Be.depth_vert,fragmentShader:Be.depth_frag},normal:{uniforms:Dt([he.common,he.bumpmap,he.normalmap,he.displacementmap,{opacity:{value:1}}]),vertexShader:Be.meshnormal_vert,fragmentShader:Be.meshnormal_frag},sprite:{uniforms:Dt([he.sprite,he.fog]),vertexShader:Be.sprite_vert,fragmentShader:Be.sprite_frag},background:{uniforms:{uvTransform:{value:new Ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Be.background_vert,fragmentShader:Be.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ie}},vertexShader:Be.backgroundCube_vert,fragmentShader:Be.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Be.cube_vert,fragmentShader:Be.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Be.equirect_vert,fragmentShader:Be.equirect_frag},distance:{uniforms:Dt([he.common,he.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Be.distance_vert,fragmentShader:Be.distance_frag},shadow:{uniforms:Dt([he.lights,he.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Be.shadow_vert,fragmentShader:Be.shadow_frag}};tn.physical={uniforms:Dt([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 Oe(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 Oe(0)},specularColor:{value:new Oe(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:Be.meshphysical_vert,fragmentShader:Be.meshphysical_frag};const Ms={r:0,b:0,g:0},xf=new lt,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 Oe(0);let o=s===!0?0:1,c,l,f=null,m=0,h=null;function _(A){let R=A.isScene===!0?A.background:null;if(R&&R.isTexture){const M=A.backgroundBlurriness>0;R=e.get(R,M)}return R}function v(A){let R=!1;const M=_(A);M===null?p(a,o):M&&M.isColor&&(p(M,1),R=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="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(A,R){const M=_(R);M&&(M.isCubeTexture||M.mapping===Gs)?(l===void 0&&(l=new Zt(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(T,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=Ye.getTransfer(M.colorSpace)!==je,(f!==M||m!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,f=M,m=M.version,h=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Zt(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=Ye.getTransfer(M.colorSpace)!==je,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(),A.unshift(c,c.geometry,c.material,0,0,null))}function p(A,R){A.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(A,R=1){a.set(A),o=R,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,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,F,Y,K,z){let X=!1;const H=m(P,K,Y,F);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,F,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,F,Y,K){const z=K.wireframe===!0;let X=n[F.id];X===void 0&&(X={},n[F.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 F=[],Y=[],K=[];for(let z=0;z=0){const de=z[j];let _e=X[j];if(_e===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(_e=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(_e=P.instanceColor)),de===void 0||de.attribute!==_e||_e&&de.data!==_e.data)return!0;H++}return r.attributesNum!==H||r.index!==K}function v(P,F,Y,K){const z={},X=F.attributes;let H=0;const J=Y.getAttributes();for(const j in J)if(J[j].location>=0){let de=X[j];de===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(de=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(de=P.instanceColor));const _e={};_e.attribute=de,de&&de.data&&(_e.data=de.data),z[j]=_e,H++}r.attributes=z,r.attributesNum=H,r.index=K}function S(){const P=r.newAttributes;for(let F=0,Y=P.length;F=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 de=re.normalized,_e=re.itemSize,qe=e.get(re);if(qe===void 0)continue;const Je=qe.buffer,He=qe.type,q=qe.bytesPerElement,ne=He===i.INT||He===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),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=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:A,maxVaryings:R,maxFragmentUniforms:M,maxSamples:T,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 A=r?0:n,R=A*4;let M=u.clippingState||null;c.value=M,M=f(v,h,R,_);for(let T=0;T!==R;++T)M[T]=t[T];u.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=A}};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,A=h.matrixWorldInverse;o.getNormalMatrix(A),(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?T:0,T,T),m.setRenderTarget(s),u&&m.render(S,c),m.render(e,c)}m.toneMapping=_,m.autoClear=h,e.background=A}_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;xi(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,xi(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,xi(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"&&Xe("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*Yn-1),S=r/v,p=isFinite(r)?1+Math.floor(f*S):Yn;p>Yn&&Pe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Yn}`);const u=[];let A=0;for(let w=0;wR-In?s-R+In:0),y=4*(this._cubeSize-M);xi(t,T,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,A=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];A.set(b,S*v*y),R.set(h,p*v*y);const I=[y,y,y,y,y,y];M.set(I,u*v*y)}const T=new Ut;T.setAttribute("position",new Kt(A,S)),T.setAttribute("uv",new Kt(R,p)),T.setAttribute("faceIndex",new Kt(M,u)),n.push(new Zt(T,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 xi(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; @@ -3780,7 +3780,7 @@ void main() { 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:` + `,blending:xn,depthTest:!1,depthWrite:!1})}function wf(i,e,t){const n=new Float32Array(Yn),s=new U(0,1,0);return new hn({name:"SphericalGaussianBlur",defines:{n:Yn,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; @@ -3840,7 +3840,7 @@ void main() { } } - `,blending:gn,depthTest:!1,depthWrite:!1})}function Ho(){return new hn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ws(),fragmentShader:` + `,blending:xn,depthTest:!1,depthWrite:!1})}function Ho(){return new hn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ws(),fragmentShader:` precision mediump float; precision mediump int; @@ -3859,7 +3859,7 @@ void main() { 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:` + `,blending:xn,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; @@ -3875,7 +3875,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:gn,depthTest:!1,depthWrite:!1})}function Ws(){return` + `,blending:xn,depthTest:!1,depthWrite:!1})}function Ws(){return` precision mediump float; precision mediump int; @@ -3965,7 +3965,7 @@ void main() { 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;U0){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=_===Ks||_===Zs,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 A=h.image;return v&&A&&A.height>0||S&&A&&c(A)?(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 _===Ks?h.mapping=Zn:_===Zs&&(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:Xe("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 ut;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||[],A=o.morphAttributes.color||[];let R=0;_===!0&&(R=1),v===!0&&(R=2),S===!0&&(R=3);let M=o.attributes.position.count*R,T=1;M>e.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const y=new Float32Array(M*T*4*m),w=new Rl(y,M,T,m);w.type=rn,w.needsUpdate=!0;const g=R*4;for(let I=0;I0&&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(` + }`,depthTest:!1,depthWrite:!1}),f=new Zt(c,l),m=new Ba(-1,1,1,-1,0,1);let h=null,_=null,v=!1,S,p=null,u=[],A=!1;this.setSize=function(R,M){a.setSize(R,M),o.setSize(R,M);for(let T=0;T0&&u[0].isRenderPass===!0;const M=a.width,T=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()+` +`)}const Jo=new Ie;function Dp(i){Ye._getMatrix(Jo,Ye.workingColorSpace,i);const e=`mat3( ${Jo.elements.map(t=>t.toFixed(4))} )`;switch(Ye.getTransfer(i)){case Is:return[e,"LinearTransferOETF"];case je: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(` +`)}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 U;function Np(){Ye.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);r/gm;function Ea(i){return i.replace(zp,Vp)}const Gp=new Map;function Vp(i,e){let t=Be[e];if(t===void 0){const n=Gp.get(e);if(n!==void 0)t=Be[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:"",` +`),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?Be.tonemapping_pars_fragment:"",t.toneMapping!==on?Up("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Be.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 +`)),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&&(A=`#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)+` +`+u);const R=A+p+a,M=A+u+o,T=$o(s,s.VERTEX_SHADER,R),y=$o(s,s.FRAGMENT_SHADER,M);s.attachShader(S,T),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 F=s.getProgramInfoLog(S)||"",Y=s.getShaderInfoLog(T)||"",K=s.getShaderInfoLog(y)||"",z=F.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,T,y);else{const re=Qo(s,T,"vertex"),de=Qo(s,y,"fragment");Xe("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() { +`+de)}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(T),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 I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(S,wp)),I},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=T,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===$n||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,I,P,F,Y){const K=P.fog,z=F.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 de=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,_e=de!==void 0?de.length:0;let qe=0;z.morphAttributes.position!==void 0&&(qe=1),z.morphAttributes.normal!==void 0&&(qe=2),z.morphAttributes.color!==void 0&&(qe=3);let Je,He,q,ne;if(re){const Me=tn[re];Je=Me.vertexShader,He=Me.fragmentShader}else{Je=g.vertexShader,He=g.fragmentShader;const Me=o.getVertexShaderStage(g),dt=o.getFragmentShaderStage(g);o.update(g,Me,dt),q=Me.id,ne=dt.id}const ee=i.getRenderTarget(),De=i.state.buffers.depth.getReversed(),Le=F.isInstancedMesh===!0,we=F.isBatchedMesh===!0,ct=!!g.map,ze=!!g.matcap,Qe=!!J,Ke=!!g.aoMap,ke=!!g.lightMap,xe=!!g.bumpMap&&g.wireframe===!1,ve=!!g.normalMap,Ue=!!g.displacementMap,We=!!g.emissiveMap,ot=!!g.metalnessMap,ht=!!g.roughnessMap,D=g.anisotropy>0,yt=g.clearcoat>0,Ze=g.dispersion>0,E=g.iridescence>0,d=g.sheen>0,N=g.transmission>0,G=D&&!!g.anisotropyMap,k=yt&&!!g.clearcoatMap,te=yt&&!!g.clearcoatNormalMap,se=yt&&!!g.clearcoatRoughnessMap,W=E&&!!g.iridescenceMap,$=E&&!!g.iridescenceThicknessMap,ae=d&&!!g.sheenColorMap,ye=d&&!!g.sheenRoughnessMap,ce=!!g.specularMap,oe=!!g.specularColorMap,Ae=!!g.specularIntensityMap,Ce=N&&!!g.transmissionMap,Ne=N&&!!g.thicknessMap,C=!!g.gradientMap,ie=!!g.alphaMap,Z=g.alphaTest>0,le=!!g.alphaHash,pe=!!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:Je,fragmentShader:He,defines:g.defines,customVertexShaderID:q,customFragmentShaderID:ne,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:we,batchingColor:we&&F._colorsTexture!==null,instancing:Le,instancingColor:Le&&F.instanceColor!==null,instancingMorph:Le&&F.morphTexture!==null,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Ye.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:ct,matcap:ze,envMap:Qe,envMapMode:Qe&&J.mapping,envMapCubeUVHeight:j,aoMap:Ke,lightMap:ke,bumpMap:xe,normalMap:ve,displacementMap:Ue,emissiveMap:We,normalMapObjectSpace:ve&&g.normalMapType===Dc,normalMapTangentSpace:ve&&g.normalMapType===ga,packedNormalMap:ve&&g.normalMapType===ga&&im(g.normalMap.format),metalnessMap:ot,roughnessMap:ht,anisotropy:D,anisotropyMap:G,clearcoat:yt,clearcoatMap:k,clearcoatNormalMap:te,clearcoatRoughnessMap:se,dispersion:Ze,iridescence:E,iridescenceMap:W,iridescenceThicknessMap:$,sheen:d,sheenColorMap:ae,sheenRoughnessMap:ye,specularMap:ce,specularColorMap:oe,specularIntensityMap:Ae,transmission:N,transmissionMap:Ce,thicknessMap:Ne,gradientMap:C,opaque:g.transparent===!1&&g.blending===Si&&g.alphaToCoverage===!1,alphaMap:ie,alphaTest:Z,alphaHash:le,combine:g.combine,mapUv:ct&&v(g.map.channel),aoMapUv:Ke&&v(g.aoMap.channel),lightMapUv:ke&&v(g.lightMap.channel),bumpMapUv:xe&&v(g.bumpMap.channel),normalMapUv:ve&&v(g.normalMap.channel),displacementMapUv:Ue&&v(g.displacementMap.channel),emissiveMapUv:We&&v(g.emissiveMap.channel),metalnessMapUv:ot&&v(g.metalnessMap.channel),roughnessMapUv:ht&&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:ae&&v(g.sheenColorMap.channel),sheenRoughnessMapUv:ye&&v(g.sheenRoughnessMap.channel),specularMapUv:ce&&v(g.specularMap.channel),specularColorMapUv:oe&&v(g.specularColorMap.channel),specularIntensityMapUv:Ae&&v(g.specularIntensityMap.channel),transmissionMapUv:Ce&&v(g.transmissionMap.channel),thicknessMapUv:Ne&&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:F.isPoints===!0&&!!z.attributes.uv&&(ct||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:F.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:_e,morphTextureStride:qe,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&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:ct&&g.map.isVideoTexture===!0&&Ye.getTransfer(g.map.colorSpace)===je,decodeVideoTextureEmissive:We&&g.emissiveMap.isVideoTexture===!0&&Ye.getTransfer(g.emissiveMap.colorSpace)===je,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===nn,flipSided:g.side===It,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:pe&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pe&&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 I in g.defines)b.push(I),b.push(g.defines[I]);return g.isRawShaderMaterial===!1&&(u(b,g),A(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 A(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 I;if(b){const P=tn[b];I=Mh.clone(P.uniforms)}else I=g.uniforms;return I}function M(g,b){let I=f.get(b);return I!==void 0?++I.usedTimes:(I=new jp(i,b,g,s),l.push(I),f.set(b,I)),I}function T(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:T,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 A=i[e];return A===void 0?(A={id:h.id,object:h,geometry:_,material:v,materialVariant:a(h),groupOrder:S,renderOrder:h.renderOrder,z:p,group:u},i[e]=A):(A.id=h.id,A.object=h,A.geometry=_,A.material=v,A.materialVariant=a(h),A.groupOrder=S,A.renderOrder=h.renderOrder,A.z=p,A.group=u),e++,A}function c(h,_,v,S,p,u){const A=o(h,_,v,S,p,u);v.transmission>0?n.push(A):v.transparent===!0?s.push(A):t.push(A)}function l(h,_,v,S,p,u){const A=o(h,_,v,S,p,u);v.transmission>0?n.unshift(A):v.transparent===!0?s.unshift(A):t.unshift(A)}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 U,color:new Oe};break;case"SpotLight":t={position:new U,direction:new U,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new U,halfWidth:new U,halfHeight:new U};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 U);const s=new U,r=new lt,a=new lt;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,A=0,R=0,M=0,T=0,y=0,w=0;l.sort(um);for(let b=0,I=l.length;b0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=he.LTC_FLOAT_1,n.rectAreaLTC2=he.LTC_FLOAT_2):(n.rectAreaLTC1=he.LTC_HALF_1,n.rectAreaLTC2=he.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!==A||g.numPointShadows!==R||g.numSpotShadows!==M||g.numSpotMaps!==T||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=A,n.directionalShadowMap.length=A,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=M+T-y,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=w,g.directionalLength=_,g.pointLength=v,g.spotLength=S,g.rectAreaLength=p,g.hemiLength=u,g.numDirectionalShadows=A,g.numPointShadows=R,g.numSpotShadows=M,g.numSpotMaps=T,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,A=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; @@ -4089,7 +4089,7 @@ void main() { 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=` +}`,_m=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],gm=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],al=new lt,zi=new U,wr=new U;function xm(i,e,t){let n=new Na;const s=new Re,r=new Re,a=new ut,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 Kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Zt(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(),I=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),F=i.state;F.setBlending(xn),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.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:$n,type:Mn,minFilter:wt,magFilter:wt,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=Sn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=bt,H.map.depthTexture.magFilter=bt}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=Sn,this.type===ys?(H.map.depthTexture.compareFunction=j?Da:Pa,H.map.depthTexture.minFilter=wt,H.map.depthTexture.magFilter=wt):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=bt,H.map.depthTexture.magFilter=bt);H.camera.updateProjectionMatrix()}const re=H.map.isWebGLCubeRenderTarget?6:1;for(let de=0;de0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){const F=I.uuid,Y=w.uuid;let K=l[F];K===void 0&&(K={},l[F]=K);let z=K[Y];z===void 0&&(z=I.clone(),K[Y]=z,w.addEventListener("dispose",T)),I=z}if(I.visible=w.visible,I.wireframe=w.wireframe,b===Gi?I.side=w.shadowSide!==null?w.shadowSide:w.side:I.side=w.shadowSide!==null?w.shadowSide:m[w.side],I.alphaMap=w.alphaMap,I.alphaTest=w.alphaToCoverage===!0?.5:w.alphaTest,I.map=w.map,I.clipShadows=w.clipShadows,I.clippingPlanes=w.clippingPlanes,I.clipIntersection=w.clipIntersection,I.displacementMap=w.displacementMap,I.displacementScale=w.displacementScale,I.displacementBias=w.displacementBias,I.wireframeLinewidth=w.wireframeLinewidth,I.linewidth=w.linewidth,g.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const F=i.properties.get(I);F.light=g}return I}function M(y,w,g,b,I){if(y.visible===!1)return;if(y.layers.test(w.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&I===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,de={};const _e=i.getParameter(i.SCISSOR_BOX),qe=i.getParameter(i.VIEWPORT),Je=new ut().fromArray(_e),He=new ut().fromArray(qe);function q(C,ie,Z,le){const pe=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=Ze(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 A(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:Ye.getTransfer(k);N===i.FLOAT&&(W=i.RGBA32F),N===i.HALF_FLOAT&&(W=i.RGBA16F),N===i.UNSIGNED_BYTE&&(W=$===je?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 T(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!==bt&&E.minFilter!==wt?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&&I(E),Object.keys(G).length===0&&_.delete(N)}n.remove(E)}function I(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),F+=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 de(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 _e={[zr]:i.REPEAT,[gn]:i.CLAMP_TO_EDGE,[Gr]:i.MIRRORED_REPEAT},qe={[bt]:i.NEAREST,[Cc]:i.NEAREST_MIPMAP_NEAREST,[Zi]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[$s]:i.LINEAR_MIPMAP_NEAREST,[qn]:i.LINEAR_MIPMAP_LINEAR},Je={[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 He(E,d){if(d.type===rn&&e.has("OES_texture_float_linear")===!1&&(d.magFilter===wt||d.magFilter===$s||d.magFilter===Zi||d.magFilter===qn||d.minFilter===wt||d.minFilter===$s||d.minFilter===Zi||d.minFilter===qn)&&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,_e[d.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,_e[d.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,_e[d.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,qe[d.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,qe[d.minFilter]),d.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,Je[d.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(d.magFilter===bt||d.minFilter!==Zi&&d.minFilter!==qn||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&&I(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,ce)=>ye.start-ce.start);let se=0;for(let ye=1;ye0){Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,ie,ce,Ae[0].width,Ae[0].height);for(let Z=0,le=Ae.length;Z0){const pe=Oo(oe.width,oe.height,d.format,d.type);for(const Q of d.layerUpdates){const Ee=oe.data.subarray(Q*pe/oe.data.BYTES_PER_ELEMENT,(Q+1)*pe/oe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,Q,oe.width,oe.height,1,ae,Ee)}d.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,oe.width,oe.height,$.depth,ae,oe.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,ce,oe.width,oe.height,$.depth,0,oe.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,oe.width,oe.height,$.depth,ae,ye,oe.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,ce,oe.width,oe.height,$.depth,0,ae,ye,oe.data)}else{Ce&&Ne&&t.texStorage2D(i.TEXTURE_2D,ie,ce,Ae[0].width,Ae[0].height);for(let Z=0,le=Ae.length;Z0){const Z=Oo($.width,$.height,d.format,d.type);for(const le of d.layerUpdates){const pe=$.data.subarray(le*Z/$.data.BYTES_PER_ELEMENT,(le+1)*Z/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,le,$.width,$.height,1,ae,ye,pe)}d.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ae,ye,$.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ce,$.width,$.height,$.depth,0,ae,ye,$.data);else if(d.isData3DTexture)Ce?(Ne&&t.texStorage3D(i.TEXTURE_3D,ie,ce,$.width,$.height,$.depth),C&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ae,ye,$.data)):t.texImage3D(i.TEXTURE_3D,0,ce,$.width,$.height,$.depth,0,ae,ye,$.data);else if(d.isFramebufferTexture){if(Ne)if(Ce)t.texStorage2D(i.TEXTURE_2D,ie,ce,$.width,$.height);else{let Z=$.width,le=$.height;for(let pe=0;pe>=1,le>>=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=le=>{const pe=le.changedElements;for(const Q of m)pe.includes(Q.image)&&(Q.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,$);else{const pe=i.RGBA,Q=i.RGBA,Ee=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,pe,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&&Ne){const Z=Ze(Ae[0]);t.texStorage2D(i.TEXTURE_2D,ie,ce,Z.width,Z.height)}for(let Z=0,le=Ae.length;Z0&&le++;const Q=Ze(ce[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,le,Ne,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,ce[Q].width,ce[Q].height,Ae,Ce,ce[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Ne,ce[Q].width,ce[Q].height,0,Ae,Ce,ce[Q].data);for(let Ee=0;Ee>te),oe=Math.max(1,d.height>>te);k===i.TEXTURE_3D||k===i.TEXTURE_2D_ARRAY?t.texImage3D(k,te,$,ce,oe,d.depth,0,se,W,null):t.texImage2D(k,te,$,ce,oe,0,se,W,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ht(d)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,k,ye.__webglTexture,0,ot(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 ct(E,d,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),d.depthBuffer){const G=d.depthTexture,k=G&&G.isDepthTexture?G.type:null,te=T(d.stencilBuffer,k),se=d.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ht(d)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ot(d),te,d.width,d.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,ot(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(),ct(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(),ct(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 Ke(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&&Qe(E)}function ke(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&&ht(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(ht(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 ae=0;ae0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer);for(let ae=0;ae0&&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 yt(E,d){const N=E.colorSpace,G=E.format,k=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Ls&&N!==Ln&&(Ye.getTransfer(N)===je?(G!==qt||k!==Bt)&&Pe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",N)),d}function Ze(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=de,this.rebindTextures=Ke,this.setupRenderTarget=ke,this.updateRenderTargetMipmap=xe,this.updateMultisampleRenderTarget=We,this.setupDepthRenderbuffer=Qe,this.setupFrameBufferTexture=we,this.useMultisampledRTT=ht,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Sm(i,e){function t(n,s=Ln){let r;const a=Ye.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===Mn)return i.HALF_FLOAT;if(n===yl)return i.ALPHA;if(n===bl)return i.RGB;if(n===qt)return i.RGBA;if(n===Sn)return i.DEPTH_COMPONENT;if(n===Kn)return i.DEPTH_STENCIL;if(n===Tl)return i.RED;if(n===Ra)return i.RED_INTEGER;if(n===$n)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===je)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===Kr||n===Zr||n===Ps||n===$r)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Xr||n===Yr)return a===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===qr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Kr)return r.COMPRESSED_R11_EAC;if(n===Zr)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===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Qr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===jr)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ea)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ta)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===na)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ia)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ra)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===aa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===oa)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===la)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ca)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ha)return a===je?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===je?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 ); @@ -4113,4 +4113,4 @@ void main() { } -}`;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}; +}`;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 Zt(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={},A=t.getContextAttributes();let R=null,M=null;const T=[],y=[],w=new Re;let g=null;const b=new Ht;b.viewport=new ut;const I=new Ht;I.viewport=new ut;const P=[b,I],F=new Lh;let Y=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getGripSpace()},this.getHand=function(q){let ne=T[q];return ne===void 0&&(ne=new ir,T[q]=ne),ne.getHandSpace()};function z(q){const ne=y.indexOf(q.inputSource);if(ne===-1)return;const ee=T[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,T[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=T[De];Le&&Le.connect(ee)}}const J=new U,j=new U;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,ct=Le[14]/(Le[10]-1),ze=Le[14]/(Le[10]+1),Qe=(Le[9]+1)/Le[5],Ke=(Le[9]-1)/Le[5],ke=(Le[8]-1)/Le[0],xe=(we[8]+1)/we[0],ve=ct*ke,Ue=ct*xe,We=De/(-ke+xe),ot=We*-ke;if(ne.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(ot),q.translateZ(We),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 ht=ct+We,D=ze+We,yt=ve-ot,Ze=Ue+(De-ot),E=Qe*ze/D*ht,d=Ke*ze/D*ht;q.projectionMatrix.makePerspective(yt,Ze,E,d,ht,D),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function de(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)),F.near=I.near=b.near=ne,F.far=I.far=b.far=ee,(Y!==F.near||K!==F.far)&&(s.updateRenderState({depthNear:F.near,depthFar:F.far}),Y=F.near,K=F.far),F.layers.mask=q.layers.mask|6,b.layers.mask=F.layers.mask&-5,I.layers.mask=F.layers.mask&-3;const De=q.parent,Le=F.cameras;de(F,De);for(let we=0;we0&&(p.alphaTest.value=u.alphaTest);const A=e.get(u),R=A.envMap,M=A.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,A,R){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*A,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,A){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=A.texture,p.transmissionSamplerSize.value.set(A.width,A.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 A=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.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,T){const y=T.program;n.uniformBlockBinding(M,y)}function l(M,T){let y=s[M.id];y===void 0&&(p(M),y=f(M),s[M.id]=y,M.addEventListener("dispose",A));const w=T.program;n.updateUBOMapping(M,w);const g=e.render.frame;r[M.id]!==g&&(h(M),r[M.id]=g)}function f(M){const T=m();M.__bindingPointIndex=T;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,T,y),y}function m(){for(let M=0;M0&&(y+=w-g),M.__size=y,M.__cache={},this}function u(M){const T={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(T.boundary=4,T.storage=4):M.isVector2?(T.boundary=8,T.storage=8):M.isVector3||M.isColor?(T.boundary=16,T.storage=12):M.isVector4?(T.boundary=16,T.storage=16):M.isMatrix3?(T.boundary=48,T.storage=48):M.isMatrix4?(T.boundary=64,T.storage=64):M.isTexture?Pe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(T.boundary=16,T.storage=M.byteLength):Pe("WebGLRenderer: Unsupported uniform value type.",M),T}function A(M){const T=M.target;T.removeEventListener("dispose",A);const y=a.indexOf(T.__bindingPointIndex);a.splice(y,1),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.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,$n,Mn),en.name="DFG_LUT",en.minFilter=wt,en.magFilter=wt,en.wrapS=gn,en.wrapT=gn,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]),A=new Uint32Array(4),R=new Int32Array(4),M=new U;let T=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 I=this;let P=!1,F=null,Y=null,K=null,z=null;this._outputColorSpace=Vt;let X=0,H=0,J=null,j=-1,re=null;const de=new ut,_e=new ut;let qe=null;const Je=new Oe(0);let He=0,q=t.width,ne=t.height,ee=1,De=null,Le=null;const we=new ut(0,0,q,ne),ct=new ut(0,0,q,ne);let ze=!1;const Qe=new Na;let Ke=!1,ke=!1;const xe=new lt,ve=new U,Ue=new ut,We={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ot=!1;function ht(){return J===null?ee:1}let D=n;function yt(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",dt,!1),t.addEventListener("webglcontextrestored",rt,!1),t.addEventListener("webglcontextcreationerror",$t,!1),D===null){const L="webgl2";if(D=yt(L,x),D===null)throw yt(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw Xe("WebGLRenderer: "+x.message),x}let Ze,E,d,N,G,k,te,se,W,$,ae,ye,ce,oe,Ae,Ce,Ne,C,ie,Z,le,pe,Q;function Ee(){Ze=new Pf(D),Ze.init(),le=new Sm(D,Ze),E=new Ef(D,Ze,e,le),d=new vm(D,Ze),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,Ze,d,G,E,le,N),te=new Cf(I),se=new Fh(D),pe=new Mf(D,se),W=new Df(D,se,N,pe),$=new Nf(D,W,se,pe,N),C=new Uf(D,E,k),Ae=new yf(G),ae=new sm(I,te,Ze,E,pe,Ae),ye=new Rm(I,G),ce=new om,oe=new fm(Ze),Ne=new vf(I,te,d,$,v,c),Ce=new xm(I,$,E),Q=new wm(D,N,E,d),ie=new Sf(D,Ze,N),Z=new Lf(D,Ze,N),N.programs=ae.programs,I.capabilities=E,I.extensions=Ze,I.properties=G,I.renderLists=ce,I.shadowMap=Ce,I.state=d,I.info=N}Ee(),S!==Bt&&(b=new Of(S,t.width,t.height,o,s,r));const Me=new Tm(I,D);this.xr=Me,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const x=Ze.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ze.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){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let L=0;L{function fe(){if(O.forEach(function(ge){G.get(ge).currentProgram.isReady()&&O.delete(ge)}),O.size===0){B(x);return}setTimeout(fe,10)}Ze.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,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){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;F!==null&&F.renderStart(x,L);const V=Me.enabled===!0&&Me.isPresenting===!0,O=b!==null&&(J===null||V)&&b.begin(I,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(I,x,L,J),y=oe.get(x,g.length),y.init(L),y.state.textureUnits=k.getTextureUnits(),g.push(y),xe.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Qe.setFromProjectionMatrix(xe,an,L.reversedDepth),ke=this.localClippingEnabled,Ke=Ae.init(this.clippingPlanes,ke),T=ce.get(x,w.length),T.init(),w.push(T),Me.enabled===!0&&Me.isPresenting===!0){const ge=I.xr.getDepthSensingMesh();ge!==null&&qs(ge,L,-1/0,I.sortObjects)}qs(x,L,0,I.sortObjects),T.finish(),I.sortObjects===!0&&T.sort(De,Le,L.reversedDepth),ot=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,ot&&Ne.addToRenderList(T,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ke===!0&&Ae.beginShadows();const B=y.state.shadowsArray;if(Ce.render(B,x,L),Ke===!0&&Ae.endShadows(),(O&&b.hasRenderPass())===!1){const ge=T.opaque,ue=T.transmissive;if(y.setupLights(),L.isArrayCamera){const Se=L.cameras;if(ue.length>0)for(let be=0,Fe=Se.length;be0&&Za(ge,ue,x,L),ot&&Ne.render(x),Ka(T,x,L)}J!==null&&H===0&&(k.updateMultisampleRenderTarget(J),k.updateRenderTargetMipmap(J)),O&&b.end(I),x.isScene===!0&&x.onAfterRender(I,x,L),pe.resetDefaultState(),j=-1,re=null,g.pop(),g.length>0?(y=g[g.length-1],k.setTextureUnits(y.state.textureUnits),Ke===!0&&Ae.setGlobalState(I.clippingPlanes,y.state.camera)):y=null,w.pop(),w.length>0?T=w[w.length-1]:T=null,F!==null&&F.renderEnd()};function qs(x,L,V,O){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||Qe.intersectsSprite(x)){O&&Ue.setFromMatrixPosition(x.matrixWorld).applyMatrix4(xe);const ge=$.update(x),ue=x.material;ue.visible&&T.push(x,ge,ue,V,Ue.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Qe.intersectsObject(x))){const ge=$.update(x),ue=x.material;if(O&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),Ue.copy(x.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),Ue.copy(ge.boundingSphere.center)),Ue.applyMatrix4(x.matrixWorld).applyMatrix4(xe)),Array.isArray(ue)){const Se=ge.groups;for(let be=0,Fe=Se.length;be0&&qi(B,L,V),fe.length>0&&qi(fe,L,V),ge.length>0&&qi(ge,L,V),d.buffers.depth.setTest(!0),d.buffers.depth.setMask(!0),d.buffers.color.setMask(!0),d.setPolygonOffset(!1)}function Za(x,L,V,O){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[O.id]===void 0){const Te=Ze.has("EXT_color_buffer_half_float")||Ze.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[O.id]=new ln(1,1,{generateMipmaps:!0,type:Te?Mn:Bt,minFilter:qn,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ye.workingColorSpace})}const fe=y.state.transmissionRenderTarget[O.id],ge=O.viewport||de;fe.setSize(ge.z*I.transmissionResolutionScale,ge.w*I.transmissionResolutionScale);const ue=I.getRenderTarget(),Se=I.getActiveCubeFace(),be=I.getActiveMipmapLevel();I.setRenderTarget(fe),I.getClearColor(Je),He=I.getClearAlpha(),He<1&&I.setClearColor(16777215,.5),I.clear(),ot&&Ne.render(V);const Fe=I.toneMapping;I.toneMapping=on;const Ge=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),y.setupLightsView(O),Ke===!0&&Ae.setGlobalState(I.clippingPlanes,O),qi(x,V,O),k.updateMultisampleRenderTarget(fe),k.updateRenderTargetMipmap(fe),Ze.has("WEBGL_multisampled_render_to_texture")===!1){let Te=!1;for(let et=0,pt=L.length;et0,O.currentProgram=Ge,O.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,O=x.length;V0),Te=!!V.morphAttributes.position,et=!!V.morphAttributes.normal,pt=!!V.morphAttributes.color;let ft=on;O.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(ft=I.toneMapping);const it=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Tt=it!==void 0?it.length:0,me=G.get(O),Nt=y.state.lights;if(Ke===!0&&(ke===!0||x!==re)){const at=x===re&&O.id===j;Ae.setState(O,x,at)}let $e=!1;O.version===me.__version?(me.needsLights&&me.lightsStateVersion!==Nt.state.version||me.outputColorSpace!==ue||B.isBatchedMesh&&me.batching===!1||!B.isBatchedMesh&&me.batching===!0||B.isBatchedMesh&&me.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&me.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&me.instancing===!1||!B.isInstancedMesh&&me.instancing===!0||B.isSkinnedMesh&&me.skinning===!1||!B.isSkinnedMesh&&me.skinning===!0||B.isInstancedMesh&&me.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&me.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&me.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&me.instancingMorph===!1&&B.morphTexture!==null||me.envMap!==be||O.fog===!0&&me.fog!==fe||me.numClippingPlanes!==void 0&&(me.numClippingPlanes!==Ae.numPlanes||me.numIntersection!==Ae.numIntersection)||me.vertexAlphas!==Fe||me.vertexTangents!==Ge||me.morphTargets!==Te||me.morphNormals!==et||me.morphColors!==pt||me.toneMapping!==ft||me.morphTargetsCount!==Tt||!!me.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,me.__version=O.version);let zt=me.currentProgram;$e===!0&&(zt=Ki(O,L,B),F&&O.isNodeMaterial&&F.onUpdateProgram(O,zt,me));let Qt=!1,En=!1,Qn=!1;const st=zt.getUniforms(),mt=me.uniforms;if(d.useProgram(zt.program)&&(Qt=!0,En=!0,Qn=!0),O.id!==j&&(j=O.id,En=!0),me.needsLights){const at=Jl(y.state.lightProbeGridArray,B);me.lightProbeGrid!==at&&(me.lightProbeGrid=at,En=!0)}if(Qt||re!==x){d.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),st.setValue(D,"projectionMatrix",x.projectionMatrix),st.setValue(D,"viewMatrix",x.matrixWorldInverse);const bn=st.map.cameraPosition;bn!==void 0&&bn.setValue(D,ve.setFromMatrixPosition(x.matrixWorld)),E.logarithmicDepthBuffer&&st.setValue(D,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&st.setValue(D,"isOrthographic",x.isOrthographicCamera===!0),re!==x&&(re=x,En=!0,Qn=!0)}if(me.needsLights&&(Nt.state.directionalShadowMap.length>0&&st.setValue(D,"directionalShadowMap",Nt.state.directionalShadowMap,k),Nt.state.spotShadowMap.length>0&&st.setValue(D,"spotShadowMap",Nt.state.spotShadowMap,k),Nt.state.pointShadowMap.length>0&&st.setValue(D,"pointShadowMap",Nt.state.pointShadowMap,k)),B.isSkinnedMesh){st.setOptional(D,B,"bindMatrix"),st.setOptional(D,B,"bindMatrixInverse");const at=B.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),st.setValue(D,"boneTexture",at.boneTexture,k))}B.isBatchedMesh&&(st.setOptional(D,B,"batchingTexture"),st.setValue(D,"batchingTexture",B._matricesTexture,k),st.setOptional(D,B,"batchingIdTexture"),st.setValue(D,"batchingIdTexture",B._indirectTexture,k),st.setOptional(D,B,"batchingColorTexture"),B._colorsTexture!==null&&st.setValue(D,"batchingColorTexture",B._colorsTexture,k));const yn=V.morphAttributes;if((yn.position!==void 0||yn.normal!==void 0||yn.color!==void 0)&&C.update(B,V,zt),(En||me.receiveShadow!==B.receiveShadow)&&(me.receiveShadow=B.receiveShadow,st.setValue(D,"receiveShadow",B.receiveShadow)),(O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial)&&O.envMap===null&&L.environment!==null&&(mt.envMapIntensity.value=L.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Pm()),En){if(st.setValue(D,"toneMappingExposure",I.toneMappingExposure),me.needsLights&&jl(mt,Qn),fe&&O.fog===!0&&ye.refreshFogUniforms(mt,fe),ye.refreshMaterialUniforms(mt,O,ee,ne,y.state.transmissionRenderTarget[x.id]),me.needsLights&&me.lightProbeGrid){const at=me.lightProbeGrid;mt.probesSH.value=at.texture,mt.probesMin.value.copy(at.boundingBox.min),mt.probesMax.value.copy(at.boundingBox.max),mt.probesResolution.value.copy(at.resolution)}Cs.upload(D,Ja(me),mt,k)}if(O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Cs.upload(D,Ja(me),mt,k),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&st.setValue(D,"center",B.center),st.setValue(D,"modelViewMatrix",B.modelViewMatrix),st.setValue(D,"normalMatrix",B.normalMatrix),st.setValue(D,"modelMatrix",B.matrixWorld),O.uniformsGroups!==void 0){const at=O.uniformsGroups;for(let bn=0,jn=at.length;bn0&&k.useMultisampledRTT(x)===!1?O=G.get(x).__webglMultisampledFramebuffer:Array.isArray(be)?O=be[V]:O=be,de.copy(x.viewport),_e.copy(x.scissor),qe=x.scissorTest}else de.copy(we).multiplyScalar(ee).floor(),_e.copy(ct).multiplyScalar(ee).floor(),qe=ze;if(V!==0&&(O=Y),d.bindFramebuffer(D.FRAMEBUFFER,O)&&d.drawBuffers(x,O),d.viewport(de),d.scissor(_e),d.setScissorTest(qe),B){const ue=G.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,ue.__webglTexture,V)}else if(fe){const ue=L;for(let Se=0;Se1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!E.textureFormatReadable(Fe)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Ge)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-O&&V>=0&&V<=x.height-B&&D.readPixels(L,V,O,B,le.convert(Fe),le.convert(Ge),fe)}finally{const be=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,be)}}},this.readRenderTargetPixelsAsync=async function(x,L,V,O,B,fe,ge,ue=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&&ge!==void 0&&(Se=Se[ge]),Se)if(L>=0&&L<=x.width-O&&V>=0&&V<=x.height-B){d.bindFramebuffer(D.FRAMEBUFFER,Se);const be=x.textures[ue],Fe=be.format,Ge=be.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!E.textureFormatReadable(Fe))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,fe.byteLength,D.STREAM_READ),D.readPixels(L,V,O,B,le.convert(Fe),le.convert(Ge),0);const et=J!==null?G.get(J).__webglFramebuffer:null;d.bindFramebuffer(D.FRAMEBUFFER,et);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,fe),D.deleteBuffer(Te),D.deleteSync(pt),fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,L=null,V=0){const O=Math.pow(2,-V),B=Math.floor(x.image.width*O),fe=Math.floor(x.image.height*O),ge=L!==null?L.x:0,ue=L!==null?L.y:0;k.setTexture2D(x,0),D.copyTexSubImage2D(D.TEXTURE_2D,V,0,0,ge,ue,B,fe),d.unbindTexture()},this.copyTextureToTexture=function(x,L,V=null,O=null,B=0,fe=0){let ge,ue,Se,be,Fe,Ge,Te,et,pt;const ft=x.isCompressedTexture?x.mipmaps[fe]:x.image;if(V!==null)ge=V.max.x-V.min.x,ue=V.max.y-V.min.y,Se=V.isBox3?V.max.z-V.min.z:1,be=V.min.x,Fe=V.min.y,Ge=V.isBox3?V.min.z:0;else{const mt=Math.pow(2,-B);ge=Math.floor(ft.width*mt),ue=Math.floor(ft.height*mt),x.isDataArrayTexture?Se=ft.depth:x.isData3DTexture?Se=Math.floor(ft.depth*mt):Se=1,be=0,Fe=0,Ge=0}O!==null?(Te=O.x,et=O.y,pt=O.z):(Te=0,et=0,pt=0);const it=le.convert(L.format),Tt=le.convert(L.type);let me;L.isData3DTexture?(k.setTexture3D(L,0),me=D.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(k.setTexture2DArray(L,0),me=D.TEXTURE_2D_ARRAY):(k.setTexture2D(L,0),me=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),$e=d.getParameter(D.UNPACK_IMAGE_HEIGHT),zt=d.getParameter(D.UNPACK_SKIP_PIXELS),Qt=d.getParameter(D.UNPACK_SKIP_ROWS),En=d.getParameter(D.UNPACK_SKIP_IMAGES);d.pixelStorei(D.UNPACK_ROW_LENGTH,ft.width),d.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ft.height),d.pixelStorei(D.UNPACK_SKIP_PIXELS,be),d.pixelStorei(D.UNPACK_SKIP_ROWS,Fe),d.pixelStorei(D.UNPACK_SKIP_IMAGES,Ge);const Qn=x.isDataArrayTexture||x.isData3DTexture,st=L.isDataArrayTexture||L.isData3DTexture;if(x.isDepthTexture){const mt=G.get(x),yn=G.get(L),at=G.get(mt.__renderTarget),bn=G.get(yn.__renderTarget);d.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),d.bindFramebuffer(D.DRAW_FRAMEBUFFER,bn.__webglFramebuffer);for(let jn=0;jnMath.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 U(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 U(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 Km({nodes:i,edges:e,selectedId:t,neighborIds:n,onSelect:s}){const r=un.useRef(null),a=un.useRef(null),[o,c]=un.useState(null),[l,f]=un.useState(null),m=un.useRef(s);m.current=s;const h=un.useRef({selectedId:t,neighborIds:n});h.current={selectedId:t,neighborIds:n};const _=un.useRef(null),v=`${i.map(S=>S.id).join("\0")}|${e.map(S=>S.id).join("\0")}`;return un.useEffect(()=>{const S=a.current;if(!S)return;const p=window.matchMedia("(prefers-reduced-motion: reduce)").matches,u=Wn("--graph-bg","#0b0f14"),A=new Oe(Wn("--accent","#4cc9f0")),R=new ih;R.background=new Oe(u);const M=new Ht(50,1,1,8e3);let T;try{T=new Dm({antialias:!0,alpha:!1,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(!T.getContext()){T.dispose(),f("WebGL is unavailable in this browser, so the 3D view cannot start. Switch back to 2D map.");return}f(null),T.setClearColor(u,1),T.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),T.domElement.dataset.testid="graph-3d-canvas",S.appendChild(T.domElement);const y=new Im(M,T.domElement);y.enableDamping=!p,y.dampingFactor=.08,y.minDistance=80,y.maxDistance=2400,R.add(new Ph(16777215,.7));const w=new Ch(16777215,.85);w.position.set(200,320,180),R.add(w);const g=tc(i),b=new Map(i.map(xe=>[xe.id,xe])),I=new Map,P=new Vi;R.add(P);const F=new Oa(11,18,14);for(const xe of i){const ve=g.get(xe.id)??{x:0,y:0,z:0},Ue=new bh({color:nc(xe.type),roughness:.45,metalness:.05,transparent:!0,opacity:1}),We=new Zt(F,Ue);We.position.set(ve.x,ve.y,ve.z),We.userData.id=xe.id,P.add(We),I.set(xe.id,We)}const Y=new Ut,K=[],z=[],X=new Oe(Wn("--edge-cheap","#4a5568")),H=new Oe(Wn("--edge-expensive","#f4a261")),J=new Oe(Wn("--edge-critical","#e85d04"));for(const xe of e){const ve=g.get(xe.src),Ue=g.get(xe.dst);if(!ve||!Ue)continue;K.push(ve.x,ve.y,ve.z,Ue.x,Ue.y,Ue.z);const We=xe.weight==="critical"?J:xe.weight==="expensive"?H:X;z.push(We.r,We.g,We.b,We.r,We.g,We.b)}Y.setAttribute("position",new xt(K,3)),Y.setAttribute("color",new xt(z,3));const j=new _h(Y,new Il({vertexColors:!0,transparent:!0,opacity:.55}));P.add(j);const re=new Ua({color:new Oe(Wn("--muted","#8b9bb0")),transparent:!0,opacity:.07,side:nn,depthWrite:!1}),de=Wn("--muted","#8b9bb0"),_e=[],qe=[];for(const xe of ic(i)){const ve=new Fa(cl(xe.count),48);qe.push(ve);const Ue=new Zt(ve,re);Ue.rotation.y=Math.PI/2,Ue.position.x=xe.x,P.add(Ue);const We=Ym(sc[xe.layer]??`layer ${xe.layer}`,de);We.position.set(xe.x,cl(xe.count)+18,0),P.add(We),_e.push(We)}const Je=_.current;if(Je&&Je.topology===v)M.position.set(Je.position.x,Je.position.y,Je.position.z),y.target.set(Je.target.x,Je.target.y,Je.target.z),M.lookAt(y.target);else{const xe=new wi().setFromObject(P),ve=xe.getCenter(new U),Ue=xe.getSize(new U);y.target.copy(ve),M.position.set(ve.x+Ue.x*.15,ve.y+Math.max(140,Ue.y*.45),ve.z+Math.max(280,Ue.z*.9+180)),M.lookAt(ve)}const He=new Ih;He.params.Mesh={...He.params.Mesh,threshold:2};const q=new Re,ne=[...I.values()],ee=(xe,ve)=>{const Ue=!!(xe&&ve.size),We=new Oe(0);for(const[ot,ht]of I){const D=ht.material,yt=!Ue||ve.has(ot),Ze=ot===xe;D.opacity=Ze?1:yt?.95:.12,ht.scale.setScalar(Ze?1.25:yt?1:.7),D.emissive.copy(Ze?A:We),D.emissiveIntensity=Ze?.35:0}j.material.opacity=Ue?.85:.5},De=xe=>{const ve=T.domElement.getBoundingClientRect();q.x=(xe.clientX-ve.left)/ve.width*2-1,q.y=-((xe.clientY-ve.top)/ve.height)*2+1},Le=()=>{He.setFromCamera(q,M);const xe=He.intersectObjects(ne,!1)[0],ve=xe==null?void 0:xe.object.userData.id;return ve?b.get(ve)??null:null},we=xe=>{De(xe);const ve=Le();if(!ve){c(null),T.domElement.style.cursor="grab";return}T.domElement.style.cursor="pointer";const Ue=(r.current??S).getBoundingClientRect();c({node:ve,x:xe.clientX-Ue.left,y:xe.clientY-Ue.top})},ct=xe=>{De(xe);const ve=Le();m.current(ve?ve.id:null)},ze=()=>{const xe=S.clientWidth||1,ve=S.clientHeight||1;M.aspect=xe/ve,M.updateProjectionMatrix(),T.setSize(xe,ve,!1)};ze();const Qe=new ResizeObserver(ze);Qe.observe(S);let Ke=0;const ke=()=>{Ke=requestAnimationFrame(ke),y.update(),T.render(R,M)};return ke(),T.domElement.addEventListener("pointermove",we),T.domElement.addEventListener("click",ct),S.__paint=ee,ee(h.current.selectedId,h.current.neighborIds),()=>{var xe;_.current={topology:v,position:{x:M.position.x,y:M.position.y,z:M.position.z},target:{x:y.target.x,y:y.target.y,z:y.target.z}},cancelAnimationFrame(Ke),Qe.disconnect(),T.domElement.removeEventListener("pointermove",we),T.domElement.removeEventListener("click",ct),delete S.__paint,y.dispose(),F.dispose(),Y.dispose(),re.dispose();for(const ve of qe)ve.dispose();j.material.dispose();for(const ve of _e){const Ue=ve.material;(xe=Ue.map)==null||xe.dispose(),Ue.dispose()}for(const ve of I.values())ve.material.dispose();T.dispose(),T.domElement.remove(),c(null)}},[v]),un.useEffect(()=>{var S,p;(p=(S=a.current)==null?void 0:S.__paint)==null||p.call(S,t,n)},[t,n]),ei.jsxs("div",{className:"graph-3d-host",ref:r,children:[ei.jsx("div",{className:"graph-3d-canvas-host",ref:a}),l?ei.jsx("p",{className:"muted graph-3d-hint","data-testid":"graph-3d-fallback",children:l}):null,o?ei.jsxs("div",{className:"graph-3d-tip",style:{left:o.x+12,top:o.y+12},children:[ei.jsx("div",{className:"t",children:rc(o.node.type)}),ei.jsx("div",{className:"n",children:o.node.name})]}):null]})}export{Km as LayeredGraph3D}; diff --git a/src/loadpath/static/assets/index-B5eCWnJO.css b/src/loadpath/static/assets/index-DiHJRVJW.css similarity index 76% rename from src/loadpath/static/assets/index-B5eCWnJO.css rename to src/loadpath/static/assets/index-DiHJRVJW.css index 6420f3a..e016481 100644 --- a/src/loadpath/static/assets/index-B5eCWnJO.css +++ b/src/loadpath/static/assets/index-DiHJRVJW.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0}.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}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width: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}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item .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}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}*{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-BAQ4x0wM.js b/src/loadpath/static/assets/index-dUZaA8eL.js similarity index 51% rename from src/loadpath/static/assets/index-BAQ4x0wM.js rename to src/loadpath/static/assets/index-dUZaA8eL.js index 5197b6e..c2c196c 100644 --- a/src/loadpath/static/assets/index-BAQ4x0wM.js +++ b/src/loadpath/static/assets/index-dUZaA8eL.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))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 xp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wu={exports:{}},uo={},_u={exports:{}},Ie={};/** +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))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 xp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _u={exports:{}},uo={},Su={exports:{}},Ie={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Hf;function Qy(){if(Hf)return Ie;Hf=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"),g=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),x=Symbol.iterator;function v(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,C={};function E(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}E.prototype.isReactComponent={},E.prototype.setState=function(M,L){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,L,"setState")},E.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function N(){}N.prototype=E.prototype;function I(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}var k=I.prototype=new N;k.constructor=I,S(k,E.prototype),k.isPureReactComponent=!0;var j=Array.isArray,R=Object.prototype.hasOwnProperty,T={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function G(M,L,ne){var re,ce={},fe=null,de=null;if(L!=null)for(re in L.ref!==void 0&&(de=L.ref),L.key!==void 0&&(fe=""+L.key),L)R.call(L,re)&&!B.hasOwnProperty(re)&&(ce[re]=L[re]);var K=arguments.length-2;if(K===1)ce.children=ne;else if(1>>1,L=D[M];if(0>>1;Ma(ce,H))fea(de,ce)?(D[M]=de,D[fe]=H,M=fe):(D[M]=ce,D[re]=H,M=re);else if(fea(de,H))D[M]=de,D[fe]=H,M=fe;else break e}}return A}function a(D,A){var H=D.sortIndex-A.sortIndex;return H!==0?H:D.id-A.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 g=[],y=[],m=1,x=null,v=3,_=!1,S=!1,C=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(D){for(var A=o(y);A!==null;){if(A.callback===null)l(y);else if(A.startTime<=D)l(y),A.sortIndex=A.expirationTime,r(g,A);else break;A=o(y)}}function j(D){if(C=!1,k(D),!S)if(o(g)!==null)S=!0,V(R);else{var A=o(y);A!==null&&W(j,A.startTime-D)}}function R(D,A){S=!1,C&&(C=!1,N(G),G=-1),_=!0;var H=v;try{for(k(A),x=o(g);x!==null&&(!(x.expirationTime>A)||D&&!q());){var M=x.callback;if(typeof M=="function"){x.callback=null,v=x.priorityLevel;var L=M(x.expirationTime<=A);A=t.unstable_now(),typeof L=="function"?x.callback=L:x===o(g)&&l(g),k(A)}else l(g);x=o(g)}if(x!==null)var ne=!0;else{var re=o(y);re!==null&&W(j,re.startTime-A),ne=!1}return ne}finally{x=null,v=H,_=!1}}var T=!1,B=null,G=-1,U=5,ee=-1;function q(){return!(t.unstable_now()-eeD||125M?(D.sortIndex=H,r(y,D),o(g)===null&&D===o(y)&&(C?(N(G),G=-1):C=!0,W(j,H-M))):(D.sortIndex=L,r(g,D),S||_||(S=!0,V(R))),D},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(D){var A=v;return function(){var H=v;v=A;try{return D.apply(this,arguments)}finally{v=H}}}})(Eu)),Eu}var Yf;function e0(){return Yf||(Yf=1,ku.exports=Jy()),ku.exports}/** + */var Xf;function Jy(){return Xf||(Xf=1,(function(t){function r(D,z){var B=D.length;D.push(z);e:for(;0>>1,L=D[M];if(0>>1;Ma(ce,B))fea(de,ce)?(D[M]=de,D[fe]=B,M=fe):(D[M]=ce,D[re]=B,M=re);else if(fea(de,B))D[M]=de,D[fe]=B,M=fe;else break e}}return z}function a(D,z){var B=D.sortIndex-z.sortIndex;return B!==0?B:D.id-z.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 g=[],y=[],m=1,x=null,v=3,_=!1,k=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=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(D){for(var z=o(y);z!==null;){if(z.callback===null)l(y);else if(z.startTime<=D)l(y),z.sortIndex=z.expirationTime,r(g,z);else break;z=o(y)}}function j(D){if(C=!1,N(D),!k)if(o(g)!==null)k=!0,V(R);else{var z=o(y);z!==null&&U(j,z.startTime-D)}}function R(D,z){k=!1,C&&(C=!1,E(G),G=-1),_=!0;var B=v;try{for(N(z),x=o(g);x!==null&&(!(x.expirationTime>z)||D&&!W());){var M=x.callback;if(typeof M=="function"){x.callback=null,v=x.priorityLevel;var L=M(x.expirationTime<=z);z=t.unstable_now(),typeof L=="function"?x.callback=L:x===o(g)&&l(g),N(z)}else l(g);x=o(g)}if(x!==null)var ne=!0;else{var re=o(y);re!==null&&U(j,re.startTime-z),ne=!1}return ne}finally{x=null,v=B,_=!1}}var T=!1,H=null,G=-1,K=5,te=-1;function W(){return!(t.unstable_now()-teD||125M?(D.sortIndex=B,r(y,D),o(g)===null&&D===o(y)&&(C?(E(G),G=-1):C=!0,U(j,B-M))):(D.sortIndex=L,r(g,D),k||_||(k=!0,V(R))),D},t.unstable_shouldYield=W,t.unstable_wrapCallback=function(D){var z=v;return function(){var B=v;v=z;try{return D.apply(this,arguments)}finally{v=B}}}})(Nu)),Nu}var Gf;function e0(){return Gf||(Gf=1,Eu.exports=Jy()),Eu.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Xf;function t0(){if(Xf)return Ct;Xf=1;var t=bo(),r=e0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},x={};function v(e){return g.call(x,e)?!0:g.call(m,e)?!1:y.test(e)?x[e]=!0:(m[e]=!0,!1)}function _(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 S(e,n,i,s){if(n===null||typeof n>"u"||_(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 E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[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];E[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[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){E[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function I(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,I);E[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(N,I);E[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(N,I);E[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,i,s){var c=E.hasOwnProperty(n)?E[n]:null;(c!==null?c.type!==0:s||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},x={};function v(e){return g.call(x,e)?!0:g.call(m,e)?!1:y.test(e)?x[e]=!0:(m[e]=!0,!1)}function _(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 k(e,n,i,s){if(n===null||typeof n>"u"||_(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 S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){S[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];S[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){S[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){S[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){S[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){S[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){S[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){S[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){S[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function I(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,I);S[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,I);S[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,I);S[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),S.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,s){var c=S.hasOwnProperty(n)?S[n]:null;(c!==null?c.type!==0:s||!(2P||c[w]!==h[P]){var z=` -`+c[w].replace(" at new "," at ");return e.displayName&&z.includes("")&&(z=z.replace("",e.displayName)),z}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case T:return"Portal";case U:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b: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 Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function K(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function pe(e){var n=se(e)?"checked":"value",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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function me(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 ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(e,n){var i=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;i=K(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 je(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function Me(e,n){je(e,n);var i=K(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")?Ge(e,n.type,i):n.hasOwnProperty("defaultValue")&&Ge(e,n.type,K(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var 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 Ge(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var nt=Array.isArray;function Ke(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=wt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var gn={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},Ni=["Webkit","ms","Moz","O"];Object.keys(gn).forEach(function(e){Ni.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),gn[n]=gn[e]})});function $r(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||gn.hasOwnProperty(e)&&gn[e]?(""+n).trim():n+"px"}function ir(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=$r(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Ci=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function or(e,n){if(n){if(Ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Pn(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 mn=null;function In(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,on=null,sn=null;function lr(e){if(e=Gi(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),sr(e.stateNode,e.type,n))}}function ar(e){on?sn?sn.push(e):sn=[e]:on=e}function ur(){if(on){var e=on,n=sn;if(sn=on=null,lr(e),n)for(e=0;e>>=0,e===0?32:31-(Ol(e)/Fl|0)|0}var Br=64,Vr=4194304;function hr(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 yn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Pt(n),e[n]=i}function Vl(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=Oi),Rc=" ",Lc=!1;function zc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ac(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xr=!1;function Ym(e,n){switch(e){case"compositionend":return Ac(n);case"keypress":return n.which!==32?null:(Lc=!0,Rc);case"textInput":return e=n.data,e===Rc&&Lc?null:e;default:return null}}function Xm(e,n){if(Xr)return e==="compositionend"||!ea&&zc(e,n)?(e=jc(),Go=Gl=$n=null,Xr=!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=Vc(i)}}function Wc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Wc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Yc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ra(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 ny(e){var n=Yc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Wc(i.ownerDocument.documentElement,i)){if(s!==null&&ra(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=Uc(i,h);var w=Uc(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,Gr=null,ia=null,Vi=null,oa=!1;function Xc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;oa||Gr==null||Gr!==ye(s)||(s=Gr,"selectionStart"in s&&ra(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(ia,"onSelect"),0Jr||(e.current=ya[Jr],ya[Jr]=null,Jr--)}function De(e,n){Jr++,ya[Jr]=e.current,e.current=n}var Bn={},pt=Hn(Bn),_t=Hn(!1),yr=Bn;function ei(e,n){var i=e.type.contextTypes;if(!i)return Bn;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(pt)}function ad(e,n,i){if(pt.current!==Bn)throw Error(o(168));De(pt,n),De(_t,i)}function ud(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,de(e)||"Unknown",c));return H({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,yr=pt.current,De(pt,e),De(_t,_t.current),!0}function cd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=ud(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(pt),De(pt,e)):Fe(_t),De(_t,i)}var xn=null,as=!1,va=!1;function dd(e){xn===null?xn=[e]:xn.push(e)}function py(e){as=!0,dd(e)}function Vn(){if(!va&&xn!==null){va=!0;var e=0,n=ze;try{var i=xn;for(ze=1;e>=w,c-=w,wn=1<<32-Pt(n)+c|i<Ce?(at=Ee,Ee=null):at=Ee.sibling;var Le=ie(X,Ee,Q[Ce],ue);if(Le===null){Ee===null&&(Ee=at);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=at}if(Ce===Q.length)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;CeCe?(at=Ee,Ee=null):at=Ee.sibling;var Zn=ie(X,Ee,Le.value,ue);if(Zn===null){Ee===null&&(Ee=at);break}e&&Ee&&Zn.alternate===null&&n(X,Ee),O=h(Zn,O,Ce),ke===null?we=Zn:ke.sibling=Zn,ke=Zn,Ee=at}if(Le.done)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;!Le.done;Ce++,Le=Q.next())Le=le(X,Le.value,ue),Le!==null&&(O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,Ce),we}for(Ee=s(X,Ee);!Le.done;Ce++,Le=Q.next())Le=he(Ee,X,Ce,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?Ce:Le.key),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,Ce),we}function qe(X,O,Q,ue){if(typeof Q=="object"&&Q!==null&&Q.type===B&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===B){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&yd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===B?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=As(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=gu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,qe(X,O,ke(Q._payload),ue)}if(nt(Q))return ve(X,O,Q,ue);if(A(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=pu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return qe}var ii=vd(!0),xd=vd(!1),hs=Hn(null),ps=null,oi=null,Ea=null;function Na(){Ea=oi=ps=null}function Ca(e){var n=hs.current;Fe(hs),e._currentValue=n}function ja(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 si(e,n){ps=e,Ea=oi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ft(e){var n=e._currentValue;if(Ea!==e)if(e={context:e,memoizedValue:n,next:null},oi===null){if(ps===null)throw Error(o(308));oi=e,ps.dependencies={lanes:0,firstContext:e}}else oi=oi.next=e;return n}var wr=null;function ba(e){wr===null?wr=[e]:wr.push(e)}function wd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,ba(n)):(i.next=c.next,c.next=i),n.interleaved=i,Sn(e,s)}function Sn(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 Un=!1;function Ma(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _d(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Wn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,Sn(e,i)}return c=s.interleaved,c===null?(n.next=n,ba(s)):(n.next=c.next,c.next=n),s.interleaved=n,Sn(e,i)}function gs(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,Ur(e,i)}}function Sd(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 ms(e,n,i,s){var c=e.updateQueue;Un=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var z=P,Z=z.next;z.next=null,w===null?h=Z:w.next=Z,w=z;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==w&&(P===null?oe.firstBaseUpdate=Z:P.next=Z,oe.lastBaseUpdate=z))}if(h!==null){var le=c.baseState;w=0,oe=Z=z=null,P=h;do{var ie=P.lane,he=P.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(ie=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){le=ve.call(he,le,ie);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,ie=typeof ve=="function"?ve.call(he,le,ie):ve,ie==null)break e;le=H({},le,ie);break e;case 2:Un=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[P]:ie.push(P))}else he={eventTime:he,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(Z=oe=he,z=le):oe=oe.next=he,w|=ie;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(z=le),c.baseState=z,c.firstBaseUpdate=Z,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);kr|=w,e.lanes=w,e.memoizedState=le}}function kd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=La.transition;La.transition={};try{e(!1),n()}finally{ze=i,La.transition=s}}function Bd(){return Ht().memoizedState}function vy(e,n,i){var s=Qn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Vd(e))Ud(n,i);else if(i=wd(e,n,i,s),i!==null){var c=xt();Kt(i,e,s,c),Wd(i,n,s)}}function xy(e,n,i){var s=Qn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Vd(e))Ud(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Wt(P,w)){var z=n.interleaved;z===null?(c.next=c,ba(n)):(c.next=z.next,z.next=c),n.interleaved=c;return}}catch{}finally{}i=wd(e,n,c,s),i!==null&&(c=xt(),Kt(i,e,s,c),Wd(i,n,s))}}function Vd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Ud(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Wd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Ur(e,i)}}var Ss={readContext:Ft,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},wy={readContext:Ft,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ft,useEffect:Ld,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Dd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=cn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=cn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Td,useDebugValue:Ha,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Td(!1),n=e[0];return e=yy.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=cn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),lt===null)throw Error(o(349));(Sr&30)!==0||jd(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,Ld(Md.bind(null,s,h,e),[e]),s.flags|=2048,no(9,bd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=cn(),n=lt.identifierPrefix;if(Be){var i=_n,s=wn;i=(s&~(1<<32-Pt(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,0P||c[w]!==h[P]){var A=` +`+c[w].replace(" at new "," at ");return e.displayName&&A.includes("")&&(A=A.replace("",e.displayName)),A}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case T:return"Portal";case K:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case W:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function 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 pe(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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function me(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 ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(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 je(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Me(e,n){je(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")?Ge(e,n.type,i):n.hasOwnProperty("defaultValue")&&Ge(e,n.type,q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var 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 Ge(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var nt=Array.isArray;function qe(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=wt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var gn={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},Ni=["Webkit","ms","Moz","O"];Object.keys(gn).forEach(function(e){Ni.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),gn[n]=gn[e]})});function $r(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||gn.hasOwnProperty(e)&&gn[e]?(""+n).trim():n+"px"}function ir(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=$r(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function or(e,n){if(n){if(Ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Pn(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 mn=null;function In(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,on=null,sn=null;function lr(e){if(e=Gi(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),sr(e.stateNode,e.type,n))}}function ar(e){on?sn?sn.push(e):sn=[e]:on=e}function ur(){if(on){var e=on,n=sn;if(sn=on=null,lr(e),n)for(e=0;e>>=0,e===0?32:31-(Fl(e)/Hl|0)|0}var Br=64,Vr=4194304;function hr(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 yn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Pt(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Oi),Ac=" ",zc=!1;function Dc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $c(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xr=!1;function Ym(e,n){switch(e){case"compositionend":return $c(n);case"keypress":return n.which!==32?null:(zc=!0,Ac);case"textInput":return e=n.data,e===Ac&&zc?null:e;default:return null}}function Xm(e,n){if(Xr)return e==="compositionend"||!ta&&Dc(e,n)?(e=Mc(),Go=Ql=$n=null,Xr=!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=Wc(i)}}function Xc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Xc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Gc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ia(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 ny(e){var n=Gc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Xc(i.ownerDocument.documentElement,i)){if(s!==null&&ia(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=Yc(i,h);var w=Yc(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,Gr=null,oa=null,Vi=null,sa=!1;function Qc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;sa||Gr==null||Gr!==ye(s)||(s=Gr,"selectionStart"in s&&ia(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(oa,"onSelect"),0Jr||(e.current=va[Jr],va[Jr]=null,Jr--)}function De(e,n){Jr++,va[Jr]=e.current,e.current=n}var Bn={},pt=Hn(Bn),_t=Hn(!1),yr=Bn;function ei(e,n){var i=e.type.contextTypes;if(!i)return Bn;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(pt)}function cd(e,n,i){if(pt.current!==Bn)throw Error(o(168));De(pt,n),De(_t,i)}function dd(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,de(e)||"Unknown",c));return B({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,yr=pt.current,De(pt,e),De(_t,_t.current),!0}function fd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=dd(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(pt),De(pt,e)):Fe(_t),De(_t,i)}var xn=null,as=!1,xa=!1;function hd(e){xn===null?xn=[e]:xn.push(e)}function py(e){as=!0,hd(e)}function Vn(){if(!xa&&xn!==null){xa=!0;var e=0,n=Ae;try{var i=xn;for(Ae=1;e>=w,c-=w,wn=1<<32-Pt(n)+c|i<Ce?(at=Ee,Ee=null):at=Ee.sibling;var Le=ie(X,Ee,Q[Ce],ue);if(Le===null){Ee===null&&(Ee=at);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=at}if(Ce===Q.length)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;CeCe?(at=Ee,Ee=null):at=Ee.sibling;var Zn=ie(X,Ee,Le.value,ue);if(Zn===null){Ee===null&&(Ee=at);break}e&&Ee&&Zn.alternate===null&&n(X,Ee),O=h(Zn,O,Ce),ke===null?we=Zn:ke.sibling=Zn,ke=Zn,Ee=at}if(Le.done)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;!Le.done;Ce++,Le=Q.next())Le=le(X,Le.value,ue),Le!==null&&(O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,Ce),we}for(Ee=s(X,Ee);!Le.done;Ce++,Le=Q.next())Le=he(Ee,X,Ce,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?Ce:Le.key),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,Ce),we}function Ke(X,O,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 R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===H){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&xd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===H?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=zs(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=mu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,Ke(X,O,ke(Q._payload),ue)}if(nt(Q))return ve(X,O,Q,ue);if(z(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=gu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return Ke}var ii=wd(!0),_d=wd(!1),hs=Hn(null),ps=null,oi=null,Na=null;function Ca(){Na=oi=ps=null}function ja(e){var n=hs.current;Fe(hs),e._currentValue=n}function ba(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 si(e,n){ps=e,Na=oi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ft(e){var n=e._currentValue;if(Na!==e)if(e={context:e,memoizedValue:n,next:null},oi===null){if(ps===null)throw Error(o(308));oi=e,ps.dependencies={lanes:0,firstContext:e}}else oi=oi.next=e;return n}var wr=null;function Ma(e){wr===null?wr=[e]:wr.push(e)}function Sd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ma(n)):(i.next=c.next,c.next=i),n.interleaved=i,Sn(e,s)}function Sn(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 Un=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Wn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,Sn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,Sn(e,i)}function gs(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,Ur(e,i)}}function Ed(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 ms(e,n,i,s){var c=e.updateQueue;Un=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var A=P,Z=A.next;A.next=null,w===null?h=Z:w.next=Z,w=A;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==w&&(P===null?oe.firstBaseUpdate=Z:P.next=Z,oe.lastBaseUpdate=A))}if(h!==null){var le=c.baseState;w=0,oe=Z=A=null,P=h;do{var ie=P.lane,he=P.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(ie=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){le=ve.call(he,le,ie);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,ie=typeof ve=="function"?ve.call(he,le,ie):ve,ie==null)break e;le=B({},le,ie);break e;case 2:Un=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[P]:ie.push(P))}else he={eventTime:he,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(Z=oe=he,A=le):oe=oe.next=he,w|=ie;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(A=le),c.baseState=A,c.firstBaseUpdate=Z,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);kr|=w,e.lanes=w,e.memoizedState=le}}function Nd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Aa.transition;Aa.transition={};try{e(!1),n()}finally{Ae=i,Aa.transition=s}}function Ud(){return Ht().memoizedState}function vy(e,n,i){var s=Qn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(e))Yd(n,i);else if(i=Sd(e,n,i,s),i!==null){var c=xt();qt(i,e,s,c),Xd(i,n,s)}}function xy(e,n,i){var s=Qn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(e))Yd(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Wt(P,w)){var A=n.interleaved;A===null?(c.next=c,Ma(n)):(c.next=A.next,A.next=c),n.interleaved=c;return}}catch{}finally{}i=Sd(e,n,c,s),i!==null&&(c=xt(),qt(i,e,s,c),Xd(i,n,s))}}function Wd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Yd(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Xd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Ur(e,i)}}var Ss={readContext:Ft,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},wy={readContext:Ft,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ft,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Od.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=cn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=cn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Ld,useDebugValue:Ba,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Ld(!1),n=e[0];return e=yy.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=cn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),lt===null)throw Error(o(349));(Sr&30)!==0||Md(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(Id.bind(null,s,h,e),[e]),s.flags|=2048,no(9,Pd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=cn(),n=lt.identifierPrefix;if(Be){var i=_n,s=wn;i=(s&~(1<<32-Pt(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,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[an]=n,e[Xi]=s,ff(e,n,!1,!1),n.stateNode=e;e:{switch(w=Pn(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cdi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return mt(n),null}else 2*Ue()-h.renderingStartTime>di&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(mt(n),null);case 22:case 23:return du(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Lt&1073741824)!==0&&(mt(n),n.subtreeFlags&6&&(n.flags|=8192)):mt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(wa(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return li(),Fe(_t),Fe(pt),Ra(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ia(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ri()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return li(),null;case 10:return Ca(n.type._context),null;case 22:case 23:return du(),null;case 24:return null;default:return null}}var Cs=!1,yt=!1,My=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ui(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Qe(e,n,s)}else i.current=null}function Ja(e,n,i){try{i()}catch(s){Qe(e,n,s)}}var gf=!1;function Py(e,n){if(da=Yo,e=Yc(),ra(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,P=-1,z=-1,Z=0,oe=0,le=e,ie=null;t:for(;;){for(var he;le!==i||c!==0&&le.nodeType!==3||(P=w+c),le!==h||s!==0&&le.nodeType!==3||(z=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)ie=le,le=he;for(;;){if(le===e)break t;if(ie===i&&++Z===c&&(P=w),ie===h&&++oe===s&&(z=w),(he=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=he}i=P===-1||z===-1?null:{start:P,end:z}}else i=null}i=i||{start:0,end:0}}else i=null;for(fa={focusedElem:e,selectionRange:i},Yo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,qe=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Xt(n.type,xe),qe);X.__reactInternalSnapshotBeforeUpdate=O}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){Qe(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=gf,gf=!1,ve}function io(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&&Ja(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function eu(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 mf(e){var n=e.alternate;n!==null&&(e.alternate=null,mf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[an],delete n[Xi],delete n[ma],delete n[fy],delete n[hy])),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 yf(e){return e.tag===5||e.tag===3||e.tag===4}function vf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yf(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 tu(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=is));else if(s!==4&&(e=e.child,e!==null))for(tu(e,n,i),e=e.sibling;e!==null;)tu(e,n,i),e=e.sibling}function nu(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(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}var dt=null,Gt=!1;function Yn(e,n,i){for(i=i.child;i!==null;)xf(e,n,i),i=i.sibling}function xf(e,n,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Hr,i)}catch{}switch(i.tag){case 5:yt||ui(i,n);case 6:var s=dt,c=Gt;dt=null,Yn(e,n,i),dt=s,Gt=c,dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?ga(e.parentNode,i):e.nodeType===1&&ga(e,i),Ai(e)):ga(dt,i.stateNode));break;case 4:s=dt,c=Gt,dt=i.stateNode.containerInfo,Gt=!0,Yn(e,n,i),dt=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!yt&&(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)&&Ja(i,n,w),c=c.next}while(c!==s)}Yn(e,n,i);break;case 1:if(!yt&&(ui(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Qe(i,n,P)}Yn(e,n,i);break;case 21:Yn(e,n,i);break;case 22:i.mode&1?(yt=(s=yt)||i.memoizedState!==null,Yn(e,n,i),yt=s):Yn(e,n,i);break;default:Yn(e,n,i)}}function wf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,Gn===null)var s=!1;else{if(e=Gn,Gn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var P=h.deletions;if(P!==null){for(var z=0;zUe()-ou?Nr(e,0):iu|=i),Nt(e,n)}function Rf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Vr,Vr<<=1,(Vr&130023424)===0&&(Vr=4194304)));var i=xt();e=Sn(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Rf(e,i)}function Oy(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),Rf(e,i)}var Lf;Lf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&fd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ei(n,pt.current);si(n,i),c=Aa(null,n,s,e,c,i);var h=Da();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Ma(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Va(n,s,e,i),n=Xa(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&xa(n),vt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Xt(s,e),c){case 0:n=Ya(null,n,s,e,i);break e;case 1:n=sf(null,n,s,e,i);break e;case 11:n=ef(null,n,s,e,i);break e;case 14:n=tf(null,n,s,Xt(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:Xt(s,c),Ya(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),sf(e,n,s,c,i);case 3:e:{if(lf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,_d(e,n),ms(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=ai(Error(o(423)),n),n=af(e,n,s,i,c);break e}else if(s!==c){c=ai(Error(o(424)),n),n=af(e,n,s,i,c);break e}else for(Rt=Fn(n.stateNode.containerInfo.firstChild),Tt=n,Be=!0,Yt=null,i=xd(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ri(),s===c){n=En(e,n,i);break e}vt(e,n,s,i)}n=n.child}return n;case 5:return Ed(n),e===null&&Sa(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,ha(s,c)?w=null:h!==null&&ha(s,h)&&(n.flags|=32),of(e,n),vt(e,n,w,i),n.child;case 6:return e===null&&Sa(n),null;case 13:return uf(e,n,i);case 4:return Pa(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=ii(n,null,s,i):vt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),ef(e,n,s,c,i);case 7:return vt(e,n,n.pendingProps,i),n.child;case 8:return vt(e,n,n.pendingProps.children,i),n.child;case 12:return vt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!_t.current){n=En(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var z=P.firstContext;z!==null;){if(z.context===s){if(h.tag===1){z=kn(-1,i&-i),z.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var oe=Z.pending;oe===null?z.next=z:(z.next=oe.next,oe.next=z),Z.pending=z}}h.lanes|=i,z=h.alternate,z!==null&&(z.lanes|=i),ja(h.return,i,n),P.lanes|=i;break}z=z.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,P=w.alternate,P!==null&&(P.lanes|=i),ja(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}vt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,si(n,i),c=Ft(c),s=s(c),n.flags|=1,vt(e,n,s,i),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),tf(e,n,s,c,i);case 15:return nf(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,si(n,i),Xd(n,s,c),Va(n,s,c,i),Xa(null,n,s,!0,e,i);case 19:return df(e,n,i);case 22:return rf(e,n,i)}throw Error(o(156,n.tag))};function zf(e,n){return Do(e,n)}function Fy(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 Fy(e,n,i,s)}function hu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return hu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===Y)return 14}return 2}function qn(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 As(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")hu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case B:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case U:return e=Vt(12,i,n,c|2),e.elementType=U,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Vt(19,i,n,c),e.elementType=b,e.lanes=h,e;case W:return Ds(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 Y: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 jr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=W,e.lanes=i,e.stateNode={isHidden:!1},e}function pu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function gu(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 By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function mu(e,n,i,s,c,h,w,P,z){return e=new By(e,n,i,P,z),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},Ma(h),e}function Vy(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(),Su.exports=t0(),Su.exports}var Qf;function n0(){if(Qf)return Us;Qf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function pi(t){return t.replace(/([/\\._:@-])/g,"$1​")}function Dr({className:t,children:r}){return p.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 a0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function u0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function c0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function d0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function f0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function h0({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const p0="modulepreload",g0=function(t,r){return new URL(t,r).href},Kf={},m0=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(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(m=>{if(m=g0(m,l),m in Kf)return;Kf[m]=!0;const x=m.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const E=f[C];if(E.href===m&&(!x||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const S=document.createElement("link");if(S.rel=x?"stylesheet":p0,x||(S.as="script"),S.crossOrigin="",S.href=m,y&&S.setAttribute("nonce",y),document.head.appendChild(S),x)return new Promise((C,E)=>{S.addEventListener("load",C),S.addEventListener("error",()=>E(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 et(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=v0(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)),Zf.hasOwnProperty(r)?{space:Zf[r],local:t}:t}function w0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Ou&&r.documentElement.namespaceURI===Ou?r.createElement(t):r.createElementNS(o,t)}}function _0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?_0:w0)(r)}function S0(){}function Ju(t){return t==null?S0:function(){return this.querySelector(t)}}function k0(t){typeof t!="function"&&(t=Ju(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=k&&(k=I+1);!(R=E[k])&&++k=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function G0(t){t||(t=Q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function K0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function q0(){return Array.from(this)}function Z0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?uv:typeof r=="function"?dv:cv)(t,r,o??"")):vi(this.node(),t)}function vi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function hv(t){return function(){delete this[t]}}function pv(t,r){return function(){this[t]=r}}function gv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function mv(t,r){return arguments.length>1?this.each((r==null?hv:typeof r=="function"?gv:pv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function ec(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=ec(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Uv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Fu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:y,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:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:m}})}Fu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ex(t){return!t.ctrlKey&&!t.button}function tx(){return this.parentNode}function nx(t,r){return r??{x:t.x,y:t.y}}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ap(){var t=ex,r=tx,o=nx,l=rx,a={},u=vl("start","drag","end"),d=0,f,g,y,m,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",E).on("touchmove.drag",N,Jv).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(m||!t.call(this,j,R))){var T=k(this,r.call(this,j,R),j,R,"mouse");T&&(zt(j.view).on("mousemove.drag",S,vo).on("mouseup.drag",C,vo),Lp(j.view),Nu(j),y=!1,f=j.clientX,g=j.clientY,T("start",j))}}function S(j){if(mi(j),!y){var R=j.clientX-f,T=j.clientY-g;y=R*R+T*T>x}a.mouse("drag",j)}function C(j){zt(j.view).on("mousemove.drag mouseup.drag",null),zp(j.view,y),mi(j),a.mouse("end",j)}function E(j,R){if(t.call(this,j,R)){var T=j.changedTouches,B=r.call(this,j,R),G=T.length,U,ee;for(U=0;U>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=ox.exec(t))?new jt(r[1],r[2],r[3],1):(r=sx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=lx.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ax.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ux.exec(t))?oh(r[1],r[2]/100,r[3]/100,1):(r=cx.exec(t))?oh(r[1],r[2]/100,r[3]/100,r[4]):Jf.hasOwnProperty(t)?nh(Jf[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function nh(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function hx(t){return t instanceof Po||(t=Tr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Hu(t,r,o,l){return arguments.length===1?hx(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}tc(jt,Hu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Pr(this.r),Pr(this.g),Pr(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rh,formatHex:rh,formatHex8:px,formatRgb:ih,toString:ih}));function rh(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}`}function px(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}${Mr((isNaN(this.opacity)?1:this.opacity)*255)}`}function ih(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Pr(this.r)}, ${Pr(this.g)}, ${Pr(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Pr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Mr(t){return t=Pr(t),(t<16?"0":"")+t.toString(16)}function oh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,o,l)}function $p(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Tr(t)),!t)return new Zt;if(t instanceof Zt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Zt(d,f,g,t.opacity)}function gx(t,r,o,l){return arguments.length===1?$p(t):new Zt(t,r,o,l??1)}function Zt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}tc(Zt,gx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Zt(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 jt(Cu(t>=240?t-240:t+120,a,l),Cu(t,a,l),Cu(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(sh(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${sh(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function sh(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function Cu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const nc=t=>()=>t;function mx(t,r){return function(o){return t+o*r}}function yx(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 vx(t){return(t=+t)==1?Op:function(r,o){return o-r?yx(r,o,t):nc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?mx(t,o):nc(isNaN(t)?r:t)}const ul=(function t(r){var o=vx(r);function l(a,u){var d=o((a=Hu(a)).r,(u=Hu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Op(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=g(m),a.opacity=y(m),a+""}}return l.gamma=t,l})(1);function xx(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,g.push({i:d,x:fn(l,a)})),o=ju.lastIndex;return o180?m+=360:m-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:fn(y,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(y,m,x,v){y!==m?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:fn(y,m)}):m&&x.push(a(x)+"skewX("+m+l)}function g(y,m,x,v,_,S){if(y!==x||m!==v){var C=_.push(a(_)+"scale(",null,",",null,")");S.push({i:C-4,x:fn(y,x)},{i:C-2,x:fn(m,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,m){var x=[],v=[];return y=t(y),m=t(m),u(y.translateX,y.translateY,m.translateX,m.translateY,x,v),d(y.rotate,m.rotate,x,v),f(y.skewX,m.skewX,x,v),g(y.scaleX,y.scaleY,m.scaleX,m.scaleY,x,v),y=m=null,function(_){for(var S=-1,C=v.length,E;++S=0&&t._call.call(void 0,r),t=t._next;--xi}function uh(){Rr=(dl=_o.now())+wl,xi=ho=0;try{Lx()}finally{xi=0,Ax(),Rr=0}}function zx(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function Ax(){for(var t,r=cl,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:cl=o);po=t,Uu(l)}function Uu(t){if(!xi){ho&&(ho=clearTimeout(ho));var r=t-Rr;r>24?(t<1/0&&(ho=setTimeout(uh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(zx,Vp)),xi=1,Up(uh))}}function ch(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Dx=vl("start","end","cancel","interrupt"),$x=[],Yp=0,dh=1,Wu=2,rl=3,fh=4,Yu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Ox(t,o,{name:r,index:l,group:a,on:Dx,tween:$x,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function ic(t,r){var o=nn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function pn(t,r){var o=nn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function nn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Ox(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(y){o.state=dh,o.timer.restart(d,o.delay,o.time),o.delay<=y&&d(y-o.delay)}function d(y){var m,x,v,_;if(o.state!==dh)return g();for(m in l)if(_=l[m],_.name===o.name){if(_.state===rl)return ch(d);_.state===fh?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[m]):+mWu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function gw(t,r,o){var l,a,u=pw(r)?ic:pn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function mw(t,r){var o=this._id;return arguments.length<2?nn(this.node(),o).on.on(t):this.each(gw(o,t,r))}function yw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function vw(){return this.on("end.remove",yw(this._id))}function xw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=Ju(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Uw(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 jn(t,r,o){this.k=t,this.x=r,this.y=o}jn.prototype={constructor:jn,scale:function(t){return t===1?this:new jn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new jn(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 Sl=new jn(1,0,0);Kp.prototype=jn.prototype;function Kp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function bu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Ww(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Yw(){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 hh(){return this.__zoom||Sl}function Xw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Gw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(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 qp(){var t=Ww,r=Yw,o=Qw,l=Xw,a=Gw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,y=vl("start","zoom","end"),m,x,v,_=500,S=150,C=0,E=10;function N(b){b.property("__zoom",hh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",U).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)")}N.transform=function(b,Y,V,W){var D=b.selection?b.selection():b;D.property("__zoom",hh),b!==D?R(b,Y,V,W):D.interrupt().each(function(){T(this,arguments).event(W).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},N.scaleBy=function(b,Y,V,W){N.scaleTo(b,function(){var D=this.__zoom.k,A=typeof Y=="function"?Y.apply(this,arguments):Y;return D*A},V,W)},N.scaleTo=function(b,Y,V,W){N.transform(b,function(){var D=r.apply(this,arguments),A=this.__zoom,H=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=A.invert(H),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(k(I(A,L),H,M),D,d)},V,W)},N.translateBy=function(b,Y,V,W){N.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,W)},N.translateTo=function(b,Y,V,W,D){N.transform(b,function(){var A=r.apply(this,arguments),H=this.__zoom,M=W==null?j(A):typeof W=="function"?W.apply(this,arguments):W;return o(Sl.translate(M[0],M[1]).scale(H.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),A,d)},W,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new jn(Y,b.x,b.y)}function k(b,Y,V){var W=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return W===b.x&&D===b.y?b:new jn(b.k,W,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,W){b.on("start.zoom",function(){T(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(W).end()}).tween("zoom",function(){var D=this,A=arguments,H=T(D,A).event(W),M=r.apply(D,A),L=V==null?j(M):typeof V=="function"?V.apply(D,A):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,A):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var K=fe(de),se=ne/K[2];de=new jn(se,L[0]-K[0]*se,L[1]-K[1]*se)}H.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new B(b,Y)}function B(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}B.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=zt(this.that).datum();y.call(b,this.that,new Uw(b,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:y}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),W=this.__zoom,D=Math.max(u[0],Math.min(u[1],W.k*Math.pow(2,l.apply(this,arguments)))),A=qt(b);if(V.wheel)(V.mouse[0][0]!==A[0]||V.mouse[0][1]!==A[1])&&(V.mouse[1]=W.invert(V.mouse[0]=A)),clearTimeout(V.wheel);else{if(W.k===D)return;V.mouse=[A,W.invert(A)],ol(this),V.start()}fo(b),V.wheel=setTimeout(H,S),V.zoom("mouse",o(k(I(W,D),V.mouse[0],V.mouse[1]),V.extent,d));function H(){V.wheel=null,V.end()}}function U(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,W=T(this,Y,!0).event(b),D=zt(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),A=qt(b,V),H=b.clientX,M=b.clientY;Lp(b.view),bu(b),W.mouse=[A,this.__zoom.invert(A)],ol(this),W.start();function L(re){if(fo(re),!W.moved){var ce=re.clientX-H,fe=re.clientY-M;W.moved=ce*ce+fe*fe>C}W.event(re).zoom("mouse",o(k(W.that.__zoom,W.mouse[0]=qt(re,V),W.mouse[1]),W.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),zp(re.view,W.moved),fo(re),W.event(re).end()}}function ee(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,W=qt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(W),A=V.k*(b.shiftKey?.5:2),H=o(k(I(V,A),W,D),r.apply(this,Y),d);fo(b),f>0?zt(this).transition().duration(f).call(R,H,W,b):zt(this).call(N.transform,H,W,b)}}function q(b,...Y){if(t.apply(this,arguments)){var V=b.touches,W=V.length,D=T(this,Y,b.changedTouches.length===W).event(b),A,H,M,L;for(bu(b),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle: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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 wi;(function(t){t.Strict="strict",t.Loose="loose"})(wi||(wi={}));var Ir;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Ir||(Ir={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var nr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(nr||(nr={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const ph={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Kw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),sc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=rn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},qw=(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):sc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},lc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,y=r.width/a,m=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:S=!0,hidden:C=!1}=v;if(d&&!S||C)continue;const E=_.width??v.width??v.initialWidth??0,N=_.height??v.height??v.initialHeight??0,{x:I,y:k}=v.internals.positionAbsolute,j=sg(f,g,y,m,I,k,E,N),R=E*N,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Zw=(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 Jw(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}=rn(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 e1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Jw(t,d),g=To(f),y=uc(g,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(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y}=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",tn.error005());else{const{width:_,height:S}=rn(f);_&&S&&(x=[[g,y],[g+_,y+S]])}else f&&zr(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+y],[d.extent[1][0]+g,d.extent[1][1]+y]]);const v=zr(x)?Lr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-g+(d.measured.width??0)*m[0],y:v.y-y+(d.measured.height??0)*m[1]},positionAbsolute:v}}async function t1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),S=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||S)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),m=Zw(d,g);for(const v of g)f.has(v.id)&&!m.find(S=>S.id===v.id)&&m.push(v);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 _i=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Lr=(t={x:0,y:0},r,o)=>({x:_i(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:_i(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=rn(o),{x:u,y:d}=o.internals.positionAbsolute;return Lr(t,[[u,d],[u+l,d+a]],r)}const gh=(t,r,o)=>to?-_i(Math.abs(t-o),1,r)/r:0,ac=(t,r,o=15,l=40)=>{const a=gh(t.x,l,r.width-l)*o,u=gh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Xu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=sc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=sc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Xu(t),Xu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*y)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),mh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Si=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function hi(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 n1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=hi(t,o),a=hi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=hi(t.top??t.y??0,o),a=hi(t.bottom??t.y??0,o),u=hi(t.left??t.x??0,r),d=hi(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 r1(t,r,o,l,a,u){const{x:d,y:f}=Si(t,[r,o,l]),{x:g,y}=Si({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-g,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const uc=(t,r,o,l,a,u)=>{const d=n1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,y=Math.min(f,g),m=_i(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*m,S=o/2-v*m,C=r1(t,_,S,m,r,o),E={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:_-E.left+E.right,y:S-E.top+E.bottom,zoom:m}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function zr(t){return t!=null&&t!=="parent"}function rn(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 ag(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 ug(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 yh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function i1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const cc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},s1=["INPUT","SELECT","TEXTAREA"];function dg(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:s1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,en=(t,r)=>{var u,d;const o=fg(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)}},vh=(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,...cc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,y=r*.125+u*.375+f*.375+l*.125,m=Math.abs(g-t),x=Math.abs(y-r);return[g,y,m,x]}function Ks(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function xh({pos:t,x1:r,y1:o,x2:l,y2:a,c:u}){switch(t){case Se.Left:return[r-Ks(r-l,u),o];case Se.Right:return[r+Ks(l-r,u),o];case Se.Top:return[r,o-Ks(o-a,u)];case Se.Bottom:return[r,o+Ks(a-o,u)]}}function pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=xh({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[y,m]=xh({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,S]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:m});return[`M${t},${r} C${f},${g} ${y},${m} ${l},${a}`,x,v,_,S]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const u1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,c1=(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)),d1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",tn.error006()),r;const l=o.getEdgeId||u1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},c1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const wh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},f1=({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 h1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=wh[r],g=wh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+g.x*u,y:o.y+g.y*u},x=f1({source:y,sourcePosition:r,target:m}),v=x.x!==0?"x":"y",_=x[v];let S=[],C,E;const N={x:0,y:0},I={x:0,y:0},[,,k,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??y.x+(m.x-y.x)*d,E=a.y??(y.y+m.y)/2):(C=a.x??(y.x+m.x)/2,E=a.y??y.y+(m.y-y.y)*d);const G=[{x:C,y:y.y},{x:C,y:m.y}],U=[{x:y.x,y:E},{x:m.x,y:E}];f[v]===_?S=v==="x"?G:U:S=v==="x"?U:G}else{const G=[{x:y.x,y:m.y}],U=[{x:m.x,y:y.y}];if(v==="x"?S=f.x===_?U:G:S=f.y===_?G:U,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?N[v]=(y[v]>t[v]?-1:1)*Y:I[v]=(m[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=y[b]>m[b],W=y[b]=J?(C=(ee.x+q.x)/2,E=S[0].y):(C=S[0].x,E=(ee.y+q.y)/2)}const R={x:y.x+N.x,y:y.y+N.y},T={x:m.x+I.x,y:m.y+I.y};return[[t,...R.x!==S[0].x||R.y!==S[0].y?[R]:[],...S,...T.x!==S[S.length-1].x||T.y!==S[S.length-1].y?[T]:[],o],C,E,k,j]}function p1(t,r,o,l){const a=Math.min(_h(t,r)/2,_h(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 y=t.xo.id===r):t[0])||null}function Qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(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(g=>{if(g&&typeof g=="object"){const y=Qu(g,r);u.has(y)||(d.push({id:y,color:g.color||o,...g}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,y1=10,dc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},v1={...dc,checkEquality:!0};function fc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function x1(t,r,o){const l=fc(dc,o);for(const a of t.values())if(a.parentId)pc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=zr(a.extent)?a.extent:l.nodeExtent,f=Lr(u,d,rn(a));a.internals.positionAbsolute=f}}function w1(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 hc(t){return t==="manual"}function Ku(t,r,o,l={}){var m,x;const a=fc(v1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!hc(a.zIndexMode)?yg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const S=Io(v,a.nodeOrigin),C=zr(v.extent)?v.extent:a.nodeExtent,E=Lr(S,C,rn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:E,handleBounds:w1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&pc(_,r,o,l,u),y||(y=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function _1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function pc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=fc(dc,l),y=t.parentId,m=r.get(y);if(!m){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&g==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*y1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!hc(g)?yg:0,{x:v,y:_,z:S}=S1(t,m,d,f,x,g),{positionAbsolute:C}=t.internals,E=v!==C.x||_!==C.y;(E||S!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:v,y:_}:C,z:S}})}function vg(t,r,o){const l=Jt(t.zIndex)?t.zIndex:0;return hc(o)?l:l+(t.selected?r:0)}function S1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=rn(t),y=Io(t,o),m=zr(t.extent)?Lr(y,t.extent,g):y;let x=Lr({x:d+m.x,y:f+m.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function gc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),m=og(y,f.rect);u.set(f.parentId,{expandedRect:m,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var k;const m=g.internals.positionAbsolute,x=rn(g),v=g.origin??l,_=f.x0||S>0||N||I)&&(a.push({id:y,type:"position",position:{x:g.position.x-_+N,y:g.position.y-S+I}}),(k=o.get(y))==null||k.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+S}})})),(x.width0){const _=gc(v,r,o,a);y.push(..._)}return{changes:y,updatedInternals:g}}async function E1({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 Nh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;Nh("source",g,m,t,a,d),Nh("target",g,y,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function Ch(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 N1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Mu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[y,m]of r){const x=(d=o.get(y))==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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function C1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function j1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,y={x:0,y:0},m=null,x=!1,v=null,_=!1,S=!1,C=null;function E({noDragClassName:I,handleSelector:k,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:B=0}){v=zt(j);function G({x:te,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:W,nodeOrigin:D,onNodeDrag:A,onSelectionDrag:H,onError:M,updateNodePositions:L}=r();u={x:te,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Xu(To(f)):null,fe=re&&W?C1({dragItems:f,snapGrid:V,x:te,y:J}):null;for(const[de,K]of f){if(!b.has(de))continue;let se={x:te-K.distance.x,y:J-K.distance.y};W&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:Ro(se,V));let pe=null;if(re&&Y&&!K.extent&&ce){const{positionAbsolute:ye}=K.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+K.measured.width-ce.x2+Y[1][0],je=ye.y-ce.y+Y[0][1],Me=ye.y+K.measured.height-ce.y2+Y[1][1];pe=[[Ne,je],[Pe,Me]]}const{position:_e,positionAbsolute:me}=rg({nodeId:de,nextPosition:se,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||K.position.x!==_e.x||K.position.y!==_e.y,K.position=_e,K.internals.positionAbsolute=me}if(S=S||ne,!!ne&&(L(f,!0),C&&(l||A||!T&&H))){const[de,K]=Mu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,K),A==null||A(C,de,K),T||H==null||H(C,K)}}async function U(){if(!m)return;const{transform:te,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,W]=ac(y,m,b);(V!==0||W!==0)&&(u.x=(u.x??0)-V/te[2],u.y=(u.y??0)-W/te[2],await J({x:V,y:W})&&G(u)),d=requestAnimationFrame(U)}function ee(te){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:W,snapToGrid:D,selectNodesOnDrag:A,onNodeDragStart:H,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!A||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&A&&T&&(t==null||t(T));const ne=mo(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:D,containerBounds:m});if(u=ne,f=N1(J,Y,ne,T),f.size>0&&(o||H||!T&&M)){const[ce,fe]=Mu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(te.sourceEvent,f,ce,fe),H==null||H(te.sourceEvent,ce,fe),T||M==null||M(te.sourceEvent,fe)}}const q=Ap().clickDistance(B).on("start",te=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:W}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,S=!1,C=te.sourceEvent,b===0&&ee(te),u=mo(te.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:W,containerBounds:m}),y=en(te.sourceEvent,m)}).on("drag",te=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:W,nodeLookup:D}=r(),A=mo(te.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:m});if(C=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,U()),!x){const H=en(te.sourceEvent,m),M=H.x-y.x,L=H.y-y.y;Math.sqrt(M*M+L*L)>W&&ee(te)}(u.x!==A.xSnapped||u.y!==A.ySnapped)&&f&&x&&(y=en(te.sourceEvent,m),G(A))}}).on("end",te=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(S&&(b(f,!1),S=!1),a||Y||!T&&V){const[W,D]=Mu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(te.sourceEvent,f,W,D),Y==null||Y(te.sourceEvent,W,D),T||V==null||V(te.sourceEvent,D)}}}).filter(te=>{const J=te.target;return!te.button&&(!I||!Ch(J,`.${I}`,j))&&(!k||Ch(J,k,j))});v.call(q)}function N(){v==null||v.on(".drag",null)}return{update:E,destroy:N}}function b1(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())pl(a,No(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,o,l){var f,g;let a=[],u=1/0;const d=b1(t,o,r+M1);for(const y of d){const m=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=Ar(y,x,x.position,!0),S=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));S>r||(S1){const y=l.type==="source"?"target":"source";return a.find(m=>m.type===y)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var y,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...Ar(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function T1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:m,flowId:x,panBy:v,cancelConnection:_,onConnectStart:S,onConnect:C,onConnectEnd:E,isValidConnection:N=kg,onReconnectEnd:I,updateConnection:k,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:B=1,handleDomNode:G}){const U=cg(t.target);let ee=0,q;const{x:te,y:J}=en(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const W=_g(a,b,l,g,r);if(!W)return;let D=en(t,Y),A=!1,H=null,M=!1,L=null;function ne(){if(!m||!Y)return;const[_e,me]=ac(D,Y,T);v({x:_e,y:me}),ee=requestAnimationFrame(ne)}const re={...W,nodeId:a,type:b,position:W.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:Ar(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:ph[re.position],toNode:null,pointer:D};function K(){V=!0,k(de),S==null||S(t,{nodeId:a,handleId:l,handleType:b})}B===0&&K();function se(_e){if(!V){const{x:Me,y:tt}=en(_e),Ge=Me-te,nt=tt-J;if(!(Ge*Ge+nt*nt>B*B))return;K()}if(!R()||!re){pe(_e);return}const me=j();D=en(_e,Y),q=P1(Lo(D,me,!1,[1,1]),o,g,re),A||(ne(),A=!0);const ye=Eg(_e,{handle:q,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:N,doc:U,lib:y,flowId:x,nodeLookup:g});L=ye.handleDomNode,H=ye.connection,M=I1(!!q,ye.isValid);const Ne=g.get(a),Pe=Ne?Ar(Ne,re,Se.Left,!0):de.from,je={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Si({x:ye.toHandle.x,y:ye.toHandle.y},me):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:ph[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};k(je),de=je}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(q||L)&&H&&M&&(C==null||C(H));const{inProgress:me,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};E==null||E(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(ee),A=!1,M=!1,H=null,L=null,U.removeEventListener("mousemove",se),U.removeEventListener("mouseup",pe),U.removeEventListener("touchmove",se),U.removeEventListener("touchend",pe)}}U.addEventListener("mousemove",se),U.addEventListener("mouseup",pe),U.addEventListener("touchmove",se),U.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:y=kg,nodeLookup:m}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:S}=en(t),C=d.elementFromPoint(_,S),E=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const I=Sg(void 0,E),k=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),R=E.classList.contains("connectable"),T=E.classList.contains("connectableend");if(!k||!I)return N;const B={source:x?k:l,sourceHandle:x?j:a,target:x?l:k,targetHandle:x?a:j};N.connection=B;const U=R&&T&&(o===wi.Strict?x&&I==="source"||!x&&I==="target":k!==l||j!==a);N.isValid=U&&y(B),N.toHandle=_g(k,I,j,m,o,!0)}return N}const qu={onPointerDown:T1,isValid:Eg};function R1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=zt(t);function u({translateExtent:f,width:g,height:y,zoomStep:m=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const S=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=k.sourceEvent.ctrlKey&&Co()?10:1,T=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,B=j[2]*Math.pow(2,T*R);r.scaleTo(B)};let C=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(C=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},N=k=>{const j=o();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const R=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const B=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*B,y:j[1]-T[1]*B},U=[[0,0],[g,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},U,f)},I=qp().on("start",E).on("zoom",x?N:null).on("zoom.wheel",v?S:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:qt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Pu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),tr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),L1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Iu=(t,r=0,o=L1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function z1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return m=>{if(tr(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const E=qt(m),N=Cg(m),I=x*Math.pow(2,N);l.scaleTo(o,I,E,m);return}const v=m.deltaMode===1?20:1;let _=a===Ir.Vertical?0:m.deltaX*v,S=a===Ir.Horizontal?0:m.deltaY*v;!Co()&&m.shiftKey&&a!==Ir.Vertical&&(_=m.deltaY*v,S=0),l.translateBy(o,-(_/x)*u,-(S/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(m,C),t.isPanScrolling=!1},150)}}function A1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=tr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function D1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 $1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function O1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function F1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:m,connectionInProgress:x}){return v=>{var N;const _=r||o,S=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(tr(v,`${m}-flow__node`)||tr(v,`${m}-flow__edge`)||tr(v,`${m}-flow__selection`)||tr(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||tr(v,g)&&C||tr(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((N=v.touches)==null?void 0:N.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!S&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&E}}function H1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const y={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 v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=qp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),S=zt(t).call(_);j({x:a.x,y:a.y,zoom:_i(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=S.on("wheel.zoom"),E=S.on("dblclick.zoom");_.wheelDelta(Cg);async function N(J,b){return S?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Iu(S,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:W,panOnDrag:D,panOnScrollMode:A,panOnScrollSpeed:H,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:K,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:_e}){V&&!y.isZoomingOrPanning&&k();const me=W&&!fe&&!V;_.clickDistance(_e?1/0:!Jt(pe)||pe<0?0:pe);const ye=me?z1({zoomPanValues:y,noWheelClassName:J,d3Selection:S,d3Zoom:_,panOnScrollMode:A,panOnScrollSpeed:H,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):A1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});S.on("wheel.zoom",ye,{passive:!1});const Ne=D1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=$1({zoomPanValues:y,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:K});_.on("zoom",Pe);const je=O1({zoomPanValues:y,panOnDrag:D,panOnScroll:W,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",je);const Me=F1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:W,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Me),re?S.on("dblclick.zoom",E):S.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function j(J,b,Y){const V=Pu(J),W=_==null?void 0:_.constrain()(V,b,Y);return W&&await N(W),W}async function R(J,b){const Y=Pu(J);return await N(Y,b),Y}function T(J){if(S){const b=Pu(J),Y=S.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(S,b,null,{sync:!0}))}}function B(){const J=S?Kp(S.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return S?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Iu(S,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function U(J,b){return S?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Iu(S,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function ee(J){_==null||_.scaleExtent(J)}function q(J){_==null||_.translateExtent(J)}function te(J){const b=!Jt(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:k,setViewport:R,setViewportConstrained:j,getViewport:B,scaleTo:G,scaleBy:U,setScaleExtent:ee,setTranslateExtent:q,syncViewport:T,setClickDistance:te}}var ki;(function(t){t.Line="line",t.Handle="handle"})(ki||(ki={}));function B1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function jh(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 Jn(t,r){return Math.max(0,r-t)}function er(t,r){return Math.max(0,t-r)}function qs(t,r,o){return Math.max(0,r-t,t-o)}function bh(t,r){return t?!r:r}function V1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:m,isVertical:x}=r,v=m&&x,{xSnapped:_,ySnapped:S}=o,{minWidth:C,maxWidth:E,minHeight:N,maxHeight:I}=l,{x:k,y:j,width:R,height:T,aspectRatio:B}=t;let G=Math.floor(m?_-t.pointerX:0),U=Math.floor(x?S-t.pointerY:0);const ee=R+(g?-G:G),q=T+(y?-U:U),te=-u[0]*R,J=-u[1]*T;let b=qs(ee,C,E),Y=qs(q,N,I);if(d){let D=0,A=0;g&&G<0?D=Jn(k+G+te,d[0][0]):!g&&G>0&&(D=er(k+ee+te,d[1][0])),y&&U<0?A=Jn(j+U+J,d[0][1]):!y&&U>0&&(A=er(j+q+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,A)}if(f){let D=0,A=0;g&&G>0?D=er(k+G,f[0][0]):!g&&G<0&&(D=Jn(k+ee,f[1][0])),y&&U>0?A=er(j+U,f[0][1]):!y&&U<0&&(A=Jn(j+q,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,A)}if(a){if(m){const D=qs(ee/B,N,I)*B;if(b=Math.max(b,D),d){let A=0;!g&&!y||g&&!y&&v?A=er(j+J+ee/B,d[1][1])*B:A=Jn(j+J+(g?G:-G)/B,d[0][1])*B,b=Math.max(b,A)}if(f){let A=0;!g&&!y||g&&!y&&v?A=Jn(j+ee/B,f[1][1])*B:A=er(j+(g?G:-G)/B,f[0][1])*B,b=Math.max(b,A)}}if(x){const D=qs(q*B,C,E)/B;if(Y=Math.max(Y,D),d){let A=0;!g&&!y||y&&!g&&v?A=er(k+q*B+te,d[1][0])/B:A=Jn(k+(y?U:-U)*B+te,d[0][0])/B,Y=Math.max(Y,A)}if(f){let A=0;!g&&!y||y&&!g&&v?A=Jn(k+q*B,f[1][0])/B:A=er(k+(y?U:-U)*B,f[0][0])/B,Y=Math.max(Y,A)}}}U=U+(U<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?ee>q*B?U=(bh(g,y)?-G:G)/B:G=(bh(g,y)?-U:U)*B:m?(U=G/B,y=g):(G=U*B,g=y));const V=g?k+G:k,W=y?j+U:j;return{width:R+(g?-G:G),height:T+(y?-U:U),x:u[0]*G*(g?-1:1)+V,y:u[1]*U*(y?-1:1)+W}}const jg={width:0,height:0,x:0,y:0},U1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function W1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function Y1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=zt(t);let d={controlDirection:jh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:m,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:S,onResizeEnd:C,shouldResize:E}){let N={...jg},I={...U1};d={boundaries:m,resizeDirection:v,keepAspectRatio:x,controlDirection:jh(y)};let k,j=null,R=[],T,B,G,U=!1;const ee=Ap().on("start",q=>{const{nodeLookup:te,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:W}=o();if(k=te.get(r),!k)return;j=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:A}=mo(q.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});N={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},I={...N,pointerX:D,pointerY:A,aspectRatio:N.width/N.height},T=void 0,B=zr(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(T=te.get(k.parentId)),T&&k.extent==="parent"&&(B=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[H,M]of te)if(M.parentId===r&&(R.push({id:H,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=W1(M,k,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(q,{...N})}).on("drag",q=>{const{transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(q.sourceEvent,{transform:te,snapGrid:J,snapToGrid:b,containerBounds:j}),W=[];if(!k)return;const{x:D,y:A,width:H,height:M}=N,L={},ne=k.origin??Y,{width:re,height:ce,x:fe,y:de}=V1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,B,G),K=re!==H,se=ce!==M,pe=fe!==D&&K,_e=de!==A&&se;if(!pe&&!_e&&!K&&!se)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:N.x,L.y=_e?de:N.y,N.x=L.x,N.y=L.y,R.length>0)){const Pe=fe-D,je=de-A;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-H),y:Me.position.y-je+ne[1]*(ce-M)},W.push(Me)}if((K||se)&&(L.width=K&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:N.width,L.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:N.height,N.width=L.width,N.height=L.height),T&&k.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{U&&(C==null||C(q,{...N}),a==null||a({...N}),U=!1)});u.call(ee)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Tu={exports:{}},Ru={},Lu={exports:{}},zu={};/** +`+h.stack}return{value:e,source:n,stack:c,digest:null}}function Wa(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function Ya(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var ky=typeof WeakMap=="function"?WeakMap:Map;function Kd(e,n,i){i=kn(-1,i),i.tag=3,i.payload={element:null};var s=n.value;return i.callback=function(){Ps||(Ps=!0,lu=s),Ya(e,n)},i}function Zd(e,n,i){i=kn(-1,i),i.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var c=n.value;i.payload=function(){return s(c)},i.callback=function(){Ya(e,n)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(i.callback=function(){Ya(e,n),typeof s!="function"&&(Xn===null?Xn=new Set([this]):Xn.add(this));var w=n.stack;this.componentDidCatch(n.value,{componentStack:w!==null?w:""})}),i}function Jd(e,n,i){var s=e.pingCache;if(s===null){s=e.pingCache=new ky;var c=new Set;s.set(n,c)}else c=s.get(n),c===void 0&&(c=new Set,s.set(n,c));c.has(i)||(c.add(i),e=Dy.bind(null,e,n,i),n.then(e,e))}function ef(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function tf(e,n,i,s,c){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=kn(-1,1),n.tag=2,Wn(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=c,e)}var Ey=j.ReactCurrentOwner,kt=!1;function vt(e,n,i,s){n.child=e===null?_d(n,null,i,s):ii(n,e.child,i,s)}function nf(e,n,i,s,c){i=i.render;var h=n.ref;return si(n,c),s=Da(e,n,i,s,h,c),i=$a(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~c,En(e,n,c)):(Be&&i&&wa(n),n.flags|=1,vt(e,n,s,c),n.child)}function rf(e,n,i,s,c){if(e===null){var h=i.type;return typeof h=="function"&&!pu(h)&&h.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=h,of(e,n,h,s,c)):(e=zs(i.type,null,s,n,n.mode,c),e.ref=n.ref,e.return=n,n.child=e)}if(h=e.child,(e.lanes&c)===0){var w=h.memoizedProps;if(i=i.compare,i=i!==null?i:Bi,i(w,s)&&e.ref===n.ref)return En(e,n,c)}return n.flags|=1,e=Kn(h,s),e.ref=n.ref,e.return=n,n.child=e}function of(e,n,i,s,c){if(e!==null){var h=e.memoizedProps;if(Bi(h,s)&&e.ref===n.ref)if(kt=!1,n.pendingProps=s=h,(e.lanes&c)!==0)(e.flags&131072)!==0&&(kt=!0);else return n.lanes=e.lanes,En(e,n,c)}return Xa(e,n,i,s,c)}function sf(e,n,i){var s=n.pendingProps,c=s.children,h=e!==null?e.memoizedState:null;if(s.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},De(ci,Lt),Lt|=i;else{if((i&1073741824)===0)return e=h!==null?h.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,De(ci,Lt),Lt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=h!==null?h.baseLanes:i,De(ci,Lt),Lt|=s}else h!==null?(s=h.baseLanes|i,n.memoizedState=null):s=i,De(ci,Lt),Lt|=s;return vt(e,n,c,i),n.child}function lf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Xa(e,n,i,s,c){var h=St(i)?yr:pt.current;return h=ei(n,h),si(n,c),i=Da(e,n,i,s,h,c),s=$a(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~c,En(e,n,c)):(Be&&s&&wa(n),n.flags|=1,vt(e,n,i,c),n.child)}function af(e,n,i,s,c){if(St(i)){var h=!0;ls(n)}else h=!1;if(si(n,c),n.stateNode===null)Ns(e,n),Qd(n,i,s),Ua(n,i,s,c),s=!0;else if(e===null){var w=n.stateNode,P=n.memoizedProps;w.props=P;var A=w.context,Z=i.contextType;typeof Z=="object"&&Z!==null?Z=Ft(Z):(Z=St(i)?yr:pt.current,Z=ei(n,Z));var oe=i.getDerivedStateFromProps,le=typeof oe=="function"||typeof w.getSnapshotBeforeUpdate=="function";le||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(P!==s||A!==Z)&&qd(n,w,s,Z),Un=!1;var ie=n.memoizedState;w.state=ie,ms(n,s,w,c),A=n.memoizedState,P!==s||ie!==A||_t.current||Un?(typeof oe=="function"&&(Va(n,i,oe,s),A=n.memoizedState),(P=Un||Gd(n,i,P,s,ie,A,Z))?(le||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(n.flags|=4194308)):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=s,n.memoizedState=A),w.props=s,w.state=A,w.context=Z,s=P):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),s=!1)}else{w=n.stateNode,kd(e,n),P=n.memoizedProps,Z=n.type===n.elementType?P:Xt(n.type,P),w.props=Z,le=n.pendingProps,ie=w.context,A=i.contextType,typeof A=="object"&&A!==null?A=Ft(A):(A=St(i)?yr:pt.current,A=ei(n,A));var he=i.getDerivedStateFromProps;(oe=typeof he=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(P!==le||ie!==A)&&qd(n,w,s,A),Un=!1,ie=n.memoizedState,w.state=ie,ms(n,s,w,c);var ve=n.memoizedState;P!==le||ie!==ve||_t.current||Un?(typeof he=="function"&&(Va(n,i,he,s),ve=n.memoizedState),(Z=Un||Gd(n,i,Z,s,ie,ve,A)||!1)?(oe||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(s,ve,A),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(s,ve,A)),typeof w.componentDidUpdate=="function"&&(n.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof w.componentDidUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=1024),n.memoizedProps=s,n.memoizedState=ve),w.props=s,w.state=ve,w.context=A,s=Z):(typeof w.componentDidUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=1024),s=!1)}return Ga(e,n,i,s,h,c)}function Ga(e,n,i,s,c,h){lf(e,n);var w=(n.flags&128)!==0;if(!s&&!w)return c&&fd(n,i,!1),En(e,n,h);s=n.stateNode,Ey.current=n;var P=w&&typeof i.getDerivedStateFromError!="function"?null:s.render();return n.flags|=1,e!==null&&w?(n.child=ii(n,e.child,null,h),n.child=ii(n,null,P,h)):vt(e,n,P,h),n.memoizedState=s.state,c&&fd(n,i,!0),n.child}function uf(e){var n=e.stateNode;n.pendingContext?cd(e,n.pendingContext,n.pendingContext!==n.context):n.context&&cd(e,n.context,!1),Ia(e,n.containerInfo)}function cf(e,n,i,s,c){return ri(),Ea(c),n.flags|=256,vt(e,n,i,s),n.child}var Qa={dehydrated:null,treeContext:null,retryLane:0};function qa(e){return{baseLanes:e,cachePool:null,transitions:null}}function df(e,n,i){var s=n.pendingProps,c=We.current,h=!1,w=(n.flags&128)!==0,P;if((P=w)||(P=e!==null&&e.memoizedState===null?!1:(c&2)!==0),P?(h=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(c|=1),De(We,c&1),e===null)return ka(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(w=s.children,e=s.fallback,h?(s=n.mode,h=n.child,w={mode:"hidden",children:w},(s&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=w):h=Ds(w,s,0,null),e=jr(e,s,i,null),h.return=n,e.return=n,h.sibling=e,n.child=h,n.child.memoizedState=qa(i),n.memoizedState=Qa,e):Ka(n,w));if(c=e.memoizedState,c!==null&&(P=c.dehydrated,P!==null))return Ny(e,n,w,s,P,c,i);if(h){h=s.fallback,w=n.mode,c=e.child,P=c.sibling;var A={mode:"hidden",children:s.children};return(w&1)===0&&n.child!==c?(s=n.child,s.childLanes=0,s.pendingProps=A,n.deletions=null):(s=Kn(c,A),s.subtreeFlags=c.subtreeFlags&14680064),P!==null?h=Kn(P,h):(h=jr(h,w,i,null),h.flags|=2),h.return=n,s.return=n,s.sibling=h,n.child=s,s=h,h=n.child,w=e.child.memoizedState,w=w===null?qa(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},h.memoizedState=w,h.childLanes=e.childLanes&~i,n.memoizedState=Qa,s}return h=e.child,e=h.sibling,s=Kn(h,{mode:"visible",children:s.children}),(n.mode&1)===0&&(s.lanes=i),s.return=n,s.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=s,n.memoizedState=null,s}function Ka(e,n){return n=Ds({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Es(e,n,i,s){return s!==null&&Ea(s),ii(n,e.child,null,i),e=Ka(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Ny(e,n,i,s,c,h,w){if(i)return n.flags&256?(n.flags&=-257,s=Wa(Error(o(422))),Es(e,n,w,s)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(h=s.fallback,c=n.mode,s=Ds({mode:"visible",children:s.children},c,0,null),h=jr(h,c,w,null),h.flags|=2,s.return=n,h.return=n,s.sibling=h,n.child=s,(n.mode&1)!==0&&ii(n,e.child,null,w),n.child.memoizedState=qa(w),n.memoizedState=Qa,h);if((n.mode&1)===0)return Es(e,n,w,null);if(c.data==="$!"){if(s=c.nextSibling&&c.nextSibling.dataset,s)var P=s.dgst;return s=P,h=Error(o(419)),s=Wa(h,s,void 0),Es(e,n,w,s)}if(P=(w&e.childLanes)!==0,kt||P){if(s=lt,s!==null){switch(w&-w){case 4:c=2;break;case 16:c=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:c=32;break;case 536870912:c=268435456;break;default:c=0}c=(c&(s.suspendedLanes|w))!==0?0:c,c!==0&&c!==h.retryLane&&(h.retryLane=c,Sn(e,c),qt(s,e,c,-1))}return hu(),s=Wa(Error(o(421))),Es(e,n,w,s)}return c.data==="$?"?(n.flags|=128,n.child=e.child,n=$y.bind(null,e),c._reactRetry=n,null):(e=h.treeContext,Rt=Fn(c.nextSibling),Tt=n,Be=!0,Yt=null,e!==null&&($t[Ot++]=wn,$t[Ot++]=_n,$t[Ot++]=vr,wn=e.id,_n=e.overflow,vr=n),n=Ka(n,s.children),n.flags|=4096,n)}function ff(e,n,i){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n),ba(e.return,n,i)}function Za(e,n,i,s,c){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:s,tail:i,tailMode:c}:(h.isBackwards=n,h.rendering=null,h.renderingStartTime=0,h.last=s,h.tail=i,h.tailMode=c)}function hf(e,n,i){var s=n.pendingProps,c=s.revealOrder,h=s.tail;if(vt(e,n,s.children,i),s=We.current,(s&2)!==0)s=s&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ff(e,i,n);else if(e.tag===19)ff(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}s&=1}if(De(We,s),(n.mode&1)===0)n.memoizedState=null;else switch(c){case"forwards":for(i=n.child,c=null;i!==null;)e=i.alternate,e!==null&&ys(e)===null&&(c=i),i=i.sibling;i=c,i===null?(c=n.child,n.child=null):(c=i.sibling,i.sibling=null),Za(n,!1,c,i,h);break;case"backwards":for(i=null,c=n.child,n.child=null;c!==null;){if(e=c.alternate,e!==null&&ys(e)===null){n.child=c;break}e=c.sibling,c.sibling=i,i=c,c=e}Za(n,!0,i,null,h);break;case"together":Za(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Ns(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function En(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),kr|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Kn(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Kn(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Cy(e,n,i){switch(n.tag){case 3:uf(n),ri();break;case 5:Cd(n);break;case 1:St(n.type)&&ls(n);break;case 4:Ia(n,n.stateNode.containerInfo);break;case 10:var s=n.type._context,c=n.memoizedProps.value;De(hs,s._currentValue),s._currentValue=c;break;case 13:if(s=n.memoizedState,s!==null)return s.dehydrated!==null?(De(We,We.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?df(e,n,i):(De(We,We.current&1),e=En(e,n,i),e!==null?e.sibling:null);De(We,We.current&1);break;case 19:if(s=(i&n.childLanes)!==0,(e.flags&128)!==0){if(s)return hf(e,n,i);n.flags|=128}if(c=n.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),De(We,We.current),s)break;return null;case 22:case 23:return n.lanes=0,sf(e,n,i)}return En(e,n,i)}var pf,Ja,gf,mf;pf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Ja=function(){},gf=function(e,n,i,s){var c=e.memoizedProps;if(c!==s){e=n.stateNode,_r(un.current);var h=null;switch(i){case"input":c=Ne(e,c),s=Ne(e,s),h=[];break;case"select":c=B({},c,{value:void 0}),s=B({},s,{value:void 0}),h=[];break;case"textarea":c=bt(e,c),s=bt(e,s),h=[];break;default:typeof c.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=is)}or(i,s);var w;i=null;for(Z in c)if(!s.hasOwnProperty(Z)&&c.hasOwnProperty(Z)&&c[Z]!=null)if(Z==="style"){var P=c[Z];for(w in P)P.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else Z!=="dangerouslySetInnerHTML"&&Z!=="children"&&Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&Z!=="autoFocus"&&(a.hasOwnProperty(Z)?h||(h=[]):(h=h||[]).push(Z,null));for(Z in s){var A=s[Z];if(P=c!=null?c[Z]:void 0,s.hasOwnProperty(Z)&&A!==P&&(A!=null||P!=null))if(Z==="style")if(P){for(w in P)!P.hasOwnProperty(w)||A&&A.hasOwnProperty(w)||(i||(i={}),i[w]="");for(w in A)A.hasOwnProperty(w)&&P[w]!==A[w]&&(i||(i={}),i[w]=A[w])}else i||(h||(h=[]),h.push(Z,i)),i=A;else Z==="dangerouslySetInnerHTML"?(A=A?A.__html:void 0,P=P?P.__html:void 0,A!=null&&P!==A&&(h=h||[]).push(Z,A)):Z==="children"?typeof A!="string"&&typeof A!="number"||(h=h||[]).push(Z,""+A):Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&(a.hasOwnProperty(Z)?(A!=null&&Z==="onScroll"&&Oe("scroll",e),h||P===A||(h=[])):(h=h||[]).push(Z,A))}i&&(h=h||[]).push("style",i);var Z=h;(n.updateQueue=Z)&&(n.flags|=4)}},mf=function(e,n,i,s){i!==s&&(n.flags|=4)};function ro(e,n){if(!Be)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var s=null;i!==null;)i.alternate!==null&&(s=i),i=i.sibling;s===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function mt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,s=0;if(n)for(var c=e.child;c!==null;)i|=c.lanes|c.childLanes,s|=c.subtreeFlags&14680064,s|=c.flags&14680064,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)i|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=i,n}function jy(e,n,i){var s=n.pendingProps;switch(_a(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mt(n),null;case 1:return St(n.type)&&ss(),mt(n),null;case 3:return s=n.stateNode,li(),Fe(_t),Fe(pt),La(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(ds(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Yt!==null&&(cu(Yt),Yt=null))),Ja(e,n),mt(n),null;case 5:Ta(n);var c=_r(Zi.current);if(i=n.type,e!==null&&n.stateNode!=null)gf(e,n,i,s,c),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!s){if(n.stateNode===null)throw Error(o(166));return mt(n),null}if(e=_r(un.current),ds(n)){s=n.stateNode,i=n.type;var h=n.memoizedProps;switch(s[an]=n,s[Xi]=h,e=(n.mode&1)!==0,i){case"dialog":Oe("cancel",s),Oe("close",s);break;case"iframe":case"object":case"embed":Oe("load",s);break;case"video":case"audio":for(c=0;c<\/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[an]=n,e[Xi]=s,pf(e,n,!1,!1),n.stateNode=e;e:{switch(w=Pn(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cdi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return mt(n),null}else 2*Ue()-h.renderingStartTime>di&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(mt(n),null);case 22:case 23:return fu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Lt&1073741824)!==0&&(mt(n),n.subtreeFlags&6&&(n.flags|=8192)):mt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(_a(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return li(),Fe(_t),Fe(pt),La(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ta(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ri()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return li(),null;case 10:return ja(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Cs=!1,yt=!1,My=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ui(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Qe(e,n,s)}else i.current=null}function eu(e,n,i){try{i()}catch(s){Qe(e,n,s)}}var yf=!1;function Py(e,n){if(fa=Yo,e=Gc(),ia(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,P=-1,A=-1,Z=0,oe=0,le=e,ie=null;t:for(;;){for(var he;le!==i||c!==0&&le.nodeType!==3||(P=w+c),le!==h||s!==0&&le.nodeType!==3||(A=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)ie=le,le=he;for(;;){if(le===e)break t;if(ie===i&&++Z===c&&(P=w),ie===h&&++oe===s&&(A=w),(he=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=he}i=P===-1||A===-1?null:{start:P,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(ha={focusedElem:e,selectionRange:i},Yo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,Ke=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Xt(n.type,xe),Ke);X.__reactInternalSnapshotBeforeUpdate=O}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){Qe(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=yf,yf=!1,ve}function io(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&&eu(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function tu(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 vf(e){var n=e.alternate;n!==null&&(e.alternate=null,vf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[an],delete n[Xi],delete n[ya],delete n[fy],delete n[hy])),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 xf(e){return e.tag===5||e.tag===3||e.tag===4}function wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 nu(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=is));else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}function ru(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(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}var dt=null,Gt=!1;function Yn(e,n,i){for(i=i.child;i!==null;)_f(e,n,i),i=i.sibling}function _f(e,n,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Hr,i)}catch{}switch(i.tag){case 5:yt||ui(i,n);case 6:var s=dt,c=Gt;dt=null,Yn(e,n,i),dt=s,Gt=c,dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?ma(e.parentNode,i):e.nodeType===1&&ma(e,i),zi(e)):ma(dt,i.stateNode));break;case 4:s=dt,c=Gt,dt=i.stateNode.containerInfo,Gt=!0,Yn(e,n,i),dt=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!yt&&(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)&&eu(i,n,w),c=c.next}while(c!==s)}Yn(e,n,i);break;case 1:if(!yt&&(ui(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Qe(i,n,P)}Yn(e,n,i);break;case 21:Yn(e,n,i);break;case 22:i.mode&1?(yt=(s=yt)||i.memoizedState!==null,Yn(e,n,i),yt=s):Yn(e,n,i);break;default:Yn(e,n,i)}}function Sf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,Gn===null)var s=!1;else{if(e=Gn,Gn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var P=h.deletions;if(P!==null){for(var A=0;AUe()-su?Nr(e,0):ou|=i),Nt(e,n)}function Af(e,n){n===0&&((e.mode&1)===0?n=1:(n=Vr,Vr<<=1,(Vr&130023424)===0&&(Vr=4194304)));var i=xt();e=Sn(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Af(e,i)}function Oy(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),Af(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&pd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ei(n,pt.current);si(n,i),c=Da(null,n,s,e,c,i);var h=$a();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Ua(n,s,e,i),n=Ga(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&wa(n),vt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Xt(s,e),c){case 0:n=Xa(null,n,s,e,i);break e;case 1:n=af(null,n,s,e,i);break e;case 11:n=nf(null,n,s,e,i);break e;case 14:n=rf(null,n,s,Xt(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:Xt(s,c),Xa(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),af(e,n,s,c,i);case 3:e:{if(uf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,kd(e,n),ms(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=ai(Error(o(423)),n),n=cf(e,n,s,i,c);break e}else if(s!==c){c=ai(Error(o(424)),n),n=cf(e,n,s,i,c);break e}else for(Rt=Fn(n.stateNode.containerInfo.firstChild),Tt=n,Be=!0,Yt=null,i=_d(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ri(),s===c){n=En(e,n,i);break e}vt(e,n,s,i)}n=n.child}return n;case 5:return Cd(n),e===null&&ka(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,pa(s,c)?w=null:h!==null&&pa(s,h)&&(n.flags|=32),lf(e,n),vt(e,n,w,i),n.child;case 6:return e===null&&ka(n),null;case 13:return df(e,n,i);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=ii(n,null,s,i):vt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),nf(e,n,s,c,i);case 7:return vt(e,n,n.pendingProps,i),n.child;case 8:return vt(e,n,n.pendingProps.children,i),n.child;case 12:return vt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!_t.current){n=En(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var A=P.firstContext;A!==null;){if(A.context===s){if(h.tag===1){A=kn(-1,i&-i),A.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var oe=Z.pending;oe===null?A.next=A:(A.next=oe.next,oe.next=A),Z.pending=A}}h.lanes|=i,A=h.alternate,A!==null&&(A.lanes|=i),ba(h.return,i,n),P.lanes|=i;break}A=A.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,P=w.alternate,P!==null&&(P.lanes|=i),ba(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}vt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,si(n,i),c=Ft(c),s=s(c),n.flags|=1,vt(e,n,s,i),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),rf(e,n,s,c,i);case 15:return of(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,si(n,i),Qd(n,s,c),Ua(n,s,c,i),Ga(null,n,s,!0,e,i);case 19:return hf(e,n,i);case 22:return sf(e,n,i)}throw Error(o(156,n.tag))};function Df(e,n){return Do(e,n)}function Fy(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 Fy(e,n,i,s)}function pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===Y)return 14}return 2}function Kn(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 zs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")pu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case K:return e=Vt(12,i,n,c|2),e.elementType=K,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Vt(19,i,n,c),e.elementType=b,e.lanes=h,e;case U:return Ds(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case W:w=9;break e;case ee:w=11;break e;case Y: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 jr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function gu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function mu(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 By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function yu(e,n,i,s,c,h,w,P,A){return e=new By(e,n,i,P,A),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},Pa(h),e}function Vy(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(),ku.exports=t0(),ku.exports}var Kf;function n0(){if(Kf)return Us;Kf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function pi(t){return t.replace(/([/\\._:@-])/g,"$1​")}function Dr({className:t,children:r}){return p.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 a0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function u0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function c0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function d0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function f0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function h0({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const p0="modulepreload",g0=function(t,r){return new URL(t,r).href},Zf={},m0=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(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(m=>{if(m=g0(m,l),m in Zf)return;Zf[m]=!0;const x=m.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const S=f[C];if(S.href===m&&(!x||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":p0,x||(k.as="script"),k.crossOrigin="",k.href=m,y&&k.setAttribute("nonce",y),document.head.appendChild(k),x)return new Promise((C,S)=>{k.addEventListener("load",C),k.addEventListener("error",()=>S(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 et(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=v0(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)),eh.hasOwnProperty(r)?{space:eh[r],local:t}:t}function w0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Fu&&r.documentElement.namespaceURI===Fu?r.createElement(t):r.createElementNS(o,t)}}function _0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?_0:w0)(r)}function S0(){}function nc(t){return t==null?S0:function(){return this.querySelector(t)}}function k0(t){typeof t!="function"&&(t=nc(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=I+1);!(R=S[N])&&++N=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function G0(t){t||(t=Q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function q0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function K0(){return Array.from(this)}function Z0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?uv:typeof r=="function"?dv:cv)(t,r,o??"")):vi(this.node(),t)}function vi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function hv(t){return function(){delete this[t]}}function pv(t,r){return function(){this[t]=r}}function gv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function mv(t,r){return arguments.length>1?this.each((r==null?hv:typeof r=="function"?gv:pv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function rc(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=rc(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Uv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Hu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:y,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:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:m}})}Hu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ex(t){return!t.ctrlKey&&!t.button}function tx(){return this.parentNode}function nx(t,r){return r??{x:t.x,y:t.y}}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=ex,r=tx,o=nx,l=rx,a={},u=vl("start","drag","end"),d=0,f,g,y,m,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",S).on("touchmove.drag",E,Jv).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(m||!t.call(this,j,R))){var T=N(this,r.call(this,j,R),j,R,"mouse");T&&(At(j.view).on("mousemove.drag",k,vo).on("mouseup.drag",C,vo),Lp(j.view),Cu(j),y=!1,f=j.clientX,g=j.clientY,T("start",j))}}function k(j){if(mi(j),!y){var R=j.clientX-f,T=j.clientY-g;y=R*R+T*T>x}a.mouse("drag",j)}function C(j){At(j.view).on("mousemove.drag mouseup.drag",null),Ap(j.view,y),mi(j),a.mouse("end",j)}function S(j,R){if(t.call(this,j,R)){var T=j.changedTouches,H=r.call(this,j,R),G=T.length,K,te;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=ox.exec(t))?new jt(r[1],r[2],r[3],1):(r=sx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=lx.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ax.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ux.exec(t))?lh(r[1],r[2]/100,r[3]/100,1):(r=cx.exec(t))?lh(r[1],r[2]/100,r[3]/100,r[4]):th.hasOwnProperty(t)?ih(th[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function ih(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function hx(t){return t instanceof Po||(t=Tr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Bu(t,r,o,l){return arguments.length===1?hx(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}ic(jt,Bu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Pr(this.r),Pr(this.g),Pr(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:oh,formatHex:oh,formatHex8:px,formatRgb:sh,toString:sh}));function oh(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}`}function px(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}${Mr((isNaN(this.opacity)?1:this.opacity)*255)}`}function sh(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Pr(this.r)}, ${Pr(this.g)}, ${Pr(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Pr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Mr(t){return t=Pr(t),(t<16?"0":"")+t.toString(16)}function lh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,o,l)}function $p(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Tr(t)),!t)return new Zt;if(t instanceof Zt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Zt(d,f,g,t.opacity)}function gx(t,r,o,l){return arguments.length===1?$p(t):new Zt(t,r,o,l??1)}function Zt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}ic(Zt,gx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Zt(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 jt(ju(t>=240?t-240:t+120,a,l),ju(t,a,l),ju(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(ah(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${ah(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ah(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function ju(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 oc=t=>()=>t;function mx(t,r){return function(o){return t+o*r}}function yx(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 vx(t){return(t=+t)==1?Op:function(r,o){return o-r?yx(r,o,t):oc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?mx(t,o):oc(isNaN(t)?r:t)}const ul=(function t(r){var o=vx(r);function l(a,u){var d=o((a=Bu(a)).r,(u=Bu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Op(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=g(m),a.opacity=y(m),a+""}}return l.gamma=t,l})(1);function xx(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,g.push({i:d,x:fn(l,a)})),o=bu.lastIndex;return o180?m+=360:m-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:fn(y,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(y,m,x,v){y!==m?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:fn(y,m)}):m&&x.push(a(x)+"skewX("+m+l)}function g(y,m,x,v,_,k){if(y!==x||m!==v){var C=_.push(a(_)+"scale(",null,",",null,")");k.push({i:C-4,x:fn(y,x)},{i:C-2,x:fn(m,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,m){var x=[],v=[];return y=t(y),m=t(m),u(y.translateX,y.translateY,m.translateX,m.translateY,x,v),d(y.rotate,m.rotate,x,v),f(y.skewX,m.skewX,x,v),g(y.scaleX,y.scaleY,m.scaleX,m.scaleY,x,v),y=m=null,function(_){for(var k=-1,C=v.length,S;++k=0&&t._call.call(void 0,r),t=t._next;--xi}function dh(){Rr=(dl=_o.now())+wl,xi=ho=0;try{Lx()}finally{xi=0,zx(),Rr=0}}function Ax(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function zx(){for(var t,r=cl,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:cl=o);po=t,Wu(l)}function Wu(t){if(!xi){ho&&(ho=clearTimeout(ho));var r=t-Rr;r>24?(t<1/0&&(ho=setTimeout(dh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(Ax,Vp)),xi=1,Up(dh))}}function fh(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Dx=vl("start","end","cancel","interrupt"),$x=[],Yp=0,hh=1,Yu=2,rl=3,ph=4,Xu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Ox(t,o,{name:r,index:l,group:a,on:Dx,tween:$x,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function lc(t,r){var o=nn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function pn(t,r){var o=nn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function nn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Ox(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(y){o.state=hh,o.timer.restart(d,o.delay,o.time),o.delay<=y&&d(y-o.delay)}function d(y){var m,x,v,_;if(o.state!==hh)return g();for(m in l)if(_=l[m],_.name===o.name){if(_.state===rl)return fh(d);_.state===ph?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[m]):+mYu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function gw(t,r,o){var l,a,u=pw(r)?lc:pn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function mw(t,r){var o=this._id;return arguments.length<2?nn(this.node(),o).on.on(t):this.each(gw(o,t,r))}function yw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function vw(){return this.on("end.remove",yw(this._id))}function xw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=nc(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Uw(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 jn(t,r,o){this.k=t,this.x=r,this.y=o}jn.prototype={constructor:jn,scale:function(t){return t===1?this:new jn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new jn(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 Sl=new jn(1,0,0);qp.prototype=jn.prototype;function qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Ww(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Yw(){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 gh(){return this.__zoom||Sl}function Xw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Gw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(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 Kp(){var t=Ww,r=Yw,o=Qw,l=Xw,a=Gw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,y=vl("start","zoom","end"),m,x,v,_=500,k=150,C=0,S=10;function E(b){b.property("__zoom",gh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",W).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(b,Y,V,U){var D=b.selection?b.selection():b;D.property("__zoom",gh),b!==D?R(b,Y,V,U):D.interrupt().each(function(){T(this,arguments).event(U).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},E.scaleBy=function(b,Y,V,U){E.scaleTo(b,function(){var D=this.__zoom.k,z=typeof Y=="function"?Y.apply(this,arguments):Y;return D*z},V,U)},E.scaleTo=function(b,Y,V,U){E.transform(b,function(){var D=r.apply(this,arguments),z=this.__zoom,B=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=z.invert(B),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(N(I(z,L),B,M),D,d)},V,U)},E.translateBy=function(b,Y,V,U){E.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,U)},E.translateTo=function(b,Y,V,U,D){E.transform(b,function(){var z=r.apply(this,arguments),B=this.__zoom,M=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Sl.translate(M[0],M[1]).scale(B.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),z,d)},U,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new jn(Y,b.x,b.y)}function N(b,Y,V){var U=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return U===b.x&&D===b.y?b:new jn(b.k,U,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,U){b.on("start.zoom",function(){T(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,B=T(D,z).event(U),M=r.apply(D,z),L=V==null?j(M):typeof V=="function"?V.apply(D,z):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,z):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var q=fe(de),se=ne/q[2];de=new jn(se,L[0]-q[0]*se,L[1]-q[1]*se)}B.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new H(b,Y)}function H(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}H.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=At(this.that).datum();y.call(b,this.that,new Uw(b,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),U=this.__zoom,D=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=Kt(b);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=U.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(U.k===D)return;V.mouse=[z,U.invert(z)],ol(this),V.start()}fo(b),V.wheel=setTimeout(B,k),V.zoom("mouse",o(N(I(U,D),V.mouse[0],V.mouse[1]),V.extent,d));function B(){V.wheel=null,V.end()}}function K(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,U=T(this,Y,!0).event(b),D=At(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),z=Kt(b,V),B=b.clientX,M=b.clientY;Lp(b.view),Mu(b),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function L(re){if(fo(re),!U.moved){var ce=re.clientX-B,fe=re.clientY-M;U.moved=ce*ce+fe*fe>C}U.event(re).zoom("mouse",o(N(U.that.__zoom,U.mouse[0]=Kt(re,V),U.mouse[1]),U.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),Ap(re.view,U.moved),fo(re),U.event(re).end()}}function te(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,U=Kt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(U),z=V.k*(b.shiftKey?.5:2),B=o(N(I(V,z),U,D),r.apply(this,Y),d);fo(b),f>0?At(this).transition().duration(f).call(R,B,U,b):At(this).call(E.transform,B,U,b)}}function W(b,...Y){if(t.apply(this,arguments)){var V=b.touches,U=V.length,D=T(this,Y,b.changedTouches.length===U).event(b),z,B,M,L;for(Mu(b),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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 wi;(function(t){t.Strict="strict",t.Loose="loose"})(wi||(wi={}));var Ir;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Ir||(Ir={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var nr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(nr||(nr={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const mh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,qw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),uc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=rn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Kw=(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):uc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},cc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,y=r.width/a,m=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:k=!0,hidden:C=!1}=v;if(d&&!k||C)continue;const S=_.width??v.width??v.initialWidth??0,E=_.height??v.height??v.initialHeight??0,{x:I,y:N}=v.internals.positionAbsolute,j=sg(f,g,y,m,I,N,S,E),R=S*E,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Zw=(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 Jw(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}=rn(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 e1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Jw(t,d),g=To(f),y=fc(g,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(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y}=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",tn.error005());else{const{width:_,height:k}=rn(f);_&&k&&(x=[[g,y],[g+_,y+k]])}else f&&Ar(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+y],[d.extent[1][0]+g,d.extent[1][1]+y]]);const v=Ar(x)?Lr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-g+(d.measured.width??0)*m[0],y:v.y-y+(d.measured.height??0)*m[1]},positionAbsolute:v}}async function t1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),k=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||k)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),m=Zw(d,g);for(const v of g)f.has(v.id)&&!m.find(k=>k.id===v.id)&&m.push(v);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 _i=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Lr=(t={x:0,y:0},r,o)=>({x:_i(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:_i(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=rn(o),{x:u,y:d}=o.internals.positionAbsolute;return Lr(t,[[u,d],[u+l,d+a]],r)}const yh=(t,r,o)=>to?-_i(Math.abs(t-o),1,r)/r:0,dc=(t,r,o=15,l=40)=>{const a=yh(t.x,l,r.width-l)*o,u=yh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Gu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Gu(t),Gu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*y)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),vh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Si=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function hi(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 n1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=hi(t,o),a=hi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=hi(t.top??t.y??0,o),a=hi(t.bottom??t.y??0,o),u=hi(t.left??t.x??0,r),d=hi(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 r1(t,r,o,l,a,u){const{x:d,y:f}=Si(t,[r,o,l]),{x:g,y}=Si({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-g,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const fc=(t,r,o,l,a,u)=>{const d=n1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,y=Math.min(f,g),m=_i(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*m,k=o/2-v*m,C=r1(t,_,k,m,r,o),S={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.left+S.right,y:k-S.top+S.bottom,zoom:m}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Ar(t){return t!=null&&t!=="parent"}function rn(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 ag(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 ug(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 xh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function i1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const hc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},s1=["INPUT","SELECT","TEXTAREA"];function dg(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:s1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,en=(t,r)=>{var u,d;const o=fg(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)}},wh=(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,...hc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,y=r*.125+u*.375+f*.375+l*.125,m=Math.abs(g-t),x=Math.abs(y-r);return[g,y,m,x]}function qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function _h({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 pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=_h({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[y,m]=_h({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,k]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:m});return[`M${t},${r} C${f},${g} ${y},${m} ${l},${a}`,x,v,_,k]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const u1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,c1=(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)),d1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",tn.error006()),r;const l=o.getEdgeId||u1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},c1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const Sh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},f1=({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 h1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=Sh[r],g=Sh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+g.x*u,y:o.y+g.y*u},x=f1({source:y,sourcePosition:r,target:m}),v=x.x!==0?"x":"y",_=x[v];let k=[],C,S;const E={x:0,y:0},I={x:0,y:0},[,,N,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??y.x+(m.x-y.x)*d,S=a.y??(y.y+m.y)/2):(C=a.x??(y.x+m.x)/2,S=a.y??y.y+(m.y-y.y)*d);const G=[{x:C,y:y.y},{x:C,y:m.y}],K=[{x:y.x,y:S},{x:m.x,y:S}];f[v]===_?k=v==="x"?G:K:k=v==="x"?K:G}else{const G=[{x:y.x,y:m.y}],K=[{x:m.x,y:y.y}];if(v==="x"?k=f.x===_?K:G:k=f.y===_?G:K,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?E[v]=(y[v]>t[v]?-1:1)*Y:I[v]=(m[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=y[b]>m[b],U=y[b]=J?(C=(te.x+W.x)/2,S=k[0].y):(C=k[0].x,S=(te.y+W.y)/2)}const R={x:y.x+E.x,y:y.y+E.y},T={x:m.x+I.x,y:m.y+I.y};return[[t,...R.x!==k[0].x||R.y!==k[0].y?[R]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],o],C,S,N,j]}function p1(t,r,o,l){const a=Math.min(kh(t,r)/2,kh(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 y=t.xo.id===r):t[0])||null}function qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(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(g=>{if(g&&typeof g=="object"){const y=qu(g,r);u.has(y)||(d.push({id:y,color:g.color||o,...g}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,y1=10,pc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},v1={...pc,checkEquality:!0};function gc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function x1(t,r,o){const l=gc(pc,o);for(const a of t.values())if(a.parentId)yc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=Ar(a.extent)?a.extent:l.nodeExtent,f=Lr(u,d,rn(a));a.internals.positionAbsolute=f}}function w1(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 mc(t){return t==="manual"}function Ku(t,r,o,l={}){var m,x;const a=gc(v1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!mc(a.zIndexMode)?yg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const k=Io(v,a.nodeOrigin),C=Ar(v.extent)?v.extent:a.nodeExtent,S=Lr(k,C,rn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:S,handleBounds:w1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&yc(_,r,o,l,u),y||(y=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function _1(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 yc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=gc(pc,l),y=t.parentId,m=r.get(y);if(!m){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&g==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*y1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!mc(g)?yg:0,{x:v,y:_,z:k}=S1(t,m,d,f,x,g),{positionAbsolute:C}=t.internals,S=v!==C.x||_!==C.y;(S||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:S?{x:v,y:_}:C,z:k}})}function vg(t,r,o){const l=Jt(t.zIndex)?t.zIndex:0;return mc(o)?l:l+(t.selected?r:0)}function S1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=rn(t),y=Io(t,o),m=Ar(t.extent)?Lr(y,t.extent,g):y;let x=Lr({x:d+m.x,y:f+m.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function vc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),m=og(y,f.rect);u.set(f.parentId,{expandedRect:m,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var N;const m=g.internals.positionAbsolute,x=rn(g),v=g.origin??l,_=f.x0||k>0||E||I)&&(a.push({id:y,type:"position",position:{x:g.position.x-_+E,y:g.position.y-k+I}}),(N=o.get(y))==null||N.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(x.width0){const _=vc(v,r,o,a);y.push(..._)}return{changes:y,updatedInternals:g}}async function E1({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 jh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;jh("source",g,m,t,a,d),jh("target",g,y,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function bh(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 N1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Pu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[y,m]of r){const x=(d=o.get(y))==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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function C1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function j1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,y={x:0,y:0},m=null,x=!1,v=null,_=!1,k=!1,C=null;function S({noDragClassName:I,handleSelector:N,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:H=0}){v=At(j);function G({x:ee,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:U,nodeOrigin:D,onNodeDrag:z,onSelectionDrag:B,onError:M,updateNodePositions:L}=r();u={x:ee,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Gu(To(f)):null,fe=re&&U?C1({dragItems:f,snapGrid:V,x:ee,y:J}):null;for(const[de,q]of f){if(!b.has(de))continue;let se={x:ee-q.distance.x,y:J-q.distance.y};U&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:Ro(se,V));let pe=null;if(re&&Y&&!q.extent&&ce){const{positionAbsolute:ye}=q.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+q.measured.width-ce.x2+Y[1][0],je=ye.y-ce.y+Y[0][1],Me=ye.y+q.measured.height-ce.y2+Y[1][1];pe=[[Ne,je],[Pe,Me]]}const{position:_e,positionAbsolute:me}=rg({nodeId:de,nextPosition:se,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||q.position.x!==_e.x||q.position.y!==_e.y,q.position=_e,q.internals.positionAbsolute=me}if(k=k||ne,!!ne&&(L(f,!0),C&&(l||z||!T&&B))){const[de,q]=Pu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,q),z==null||z(C,de,q),T||B==null||B(C,q)}}async function K(){if(!m)return;const{transform:ee,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,U]=dc(y,m,b);(V!==0||U!==0)&&(u.x=(u.x??0)-V/ee[2],u.y=(u.y??0)-U/ee[2],await J({x:V,y:U})&&G(u)),d=requestAnimationFrame(K)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:U,snapToGrid:D,selectNodesOnDrag:z,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!z||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&z&&T&&(t==null||t(T));const ne=mo(ee.sourceEvent,{transform:V,snapGrid:U,snapToGrid:D,containerBounds:m});if(u=ne,f=N1(J,Y,ne,T),f.size>0&&(o||B||!T&&M)){const[ce,fe]=Pu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(ee.sourceEvent,f,ce,fe),B==null||B(ee.sourceEvent,ce,fe),T||M==null||M(ee.sourceEvent,fe)}}const W=zp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:U}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,k=!1,C=ee.sourceEvent,b===0&&te(ee),u=mo(ee.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:U,containerBounds:m}),y=en(ee.sourceEvent,m)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:U,nodeLookup:D}=r(),z=mo(ee.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:m});if(C=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,K()),!x){const B=en(ee.sourceEvent,m),M=B.x-y.x,L=B.y-y.y;Math.sqrt(M*M+L*L)>U&&te(ee)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(y=en(ee.sourceEvent,m),G(z))}}).on("end",ee=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(k&&(b(f,!1),k=!1),a||Y||!T&&V){const[U,D]=Pu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,f,U,D),Y==null||Y(ee.sourceEvent,U,D),T||V==null||V(ee.sourceEvent,D)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!I||!bh(J,`.${I}`,j))&&(!N||bh(J,N,j))});v.call(W)}function E(){v==null||v.on(".drag",null)}return{update:S,destroy:E}}function b1(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())pl(a,No(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,o,l){var f,g;let a=[],u=1/0;const d=b1(t,o,r+M1);for(const y of d){const m=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=zr(y,x,x.position,!0),k=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=l.type==="source"?"target":"source";return a.find(m=>m.type===y)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var y,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...zr(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function T1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:m,flowId:x,panBy:v,cancelConnection:_,onConnectStart:k,onConnect:C,onConnectEnd:S,isValidConnection:E=kg,onReconnectEnd:I,updateConnection:N,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:H=1,handleDomNode:G}){const K=cg(t.target);let te=0,W;const{x:ee,y:J}=en(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const U=_g(a,b,l,g,r);if(!U)return;let D=en(t,Y),z=!1,B=null,M=!1,L=null;function ne(){if(!m||!Y)return;const[_e,me]=dc(D,Y,T);v({x:_e,y:me}),te=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:b,position:U.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:zr(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:mh[re.position],toNode:null,pointer:D};function q(){V=!0,N(de),k==null||k(t,{nodeId:a,handleId:l,handleType:b})}H===0&&q();function se(_e){if(!V){const{x:Me,y:tt}=en(_e),Ge=Me-ee,nt=tt-J;if(!(Ge*Ge+nt*nt>H*H))return;q()}if(!R()||!re){pe(_e);return}const me=j();D=en(_e,Y),W=P1(Lo(D,me,!1,[1,1]),o,g,re),z||(ne(),z=!0);const ye=Eg(_e,{handle:W,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:y,flowId:x,nodeLookup:g});L=ye.handleDomNode,B=ye.connection,M=I1(!!W,ye.isValid);const Ne=g.get(a),Pe=Ne?zr(Ne,re,Se.Left,!0):de.from,je={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Si({x:ye.toHandle.x,y:ye.toHandle.y},me):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:mh[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};N(je),de=je}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(W||L)&&B&&M&&(C==null||C(B));const{inProgress:me,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(te),z=!1,M=!1,B=null,L=null,K.removeEventListener("mousemove",se),K.removeEventListener("mouseup",pe),K.removeEventListener("touchmove",se),K.removeEventListener("touchend",pe)}}K.addEventListener("mousemove",se),K.addEventListener("mouseup",pe),K.addEventListener("touchmove",se),K.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:y=kg,nodeLookup:m}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=en(t),C=d.elementFromPoint(_,k),S=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const I=Sg(void 0,S),N=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!N||!I)return E;const H={source:x?N:l,sourceHandle:x?j:a,target:x?l:N,targetHandle:x?a:j};E.connection=H;const K=R&&T&&(o===wi.Strict?x&&I==="source"||!x&&I==="target":N!==l||j!==a);E.isValid=K&&y(H),E.toHandle=_g(N,I,j,m,o,!0)}return E}const Zu={onPointerDown:T1,isValid:Eg};function R1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=At(t);function u({translateExtent:f,width:g,height:y,zoomStep:m=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=N.sourceEvent.ctrlKey&&Co()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=j[2]*Math.pow(2,T*R);r.scaleTo(H)};let C=[0,0];const S=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 j=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*H,y:j[1]-T[1]*H},K=[[0,0],[g,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},K,f)},I=Kp().on("start",S).on("zoom",x?E:null).on("zoom.wheel",v?k:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Kt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),tr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),L1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Tu=(t,r=0,o=L1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function A1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return m=>{if(tr(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const S=Kt(m),E=Cg(m),I=x*Math.pow(2,E);l.scaleTo(o,I,S,m);return}const v=m.deltaMode===1?20:1;let _=a===Ir.Vertical?0:m.deltaX*v,k=a===Ir.Horizontal?0:m.deltaY*v;!Co()&&m.shiftKey&&a!==Ir.Vertical&&(_=m.deltaY*v,k=0),l.translateBy(o,-(_/x)*u,-(k/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(m,C),t.isPanScrolling=!1},150)}}function z1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=tr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function D1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 $1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function O1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function F1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:m,connectionInProgress:x}){return v=>{var E;const _=r||o,k=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(tr(v,`${m}-flow__node`)||tr(v,`${m}-flow__edge`)||tr(v,`${m}-flow__selection`)||tr(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||tr(v,g)&&C||tr(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((E=v.touches)==null?void 0:E.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!k&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const S=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&S}}function H1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const y={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 v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),k=At(t).call(_);j({x:a.x,y:a.y,zoom:_i(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=k.on("wheel.zoom"),S=k.on("dblclick.zoom");_.wheelDelta(Cg);async function E(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:U,panOnDrag:D,panOnScrollMode:z,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:q,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:_e}){V&&!y.isZoomingOrPanning&&N();const me=U&&!fe&&!V;_.clickDistance(_e?1/0:!Jt(pe)||pe<0?0:pe);const ye=me?A1({zoomPanValues:y,noWheelClassName:J,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:B,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):z1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});k.on("wheel.zoom",ye,{passive:!1});const Ne=D1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=$1({zoomPanValues:y,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:q});_.on("zoom",Pe);const je=O1({zoomPanValues:y,panOnDrag:D,panOnScroll:U,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",je);const Me=F1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Me),re?k.on("dblclick.zoom",S):k.on("dblclick.zoom",null)}function N(){_.on("zoom",null)}async function j(J,b,Y){const V=Iu(J),U=_==null?void 0:_.constrain()(V,b,Y);return U&&await E(U),U}async function R(J,b){const Y=Iu(J);return await E(Y,b),Y}function T(J){if(k){const b=Iu(J),Y=k.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(k,b,null,{sync:!0}))}}function H(){const J=k?qp(k.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function K(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function te(J){_==null||_.scaleExtent(J)}function W(J){_==null||_.translateExtent(J)}function ee(J){const b=!Jt(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:N,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:G,scaleBy:K,setScaleExtent:te,setTranslateExtent:W,syncViewport:T,setClickDistance:ee}}var ki;(function(t){t.Line="line",t.Handle="handle"})(ki||(ki={}));function B1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Mh(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 Jn(t,r){return Math.max(0,r-t)}function er(t,r){return Math.max(0,t-r)}function Ks(t,r,o){return Math.max(0,r-t,t-o)}function Ph(t,r){return t?!r:r}function V1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:m,isVertical:x}=r,v=m&&x,{xSnapped:_,ySnapped:k}=o,{minWidth:C,maxWidth:S,minHeight:E,maxHeight:I}=l,{x:N,y:j,width:R,height:T,aspectRatio:H}=t;let G=Math.floor(m?_-t.pointerX:0),K=Math.floor(x?k-t.pointerY:0);const te=R+(g?-G:G),W=T+(y?-K:K),ee=-u[0]*R,J=-u[1]*T;let b=Ks(te,C,S),Y=Ks(W,E,I);if(d){let D=0,z=0;g&&G<0?D=Jn(N+G+ee,d[0][0]):!g&&G>0&&(D=er(N+te+ee,d[1][0])),y&&K<0?z=Jn(j+K+J,d[0][1]):!y&&K>0&&(z=er(j+W+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(f){let D=0,z=0;g&&G>0?D=er(N+G,f[0][0]):!g&&G<0&&(D=Jn(N+te,f[1][0])),y&&K>0?z=er(j+K,f[0][1]):!y&&K<0&&(z=Jn(j+W,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(a){if(m){const D=Ks(te/H,E,I)*H;if(b=Math.max(b,D),d){let z=0;!g&&!y||g&&!y&&v?z=er(j+J+te/H,d[1][1])*H:z=Jn(j+J+(g?G:-G)/H,d[0][1])*H,b=Math.max(b,z)}if(f){let z=0;!g&&!y||g&&!y&&v?z=Jn(j+te/H,f[1][1])*H:z=er(j+(g?G:-G)/H,f[0][1])*H,b=Math.max(b,z)}}if(x){const D=Ks(W*H,C,S)/H;if(Y=Math.max(Y,D),d){let z=0;!g&&!y||y&&!g&&v?z=er(N+W*H+ee,d[1][0])/H:z=Jn(N+(y?K:-K)*H+ee,d[0][0])/H,Y=Math.max(Y,z)}if(f){let z=0;!g&&!y||y&&!g&&v?z=Jn(N+W*H,f[1][0])/H:z=er(N+(y?K:-K)*H,f[0][0])/H,Y=Math.max(Y,z)}}}K=K+(K<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?te>W*H?K=(Ph(g,y)?-G:G)/H:G=(Ph(g,y)?-K:K)*H:m?(K=G/H,y=g):(G=K*H,g=y));const V=g?N+G:N,U=y?j+K:j;return{width:R+(g?-G:G),height:T+(y?-K:K),x:u[0]*G*(g?-1:1)+V,y:u[1]*K*(y?-1:1)+U}}const jg={width:0,height:0,x:0,y:0},U1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function W1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function Y1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=At(t);let d={controlDirection:Mh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:m,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:k,onResizeEnd:C,shouldResize:S}){let E={...jg},I={...U1};d={boundaries:m,resizeDirection:v,keepAspectRatio:x,controlDirection:Mh(y)};let N,j=null,R=[],T,H,G,K=!1;const te=zp().on("start",W=>{const{nodeLookup:ee,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:U}=o();if(N=ee.get(r),!N)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:z}=mo(W.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},I={...E,pointerX:D,pointerY:z,aspectRatio:E.width/E.height},T=void 0,H=Ar(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=ee.get(N.parentId)),T&&N.extent==="parent"&&(H=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[B,M]of ee)if(M.parentId===r&&(R.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=W1(M,N,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(W,{...E})}).on("drag",W=>{const{transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(W.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:b,containerBounds:j}),U=[];if(!N)return;const{x:D,y:z,width:B,height:M}=E,L={},ne=N.origin??Y,{width:re,height:ce,x:fe,y:de}=V1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,H,G),q=re!==B,se=ce!==M,pe=fe!==D&&q,_e=de!==z&&se;if(!pe&&!_e&&!q&&!se)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:E.x,L.y=_e?de:E.y,E.x=L.x,E.y=L.y,R.length>0)){const Pe=fe-D,je=de-z;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-B),y:Me.position.y-je+ne[1]*(ce-M)},U.push(Me)}if((q||se)&&(L.width=q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:E.width,L.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:E.height,E.width=L.width,E.height=L.height),T&&N.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{K&&(C==null||C(W,{...E}),a==null||a({...E}),K=!1)});u.call(te)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Ru={exports:{}},Lu={},Au={exports:{}},zu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -45,7 +45,7 @@ Error generating stack: `+h.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Mh;function X1(){if(Mh)return zu;Mh=1;var t=bo();function r(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,v){var _=v(),S=l({inst:{value:_,getSnapshot:v}}),C=S[0].inst,E=S[1];return u(function(){C.value=_,C.getSnapshot=v,g(C)&&E({inst:C})},[x,_,v]),a(function(){return g(C)&&E({inst:C}),x(function(){g(C)&&E({inst:C})})},[x]),d(_),_}function g(x){var v=x.getSnapshot;x=x.value;try{var _=v();return!o(x,_)}catch{return!0}}function y(x,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:f;return zu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,zu}var Ph;function G1(){return Ph||(Ph=1,Lu.exports=X1()),Lu.exports}/** + */var Ih;function X1(){if(Ih)return zu;Ih=1;var t=bo();function r(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,v){var _=v(),k=l({inst:{value:_,getSnapshot:v}}),C=k[0].inst,S=k[1];return u(function(){C.value=_,C.getSnapshot=v,g(C)&&S({inst:C})},[x,_,v]),a(function(){return g(C)&&S({inst:C}),x(function(){g(C)&&S({inst:C})})},[x]),d(_),_}function g(x){var v=x.getSnapshot;x=x.value;try{var _=v();return!o(x,_)}catch{return!0}}function y(x,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:f;return zu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,zu}var Th;function G1(){return Th||(Th=1,Au.exports=X1()),Au.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -53,10 +53,10 @@ Error generating stack: `+h.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ih;function Q1(){if(Ih)return Ru;Ih=1;var t=bo(),r=G1();function o(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,g=t.useDebugValue;return Ru.useSyncExternalStoreWithSelector=function(y,m,x,v,_){var S=u(null);if(S.current===null){var C={hasValue:!1,value:null};S.current=C}else C=S.current;S=f(function(){function N(T){if(!I){if(I=!0,k=T,T=v(T),_!==void 0&&C.hasValue){var B=C.value;if(_(B,T))return j=B}return j=T}if(B=j,l(k,T))return B;var G=v(T);return _!==void 0&&_(B,G)?(k=T,B):(k=T,j=G)}var I=!1,k,j,R=x===void 0?null:x;return[function(){return N(m())},R===null?void 0:function(){return N(R())}]},[m,x,v,_]);var E=a(y,S[0],S[1]);return d(function(){C.hasValue=!0,C.value=E},[E]),g(E),E},Ru}var Th;function K1(){return Th||(Th=1,Tu.exports=Q1()),Tu.exports}var q1=K1();const Z1=xp(q1),J1={},Rh=t=>{let r;const o=new Set,l=(m,x)=>{const v=typeof m=="function"?m(r):m;if(!Object.is(v,r)){const _=r;r=x??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(S=>S(r,_))}},a=()=>r,g={setState:l,getState:a,getInitialState:()=>y,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(J1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},y=r=t(l,a,g);return g},e_=t=>t?Rh(t):Rh,{useDebugValue:t_}=Zy,{useSyncExternalStoreWithSelector:n_}=Z1,r_=t=>t;function bg(t,r=r_,o){const l=n_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return t_(l),l}const Lh=(t,r)=>{const o=e_(t),l=(a,u=r)=>bg(o,a,u);return Object.assign(l,o),l},i_=(t,r)=>t?Lh(t,r):Lh;function Xe(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}wp();const Cl=$.createContext(null),o_=Cl.Provider,Mg=tn.error001("react");function Re(t,r){const o=$.useContext(Cl);if(o===null)throw new Error(Mg);return bg(o,t,r)}function He(){const t=$.useContext(Cl);if(t===null)throw new Error(Mg);return $.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const zh={display:"none"},s_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pg="react-flow__node-desc",Ig="react-flow__edge-desc",l_="react-flow__aria-live",a_=t=>t.ariaLiveMessage,u_=t=>t.ariaLabelConfig;function c_({rfId:t}){const r=Re(a_);return p.jsx("div",{id:`${l_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:s_,children:r})}function d_({rfId:t,disableKeyboardA11y:r}){const o=Re(u_);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${Pg}-${t}`,style:zh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${Ig}-${t}`,style:zh,children:o["edge.a11yDescription.default"]}),!r&&p.jsx(c_,{rfId:t})]})}const jl=$.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return p.jsx("div",{className:et(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});jl.displayName="Panel";const Ah="https://reactflow.dev?utm_source=attribution";function f_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:p.jsx(jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ah}`,children:p.jsx("a",{href:Ah,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const h_=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}},Zs=t=>t.id;function p_(t,r){return Xe(t.selectedNodes.map(Zs),r.selectedNodes.map(Zs))&&Xe(t.selectedEdges.map(Zs),r.selectedEdges.map(Zs))}function g_({onSelectionChange:t}){const r=He(),{selectedNodes:o,selectedEdges:l}=Re(h_,p_);return $.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const m_=t=>!!t.onSelectionChangeHandlers;function y_({onSelectionChange:t}){const r=Re(m_);return t||r?p.jsx(g_,{onSelectionChange:t}):null}const Tg=[0,0],v_={x:0,y:0,zoom:1},x_=["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"],Dh=[...x_,"rfId"],w_=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}),$h={translateExtent:So,nodeOrigin:Tg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function __(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:g}=Re(w_,Xe),y=He();$.useEffect(()=>(g(t.defaultNodes,t.defaultEdges),()=>{m.current=$h,f()}),[]);const m=$.useRef($h);return $.useEffect(()=>{for(const x of Dh){const v=t[x],_=m.current[x];v!==_&&(typeof t[x]>"u"||(x==="nodes"?r(v):x==="edges"?o(v):x==="minZoom"?l(v):x==="maxZoom"?a(v):x==="translateExtent"?u(v):x==="nodeExtent"?d(v):x==="ariaLabelConfig"?y.setState({ariaLabelConfig:o1(v)}):x==="fitView"?y.setState({fitViewQueued:v}):x==="fitViewOptions"?y.setState({fitViewOptions:v}):y.setState({[x]:v})))}m.current=t},Dh.map(x=>t[x])),null}function Oh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function S_(t){var l;const[r,o]=$.useState(t==="system"?null:t);return $.useEffect(()=>{if(t!=="system"){o(t);return}const a=Oh(),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=Oh())!=null&&l.matches?"dark":"light"}const Fh=typeof document<"u"?document:null;function jo(t=null,r={target:Fh,actInsideInputWithModifier:!0}){const[o,l]=$.useState(!1),a=$.useRef(!1),u=$.useRef(new Set([])),[d,f]=$.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` + */var Rh;function Q1(){if(Rh)return Lu;Rh=1;var t=bo(),r=G1();function o(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,g=t.useDebugValue;return Lu.useSyncExternalStoreWithSelector=function(y,m,x,v,_){var k=u(null);if(k.current===null){var C={hasValue:!1,value:null};k.current=C}else C=k.current;k=f(function(){function E(T){if(!I){if(I=!0,N=T,T=v(T),_!==void 0&&C.hasValue){var H=C.value;if(_(H,T))return j=H}return j=T}if(H=j,l(N,T))return H;var G=v(T);return _!==void 0&&_(H,G)?(N=T,H):(N=T,j=G)}var I=!1,N,j,R=x===void 0?null:x;return[function(){return E(m())},R===null?void 0:function(){return E(R())}]},[m,x,v,_]);var S=a(y,k[0],k[1]);return d(function(){C.hasValue=!0,C.value=S},[S]),g(S),S},Lu}var Lh;function q1(){return Lh||(Lh=1,Ru.exports=Q1()),Ru.exports}var K1=q1();const Z1=xp(K1),J1={},Ah=t=>{let r;const o=new Set,l=(m,x)=>{const v=typeof m=="function"?m(r):m;if(!Object.is(v,r)){const _=r;r=x??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(k=>k(r,_))}},a=()=>r,g={setState:l,getState:a,getInitialState:()=>y,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(J1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},y=r=t(l,a,g);return g},e_=t=>t?Ah(t):Ah,{useDebugValue:t_}=Zy,{useSyncExternalStoreWithSelector:n_}=Z1,r_=t=>t;function bg(t,r=r_,o){const l=n_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return t_(l),l}const zh=(t,r)=>{const o=e_(t),l=(a,u=r)=>bg(o,a,u);return Object.assign(l,o),l},i_=(t,r)=>t?zh(t,r):zh;function Xe(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}wp();const Cl=$.createContext(null),o_=Cl.Provider,Mg=tn.error001("react");function Re(t,r){const o=$.useContext(Cl);if(o===null)throw new Error(Mg);return bg(o,t,r)}function He(){const t=$.useContext(Cl);if(t===null)throw new Error(Mg);return $.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Dh={display:"none"},s_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pg="react-flow__node-desc",Ig="react-flow__edge-desc",l_="react-flow__aria-live",a_=t=>t.ariaLiveMessage,u_=t=>t.ariaLabelConfig;function c_({rfId:t}){const r=Re(a_);return p.jsx("div",{id:`${l_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:s_,children:r})}function d_({rfId:t,disableKeyboardA11y:r}){const o=Re(u_);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${Pg}-${t}`,style:Dh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${Ig}-${t}`,style:Dh,children:o["edge.a11yDescription.default"]}),!r&&p.jsx(c_,{rfId:t})]})}const jl=$.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return p.jsx("div",{className:et(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});jl.displayName="Panel";const $h="https://reactflow.dev?utm_source=attribution";function f_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:p.jsx(jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${$h}`,children:p.jsx("a",{href:$h,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const h_=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}},Zs=t=>t.id;function p_(t,r){return Xe(t.selectedNodes.map(Zs),r.selectedNodes.map(Zs))&&Xe(t.selectedEdges.map(Zs),r.selectedEdges.map(Zs))}function g_({onSelectionChange:t}){const r=He(),{selectedNodes:o,selectedEdges:l}=Re(h_,p_);return $.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const m_=t=>!!t.onSelectionChangeHandlers;function y_({onSelectionChange:t}){const r=Re(m_);return t||r?p.jsx(g_,{onSelectionChange:t}):null}const Tg=[0,0],v_={x:0,y:0,zoom:1},x_=["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"],Oh=[...x_,"rfId"],w_=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}),Fh={translateExtent:So,nodeOrigin:Tg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function __(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:g}=Re(w_,Xe),y=He();$.useEffect(()=>(g(t.defaultNodes,t.defaultEdges),()=>{m.current=Fh,f()}),[]);const m=$.useRef(Fh);return $.useEffect(()=>{for(const x of Oh){const v=t[x],_=m.current[x];v!==_&&(typeof t[x]>"u"||(x==="nodes"?r(v):x==="edges"?o(v):x==="minZoom"?l(v):x==="maxZoom"?a(v):x==="translateExtent"?u(v):x==="nodeExtent"?d(v):x==="ariaLabelConfig"?y.setState({ariaLabelConfig:o1(v)}):x==="fitView"?y.setState({fitViewQueued:v}):x==="fitViewOptions"?y.setState({fitViewOptions:v}):y.setState({[x]:v})))}m.current=t},Oh.map(x=>t[x])),null}function Hh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function S_(t){var l;const[r,o]=$.useState(t==="system"?null:t);return $.useEffect(()=>{if(t!=="system"){o(t);return}const a=Hh(),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=Hh())!=null&&l.matches?"dark":"light"}const Bh=typeof document<"u"?document:null;function jo(t=null,r={target:Bh,actInsideInputWithModifier:!0}){const[o,l]=$.useState(!1),a=$.useRef(!1),u=$.useRef(new Set([])),[d,f]=$.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` `).replace(` `,` +`).split(` -`)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Fh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Bh(_.code,f);if(u.current.add(_[C]),Hh(d,u.current,!1)){const I=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,k=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),l(!0)}},x=_=>{const S=Bh(_.code,f);Hh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[S]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Hh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Bh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=uc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Vh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Uh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Wh=t=>Kw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const zg=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Yh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Ag=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:S}=r.getState();let C=g;for(const N of f)C=typeof N=="function"?N(C):N;let E=Vh({items:C,lookup:v});for(const N of S.values())E=N(E);m&&y(C),E.length>0?x==null||x(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:I,setNodes:k}=r.getState();N&&k(I)})},[]),l=Yh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const S of f)_=typeof S=="function"?S(_):S;m?y(_):x&&x(Vh({items:_,lookup:v}))},[]),u=Yh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(Ag.Provider,{value:d,children:t})}function T_(){const t=$.useContext(Ag);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function mc(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var N,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),S=Wh(x)?x:v.get(x.id),C=S.parentId?ug(S.position,S.measured,S.parentId,v,_):S.position,E={...S,position:C,width:((N=S.measured)==null?void 0:N.width)??S.width,height:((I=S.measured)==null?void 0:I.height)??S.height};return No(E)},y=(x,v,_={replace:!1})=>{d(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&Wh(E)?E:{...C,...E}}return C}))},m=(x,v,_={replace:!1})=>{f(S=>S.map(C=>{if(C.id===x){const E=typeof v=="function"?v(C):v;return _.replace&&M_(E)?E:{...C,...E}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[S,C,E]=_;return{nodes:x.map(N=>({...N})),edges:v.map(N=>({...N})),viewport:{x:S,y:C,zoom:E}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:S,onNodesDelete:C,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:I,onDelete:k,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:S,onBeforeDelete:j}),B=T.length>0,G=R.length>0;if(B){const U=T.map(Uh);E==null||E(T),I(U)}if(G){const U=R.map(Uh);C==null||C(R),N(U)}return(G||B)&&(k==null||k({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const S=mh(x),C=S?x:g(x),E=_!==void 0;return C?(_||r.getState().nodes).filter(N=>{const I=r.getState().nodeLookup.get(N.id);if(I&&!S&&(N.id===x.id||!I.internals.positionAbsolute))return!1;const k=No(E?N:I),j=pl(k,C);return v&&j>0||j>=k.width*k.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=mh(x)?x:g(x);if(!C)return!1;const E=pl(C,v);return _&&E>0||E>=v.width*v.height||E>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,S=>{const C=typeof v=="function"?v(S):v;return _.replace?{...S,data:C}:{...S,data:{...S.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return qw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:S.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Xh=t=>t.selected,L_=typeof window<"u"?window:void 0;function z_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=mc(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Xh),edges:d.filter(Xh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function A_(t){const r=He();$.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=cc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 bl={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Ir.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:S=!0,children:C,noWheelClassName:E,noPanClassName:N,onViewportChange:I,isControlledViewport:k,paneClickDistance:j,selectionOnDrag:R}){const T=He(),B=$.useRef(null),{userSelectionActive:G,lib:U,connectionInProgress:ee}=Re(D_,Xe),q=jo(_),te=$.useRef();A_(B);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),k||T.setState({transform:b})},[I,k]);return $.useEffect(()=>{if(B.current){te.current=H1({domNode:B.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:W=>T.setState(D=>D.paneDragging===W?D:{paneDragging:W}),onPanZoomStart:(W,D)=>{const{onViewportChangeStart:A,onMoveStart:H}=T.getState();H==null||H(W,D),A==null||A(D)},onPanZoom:(W,D)=>{const{onViewportChange:A,onMove:H}=T.getState();H==null||H(W,D),A==null||A(D)},onPanZoomEnd:(W,D)=>{const{onViewportChangeEnd:A,onMoveEnd:H}=T.getState();H==null||H(W,D),A==null||A(D)}});const{x:b,y:Y,zoom:V}=te.current.getViewport();return T.setState({panZoom:te.current,transform:[b,Y,V],domNode:B.current.closest(".react-flow")}),()=>{var W;(W=te.current)==null||W.destroy()}}},[]),$.useEffect(()=>{var b;(b=te.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:q,preventScrolling:S,noPanClassName:N,userSelectionActive:G,noWheelClassName:E,lib:U,onTransformChange:J,connectionInProgress:ee,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,q,S,N,G,E,U,J,ee,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:B,style:bl,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Au=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:S,children:C}){const E=$.useRef(0),N=He(),{userSelectionActive:I,elementsSelectable:k,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),B=k&&(t||I),G=$.useRef(null),U=$.useRef(),ee=$.useRef(new Set),q=$.useRef(new Set),te=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=K=>{if(J.current||te.current||N.getState().connection.inProgress){J.current=!1,te.current=!1;return}y==null||y(K),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},W=K=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){K.preventDefault();return}m==null||m(K)},D=x?K=>x(K):void 0,A=K=>{J.current&&(K.stopPropagation(),J.current=!1)},H=K=>{var Me,tt;if(K.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=N.getState();if(U.current=se==null?void 0:se.getBoundingClientRect(),!U.current)return;const _e=K.target===G.current;if(!_e&&!!K.target.closest(".nokey")||!t||!(d&&_e||r)||K.button!==0||!K.isPrimary)return;(tt=(Me=K.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,K.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(K.nativeEvent,U.current),je=Lo({x:Ne,y:Pe},pe);N.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(K.stopPropagation(),K.preventDefault())};function M(K,se){const{userSelectionRect:pe}=N.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=N.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),Ke={startX:tt.x,startY:tt.y,x:Kut.id)),q.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of ee.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&q.current.add(ht)}}if(!yh(bt,ee.current)){const ut=gi(me,ee.current,!0);Pe(ut)}if(!yh(Dt,q.current)){const ut=gi(ye,q.current);je(ut)}N.setState({userSelectionRect:Ke,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!U.current)return;const[K,se]=ac(b.current,U.current,T);R({x:K,y:se}).then(pe=>{if(!J.current||!pe){E.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),E.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(E.current),E.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=K=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=N.getState();if(!U.current||!se)return;const{x:me,y:ye}=en(K.nativeEvent,U.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(K)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=K=>{var se,pe;if(!B){K.target===G.current&&N.getState().connection.inProgress&&(te.current=!0);return}K.button===0&&((pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),!I&&K.target===G.current&&N.getState().userSelectionRect&&(V==null||V(K)),N.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(K),N.setState({nodesSelectionActive:ee.current.size>0})),ne())},fe=K=>{var se,pe;(pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:B?void 0:Au(V,G),onContextMenu:Au(W,G),onWheel:Au(D,G),onPointerEnter:B?void 0:v,onPointerMove:B?re:_,onPointerUp:ce,onPointerCancel:B?fe:void 0,onPointerDownCapture:B?H:void 0,onClickCapture:B?A:void 0,onPointerLeave:S,ref:G,style:bl,children:[C,p.jsx(F_,{})]})}function Zu({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Zu({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,S=a?u[1]:5,C=o.direction.x*_*o.factor,E=o.direction.y*S*o.factor;for(const[,N]of y){if(!v(N))continue;let I={x:N.internals.positionAbsolute.x+C,y:N.internals.positionAbsolute.y+E};a&&(I=Ro(I,u));const{position:k,positionAbsolute:j}=rg({nodeId:N.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});N.position=k,N.internals.positionAbsolute=j,x.set(N.id,N)}g(x)},[])}const yc=$.createContext(null),U_=yc.Provider;yc.Consumer;const Og=()=>$.useContext(yc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function K_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const S=d||null,C=t==="target",E=He(),N=Og(),{connectOnClick:I,noPanClassName:k,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:B,isPossibleEndHandle:G,connectionInProcess:U,clickConnectionInProcess:ee,valid:q}=Re(Q_(N,S,t),Xe);N||(V=(Y=E.getState()).onError)==null||V.call(Y,"010",tn.error010());const te=W=>{const{defaultEdgeOptions:D,onConnect:A,hasDefaultEdges:H}=E.getState(),M={...D,...W};if(H){const{edges:L,setEdges:ne,onError:re}=E.getState();ne(b_(M,L,{onError:re}))}A==null||A(M),f==null||f(M)},J=W=>{if(!N)return;const D=fg(W.nativeEvent);if(a&&(D&&W.button===0||!D)){const A=E.getState();qu.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:C,handleId:S,nodeId:N,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...H)=>{var M,L;return(L=(M=E.getState()).onConnectEnd)==null?void 0:L.call(M,...H)},updateConnection:A.updateConnection,onConnect:te,isValidConnection:o||((...H)=>{var M,L;return((L=(M=E.getState()).isValidConnection)==null?void 0:L.call(M,...H))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}D?m==null||m(W):x==null||x(W)},b=W=>{const{onClickConnectStart:D,onClickConnectEnd:A,connectionClickStartHandle:H,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=E.getState();if(!N||!H&&!a)return;if(!H){D==null||D(W.nativeEvent,{nodeId:N,handleId:S,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:S}});return}const de=cg(W.target),K=o||L,{connection:se,isValid:pe}=qu.isValid(W.nativeEvent,{handle:{nodeId:N,id:S,type:t},connectionMode:M,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:K,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&te(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,A==null||A(W,_e),E.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":S,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${S}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:R,connectingto:T,valid:q,connectionindicator:l&&(!U||G)&&(U||ee?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(K_));function q_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Gh={input:q_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const S=l.getState().nodes.filter(C=>C.selected);t(_,S)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Qh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:I,zoomOnPinch:k,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:B,panOnDrag:G,autoPanOnSelection:U,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:W,disableKeyboardA11y:D,onViewportChange:A,isControlledViewport:H}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Qh}),re=jo(C,{target:Qh}),ce=re||G,fe=re||j,de=m&&ce!==!0,K=ne||L||de;return z_({deleteKeyCode:g,multiSelectionKeyCode:S}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:I,zoomOnPinch:k,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:B,panOnDrag:!ne&&ce,defaultViewport:ee,translateExtent:q,minZoom:te,maxZoom:J,zoomActivationKeyCode:E,preventScrolling:b,noWheelClassName:V,noPanClassName:W,onViewportChange:A,isControlledViewport:H,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:U,isSelecting:!!K,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:W,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?lc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:S,rfId:C,nodeTypes:E,nodeClickDistance:N,onError:I}){const{node:k,internals:j,isParent:R}=Re(K=>{const se=K.nodeLookup.get(t),pe=K.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=k.type||"default",B=(E==null?void 0:E[T])||Gh[T];B===void 0&&(I==null||I("003",tn.error003(T)),T="default",B=(E==null?void 0:E.default)||Gh.default);const G=!!(k.draggable||f&&typeof k.draggable>"u"),U=!!(k.selectable||g&&typeof k.selectable>"u"),ee=!!(k.connectable||y&&typeof k.connectable>"u"),q=!!(k.focusable||m&&typeof k.focusable>"u"),te=He(),J=ag(k),b=cS({node:k,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:k.hidden||!G,noDragClassName:v,handleSelector:k.dragHandle,nodeId:t,isSelectable:U,nodeClickDistance:N}),V=$g();if(k.hidden)return null;const W=rn(k),D=tS(k),A=U||G||r||o||l||a,H=o?K=>o(K,{...j.userNode}):void 0,M=l?K=>l(K,{...j.userNode}):void 0,L=a?K=>a(K,{...j.userNode}):void 0,ne=u?K=>u(K,{...j.userNode}):void 0,re=d?K=>d(K,{...j.userNode}):void 0,ce=K=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=te.getState();U&&(!se||!G||pe>0)&&Zu({id:t,store:te,nodeRef:b}),r&&r(K,{...j.userNode})},fe=K=>{if(!(dg(K.nativeEvent)||S)){if(Zp.includes(K.key)&&U){const se=K.key==="Escape";Zu({id:t,store:te,unselect:se,nodeRef:b})}else if(G&&k.selected&&Object.prototype.hasOwnProperty.call(gl,K.key)){K.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:K.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[K.key],factor:K.shiftKey?4:1})}}},de=()=>{var Ne;if(S||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:K,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=te.getState();if(!_e)return;lc(new Map([[t,k]]),{x:0,y:0,width:se,height:pe},K,!0).length>0||me(k.position.x+W.width/2,k.position.y+W.height/2,{zoom:K[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},k.className,{selected:k.selected,selectable:U,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:J?"visible":"hidden",...k.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:q?fe:void 0,tabIndex:q?0:void 0,onFocus:q?de:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Pg}-${C}`,"aria-label":k.ariaLabel,...k.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(B,{id:t,data:k.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:k.selected??!1,selectable:U,draggable:G,deletable:k.deletable??!0,isConnectable:ee,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:Y,dragHandle:k.dragHandle,zIndex:j.z,parentId:k.parentId,...W})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:bl,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Kh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Kh,t)?Kh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),S=$.useRef(null);return $.useEffect(()=>{if(S.current){const C=S.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:S,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Ml({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function qh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=qh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=qh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:N})=>{const[I,k,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Ml,{id:R,path:I,labelX:k,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:N})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:S=Se.Top,markerEnd:C,markerStart:E,pathOptions:N,interactionWidth:I})=>{const[k,j,R]=Gu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:S,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Ml,{id:T,path:k,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:E,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),Kg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";Kg.displayName="SmoothStepEdgeInternal";function qg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=qg({isInternal:!1}),Zg=qg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:S,interactionWidth:C})=>{const[E,N,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return p.jsx(Ml,{id:k,path:E,labelX:N,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:S,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,pathOptions:N,interactionWidth:I})=>{const[k,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:N==null?void 0:N.curvature}),T=t.isInternal?void 0:r;return p.jsx(Ml,{id:T,path:k,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:S,markerEnd:C,markerStart:E,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const Zh={default:nm,straight:em,step:Zg,smoothstep:Kg,simplebezier:Xg},Jh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ep="react-flow__edgeupdater";function tp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([ep,`${ep}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const S=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:B,connectionMode:G,connectionRadius:U,lib:ee,onConnectStart:q,cancelConnection:te,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=S.getState(),W=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},A=M=>y==null?void 0:y(o,M),H=(M,L)=>{v(!0),m==null||m(j,o,R.type),q==null||q(M,L)};qu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:U,domNode:B,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:W,edgeUpdaterType:R.type,lib:ee,flowId:b,cancelConnection:te,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=S.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:A,onConnectStart:H,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=S.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),k=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(tp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&p.jsx(tp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:N,onMouseEnter:I,onMouseOut:k,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:S,edgeTypes:C,noPanClassName:E,onError:N,disableKeyboardA11y:I}){let k=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);k=j?{...j,...k}:k;let R=k.type||"default",T=(C==null?void 0:C[R])||Zh[R];T===void 0&&(N==null||N("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||Zh.default);const B=!!(k.focusable||r&&typeof k.focusable>"u"),G=typeof x<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),U=!!(k.selectable||l&&typeof k.selectable>"u"),ee=$.useRef(null),[q,te]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=k.zIndex,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(k.source),Ne=me.nodeLookup.get(k.target);if(!ye||!Ne)return Jh;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:me.connectionMode,onError:N}),je=l1({selected:k.selected,zIndex:k.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||Jh,zIndex:je}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,N]),Xe),ne=$.useMemo(()=>k.markerStart?`url('#${Qu(k.markerStart,S)}')`:void 0,[k.markerStart,S]),re=$.useMemo(()=>k.markerEnd?`url('#${Qu(k.markerEnd,S)}')`:void 0,[k.markerEnd,S]);if(k.hidden||W===null||D===null||A===null||H===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();U&&(Y.setState({nodesSelectionActive:!1}),k.selected&&Pe?(Ne({nodes:[],edges:[k]}),(je=ee.current)==null||je.blur()):ye([t])),a&&a(me,k)},fe=u?me=>{u(me,{...k})}:void 0,de=d?me=>{d(me,{...k})}:void 0,K=f?me=>{f(me,{...k})}:void 0,se=g?me=>{g(me,{...k})}:void 0,pe=y?me=>{y(me,{...k})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&U){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=ee.current)==null||ye.blur(),Ne({edges:[k]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!U&&!a,updating:q,selectable:U}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:K,onMouseMove:se,onMouseLeave:pe,onKeyDown:B?_e:void 0,tabIndex:B?0:void 0,role:k.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":B?`${Ig}-${S}`:void 0,ref:ee,...k.domAttributes,children:[!J&&p.jsx(T,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:U,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),G&&p.jsx(bS,{edge:k,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:W,sourceY:D,targetX:A,targetY:H,sourcePosition:M,targetPosition:L,setUpdateHover:te,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:S,disableKeyboardA11y:C}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:I,onError:k}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:S,rfId:o,onError:k,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),np=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return zg(()=>{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=np(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:np(l)},children:t})}function LS(t){const r=mc(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const zS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function AS(t){const r=Re(zS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let S="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[S]=pg(C);break;case nr.SimpleBezier:[S]=Wg(C);break;case nr.Step:[S]=Gu({...C,borderRadius:0});break;case nr.SmoothStep:[S]=Gu(C);break;default:[S]=mg(C)}return p.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function rp(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:S,connectionLineStyle:C,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:I,selectionOnDrag:k,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:B,deleteKeyCode:G,onlyRenderVisibleElements:U,elementsSelectable:ee,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:W,zoomOnPinch:D,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:K,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:Ke,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return rp(t),rp(r),VS(),LS(o),AS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:K,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:k,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:B,elementsSelectable:ee,zoomOnScroll:W,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:A,panOnScrollSpeed:H,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:q,translateExtent:te,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:Ke,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:U,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:S,component:E,containerStyle:N}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:U,noPanClassName:Dt,noDragClassName:Ke,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),ip=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,S=new Map,C=new Map,E=new Map,N=l??r??[],I=o??t??[],k=m??[0,0],j=x??So;xg(C,E,N);const{nodesInitialized:R}=Ku(I,_,S,{nodeOrigin:k,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const B=To(_,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:G,y:U,zoom:ee}=uc(B,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,U,ee]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:S,edges:N,edgeLookup:E,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:f,fitViewResolver:null,connection:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,S)=>{async function C(){const{nodeLookup:E,panZoom:N,fitViewOptions:I,fitViewResolver:k,width:j,height:R,minZoom:T,maxZoom:B}=S();N&&(await e1({nodes:E,width:j,height:R,panZoom:N,minZoom:T,maxZoom:B},I),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...ip({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:E=>{const{nodeLookup:N,parentLookup:I,nodeOrigin:k,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:B,nodesSelectionActive:G}=S(),{nodesInitialized:U,hasSelectedNodes:ee}=Ku(E,N,I,{nodeOrigin:k,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:B}),q=G&ⅇT&&U?(C(),_({nodes:E,nodesInitialized:U,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):_({nodes:E,nodesInitialized:U,nodesSelectionActive:q})},setEdges:E=>{const{connectionLookup:N,edgeLookup:I}=S();xg(N,I,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:I}=S();I(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:I}=S();I(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:I,parentLookup:k,domNode:j,nodeOrigin:R,nodeExtent:T,debug:B,fitViewQueued:G,zIndexMode:U}=S(),{changes:ee,updatedInternals:q}=k1(E,I,k,j,R,T,U);q&&(x1(I,k,{nodeOrigin:R,nodeExtent:T,zIndexMode:U}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ee==null?void 0:ee.length)>0&&(B&&console.log("React Flow: trigger node changes",ee),N==null||N(ee)))},updateNodePositions:(E,N=!1)=>{const I=[];let k=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:B,onNodesChangeMiddlewareMap:G}=S();for(const[U,ee]of E){const q=j.get(U),te=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(ee!=null&&ee.position)),J={id:U,type:"position",position:te?{x:Math.max(0,ee.position.x),y:Math.max(0,ee.position.y)}:ee.position,dragging:N};if(q&&T.inProgress&&T.fromNode.id===q.id){const b=Ar(q,T.fromHandle,Se.Left,!0);B({...T,from:b})}te&&q.parentId&&I.push({id:U,parentId:q.parentId,rect:{...ee.internals.positionAbsolute,width:ee.measured.width??0,height:ee.measured.height??0}}),k.push(J)}if(I.length>0){const{parentLookup:U,nodeOrigin:ee}=S(),q=gc(I,j,U,ee);k.push(...q)}for(const U of G.values())k=U(k);R(k)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:I,nodes:k,hasDefaultNodes:j,debug:R}=S();if(E!=null&&E.length){if(j){const T=N_(E,k);I(T)}R&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:I,edges:k,hasDefaultEdges:j,debug:R}=S();if(E!=null&&E.length){if(j){const T=C_(E,k);I(T)}R&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:I,nodeLookup:k,triggerNodeChanges:j,triggerEdgeChanges:R}=S();if(N){const T=E.map(B=>br(B,!0));j(T);return}j(gi(k,new Set([...E]),!0)),R(gi(I))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:I,nodeLookup:k,triggerNodeChanges:j,triggerEdgeChanges:R}=S();if(N){const T=E.map(B=>br(B,!0));R(T);return}R(gi(I,new Set([...E]))),j(gi(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:I,nodes:k,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=S(),B=E||k,G=N||I,U=[];for(const q of B){if(!q.selected)continue;const te=j.get(q.id);te&&(te.selected=!1),U.push(br(q.id,!1))}const ee=[];for(const q of G)q.selected&&ee.push(br(q.id,!1));R(U),T(ee)},setMinZoom:E=>{const{panZoom:N,maxZoom:I}=S();N==null||N.setScaleExtent([E,I]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:I}=S();N==null||N.setScaleExtent([I,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=S().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:I,triggerEdgeChanges:k,elementsSelectable:j}=S();if(!j)return;const R=N.reduce((B,G)=>G.selected?[...B,br(G.id,!1)]:B,[]),T=E.reduce((B,G)=>G.selected?[...B,br(G.id,!1)]:B,[]);I(R),k(T)},setNodeExtent:E=>{const{nodes:N,nodeLookup:I,parentLookup:k,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:B}=S();E[0][0]===T[0][0]&&E[0][1]===T[0][1]&&E[1][0]===T[1][0]&&E[1][1]===T[1][1]||(Ku(N,I,k,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:I,height:k,panZoom:j,translateExtent:R}=S();return E1({delta:E,panZoom:j,transform:N,translateExtent:R,width:I,height:k})},setCenter:async(E,N,I)=>{const{width:k,height:j,maxZoom:R,panZoom:T}=S();if(!T)return!1;const B=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:k/2-E*B,y:j/2-N*B,zoom:B},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...ip()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[S]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:S,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:S,onConnectEnd:C,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:I,onNodeMouseMove:k,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:U,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:W,onSelectionStart:D,onSelectionEnd:A,onBeforeDelete:H,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:K=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:Ke=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:$r=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Ir.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:Ae,onEdgeMouseLeave:Rn,reconnectRadius:Or=10,onNodesChange:ji,onEdgesChange:Il,noDragClassName:Tl="nodrag",noWheelClassName:Rl="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Ll,attributionPosition:zo,proOptions:Ao,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Al,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Fr,isValidConnection:Dl,onError:Ho,style:Hr,id:Mt,nodeDragThreshold:$l,connectionDragThreshold:Pt,viewport:Ol,onViewportChange:Fl,width:Hl,height:Br,colorMode:Vr="light",debug:hr,onScroll:yn,ariaLabelConfig:Bl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Vr),Vl=$.useCallback(Ur=>{Ur.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Ur)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Vl,style:{...Hr,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Hl,height:Br,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:Ke,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:S,onConnectEnd:C,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Il,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Ll,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:ee,onEdgesDelete:q,onDelete:te,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:U,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:Ke,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Al,autoPanSpeed:Fo,onError:Ho,connectionRadius:Fr,isValidConnection:Dl,selectNodesOnDrag:je,nodeDragThreshold:$l,connectionDragThreshold:Pt,onBeforeDelete:H,debug:hr,ariaLabelConfig:Bl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:k,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:K,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:$r,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:W,onSelectionStart:D,onSelectionEnd:A,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:Ae,onEdgeMouseLeave:Rn,reconnectRadius:Or,defaultMarkerColor:gn,noDragClassName:Tl,noWheelClassName:Rl,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Ol,onViewportChange:Fl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:Ao,position:zo}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var KS=Lg(QS);function qS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),S=l||JS[r],C=r===rr.Dots,E=r===rr.Cross,N=Array.isArray(o)?o:[o,o],I=[N[0]*v[2]||1,N[1]*v[2]||1],k=S*v[2],j=Array.isArray(u)?u:[u,u],R=E?[k,k]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],B=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...bl,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:B,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:k/2,className:m}):p.jsx(qS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const S=He(),{isInteractive:C,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:k,zoomOut:j,fitView:R}=mc(),T=()=>{k(),u==null||u()},B=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},U=()=>{S.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},ee=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",ee,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:N,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:B,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:E,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:U,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:S,backgroundColor:C}=u||{},E=d||S||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:E,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?N=>_(N,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),Du=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=Du(r),y=Du(t),m=Du(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(S=>{const C=S.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const E=C.internals.userNode,{x:N,y:I}=C.internals.positionAbsolute,{width:k,height:j}=rn(E);return{node:E,x:N,y:I,width:k,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},op=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>op(t.viewBB,r.viewBB)&&op(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:S,pannable:C=!1,zoomable:E=!1,ariaLabel:N,inversePan:I,zoomStep:k=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:B,viewBB:G,rfId:U,panZoom:ee,translateExtent:q,flowWidth:te,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,W=B.width/Y,D=B.height/V,A=Math.max(W,D),H=A*Y,M=A*V,L=j*A,ne=B.x-(H-B.width)/2-L,re=B.y-(M-B.height)/2-L,ce=H+L*2,fe=M+L*2,de=`${_k}-${U}`,K=$.useRef(0),se=$.useRef();K.current=A,$.useEffect(()=>{if(T.current&&ee)return se.current=R1({domNode:T.current,panZoom:ee,getTransform:()=>R.getState().transform,getViewScale:()=>K.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[ee]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:q,width:te,height:J,inversePan:I,pannable:C,zoomStep:k,zoomable:E})},[C,E,I,k,q,te,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=S?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;S(ye,Pe)},[]):void 0,me=N??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*A: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:S,onResizeStart:C,onResize:E,onResizeEnd:N}){const I=Og(),k=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,B=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),U=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!k))return G.current||(G.current=Y1({domNode:R.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:q,transform:te,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(q,te)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),W=[],D={x:q.x,y:q.y},A=b.get(k);if(A&&A.expandParent&&A.parentId){const H=A.origin??V,M=q.width??A.measured.width??0,L=q.height??A.measured.height??0,ne={id:A.id,parentId:A.parentId,rect:{width:M,height:L,...ug({x:q.x??A.position.x,y:q.y??A.position.y},{width:M,height:L},A.parentId,b,H)}},re=gc([ne],b,Y,V);W.push(...re),D.x=q.x?Math.max(H[0]*M,q.x):void 0,D.y=q.y?Math.max(H[1]*L,q.y):void 0}if(D.x!==void 0&&D.y!==void 0){const H={id:k,type:"position",position:{...D}};W.push(H)}if(q.width!==void 0&&q.height!==void 0){const M={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(M)}for(const H of te){const M={...H,type:"position"};W.push(M)}J(W)},onEnd:({width:q,height:te})=>{const J={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:te}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:U,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:E,onResizeEnd:N,shouldResize:S}),()=>{var q;(q=G.current)==null||q.destroy()}},[U,f,g,y,m,x,C,E,N,S]);const ee=U.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...ee,o,l]),ref:R,style:{...a,scale:B,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"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 Pl(t){return Ck[t]??8}function jk(t){const r=new Map;for(const l of t){const a=Pl(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 cm=90,bk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),sp={"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"},Mk=Math.PI*(3-Math.sqrt(5)),dm=220,Pk=26,Ik={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 fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function cE(t){return sp[t]?sp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Tk(t){return t>=cm?"3d":"2d"}function Rk(t){return t>=cm?"overview":"full"}function Lk(t,r,o=1){const l=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!bk.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?Lk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&d.size){l=l.filter(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function dE(t){const r=new Map;for(const l of t){const a=Pl(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Pk*Math.sqrt(f+1),y=f*Mk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function fE(t){const r=new Map;for(const o of t){const l=Pl(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*dm,count:l}))}const el=16,Ak=12,Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),$k=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),lp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Ok={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},ap=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],up=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Fk=new Set(["looks_idempotent_on_pk"]),Hk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Bk(t){return lp[t]?lp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Vk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Dk.has(t.type)&&a.push("sink"),$k.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>cp(x,l,x.src)),y=f.slice(0,el).map(x=>cp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ik[Pl(t.type)]??"other",purpose:Bk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Uk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function cp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Uk(t){const r=[...ap.filter(a=>a in t),...Object.keys(t).filter(a=>!ap.includes(a)&&!up.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||up.has(a)||Hk.has(a))continue;l.add(a);const u=Wk(a,t[a]);u!=null&&o.push({key:a,label:Ok[a]??yo(a),value:u})}return o}function Wk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Fk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Ak),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const Yk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-D8Vppi7Z.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Xk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Gk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:t.name}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const Qk={load:Gk},dp=180,fp=56,Kk=new Set(["django","react","stitch","arch"]);function qk(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=jk(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:dp,height:fp,style:{width:dp,height:fp}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Xk[f.weight]||"var(--edge-cheap)";return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:f.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:10}}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Vk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:pi(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:pi(a.context)}):null,a.file?p.jsx("div",{className:"file",children:pi(a.file)}):null,p.jsx("div",{className:"muted",children:pi(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:pi(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:pi(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function $u({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(Kk)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??Tk(t.length),S=d??Rk(t.length),C=$.useMemo(()=>zk(t,r,{detail:S,families:g,focusId:o,neighborhoodOnly:m&&_==="3d"}),[t,r,S,g,o,m,_]),E=$.useMemo(()=>new Map(C.nodes.map(U=>[U.id,U])),[C.nodes]),N=o?E.get(o)??null:null,{rfNodes:I,rfEdges:k}=$.useMemo(()=>{const U=qk(C.nodes,C.edges,o);return v&&(U.rfEdges=U.rfEdges.map(ee=>({...ee,animated:!1}))),U},[C.nodes,C.edges,o,v]);$.useEffect(()=>{o&&!E.has(o)&&l(null)},[E,o]);const j=(U,ee)=>{l(ee.id)},R=()=>{l(null),x(!1)},T=U=>{y(ee=>{const q=new Set(ee);if(q.has(U)){if(q.size===1)return ee;q.delete(U)}else q.add(U);return q})},B=$.useMemo(()=>{const U=new Set;for(const ee of t)U.add(fm(ee.type));return U},[t]),G=t.length-C.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:S==="overview"?"active":"","aria-pressed":S==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:S==="full"?"active":"","aria-pressed":S==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(U=>B.has(U)).map(U=>p.jsx("button",{type:"button","data-testid":`graph-family-${U}`,className:g.has(U)?"active":"","aria-pressed":g.has(U),onClick:()=>T(U),children:U},U))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(U=>!U),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[C.nodes.length," nodes · ",C.edges.length," edges",G?` · ${G} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Yk,{nodes:C.nodes,edges:C.edges,selectedId:o,neighborIds:C.neighborIds,onSelect:U=>{l(U),U||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]}):p.jsxs(sm,{children:[p.jsxs(KS,{nodes:I,edges:k,nodeTypes:Qk,fitView:!0,fitViewOptions:{padding:.2,maxZoom:1.15},minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:j,onPaneClick:R,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:R}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],Zk=["preset","branch","tag","commit"];function Jk(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function eE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function tE(t){return Zk.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function nE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,S]=$.useState(0),C=$.useMemo(()=>{const j=Jk(u);return x===null?j:eE(j,x)},[u,x]),E=$.useMemo(()=>tE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{S(0)},[x,y]);const N=()=>{m(!1),v(null)},I=j=>{r(j.value),N()},k=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}S(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;S(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),N())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:k}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?N():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:E.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:nE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>S(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function rE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),S=$.useRef(0),C=async k=>{const j=S.current+1;S.current=j,v(!0);try{const R=await Ve.browse(k);if(S.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(S.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{S.current===j&&v(!1)}};$.useEffect(()=>{var k,j;C(t),(k=_.current)==null||k.focus(),(j=_.current)==null||j.select()},[t]);const E=f||(l==null?void 0:l.path)||u,N=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>d(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(k=>{const j=f===k.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>g(k.path),onDoubleClick:()=>void C(k.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:E,children:E}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],iE="obsidian",hm="loadpath.theme";function oE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(oE(t))return t}catch{}return iE}function sE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=sE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function lE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[S,C]=$.useState("review"),[E,N]=$.useState(""),[I,k]=$.useState(""),[j,R]=$.useState(""),[T,B]=$.useState({}),[G,U]=$.useState([]),[ee,q]=$.useState([]),[te,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,W]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,A]=$.useState(""),[H,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[K,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,k(F)};$.useEffect(()=>{Ve.settings().then(B).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(N("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),Ke=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(W(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);q(be.repos),(ae=be.user)!=null&&ae.login&&B($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{q([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||q([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!K)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(K.flow_id);if(F)return;if($e.status==="complete"){se(null);const Ae=await Ve.settings();B(Ae),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||K.interval,5)*1e3);return}se(null),N($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),N($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(K.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[K,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const Ae=await Ve.oauthStatus();if(F)return;if(Ae.bitbucket.connected){_e(!1);const Rn=await Ve.settings();B(Rn),R(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),N("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(Ae){if(F)return;_e(!1),N(Ae instanceof Error?Ae.message:String(Ae))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Tracing load path…"),Ge(o),Ke(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){N(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){N(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){N(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){N(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!te||!V){N("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,te,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){N(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,te);U(F.pull_requests);const ae=ee.find(be=>be.slug.toLowerCase()===te.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{N("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){N(F instanceof Error?F.message:String(F))}},$r=async()=>{N("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),N(F instanceof Error?F.message:String(F))}},ir=async F=>{N("");try{B(await Ve.oauthDisconnect(F)),b===F&&q([]),R(`Disconnected ${F}`)}catch(ae){N(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(Ae=>({path:Ae.path,name:Ae.name}))}:be;try{B(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(Ae){N(Ae instanceof Error?Ae.message:String(Ae))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);A(F.note)}catch(F){N(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){N(""),R("");return}const $e=yp.find(Ae=>Ae.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[S,m,g]),sr=$.useMemo(()=>S==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[S,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:H,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>Ke(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>Ke(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[E?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:E}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>N(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(aE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx($u,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(uE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx($u,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":S==="review","data-testid":"graph-mode-review",className:S==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":S==="architecture","data-testid":"graph-mode-architecture",className:S==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx($u,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,te,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:ee.length?"Search your repos":"owner/repo",value:te,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:ee.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),ee.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[ee.length," ",b," repositor",ee.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{Ke(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=ee.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:H===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!K||!T.github_oauth_ready,onClick:()=>void Ni(),children:K?"Waiting for GitHub…":"Sign in with GitHub"})})]}),K?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:K.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void $r(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(rE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function aE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,S,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(E=>p.jsx("li",{children:E},E))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(E=>p.jsx("span",{className:"chip",children:yo(E)},E))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((E,N)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[N+1,". ",E.path]}),p.jsx("div",{className:"why",children:E.why})]},E.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:E.title})," — ",E.files.join(", ")]},E.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(E=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${E.severity}`,children:E.severity}),E.message]},E.rule+E.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(E=>p.jsx("div",{className:"residual muted",children:E},E))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(E=>E.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(E=>p.jsx("div",{className:"muted",children:E},E)),(((S=t.evolution)==null?void 0:S.hotspots)||[]).filter(E=>E.commits).slice(0,6).map(E=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:E.path})," — ",E.commits," commits, bus factor ",E.bus_factor]},E.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function uE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(lE,{})}));export{Ik as L,fE as a,cE as c,p as j,dE as l,$ as r,yl as t}; +`)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Bh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var S,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Uh(_.code,f);if(u.current.add(_[C]),Vh(d,u.current,!1)){const I=((E=(S=_.composedPath)==null?void 0:S.call(_))==null?void 0:E[0])||_.target,N=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&_.preventDefault(),l(!0)}},x=_=>{const k=Uh(_.code,f);Vh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Vh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Uh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=fc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Wh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Yh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Xh=t=>qw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const Ag=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Gh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return Ag(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const zg=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let C=g;for(const E of f)C=typeof E=="function"?E(C):E;let S=Wh({items:C,lookup:v});for(const E of k.values())S=E(S);m&&y(C),S.length>0?x==null||x(S):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:N}=r.getState();E&&N(I)})},[]),l=Gh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const k of f)_=typeof k=="function"?k(_):k;m?y(_):x&&x(Wh({items:_,lookup:v}))},[]),u=Gh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(zg.Provider,{value:d,children:t})}function T_(){const t=$.useContext(zg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function bl(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var E,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),k=Xh(x)?x:v.get(x.id),C=k.parentId?ug(k.position,k.measured,k.parentId,v,_):k.position,S={...k,position:C,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((I=k.measured)==null?void 0:I.height)??k.height};return No(S)},y=(x,v,_={replace:!1})=>{d(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&Xh(S)?S:{...C,...S}}return C}))},m=(x,v,_={replace:!1})=>{f(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&M_(S)?S:{...C,...S}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[k,C,S]=_;return{nodes:x.map(E=>({...E})),edges:v.map(E=>({...E})),viewport:{x:k,y:C,zoom:S}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:k,onNodesDelete:C,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:N,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:k,onBeforeDelete:j}),H=T.length>0,G=R.length>0;if(H){const K=T.map(Yh);S==null||S(T),I(K)}if(G){const K=R.map(Yh);C==null||C(R),E(K)}return(G||H)&&(N==null||N({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const k=vh(x),C=k?x:g(x),S=_!==void 0;return C?(_||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!k&&(E.id===x.id||!I.internals.positionAbsolute))return!1;const N=No(S?E:I),j=pl(N,C);return v&&j>0||j>=N.width*N.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=vh(x)?x:g(x);if(!C)return!1;const S=pl(C,v);return _&&S>0||S>=v.width*v.height||S>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Kw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Qh=t=>t.selected,L_=typeof window<"u"?window:void 0;function A_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=bl(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Qh),edges:d.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function z_(t){const r=He();$.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=hc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Ir.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:k=!0,children:C,noWheelClassName:S,noPanClassName:E,onViewportChange:I,isControlledViewport:N,paneClickDistance:j,selectionOnDrag:R}){const T=He(),H=$.useRef(null),{userSelectionActive:G,lib:K,connectionInProgress:te}=Re(D_,Xe),W=jo(_),ee=$.useRef();z_(H);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),N||T.setState({transform:b})},[I,N]);return $.useEffect(()=>{if(H.current){ee.current=H1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:U=>T.setState(D=>D.paneDragging===U?D:{paneDragging:U}),onPanZoomStart:(U,D)=>{const{onViewportChangeStart:z,onMoveStart:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoom:(U,D)=>{const{onViewportChange:z,onMove:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoomEnd:(U,D)=>{const{onViewportChangeEnd:z,onMoveEnd:B}=T.getState();B==null||B(U,D),z==null||z(D)}});const{x:b,y:Y,zoom:V}=ee.current.getViewport();return T.setState({panZoom:ee.current,transform:[b,Y,V],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=ee.current)==null||U.destroy()}}},[]),$.useEffect(()=>{var b;(b=ee.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:W,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:S,lib:K,onTransformChange:J,connectionInProgress:te,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,W,k,E,G,S,K,J,te,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:H,style:Ml,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Du=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:k,children:C}){const S=$.useRef(0),E=He(),{userSelectionActive:I,elementsSelectable:N,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),H=N&&(t||I),G=$.useRef(null),K=$.useRef(),te=$.useRef(new Set),W=$.useRef(new Set),ee=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){q.preventDefault();return}m==null||m(q)},D=x?q=>x(q):void 0,z=q=>{J.current&&(q.stopPropagation(),J.current=!1)},B=q=>{var Me,tt;if(q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=E.getState();if(K.current=se==null?void 0:se.getBoundingClientRect(),!K.current)return;const _e=q.target===G.current;if(!_e&&!!q.target.closest(".nokey")||!t||!(d&&_e||r)||q.button!==0||!q.isPrimary)return;(tt=(Me=q.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,q.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(q.nativeEvent,K.current),je=Lo({x:Ne,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(q.stopPropagation(),q.preventDefault())};function M(q,se){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=E.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),qe={startX:tt.x,startY:tt.y,x:qut.id)),W.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of te.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&W.current.add(ht)}}if(!xh(bt,te.current)){const ut=gi(me,te.current,!0);Pe(ut)}if(!xh(Dt,W.current)){const ut=gi(ye,W.current);je(ut)}E.setState({userSelectionRect:qe,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!K.current)return;const[q,se]=dc(b.current,K.current,T);R({x:q,y:se}).then(pe=>{if(!J.current||!pe){S.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),S.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=q=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=E.getState();if(!K.current||!se)return;const{x:me,y:ye}=en(q.nativeEvent,K.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(q)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=q=>{var se,pe;if(!H){q.target===G.current&&E.getState().connection.inProgress&&(ee.current=!0);return}q.button===0&&((pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),!I&&q.target===G.current&&E.getState().userSelectionRect&&(V==null||V(q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(q),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=q=>{var se,pe;(pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:H?void 0:Du(V,G),onContextMenu:Du(U,G),onWheel:Du(D,G),onPointerEnter:H?void 0:v,onPointerMove:H?re:_,onPointerUp:ce,onPointerCancel:H?fe:void 0,onPointerDownCapture:H?B:void 0,onClickCapture:H?z:void 0,onPointerLeave:k,ref:G,style:Ml,children:[C,p.jsx(F_,{})]})}function Ju({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Ju({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,k=a?u[1]:5,C=o.direction.x*_*o.factor,S=o.direction.y*k*o.factor;for(const[,E]of y){if(!v(E))continue;let I={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+S};a&&(I=Ro(I,u));const{position:N,positionAbsolute:j}=rg({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});E.position=N,E.internals.positionAbsolute=j,x.set(E.id,E)}g(x)},[])}const xc=$.createContext(null),U_=xc.Provider;xc.Consumer;const Og=()=>$.useContext(xc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function q_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const k=d||null,C=t==="target",S=He(),E=Og(),{connectOnClick:I,noPanClassName:N,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:H,isPossibleEndHandle:G,connectionInProcess:K,clickConnectionInProcess:te,valid:W}=Re(Q_(E,k,t),Xe);E||(V=(Y=S.getState()).onError)==null||V.call(Y,"010",tn.error010());const ee=U=>{const{defaultEdgeOptions:D,onConnect:z,hasDefaultEdges:B}=S.getState(),M={...D,...U};if(B){const{edges:L,setEdges:ne,onError:re}=S.getState();ne(b_(M,L,{onError:re}))}z==null||z(M),f==null||f(M)},J=U=>{if(!E)return;const D=fg(U.nativeEvent);if(a&&(D&&U.button===0||!D)){const z=S.getState();Zu.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:C,handleId:k,nodeId:E,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...B)=>{var M,L;return(L=(M=S.getState()).onConnectEnd)==null?void 0:L.call(M,...B)},updateConnection:z.updateConnection,onConnect:ee,isValidConnection:o||((...B)=>{var M,L;return((L=(M=S.getState()).isValidConnection)==null?void 0:L.call(M,...B))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}D?m==null||m(U):x==null||x(U)},b=U=>{const{onClickConnectStart:D,onClickConnectEnd:z,connectionClickStartHandle:B,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=S.getState();if(!E||!B&&!a)return;if(!B){D==null||D(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const de=cg(U.target),q=o||L,{connection:se,isValid:pe}=Zu.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:q,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&ee(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,z==null||z(U,_e),S.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${k}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:R,connectingto:T,valid:W,connectionindicator:l&&(!K||G)&&(K||te?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(q_));function K_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qh={input:K_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const k=l.getState().nodes.filter(C=>C.selected);t(_,k)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Kh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:G,autoPanOnSelection:K,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:U,disableKeyboardA11y:D,onViewportChange:z,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Kh}),re=jo(C,{target:Kh}),ce=re||G,fe=re||j,de=m&&ce!==!0,q=ne||L||de;return A_({deleteKeyCode:g,multiSelectionKeyCode:k}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:!ne&&ce,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,zoomActivationKeyCode:S,preventScrolling:b,noWheelClassName:V,noPanClassName:U,onViewportChange:z,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:K,isSelecting:!!q,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:U,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?cc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:k,rfId:C,nodeTypes:S,nodeClickDistance:E,onError:I}){const{node:N,internals:j,isParent:R}=Re(q=>{const se=q.nodeLookup.get(t),pe=q.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=N.type||"default",H=(S==null?void 0:S[T])||qh[T];H===void 0&&(I==null||I("003",tn.error003(T)),T="default",H=(S==null?void 0:S.default)||qh.default);const G=!!(N.draggable||f&&typeof N.draggable>"u"),K=!!(N.selectable||g&&typeof N.selectable>"u"),te=!!(N.connectable||y&&typeof N.connectable>"u"),W=!!(N.focusable||m&&typeof N.focusable>"u"),ee=He(),J=ag(N),b=cS({node:N,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:N.hidden||!G,noDragClassName:v,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),V=$g();if(N.hidden)return null;const U=rn(N),D=tS(N),z=K||G||r||o||l||a,B=o?q=>o(q,{...j.userNode}):void 0,M=l?q=>l(q,{...j.userNode}):void 0,L=a?q=>a(q,{...j.userNode}):void 0,ne=u?q=>u(q,{...j.userNode}):void 0,re=d?q=>d(q,{...j.userNode}):void 0,ce=q=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();K&&(!se||!G||pe>0)&&Ju({id:t,store:ee,nodeRef:b}),r&&r(q,{...j.userNode})},fe=q=>{if(!(dg(q.nativeEvent)||k)){if(Zp.includes(q.key)&&K){const se=q.key==="Escape";Ju({id:t,store:ee,unselect:se,nodeRef:b})}else if(G&&N.selected&&Object.prototype.hasOwnProperty.call(gl,q.key)){q.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[q.key],factor:q.shiftKey?4:1})}}},de=()=>{var Ne;if(k||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:q,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=ee.getState();if(!_e)return;cc(new Map([[t,N]]),{x:0,y:0,width:se,height:pe},q,!0).length>0||me(N.position.x+U.width/2,N.position.y+U.height/2,{zoom:q[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},N.className,{selected:N.selected,selectable:K,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:J?"visible":"hidden",...N.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:W?fe:void 0,tabIndex:W?0:void 0,onFocus:W?de:void 0,role:N.ariaRole??(W?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Pg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(H,{id:t,data:N.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:G,deletable:N.deletable??!0,isConnectable:te,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:j.z,parentId:N.parentId,...U})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:Ml,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Zh,t)?Zh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),k=$.useRef(null);return $.useEffect(()=>{if(k.current){const C=k.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Pl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function Jh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Jh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=Jh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})=>{const[I,N,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Pl,{id:R,path:I,labelX:N,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=Qu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:S,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),qg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";qg.displayName="SmoothStepEdgeInternal";function Kg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})=>{const[S,E,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return p.jsx(Pl,{id:N,path:S,labelX:E,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const ep={default:nm,straight:em,step:Zg,smoothstep:qg,simplebezier:Xg},tp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,np="react-flow__edgeupdater";function rp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([np,`${np}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const k=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:H,connectionMode:G,connectionRadius:K,lib:te,onConnectStart:W,cancelConnection:ee,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=k.getState(),U=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},z=M=>y==null?void 0:y(o,M),B=(M,L)=>{v(!0),m==null||m(j,o,R.type),W==null||W(M,L)};Zu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:K,domNode:H,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:U,edgeUpdaterType:R.type,lib:te,flowId:b,cancelConnection:ee,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=k.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:z,onConnectStart:B,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=k.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),N=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(rp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:S,onMouseEnter:I,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&p.jsx(rp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:N,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:k,edgeTypes:C,noPanClassName:S,onError:E,disableKeyboardA11y:I}){let N=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);N=j?{...j,...N}:N;let R=N.type||"default",T=(C==null?void 0:C[R])||ep[R];T===void 0&&(E==null||E("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||ep.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),G=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),te=$.useRef(null),[W,ee]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=N.zIndex,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(N.source),Ne=me.nodeLookup.get(N.target);if(!ye||!Ne)return tp;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:me.connectionMode,onError:E}),je=l1({selected:N.selected,zIndex:N.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||tp,zIndex:je}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Xe),ne=$.useMemo(()=>N.markerStart?`url('#${qu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),re=$.useMemo(()=>N.markerEnd?`url('#${qu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||U===null||D===null||z===null||B===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();K&&(Y.setState({nodesSelectionActive:!1}),N.selected&&Pe?(Ne({nodes:[],edges:[N]}),(je=te.current)==null||je.blur()):ye([t])),a&&a(me,N)},fe=u?me=>{u(me,{...N})}:void 0,de=d?me=>{d(me,{...N})}:void 0,q=f?me=>{f(me,{...N})}:void 0,se=g?me=>{g(me,{...N})}:void 0,pe=y?me=>{y(me,{...N})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&K){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=te.current)==null||ye.blur(),Ne({edges:[N]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,N.className,S,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:W,selectable:K}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:q,onMouseMove:se,onMouseLeave:pe,onKeyDown:H?_e: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?`${Ig}-${k}`:void 0,ref:te,...N.domAttributes,children:[!J&&p.jsx(T,{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:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),G&&p.jsx(bS,{edge:N,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,setUpdateHover:ee,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:C}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,onError:N}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),ip=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return Ag(()=>{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=ip(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ip(l)},children:t})}function LS(t){const r=bl(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const AS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function zS(t){const r=Re(AS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let k="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[k]=pg(C);break;case nr.SimpleBezier:[k]=Wg(C);break;case nr.Step:[k]=Qu({...C,borderRadius:0});break;case nr.SmoothStep:[k]=Qu(C);break;default:[k]=mg(C)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function op(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:C,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,deleteKeyCode:G,onlyRenderVisibleElements:K,elementsSelectable:te,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:U,zoomOnPinch:D,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return op(t),op(r),VS(),LS(o),zS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:K,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:k,component:S,containerStyle:E}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:qe,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),sp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,k=new Map,C=new Map,S=new Map,E=l??r??[],I=o??t??[],N=m??[0,0],j=x??So;xg(C,S,E);const{nodesInitialized:R}=Ku(I,_,k,{nodeOrigin:N,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const H=To(_,{filter:W=>!!((W.width||W.initialWidth)&&(W.height||W.initialHeight))}),{x:G,y:K,zoom:te}=fc(H,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,K,te]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:S,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.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:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,k)=>{async function C(){const{nodeLookup:S,panZoom:E,fitViewOptions:I,fitViewResolver:N,width:j,height:R,minZoom:T,maxZoom:H}=k();E&&(await e1({nodes:S,width:j,height:R,panZoom:E,minZoom:T,maxZoom:H},I),N==null||N.resolve(!0),_({fitViewResolver:null}))}return{...sp({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:S=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:H,nodesSelectionActive:G}=k(),{nodesInitialized:K,hasSelectedNodes:te}=Ku(S,E,I,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:H}),W=G&&te;T&&K?(C(),_({nodes:S,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:W})):_({nodes:S,nodesInitialized:K,nodesSelectionActive:W})},setEdges:S=>{const{connectionLookup:E,edgeLookup:I}=k();xg(E,I,S),_({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:I}=k();I(S),_({hasDefaultNodes:!0})}if(E){const{setEdges:I}=k();I(E),_({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:N,domNode:j,nodeOrigin:R,nodeExtent:T,debug:H,fitViewQueued:G,zIndexMode:K}=k(),{changes:te,updatedInternals:W}=k1(S,I,N,j,R,T,K);W&&(x1(I,N,{nodeOrigin:R,nodeExtent:T,zIndexMode:K}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(H&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(S,E=!1)=>{const I=[];let N=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:H,onNodesChangeMiddlewareMap:G}=k();for(const[K,te]of S){const W=j.get(K),ee=!!(W!=null&&W.expandParent&&(W!=null&&W.parentId)&&(te!=null&&te.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(W&&T.inProgress&&T.fromNode.id===W.id){const b=zr(W,T.fromHandle,Se.Left,!0);H({...T,from:b})}ee&&W.parentId&&I.push({id:K,parentId:W.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),N.push(J)}if(I.length>0){const{parentLookup:K,nodeOrigin:te}=k(),W=vc(I,j,K,te);N.push(...W)}for(const K of G.values())N=K(N);R(N)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:I,nodes:N,hasDefaultNodes:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=N_(S,N);I(T)}R&&console.log("React Flow: trigger node changes",S),E==null||E(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:I,edges:N,hasDefaultEdges:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=C_(S,N);I(T)}R&&console.log("React Flow: trigger edge changes",S),E==null||E(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));j(T);return}j(gi(N,new Set([...S]),!0)),R(gi(I))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));R(T);return}R(gi(I,new Set([...S]))),j(gi(N,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:I,nodes:N,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=k(),H=S||N,G=E||I,K=[];for(const W of H){if(!W.selected)continue;const ee=j.get(W.id);ee&&(ee.selected=!1),K.push(br(W.id,!1))}const te=[];for(const W of G)W.selected&&te.push(br(W.id,!1));R(K),T(te)},setMinZoom:S=>{const{panZoom:E,maxZoom:I}=k();E==null||E.setScaleExtent([S,I]),_({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:I}=k();E==null||E.setScaleExtent([I,S]),_({maxZoom:S})},setTranslateExtent:S=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(S),_({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:N,elementsSelectable:j}=k();if(!j)return;const R=E.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]),T=S.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]);I(R),N(T)},setNodeExtent:S=>{const{nodes:E,nodeLookup:I,parentLookup:N,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:H}=k();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(Ku(E,I,N,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:H}),_({nodeExtent:S}))},panBy:S=>{const{transform:E,width:I,height:N,panZoom:j,translateExtent:R}=k();return E1({delta:S,panZoom:j,transform:E,translateExtent:R,width:I,height:N})},setCenter:async(S,E,I)=>{const{width:N,height:j,maxZoom:R,panZoom:T}=k();if(!T)return!1;const H=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:N/2-S*H,y:j/2-E*H,zoom:H},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:S=>{_({connection:S})},reset:()=>_({...sp()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[k]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:k,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onBeforeDelete:B,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:q=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:qe=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:$r=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Ir.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Or=10,onNodesChange:ji,onEdgesChange:Tl,noDragClassName:Rl="nodrag",noWheelClassName:Ll="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Al,attributionPosition:Ao,proOptions:zo,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Fr,isValidConnection:$l,onError:Ho,style:Hr,id:Mt,nodeDragThreshold:Ol,connectionDragThreshold:Pt,viewport:Fl,onViewportChange:Hl,width:Bl,height:Br,colorMode:Vr="light",debug:hr,onScroll:yn,ariaLabelConfig:Vl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Vr),Ul=$.useCallback(Ur=>{Ur.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Ur)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Ul,style:{...Hr,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Bl,height:Br,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:qe,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Tl,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Al,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:qe,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanSpeed:Fo,onError:Ho,connectionRadius:Fr,isValidConnection:$l,selectNodesOnDrag:je,nodeDragThreshold:Ol,connectionDragThreshold:Pt,onBeforeDelete:B,debug:hr,ariaLabelConfig:Vl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:q,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:$r,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Or,defaultMarkerColor:gn,noDragClassName:Rl,noWheelClassName:Ll,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Fl,onViewportChange:Hl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:zo,position:Ao}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var qS=Lg(QS);function KS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),k=l||JS[r],C=r===rr.Dots,S=r===rr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*v[2]||1,E[1]*v[2]||1],N=k*v[2],j=Array.isArray(u)?u:[u,u],R=S?[N,N]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],H=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...Ml,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:H,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:N/2,className:m}):p.jsx(KS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const k=He(),{isInteractive:C,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:N,zoomOut:j,fitView:R}=bl(),T=()=>{N(),u==null||u()},H=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},K=()=>{k.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},te=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",te,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:H,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:S,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:K,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:k,backgroundColor:C}=u||{},S=d||k||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?E=>_(E,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),$u=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=$u(r),y=$u(t),m=$u(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(k=>{const C=k.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const S=C.internals.userNode,{x:E,y:I}=C.internals.positionAbsolute,{width:N,height:j}=rn(S);return{node:S,x:E,y:I,width:N,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},lp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>lp(t.viewBB,r.viewBB)&&lp(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:k,pannable:C=!1,zoomable:S=!1,ariaLabel:E,inversePan:I,zoomStep:N=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:H,viewBB:G,rfId:K,panZoom:te,translateExtent:W,flowWidth:ee,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,U=H.width/Y,D=H.height/V,z=Math.max(U,D),B=z*Y,M=z*V,L=j*z,ne=H.x-(B-H.width)/2-L,re=H.y-(M-H.height)/2-L,ce=B+L*2,fe=M+L*2,de=`${_k}-${K}`,q=$.useRef(0),se=$.useRef();q.current=z,$.useEffect(()=>{if(T.current&&te)return se.current=R1({domNode:T.current,panZoom:te,getTransform:()=>R.getState().transform,getViewScale:()=>q.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[te]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:W,width:ee,height:J,inversePan:I,pannable:C,zoomStep:N,zoomable:S})},[C,S,I,N,W,ee,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=k?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;k(ye,Pe)},[]):void 0,me=E??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*z: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:k,onResizeStart:C,onResize:S,onResizeEnd:E}){const I=Og(),N=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,H=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),K=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!N))return G.current||(G.current=Y1({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(W,ee)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),U=[],D={x:W.x,y:W.y},z=b.get(N);if(z&&z.expandParent&&z.parentId){const B=z.origin??V,M=W.width??z.measured.width??0,L=W.height??z.measured.height??0,ne={id:z.id,parentId:z.parentId,rect:{width:M,height:L,...ug({x:W.x??z.position.x,y:W.y??z.position.y},{width:M,height:L},z.parentId,b,B)}},re=vc([ne],b,Y,V);U.push(...re),D.x=W.x?Math.max(B[0]*M,W.x):void 0,D.y=W.y?Math.max(B[1]*L,W.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:N,type:"position",position:{...D}};U.push(B)}if(W.width!==void 0&&W.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:W.width,height:W.height}};U.push(M)}for(const B of ee){const M={...B,type:"position"};U.push(M)}J(U)},onEnd:({width:W,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:W,height:ee}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:K,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:S,onResizeEnd:E,shouldResize:k}),()=>{var W;(W=G.current)==null||W.destroy()}},[K,f,g,y,m,x,C,S,E,k]);const te=K.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...te,o,l]),ref:R,style:{...a,scale:H,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"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 Il(t){return Ck[t]??8}const ec=208,tc=64,jk=88,bk=28,Mk=8;function Pk(t){if(!t.length)return Number.NaN;const r=[...t].sort((l,a)=>l-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Ik(t,r=[]){const o=new Map;if(!t.length)return o;const l=new Map;for(const C of t){const S=Il(C.type),E=l.get(S)??[];E.push(C),l.set(S,E)}const u=[...l.keys()].sort((C,S)=>C-S).map(C=>[...l.get(C)??[]].sort((S,E)=>S.name.localeCompare(E.name)||S.id.localeCompare(E.id))),d=new Set(t.map(C=>C.id)),f=new Map,g=new Map;for(const C of t)f.set(C.id,[]),g.set(C.id,[]);for(const C of r)!d.has(C.src)||!d.has(C.dst)||C.src===C.dst||(g.get(C.src).push(C.dst),f.get(C.dst).push(C.src));const y=new Map,m=()=>{for(const C of u)C.forEach((S,E)=>y.set(S.id,E))};m();const x=(C,S)=>{const E=C.map((I,N)=>{const j=S(I.id).map(T=>y.get(T)).filter(T=>T!==void 0),R=Pk(j);return{n:I,bary:Number.isNaN(R)?N:R,name:I.name,id:I.id}});return E.sort((I,N)=>I.bary-N.bary||I.name.localeCompare(N.name)||I.id.localeCompare(N.id)),E.map(I=>I.n)};for(let C=0;Cf.get(E)??[]),m();for(let S=u.length-2;S>=0;S--)u[S]=x(u[S],E=>g.get(E)??[]),m()}const v=ec+jk,_=tc+bk,k=Math.max(...u.map(C=>C.length),1);return u.forEach((C,S)=>{const E=(k-C.length)*_/2;C.forEach((I,N)=>{o.set(I.id,{x:S*v,y:E+N*_})})}),o}const cm=90,Tk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ap={"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"},Rk=Math.PI*(3-Math.sqrt(5)),dm=220,Lk=26,Ak={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 fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function mE(t){return ap[t]?ap[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function zk(t){return t>=cm?"3d":"2d"}function Dk(t){return t>=cm?"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(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!Tk.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(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function yE(t){const r=new Map;for(const l of t){const a=Il(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Lk*Math.sqrt(f+1),y=f*Rk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function vE(t){const r=new Map;for(const o of t){const l=Il(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*dm,count:l}))}const el=16,Fk=12,Hk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),Bk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),up={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Vk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},cp=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],dp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Uk=new Set(["looks_idempotent_on_pk"]),Wk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Yk(t){return up[t]?up[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Xk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Hk.has(t.type)&&a.push("sink"),Bk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>fp(x,l,x.src)),y=f.slice(0,el).map(x=>fp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ak[Il(t.type)]??"other",purpose:Yk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Gk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function fp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Gk(t){const r=[...cp.filter(a=>a in t),...Object.keys(t).filter(a=>!cp.includes(a)&&!dp.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||dp.has(a)||Wk.has(a))continue;l.add(a);const u=Qk(a,t[a]);u!=null&&o.push({key:a,label:Vk[a]??yo(a),value:u})}return o}function Qk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Uk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Fk),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const qk=new Set,Kk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-D0mq8ReQ.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Zk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Jk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:t.name}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const eE={load:Jk},tE=new Set(["django","react","stitch","arch"]);function nE({topologyKey:t}){const{fitView:r}=bl();return $.useEffect(()=>{let o=0;const l=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(o)}},[r,t]),null}function rE(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=Ik(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:ec,height:tc,style:{width:ec,height:tc}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Zk[f.weight]||"var(--edge-cheap)",y=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:y?f.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Xk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:pi(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:pi(a.context)}):null,a.file?p.jsx("div",{className:"file",children:pi(a.file)}):null,p.jsx("div",{className:"muted",children:pi(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:pi(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:pi(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function Ou({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(tE)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??zk(t.length),k=d??Dk(t.length),C=m&&_==="3d"?o:null,S=$.useMemo(()=>Ok(t,r,{detail:k,families:g,focusId:C,neighborhoodOnly:!!C}),[t,r,k,g,C]),E=$.useMemo(()=>`${S.nodes.map(W=>W.id).join("\0")}|${S.edges.map(W=>W.id).join("\0")}`,[S.nodes,S.edges]),I=$.useMemo(()=>new Map(S.nodes.map(W=>[W.id,W])),[S.nodes]),N=o?I.get(o)??null:null,{rfNodes:j,rfEdges:R}=$.useMemo(()=>{const W=rE(S.nodes,S.edges,o);return v&&(W.rfEdges=W.rfEdges.map(ee=>({...ee,animated:!1}))),W},[S.nodes,S.edges,o,v]);$.useEffect(()=>{o&&!I.has(o)&&l(null)},[I,o]);const T=(W,ee)=>{l(ee.id)},H=()=>{l(null),x(!1)},G=W=>{y(ee=>{const J=new Set(ee);if(J.has(W)){if(J.size===1)return ee;J.delete(W)}else J.add(W);return J})},K=$.useMemo(()=>{const W=new Set;for(const ee of t)W.add(fm(ee.type));return W},[t]),te=t.length-S.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:k==="overview"?"active":"","aria-pressed":k==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:k==="full"?"active":"","aria-pressed":k==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(W=>K.has(W)).map(W=>p.jsx("button",{type:"button","data-testid":`graph-family-${W}`,className:g.has(W)?"active":"","aria-pressed":g.has(W),onClick:()=>G(W),children:W},W))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(W=>!W),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[S.nodes.length," nodes · ",S.edges.length," edges",te?` · ${te} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Kk,{nodes:S.nodes,edges:S.edges,selectedId:o,neighborIds:C?S.neighborIds:qk,onSelect:W=>{l(W),W||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]}):p.jsxs(sm,{children:[p.jsxs(qS,{nodes:j,edges:R,nodeTypes:eE,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:H,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(nE,{topologyKey:E}),p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],iE=["preset","branch","tag","commit"];function oE(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function sE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function lE(t){return iE.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function aE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,k]=$.useState(0),C=$.useMemo(()=>{const j=oE(u);return x===null?j:sE(j,x)},[u,x]),S=$.useMemo(()=>lE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{k(0)},[x,y]);const E=()=>{m(!1),v(null)},I=j=>{r(j.value),E()},N=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}k(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),E())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:N}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?E():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:S.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):S.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:aE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:H=>H.preventDefault(),onMouseEnter:()=>k(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function uE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),k=$.useRef(0),C=async N=>{const j=k.current+1;k.current=j,v(!0);try{const R=await Ve.browse(N);if(k.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(k.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{k.current===j&&v(!1)}};$.useEffect(()=>{var N,j;C(t),(N=_.current)==null||N.focus(),(j=_.current)==null||j.select()},[t]);const S=f||(l==null?void 0:l.path)||u,E=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:N=>d(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(N=>{const j=f===N.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void C(N.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:S,children:S}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!S,onClick:()=>S&&r(S),children:["Use ",E]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],cE="obsidian",hm="loadpath.theme";function dE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(dE(t))return t}catch{}return cE}function fE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=fE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function hE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[k,C]=$.useState("review"),[S,E]=$.useState(""),[I,N]=$.useState(""),[j,R]=$.useState(""),[T,H]=$.useState({}),[G,K]=$.useState([]),[te,W]=$.useState([]),[ee,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,U]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,z]=$.useState(""),[B,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[q,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,N(F)};$.useEffect(()=>{Ve.settings().then(H).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),qe=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(U(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);W(be.repos),(ae=be.user)!=null&&ae.login&&H($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{W([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||W([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!q)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(q.flow_id);if(F)return;if($e.status==="complete"){se(null);const ze=await Ve.settings();H(ze),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||q.interval,5)*1e3);return}se(null),E($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),E($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(q.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[q,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const ze=await Ve.oauthStatus();if(F)return;if(ze.bitbucket.connected){_e(!1);const Rn=await Ve.settings();H(Rn),R(ze.bitbucket.user?`Signed in to Bitbucket as ${ze.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),E("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(ze){if(F)return;_e(!1),E(ze instanceof Error?ze.message:String(ze))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Tracing load path…"),Ge(o),qe(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){E(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){E(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){E(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!ee||!V){E("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,ee,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){E(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,ee);K(F.pull_requests);const ae=te.find(be=>be.slug.toLowerCase()===ee.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{E("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){E(F instanceof Error?F.message:String(F))}},$r=async()=>{E("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),E(F instanceof Error?F.message:String(F))}},ir=async F=>{E("");try{H(await Ve.oauthDisconnect(F)),b===F&&W([]),R(`Disconnected ${F}`)}catch(ae){E(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(ze=>({path:ze.path,name:ze.name}))}:be;try{H(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(ze){E(ze instanceof Error?ze.message:String(ze))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);z(F.note)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){E(""),R("");return}const $e=yp.find(ze=>ze.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,m,g]),sr=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[k,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:B,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>qe(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>qe(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[S?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:S}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(pE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx(Ou,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(gE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx(Ou,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx(Ou,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,ee,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:te.length?"Search your repos":"owner/repo",value:ee,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:te.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),te.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[te.length," ",b," repositor",te.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{qe(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=te.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:B===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!q||!T.github_oauth_ready,onClick:()=>void Ni(),children:q?"Waiting for GitHub…":"Sign in with GitHub"})})]}),q?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:q.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void $r(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(uE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function pE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,k,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(S=>p.jsx("li",{children:S},S))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(S=>p.jsx("span",{className:"chip",children:yo(S)},S))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((S,E)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[E+1,". ",S.path]}),p.jsx("div",{className:"why",children:S.why})]},S.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:S.title})," — ",S.files.join(", ")]},S.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(S=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${S.severity}`,children:S.severity}),S.message]},S.rule+S.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(S=>p.jsx("div",{className:"residual muted",children:S},S))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(S=>S.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(S=>p.jsx("div",{className:"muted",children:S},S)),(((k=t.evolution)==null?void 0:k.hotspots)||[]).filter(S=>S.commits).slice(0,6).map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:S.path})," — ",S.commits," commits, bus factor ",S.bus_factor]},S.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function gE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(hE,{})}));export{Ak as L,vE as a,mE as c,p as j,yE as l,$ as r,yl as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index c0aa913..779cfb5 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/ui/src/ImpactGraph.test.ts b/ui/src/ImpactGraph.test.ts index c030f8d..11097c9 100644 --- a/ui/src/ImpactGraph.test.ts +++ b/ui/src/ImpactGraph.test.ts @@ -27,5 +27,24 @@ describe("toReactFlowElements", () => { type: "smoothstep", }); expect(rfEdges[0].markerEnd).toMatchObject({ type: MarkerType.ArrowClosed }); + expect(rfEdges[0].label).toBeUndefined(); + }); + + it("labels only edges incident to the selected node", () => { + const extraNodes: GraphNode[] = [ + ...nodes, + { id: "model", type: "django.model", name: "Invoice", qualified_name: "billing.Invoice" }, + ]; + const extra: GraphEdge = { + id: "other", + src: "ser", + dst: "model", + type: "serializes", + weight: "cheap", + confidence: 1, + }; + const { rfEdges } = toReactFlowElements(extraNodes, [...edges, extra], "view"); + expect(rfEdges.find((e) => e.id === "ok")?.label).toBe("uses serializer"); + expect(rfEdges.find((e) => e.id === "other")?.label).toBeUndefined(); }); }); diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index e5f89b5..f0e92dd 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -8,6 +8,7 @@ import { Position, ReactFlow, ReactFlowProvider, + useReactFlow, type Edge, type Node, type NodeMouseHandler, @@ -24,7 +25,15 @@ import { type GraphProjection, } from "./graphView"; import { inspectNode, type InspectorLink } from "./nodeInspector"; -import { layoutNodes, type GraphEdge, type GraphNode } from "./types"; +import { + GRAPH_NODE_HEIGHT, + GRAPH_NODE_WIDTH, + layoutNodes, + type GraphEdge, + type GraphNode, +} from "./types"; + +const NO_NEIGHBORS = new Set(); const LayeredGraph3D = lazy(() => import("./LayeredGraph3D").then((mod) => ({ default: mod.LayeredGraph3D })), @@ -50,17 +59,32 @@ 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"]); +function FitViewOnTopology({ topologyKey }: { topologyKey: string }) { + const { fitView } = useReactFlow(); + useEffect(() => { + let inner = 0; + const outer = requestAnimationFrame(() => { + inner = requestAnimationFrame(() => { + fitView({ padding: 0.2, maxZoom: 1.15 }); + }); + }); + return () => { + cancelAnimationFrame(outer); + cancelAnimationFrame(inner); + }; + }, [fitView, topologyKey]); + return 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 pos = layoutNodes(nodes, edges); const rfNodes: Node[] = nodes.map((n) => ({ id: n.id, type: "load", @@ -69,14 +93,15 @@ export function toReactFlowElements( selected: selectedId === n.id, sourcePosition: Position.Right, targetPosition: Position.Left, - width: NODE_WIDTH, - height: NODE_HEIGHT, - style: { width: NODE_WIDTH, height: NODE_HEIGHT }, + width: GRAPH_NODE_WIDTH, + height: GRAPH_NODE_HEIGHT, + style: { width: GRAPH_NODE_WIDTH, height: GRAPH_NODE_HEIGHT }, })); const rfEdges: Edge[] = edges .filter((e) => byId.has(e.src) && byId.has(e.dst)) .map((e) => { const stroke = WEIGHT_COLOR[e.weight] || "var(--edge-cheap)"; + const labeled = Boolean(selectedId && (e.src === selectedId || e.dst === selectedId)); return { id: e.id, source: e.src, @@ -94,8 +119,11 @@ export function toReactFlowElements( height: 14, color: stroke, }, - label: e.type.replaceAll("_", " "), - labelStyle: { fill: "var(--muted)", fontSize: 10 }, + label: labeled ? e.type.replaceAll("_", " ") : undefined, + labelStyle: labeled ? { fill: "var(--ink)", fontSize: 10, fontWeight: 600 } : undefined, + labelBgStyle: labeled ? { fill: "var(--graph-bg)", fillOpacity: 0.92 } : undefined, + labelBgPadding: labeled ? ([3, 5] as [number, number]) : undefined, + labelBgBorderRadius: labeled ? 4 : undefined, }; }); return { rfNodes, rfEdges }; @@ -230,15 +258,20 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph const view = projection ?? defaultProjection(nodes.length); const level = detail ?? defaultDetail(nodes.length); + const neighborhoodFocus = neighborhoodOnly && view === "3d" ? selectedId : null; const visible = useMemo( () => visibleGraph(nodes, edges, { detail: level, families, - focusId: selectedId, - neighborhoodOnly: neighborhoodOnly && view === "3d", + focusId: neighborhoodFocus, + neighborhoodOnly: Boolean(neighborhoodFocus), }), - [nodes, edges, level, families, selectedId, neighborhoodOnly, view], + [nodes, edges, level, families, neighborhoodFocus], + ); + const topologyKey = useMemo( + () => `${visible.nodes.map((n) => n.id).join("\0")}|${visible.edges.map((e) => e.id).join("\0")}`, + [visible.nodes, visible.edges], ); const byId = useMemo(() => new Map(visible.nodes.map((n) => [n.id, n])), [visible.nodes]); const selected = selectedId ? byId.get(selectedId) ?? null : null; @@ -371,7 +404,7 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph nodes={visible.nodes} edges={visible.edges} selectedId={selectedId} - neighborIds={visible.neighborIds} + neighborIds={neighborhoodFocus ? visible.neighborIds : NO_NEIGHBORS} onSelect={(id) => { setSelectedId(id); if (!id) setNeighborhoodOnly(false); @@ -388,8 +421,7 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph nodes={rfNodes} edges={rfEdges} nodeTypes={nodeTypes} - fitView - fitViewOptions={{ padding: 0.2, maxZoom: 1.15 }} + fitView={false} minZoom={0.25} nodesDraggable={false} nodesConnectable={false} @@ -400,6 +432,7 @@ export function ImpactGraph({ nodes, edges }: { nodes: GraphNode[]; edges: Graph proOptions={{ hideAttribution: false }} data-testid="impact-graph" > + (null); + const topologyKey = `${nodes.map((n) => n.id).join("\0")}|${edges.map((e) => e.id).join("\0")}`; useEffect(() => { const host = hostRef.current; if (!host) return; const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches; + const bg = cssColor("--graph-bg", "#0b0f14"); + const accent = new THREE.Color(cssColor("--accent", "#4cc9f0")); const scene = new THREE.Scene(); - scene.background = new THREE.Color(cssColor("--graph-bg", "#0b0f14")); + scene.background = new THREE.Color(bg); const camera = new THREE.PerspectiveCamera(50, 1, 1, 8000); let renderer: THREE.WebGLRenderer; try { renderer = new THREE.WebGLRenderer({ antialias: true, + alpha: false, failIfMajorPerformanceCaveat: false, powerPreference: "low-power", }); @@ -82,6 +91,7 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect return; } setWebglError(null); + renderer.setClearColor(bg, 1); renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); renderer.domElement.dataset.testid = "graph-3d-canvas"; host.appendChild(renderer.domElement); @@ -165,16 +175,23 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect 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 saved = cameraStateRef.current; + if (saved && saved.topology === topologyKey) { + camera.position.set(saved.position.x, saved.position.y, saved.position.z); + controls.target.set(saved.target.x, saved.target.y, saved.target.z); + camera.lookAt(controls.target); + } else { + 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 }; @@ -183,14 +200,15 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect const paint = (focus: string | null, neighbors: Set) => { const isolating = Boolean(focus && neighbors.size); + const idle = new THREE.Color(0x000000); 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; + mesh.scale.setScalar(selected ? 1.25 : onPath ? 1 : 0.7); + material.emissive.copy(selected ? accent : idle); + material.emissiveIntensity = selected ? 0.35 : 0; } (lines.material as THREE.LineBasicMaterial).opacity = isolating ? 0.85 : 0.5; }; @@ -250,6 +268,11 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect paint(focusRef.current.selectedId, focusRef.current.neighborIds); return () => { + cameraStateRef.current = { + topology: topologyKey, + position: { x: camera.position.x, y: camera.position.y, z: camera.position.z }, + target: { x: controls.target.x, y: controls.target.y, z: controls.target.z }, + }; cancelAnimationFrame(frame); ro.disconnect(); renderer.domElement.removeEventListener("pointermove", onMove); @@ -269,16 +292,13 @@ export function LayeredGraph3D({ nodes, edges, selectedId, neighborIds, onSelect 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]); + // Rebuild only when the graph's node/edge ids change — not when selection paints. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [topologyKey]); useEffect(() => { (hostRef.current as HostEl | null)?.__paint?.(selectedId, neighborIds); diff --git a/ui/src/graphView.test.ts b/ui/src/graphView.test.ts index a792c02..cf219e1 100644 --- a/ui/src/graphView.test.ts +++ b/ui/src/graphView.test.ts @@ -48,6 +48,17 @@ describe("visibleGraph", () => { expect(g.nodes.map((n) => n.id).sort()).toEqual(["a", "b", "c", "d"]); }); + it("does not shrink the graph when a node is selected without neighborhood mode", () => { + const g = visibleGraph(nodes, edges, { + detail: "full", + families: allFamilies, + focusId: "b", + neighborhoodOnly: false, + }); + expect(g.nodes.map((n) => n.id).sort()).toEqual(["a", "b", "c", "d"]); + expect(g.edges).toHaveLength(3); + }); + 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"]); diff --git a/ui/src/styles.css b/ui/src/styles.css index a377e9f..08b4474 100644 --- a/ui/src/styles.css +++ b/ui/src/styles.css @@ -1170,7 +1170,11 @@ kbd { 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-host { + position: relative; + min-height: 0; + background: var(--graph-bg); +} .graph-3d canvas { display: block; width: 100%; height: 100%; } .graph-3d-tip { position: absolute; @@ -1648,9 +1652,9 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } border-radius: var(--radius); border: 1px solid var(--node-line); background: var(--node-bg); - width: 180px; + width: 208px; max-width: 100%; - height: 56px; + height: 64px; box-sizing: border-box; box-shadow: 0 0 0 1px var(--shadow); overflow: visible; @@ -1660,9 +1664,12 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } .lp-node .n { font-size: 13px; font-weight: 600; + line-height: 1.2; overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow-wrap: anywhere; } .lp-node.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); } .react-flow__node-load .react-flow__handle { diff --git a/ui/src/styles.test.ts b/ui/src/styles.test.ts index 13a3afa..713ae77 100644 --- a/ui/src/styles.test.ts +++ b/ui/src/styles.test.ts @@ -49,11 +49,15 @@ describe("graph selected-node overflow", () => { expect(getComputedStyle(btn).height).toBe("24px"); }); - it("ellipsizes long titles inside graph nodes", () => { + it("clamps long titles inside graph nodes to two lines", () => { mount(`
test_index_summary_includes_contexts_and_more
`); + const box = document.querySelector(".lp-node") as HTMLElement; const name = document.querySelector(".lp-node .n") as HTMLElement; - expect(getComputedStyle(name).textOverflow).toBe("ellipsis"); - expect(getComputedStyle(name).overflow).toBe("hidden"); - expect(getComputedStyle(name).whiteSpace).toBe("nowrap"); + const style = getComputedStyle(name); + expect(getComputedStyle(box).width).toBe("208px"); + expect(getComputedStyle(box).height).toBe("64px"); + expect(style.overflow).toBe("hidden"); + expect(style.display).toBe("-webkit-box"); + expect(style.webkitLineClamp).toBe("2"); }); }); diff --git a/ui/src/types.test.ts b/ui/src/types.test.ts index 12ff0c7..2702176 100644 --- a/ui/src/types.test.ts +++ b/ui/src/types.test.ts @@ -1,5 +1,21 @@ import { describe, expect, it } from "vitest"; -import { layerFor, layoutNodes, type GraphNode } from "./types"; +import { + GRAPH_COL_GAP, + GRAPH_NODE_HEIGHT, + GRAPH_NODE_WIDTH, + layerFor, + layoutNodes, + type GraphEdge, + type 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 }; +} describe("load-path layout", () => { it("places Django left of the React stitch", () => { @@ -15,4 +31,48 @@ describe("load-path layout", () => { expect(pos.get("p")!.x).toBeLessThan(pos.get("f")!.x); expect(layerFor("django.serializer_field")).toBeLessThan(layerFor("react.form_schema")); }); + + it("packs occupied layers so empty columns do not open huge gaps", () => { + const nodes = [node("r", "django.route"), node("f", "react.form_schema")]; + const pos = layoutNodes(nodes); + expect(Math.abs(pos.get("f")!.x - pos.get("r")!.x)).toBe(GRAPH_NODE_WIDTH + GRAPH_COL_GAP); + expect(Math.abs(pos.get("f")!.x - pos.get("r")!.x)).toBeLessThan(13 * 260); + }); + + it("keeps same-column nodes from overlapping", () => { + const nodes = [ + node("a", "django.view", "AlphaView"), + node("b", "django.view", "BetaView"), + node("c", "django.view", "GammaView"), + node("d", "django.serializer", "AlphaSer"), + ]; + const pos = layoutNodes(nodes); + const byX = new Map(); + for (const n of nodes) { + const p = pos.get(n.id)!; + const list = byX.get(p.x) ?? []; + list.push({ id: n.id, y: p.y }); + byX.set(p.x, list); + } + for (const col of byX.values()) { + col.sort((a, b) => a.y - b.y); + for (let i = 1; i < col.length; i++) { + expect(col[i]!.y - col[i - 1]!.y).toBeGreaterThanOrEqual(GRAPH_NODE_HEIGHT); + } + } + }); + + it("uncrosses a swapped pair with a barycenter pass", () => { + const nodes = [ + node("a", "django.route", "A"), + node("b", "django.route", "B"), + node("ap", "django.view", "APrime"), + node("bp", "django.view", "BPrime"), + ]; + const edges = [edge("a", "bp"), edge("b", "ap")]; + const pos = layoutNodes(nodes, edges); + const sourceOrder = pos.get("a")!.y - pos.get("b")!.y; + const swappedTargets = pos.get("bp")!.y - pos.get("ap")!.y; + expect(sourceOrder * swappedTargets).toBeGreaterThan(0); + }); }); diff --git a/ui/src/types.ts b/ui/src/types.ts index b2a30e1..80b8a03 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -257,7 +257,28 @@ export function layerFor(type: string): number { return LAYER_ORDER[type] ?? 8; } -export function layoutNodes(nodes: GraphNode[]): Map { +export const GRAPH_NODE_WIDTH = 208; +export const GRAPH_NODE_HEIGHT = 64; +export const GRAPH_COL_GAP = 88; +export const GRAPH_ROW_GAP = 28; + +const LAYOUT_PASSES = 8; + +function median(values: number[]): number { + if (!values.length) return Number.NaN; + const sorted = [...values].sort((a, b) => a - b); + const mid = Math.floor(sorted.length / 2); + return sorted.length % 2 ? sorted[mid]! : (sorted[mid - 1]! + sorted[mid]!) / 2; +} + +/** Layered left-to-right layout: occupied columns only, barycenter ordering, no in-column overlap. */ +export function layoutNodes( + nodes: GraphNode[], + edges: GraphEdge[] = [], +): Map { + const pos = new Map(); + if (!nodes.length) return pos; + const columns = new Map(); for (const n of nodes) { const layer = layerFor(n.type); @@ -265,12 +286,64 @@ export function layoutNodes(nodes: GraphNode[]): Map(); - for (const [layer, list] of columns) { - list.sort((a, b) => a.name.localeCompare(b.name)); - list.forEach((n, i) => { - pos.set(n.id, { x: layer * 260, y: i * 108 }); + + const layers = [...columns.keys()].sort((a, b) => a - b); + const order = layers.map((layer) => + [...(columns.get(layer) ?? [])].sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id)), + ); + + const ids = new Set(nodes.map((n) => n.id)); + const preds = new Map(); + const succs = new Map(); + for (const n of nodes) { + preds.set(n.id, []); + succs.set(n.id, []); + } + for (const e of edges) { + if (!ids.has(e.src) || !ids.has(e.dst) || e.src === e.dst) continue; + succs.get(e.src)!.push(e.dst); + preds.get(e.dst)!.push(e.src); + } + + const rank = new Map(); + const refreshRanks = () => { + for (const col of order) { + col.forEach((n, i) => rank.set(n.id, i)); + } + }; + refreshRanks(); + + const sortByBarycenter = (col: GraphNode[], neighborsOf: (id: string) => string[]) => { + const keyed = col.map((n, i) => { + const nbrs = neighborsOf(n.id) + .map((id) => rank.get(id)) + .filter((v): v is number => v !== undefined); + const bary = median(nbrs); + return { n, bary: Number.isNaN(bary) ? i : bary, name: n.name, id: n.id }; }); + keyed.sort((a, b) => a.bary - b.bary || a.name.localeCompare(b.name) || a.id.localeCompare(b.id)); + return keyed.map((k) => k.n); + }; + + for (let pass = 0; pass < LAYOUT_PASSES; pass++) { + for (let i = 1; i < order.length; i++) { + order[i] = sortByBarycenter(order[i]!, (id) => preds.get(id) ?? []); + refreshRanks(); + } + for (let i = order.length - 2; i >= 0; i--) { + order[i] = sortByBarycenter(order[i]!, (id) => succs.get(id) ?? []); + refreshRanks(); + } } + + const colPitch = GRAPH_NODE_WIDTH + GRAPH_COL_GAP; + const rowPitch = GRAPH_NODE_HEIGHT + GRAPH_ROW_GAP; + const maxRows = Math.max(...order.map((col) => col.length), 1); + order.forEach((col, colIndex) => { + const y0 = ((maxRows - col.length) * rowPitch) / 2; + col.forEach((n, i) => { + pos.set(n.id, { x: colIndex * colPitch, y: y0 + i * rowPitch }); + }); + }); return pos; } From 06ff147445a39c3c6ca49b3bd87c8f5ba8a2684c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 10:59:27 +0000 Subject: [PATCH 4/7] Give URL names their own column and wrap graph node labels. Routes and reverse-URL names were stacked in one layer, so pretix-style widget graphs crowded four boxes into a single column. Management commands also fell through to the OpenAPI default layer. Put those types on the path they belong on, and insert wrap hints so long routes break at slashes. Co-authored-by: zord.lack.net --- ...D0mq8ReQ.js => LayeredGraph3D-B5oUhOgB.js} | 2 +- .../{index-dUZaA8eL.js => index-Dc1-DXoM.js} | 10 ++-- src/loadpath/static/index.html | 2 +- ui/src/ImpactGraph.tsx | 2 +- ui/src/graphView.ts | 25 ++++---- ui/src/types.test.ts | 14 +++++ ui/src/types.ts | 58 ++++++++++--------- 7 files changed, 65 insertions(+), 48 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-D0mq8ReQ.js => LayeredGraph3D-B5oUhOgB.js} (99%) rename src/loadpath/static/assets/{index-dUZaA8eL.js => index-Dc1-DXoM.js} (81%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js b/src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js rename to src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js index 1c8d17b..e00a861 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-D0mq8ReQ.js +++ b/src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-dUZaA8eL.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Dc1-DXoM.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-dUZaA8eL.js b/src/loadpath/static/assets/index-Dc1-DXoM.js similarity index 81% rename from src/loadpath/static/assets/index-dUZaA8eL.js rename to src/loadpath/static/assets/index-Dc1-DXoM.js index c2c196c..dfb0720 100644 --- a/src/loadpath/static/assets/index-dUZaA8eL.js +++ b/src/loadpath/static/assets/index-Dc1-DXoM.js @@ -34,10 +34,10 @@ `+M+e}var ne=!1;function re(e,n){if(!e||ne)return"";ne=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(Z){var s=Z}Reflect.construct(e,[],n)}else{try{n.call()}catch(Z){s=Z}e.call(n.prototype)}else{try{throw Error()}catch(Z){s=Z}e()}}catch(Z){if(Z&&s&&typeof Z.stack=="string"){for(var c=Z.stack.split(` `),h=s.stack.split(` `),w=c.length-1,P=h.length-1;1<=w&&0<=P&&c[w]!==h[P];)P--;for(;1<=w&&0<=P;w--,P--)if(c[w]!==h[P]){if(w!==1||P!==1)do if(w--,P--,0>P||c[w]!==h[P]){var A=` -`+c[w].replace(" at new "," at ");return e.displayName&&A.includes("")&&(A=A.replace("",e.displayName)),A}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case T:return"Portal";case K:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case W:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function 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 pe(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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function me(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 ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(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 je(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Me(e,n){je(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")?Ge(e,n.type,i):n.hasOwnProperty("defaultValue")&&Ge(e,n.type,q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var 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 Ge(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var nt=Array.isArray;function qe(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=wt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var gn={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},Ni=["Webkit","ms","Moz","O"];Object.keys(gn).forEach(function(e){Ni.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),gn[n]=gn[e]})});function $r(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||gn.hasOwnProperty(e)&&gn[e]?(""+n).trim():n+"px"}function ir(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=$r(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function or(e,n){if(n){if(Ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Pn(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 mn=null;function In(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,on=null,sn=null;function lr(e){if(e=Gi(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),sr(e.stateNode,e.type,n))}}function ar(e){on?sn?sn.push(e):sn=[e]:on=e}function ur(){if(on){var e=on,n=sn;if(sn=on=null,lr(e),n)for(e=0;e>>=0,e===0?32:31-(Fl(e)/Hl|0)|0}var Br=64,Vr=4194304;function hr(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 yn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Pt(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Oi),Ac=" ",zc=!1;function Dc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $c(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Xr=!1;function Ym(e,n){switch(e){case"compositionend":return $c(n);case"keypress":return n.which!==32?null:(zc=!0,Ac);case"textInput":return e=n.data,e===Ac&&zc?null:e;default:return null}}function Xm(e,n){if(Xr)return e==="compositionend"||!ta&&Dc(e,n)?(e=Mc(),Go=Ql=$n=null,Xr=!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=Wc(i)}}function Xc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Xc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Gc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ia(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 ny(e){var n=Gc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Xc(i.ownerDocument.documentElement,i)){if(s!==null&&ia(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=Yc(i,h);var w=Yc(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,Gr=null,oa=null,Vi=null,sa=!1;function Qc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;sa||Gr==null||Gr!==ye(s)||(s=Gr,"selectionStart"in s&&ia(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(oa,"onSelect"),0Jr||(e.current=va[Jr],va[Jr]=null,Jr--)}function De(e,n){Jr++,va[Jr]=e.current,e.current=n}var Bn={},pt=Hn(Bn),_t=Hn(!1),yr=Bn;function ei(e,n){var i=e.type.contextTypes;if(!i)return Bn;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(pt)}function cd(e,n,i){if(pt.current!==Bn)throw Error(o(168));De(pt,n),De(_t,i)}function dd(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,de(e)||"Unknown",c));return B({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,yr=pt.current,De(pt,e),De(_t,_t.current),!0}function fd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=dd(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(pt),De(pt,e)):Fe(_t),De(_t,i)}var xn=null,as=!1,xa=!1;function hd(e){xn===null?xn=[e]:xn.push(e)}function py(e){as=!0,hd(e)}function Vn(){if(!xa&&xn!==null){xa=!0;var e=0,n=Ae;try{var i=xn;for(Ae=1;e>=w,c-=w,wn=1<<32-Pt(n)+c|i<Ce?(at=Ee,Ee=null):at=Ee.sibling;var Le=ie(X,Ee,Q[Ce],ue);if(Le===null){Ee===null&&(Ee=at);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=at}if(Ce===Q.length)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;CeCe?(at=Ee,Ee=null):at=Ee.sibling;var Zn=ie(X,Ee,Le.value,ue);if(Zn===null){Ee===null&&(Ee=at);break}e&&Ee&&Zn.alternate===null&&n(X,Ee),O=h(Zn,O,Ce),ke===null?we=Zn:ke.sibling=Zn,ke=Zn,Ee=at}if(Le.done)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;!Le.done;Ce++,Le=Q.next())Le=le(X,Le.value,ue),Le!==null&&(O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,Ce),we}for(Ee=s(X,Ee);!Le.done;Ce++,Le=Q.next())Le=he(Ee,X,Ce,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?Ce:Le.key),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,Ce),we}function Ke(X,O,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 R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===H){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&xd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===H?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=zs(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=mu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,Ke(X,O,ke(Q._payload),ue)}if(nt(Q))return ve(X,O,Q,ue);if(z(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=gu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return Ke}var ii=wd(!0),_d=wd(!1),hs=Hn(null),ps=null,oi=null,Na=null;function Ca(){Na=oi=ps=null}function ja(e){var n=hs.current;Fe(hs),e._currentValue=n}function ba(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 si(e,n){ps=e,Na=oi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ft(e){var n=e._currentValue;if(Na!==e)if(e={context:e,memoizedValue:n,next:null},oi===null){if(ps===null)throw Error(o(308));oi=e,ps.dependencies={lanes:0,firstContext:e}}else oi=oi.next=e;return n}var wr=null;function Ma(e){wr===null?wr=[e]:wr.push(e)}function Sd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ma(n)):(i.next=c.next,c.next=i),n.interleaved=i,Sn(e,s)}function Sn(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 Un=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Wn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,Sn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,Sn(e,i)}function gs(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,Ur(e,i)}}function Ed(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 ms(e,n,i,s){var c=e.updateQueue;Un=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var A=P,Z=A.next;A.next=null,w===null?h=Z:w.next=Z,w=A;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==w&&(P===null?oe.firstBaseUpdate=Z:P.next=Z,oe.lastBaseUpdate=A))}if(h!==null){var le=c.baseState;w=0,oe=Z=A=null,P=h;do{var ie=P.lane,he=P.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(ie=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){le=ve.call(he,le,ie);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,ie=typeof ve=="function"?ve.call(he,le,ie):ve,ie==null)break e;le=B({},le,ie);break e;case 2:Un=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[P]:ie.push(P))}else he={eventTime:he,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(Z=oe=he,A=le):oe=oe.next=he,w|=ie;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(A=le),c.baseState=A,c.firstBaseUpdate=Z,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);kr|=w,e.lanes=w,e.memoizedState=le}}function Nd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Aa.transition;Aa.transition={};try{e(!1),n()}finally{Ae=i,Aa.transition=s}}function Ud(){return Ht().memoizedState}function vy(e,n,i){var s=Qn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(e))Yd(n,i);else if(i=Sd(e,n,i,s),i!==null){var c=xt();qt(i,e,s,c),Xd(i,n,s)}}function xy(e,n,i){var s=Qn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(e))Yd(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Wt(P,w)){var A=n.interleaved;A===null?(c.next=c,Ma(n)):(c.next=A.next,A.next=c),n.interleaved=c;return}}catch{}finally{}i=Sd(e,n,c,s),i!==null&&(c=xt(),qt(i,e,s,c),Xd(i,n,s))}}function Wd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Yd(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Xd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Ur(e,i)}}var Ss={readContext:Ft,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},wy={readContext:Ft,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ft,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Od.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=cn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=cn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Ld,useDebugValue:Ba,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Ld(!1),n=e[0];return e=yy.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=cn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),lt===null)throw Error(o(349));(Sr&30)!==0||Md(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(Id.bind(null,s,h,e),[e]),s.flags|=2048,no(9,Pd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=cn(),n=lt.identifierPrefix;if(Be){var i=_n,s=wn;i=(s&~(1<<32-Pt(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,0")&&(A=A.replace("",e.displayName)),A}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case T:return"Portal";case K:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case W:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function 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 pe(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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function me(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 ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(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 je(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Me(e,n){je(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")?Ge(e,n.type,i):n.hasOwnProperty("defaultValue")&&Ge(e,n.type,q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var 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 Ge(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var nt=Array.isArray;function qe(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=wt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var gn={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},Ni=["Webkit","ms","Moz","O"];Object.keys(gn).forEach(function(e){Ni.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),gn[n]=gn[e]})});function Or(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||gn.hasOwnProperty(e)&&gn[e]?(""+n).trim():n+"px"}function ir(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=Or(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function or(e,n){if(n){if(Ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Pn(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 mn=null;function In(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,on=null,sn=null;function lr(e){if(e=Gi(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),sr(e.stateNode,e.type,n))}}function ar(e){on?sn?sn.push(e):sn=[e]:on=e}function ur(){if(on){var e=on,n=sn;if(sn=on=null,lr(e),n)for(e=0;e>>=0,e===0?32:31-(Fl(e)/Hl|0)|0}var Vr=64,Ur=4194304;function hr(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 yn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Pt(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Oi),Ac=" ",zc=!1;function Dc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $c(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gr=!1;function Ym(e,n){switch(e){case"compositionend":return $c(n);case"keypress":return n.which!==32?null:(zc=!0,Ac);case"textInput":return e=n.data,e===Ac&&zc?null:e;default:return null}}function Xm(e,n){if(Gr)return e==="compositionend"||!ta&&Dc(e,n)?(e=Mc(),Go=Ql=$n=null,Gr=!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=Wc(i)}}function Xc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Xc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Gc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ia(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 ny(e){var n=Gc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Xc(i.ownerDocument.documentElement,i)){if(s!==null&&ia(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=Yc(i,h);var w=Yc(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,Qr=null,oa=null,Vi=null,sa=!1;function Qc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;sa||Qr==null||Qr!==ye(s)||(s=Qr,"selectionStart"in s&&ia(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(oa,"onSelect"),0ei||(e.current=va[ei],va[ei]=null,ei--)}function De(e,n){ei++,va[ei]=e.current,e.current=n}var Bn={},pt=Hn(Bn),_t=Hn(!1),yr=Bn;function ti(e,n){var i=e.type.contextTypes;if(!i)return Bn;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(pt)}function cd(e,n,i){if(pt.current!==Bn)throw Error(o(168));De(pt,n),De(_t,i)}function dd(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,de(e)||"Unknown",c));return B({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,yr=pt.current,De(pt,e),De(_t,_t.current),!0}function fd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=dd(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(pt),De(pt,e)):Fe(_t),De(_t,i)}var xn=null,as=!1,xa=!1;function hd(e){xn===null?xn=[e]:xn.push(e)}function py(e){as=!0,hd(e)}function Vn(){if(!xa&&xn!==null){xa=!0;var e=0,n=Ae;try{var i=xn;for(Ae=1;e>=w,c-=w,wn=1<<32-Pt(n)+c|i<Ce?(at=Ee,Ee=null):at=Ee.sibling;var Le=ie(X,Ee,Q[Ce],ue);if(Le===null){Ee===null&&(Ee=at);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=at}if(Ce===Q.length)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;CeCe?(at=Ee,Ee=null):at=Ee.sibling;var Zn=ie(X,Ee,Le.value,ue);if(Zn===null){Ee===null&&(Ee=at);break}e&&Ee&&Zn.alternate===null&&n(X,Ee),O=h(Zn,O,Ce),ke===null?we=Zn:ke.sibling=Zn,ke=Zn,Ee=at}if(Le.done)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;!Le.done;Ce++,Le=Q.next())Le=le(X,Le.value,ue),Le!==null&&(O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,Ce),we}for(Ee=s(X,Ee);!Le.done;Ce++,Le=Q.next())Le=he(Ee,X,Ce,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?Ce:Le.key),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,Ce),we}function Ke(X,O,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 R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===H){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&xd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===H?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=zs(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=mu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,Ke(X,O,ke(Q._payload),ue)}if(nt(Q))return ve(X,O,Q,ue);if(z(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=gu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return Ke}var oi=wd(!0),_d=wd(!1),hs=Hn(null),ps=null,si=null,Na=null;function Ca(){Na=si=ps=null}function ja(e){var n=hs.current;Fe(hs),e._currentValue=n}function ba(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 li(e,n){ps=e,Na=si=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ft(e){var n=e._currentValue;if(Na!==e)if(e={context:e,memoizedValue:n,next:null},si===null){if(ps===null)throw Error(o(308));si=e,ps.dependencies={lanes:0,firstContext:e}}else si=si.next=e;return n}var wr=null;function Ma(e){wr===null?wr=[e]:wr.push(e)}function Sd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ma(n)):(i.next=c.next,c.next=i),n.interleaved=i,Sn(e,s)}function Sn(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 Un=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Wn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,Sn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,Sn(e,i)}function gs(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,Wr(e,i)}}function Ed(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 ms(e,n,i,s){var c=e.updateQueue;Un=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var A=P,Z=A.next;A.next=null,w===null?h=Z:w.next=Z,w=A;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==w&&(P===null?oe.firstBaseUpdate=Z:P.next=Z,oe.lastBaseUpdate=A))}if(h!==null){var le=c.baseState;w=0,oe=Z=A=null,P=h;do{var ie=P.lane,he=P.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(ie=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){le=ve.call(he,le,ie);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,ie=typeof ve=="function"?ve.call(he,le,ie):ve,ie==null)break e;le=B({},le,ie);break e;case 2:Un=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[P]:ie.push(P))}else he={eventTime:he,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(Z=oe=he,A=le):oe=oe.next=he,w|=ie;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(A=le),c.baseState=A,c.firstBaseUpdate=Z,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);kr|=w,e.lanes=w,e.memoizedState=le}}function Nd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Aa.transition;Aa.transition={};try{e(!1),n()}finally{Ae=i,Aa.transition=s}}function Ud(){return Ht().memoizedState}function vy(e,n,i){var s=Qn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(e))Yd(n,i);else if(i=Sd(e,n,i,s),i!==null){var c=xt();qt(i,e,s,c),Xd(i,n,s)}}function xy(e,n,i){var s=Qn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(e))Yd(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Wt(P,w)){var A=n.interleaved;A===null?(c.next=c,Ma(n)):(c.next=A.next,A.next=c),n.interleaved=c;return}}catch{}finally{}i=Sd(e,n,c,s),i!==null&&(c=xt(),qt(i,e,s,c),Xd(i,n,s))}}function Wd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Yd(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Xd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Wr(e,i)}}var Ss={readContext:Ft,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},wy={readContext:Ft,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ft,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Od.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=cn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=cn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Ld,useDebugValue:Ba,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Ld(!1),n=e[0];return e=yy.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=cn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),lt===null)throw Error(o(349));(Sr&30)!==0||Md(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(Id.bind(null,s,h,e),[e]),s.flags|=2048,no(9,Pd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=cn(),n=lt.identifierPrefix;if(Be){var i=_n,s=wn;i=(s&~(1<<32-Pt(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,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[an]=n,e[Xi]=s,pf(e,n,!1,!1),n.stateNode=e;e:{switch(w=Pn(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cdi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return mt(n),null}else 2*Ue()-h.renderingStartTime>di&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(mt(n),null);case 22:case 23:return fu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Lt&1073741824)!==0&&(mt(n),n.subtreeFlags&6&&(n.flags|=8192)):mt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(_a(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return li(),Fe(_t),Fe(pt),La(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ta(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ri()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return li(),null;case 10:return ja(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Cs=!1,yt=!1,My=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ui(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Qe(e,n,s)}else i.current=null}function eu(e,n,i){try{i()}catch(s){Qe(e,n,s)}}var yf=!1;function Py(e,n){if(fa=Yo,e=Gc(),ia(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,P=-1,A=-1,Z=0,oe=0,le=e,ie=null;t:for(;;){for(var he;le!==i||c!==0&&le.nodeType!==3||(P=w+c),le!==h||s!==0&&le.nodeType!==3||(A=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)ie=le,le=he;for(;;){if(le===e)break t;if(ie===i&&++Z===c&&(P=w),ie===h&&++oe===s&&(A=w),(he=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=he}i=P===-1||A===-1?null:{start:P,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(ha={focusedElem:e,selectionRange:i},Yo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,Ke=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Xt(n.type,xe),Ke);X.__reactInternalSnapshotBeforeUpdate=O}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){Qe(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=yf,yf=!1,ve}function io(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&&eu(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function tu(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 vf(e){var n=e.alternate;n!==null&&(e.alternate=null,vf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[an],delete n[Xi],delete n[ya],delete n[fy],delete n[hy])),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 xf(e){return e.tag===5||e.tag===3||e.tag===4}function wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 nu(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=is));else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}function ru(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(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}var dt=null,Gt=!1;function Yn(e,n,i){for(i=i.child;i!==null;)_f(e,n,i),i=i.sibling}function _f(e,n,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Hr,i)}catch{}switch(i.tag){case 5:yt||ui(i,n);case 6:var s=dt,c=Gt;dt=null,Yn(e,n,i),dt=s,Gt=c,dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?ma(e.parentNode,i):e.nodeType===1&&ma(e,i),zi(e)):ma(dt,i.stateNode));break;case 4:s=dt,c=Gt,dt=i.stateNode.containerInfo,Gt=!0,Yn(e,n,i),dt=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!yt&&(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)&&eu(i,n,w),c=c.next}while(c!==s)}Yn(e,n,i);break;case 1:if(!yt&&(ui(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Qe(i,n,P)}Yn(e,n,i);break;case 21:Yn(e,n,i);break;case 22:i.mode&1?(yt=(s=yt)||i.memoizedState!==null,Yn(e,n,i),yt=s):Yn(e,n,i);break;default:Yn(e,n,i)}}function Sf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,Gn===null)var s=!1;else{if(e=Gn,Gn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var P=h.deletions;if(P!==null){for(var A=0;AUe()-su?Nr(e,0):ou|=i),Nt(e,n)}function Af(e,n){n===0&&((e.mode&1)===0?n=1:(n=Vr,Vr<<=1,(Vr&130023424)===0&&(Vr=4194304)));var i=xt();e=Sn(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Af(e,i)}function Oy(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),Af(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&pd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ei(n,pt.current);si(n,i),c=Da(null,n,s,e,c,i);var h=$a();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Ua(n,s,e,i),n=Ga(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&wa(n),vt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Xt(s,e),c){case 0:n=Xa(null,n,s,e,i);break e;case 1:n=af(null,n,s,e,i);break e;case 11:n=nf(null,n,s,e,i);break e;case 14:n=rf(null,n,s,Xt(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:Xt(s,c),Xa(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),af(e,n,s,c,i);case 3:e:{if(uf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,kd(e,n),ms(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=ai(Error(o(423)),n),n=cf(e,n,s,i,c);break e}else if(s!==c){c=ai(Error(o(424)),n),n=cf(e,n,s,i,c);break e}else for(Rt=Fn(n.stateNode.containerInfo.firstChild),Tt=n,Be=!0,Yt=null,i=_d(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ri(),s===c){n=En(e,n,i);break e}vt(e,n,s,i)}n=n.child}return n;case 5:return Cd(n),e===null&&ka(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,pa(s,c)?w=null:h!==null&&pa(s,h)&&(n.flags|=32),lf(e,n),vt(e,n,w,i),n.child;case 6:return e===null&&ka(n),null;case 13:return df(e,n,i);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=ii(n,null,s,i):vt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),nf(e,n,s,c,i);case 7:return vt(e,n,n.pendingProps,i),n.child;case 8:return vt(e,n,n.pendingProps.children,i),n.child;case 12:return vt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!_t.current){n=En(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var A=P.firstContext;A!==null;){if(A.context===s){if(h.tag===1){A=kn(-1,i&-i),A.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var oe=Z.pending;oe===null?A.next=A:(A.next=oe.next,oe.next=A),Z.pending=A}}h.lanes|=i,A=h.alternate,A!==null&&(A.lanes|=i),ba(h.return,i,n),P.lanes|=i;break}A=A.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,P=w.alternate,P!==null&&(P.lanes|=i),ba(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}vt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,si(n,i),c=Ft(c),s=s(c),n.flags|=1,vt(e,n,s,i),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),rf(e,n,s,c,i);case 15:return of(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,si(n,i),Qd(n,s,c),Ua(n,s,c,i),Ga(null,n,s,!0,e,i);case 19:return hf(e,n,i);case 22:return sf(e,n,i)}throw Error(o(156,n.tag))};function Df(e,n){return Do(e,n)}function Fy(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 Fy(e,n,i,s)}function pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===Y)return 14}return 2}function Kn(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 zs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")pu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case K:return e=Vt(12,i,n,c|2),e.elementType=K,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Vt(19,i,n,c),e.elementType=b,e.lanes=h,e;case U:return Ds(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case W:w=9;break e;case ee:w=11;break e;case Y: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 jr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function gu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function mu(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 By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function yu(e,n,i,s,c,h,w,P,A){return e=new By(e,n,i,P,A),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},Pa(h),e}function Vy(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(),ku.exports=t0(),ku.exports}var Kf;function n0(){if(Kf)return Us;Kf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function pi(t){return t.replace(/([/\\._:@-])/g,"$1​")}function Dr({className:t,children:r}){return p.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 a0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function u0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function c0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function d0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function f0({className:t}){return p.jsxs(Dr,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function h0({className:t}){return p.jsx(Dr,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const p0="modulepreload",g0=function(t,r){return new URL(t,r).href},Zf={},m0=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(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(m=>{if(m=g0(m,l),m in Zf)return;Zf[m]=!0;const x=m.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const S=f[C];if(S.href===m&&(!x||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":p0,x||(k.as="script"),k.crossOrigin="",k.href=m,y&&k.setAttribute("nonce",y),document.head.appendChild(k),x)return new Promise((C,S)=>{k.addEventListener("load",C),k.addEventListener("error",()=>S(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 et(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=v0(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)),eh.hasOwnProperty(r)?{space:eh[r],local:t}:t}function w0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Fu&&r.documentElement.namespaceURI===Fu?r.createElement(t):r.createElementNS(o,t)}}function _0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?_0:w0)(r)}function S0(){}function nc(t){return t==null?S0:function(){return this.querySelector(t)}}function k0(t){typeof t!="function"&&(t=nc(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=I+1);!(R=S[N])&&++N=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function G0(t){t||(t=Q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function q0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function K0(){return Array.from(this)}function Z0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?uv:typeof r=="function"?dv:cv)(t,r,o??"")):vi(this.node(),t)}function vi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function hv(t){return function(){delete this[t]}}function pv(t,r){return function(){this[t]=r}}function gv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function mv(t,r){return arguments.length>1?this.each((r==null?hv:typeof r=="function"?gv:pv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function rc(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=rc(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Uv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Hu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:y,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:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:m}})}Hu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ex(t){return!t.ctrlKey&&!t.button}function tx(){return this.parentNode}function nx(t,r){return r??{x:t.x,y:t.y}}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=ex,r=tx,o=nx,l=rx,a={},u=vl("start","drag","end"),d=0,f,g,y,m,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",S).on("touchmove.drag",E,Jv).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(m||!t.call(this,j,R))){var T=N(this,r.call(this,j,R),j,R,"mouse");T&&(At(j.view).on("mousemove.drag",k,vo).on("mouseup.drag",C,vo),Lp(j.view),Cu(j),y=!1,f=j.clientX,g=j.clientY,T("start",j))}}function k(j){if(mi(j),!y){var R=j.clientX-f,T=j.clientY-g;y=R*R+T*T>x}a.mouse("drag",j)}function C(j){At(j.view).on("mousemove.drag mouseup.drag",null),Ap(j.view,y),mi(j),a.mouse("end",j)}function S(j,R){if(t.call(this,j,R)){var T=j.changedTouches,H=r.call(this,j,R),G=T.length,K,te;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=ox.exec(t))?new jt(r[1],r[2],r[3],1):(r=sx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=lx.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ax.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ux.exec(t))?lh(r[1],r[2]/100,r[3]/100,1):(r=cx.exec(t))?lh(r[1],r[2]/100,r[3]/100,r[4]):th.hasOwnProperty(t)?ih(th[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function ih(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function hx(t){return t instanceof Po||(t=Tr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Bu(t,r,o,l){return arguments.length===1?hx(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}ic(jt,Bu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Pr(this.r),Pr(this.g),Pr(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:oh,formatHex:oh,formatHex8:px,formatRgb:sh,toString:sh}));function oh(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}`}function px(){return`#${Mr(this.r)}${Mr(this.g)}${Mr(this.b)}${Mr((isNaN(this.opacity)?1:this.opacity)*255)}`}function sh(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Pr(this.r)}, ${Pr(this.g)}, ${Pr(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Pr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Mr(t){return t=Pr(t),(t<16?"0":"")+t.toString(16)}function lh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,o,l)}function $p(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Tr(t)),!t)return new Zt;if(t instanceof Zt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Zt(d,f,g,t.opacity)}function gx(t,r,o,l){return arguments.length===1?$p(t):new Zt(t,r,o,l??1)}function Zt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}ic(Zt,gx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Zt(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 jt(ju(t>=240?t-240:t+120,a,l),ju(t,a,l),ju(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(ah(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${ah(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ah(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function ju(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 oc=t=>()=>t;function mx(t,r){return function(o){return t+o*r}}function yx(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 vx(t){return(t=+t)==1?Op:function(r,o){return o-r?yx(r,o,t):oc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?mx(t,o):oc(isNaN(t)?r:t)}const ul=(function t(r){var o=vx(r);function l(a,u){var d=o((a=Bu(a)).r,(u=Bu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Op(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=g(m),a.opacity=y(m),a+""}}return l.gamma=t,l})(1);function xx(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,g.push({i:d,x:fn(l,a)})),o=bu.lastIndex;return o180?m+=360:m-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:fn(y,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(y,m,x,v){y!==m?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:fn(y,m)}):m&&x.push(a(x)+"skewX("+m+l)}function g(y,m,x,v,_,k){if(y!==x||m!==v){var C=_.push(a(_)+"scale(",null,",",null,")");k.push({i:C-4,x:fn(y,x)},{i:C-2,x:fn(m,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,m){var x=[],v=[];return y=t(y),m=t(m),u(y.translateX,y.translateY,m.translateX,m.translateY,x,v),d(y.rotate,m.rotate,x,v),f(y.skewX,m.skewX,x,v),g(y.scaleX,y.scaleY,m.scaleX,m.scaleY,x,v),y=m=null,function(_){for(var k=-1,C=v.length,S;++k=0&&t._call.call(void 0,r),t=t._next;--xi}function dh(){Rr=(dl=_o.now())+wl,xi=ho=0;try{Lx()}finally{xi=0,zx(),Rr=0}}function Ax(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function zx(){for(var t,r=cl,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:cl=o);po=t,Wu(l)}function Wu(t){if(!xi){ho&&(ho=clearTimeout(ho));var r=t-Rr;r>24?(t<1/0&&(ho=setTimeout(dh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(Ax,Vp)),xi=1,Up(dh))}}function fh(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Dx=vl("start","end","cancel","interrupt"),$x=[],Yp=0,hh=1,Yu=2,rl=3,ph=4,Xu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Ox(t,o,{name:r,index:l,group:a,on:Dx,tween:$x,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function lc(t,r){var o=nn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function pn(t,r){var o=nn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function nn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Ox(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(y){o.state=hh,o.timer.restart(d,o.delay,o.time),o.delay<=y&&d(y-o.delay)}function d(y){var m,x,v,_;if(o.state!==hh)return g();for(m in l)if(_=l[m],_.name===o.name){if(_.state===rl)return fh(d);_.state===ph?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[m]):+mYu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function gw(t,r,o){var l,a,u=pw(r)?lc:pn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function mw(t,r){var o=this._id;return arguments.length<2?nn(this.node(),o).on.on(t):this.each(gw(o,t,r))}function yw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function vw(){return this.on("end.remove",yw(this._id))}function xw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=nc(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Uw(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 jn(t,r,o){this.k=t,this.x=r,this.y=o}jn.prototype={constructor:jn,scale:function(t){return t===1?this:new jn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new jn(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 Sl=new jn(1,0,0);qp.prototype=jn.prototype;function qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Ww(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Yw(){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 gh(){return this.__zoom||Sl}function Xw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Gw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(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 Kp(){var t=Ww,r=Yw,o=Qw,l=Xw,a=Gw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,y=vl("start","zoom","end"),m,x,v,_=500,k=150,C=0,S=10;function E(b){b.property("__zoom",gh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",W).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(b,Y,V,U){var D=b.selection?b.selection():b;D.property("__zoom",gh),b!==D?R(b,Y,V,U):D.interrupt().each(function(){T(this,arguments).event(U).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},E.scaleBy=function(b,Y,V,U){E.scaleTo(b,function(){var D=this.__zoom.k,z=typeof Y=="function"?Y.apply(this,arguments):Y;return D*z},V,U)},E.scaleTo=function(b,Y,V,U){E.transform(b,function(){var D=r.apply(this,arguments),z=this.__zoom,B=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=z.invert(B),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(N(I(z,L),B,M),D,d)},V,U)},E.translateBy=function(b,Y,V,U){E.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,U)},E.translateTo=function(b,Y,V,U,D){E.transform(b,function(){var z=r.apply(this,arguments),B=this.__zoom,M=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Sl.translate(M[0],M[1]).scale(B.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),z,d)},U,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new jn(Y,b.x,b.y)}function N(b,Y,V){var U=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return U===b.x&&D===b.y?b:new jn(b.k,U,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,U){b.on("start.zoom",function(){T(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,B=T(D,z).event(U),M=r.apply(D,z),L=V==null?j(M):typeof V=="function"?V.apply(D,z):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,z):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var q=fe(de),se=ne/q[2];de=new jn(se,L[0]-q[0]*se,L[1]-q[1]*se)}B.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new H(b,Y)}function H(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}H.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=At(this.that).datum();y.call(b,this.that,new Uw(b,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),U=this.__zoom,D=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=Kt(b);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=U.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(U.k===D)return;V.mouse=[z,U.invert(z)],ol(this),V.start()}fo(b),V.wheel=setTimeout(B,k),V.zoom("mouse",o(N(I(U,D),V.mouse[0],V.mouse[1]),V.extent,d));function B(){V.wheel=null,V.end()}}function K(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,U=T(this,Y,!0).event(b),D=At(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),z=Kt(b,V),B=b.clientX,M=b.clientY;Lp(b.view),Mu(b),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function L(re){if(fo(re),!U.moved){var ce=re.clientX-B,fe=re.clientY-M;U.moved=ce*ce+fe*fe>C}U.event(re).zoom("mouse",o(N(U.that.__zoom,U.mouse[0]=Kt(re,V),U.mouse[1]),U.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),Ap(re.view,U.moved),fo(re),U.event(re).end()}}function te(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,U=Kt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(U),z=V.k*(b.shiftKey?.5:2),B=o(N(I(V,z),U,D),r.apply(this,Y),d);fo(b),f>0?At(this).transition().duration(f).call(R,B,U,b):At(this).call(E.transform,B,U,b)}}function W(b,...Y){if(t.apply(this,arguments)){var V=b.touches,U=V.length,D=T(this,Y,b.changedTouches.length===U).event(b),z,B,M,L;for(Mu(b),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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 wi;(function(t){t.Strict="strict",t.Loose="loose"})(wi||(wi={}));var Ir;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Ir||(Ir={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var nr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(nr||(nr={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const mh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,qw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),uc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=rn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Kw=(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):uc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},cc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,y=r.width/a,m=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:k=!0,hidden:C=!1}=v;if(d&&!k||C)continue;const S=_.width??v.width??v.initialWidth??0,E=_.height??v.height??v.initialHeight??0,{x:I,y:N}=v.internals.positionAbsolute,j=sg(f,g,y,m,I,N,S,E),R=S*E,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Zw=(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 Jw(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}=rn(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 e1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Jw(t,d),g=To(f),y=fc(g,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(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y}=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",tn.error005());else{const{width:_,height:k}=rn(f);_&&k&&(x=[[g,y],[g+_,y+k]])}else f&&Ar(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+y],[d.extent[1][0]+g,d.extent[1][1]+y]]);const v=Ar(x)?Lr(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-g+(d.measured.width??0)*m[0],y:v.y-y+(d.measured.height??0)*m[1]},positionAbsolute:v}}async function t1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),k=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||k)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),m=Zw(d,g);for(const v of g)f.has(v.id)&&!m.find(k=>k.id===v.id)&&m.push(v);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 _i=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Lr=(t={x:0,y:0},r,o)=>({x:_i(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:_i(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=rn(o),{x:u,y:d}=o.internals.positionAbsolute;return Lr(t,[[u,d],[u+l,d+a]],r)}const yh=(t,r,o)=>to?-_i(Math.abs(t-o),1,r)/r:0,dc=(t,r,o=15,l=40)=>{const a=yh(t.x,l,r.width-l)*o,u=yh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Gu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Gu(t),Gu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*y)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),vh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Si=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function hi(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 n1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=hi(t,o),a=hi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=hi(t.top??t.y??0,o),a=hi(t.bottom??t.y??0,o),u=hi(t.left??t.x??0,r),d=hi(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 r1(t,r,o,l,a,u){const{x:d,y:f}=Si(t,[r,o,l]),{x:g,y}=Si({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-g,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const fc=(t,r,o,l,a,u)=>{const d=n1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,y=Math.min(f,g),m=_i(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*m,k=o/2-v*m,C=r1(t,_,k,m,r,o),S={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.left+S.right,y:k-S.top+S.bottom,zoom:m}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Ar(t){return t!=null&&t!=="parent"}function rn(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 ag(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 ug(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 xh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function i1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const hc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},s1=["INPUT","SELECT","TEXTAREA"];function dg(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:s1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,en=(t,r)=>{var u,d;const o=fg(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)}},wh=(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,...hc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,y=r*.125+u*.375+f*.375+l*.125,m=Math.abs(g-t),x=Math.abs(y-r);return[g,y,m,x]}function qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function _h({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 pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=_h({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[y,m]=_h({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,k]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:m});return[`M${t},${r} C${f},${g} ${y},${m} ${l},${a}`,x,v,_,k]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const u1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,c1=(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)),d1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",tn.error006()),r;const l=o.getEdgeId||u1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},c1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const Sh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},f1=({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 h1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=Sh[r],g=Sh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+g.x*u,y:o.y+g.y*u},x=f1({source:y,sourcePosition:r,target:m}),v=x.x!==0?"x":"y",_=x[v];let k=[],C,S;const E={x:0,y:0},I={x:0,y:0},[,,N,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??y.x+(m.x-y.x)*d,S=a.y??(y.y+m.y)/2):(C=a.x??(y.x+m.x)/2,S=a.y??y.y+(m.y-y.y)*d);const G=[{x:C,y:y.y},{x:C,y:m.y}],K=[{x:y.x,y:S},{x:m.x,y:S}];f[v]===_?k=v==="x"?G:K:k=v==="x"?K:G}else{const G=[{x:y.x,y:m.y}],K=[{x:m.x,y:y.y}];if(v==="x"?k=f.x===_?K:G:k=f.y===_?G:K,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?E[v]=(y[v]>t[v]?-1:1)*Y:I[v]=(m[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=y[b]>m[b],U=y[b]=J?(C=(te.x+W.x)/2,S=k[0].y):(C=k[0].x,S=(te.y+W.y)/2)}const R={x:y.x+E.x,y:y.y+E.y},T={x:m.x+I.x,y:m.y+I.y};return[[t,...R.x!==k[0].x||R.y!==k[0].y?[R]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],o],C,S,N,j]}function p1(t,r,o,l){const a=Math.min(kh(t,r)/2,kh(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 y=t.xo.id===r):t[0])||null}function qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(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(g=>{if(g&&typeof g=="object"){const y=qu(g,r);u.has(y)||(d.push({id:y,color:g.color||o,...g}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,y1=10,pc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},v1={...pc,checkEquality:!0};function gc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function x1(t,r,o){const l=gc(pc,o);for(const a of t.values())if(a.parentId)yc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=Ar(a.extent)?a.extent:l.nodeExtent,f=Lr(u,d,rn(a));a.internals.positionAbsolute=f}}function w1(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 mc(t){return t==="manual"}function Ku(t,r,o,l={}){var m,x;const a=gc(v1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!mc(a.zIndexMode)?yg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const k=Io(v,a.nodeOrigin),C=Ar(v.extent)?v.extent:a.nodeExtent,S=Lr(k,C,rn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:S,handleBounds:w1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&yc(_,r,o,l,u),y||(y=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function _1(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 yc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=gc(pc,l),y=t.parentId,m=r.get(y);if(!m){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&g==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*y1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!mc(g)?yg:0,{x:v,y:_,z:k}=S1(t,m,d,f,x,g),{positionAbsolute:C}=t.internals,S=v!==C.x||_!==C.y;(S||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:S?{x:v,y:_}:C,z:k}})}function vg(t,r,o){const l=Jt(t.zIndex)?t.zIndex:0;return mc(o)?l:l+(t.selected?r:0)}function S1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=rn(t),y=Io(t,o),m=Ar(t.extent)?Lr(y,t.extent,g):y;let x=Lr({x:d+m.x,y:f+m.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function vc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),m=og(y,f.rect);u.set(f.parentId,{expandedRect:m,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var N;const m=g.internals.positionAbsolute,x=rn(g),v=g.origin??l,_=f.x0||k>0||E||I)&&(a.push({id:y,type:"position",position:{x:g.position.x-_+E,y:g.position.y-k+I}}),(N=o.get(y))==null||N.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(x.width0){const _=vc(v,r,o,a);y.push(..._)}return{changes:y,updatedInternals:g}}async function E1({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 jh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;jh("source",g,m,t,a,d),jh("target",g,y,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function bh(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 N1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Pu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[y,m]of r){const x=(d=o.get(y))==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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function C1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function j1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,y={x:0,y:0},m=null,x=!1,v=null,_=!1,k=!1,C=null;function S({noDragClassName:I,handleSelector:N,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:H=0}){v=At(j);function G({x:ee,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:U,nodeOrigin:D,onNodeDrag:z,onSelectionDrag:B,onError:M,updateNodePositions:L}=r();u={x:ee,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Gu(To(f)):null,fe=re&&U?C1({dragItems:f,snapGrid:V,x:ee,y:J}):null;for(const[de,q]of f){if(!b.has(de))continue;let se={x:ee-q.distance.x,y:J-q.distance.y};U&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:Ro(se,V));let pe=null;if(re&&Y&&!q.extent&&ce){const{positionAbsolute:ye}=q.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+q.measured.width-ce.x2+Y[1][0],je=ye.y-ce.y+Y[0][1],Me=ye.y+q.measured.height-ce.y2+Y[1][1];pe=[[Ne,je],[Pe,Me]]}const{position:_e,positionAbsolute:me}=rg({nodeId:de,nextPosition:se,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||q.position.x!==_e.x||q.position.y!==_e.y,q.position=_e,q.internals.positionAbsolute=me}if(k=k||ne,!!ne&&(L(f,!0),C&&(l||z||!T&&B))){const[de,q]=Pu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,q),z==null||z(C,de,q),T||B==null||B(C,q)}}async function K(){if(!m)return;const{transform:ee,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,U]=dc(y,m,b);(V!==0||U!==0)&&(u.x=(u.x??0)-V/ee[2],u.y=(u.y??0)-U/ee[2],await J({x:V,y:U})&&G(u)),d=requestAnimationFrame(K)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:U,snapToGrid:D,selectNodesOnDrag:z,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!z||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&z&&T&&(t==null||t(T));const ne=mo(ee.sourceEvent,{transform:V,snapGrid:U,snapToGrid:D,containerBounds:m});if(u=ne,f=N1(J,Y,ne,T),f.size>0&&(o||B||!T&&M)){const[ce,fe]=Pu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(ee.sourceEvent,f,ce,fe),B==null||B(ee.sourceEvent,ce,fe),T||M==null||M(ee.sourceEvent,fe)}}const W=zp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:U}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,k=!1,C=ee.sourceEvent,b===0&&te(ee),u=mo(ee.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:U,containerBounds:m}),y=en(ee.sourceEvent,m)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:U,nodeLookup:D}=r(),z=mo(ee.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:m});if(C=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,K()),!x){const B=en(ee.sourceEvent,m),M=B.x-y.x,L=B.y-y.y;Math.sqrt(M*M+L*L)>U&&te(ee)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(y=en(ee.sourceEvent,m),G(z))}}).on("end",ee=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(k&&(b(f,!1),k=!1),a||Y||!T&&V){const[U,D]=Pu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,f,U,D),Y==null||Y(ee.sourceEvent,U,D),T||V==null||V(ee.sourceEvent,D)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!I||!bh(J,`.${I}`,j))&&(!N||bh(J,N,j))});v.call(W)}function E(){v==null||v.on(".drag",null)}return{update:S,destroy:E}}function b1(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())pl(a,No(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,o,l){var f,g;let a=[],u=1/0;const d=b1(t,o,r+M1);for(const y of d){const m=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=zr(y,x,x.position,!0),k=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=l.type==="source"?"target":"source";return a.find(m=>m.type===y)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var y,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...zr(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function T1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:m,flowId:x,panBy:v,cancelConnection:_,onConnectStart:k,onConnect:C,onConnectEnd:S,isValidConnection:E=kg,onReconnectEnd:I,updateConnection:N,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:H=1,handleDomNode:G}){const K=cg(t.target);let te=0,W;const{x:ee,y:J}=en(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const U=_g(a,b,l,g,r);if(!U)return;let D=en(t,Y),z=!1,B=null,M=!1,L=null;function ne(){if(!m||!Y)return;const[_e,me]=dc(D,Y,T);v({x:_e,y:me}),te=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:b,position:U.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:zr(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:mh[re.position],toNode:null,pointer:D};function q(){V=!0,N(de),k==null||k(t,{nodeId:a,handleId:l,handleType:b})}H===0&&q();function se(_e){if(!V){const{x:Me,y:tt}=en(_e),Ge=Me-ee,nt=tt-J;if(!(Ge*Ge+nt*nt>H*H))return;q()}if(!R()||!re){pe(_e);return}const me=j();D=en(_e,Y),W=P1(Lo(D,me,!1,[1,1]),o,g,re),z||(ne(),z=!0);const ye=Eg(_e,{handle:W,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:y,flowId:x,nodeLookup:g});L=ye.handleDomNode,B=ye.connection,M=I1(!!W,ye.isValid);const Ne=g.get(a),Pe=Ne?zr(Ne,re,Se.Left,!0):de.from,je={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Si({x:ye.toHandle.x,y:ye.toHandle.y},me):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:mh[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};N(je),de=je}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(W||L)&&B&&M&&(C==null||C(B));const{inProgress:me,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(te),z=!1,M=!1,B=null,L=null,K.removeEventListener("mousemove",se),K.removeEventListener("mouseup",pe),K.removeEventListener("touchmove",se),K.removeEventListener("touchend",pe)}}K.addEventListener("mousemove",se),K.addEventListener("mouseup",pe),K.addEventListener("touchmove",se),K.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:y=kg,nodeLookup:m}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=en(t),C=d.elementFromPoint(_,k),S=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const I=Sg(void 0,S),N=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!N||!I)return E;const H={source:x?N:l,sourceHandle:x?j:a,target:x?l:N,targetHandle:x?a:j};E.connection=H;const K=R&&T&&(o===wi.Strict?x&&I==="source"||!x&&I==="target":N!==l||j!==a);E.isValid=K&&y(H),E.toHandle=_g(N,I,j,m,o,!0)}return E}const Zu={onPointerDown:T1,isValid:Eg};function R1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=At(t);function u({translateExtent:f,width:g,height:y,zoomStep:m=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=N.sourceEvent.ctrlKey&&Co()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=j[2]*Math.pow(2,T*R);r.scaleTo(H)};let C=[0,0];const S=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 j=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*H,y:j[1]-T[1]*H},K=[[0,0],[g,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},K,f)},I=Kp().on("start",S).on("zoom",x?E:null).on("zoom.wheel",v?k:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Kt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),tr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),L1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Tu=(t,r=0,o=L1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function A1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return m=>{if(tr(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const S=Kt(m),E=Cg(m),I=x*Math.pow(2,E);l.scaleTo(o,I,S,m);return}const v=m.deltaMode===1?20:1;let _=a===Ir.Vertical?0:m.deltaX*v,k=a===Ir.Horizontal?0:m.deltaY*v;!Co()&&m.shiftKey&&a!==Ir.Vertical&&(_=m.deltaY*v,k=0),l.translateBy(o,-(_/x)*u,-(k/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(m,C),t.isPanScrolling=!1},150)}}function z1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=tr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function D1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 $1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function O1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function F1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:m,connectionInProgress:x}){return v=>{var E;const _=r||o,k=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(tr(v,`${m}-flow__node`)||tr(v,`${m}-flow__edge`)||tr(v,`${m}-flow__selection`)||tr(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||tr(v,g)&&C||tr(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((E=v.touches)==null?void 0:E.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!k&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const S=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&S}}function H1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const y={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 v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),k=At(t).call(_);j({x:a.x,y:a.y,zoom:_i(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=k.on("wheel.zoom"),S=k.on("dblclick.zoom");_.wheelDelta(Cg);async function E(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:U,panOnDrag:D,panOnScrollMode:z,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:q,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:_e}){V&&!y.isZoomingOrPanning&&N();const me=U&&!fe&&!V;_.clickDistance(_e?1/0:!Jt(pe)||pe<0?0:pe);const ye=me?A1({zoomPanValues:y,noWheelClassName:J,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:B,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):z1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});k.on("wheel.zoom",ye,{passive:!1});const Ne=D1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=$1({zoomPanValues:y,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:q});_.on("zoom",Pe);const je=O1({zoomPanValues:y,panOnDrag:D,panOnScroll:U,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",je);const Me=F1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Me),re?k.on("dblclick.zoom",S):k.on("dblclick.zoom",null)}function N(){_.on("zoom",null)}async function j(J,b,Y){const V=Iu(J),U=_==null?void 0:_.constrain()(V,b,Y);return U&&await E(U),U}async function R(J,b){const Y=Iu(J);return await E(Y,b),Y}function T(J){if(k){const b=Iu(J),Y=k.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(k,b,null,{sync:!0}))}}function H(){const J=k?qp(k.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function K(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function te(J){_==null||_.scaleExtent(J)}function W(J){_==null||_.translateExtent(J)}function ee(J){const b=!Jt(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:N,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:G,scaleBy:K,setScaleExtent:te,setTranslateExtent:W,syncViewport:T,setClickDistance:ee}}var ki;(function(t){t.Line="line",t.Handle="handle"})(ki||(ki={}));function B1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Mh(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 Jn(t,r){return Math.max(0,r-t)}function er(t,r){return Math.max(0,t-r)}function Ks(t,r,o){return Math.max(0,r-t,t-o)}function Ph(t,r){return t?!r:r}function V1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:m,isVertical:x}=r,v=m&&x,{xSnapped:_,ySnapped:k}=o,{minWidth:C,maxWidth:S,minHeight:E,maxHeight:I}=l,{x:N,y:j,width:R,height:T,aspectRatio:H}=t;let G=Math.floor(m?_-t.pointerX:0),K=Math.floor(x?k-t.pointerY:0);const te=R+(g?-G:G),W=T+(y?-K:K),ee=-u[0]*R,J=-u[1]*T;let b=Ks(te,C,S),Y=Ks(W,E,I);if(d){let D=0,z=0;g&&G<0?D=Jn(N+G+ee,d[0][0]):!g&&G>0&&(D=er(N+te+ee,d[1][0])),y&&K<0?z=Jn(j+K+J,d[0][1]):!y&&K>0&&(z=er(j+W+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(f){let D=0,z=0;g&&G>0?D=er(N+G,f[0][0]):!g&&G<0&&(D=Jn(N+te,f[1][0])),y&&K>0?z=er(j+K,f[0][1]):!y&&K<0&&(z=Jn(j+W,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(a){if(m){const D=Ks(te/H,E,I)*H;if(b=Math.max(b,D),d){let z=0;!g&&!y||g&&!y&&v?z=er(j+J+te/H,d[1][1])*H:z=Jn(j+J+(g?G:-G)/H,d[0][1])*H,b=Math.max(b,z)}if(f){let z=0;!g&&!y||g&&!y&&v?z=Jn(j+te/H,f[1][1])*H:z=er(j+(g?G:-G)/H,f[0][1])*H,b=Math.max(b,z)}}if(x){const D=Ks(W*H,C,S)/H;if(Y=Math.max(Y,D),d){let z=0;!g&&!y||y&&!g&&v?z=er(N+W*H+ee,d[1][0])/H:z=Jn(N+(y?K:-K)*H+ee,d[0][0])/H,Y=Math.max(Y,z)}if(f){let z=0;!g&&!y||y&&!g&&v?z=Jn(N+W*H,f[1][0])/H:z=er(N+(y?K:-K)*H,f[0][0])/H,Y=Math.max(Y,z)}}}K=K+(K<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?te>W*H?K=(Ph(g,y)?-G:G)/H:G=(Ph(g,y)?-K:K)*H:m?(K=G/H,y=g):(G=K*H,g=y));const V=g?N+G:N,U=y?j+K:j;return{width:R+(g?-G:G),height:T+(y?-K:K),x:u[0]*G*(g?-1:1)+V,y:u[1]*K*(y?-1:1)+U}}const jg={width:0,height:0,x:0,y:0},U1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function W1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function Y1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=At(t);let d={controlDirection:Mh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:m,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:k,onResizeEnd:C,shouldResize:S}){let E={...jg},I={...U1};d={boundaries:m,resizeDirection:v,keepAspectRatio:x,controlDirection:Mh(y)};let N,j=null,R=[],T,H,G,K=!1;const te=zp().on("start",W=>{const{nodeLookup:ee,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:U}=o();if(N=ee.get(r),!N)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:z}=mo(W.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},I={...E,pointerX:D,pointerY:z,aspectRatio:E.width/E.height},T=void 0,H=Ar(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=ee.get(N.parentId)),T&&N.extent==="parent"&&(H=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[B,M]of ee)if(M.parentId===r&&(R.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=W1(M,N,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(W,{...E})}).on("drag",W=>{const{transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(W.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:b,containerBounds:j}),U=[];if(!N)return;const{x:D,y:z,width:B,height:M}=E,L={},ne=N.origin??Y,{width:re,height:ce,x:fe,y:de}=V1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,H,G),q=re!==B,se=ce!==M,pe=fe!==D&&q,_e=de!==z&&se;if(!pe&&!_e&&!q&&!se)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:E.x,L.y=_e?de:E.y,E.x=L.x,E.y=L.y,R.length>0)){const Pe=fe-D,je=de-z;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-B),y:Me.position.y-je+ne[1]*(ce-M)},U.push(Me)}if((q||se)&&(L.width=q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:E.width,L.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:E.height,E.width=L.width,E.height=L.height),T&&N.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{K&&(C==null||C(W,{...E}),a==null||a({...E}),K=!1)});u.call(te)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Ru={exports:{}},Lu={},Au={exports:{}},zu={};/** +`+h.stack}return{value:e,source:n,stack:c,digest:null}}function Wa(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function Ya(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var ky=typeof WeakMap=="function"?WeakMap:Map;function Kd(e,n,i){i=kn(-1,i),i.tag=3,i.payload={element:null};var s=n.value;return i.callback=function(){Ps||(Ps=!0,lu=s),Ya(e,n)},i}function Zd(e,n,i){i=kn(-1,i),i.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var c=n.value;i.payload=function(){return s(c)},i.callback=function(){Ya(e,n)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(i.callback=function(){Ya(e,n),typeof s!="function"&&(Xn===null?Xn=new Set([this]):Xn.add(this));var w=n.stack;this.componentDidCatch(n.value,{componentStack:w!==null?w:""})}),i}function Jd(e,n,i){var s=e.pingCache;if(s===null){s=e.pingCache=new ky;var c=new Set;s.set(n,c)}else c=s.get(n),c===void 0&&(c=new Set,s.set(n,c));c.has(i)||(c.add(i),e=Dy.bind(null,e,n,i),n.then(e,e))}function ef(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function tf(e,n,i,s,c){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=kn(-1,1),n.tag=2,Wn(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=c,e)}var Ey=j.ReactCurrentOwner,kt=!1;function vt(e,n,i,s){n.child=e===null?_d(n,null,i,s):oi(n,e.child,i,s)}function nf(e,n,i,s,c){i=i.render;var h=n.ref;return li(n,c),s=Da(e,n,i,s,h,c),i=$a(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~c,En(e,n,c)):(Be&&i&&wa(n),n.flags|=1,vt(e,n,s,c),n.child)}function rf(e,n,i,s,c){if(e===null){var h=i.type;return typeof h=="function"&&!pu(h)&&h.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=h,of(e,n,h,s,c)):(e=zs(i.type,null,s,n,n.mode,c),e.ref=n.ref,e.return=n,n.child=e)}if(h=e.child,(e.lanes&c)===0){var w=h.memoizedProps;if(i=i.compare,i=i!==null?i:Bi,i(w,s)&&e.ref===n.ref)return En(e,n,c)}return n.flags|=1,e=Kn(h,s),e.ref=n.ref,e.return=n,n.child=e}function of(e,n,i,s,c){if(e!==null){var h=e.memoizedProps;if(Bi(h,s)&&e.ref===n.ref)if(kt=!1,n.pendingProps=s=h,(e.lanes&c)!==0)(e.flags&131072)!==0&&(kt=!0);else return n.lanes=e.lanes,En(e,n,c)}return Xa(e,n,i,s,c)}function sf(e,n,i){var s=n.pendingProps,c=s.children,h=e!==null?e.memoizedState:null;if(s.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},De(di,Lt),Lt|=i;else{if((i&1073741824)===0)return e=h!==null?h.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,De(di,Lt),Lt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=h!==null?h.baseLanes:i,De(di,Lt),Lt|=s}else h!==null?(s=h.baseLanes|i,n.memoizedState=null):s=i,De(di,Lt),Lt|=s;return vt(e,n,c,i),n.child}function lf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Xa(e,n,i,s,c){var h=St(i)?yr:pt.current;return h=ti(n,h),li(n,c),i=Da(e,n,i,s,h,c),s=$a(),e!==null&&!kt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~c,En(e,n,c)):(Be&&s&&wa(n),n.flags|=1,vt(e,n,i,c),n.child)}function af(e,n,i,s,c){if(St(i)){var h=!0;ls(n)}else h=!1;if(li(n,c),n.stateNode===null)Ns(e,n),Qd(n,i,s),Ua(n,i,s,c),s=!0;else if(e===null){var w=n.stateNode,P=n.memoizedProps;w.props=P;var A=w.context,Z=i.contextType;typeof Z=="object"&&Z!==null?Z=Ft(Z):(Z=St(i)?yr:pt.current,Z=ti(n,Z));var oe=i.getDerivedStateFromProps,le=typeof oe=="function"||typeof w.getSnapshotBeforeUpdate=="function";le||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(P!==s||A!==Z)&&qd(n,w,s,Z),Un=!1;var ie=n.memoizedState;w.state=ie,ms(n,s,w,c),A=n.memoizedState,P!==s||ie!==A||_t.current||Un?(typeof oe=="function"&&(Va(n,i,oe,s),A=n.memoizedState),(P=Un||Gd(n,i,P,s,ie,A,Z))?(le||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(n.flags|=4194308)):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=s,n.memoizedState=A),w.props=s,w.state=A,w.context=Z,s=P):(typeof w.componentDidMount=="function"&&(n.flags|=4194308),s=!1)}else{w=n.stateNode,kd(e,n),P=n.memoizedProps,Z=n.type===n.elementType?P:Xt(n.type,P),w.props=Z,le=n.pendingProps,ie=w.context,A=i.contextType,typeof A=="object"&&A!==null?A=Ft(A):(A=St(i)?yr:pt.current,A=ti(n,A));var he=i.getDerivedStateFromProps;(oe=typeof he=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(P!==le||ie!==A)&&qd(n,w,s,A),Un=!1,ie=n.memoizedState,w.state=ie,ms(n,s,w,c);var ve=n.memoizedState;P!==le||ie!==ve||_t.current||Un?(typeof he=="function"&&(Va(n,i,he,s),ve=n.memoizedState),(Z=Un||Gd(n,i,Z,s,ie,ve,A)||!1)?(oe||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(s,ve,A),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(s,ve,A)),typeof w.componentDidUpdate=="function"&&(n.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof w.componentDidUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=1024),n.memoizedProps=s,n.memoizedState=ve),w.props=s,w.state=ve,w.context=A,s=Z):(typeof w.componentDidUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||P===e.memoizedProps&&ie===e.memoizedState||(n.flags|=1024),s=!1)}return Ga(e,n,i,s,h,c)}function Ga(e,n,i,s,c,h){lf(e,n);var w=(n.flags&128)!==0;if(!s&&!w)return c&&fd(n,i,!1),En(e,n,h);s=n.stateNode,Ey.current=n;var P=w&&typeof i.getDerivedStateFromError!="function"?null:s.render();return n.flags|=1,e!==null&&w?(n.child=oi(n,e.child,null,h),n.child=oi(n,null,P,h)):vt(e,n,P,h),n.memoizedState=s.state,c&&fd(n,i,!0),n.child}function uf(e){var n=e.stateNode;n.pendingContext?cd(e,n.pendingContext,n.pendingContext!==n.context):n.context&&cd(e,n.context,!1),Ia(e,n.containerInfo)}function cf(e,n,i,s,c){return ii(),Ea(c),n.flags|=256,vt(e,n,i,s),n.child}var Qa={dehydrated:null,treeContext:null,retryLane:0};function qa(e){return{baseLanes:e,cachePool:null,transitions:null}}function df(e,n,i){var s=n.pendingProps,c=We.current,h=!1,w=(n.flags&128)!==0,P;if((P=w)||(P=e!==null&&e.memoizedState===null?!1:(c&2)!==0),P?(h=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(c|=1),De(We,c&1),e===null)return ka(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(w=s.children,e=s.fallback,h?(s=n.mode,h=n.child,w={mode:"hidden",children:w},(s&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=w):h=Ds(w,s,0,null),e=jr(e,s,i,null),h.return=n,e.return=n,h.sibling=e,n.child=h,n.child.memoizedState=qa(i),n.memoizedState=Qa,e):Ka(n,w));if(c=e.memoizedState,c!==null&&(P=c.dehydrated,P!==null))return Ny(e,n,w,s,P,c,i);if(h){h=s.fallback,w=n.mode,c=e.child,P=c.sibling;var A={mode:"hidden",children:s.children};return(w&1)===0&&n.child!==c?(s=n.child,s.childLanes=0,s.pendingProps=A,n.deletions=null):(s=Kn(c,A),s.subtreeFlags=c.subtreeFlags&14680064),P!==null?h=Kn(P,h):(h=jr(h,w,i,null),h.flags|=2),h.return=n,s.return=n,s.sibling=h,n.child=s,s=h,h=n.child,w=e.child.memoizedState,w=w===null?qa(i):{baseLanes:w.baseLanes|i,cachePool:null,transitions:w.transitions},h.memoizedState=w,h.childLanes=e.childLanes&~i,n.memoizedState=Qa,s}return h=e.child,e=h.sibling,s=Kn(h,{mode:"visible",children:s.children}),(n.mode&1)===0&&(s.lanes=i),s.return=n,s.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=s,n.memoizedState=null,s}function Ka(e,n){return n=Ds({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Es(e,n,i,s){return s!==null&&Ea(s),oi(n,e.child,null,i),e=Ka(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Ny(e,n,i,s,c,h,w){if(i)return n.flags&256?(n.flags&=-257,s=Wa(Error(o(422))),Es(e,n,w,s)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(h=s.fallback,c=n.mode,s=Ds({mode:"visible",children:s.children},c,0,null),h=jr(h,c,w,null),h.flags|=2,s.return=n,h.return=n,s.sibling=h,n.child=s,(n.mode&1)!==0&&oi(n,e.child,null,w),n.child.memoizedState=qa(w),n.memoizedState=Qa,h);if((n.mode&1)===0)return Es(e,n,w,null);if(c.data==="$!"){if(s=c.nextSibling&&c.nextSibling.dataset,s)var P=s.dgst;return s=P,h=Error(o(419)),s=Wa(h,s,void 0),Es(e,n,w,s)}if(P=(w&e.childLanes)!==0,kt||P){if(s=lt,s!==null){switch(w&-w){case 4:c=2;break;case 16:c=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:c=32;break;case 536870912:c=268435456;break;default:c=0}c=(c&(s.suspendedLanes|w))!==0?0:c,c!==0&&c!==h.retryLane&&(h.retryLane=c,Sn(e,c),qt(s,e,c,-1))}return hu(),s=Wa(Error(o(421))),Es(e,n,w,s)}return c.data==="$?"?(n.flags|=128,n.child=e.child,n=$y.bind(null,e),c._reactRetry=n,null):(e=h.treeContext,Rt=Fn(c.nextSibling),Tt=n,Be=!0,Yt=null,e!==null&&($t[Ot++]=wn,$t[Ot++]=_n,$t[Ot++]=vr,wn=e.id,_n=e.overflow,vr=n),n=Ka(n,s.children),n.flags|=4096,n)}function ff(e,n,i){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n),ba(e.return,n,i)}function Za(e,n,i,s,c){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:s,tail:i,tailMode:c}:(h.isBackwards=n,h.rendering=null,h.renderingStartTime=0,h.last=s,h.tail=i,h.tailMode=c)}function hf(e,n,i){var s=n.pendingProps,c=s.revealOrder,h=s.tail;if(vt(e,n,s.children,i),s=We.current,(s&2)!==0)s=s&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ff(e,i,n);else if(e.tag===19)ff(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}s&=1}if(De(We,s),(n.mode&1)===0)n.memoizedState=null;else switch(c){case"forwards":for(i=n.child,c=null;i!==null;)e=i.alternate,e!==null&&ys(e)===null&&(c=i),i=i.sibling;i=c,i===null?(c=n.child,n.child=null):(c=i.sibling,i.sibling=null),Za(n,!1,c,i,h);break;case"backwards":for(i=null,c=n.child,n.child=null;c!==null;){if(e=c.alternate,e!==null&&ys(e)===null){n.child=c;break}e=c.sibling,c.sibling=i,i=c,c=e}Za(n,!0,i,null,h);break;case"together":Za(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Ns(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function En(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),kr|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Kn(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Kn(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Cy(e,n,i){switch(n.tag){case 3:uf(n),ii();break;case 5:Cd(n);break;case 1:St(n.type)&&ls(n);break;case 4:Ia(n,n.stateNode.containerInfo);break;case 10:var s=n.type._context,c=n.memoizedProps.value;De(hs,s._currentValue),s._currentValue=c;break;case 13:if(s=n.memoizedState,s!==null)return s.dehydrated!==null?(De(We,We.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?df(e,n,i):(De(We,We.current&1),e=En(e,n,i),e!==null?e.sibling:null);De(We,We.current&1);break;case 19:if(s=(i&n.childLanes)!==0,(e.flags&128)!==0){if(s)return hf(e,n,i);n.flags|=128}if(c=n.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),De(We,We.current),s)break;return null;case 22:case 23:return n.lanes=0,sf(e,n,i)}return En(e,n,i)}var pf,Ja,gf,mf;pf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Ja=function(){},gf=function(e,n,i,s){var c=e.memoizedProps;if(c!==s){e=n.stateNode,_r(un.current);var h=null;switch(i){case"input":c=Ne(e,c),s=Ne(e,s),h=[];break;case"select":c=B({},c,{value:void 0}),s=B({},s,{value:void 0}),h=[];break;case"textarea":c=bt(e,c),s=bt(e,s),h=[];break;default:typeof c.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=is)}or(i,s);var w;i=null;for(Z in c)if(!s.hasOwnProperty(Z)&&c.hasOwnProperty(Z)&&c[Z]!=null)if(Z==="style"){var P=c[Z];for(w in P)P.hasOwnProperty(w)&&(i||(i={}),i[w]="")}else Z!=="dangerouslySetInnerHTML"&&Z!=="children"&&Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&Z!=="autoFocus"&&(a.hasOwnProperty(Z)?h||(h=[]):(h=h||[]).push(Z,null));for(Z in s){var A=s[Z];if(P=c!=null?c[Z]:void 0,s.hasOwnProperty(Z)&&A!==P&&(A!=null||P!=null))if(Z==="style")if(P){for(w in P)!P.hasOwnProperty(w)||A&&A.hasOwnProperty(w)||(i||(i={}),i[w]="");for(w in A)A.hasOwnProperty(w)&&P[w]!==A[w]&&(i||(i={}),i[w]=A[w])}else i||(h||(h=[]),h.push(Z,i)),i=A;else Z==="dangerouslySetInnerHTML"?(A=A?A.__html:void 0,P=P?P.__html:void 0,A!=null&&P!==A&&(h=h||[]).push(Z,A)):Z==="children"?typeof A!="string"&&typeof A!="number"||(h=h||[]).push(Z,""+A):Z!=="suppressContentEditableWarning"&&Z!=="suppressHydrationWarning"&&(a.hasOwnProperty(Z)?(A!=null&&Z==="onScroll"&&Oe("scroll",e),h||P===A||(h=[])):(h=h||[]).push(Z,A))}i&&(h=h||[]).push("style",i);var Z=h;(n.updateQueue=Z)&&(n.flags|=4)}},mf=function(e,n,i,s){i!==s&&(n.flags|=4)};function ro(e,n){if(!Be)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var s=null;i!==null;)i.alternate!==null&&(s=i),i=i.sibling;s===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function mt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,s=0;if(n)for(var c=e.child;c!==null;)i|=c.lanes|c.childLanes,s|=c.subtreeFlags&14680064,s|=c.flags&14680064,c.return=e,c=c.sibling;else for(c=e.child;c!==null;)i|=c.lanes|c.childLanes,s|=c.subtreeFlags,s|=c.flags,c.return=e,c=c.sibling;return e.subtreeFlags|=s,e.childLanes=i,n}function jy(e,n,i){var s=n.pendingProps;switch(_a(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mt(n),null;case 1:return St(n.type)&&ss(),mt(n),null;case 3:return s=n.stateNode,ai(),Fe(_t),Fe(pt),La(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(ds(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Yt!==null&&(cu(Yt),Yt=null))),Ja(e,n),mt(n),null;case 5:Ta(n);var c=_r(Zi.current);if(i=n.type,e!==null&&n.stateNode!=null)gf(e,n,i,s,c),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!s){if(n.stateNode===null)throw Error(o(166));return mt(n),null}if(e=_r(un.current),ds(n)){s=n.stateNode,i=n.type;var h=n.memoizedProps;switch(s[an]=n,s[Xi]=h,e=(n.mode&1)!==0,i){case"dialog":Oe("cancel",s),Oe("close",s);break;case"iframe":case"object":case"embed":Oe("load",s);break;case"video":case"audio":for(c=0;c<\/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[an]=n,e[Xi]=s,pf(e,n,!1,!1),n.stateNode=e;e:{switch(w=Pn(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cfi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return mt(n),null}else 2*Ue()-h.renderingStartTime>fi&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(mt(n),null);case 22:case 23:return fu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Lt&1073741824)!==0&&(mt(n),n.subtreeFlags&6&&(n.flags|=8192)):mt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(_a(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ai(),Fe(_t),Fe(pt),La(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ta(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ii()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return ai(),null;case 10:return ja(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Cs=!1,yt=!1,My=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ci(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Qe(e,n,s)}else i.current=null}function eu(e,n,i){try{i()}catch(s){Qe(e,n,s)}}var yf=!1;function Py(e,n){if(fa=Yo,e=Gc(),ia(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,P=-1,A=-1,Z=0,oe=0,le=e,ie=null;t:for(;;){for(var he;le!==i||c!==0&&le.nodeType!==3||(P=w+c),le!==h||s!==0&&le.nodeType!==3||(A=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)ie=le,le=he;for(;;){if(le===e)break t;if(ie===i&&++Z===c&&(P=w),ie===h&&++oe===s&&(A=w),(he=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=he}i=P===-1||A===-1?null:{start:P,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(ha={focusedElem:e,selectionRange:i},Yo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,Ke=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Xt(n.type,xe),Ke);X.__reactInternalSnapshotBeforeUpdate=O}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){Qe(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=yf,yf=!1,ve}function io(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&&eu(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function tu(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 vf(e){var n=e.alternate;n!==null&&(e.alternate=null,vf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[an],delete n[Xi],delete n[ya],delete n[fy],delete n[hy])),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 xf(e){return e.tag===5||e.tag===3||e.tag===4}function wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 nu(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=is));else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}function ru(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(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}var dt=null,Gt=!1;function Yn(e,n,i){for(i=i.child;i!==null;)_f(e,n,i),i=i.sibling}function _f(e,n,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Br,i)}catch{}switch(i.tag){case 5:yt||ci(i,n);case 6:var s=dt,c=Gt;dt=null,Yn(e,n,i),dt=s,Gt=c,dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?ma(e.parentNode,i):e.nodeType===1&&ma(e,i),zi(e)):ma(dt,i.stateNode));break;case 4:s=dt,c=Gt,dt=i.stateNode.containerInfo,Gt=!0,Yn(e,n,i),dt=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!yt&&(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)&&eu(i,n,w),c=c.next}while(c!==s)}Yn(e,n,i);break;case 1:if(!yt&&(ci(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Qe(i,n,P)}Yn(e,n,i);break;case 21:Yn(e,n,i);break;case 22:i.mode&1?(yt=(s=yt)||i.memoizedState!==null,Yn(e,n,i),yt=s):Yn(e,n,i);break;default:Yn(e,n,i)}}function Sf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,Gn===null)var s=!1;else{if(e=Gn,Gn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var P=h.deletions;if(P!==null){for(var A=0;AUe()-su?Nr(e,0):ou|=i),Nt(e,n)}function Af(e,n){n===0&&((e.mode&1)===0?n=1:(n=Ur,Ur<<=1,(Ur&130023424)===0&&(Ur=4194304)));var i=xt();e=Sn(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Af(e,i)}function Oy(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),Af(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&pd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ti(n,pt.current);li(n,i),c=Da(null,n,s,e,c,i);var h=$a();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Ua(n,s,e,i),n=Ga(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&wa(n),vt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Xt(s,e),c){case 0:n=Xa(null,n,s,e,i);break e;case 1:n=af(null,n,s,e,i);break e;case 11:n=nf(null,n,s,e,i);break e;case 14:n=rf(null,n,s,Xt(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:Xt(s,c),Xa(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),af(e,n,s,c,i);case 3:e:{if(uf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,kd(e,n),ms(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=ui(Error(o(423)),n),n=cf(e,n,s,i,c);break e}else if(s!==c){c=ui(Error(o(424)),n),n=cf(e,n,s,i,c);break e}else for(Rt=Fn(n.stateNode.containerInfo.firstChild),Tt=n,Be=!0,Yt=null,i=_d(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ii(),s===c){n=En(e,n,i);break e}vt(e,n,s,i)}n=n.child}return n;case 5:return Cd(n),e===null&&ka(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,pa(s,c)?w=null:h!==null&&pa(s,h)&&(n.flags|=32),lf(e,n),vt(e,n,w,i),n.child;case 6:return e===null&&ka(n),null;case 13:return df(e,n,i);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=oi(n,null,s,i):vt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),nf(e,n,s,c,i);case 7:return vt(e,n,n.pendingProps,i),n.child;case 8:return vt(e,n,n.pendingProps.children,i),n.child;case 12:return vt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!_t.current){n=En(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var A=P.firstContext;A!==null;){if(A.context===s){if(h.tag===1){A=kn(-1,i&-i),A.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var oe=Z.pending;oe===null?A.next=A:(A.next=oe.next,oe.next=A),Z.pending=A}}h.lanes|=i,A=h.alternate,A!==null&&(A.lanes|=i),ba(h.return,i,n),P.lanes|=i;break}A=A.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,P=w.alternate,P!==null&&(P.lanes|=i),ba(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}vt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,li(n,i),c=Ft(c),s=s(c),n.flags|=1,vt(e,n,s,i),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),rf(e,n,s,c,i);case 15:return of(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,li(n,i),Qd(n,s,c),Ua(n,s,c,i),Ga(null,n,s,!0,e,i);case 19:return hf(e,n,i);case 22:return sf(e,n,i)}throw Error(o(156,n.tag))};function Df(e,n){return Do(e,n)}function Fy(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 Fy(e,n,i,s)}function pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===Y)return 14}return 2}function Kn(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 zs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")pu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case K:return e=Vt(12,i,n,c|2),e.elementType=K,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Vt(19,i,n,c),e.elementType=b,e.lanes=h,e;case U:return Ds(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case W:w=9;break e;case ee:w=11;break e;case Y: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 jr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function gu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function mu(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 By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function yu(e,n,i,s,c,h,w,P,A){return e=new By(e,n,i,P,A),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},Pa(h),e}function Vy(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(),ku.exports=t0(),ku.exports}var Kf;function n0(){if(Kf)return Us;Kf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function Mr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function $r({className:t,children:r}){return p.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 a0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function u0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function c0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function d0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function f0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function h0({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const p0="modulepreload",g0=function(t,r){return new URL(t,r).href},Zf={},m0=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(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(m=>{if(m=g0(m,l),m in Zf)return;Zf[m]=!0;const x=m.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const S=f[C];if(S.href===m&&(!x||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":p0,x||(k.as="script"),k.crossOrigin="",k.href=m,y&&k.setAttribute("nonce",y),document.head.appendChild(k),x)return new Promise((C,S)=>{k.addEventListener("load",C),k.addEventListener("error",()=>S(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 et(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=v0(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)),eh.hasOwnProperty(r)?{space:eh[r],local:t}:t}function w0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Fu&&r.documentElement.namespaceURI===Fu?r.createElement(t):r.createElementNS(o,t)}}function _0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?_0:w0)(r)}function S0(){}function nc(t){return t==null?S0:function(){return this.querySelector(t)}}function k0(t){typeof t!="function"&&(t=nc(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=I+1);!(R=S[N])&&++N=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function G0(t){t||(t=Q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function q0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function K0(){return Array.from(this)}function Z0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?uv:typeof r=="function"?dv:cv)(t,r,o??"")):vi(this.node(),t)}function vi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function hv(t){return function(){delete this[t]}}function pv(t,r){return function(){this[t]=r}}function gv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function mv(t,r){return arguments.length>1?this.each((r==null?hv:typeof r=="function"?gv:pv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function rc(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=rc(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Uv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Hu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:y,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:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:m}})}Hu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ex(t){return!t.ctrlKey&&!t.button}function tx(){return this.parentNode}function nx(t,r){return r??{x:t.x,y:t.y}}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=ex,r=tx,o=nx,l=rx,a={},u=vl("start","drag","end"),d=0,f,g,y,m,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",S).on("touchmove.drag",E,Jv).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(m||!t.call(this,j,R))){var T=N(this,r.call(this,j,R),j,R,"mouse");T&&(At(j.view).on("mousemove.drag",k,vo).on("mouseup.drag",C,vo),Lp(j.view),Cu(j),y=!1,f=j.clientX,g=j.clientY,T("start",j))}}function k(j){if(mi(j),!y){var R=j.clientX-f,T=j.clientY-g;y=R*R+T*T>x}a.mouse("drag",j)}function C(j){At(j.view).on("mousemove.drag mouseup.drag",null),Ap(j.view,y),mi(j),a.mouse("end",j)}function S(j,R){if(t.call(this,j,R)){var T=j.changedTouches,H=r.call(this,j,R),G=T.length,K,te;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=ox.exec(t))?new jt(r[1],r[2],r[3],1):(r=sx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=lx.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ax.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ux.exec(t))?lh(r[1],r[2]/100,r[3]/100,1):(r=cx.exec(t))?lh(r[1],r[2]/100,r[3]/100,r[4]):th.hasOwnProperty(t)?ih(th[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function ih(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function hx(t){return t instanceof Po||(t=Rr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Bu(t,r,o,l){return arguments.length===1?hx(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}ic(jt,Bu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Ir(this.r),Ir(this.g),Ir(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:oh,formatHex:oh,formatHex8:px,formatRgb:sh,toString:sh}));function oh(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}`}function px(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}${Pr((isNaN(this.opacity)?1:this.opacity)*255)}`}function sh(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Ir(this.r)}, ${Ir(this.g)}, ${Ir(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ir(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Pr(t){return t=Ir(t),(t<16?"0":"")+t.toString(16)}function lh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,o,l)}function $p(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Rr(t)),!t)return new Zt;if(t instanceof Zt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Zt(d,f,g,t.opacity)}function gx(t,r,o,l){return arguments.length===1?$p(t):new Zt(t,r,o,l??1)}function Zt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}ic(Zt,gx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Zt(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 jt(ju(t>=240?t-240:t+120,a,l),ju(t,a,l),ju(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(ah(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${ah(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ah(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function ju(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 oc=t=>()=>t;function mx(t,r){return function(o){return t+o*r}}function yx(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 vx(t){return(t=+t)==1?Op:function(r,o){return o-r?yx(r,o,t):oc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?mx(t,o):oc(isNaN(t)?r:t)}const ul=(function t(r){var o=vx(r);function l(a,u){var d=o((a=Bu(a)).r,(u=Bu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Op(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=g(m),a.opacity=y(m),a+""}}return l.gamma=t,l})(1);function xx(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,g.push({i:d,x:fn(l,a)})),o=bu.lastIndex;return o180?m+=360:m-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:fn(y,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(y,m,x,v){y!==m?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:fn(y,m)}):m&&x.push(a(x)+"skewX("+m+l)}function g(y,m,x,v,_,k){if(y!==x||m!==v){var C=_.push(a(_)+"scale(",null,",",null,")");k.push({i:C-4,x:fn(y,x)},{i:C-2,x:fn(m,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,m){var x=[],v=[];return y=t(y),m=t(m),u(y.translateX,y.translateY,m.translateX,m.translateY,x,v),d(y.rotate,m.rotate,x,v),f(y.skewX,m.skewX,x,v),g(y.scaleX,y.scaleY,m.scaleX,m.scaleY,x,v),y=m=null,function(_){for(var k=-1,C=v.length,S;++k=0&&t._call.call(void 0,r),t=t._next;--xi}function dh(){Lr=(dl=_o.now())+wl,xi=ho=0;try{Lx()}finally{xi=0,zx(),Lr=0}}function Ax(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function zx(){for(var t,r=cl,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:cl=o);po=t,Wu(l)}function Wu(t){if(!xi){ho&&(ho=clearTimeout(ho));var r=t-Lr;r>24?(t<1/0&&(ho=setTimeout(dh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(Ax,Vp)),xi=1,Up(dh))}}function fh(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Dx=vl("start","end","cancel","interrupt"),$x=[],Yp=0,hh=1,Yu=2,rl=3,ph=4,Xu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Ox(t,o,{name:r,index:l,group:a,on:Dx,tween:$x,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function lc(t,r){var o=nn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function pn(t,r){var o=nn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function nn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Ox(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(y){o.state=hh,o.timer.restart(d,o.delay,o.time),o.delay<=y&&d(y-o.delay)}function d(y){var m,x,v,_;if(o.state!==hh)return g();for(m in l)if(_=l[m],_.name===o.name){if(_.state===rl)return fh(d);_.state===ph?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[m]):+mYu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function gw(t,r,o){var l,a,u=pw(r)?lc:pn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function mw(t,r){var o=this._id;return arguments.length<2?nn(this.node(),o).on.on(t):this.each(gw(o,t,r))}function yw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function vw(){return this.on("end.remove",yw(this._id))}function xw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=nc(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Uw(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 jn(t,r,o){this.k=t,this.x=r,this.y=o}jn.prototype={constructor:jn,scale:function(t){return t===1?this:new jn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new jn(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 Sl=new jn(1,0,0);qp.prototype=jn.prototype;function qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Ww(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Yw(){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 gh(){return this.__zoom||Sl}function Xw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Gw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(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 Kp(){var t=Ww,r=Yw,o=Qw,l=Xw,a=Gw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,y=vl("start","zoom","end"),m,x,v,_=500,k=150,C=0,S=10;function E(b){b.property("__zoom",gh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",W).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(b,Y,V,U){var D=b.selection?b.selection():b;D.property("__zoom",gh),b!==D?R(b,Y,V,U):D.interrupt().each(function(){T(this,arguments).event(U).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},E.scaleBy=function(b,Y,V,U){E.scaleTo(b,function(){var D=this.__zoom.k,z=typeof Y=="function"?Y.apply(this,arguments):Y;return D*z},V,U)},E.scaleTo=function(b,Y,V,U){E.transform(b,function(){var D=r.apply(this,arguments),z=this.__zoom,B=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=z.invert(B),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(N(I(z,L),B,M),D,d)},V,U)},E.translateBy=function(b,Y,V,U){E.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,U)},E.translateTo=function(b,Y,V,U,D){E.transform(b,function(){var z=r.apply(this,arguments),B=this.__zoom,M=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Sl.translate(M[0],M[1]).scale(B.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),z,d)},U,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new jn(Y,b.x,b.y)}function N(b,Y,V){var U=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return U===b.x&&D===b.y?b:new jn(b.k,U,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,U){b.on("start.zoom",function(){T(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,B=T(D,z).event(U),M=r.apply(D,z),L=V==null?j(M):typeof V=="function"?V.apply(D,z):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,z):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var q=fe(de),se=ne/q[2];de=new jn(se,L[0]-q[0]*se,L[1]-q[1]*se)}B.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new H(b,Y)}function H(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}H.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=At(this.that).datum();y.call(b,this.that,new Uw(b,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),U=this.__zoom,D=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=Kt(b);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=U.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(U.k===D)return;V.mouse=[z,U.invert(z)],ol(this),V.start()}fo(b),V.wheel=setTimeout(B,k),V.zoom("mouse",o(N(I(U,D),V.mouse[0],V.mouse[1]),V.extent,d));function B(){V.wheel=null,V.end()}}function K(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,U=T(this,Y,!0).event(b),D=At(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),z=Kt(b,V),B=b.clientX,M=b.clientY;Lp(b.view),Mu(b),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function L(re){if(fo(re),!U.moved){var ce=re.clientX-B,fe=re.clientY-M;U.moved=ce*ce+fe*fe>C}U.event(re).zoom("mouse",o(N(U.that.__zoom,U.mouse[0]=Kt(re,V),U.mouse[1]),U.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),Ap(re.view,U.moved),fo(re),U.event(re).end()}}function te(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,U=Kt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(U),z=V.k*(b.shiftKey?.5:2),B=o(N(I(V,z),U,D),r.apply(this,Y),d);fo(b),f>0?At(this).transition().duration(f).call(R,B,U,b):At(this).call(E.transform,B,U,b)}}function W(b,...Y){if(t.apply(this,arguments)){var V=b.touches,U=V.length,D=T(this,Y,b.changedTouches.length===U).event(b),z,B,M,L;for(Mu(b),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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 wi;(function(t){t.Strict="strict",t.Loose="loose"})(wi||(wi={}));var Tr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Tr||(Tr={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var nr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(nr||(nr={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const mh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,qw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),uc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=rn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Kw=(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):uc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},cc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,y=r.width/a,m=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:k=!0,hidden:C=!1}=v;if(d&&!k||C)continue;const S=_.width??v.width??v.initialWidth??0,E=_.height??v.height??v.initialHeight??0,{x:I,y:N}=v.internals.positionAbsolute,j=sg(f,g,y,m,I,N,S,E),R=S*E,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Zw=(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 Jw(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}=rn(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 e1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Jw(t,d),g=To(f),y=fc(g,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(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y}=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",tn.error005());else{const{width:_,height:k}=rn(f);_&&k&&(x=[[g,y],[g+_,y+k]])}else f&&zr(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+y],[d.extent[1][0]+g,d.extent[1][1]+y]]);const v=zr(x)?Ar(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-g+(d.measured.width??0)*m[0],y:v.y-y+(d.measured.height??0)*m[1]},positionAbsolute:v}}async function t1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),k=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||k)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),m=Zw(d,g);for(const v of g)f.has(v.id)&&!m.find(k=>k.id===v.id)&&m.push(v);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 _i=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Ar=(t={x:0,y:0},r,o)=>({x:_i(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:_i(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=rn(o),{x:u,y:d}=o.internals.positionAbsolute;return Ar(t,[[u,d],[u+l,d+a]],r)}const yh=(t,r,o)=>to?-_i(Math.abs(t-o),1,r)/r:0,dc=(t,r,o=15,l=40)=>{const a=yh(t.x,l,r.width-l)*o,u=yh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Gu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Gu(t),Gu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*y)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),vh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Si=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function pi(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 n1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=pi(t,o),a=pi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=pi(t.top??t.y??0,o),a=pi(t.bottom??t.y??0,o),u=pi(t.left??t.x??0,r),d=pi(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 r1(t,r,o,l,a,u){const{x:d,y:f}=Si(t,[r,o,l]),{x:g,y}=Si({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-g,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const fc=(t,r,o,l,a,u)=>{const d=n1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,y=Math.min(f,g),m=_i(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*m,k=o/2-v*m,C=r1(t,_,k,m,r,o),S={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.left+S.right,y:k-S.top+S.bottom,zoom:m}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function zr(t){return t!=null&&t!=="parent"}function rn(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 ag(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 ug(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 xh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function i1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const hc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},s1=["INPUT","SELECT","TEXTAREA"];function dg(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:s1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,en=(t,r)=>{var u,d;const o=fg(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)}},wh=(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,...hc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,y=r*.125+u*.375+f*.375+l*.125,m=Math.abs(g-t),x=Math.abs(y-r);return[g,y,m,x]}function qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function _h({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 pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=_h({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[y,m]=_h({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,k]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:m});return[`M${t},${r} C${f},${g} ${y},${m} ${l},${a}`,x,v,_,k]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const u1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,c1=(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)),d1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",tn.error006()),r;const l=o.getEdgeId||u1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},c1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const Sh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},f1=({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 h1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=Sh[r],g=Sh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+g.x*u,y:o.y+g.y*u},x=f1({source:y,sourcePosition:r,target:m}),v=x.x!==0?"x":"y",_=x[v];let k=[],C,S;const E={x:0,y:0},I={x:0,y:0},[,,N,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??y.x+(m.x-y.x)*d,S=a.y??(y.y+m.y)/2):(C=a.x??(y.x+m.x)/2,S=a.y??y.y+(m.y-y.y)*d);const G=[{x:C,y:y.y},{x:C,y:m.y}],K=[{x:y.x,y:S},{x:m.x,y:S}];f[v]===_?k=v==="x"?G:K:k=v==="x"?K:G}else{const G=[{x:y.x,y:m.y}],K=[{x:m.x,y:y.y}];if(v==="x"?k=f.x===_?K:G:k=f.y===_?G:K,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?E[v]=(y[v]>t[v]?-1:1)*Y:I[v]=(m[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=y[b]>m[b],U=y[b]=J?(C=(te.x+W.x)/2,S=k[0].y):(C=k[0].x,S=(te.y+W.y)/2)}const R={x:y.x+E.x,y:y.y+E.y},T={x:m.x+I.x,y:m.y+I.y};return[[t,...R.x!==k[0].x||R.y!==k[0].y?[R]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],o],C,S,N,j]}function p1(t,r,o,l){const a=Math.min(kh(t,r)/2,kh(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 y=t.xo.id===r):t[0])||null}function qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(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(g=>{if(g&&typeof g=="object"){const y=qu(g,r);u.has(y)||(d.push({id:y,color:g.color||o,...g}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,y1=10,pc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},v1={...pc,checkEquality:!0};function gc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function x1(t,r,o){const l=gc(pc,o);for(const a of t.values())if(a.parentId)yc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=zr(a.extent)?a.extent:l.nodeExtent,f=Ar(u,d,rn(a));a.internals.positionAbsolute=f}}function w1(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 mc(t){return t==="manual"}function Ku(t,r,o,l={}){var m,x;const a=gc(v1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!mc(a.zIndexMode)?yg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const k=Io(v,a.nodeOrigin),C=zr(v.extent)?v.extent:a.nodeExtent,S=Ar(k,C,rn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:S,handleBounds:w1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&yc(_,r,o,l,u),y||(y=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function _1(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 yc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=gc(pc,l),y=t.parentId,m=r.get(y);if(!m){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&g==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*y1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!mc(g)?yg:0,{x:v,y:_,z:k}=S1(t,m,d,f,x,g),{positionAbsolute:C}=t.internals,S=v!==C.x||_!==C.y;(S||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:S?{x:v,y:_}:C,z:k}})}function vg(t,r,o){const l=Jt(t.zIndex)?t.zIndex:0;return mc(o)?l:l+(t.selected?r:0)}function S1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=rn(t),y=Io(t,o),m=zr(t.extent)?Ar(y,t.extent,g):y;let x=Ar({x:d+m.x,y:f+m.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function vc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),m=og(y,f.rect);u.set(f.parentId,{expandedRect:m,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var N;const m=g.internals.positionAbsolute,x=rn(g),v=g.origin??l,_=f.x0||k>0||E||I)&&(a.push({id:y,type:"position",position:{x:g.position.x-_+E,y:g.position.y-k+I}}),(N=o.get(y))==null||N.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(x.width0){const _=vc(v,r,o,a);y.push(..._)}return{changes:y,updatedInternals:g}}async function E1({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 jh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;jh("source",g,m,t,a,d),jh("target",g,y,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function bh(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 N1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Pu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[y,m]of r){const x=(d=o.get(y))==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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function C1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function j1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,y={x:0,y:0},m=null,x=!1,v=null,_=!1,k=!1,C=null;function S({noDragClassName:I,handleSelector:N,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:H=0}){v=At(j);function G({x:ee,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:U,nodeOrigin:D,onNodeDrag:z,onSelectionDrag:B,onError:M,updateNodePositions:L}=r();u={x:ee,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Gu(To(f)):null,fe=re&&U?C1({dragItems:f,snapGrid:V,x:ee,y:J}):null;for(const[de,q]of f){if(!b.has(de))continue;let se={x:ee-q.distance.x,y:J-q.distance.y};U&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:Ro(se,V));let pe=null;if(re&&Y&&!q.extent&&ce){const{positionAbsolute:ye}=q.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+q.measured.width-ce.x2+Y[1][0],je=ye.y-ce.y+Y[0][1],Me=ye.y+q.measured.height-ce.y2+Y[1][1];pe=[[Ne,je],[Pe,Me]]}const{position:_e,positionAbsolute:me}=rg({nodeId:de,nextPosition:se,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||q.position.x!==_e.x||q.position.y!==_e.y,q.position=_e,q.internals.positionAbsolute=me}if(k=k||ne,!!ne&&(L(f,!0),C&&(l||z||!T&&B))){const[de,q]=Pu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,q),z==null||z(C,de,q),T||B==null||B(C,q)}}async function K(){if(!m)return;const{transform:ee,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,U]=dc(y,m,b);(V!==0||U!==0)&&(u.x=(u.x??0)-V/ee[2],u.y=(u.y??0)-U/ee[2],await J({x:V,y:U})&&G(u)),d=requestAnimationFrame(K)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:U,snapToGrid:D,selectNodesOnDrag:z,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!z||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&z&&T&&(t==null||t(T));const ne=mo(ee.sourceEvent,{transform:V,snapGrid:U,snapToGrid:D,containerBounds:m});if(u=ne,f=N1(J,Y,ne,T),f.size>0&&(o||B||!T&&M)){const[ce,fe]=Pu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(ee.sourceEvent,f,ce,fe),B==null||B(ee.sourceEvent,ce,fe),T||M==null||M(ee.sourceEvent,fe)}}const W=zp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:U}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,k=!1,C=ee.sourceEvent,b===0&&te(ee),u=mo(ee.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:U,containerBounds:m}),y=en(ee.sourceEvent,m)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:U,nodeLookup:D}=r(),z=mo(ee.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:m});if(C=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,K()),!x){const B=en(ee.sourceEvent,m),M=B.x-y.x,L=B.y-y.y;Math.sqrt(M*M+L*L)>U&&te(ee)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(y=en(ee.sourceEvent,m),G(z))}}).on("end",ee=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(k&&(b(f,!1),k=!1),a||Y||!T&&V){const[U,D]=Pu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,f,U,D),Y==null||Y(ee.sourceEvent,U,D),T||V==null||V(ee.sourceEvent,D)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!I||!bh(J,`.${I}`,j))&&(!N||bh(J,N,j))});v.call(W)}function E(){v==null||v.on(".drag",null)}return{update:S,destroy:E}}function b1(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())pl(a,No(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,o,l){var f,g;let a=[],u=1/0;const d=b1(t,o,r+M1);for(const y of d){const m=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=Dr(y,x,x.position,!0),k=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=l.type==="source"?"target":"source";return a.find(m=>m.type===y)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var y,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...Dr(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function T1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:m,flowId:x,panBy:v,cancelConnection:_,onConnectStart:k,onConnect:C,onConnectEnd:S,isValidConnection:E=kg,onReconnectEnd:I,updateConnection:N,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:H=1,handleDomNode:G}){const K=cg(t.target);let te=0,W;const{x:ee,y:J}=en(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const U=_g(a,b,l,g,r);if(!U)return;let D=en(t,Y),z=!1,B=null,M=!1,L=null;function ne(){if(!m||!Y)return;const[_e,me]=dc(D,Y,T);v({x:_e,y:me}),te=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:b,position:U.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:Dr(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:mh[re.position],toNode:null,pointer:D};function q(){V=!0,N(de),k==null||k(t,{nodeId:a,handleId:l,handleType:b})}H===0&&q();function se(_e){if(!V){const{x:Me,y:tt}=en(_e),Ge=Me-ee,nt=tt-J;if(!(Ge*Ge+nt*nt>H*H))return;q()}if(!R()||!re){pe(_e);return}const me=j();D=en(_e,Y),W=P1(Lo(D,me,!1,[1,1]),o,g,re),z||(ne(),z=!0);const ye=Eg(_e,{handle:W,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:y,flowId:x,nodeLookup:g});L=ye.handleDomNode,B=ye.connection,M=I1(!!W,ye.isValid);const Ne=g.get(a),Pe=Ne?Dr(Ne,re,Se.Left,!0):de.from,je={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Si({x:ye.toHandle.x,y:ye.toHandle.y},me):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:mh[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};N(je),de=je}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(W||L)&&B&&M&&(C==null||C(B));const{inProgress:me,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(te),z=!1,M=!1,B=null,L=null,K.removeEventListener("mousemove",se),K.removeEventListener("mouseup",pe),K.removeEventListener("touchmove",se),K.removeEventListener("touchend",pe)}}K.addEventListener("mousemove",se),K.addEventListener("mouseup",pe),K.addEventListener("touchmove",se),K.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:y=kg,nodeLookup:m}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=en(t),C=d.elementFromPoint(_,k),S=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const I=Sg(void 0,S),N=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!N||!I)return E;const H={source:x?N:l,sourceHandle:x?j:a,target:x?l:N,targetHandle:x?a:j};E.connection=H;const K=R&&T&&(o===wi.Strict?x&&I==="source"||!x&&I==="target":N!==l||j!==a);E.isValid=K&&y(H),E.toHandle=_g(N,I,j,m,o,!0)}return E}const Zu={onPointerDown:T1,isValid:Eg};function R1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=At(t);function u({translateExtent:f,width:g,height:y,zoomStep:m=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=N.sourceEvent.ctrlKey&&Co()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=j[2]*Math.pow(2,T*R);r.scaleTo(H)};let C=[0,0];const S=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 j=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*H,y:j[1]-T[1]*H},K=[[0,0],[g,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},K,f)},I=Kp().on("start",S).on("zoom",x?E:null).on("zoom.wheel",v?k:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Kt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),tr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),L1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Tu=(t,r=0,o=L1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function A1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return m=>{if(tr(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const S=Kt(m),E=Cg(m),I=x*Math.pow(2,E);l.scaleTo(o,I,S,m);return}const v=m.deltaMode===1?20:1;let _=a===Tr.Vertical?0:m.deltaX*v,k=a===Tr.Horizontal?0:m.deltaY*v;!Co()&&m.shiftKey&&a!==Tr.Vertical&&(_=m.deltaY*v,k=0),l.translateBy(o,-(_/x)*u,-(k/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(m,C),t.isPanScrolling=!1},150)}}function z1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=tr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function D1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 $1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function O1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function F1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:m,connectionInProgress:x}){return v=>{var E;const _=r||o,k=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(tr(v,`${m}-flow__node`)||tr(v,`${m}-flow__edge`)||tr(v,`${m}-flow__selection`)||tr(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||tr(v,g)&&C||tr(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((E=v.touches)==null?void 0:E.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!k&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const S=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&S}}function H1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const y={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 v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),k=At(t).call(_);j({x:a.x,y:a.y,zoom:_i(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=k.on("wheel.zoom"),S=k.on("dblclick.zoom");_.wheelDelta(Cg);async function E(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:U,panOnDrag:D,panOnScrollMode:z,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:q,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:_e}){V&&!y.isZoomingOrPanning&&N();const me=U&&!fe&&!V;_.clickDistance(_e?1/0:!Jt(pe)||pe<0?0:pe);const ye=me?A1({zoomPanValues:y,noWheelClassName:J,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:B,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):z1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});k.on("wheel.zoom",ye,{passive:!1});const Ne=D1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=$1({zoomPanValues:y,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:q});_.on("zoom",Pe);const je=O1({zoomPanValues:y,panOnDrag:D,panOnScroll:U,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",je);const Me=F1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Me),re?k.on("dblclick.zoom",S):k.on("dblclick.zoom",null)}function N(){_.on("zoom",null)}async function j(J,b,Y){const V=Iu(J),U=_==null?void 0:_.constrain()(V,b,Y);return U&&await E(U),U}async function R(J,b){const Y=Iu(J);return await E(Y,b),Y}function T(J){if(k){const b=Iu(J),Y=k.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(k,b,null,{sync:!0}))}}function H(){const J=k?qp(k.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function K(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function te(J){_==null||_.scaleExtent(J)}function W(J){_==null||_.translateExtent(J)}function ee(J){const b=!Jt(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:N,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:G,scaleBy:K,setScaleExtent:te,setTranslateExtent:W,syncViewport:T,setClickDistance:ee}}var ki;(function(t){t.Line="line",t.Handle="handle"})(ki||(ki={}));function B1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Mh(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 Jn(t,r){return Math.max(0,r-t)}function er(t,r){return Math.max(0,t-r)}function Ks(t,r,o){return Math.max(0,r-t,t-o)}function Ph(t,r){return t?!r:r}function V1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:m,isVertical:x}=r,v=m&&x,{xSnapped:_,ySnapped:k}=o,{minWidth:C,maxWidth:S,minHeight:E,maxHeight:I}=l,{x:N,y:j,width:R,height:T,aspectRatio:H}=t;let G=Math.floor(m?_-t.pointerX:0),K=Math.floor(x?k-t.pointerY:0);const te=R+(g?-G:G),W=T+(y?-K:K),ee=-u[0]*R,J=-u[1]*T;let b=Ks(te,C,S),Y=Ks(W,E,I);if(d){let D=0,z=0;g&&G<0?D=Jn(N+G+ee,d[0][0]):!g&&G>0&&(D=er(N+te+ee,d[1][0])),y&&K<0?z=Jn(j+K+J,d[0][1]):!y&&K>0&&(z=er(j+W+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(f){let D=0,z=0;g&&G>0?D=er(N+G,f[0][0]):!g&&G<0&&(D=Jn(N+te,f[1][0])),y&&K>0?z=er(j+K,f[0][1]):!y&&K<0&&(z=Jn(j+W,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(a){if(m){const D=Ks(te/H,E,I)*H;if(b=Math.max(b,D),d){let z=0;!g&&!y||g&&!y&&v?z=er(j+J+te/H,d[1][1])*H:z=Jn(j+J+(g?G:-G)/H,d[0][1])*H,b=Math.max(b,z)}if(f){let z=0;!g&&!y||g&&!y&&v?z=Jn(j+te/H,f[1][1])*H:z=er(j+(g?G:-G)/H,f[0][1])*H,b=Math.max(b,z)}}if(x){const D=Ks(W*H,C,S)/H;if(Y=Math.max(Y,D),d){let z=0;!g&&!y||y&&!g&&v?z=er(N+W*H+ee,d[1][0])/H:z=Jn(N+(y?K:-K)*H+ee,d[0][0])/H,Y=Math.max(Y,z)}if(f){let z=0;!g&&!y||y&&!g&&v?z=Jn(N+W*H,f[1][0])/H:z=er(N+(y?K:-K)*H,f[0][0])/H,Y=Math.max(Y,z)}}}K=K+(K<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?te>W*H?K=(Ph(g,y)?-G:G)/H:G=(Ph(g,y)?-K:K)*H:m?(K=G/H,y=g):(G=K*H,g=y));const V=g?N+G:N,U=y?j+K:j;return{width:R+(g?-G:G),height:T+(y?-K:K),x:u[0]*G*(g?-1:1)+V,y:u[1]*K*(y?-1:1)+U}}const jg={width:0,height:0,x:0,y:0},U1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function W1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function Y1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=At(t);let d={controlDirection:Mh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:m,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:k,onResizeEnd:C,shouldResize:S}){let E={...jg},I={...U1};d={boundaries:m,resizeDirection:v,keepAspectRatio:x,controlDirection:Mh(y)};let N,j=null,R=[],T,H,G,K=!1;const te=zp().on("start",W=>{const{nodeLookup:ee,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:U}=o();if(N=ee.get(r),!N)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:z}=mo(W.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},I={...E,pointerX:D,pointerY:z,aspectRatio:E.width/E.height},T=void 0,H=zr(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=ee.get(N.parentId)),T&&N.extent==="parent"&&(H=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[B,M]of ee)if(M.parentId===r&&(R.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=W1(M,N,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(W,{...E})}).on("drag",W=>{const{transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(W.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:b,containerBounds:j}),U=[];if(!N)return;const{x:D,y:z,width:B,height:M}=E,L={},ne=N.origin??Y,{width:re,height:ce,x:fe,y:de}=V1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,H,G),q=re!==B,se=ce!==M,pe=fe!==D&&q,_e=de!==z&&se;if(!pe&&!_e&&!q&&!se)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:E.x,L.y=_e?de:E.y,E.x=L.x,E.y=L.y,R.length>0)){const Pe=fe-D,je=de-z;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-B),y:Me.position.y-je+ne[1]*(ce-M)},U.push(Me)}if((q||se)&&(L.width=q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:E.width,L.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:E.height,E.width=L.width,E.height=L.height),T&&N.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{K&&(C==null||C(W,{...E}),a==null||a({...E}),K=!1)});u.call(te)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Ru={exports:{}},Lu={},Au={exports:{}},zu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -58,5 +58,5 @@ Error generating stack: `+h.message+` `,` +`).split(` -`)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Bh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var S,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Uh(_.code,f);if(u.current.add(_[C]),Vh(d,u.current,!1)){const I=((E=(S=_.composedPath)==null?void 0:S.call(_))==null?void 0:E[0])||_.target,N=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&_.preventDefault(),l(!0)}},x=_=>{const k=Uh(_.code,f);Vh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Vh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Uh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=fc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Wh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Yh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Xh=t=>qw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const Ag=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Gh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return Ag(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const zg=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let C=g;for(const E of f)C=typeof E=="function"?E(C):E;let S=Wh({items:C,lookup:v});for(const E of k.values())S=E(S);m&&y(C),S.length>0?x==null||x(S):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:N}=r.getState();E&&N(I)})},[]),l=Gh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const k of f)_=typeof k=="function"?k(_):k;m?y(_):x&&x(Wh({items:_,lookup:v}))},[]),u=Gh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(zg.Provider,{value:d,children:t})}function T_(){const t=$.useContext(zg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function bl(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var E,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),k=Xh(x)?x:v.get(x.id),C=k.parentId?ug(k.position,k.measured,k.parentId,v,_):k.position,S={...k,position:C,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((I=k.measured)==null?void 0:I.height)??k.height};return No(S)},y=(x,v,_={replace:!1})=>{d(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&Xh(S)?S:{...C,...S}}return C}))},m=(x,v,_={replace:!1})=>{f(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&M_(S)?S:{...C,...S}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[k,C,S]=_;return{nodes:x.map(E=>({...E})),edges:v.map(E=>({...E})),viewport:{x:k,y:C,zoom:S}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:k,onNodesDelete:C,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:N,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:k,onBeforeDelete:j}),H=T.length>0,G=R.length>0;if(H){const K=T.map(Yh);S==null||S(T),I(K)}if(G){const K=R.map(Yh);C==null||C(R),E(K)}return(G||H)&&(N==null||N({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const k=vh(x),C=k?x:g(x),S=_!==void 0;return C?(_||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!k&&(E.id===x.id||!I.internals.positionAbsolute))return!1;const N=No(S?E:I),j=pl(N,C);return v&&j>0||j>=N.width*N.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=vh(x)?x:g(x);if(!C)return!1;const S=pl(C,v);return _&&S>0||S>=v.width*v.height||S>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Kw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Qh=t=>t.selected,L_=typeof window<"u"?window:void 0;function A_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=bl(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Qh),edges:d.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function z_(t){const r=He();$.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=hc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Ir.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:k=!0,children:C,noWheelClassName:S,noPanClassName:E,onViewportChange:I,isControlledViewport:N,paneClickDistance:j,selectionOnDrag:R}){const T=He(),H=$.useRef(null),{userSelectionActive:G,lib:K,connectionInProgress:te}=Re(D_,Xe),W=jo(_),ee=$.useRef();z_(H);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),N||T.setState({transform:b})},[I,N]);return $.useEffect(()=>{if(H.current){ee.current=H1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:U=>T.setState(D=>D.paneDragging===U?D:{paneDragging:U}),onPanZoomStart:(U,D)=>{const{onViewportChangeStart:z,onMoveStart:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoom:(U,D)=>{const{onViewportChange:z,onMove:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoomEnd:(U,D)=>{const{onViewportChangeEnd:z,onMoveEnd:B}=T.getState();B==null||B(U,D),z==null||z(D)}});const{x:b,y:Y,zoom:V}=ee.current.getViewport();return T.setState({panZoom:ee.current,transform:[b,Y,V],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=ee.current)==null||U.destroy()}}},[]),$.useEffect(()=>{var b;(b=ee.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:W,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:S,lib:K,onTransformChange:J,connectionInProgress:te,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,W,k,E,G,S,K,J,te,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:H,style:Ml,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Du=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:k,children:C}){const S=$.useRef(0),E=He(),{userSelectionActive:I,elementsSelectable:N,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),H=N&&(t||I),G=$.useRef(null),K=$.useRef(),te=$.useRef(new Set),W=$.useRef(new Set),ee=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){q.preventDefault();return}m==null||m(q)},D=x?q=>x(q):void 0,z=q=>{J.current&&(q.stopPropagation(),J.current=!1)},B=q=>{var Me,tt;if(q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=E.getState();if(K.current=se==null?void 0:se.getBoundingClientRect(),!K.current)return;const _e=q.target===G.current;if(!_e&&!!q.target.closest(".nokey")||!t||!(d&&_e||r)||q.button!==0||!q.isPrimary)return;(tt=(Me=q.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,q.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(q.nativeEvent,K.current),je=Lo({x:Ne,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(q.stopPropagation(),q.preventDefault())};function M(q,se){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=E.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),qe={startX:tt.x,startY:tt.y,x:qut.id)),W.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of te.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&W.current.add(ht)}}if(!xh(bt,te.current)){const ut=gi(me,te.current,!0);Pe(ut)}if(!xh(Dt,W.current)){const ut=gi(ye,W.current);je(ut)}E.setState({userSelectionRect:qe,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!K.current)return;const[q,se]=dc(b.current,K.current,T);R({x:q,y:se}).then(pe=>{if(!J.current||!pe){S.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),S.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=q=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=E.getState();if(!K.current||!se)return;const{x:me,y:ye}=en(q.nativeEvent,K.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(q)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=q=>{var se,pe;if(!H){q.target===G.current&&E.getState().connection.inProgress&&(ee.current=!0);return}q.button===0&&((pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),!I&&q.target===G.current&&E.getState().userSelectionRect&&(V==null||V(q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(q),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=q=>{var se,pe;(pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:H?void 0:Du(V,G),onContextMenu:Du(U,G),onWheel:Du(D,G),onPointerEnter:H?void 0:v,onPointerMove:H?re:_,onPointerUp:ce,onPointerCancel:H?fe:void 0,onPointerDownCapture:H?B:void 0,onClickCapture:H?z:void 0,onPointerLeave:k,ref:G,style:Ml,children:[C,p.jsx(F_,{})]})}function Ju({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Ju({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,k=a?u[1]:5,C=o.direction.x*_*o.factor,S=o.direction.y*k*o.factor;for(const[,E]of y){if(!v(E))continue;let I={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+S};a&&(I=Ro(I,u));const{position:N,positionAbsolute:j}=rg({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});E.position=N,E.internals.positionAbsolute=j,x.set(E.id,E)}g(x)},[])}const xc=$.createContext(null),U_=xc.Provider;xc.Consumer;const Og=()=>$.useContext(xc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function q_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const k=d||null,C=t==="target",S=He(),E=Og(),{connectOnClick:I,noPanClassName:N,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:H,isPossibleEndHandle:G,connectionInProcess:K,clickConnectionInProcess:te,valid:W}=Re(Q_(E,k,t),Xe);E||(V=(Y=S.getState()).onError)==null||V.call(Y,"010",tn.error010());const ee=U=>{const{defaultEdgeOptions:D,onConnect:z,hasDefaultEdges:B}=S.getState(),M={...D,...U};if(B){const{edges:L,setEdges:ne,onError:re}=S.getState();ne(b_(M,L,{onError:re}))}z==null||z(M),f==null||f(M)},J=U=>{if(!E)return;const D=fg(U.nativeEvent);if(a&&(D&&U.button===0||!D)){const z=S.getState();Zu.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:C,handleId:k,nodeId:E,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...B)=>{var M,L;return(L=(M=S.getState()).onConnectEnd)==null?void 0:L.call(M,...B)},updateConnection:z.updateConnection,onConnect:ee,isValidConnection:o||((...B)=>{var M,L;return((L=(M=S.getState()).isValidConnection)==null?void 0:L.call(M,...B))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}D?m==null||m(U):x==null||x(U)},b=U=>{const{onClickConnectStart:D,onClickConnectEnd:z,connectionClickStartHandle:B,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=S.getState();if(!E||!B&&!a)return;if(!B){D==null||D(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const de=cg(U.target),q=o||L,{connection:se,isValid:pe}=Zu.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:q,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&ee(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,z==null||z(U,_e),S.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${k}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:R,connectingto:T,valid:W,connectionindicator:l&&(!K||G)&&(K||te?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(q_));function K_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qh={input:K_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const k=l.getState().nodes.filter(C=>C.selected);t(_,k)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Kh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:G,autoPanOnSelection:K,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:U,disableKeyboardA11y:D,onViewportChange:z,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Kh}),re=jo(C,{target:Kh}),ce=re||G,fe=re||j,de=m&&ce!==!0,q=ne||L||de;return A_({deleteKeyCode:g,multiSelectionKeyCode:k}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:!ne&&ce,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,zoomActivationKeyCode:S,preventScrolling:b,noWheelClassName:V,noPanClassName:U,onViewportChange:z,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:K,isSelecting:!!q,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:U,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?cc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:k,rfId:C,nodeTypes:S,nodeClickDistance:E,onError:I}){const{node:N,internals:j,isParent:R}=Re(q=>{const se=q.nodeLookup.get(t),pe=q.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=N.type||"default",H=(S==null?void 0:S[T])||qh[T];H===void 0&&(I==null||I("003",tn.error003(T)),T="default",H=(S==null?void 0:S.default)||qh.default);const G=!!(N.draggable||f&&typeof N.draggable>"u"),K=!!(N.selectable||g&&typeof N.selectable>"u"),te=!!(N.connectable||y&&typeof N.connectable>"u"),W=!!(N.focusable||m&&typeof N.focusable>"u"),ee=He(),J=ag(N),b=cS({node:N,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:N.hidden||!G,noDragClassName:v,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),V=$g();if(N.hidden)return null;const U=rn(N),D=tS(N),z=K||G||r||o||l||a,B=o?q=>o(q,{...j.userNode}):void 0,M=l?q=>l(q,{...j.userNode}):void 0,L=a?q=>a(q,{...j.userNode}):void 0,ne=u?q=>u(q,{...j.userNode}):void 0,re=d?q=>d(q,{...j.userNode}):void 0,ce=q=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();K&&(!se||!G||pe>0)&&Ju({id:t,store:ee,nodeRef:b}),r&&r(q,{...j.userNode})},fe=q=>{if(!(dg(q.nativeEvent)||k)){if(Zp.includes(q.key)&&K){const se=q.key==="Escape";Ju({id:t,store:ee,unselect:se,nodeRef:b})}else if(G&&N.selected&&Object.prototype.hasOwnProperty.call(gl,q.key)){q.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[q.key],factor:q.shiftKey?4:1})}}},de=()=>{var Ne;if(k||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:q,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=ee.getState();if(!_e)return;cc(new Map([[t,N]]),{x:0,y:0,width:se,height:pe},q,!0).length>0||me(N.position.x+U.width/2,N.position.y+U.height/2,{zoom:q[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},N.className,{selected:N.selected,selectable:K,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:J?"visible":"hidden",...N.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:W?fe:void 0,tabIndex:W?0:void 0,onFocus:W?de:void 0,role:N.ariaRole??(W?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Pg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(H,{id:t,data:N.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:G,deletable:N.deletable??!0,isConnectable:te,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:j.z,parentId:N.parentId,...U})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:Ml,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Zh,t)?Zh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),k=$.useRef(null);return $.useEffect(()=>{if(k.current){const C=k.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Pl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function Jh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Jh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=Jh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})=>{const[I,N,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Pl,{id:R,path:I,labelX:N,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=Qu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:S,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),qg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";qg.displayName="SmoothStepEdgeInternal";function Kg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})=>{const[S,E,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return p.jsx(Pl,{id:N,path:S,labelX:E,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const ep={default:nm,straight:em,step:Zg,smoothstep:qg,simplebezier:Xg},tp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,np="react-flow__edgeupdater";function rp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([np,`${np}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const k=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:H,connectionMode:G,connectionRadius:K,lib:te,onConnectStart:W,cancelConnection:ee,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=k.getState(),U=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},z=M=>y==null?void 0:y(o,M),B=(M,L)=>{v(!0),m==null||m(j,o,R.type),W==null||W(M,L)};Zu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:K,domNode:H,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:U,edgeUpdaterType:R.type,lib:te,flowId:b,cancelConnection:ee,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=k.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:z,onConnectStart:B,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=k.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),N=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(rp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:S,onMouseEnter:I,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&p.jsx(rp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:N,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:k,edgeTypes:C,noPanClassName:S,onError:E,disableKeyboardA11y:I}){let N=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);N=j?{...j,...N}:N;let R=N.type||"default",T=(C==null?void 0:C[R])||ep[R];T===void 0&&(E==null||E("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||ep.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),G=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),te=$.useRef(null),[W,ee]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=N.zIndex,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(N.source),Ne=me.nodeLookup.get(N.target);if(!ye||!Ne)return tp;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:me.connectionMode,onError:E}),je=l1({selected:N.selected,zIndex:N.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||tp,zIndex:je}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Xe),ne=$.useMemo(()=>N.markerStart?`url('#${qu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),re=$.useMemo(()=>N.markerEnd?`url('#${qu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||U===null||D===null||z===null||B===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();K&&(Y.setState({nodesSelectionActive:!1}),N.selected&&Pe?(Ne({nodes:[],edges:[N]}),(je=te.current)==null||je.blur()):ye([t])),a&&a(me,N)},fe=u?me=>{u(me,{...N})}:void 0,de=d?me=>{d(me,{...N})}:void 0,q=f?me=>{f(me,{...N})}:void 0,se=g?me=>{g(me,{...N})}:void 0,pe=y?me=>{y(me,{...N})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&K){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=te.current)==null||ye.blur(),Ne({edges:[N]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,N.className,S,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:W,selectable:K}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:q,onMouseMove:se,onMouseLeave:pe,onKeyDown:H?_e: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?`${Ig}-${k}`:void 0,ref:te,...N.domAttributes,children:[!J&&p.jsx(T,{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:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),G&&p.jsx(bS,{edge:N,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,setUpdateHover:ee,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:C}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,onError:N}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),ip=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return Ag(()=>{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=ip(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ip(l)},children:t})}function LS(t){const r=bl(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const AS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function zS(t){const r=Re(AS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let k="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[k]=pg(C);break;case nr.SimpleBezier:[k]=Wg(C);break;case nr.Step:[k]=Qu({...C,borderRadius:0});break;case nr.SmoothStep:[k]=Qu(C);break;default:[k]=mg(C)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function op(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:C,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,deleteKeyCode:G,onlyRenderVisibleElements:K,elementsSelectable:te,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:U,zoomOnPinch:D,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return op(t),op(r),VS(),LS(o),zS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:K,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:k,component:S,containerStyle:E}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:qe,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),sp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,k=new Map,C=new Map,S=new Map,E=l??r??[],I=o??t??[],N=m??[0,0],j=x??So;xg(C,S,E);const{nodesInitialized:R}=Ku(I,_,k,{nodeOrigin:N,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const H=To(_,{filter:W=>!!((W.width||W.initialWidth)&&(W.height||W.initialHeight))}),{x:G,y:K,zoom:te}=fc(H,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,K,te]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:S,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.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:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,k)=>{async function C(){const{nodeLookup:S,panZoom:E,fitViewOptions:I,fitViewResolver:N,width:j,height:R,minZoom:T,maxZoom:H}=k();E&&(await e1({nodes:S,width:j,height:R,panZoom:E,minZoom:T,maxZoom:H},I),N==null||N.resolve(!0),_({fitViewResolver:null}))}return{...sp({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:S=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:H,nodesSelectionActive:G}=k(),{nodesInitialized:K,hasSelectedNodes:te}=Ku(S,E,I,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:H}),W=G&&te;T&&K?(C(),_({nodes:S,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:W})):_({nodes:S,nodesInitialized:K,nodesSelectionActive:W})},setEdges:S=>{const{connectionLookup:E,edgeLookup:I}=k();xg(E,I,S),_({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:I}=k();I(S),_({hasDefaultNodes:!0})}if(E){const{setEdges:I}=k();I(E),_({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:N,domNode:j,nodeOrigin:R,nodeExtent:T,debug:H,fitViewQueued:G,zIndexMode:K}=k(),{changes:te,updatedInternals:W}=k1(S,I,N,j,R,T,K);W&&(x1(I,N,{nodeOrigin:R,nodeExtent:T,zIndexMode:K}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(H&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(S,E=!1)=>{const I=[];let N=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:H,onNodesChangeMiddlewareMap:G}=k();for(const[K,te]of S){const W=j.get(K),ee=!!(W!=null&&W.expandParent&&(W!=null&&W.parentId)&&(te!=null&&te.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(W&&T.inProgress&&T.fromNode.id===W.id){const b=zr(W,T.fromHandle,Se.Left,!0);H({...T,from:b})}ee&&W.parentId&&I.push({id:K,parentId:W.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),N.push(J)}if(I.length>0){const{parentLookup:K,nodeOrigin:te}=k(),W=vc(I,j,K,te);N.push(...W)}for(const K of G.values())N=K(N);R(N)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:I,nodes:N,hasDefaultNodes:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=N_(S,N);I(T)}R&&console.log("React Flow: trigger node changes",S),E==null||E(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:I,edges:N,hasDefaultEdges:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=C_(S,N);I(T)}R&&console.log("React Flow: trigger edge changes",S),E==null||E(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));j(T);return}j(gi(N,new Set([...S]),!0)),R(gi(I))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));R(T);return}R(gi(I,new Set([...S]))),j(gi(N,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:I,nodes:N,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=k(),H=S||N,G=E||I,K=[];for(const W of H){if(!W.selected)continue;const ee=j.get(W.id);ee&&(ee.selected=!1),K.push(br(W.id,!1))}const te=[];for(const W of G)W.selected&&te.push(br(W.id,!1));R(K),T(te)},setMinZoom:S=>{const{panZoom:E,maxZoom:I}=k();E==null||E.setScaleExtent([S,I]),_({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:I}=k();E==null||E.setScaleExtent([I,S]),_({maxZoom:S})},setTranslateExtent:S=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(S),_({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:N,elementsSelectable:j}=k();if(!j)return;const R=E.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]),T=S.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]);I(R),N(T)},setNodeExtent:S=>{const{nodes:E,nodeLookup:I,parentLookup:N,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:H}=k();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(Ku(E,I,N,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:H}),_({nodeExtent:S}))},panBy:S=>{const{transform:E,width:I,height:N,panZoom:j,translateExtent:R}=k();return E1({delta:S,panZoom:j,transform:E,translateExtent:R,width:I,height:N})},setCenter:async(S,E,I)=>{const{width:N,height:j,maxZoom:R,panZoom:T}=k();if(!T)return!1;const H=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:N/2-S*H,y:j/2-E*H,zoom:H},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:S=>{_({connection:S})},reset:()=>_({...sp()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[k]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:k,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onBeforeDelete:B,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:q=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:qe=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:$r=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Ir.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Or=10,onNodesChange:ji,onEdgesChange:Tl,noDragClassName:Rl="nodrag",noWheelClassName:Ll="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Al,attributionPosition:Ao,proOptions:zo,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Fr,isValidConnection:$l,onError:Ho,style:Hr,id:Mt,nodeDragThreshold:Ol,connectionDragThreshold:Pt,viewport:Fl,onViewportChange:Hl,width:Bl,height:Br,colorMode:Vr="light",debug:hr,onScroll:yn,ariaLabelConfig:Vl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Vr),Ul=$.useCallback(Ur=>{Ur.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Ur)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Ul,style:{...Hr,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Bl,height:Br,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:qe,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Tl,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Al,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:qe,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanSpeed:Fo,onError:Ho,connectionRadius:Fr,isValidConnection:$l,selectNodesOnDrag:je,nodeDragThreshold:Ol,connectionDragThreshold:Pt,onBeforeDelete:B,debug:hr,ariaLabelConfig:Vl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:q,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:$r,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Or,defaultMarkerColor:gn,noDragClassName:Rl,noWheelClassName:Ll,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Fl,onViewportChange:Hl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:zo,position:Ao}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var qS=Lg(QS);function KS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),k=l||JS[r],C=r===rr.Dots,S=r===rr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*v[2]||1,E[1]*v[2]||1],N=k*v[2],j=Array.isArray(u)?u:[u,u],R=S?[N,N]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],H=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...Ml,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:H,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:N/2,className:m}):p.jsx(KS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const k=He(),{isInteractive:C,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:N,zoomOut:j,fitView:R}=bl(),T=()=>{N(),u==null||u()},H=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},K=()=>{k.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},te=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",te,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:H,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:S,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:K,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:k,backgroundColor:C}=u||{},S=d||k||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?E=>_(E,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),$u=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=$u(r),y=$u(t),m=$u(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(k=>{const C=k.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const S=C.internals.userNode,{x:E,y:I}=C.internals.positionAbsolute,{width:N,height:j}=rn(S);return{node:S,x:E,y:I,width:N,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},lp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>lp(t.viewBB,r.viewBB)&&lp(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:k,pannable:C=!1,zoomable:S=!1,ariaLabel:E,inversePan:I,zoomStep:N=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:H,viewBB:G,rfId:K,panZoom:te,translateExtent:W,flowWidth:ee,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,U=H.width/Y,D=H.height/V,z=Math.max(U,D),B=z*Y,M=z*V,L=j*z,ne=H.x-(B-H.width)/2-L,re=H.y-(M-H.height)/2-L,ce=B+L*2,fe=M+L*2,de=`${_k}-${K}`,q=$.useRef(0),se=$.useRef();q.current=z,$.useEffect(()=>{if(T.current&&te)return se.current=R1({domNode:T.current,panZoom:te,getTransform:()=>R.getState().transform,getViewScale:()=>q.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[te]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:W,width:ee,height:J,inversePan:I,pannable:C,zoomStep:N,zoomable:S})},[C,S,I,N,W,ee,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=k?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;k(ye,Pe)},[]):void 0,me=E??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*z: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:k,onResizeStart:C,onResize:S,onResizeEnd:E}){const I=Og(),N=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,H=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),K=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!N))return G.current||(G.current=Y1({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(W,ee)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),U=[],D={x:W.x,y:W.y},z=b.get(N);if(z&&z.expandParent&&z.parentId){const B=z.origin??V,M=W.width??z.measured.width??0,L=W.height??z.measured.height??0,ne={id:z.id,parentId:z.parentId,rect:{width:M,height:L,...ug({x:W.x??z.position.x,y:W.y??z.position.y},{width:M,height:L},z.parentId,b,B)}},re=vc([ne],b,Y,V);U.push(...re),D.x=W.x?Math.max(B[0]*M,W.x):void 0,D.y=W.y?Math.max(B[1]*L,W.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:N,type:"position",position:{...D}};U.push(B)}if(W.width!==void 0&&W.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:W.width,height:W.height}};U.push(M)}for(const B of ee){const M={...B,type:"position"};U.push(M)}J(U)},onEnd:({width:W,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:W,height:ee}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:K,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:S,onResizeEnd:E,shouldResize:k}),()=>{var W;(W=G.current)==null||W.destroy()}},[K,f,g,y,m,x,C,S,E,k]);const te=K.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...te,o,l]),ref:R,style:{...a,scale:H,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"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 Il(t){return Ck[t]??8}const ec=208,tc=64,jk=88,bk=28,Mk=8;function Pk(t){if(!t.length)return Number.NaN;const r=[...t].sort((l,a)=>l-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Ik(t,r=[]){const o=new Map;if(!t.length)return o;const l=new Map;for(const C of t){const S=Il(C.type),E=l.get(S)??[];E.push(C),l.set(S,E)}const u=[...l.keys()].sort((C,S)=>C-S).map(C=>[...l.get(C)??[]].sort((S,E)=>S.name.localeCompare(E.name)||S.id.localeCompare(E.id))),d=new Set(t.map(C=>C.id)),f=new Map,g=new Map;for(const C of t)f.set(C.id,[]),g.set(C.id,[]);for(const C of r)!d.has(C.src)||!d.has(C.dst)||C.src===C.dst||(g.get(C.src).push(C.dst),f.get(C.dst).push(C.src));const y=new Map,m=()=>{for(const C of u)C.forEach((S,E)=>y.set(S.id,E))};m();const x=(C,S)=>{const E=C.map((I,N)=>{const j=S(I.id).map(T=>y.get(T)).filter(T=>T!==void 0),R=Pk(j);return{n:I,bary:Number.isNaN(R)?N:R,name:I.name,id:I.id}});return E.sort((I,N)=>I.bary-N.bary||I.name.localeCompare(N.name)||I.id.localeCompare(N.id)),E.map(I=>I.n)};for(let C=0;Cf.get(E)??[]),m();for(let S=u.length-2;S>=0;S--)u[S]=x(u[S],E=>g.get(E)??[]),m()}const v=ec+jk,_=tc+bk,k=Math.max(...u.map(C=>C.length),1);return u.forEach((C,S)=>{const E=(k-C.length)*_/2;C.forEach((I,N)=>{o.set(I.id,{x:S*v,y:E+N*_})})}),o}const cm=90,Tk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ap={"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"},Rk=Math.PI*(3-Math.sqrt(5)),dm=220,Lk=26,Ak={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 fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function mE(t){return ap[t]?ap[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function zk(t){return t>=cm?"3d":"2d"}function Dk(t){return t>=cm?"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(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!Tk.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(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function yE(t){const r=new Map;for(const l of t){const a=Il(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Lk*Math.sqrt(f+1),y=f*Rk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function vE(t){const r=new Map;for(const o of t){const l=Il(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*dm,count:l}))}const el=16,Fk=12,Hk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),Bk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),up={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Vk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},cp=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],dp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Uk=new Set(["looks_idempotent_on_pk"]),Wk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Yk(t){return up[t]?up[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Xk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Hk.has(t.type)&&a.push("sink"),Bk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>fp(x,l,x.src)),y=f.slice(0,el).map(x=>fp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ak[Il(t.type)]??"other",purpose:Yk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Gk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function fp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Gk(t){const r=[...cp.filter(a=>a in t),...Object.keys(t).filter(a=>!cp.includes(a)&&!dp.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||dp.has(a)||Wk.has(a))continue;l.add(a);const u=Qk(a,t[a]);u!=null&&o.push({key:a,label:Vk[a]??yo(a),value:u})}return o}function Qk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Uk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Fk),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const qk=new Set,Kk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-D0mq8ReQ.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Zk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Jk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:t.name}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const eE={load:Jk},tE=new Set(["django","react","stitch","arch"]);function nE({topologyKey:t}){const{fitView:r}=bl();return $.useEffect(()=>{let o=0;const l=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(o)}},[r,t]),null}function rE(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=Ik(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:ec,height:tc,style:{width:ec,height:tc}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Zk[f.weight]||"var(--edge-cheap)",y=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:y?f.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Xk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:pi(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:pi(a.context)}):null,a.file?p.jsx("div",{className:"file",children:pi(a.file)}):null,p.jsx("div",{className:"muted",children:pi(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:pi(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:pi(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function Ou({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(tE)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??zk(t.length),k=d??Dk(t.length),C=m&&_==="3d"?o:null,S=$.useMemo(()=>Ok(t,r,{detail:k,families:g,focusId:C,neighborhoodOnly:!!C}),[t,r,k,g,C]),E=$.useMemo(()=>`${S.nodes.map(W=>W.id).join("\0")}|${S.edges.map(W=>W.id).join("\0")}`,[S.nodes,S.edges]),I=$.useMemo(()=>new Map(S.nodes.map(W=>[W.id,W])),[S.nodes]),N=o?I.get(o)??null:null,{rfNodes:j,rfEdges:R}=$.useMemo(()=>{const W=rE(S.nodes,S.edges,o);return v&&(W.rfEdges=W.rfEdges.map(ee=>({...ee,animated:!1}))),W},[S.nodes,S.edges,o,v]);$.useEffect(()=>{o&&!I.has(o)&&l(null)},[I,o]);const T=(W,ee)=>{l(ee.id)},H=()=>{l(null),x(!1)},G=W=>{y(ee=>{const J=new Set(ee);if(J.has(W)){if(J.size===1)return ee;J.delete(W)}else J.add(W);return J})},K=$.useMemo(()=>{const W=new Set;for(const ee of t)W.add(fm(ee.type));return W},[t]),te=t.length-S.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:k==="overview"?"active":"","aria-pressed":k==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:k==="full"?"active":"","aria-pressed":k==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(W=>K.has(W)).map(W=>p.jsx("button",{type:"button","data-testid":`graph-family-${W}`,className:g.has(W)?"active":"","aria-pressed":g.has(W),onClick:()=>G(W),children:W},W))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(W=>!W),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[S.nodes.length," nodes · ",S.edges.length," edges",te?` · ${te} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Kk,{nodes:S.nodes,edges:S.edges,selectedId:o,neighborIds:C?S.neighborIds:qk,onSelect:W=>{l(W),W||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]}):p.jsxs(sm,{children:[p.jsxs(qS,{nodes:j,edges:R,nodeTypes:eE,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:H,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(nE,{topologyKey:E}),p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],iE=["preset","branch","tag","commit"];function oE(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function sE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function lE(t){return iE.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function aE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,k]=$.useState(0),C=$.useMemo(()=>{const j=oE(u);return x===null?j:sE(j,x)},[u,x]),S=$.useMemo(()=>lE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{k(0)},[x,y]);const E=()=>{m(!1),v(null)},I=j=>{r(j.value),E()},N=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}k(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),E())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:N}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?E():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:S.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):S.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:aE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:H=>H.preventDefault(),onMouseEnter:()=>k(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function uE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),k=$.useRef(0),C=async N=>{const j=k.current+1;k.current=j,v(!0);try{const R=await Ve.browse(N);if(k.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(k.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{k.current===j&&v(!1)}};$.useEffect(()=>{var N,j;C(t),(N=_.current)==null||N.focus(),(j=_.current)==null||j.select()},[t]);const S=f||(l==null?void 0:l.path)||u,E=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:N=>d(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(N=>{const j=f===N.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void C(N.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:S,children:S}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!S,onClick:()=>S&&r(S),children:["Use ",E]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],cE="obsidian",hm="loadpath.theme";function dE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(dE(t))return t}catch{}return cE}function fE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=fE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function hE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[k,C]=$.useState("review"),[S,E]=$.useState(""),[I,N]=$.useState(""),[j,R]=$.useState(""),[T,H]=$.useState({}),[G,K]=$.useState([]),[te,W]=$.useState([]),[ee,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,U]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,z]=$.useState(""),[B,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[q,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,N(F)};$.useEffect(()=>{Ve.settings().then(H).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),qe=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(U(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);W(be.repos),(ae=be.user)!=null&&ae.login&&H($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{W([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||W([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!q)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(q.flow_id);if(F)return;if($e.status==="complete"){se(null);const ze=await Ve.settings();H(ze),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||q.interval,5)*1e3);return}se(null),E($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),E($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(q.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[q,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const ze=await Ve.oauthStatus();if(F)return;if(ze.bitbucket.connected){_e(!1);const Rn=await Ve.settings();H(Rn),R(ze.bitbucket.user?`Signed in to Bitbucket as ${ze.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),E("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(ze){if(F)return;_e(!1),E(ze instanceof Error?ze.message:String(ze))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Tracing load path…"),Ge(o),qe(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){E(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){E(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){E(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!ee||!V){E("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,ee,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){E(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,ee);K(F.pull_requests);const ae=te.find(be=>be.slug.toLowerCase()===ee.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{E("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){E(F instanceof Error?F.message:String(F))}},$r=async()=>{E("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),E(F instanceof Error?F.message:String(F))}},ir=async F=>{E("");try{H(await Ve.oauthDisconnect(F)),b===F&&W([]),R(`Disconnected ${F}`)}catch(ae){E(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(ze=>({path:ze.path,name:ze.name}))}:be;try{H(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(ze){E(ze instanceof Error?ze.message:String(ze))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);z(F.note)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){E(""),R("");return}const $e=yp.find(ze=>ze.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,m,g]),sr=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[k,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:B,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>qe(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>qe(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[S?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:S}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(pE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx(Ou,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(gE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx(Ou,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx(Ou,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,ee,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:te.length?"Search your repos":"owner/repo",value:ee,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:te.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),te.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[te.length," ",b," repositor",te.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{qe(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=te.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:B===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!q||!T.github_oauth_ready,onClick:()=>void Ni(),children:q?"Waiting for GitHub…":"Sign in with GitHub"})})]}),q?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:q.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void $r(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(uE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function pE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,k,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(S=>p.jsx("li",{children:S},S))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(S=>p.jsx("span",{className:"chip",children:yo(S)},S))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((S,E)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[E+1,". ",S.path]}),p.jsx("div",{className:"why",children:S.why})]},S.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:S.title})," — ",S.files.join(", ")]},S.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(S=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${S.severity}`,children:S.severity}),S.message]},S.rule+S.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(S=>p.jsx("div",{className:"residual muted",children:S},S))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(S=>S.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(S=>p.jsx("div",{className:"muted",children:S},S)),(((k=t.evolution)==null?void 0:k.hotspots)||[]).filter(S=>S.commits).slice(0,6).map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:S.path})," — ",S.commits," commits, bus factor ",S.bus_factor]},S.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function gE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(hE,{})}));export{Ak as L,vE as a,mE as c,p as j,yE as l,$ as r,yl as t}; +`)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Bh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var S,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Uh(_.code,f);if(u.current.add(_[C]),Vh(d,u.current,!1)){const I=((E=(S=_.composedPath)==null?void 0:S.call(_))==null?void 0:E[0])||_.target,N=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&_.preventDefault(),l(!0)}},x=_=>{const k=Uh(_.code,f);Vh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Vh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Uh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=fc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Wh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Yh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Xh=t=>qw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const Ag=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Gh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return Ag(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const zg=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let C=g;for(const E of f)C=typeof E=="function"?E(C):E;let S=Wh({items:C,lookup:v});for(const E of k.values())S=E(S);m&&y(C),S.length>0?x==null||x(S):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:N}=r.getState();E&&N(I)})},[]),l=Gh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const k of f)_=typeof k=="function"?k(_):k;m?y(_):x&&x(Wh({items:_,lookup:v}))},[]),u=Gh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(zg.Provider,{value:d,children:t})}function T_(){const t=$.useContext(zg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function bl(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var E,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),k=Xh(x)?x:v.get(x.id),C=k.parentId?ug(k.position,k.measured,k.parentId,v,_):k.position,S={...k,position:C,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((I=k.measured)==null?void 0:I.height)??k.height};return No(S)},y=(x,v,_={replace:!1})=>{d(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&Xh(S)?S:{...C,...S}}return C}))},m=(x,v,_={replace:!1})=>{f(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&M_(S)?S:{...C,...S}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[k,C,S]=_;return{nodes:x.map(E=>({...E})),edges:v.map(E=>({...E})),viewport:{x:k,y:C,zoom:S}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:k,onNodesDelete:C,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:N,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:k,onBeforeDelete:j}),H=T.length>0,G=R.length>0;if(H){const K=T.map(Yh);S==null||S(T),I(K)}if(G){const K=R.map(Yh);C==null||C(R),E(K)}return(G||H)&&(N==null||N({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const k=vh(x),C=k?x:g(x),S=_!==void 0;return C?(_||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!k&&(E.id===x.id||!I.internals.positionAbsolute))return!1;const N=No(S?E:I),j=pl(N,C);return v&&j>0||j>=N.width*N.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=vh(x)?x:g(x);if(!C)return!1;const S=pl(C,v);return _&&S>0||S>=v.width*v.height||S>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Kw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Qh=t=>t.selected,L_=typeof window<"u"?window:void 0;function A_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=bl(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Qh),edges:d.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function z_(t){const r=He();$.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=hc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Tr.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:k=!0,children:C,noWheelClassName:S,noPanClassName:E,onViewportChange:I,isControlledViewport:N,paneClickDistance:j,selectionOnDrag:R}){const T=He(),H=$.useRef(null),{userSelectionActive:G,lib:K,connectionInProgress:te}=Re(D_,Xe),W=jo(_),ee=$.useRef();z_(H);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),N||T.setState({transform:b})},[I,N]);return $.useEffect(()=>{if(H.current){ee.current=H1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:U=>T.setState(D=>D.paneDragging===U?D:{paneDragging:U}),onPanZoomStart:(U,D)=>{const{onViewportChangeStart:z,onMoveStart:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoom:(U,D)=>{const{onViewportChange:z,onMove:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoomEnd:(U,D)=>{const{onViewportChangeEnd:z,onMoveEnd:B}=T.getState();B==null||B(U,D),z==null||z(D)}});const{x:b,y:Y,zoom:V}=ee.current.getViewport();return T.setState({panZoom:ee.current,transform:[b,Y,V],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=ee.current)==null||U.destroy()}}},[]),$.useEffect(()=>{var b;(b=ee.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:W,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:S,lib:K,onTransformChange:J,connectionInProgress:te,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,W,k,E,G,S,K,J,te,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:H,style:Ml,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Du=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:k,children:C}){const S=$.useRef(0),E=He(),{userSelectionActive:I,elementsSelectable:N,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),H=N&&(t||I),G=$.useRef(null),K=$.useRef(),te=$.useRef(new Set),W=$.useRef(new Set),ee=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){q.preventDefault();return}m==null||m(q)},D=x?q=>x(q):void 0,z=q=>{J.current&&(q.stopPropagation(),J.current=!1)},B=q=>{var Me,tt;if(q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=E.getState();if(K.current=se==null?void 0:se.getBoundingClientRect(),!K.current)return;const _e=q.target===G.current;if(!_e&&!!q.target.closest(".nokey")||!t||!(d&&_e||r)||q.button!==0||!q.isPrimary)return;(tt=(Me=q.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,q.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(q.nativeEvent,K.current),je=Lo({x:Ne,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(q.stopPropagation(),q.preventDefault())};function M(q,se){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=E.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),qe={startX:tt.x,startY:tt.y,x:qut.id)),W.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of te.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&W.current.add(ht)}}if(!xh(bt,te.current)){const ut=gi(me,te.current,!0);Pe(ut)}if(!xh(Dt,W.current)){const ut=gi(ye,W.current);je(ut)}E.setState({userSelectionRect:qe,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!K.current)return;const[q,se]=dc(b.current,K.current,T);R({x:q,y:se}).then(pe=>{if(!J.current||!pe){S.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),S.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=q=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=E.getState();if(!K.current||!se)return;const{x:me,y:ye}=en(q.nativeEvent,K.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(q)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=q=>{var se,pe;if(!H){q.target===G.current&&E.getState().connection.inProgress&&(ee.current=!0);return}q.button===0&&((pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),!I&&q.target===G.current&&E.getState().userSelectionRect&&(V==null||V(q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(q),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=q=>{var se,pe;(pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:H?void 0:Du(V,G),onContextMenu:Du(U,G),onWheel:Du(D,G),onPointerEnter:H?void 0:v,onPointerMove:H?re:_,onPointerUp:ce,onPointerCancel:H?fe:void 0,onPointerDownCapture:H?B:void 0,onClickCapture:H?z:void 0,onPointerLeave:k,ref:G,style:Ml,children:[C,p.jsx(F_,{})]})}function Ju({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Ju({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,k=a?u[1]:5,C=o.direction.x*_*o.factor,S=o.direction.y*k*o.factor;for(const[,E]of y){if(!v(E))continue;let I={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+S};a&&(I=Ro(I,u));const{position:N,positionAbsolute:j}=rg({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});E.position=N,E.internals.positionAbsolute=j,x.set(E.id,E)}g(x)},[])}const xc=$.createContext(null),U_=xc.Provider;xc.Consumer;const Og=()=>$.useContext(xc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function q_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const k=d||null,C=t==="target",S=He(),E=Og(),{connectOnClick:I,noPanClassName:N,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:H,isPossibleEndHandle:G,connectionInProcess:K,clickConnectionInProcess:te,valid:W}=Re(Q_(E,k,t),Xe);E||(V=(Y=S.getState()).onError)==null||V.call(Y,"010",tn.error010());const ee=U=>{const{defaultEdgeOptions:D,onConnect:z,hasDefaultEdges:B}=S.getState(),M={...D,...U};if(B){const{edges:L,setEdges:ne,onError:re}=S.getState();ne(b_(M,L,{onError:re}))}z==null||z(M),f==null||f(M)},J=U=>{if(!E)return;const D=fg(U.nativeEvent);if(a&&(D&&U.button===0||!D)){const z=S.getState();Zu.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:C,handleId:k,nodeId:E,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...B)=>{var M,L;return(L=(M=S.getState()).onConnectEnd)==null?void 0:L.call(M,...B)},updateConnection:z.updateConnection,onConnect:ee,isValidConnection:o||((...B)=>{var M,L;return((L=(M=S.getState()).isValidConnection)==null?void 0:L.call(M,...B))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}D?m==null||m(U):x==null||x(U)},b=U=>{const{onClickConnectStart:D,onClickConnectEnd:z,connectionClickStartHandle:B,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=S.getState();if(!E||!B&&!a)return;if(!B){D==null||D(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const de=cg(U.target),q=o||L,{connection:se,isValid:pe}=Zu.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:q,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&ee(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,z==null||z(U,_e),S.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${k}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:R,connectingto:T,valid:W,connectionindicator:l&&(!K||G)&&(K||te?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(q_));function K_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qh={input:K_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const k=l.getState().nodes.filter(C=>C.selected);t(_,k)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Kh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:G,autoPanOnSelection:K,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:U,disableKeyboardA11y:D,onViewportChange:z,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Kh}),re=jo(C,{target:Kh}),ce=re||G,fe=re||j,de=m&&ce!==!0,q=ne||L||de;return A_({deleteKeyCode:g,multiSelectionKeyCode:k}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:!ne&&ce,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,zoomActivationKeyCode:S,preventScrolling:b,noWheelClassName:V,noPanClassName:U,onViewportChange:z,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:K,isSelecting:!!q,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:U,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?cc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:k,rfId:C,nodeTypes:S,nodeClickDistance:E,onError:I}){const{node:N,internals:j,isParent:R}=Re(q=>{const se=q.nodeLookup.get(t),pe=q.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=N.type||"default",H=(S==null?void 0:S[T])||qh[T];H===void 0&&(I==null||I("003",tn.error003(T)),T="default",H=(S==null?void 0:S.default)||qh.default);const G=!!(N.draggable||f&&typeof N.draggable>"u"),K=!!(N.selectable||g&&typeof N.selectable>"u"),te=!!(N.connectable||y&&typeof N.connectable>"u"),W=!!(N.focusable||m&&typeof N.focusable>"u"),ee=He(),J=ag(N),b=cS({node:N,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:N.hidden||!G,noDragClassName:v,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),V=$g();if(N.hidden)return null;const U=rn(N),D=tS(N),z=K||G||r||o||l||a,B=o?q=>o(q,{...j.userNode}):void 0,M=l?q=>l(q,{...j.userNode}):void 0,L=a?q=>a(q,{...j.userNode}):void 0,ne=u?q=>u(q,{...j.userNode}):void 0,re=d?q=>d(q,{...j.userNode}):void 0,ce=q=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();K&&(!se||!G||pe>0)&&Ju({id:t,store:ee,nodeRef:b}),r&&r(q,{...j.userNode})},fe=q=>{if(!(dg(q.nativeEvent)||k)){if(Zp.includes(q.key)&&K){const se=q.key==="Escape";Ju({id:t,store:ee,unselect:se,nodeRef:b})}else if(G&&N.selected&&Object.prototype.hasOwnProperty.call(gl,q.key)){q.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[q.key],factor:q.shiftKey?4:1})}}},de=()=>{var Ne;if(k||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:q,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=ee.getState();if(!_e)return;cc(new Map([[t,N]]),{x:0,y:0,width:se,height:pe},q,!0).length>0||me(N.position.x+U.width/2,N.position.y+U.height/2,{zoom:q[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},N.className,{selected:N.selected,selectable:K,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:J?"visible":"hidden",...N.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:W?fe:void 0,tabIndex:W?0:void 0,onFocus:W?de:void 0,role:N.ariaRole??(W?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Pg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(H,{id:t,data:N.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:G,deletable:N.deletable??!0,isConnectable:te,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:j.z,parentId:N.parentId,...U})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:Ml,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Zh,t)?Zh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),k=$.useRef(null);return $.useEffect(()=>{if(k.current){const C=k.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Pl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function Jh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Jh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=Jh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})=>{const[I,N,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Pl,{id:R,path:I,labelX:N,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=Qu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:S,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),qg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";qg.displayName="SmoothStepEdgeInternal";function Kg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})=>{const[S,E,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return p.jsx(Pl,{id:N,path:S,labelX:E,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const ep={default:nm,straight:em,step:Zg,smoothstep:qg,simplebezier:Xg},tp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,np="react-flow__edgeupdater";function rp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([np,`${np}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const k=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:H,connectionMode:G,connectionRadius:K,lib:te,onConnectStart:W,cancelConnection:ee,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=k.getState(),U=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},z=M=>y==null?void 0:y(o,M),B=(M,L)=>{v(!0),m==null||m(j,o,R.type),W==null||W(M,L)};Zu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:K,domNode:H,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:U,edgeUpdaterType:R.type,lib:te,flowId:b,cancelConnection:ee,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=k.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:z,onConnectStart:B,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=k.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),N=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(rp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:S,onMouseEnter:I,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&p.jsx(rp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:N,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:k,edgeTypes:C,noPanClassName:S,onError:E,disableKeyboardA11y:I}){let N=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);N=j?{...j,...N}:N;let R=N.type||"default",T=(C==null?void 0:C[R])||ep[R];T===void 0&&(E==null||E("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||ep.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),G=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),te=$.useRef(null),[W,ee]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=N.zIndex,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(N.source),Ne=me.nodeLookup.get(N.target);if(!ye||!Ne)return tp;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:me.connectionMode,onError:E}),je=l1({selected:N.selected,zIndex:N.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||tp,zIndex:je}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Xe),ne=$.useMemo(()=>N.markerStart?`url('#${qu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),re=$.useMemo(()=>N.markerEnd?`url('#${qu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||U===null||D===null||z===null||B===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();K&&(Y.setState({nodesSelectionActive:!1}),N.selected&&Pe?(Ne({nodes:[],edges:[N]}),(je=te.current)==null||je.blur()):ye([t])),a&&a(me,N)},fe=u?me=>{u(me,{...N})}:void 0,de=d?me=>{d(me,{...N})}:void 0,q=f?me=>{f(me,{...N})}:void 0,se=g?me=>{g(me,{...N})}:void 0,pe=y?me=>{y(me,{...N})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&K){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=te.current)==null||ye.blur(),Ne({edges:[N]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,N.className,S,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:W,selectable:K}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:q,onMouseMove:se,onMouseLeave:pe,onKeyDown:H?_e: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?`${Ig}-${k}`:void 0,ref:te,...N.domAttributes,children:[!J&&p.jsx(T,{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:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),G&&p.jsx(bS,{edge:N,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,setUpdateHover:ee,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:C}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,onError:N}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),ip=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return Ag(()=>{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=ip(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ip(l)},children:t})}function LS(t){const r=bl(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const AS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function zS(t){const r=Re(AS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let k="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[k]=pg(C);break;case nr.SimpleBezier:[k]=Wg(C);break;case nr.Step:[k]=Qu({...C,borderRadius:0});break;case nr.SmoothStep:[k]=Qu(C);break;default:[k]=mg(C)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function op(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:C,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,deleteKeyCode:G,onlyRenderVisibleElements:K,elementsSelectable:te,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:U,zoomOnPinch:D,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return op(t),op(r),VS(),LS(o),zS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:K,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:k,component:S,containerStyle:E}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:qe,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),sp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,k=new Map,C=new Map,S=new Map,E=l??r??[],I=o??t??[],N=m??[0,0],j=x??So;xg(C,S,E);const{nodesInitialized:R}=Ku(I,_,k,{nodeOrigin:N,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const H=To(_,{filter:W=>!!((W.width||W.initialWidth)&&(W.height||W.initialHeight))}),{x:G,y:K,zoom:te}=fc(H,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,K,te]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:S,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.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:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,k)=>{async function C(){const{nodeLookup:S,panZoom:E,fitViewOptions:I,fitViewResolver:N,width:j,height:R,minZoom:T,maxZoom:H}=k();E&&(await e1({nodes:S,width:j,height:R,panZoom:E,minZoom:T,maxZoom:H},I),N==null||N.resolve(!0),_({fitViewResolver:null}))}return{...sp({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:S=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:H,nodesSelectionActive:G}=k(),{nodesInitialized:K,hasSelectedNodes:te}=Ku(S,E,I,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:H}),W=G&&te;T&&K?(C(),_({nodes:S,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:W})):_({nodes:S,nodesInitialized:K,nodesSelectionActive:W})},setEdges:S=>{const{connectionLookup:E,edgeLookup:I}=k();xg(E,I,S),_({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:I}=k();I(S),_({hasDefaultNodes:!0})}if(E){const{setEdges:I}=k();I(E),_({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:N,domNode:j,nodeOrigin:R,nodeExtent:T,debug:H,fitViewQueued:G,zIndexMode:K}=k(),{changes:te,updatedInternals:W}=k1(S,I,N,j,R,T,K);W&&(x1(I,N,{nodeOrigin:R,nodeExtent:T,zIndexMode:K}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(H&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(S,E=!1)=>{const I=[];let N=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:H,onNodesChangeMiddlewareMap:G}=k();for(const[K,te]of S){const W=j.get(K),ee=!!(W!=null&&W.expandParent&&(W!=null&&W.parentId)&&(te!=null&&te.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(W&&T.inProgress&&T.fromNode.id===W.id){const b=Dr(W,T.fromHandle,Se.Left,!0);H({...T,from:b})}ee&&W.parentId&&I.push({id:K,parentId:W.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),N.push(J)}if(I.length>0){const{parentLookup:K,nodeOrigin:te}=k(),W=vc(I,j,K,te);N.push(...W)}for(const K of G.values())N=K(N);R(N)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:I,nodes:N,hasDefaultNodes:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=N_(S,N);I(T)}R&&console.log("React Flow: trigger node changes",S),E==null||E(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:I,edges:N,hasDefaultEdges:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=C_(S,N);I(T)}R&&console.log("React Flow: trigger edge changes",S),E==null||E(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));j(T);return}j(gi(N,new Set([...S]),!0)),R(gi(I))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));R(T);return}R(gi(I,new Set([...S]))),j(gi(N,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:I,nodes:N,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=k(),H=S||N,G=E||I,K=[];for(const W of H){if(!W.selected)continue;const ee=j.get(W.id);ee&&(ee.selected=!1),K.push(br(W.id,!1))}const te=[];for(const W of G)W.selected&&te.push(br(W.id,!1));R(K),T(te)},setMinZoom:S=>{const{panZoom:E,maxZoom:I}=k();E==null||E.setScaleExtent([S,I]),_({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:I}=k();E==null||E.setScaleExtent([I,S]),_({maxZoom:S})},setTranslateExtent:S=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(S),_({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:N,elementsSelectable:j}=k();if(!j)return;const R=E.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]),T=S.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]);I(R),N(T)},setNodeExtent:S=>{const{nodes:E,nodeLookup:I,parentLookup:N,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:H}=k();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(Ku(E,I,N,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:H}),_({nodeExtent:S}))},panBy:S=>{const{transform:E,width:I,height:N,panZoom:j,translateExtent:R}=k();return E1({delta:S,panZoom:j,transform:E,translateExtent:R,width:I,height:N})},setCenter:async(S,E,I)=>{const{width:N,height:j,maxZoom:R,panZoom:T}=k();if(!T)return!1;const H=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:N/2-S*H,y:j/2-E*H,zoom:H},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:S=>{_({connection:S})},reset:()=>_({...sp()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[k]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:k,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onBeforeDelete:B,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:q=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:qe=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:Or=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Tr.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Fr=10,onNodesChange:ji,onEdgesChange:Tl,noDragClassName:Rl="nodrag",noWheelClassName:Ll="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Al,attributionPosition:Ao,proOptions:zo,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Hr,isValidConnection:$l,onError:Ho,style:Br,id:Mt,nodeDragThreshold:Ol,connectionDragThreshold:Pt,viewport:Fl,onViewportChange:Hl,width:Bl,height:Vr,colorMode:Ur="light",debug:hr,onScroll:yn,ariaLabelConfig:Vl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Ur),Ul=$.useCallback(Wr=>{Wr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Wr)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Ul,style:{...Br,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Bl,height:Vr,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:qe,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Tl,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Al,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:qe,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanSpeed:Fo,onError:Ho,connectionRadius:Hr,isValidConnection:$l,selectNodesOnDrag:je,nodeDragThreshold:Ol,connectionDragThreshold:Pt,onBeforeDelete:B,debug:hr,ariaLabelConfig:Vl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:q,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:Or,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Fr,defaultMarkerColor:gn,noDragClassName:Rl,noWheelClassName:Ll,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Fl,onViewportChange:Hl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:zo,position:Ao}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var qS=Lg(QS);function KS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),k=l||JS[r],C=r===rr.Dots,S=r===rr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*v[2]||1,E[1]*v[2]||1],N=k*v[2],j=Array.isArray(u)?u:[u,u],R=S?[N,N]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],H=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...Ml,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:H,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:N/2,className:m}):p.jsx(KS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const k=He(),{isInteractive:C,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:N,zoomOut:j,fitView:R}=bl(),T=()=>{N(),u==null||u()},H=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},K=()=>{k.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},te=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",te,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:H,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:S,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:K,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:k,backgroundColor:C}=u||{},S=d||k||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?E=>_(E,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),$u=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=$u(r),y=$u(t),m=$u(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(k=>{const C=k.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const S=C.internals.userNode,{x:E,y:I}=C.internals.positionAbsolute,{width:N,height:j}=rn(S);return{node:S,x:E,y:I,width:N,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},lp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>lp(t.viewBB,r.viewBB)&&lp(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:k,pannable:C=!1,zoomable:S=!1,ariaLabel:E,inversePan:I,zoomStep:N=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:H,viewBB:G,rfId:K,panZoom:te,translateExtent:W,flowWidth:ee,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,U=H.width/Y,D=H.height/V,z=Math.max(U,D),B=z*Y,M=z*V,L=j*z,ne=H.x-(B-H.width)/2-L,re=H.y-(M-H.height)/2-L,ce=B+L*2,fe=M+L*2,de=`${_k}-${K}`,q=$.useRef(0),se=$.useRef();q.current=z,$.useEffect(()=>{if(T.current&&te)return se.current=R1({domNode:T.current,panZoom:te,getTransform:()=>R.getState().transform,getViewScale:()=>q.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[te]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:W,width:ee,height:J,inversePan:I,pannable:C,zoomStep:N,zoomable:S})},[C,S,I,N,W,ee,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=k?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;k(ye,Pe)},[]):void 0,me=E??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*z: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:k,onResizeStart:C,onResize:S,onResizeEnd:E}){const I=Og(),N=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,H=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),K=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!N))return G.current||(G.current=Y1({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(W,ee)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),U=[],D={x:W.x,y:W.y},z=b.get(N);if(z&&z.expandParent&&z.parentId){const B=z.origin??V,M=W.width??z.measured.width??0,L=W.height??z.measured.height??0,ne={id:z.id,parentId:z.parentId,rect:{width:M,height:L,...ug({x:W.x??z.position.x,y:W.y??z.position.y},{width:M,height:L},z.parentId,b,B)}},re=vc([ne],b,Y,V);U.push(...re),D.x=W.x?Math.max(B[0]*M,W.x):void 0,D.y=W.y?Math.max(B[1]*L,W.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:N,type:"position",position:{...D}};U.push(B)}if(W.width!==void 0&&W.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:W.width,height:W.height}};U.push(M)}for(const B of ee){const M={...B,type:"position"};U.push(M)}J(U)},onEnd:({width:W,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:W,height:ee}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:K,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:S,onResizeEnd:E,shouldResize:k}),()=>{var W;(W=G.current)==null||W.destroy()}},[K,f,g,y,m,x,C,S,E,k]);const te=K.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...te,o,l]),ref:R,style:{...a,scale:H,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"arch.context":0,"django.app":0,"django.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"django.serializer_field":5,"django.service":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"openapi.path":9,"react.api_client":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"react.component":13,"react.form_schema":14,"react.test":14,"react.context":13};function Il(t){return Ck[t]??8}const ec=208,tc=64,jk=88,bk=28,Mk=8;function Pk(t){if(!t.length)return Number.NaN;const r=[...t].sort((l,a)=>l-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Ik(t,r=[]){const o=new Map;if(!t.length)return o;const l=new Map;for(const C of t){const S=Il(C.type),E=l.get(S)??[];E.push(C),l.set(S,E)}const u=[...l.keys()].sort((C,S)=>C-S).map(C=>[...l.get(C)??[]].sort((S,E)=>S.name.localeCompare(E.name)||S.id.localeCompare(E.id))),d=new Set(t.map(C=>C.id)),f=new Map,g=new Map;for(const C of t)f.set(C.id,[]),g.set(C.id,[]);for(const C of r)!d.has(C.src)||!d.has(C.dst)||C.src===C.dst||(g.get(C.src).push(C.dst),f.get(C.dst).push(C.src));const y=new Map,m=()=>{for(const C of u)C.forEach((S,E)=>y.set(S.id,E))};m();const x=(C,S)=>{const E=C.map((I,N)=>{const j=S(I.id).map(T=>y.get(T)).filter(T=>T!==void 0),R=Pk(j);return{n:I,bary:Number.isNaN(R)?N:R,name:I.name,id:I.id}});return E.sort((I,N)=>I.bary-N.bary||I.name.localeCompare(N.name)||I.id.localeCompare(N.id)),E.map(I=>I.n)};for(let C=0;Cf.get(E)??[]),m();for(let S=u.length-2;S>=0;S--)u[S]=x(u[S],E=>g.get(E)??[]),m()}const v=ec+jk,_=tc+bk,k=Math.max(...u.map(C=>C.length),1);return u.forEach((C,S)=>{const E=(k-C.length)*_/2;C.forEach((I,N)=>{o.set(I.id,{x:S*v,y:E+N*_})})}),o}const cm=90,Tk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ap={"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"},Rk=Math.PI*(3-Math.sqrt(5)),dm=220,Lk=26,Ak={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function mE(t){return ap[t]?ap[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function zk(t){return t>=cm?"3d":"2d"}function Dk(t){return t>=cm?"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(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!Tk.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(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function yE(t){const r=new Map;for(const l of t){const a=Il(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Lk*Math.sqrt(f+1),y=f*Rk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function vE(t){const r=new Map;for(const o of t){const l=Il(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*dm,count:l}))}const el=16,Fk=12,Hk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),Bk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),up={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Vk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},cp=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],dp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Uk=new Set(["looks_idempotent_on_pk"]),Wk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Yk(t){return up[t]?up[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Xk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Hk.has(t.type)&&a.push("sink"),Bk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>fp(x,l,x.src)),y=f.slice(0,el).map(x=>fp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ak[Il(t.type)]??"other",purpose:Yk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Gk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function fp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Gk(t){const r=[...cp.filter(a=>a in t),...Object.keys(t).filter(a=>!cp.includes(a)&&!dp.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||dp.has(a)||Wk.has(a))continue;l.add(a);const u=Qk(a,t[a]);u!=null&&o.push({key:a,label:Vk[a]??yo(a),value:u})}return o}function Qk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Uk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Fk),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const qk=new Set,Kk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-B5oUhOgB.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Zk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Jk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const eE={load:Jk},tE=new Set(["django","react","stitch","arch"]);function nE({topologyKey:t}){const{fitView:r}=bl();return $.useEffect(()=>{let o=0;const l=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(o)}},[r,t]),null}function rE(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=Ik(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:ec,height:tc,style:{width:ec,height:tc}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Zk[f.weight]||"var(--edge-cheap)",y=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:y?f.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Xk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:Mr(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:Mr(a.context)}):null,a.file?p.jsx("div",{className:"file",children:Mr(a.file)}):null,p.jsx("div",{className:"muted",children:Mr(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:Mr(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:Mr(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function Ou({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(tE)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??zk(t.length),k=d??Dk(t.length),C=m&&_==="3d"?o:null,S=$.useMemo(()=>Ok(t,r,{detail:k,families:g,focusId:C,neighborhoodOnly:!!C}),[t,r,k,g,C]),E=$.useMemo(()=>`${S.nodes.map(W=>W.id).join("\0")}|${S.edges.map(W=>W.id).join("\0")}`,[S.nodes,S.edges]),I=$.useMemo(()=>new Map(S.nodes.map(W=>[W.id,W])),[S.nodes]),N=o?I.get(o)??null:null,{rfNodes:j,rfEdges:R}=$.useMemo(()=>{const W=rE(S.nodes,S.edges,o);return v&&(W.rfEdges=W.rfEdges.map(ee=>({...ee,animated:!1}))),W},[S.nodes,S.edges,o,v]);$.useEffect(()=>{o&&!I.has(o)&&l(null)},[I,o]);const T=(W,ee)=>{l(ee.id)},H=()=>{l(null),x(!1)},G=W=>{y(ee=>{const J=new Set(ee);if(J.has(W)){if(J.size===1)return ee;J.delete(W)}else J.add(W);return J})},K=$.useMemo(()=>{const W=new Set;for(const ee of t)W.add(fm(ee.type));return W},[t]),te=t.length-S.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:k==="overview"?"active":"","aria-pressed":k==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:k==="full"?"active":"","aria-pressed":k==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(W=>K.has(W)).map(W=>p.jsx("button",{type:"button","data-testid":`graph-family-${W}`,className:g.has(W)?"active":"","aria-pressed":g.has(W),onClick:()=>G(W),children:W},W))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(W=>!W),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[S.nodes.length," nodes · ",S.edges.length," edges",te?` · ${te} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Kk,{nodes:S.nodes,edges:S.edges,selectedId:o,neighborIds:C?S.neighborIds:qk,onSelect:W=>{l(W),W||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]}):p.jsxs(sm,{children:[p.jsxs(qS,{nodes:j,edges:R,nodeTypes:eE,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:H,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(nE,{topologyKey:E}),p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],iE=["preset","branch","tag","commit"];function oE(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function sE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function lE(t){return iE.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function aE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,k]=$.useState(0),C=$.useMemo(()=>{const j=oE(u);return x===null?j:sE(j,x)},[u,x]),S=$.useMemo(()=>lE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{k(0)},[x,y]);const E=()=>{m(!1),v(null)},I=j=>{r(j.value),E()},N=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}k(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),E())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:N}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?E():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:S.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):S.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:aE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:H=>H.preventDefault(),onMouseEnter:()=>k(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function uE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),k=$.useRef(0),C=async N=>{const j=k.current+1;k.current=j,v(!0);try{const R=await Ve.browse(N);if(k.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(k.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{k.current===j&&v(!1)}};$.useEffect(()=>{var N,j;C(t),(N=_.current)==null||N.focus(),(j=_.current)==null||j.select()},[t]);const S=f||(l==null?void 0:l.path)||u,E=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:N=>d(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(N=>{const j=f===N.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void C(N.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:S,children:S}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!S,onClick:()=>S&&r(S),children:["Use ",E]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],cE="obsidian",hm="loadpath.theme";function dE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(dE(t))return t}catch{}return cE}function fE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=fE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function hE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[k,C]=$.useState("review"),[S,E]=$.useState(""),[I,N]=$.useState(""),[j,R]=$.useState(""),[T,H]=$.useState({}),[G,K]=$.useState([]),[te,W]=$.useState([]),[ee,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,U]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,z]=$.useState(""),[B,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[q,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,N(F)};$.useEffect(()=>{Ve.settings().then(H).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),qe=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(U(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);W(be.repos),(ae=be.user)!=null&&ae.login&&H($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{W([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||W([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!q)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(q.flow_id);if(F)return;if($e.status==="complete"){se(null);const ze=await Ve.settings();H(ze),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||q.interval,5)*1e3);return}se(null),E($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),E($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(q.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[q,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const ze=await Ve.oauthStatus();if(F)return;if(ze.bitbucket.connected){_e(!1);const Rn=await Ve.settings();H(Rn),R(ze.bitbucket.user?`Signed in to Bitbucket as ${ze.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),E("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(ze){if(F)return;_e(!1),E(ze instanceof Error?ze.message:String(ze))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Tracing load path…"),Ge(o),qe(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){E(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){E(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){E(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!ee||!V){E("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,ee,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){E(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,ee);K(F.pull_requests);const ae=te.find(be=>be.slug.toLowerCase()===ee.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{E("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){E(F instanceof Error?F.message:String(F))}},Or=async()=>{E("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),E(F instanceof Error?F.message:String(F))}},ir=async F=>{E("");try{H(await Ve.oauthDisconnect(F)),b===F&&W([]),R(`Disconnected ${F}`)}catch(ae){E(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(ze=>({path:ze.path,name:ze.name}))}:be;try{H(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(ze){E(ze instanceof Error?ze.message:String(ze))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);z(F.note)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){E(""),R("");return}const $e=yp.find(ze=>ze.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,m,g]),sr=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[k,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:B,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>qe(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>qe(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[S?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:S}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(pE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx(Ou,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(gE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx(Ou,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx(Ou,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,ee,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:te.length?"Search your repos":"owner/repo",value:ee,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:te.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),te.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[te.length," ",b," repositor",te.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{qe(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=te.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:B===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!q||!T.github_oauth_ready,onClick:()=>void Ni(),children:q?"Waiting for GitHub…":"Sign in with GitHub"})})]}),q?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:q.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void Or(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(uE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function pE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,k,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(S=>p.jsx("li",{children:S},S))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(S=>p.jsx("span",{className:"chip",children:yo(S)},S))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((S,E)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[E+1,". ",S.path]}),p.jsx("div",{className:"why",children:S.why})]},S.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:S.title})," — ",S.files.join(", ")]},S.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(S=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${S.severity}`,children:S.severity}),S.message]},S.rule+S.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(S=>p.jsx("div",{className:"residual muted",children:S},S))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(S=>S.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(S=>p.jsx("div",{className:"muted",children:S},S)),(((k=t.evolution)==null?void 0:k.hotspots)||[]).filter(S=>S.commits).slice(0,6).map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:S.path})," — ",S.commits," commits, bus factor ",S.bus_factor]},S.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function gE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(hE,{})}));export{Ak as L,vE as a,mE as c,p as j,yE as l,$ as r,yl as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 779cfb5..385e27d 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index f0e92dd..c94cd46 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -51,7 +51,7 @@ function LoadNode({ data, selected }: { data: { name: string; type: string }; se
{typeLabel(data.type)}
- {data.name} + {wrapHint(data.name)}
diff --git a/ui/src/graphView.ts b/ui/src/graphView.ts index a011e7a..59dfc31 100644 --- a/ui/src/graphView.ts +++ b/ui/src/graphView.ts @@ -55,18 +55,19 @@ 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", + 2: "url names", + 3: "views", + 4: "serializers", + 5: "services", + 6: "models", + 7: "fields", + 8: "jobs / signals", + 9: "openapi", + 10: "api client", + 11: "hooks", + 12: "pages", + 13: "components", + 14: "forms / tests", }; export function familyFor(type: string): GraphFamily { diff --git a/ui/src/types.test.ts b/ui/src/types.test.ts index 2702176..728eb8e 100644 --- a/ui/src/types.test.ts +++ b/ui/src/types.test.ts @@ -30,6 +30,9 @@ describe("load-path layout", () => { expect(pos.get("c")!.x).toBeLessThan(pos.get("p")!.x); expect(pos.get("p")!.x).toBeLessThan(pos.get("f")!.x); expect(layerFor("django.serializer_field")).toBeLessThan(layerFor("react.form_schema")); + expect(layerFor("django.route")).toBeLessThan(layerFor("django.url_name")); + expect(layerFor("django.url_name")).toBeLessThan(layerFor("django.view")); + expect(layerFor("django.management_command")).toBe(layerFor("django.task")); }); it("packs occupied layers so empty columns do not open huge gaps", () => { @@ -62,6 +65,17 @@ describe("load-path layout", () => { } }); + it("puts url names in their own column between routes and views", () => { + const nodes = [ + node("r", "django.route", "/widget/product_list"), + node("u", "django.url_name", "event.widget.productlist"), + node("v", "django.view", "WidgetAPIProductList"), + ]; + const pos = layoutNodes(nodes, [edge("r", "u"), edge("u", "v")]); + expect(pos.get("r")!.x).toBeLessThan(pos.get("u")!.x); + expect(pos.get("u")!.x).toBeLessThan(pos.get("v")!.x); + }); + it("uncrosses a swapped pair with a barycenter pass", () => { const nodes = [ node("a", "django.route", "A"), diff --git a/ui/src/types.ts b/ui/src/types.ts index 80b8a03..1b35eec 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -223,34 +223,36 @@ export const LAYER_ORDER: Record = { "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, + "django.url_name": 2, + "django.view": 3, + "django.viewset_action": 3, + "django.permission": 3, + "django.throttle": 3, + "django.serializer": 4, + "django.form": 4, + "django.serializer_field": 5, + "django.service": 5, + "django.model": 6, + "django.field": 7, + "django.relation": 7, + "django.task": 8, + "django.receiver": 8, + "django.signal": 8, + "django.test": 8, + "django.migration_op": 8, + "django.admin": 8, + "django.management_command": 8, + "openapi.path": 9, + "react.api_client": 10, + "react.query_key": 11, + "react.hook": 11, + "react.feature": 11, + "react.route": 12, + "react.page": 12, + "react.component": 13, + "react.form_schema": 14, + "react.test": 14, + "react.context": 13, }; export function layerFor(type: string): number { From 2b7f69949f821ba0a1b28266d5d19c234ad69ed1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 11:23:01 +0000 Subject: [PATCH 5/7] Show a loading state when switching workspaces. Picking another indexed repo left the previous review graph on screen with no indication that architecture was still loading. Clear stale review data, show the progress bar and a workspace placeholder, and wait for the new graph plus git refs before rendering again. Co-authored-by: zord.lack.net --- ...B5oUhOgB.js => LayeredGraph3D-CN-VAdGf.js} | 2 +- ...{index-DiHJRVJW.css => index-B1geo4g4.css} | 2 +- src/loadpath/static/assets/index-BX4jL2Pk.js | 62 +++++++++++++++++++ src/loadpath/static/assets/index-Dc1-DXoM.js | 62 ------------------- src/loadpath/static/index.html | 4 +- tests/e2e/test_ui_flows.py | 55 ++++++++++++++++ ui/src/App.tsx | 57 ++++++++++++----- ui/src/styles.css | 10 +++ ui/src/styles.test.ts | 10 +++ 9 files changed, 184 insertions(+), 80 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-B5oUhOgB.js => LayeredGraph3D-CN-VAdGf.js} (99%) rename src/loadpath/static/assets/{index-DiHJRVJW.css => index-B1geo4g4.css} (85%) create mode 100644 src/loadpath/static/assets/index-BX4jL2Pk.js delete mode 100644 src/loadpath/static/assets/index-Dc1-DXoM.js diff --git a/src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js b/src/loadpath/static/assets/LayeredGraph3D-CN-VAdGf.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js rename to src/loadpath/static/assets/LayeredGraph3D-CN-VAdGf.js index e00a861..477c0c8 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-B5oUhOgB.js +++ b/src/loadpath/static/assets/LayeredGraph3D-CN-VAdGf.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Dc1-DXoM.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-BX4jL2Pk.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-DiHJRVJW.css b/src/loadpath/static/assets/index-B1geo4g4.css similarity index 85% rename from src/loadpath/static/assets/index-DiHJRVJW.css rename to src/loadpath/static/assets/index-B1geo4g4.css index e016481..bd35962 100644 --- a/src/loadpath/static/assets/index-DiHJRVJW.css +++ b/src/loadpath/static/assets/index-B1geo4g4.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item .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}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item .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}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}*{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-BX4jL2Pk.js b/src/loadpath/static/assets/index-BX4jL2Pk.js new file mode 100644 index 0000000..e8197ce --- /dev/null +++ b/src/loadpath/static/assets/index-BX4jL2Pk.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 xp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _u={exports:{}},uo={},Su={exports:{}},Ie={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vf;function Qy(){if(Vf)return Ie;Vf=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"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),x=Symbol.iterator;function v(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,C={};function S(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}S.prototype.isReactComponent={},S.prototype.setState=function(M,L){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,L,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=S.prototype;function I(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}var N=I.prototype=new E;N.constructor=I,k(N,S.prototype),N.isPureReactComponent=!0;var j=Array.isArray,R=Object.prototype.hasOwnProperty,T={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function G(M,L,ne){var re,ce={},fe=null,de=null;if(L!=null)for(re in L.ref!==void 0&&(de=L.ref),L.key!==void 0&&(fe=""+L.key),L)R.call(L,re)&&!H.hasOwnProperty(re)&&(ce[re]=L[re]);var q=arguments.length-2;if(q===1)ce.children=ne;else if(1>>1,L=D[M];if(0>>1;Ma(ce,B))fea(de,ce)?(D[M]=de,D[fe]=B,M=fe):(D[M]=ce,D[re]=B,M=re);else if(fea(de,B))D[M]=de,D[fe]=B,M=fe;else break e}}return z}function a(D,z){var B=D.sortIndex-z.sortIndex;return B!==0?B:D.id-z.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 g=[],m=[],y=1,x=null,v=3,_=!1,k=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=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(D){for(var z=o(m);z!==null;){if(z.callback===null)l(m);else if(z.startTime<=D)l(m),z.sortIndex=z.expirationTime,r(g,z);else break;z=o(m)}}function j(D){if(C=!1,N(D),!k)if(o(g)!==null)k=!0,V(R);else{var z=o(m);z!==null&&U(j,z.startTime-D)}}function R(D,z){k=!1,C&&(C=!1,E(G),G=-1),_=!0;var B=v;try{for(N(z),x=o(g);x!==null&&(!(x.expirationTime>z)||D&&!W());){var M=x.callback;if(typeof M=="function"){x.callback=null,v=x.priorityLevel;var L=M(x.expirationTime<=z);z=t.unstable_now(),typeof L=="function"?x.callback=L:x===o(g)&&l(g),N(z)}else l(g);x=o(g)}if(x!==null)var ne=!0;else{var re=o(m);re!==null&&U(j,re.startTime-z),ne=!1}return ne}finally{x=null,v=B,_=!1}}var T=!1,H=null,G=-1,K=5,te=-1;function W(){return!(t.unstable_now()-teD||125M?(D.sortIndex=B,r(m,D),o(g)===null&&D===o(m)&&(C?(E(G),G=-1):C=!0,U(j,B-M))):(D.sortIndex=L,r(g,D),k||_||(k=!0,V(R))),D},t.unstable_shouldYield=W,t.unstable_wrapCallback=function(D){var z=v;return function(){var B=v;v=z;try{return D.apply(this,arguments)}finally{v=B}}}})(Nu)),Nu}var Gf;function e0(){return Gf||(Gf=1,Eu.exports=Jy()),Eu.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qf;function t0(){if(Qf)return Ct;Qf=1;var t=bo(),r=e0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,m=/^[: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]*$/,y={},x={};function v(e){return g.call(x,e)?!0:g.call(y,e)?!1:m.test(e)?x[e]=!0:(y[e]=!0,!1)}function _(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 k(e,n,i,s){if(n===null||typeof n>"u"||_(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 S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){S[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];S[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){S[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){S[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){S[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){S[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){S[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){S[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){S[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function I(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,I);S[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,I);S[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,I);S[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),S.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,s){var c=S.hasOwnProperty(n)?S[n]:null;(c!==null?c.type!==0:s||!(2P||c[w]!==h[P]){var A=` +`+c[w].replace(" at new "," at ");return e.displayName&&A.includes("")&&(A=A.replace("",e.displayName)),A}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case T:return"Portal";case K:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case W:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function le(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function pe(e){var n=le(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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function ge(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),s="";return e&&(s=le(e)?e.checked?"true":"false":e.value),e=s,e!==i?(n.setValue(e),!0):!1}function ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(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 be(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Me(e,n){be(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")?Qe(e,n.type,i):n.hasOwnProperty("defaultValue")&&Qe(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 Qe(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Je=Array.isArray;function qe(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=vt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Wt(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var yn={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},ji=["Webkit","ms","Moz","O"];Object.keys(yn).forEach(function(e){ji.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),yn[n]=yn[e]})});function Or(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||yn.hasOwnProperty(e)&&yn[e]?(""+n).trim():n+"px"}function Fr(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=Or(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Hr=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 sr(e,n){if(n){if(Hr[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 lr(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 Tn=null;function vn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rn=null,sn=null,ln=null;function Br(e){if(e=Gi(e)){if(typeof Rn!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),Rn(e.stateNode,e.type,n))}}function Mt(e){sn?ln?ln.push(e):ln=[e]:sn=e}function ar(){if(sn){var e=sn,n=ln;if(ln=sn=null,Br(e),n)for(e=0;e>>=0,e===0?32:31-(Fl(e)/Hl|0)|0}var Wr=64,Yr=4194304;function hr(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 xn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-It(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Oi),Ac=" ",zc=!1;function Dc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $c(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qr=!1;function Ym(e,n){switch(e){case"compositionend":return $c(n);case"keypress":return n.which!==32?null:(zc=!0,Ac);case"textInput":return e=n.data,e===Ac&&zc?null:e;default:return null}}function Xm(e,n){if(qr)return e==="compositionend"||!ta&&Dc(e,n)?(e=Mc(),Go=Ql=Fn=null,qr=!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=Wc(i)}}function Xc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Xc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Gc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ia(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 ny(e){var n=Gc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Xc(i.ownerDocument.documentElement,i)){if(s!==null&&ia(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=Yc(i,h);var w=Yc(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,Kr=null,oa=null,Vi=null,sa=!1;function Qc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;sa||Kr==null||Kr!==ye(s)||(s=Kr,"selectionStart"in s&&ia(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(oa,"onSelect"),0ni||(e.current=va[ni],va[ni]=null,ni--)}function De(e,n){ni++,va[ni]=e.current,e.current=n}var Un={},ht=Vn(Un),_t=Vn(!1),yr=Un;function ri(e,n){var i=e.type.contextTypes;if(!i)return Un;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(ht)}function cd(e,n,i){if(ht.current!==Un)throw Error(o(168));De(ht,n),De(_t,i)}function dd(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,de(e)||"Unknown",c));return B({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Un,yr=ht.current,De(ht,e),De(_t,_t.current),!0}function fd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=dd(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(ht),De(ht,e)):Fe(_t),De(_t,i)}var _n=null,as=!1,xa=!1;function hd(e){_n===null?_n=[e]:_n.push(e)}function py(e){as=!0,hd(e)}function Wn(){if(!xa&&_n!==null){xa=!0;var e=0,n=Ae;try{var i=_n;for(Ae=1;e>=w,c-=w,Sn=1<<32-It(n)+c|i<je?(ct=Ee,Ee=null):ct=Ee.sibling;var Le=oe(X,Ee,Q[je],ue);if(Le===null){Ee===null&&(Ee=ct);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,je),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=ct}if(je===Q.length)return i(X,Ee),Be&&xr(X,je),we;if(Ee===null){for(;jeje?(ct=Ee,Ee=null):ct=Ee.sibling;var er=oe(X,Ee,Le.value,ue);if(er===null){Ee===null&&(Ee=ct);break}e&&Ee&&er.alternate===null&&n(X,Ee),O=h(er,O,je),ke===null?we=er:ke.sibling=er,ke=er,Ee=ct}if(Le.done)return i(X,Ee),Be&&xr(X,je),we;if(Ee===null){for(;!Le.done;je++,Le=Q.next())Le=ae(X,Le.value,ue),Le!==null&&(O=h(Le,O,je),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,je),we}for(Ee=s(X,Ee);!Le.done;je++,Le=Q.next())Le=he(Ee,X,je,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?je:Le.key),O=h(Le,O,je),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,je),we}function Ke(X,O,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 R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===H){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&xd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===H?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=zs(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=mu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,Ke(X,O,ke(Q._payload),ue)}if(Je(Q))return ve(X,O,Q,ue);if(z(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=gu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return Ke}var li=wd(!0),_d=wd(!1),hs=Vn(null),ps=null,ai=null,Na=null;function Ca(){Na=ai=ps=null}function ja(e){var n=hs.current;Fe(hs),e._currentValue=n}function ba(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 ui(e,n){ps=e,Na=ai=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ht(e){var n=e._currentValue;if(Na!==e)if(e={context:e,memoizedValue:n,next:null},ai===null){if(ps===null)throw Error(o(308));ai=e,ps.dependencies={lanes:0,firstContext:e}}else ai=ai.next=e;return n}var wr=null;function Ma(e){wr===null?wr=[e]:wr.push(e)}function Sd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ma(n)):(i.next=c.next,c.next=i),n.interleaved=i,En(e,s)}function En(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 Yn=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kd(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 Nn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Xn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,En(e,i)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,En(e,i)}function gs(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,Xr(e,i)}}function Ed(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 ms(e,n,i,s){var c=e.updateQueue;Yn=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var A=P,Z=A.next;A.next=null,w===null?h=Z:w.next=Z,w=A;var se=e.alternate;se!==null&&(se=se.updateQueue,P=se.lastBaseUpdate,P!==w&&(P===null?se.firstBaseUpdate=Z:P.next=Z,se.lastBaseUpdate=A))}if(h!==null){var ae=c.baseState;w=0,se=Z=A=null,P=h;do{var oe=P.lane,he=P.eventTime;if((s&oe)===oe){se!==null&&(se=se.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(oe=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){ae=ve.call(he,ae,oe);break e}ae=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,oe=typeof ve=="function"?ve.call(he,ae,oe):ve,oe==null)break e;ae=B({},ae,oe);break e;case 2:Yn=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,oe=c.effects,oe===null?c.effects=[P]:oe.push(P))}else he={eventTime:he,lane:oe,tag:P.tag,payload:P.payload,callback:P.callback,next:null},se===null?(Z=se=he,A=ae):se=se.next=he,w|=oe;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;oe=P,P=oe.next,oe.next=null,c.lastBaseUpdate=oe,c.shared.pending=null}}while(!0);if(se===null&&(A=ae),c.baseState=A,c.firstBaseUpdate=Z,c.lastBaseUpdate=se,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);kr|=w,e.lanes=w,e.memoizedState=ae}}function Nd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Aa.transition;Aa.transition={};try{e(!1),n()}finally{Ae=i,Aa.transition=s}}function Ud(){return Bt().memoizedState}function vy(e,n,i){var s=Kn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(e))Yd(n,i);else if(i=Sd(e,n,i,s),i!==null){var c=wt();Kt(i,e,s,c),Xd(i,n,s)}}function xy(e,n,i){var s=Kn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(e))Yd(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Yt(P,w)){var A=n.interleaved;A===null?(c.next=c,Ma(n)):(c.next=A.next,A.next=c),n.interleaved=c;return}}catch{}finally{}i=Sd(e,n,c,s),i!==null&&(c=wt(),Kt(i,e,s,c),Xd(i,n,s))}}function Wd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Yd(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Xd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Xr(e,i)}}var Ss={readContext:Ht,useCallback:pt,useContext:pt,useEffect:pt,useImperativeHandle:pt,useInsertionEffect:pt,useLayoutEffect:pt,useMemo:pt,useReducer:pt,useRef:pt,useState:pt,useDebugValue:pt,useDeferredValue:pt,useTransition:pt,useMutableSource:pt,useSyncExternalStore:pt,useId:pt,unstable_isNewReconciler:!1},wy={readContext:Ht,useCallback:function(e,n){return fn().memoizedState=[e,n===void 0?null:n],e},useContext:Ht,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Od.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=fn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=fn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=fn();return e={current:e},n.memoizedState=e},useState:Ld,useDebugValue:Ba,useDeferredValue:function(e){return fn().memoizedState=e},useTransition:function(){var e=Ld(!1),n=e[0];return e=yy.bind(null,e[1]),fn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=fn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ut===null)throw Error(o(349));(Sr&30)!==0||Md(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(Id.bind(null,s,h,e),[e]),s.flags|=2048,no(9,Pd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=fn(),n=ut.identifierPrefix;if(Be){var i=kn,s=Sn;i=(s&~(1<<32-It(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,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[cn]=n,e[Xi]=s,pf(e,n,!1,!1),n.stateNode=e;e:{switch(w=lr(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cpi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return gt(n),null}else 2*Ue()-h.renderingStartTime>pi&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(gt(n),null);case 22:case 23:return fu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(At&1073741824)!==0&&(gt(n),n.subtreeFlags&6&&(n.flags|=8192)):gt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(_a(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ci(),Fe(_t),Fe(ht),La(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ta(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));si()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return ci(),null;case 10:return ja(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Cs=!1,mt=!1,My=typeof WeakSet=="function"?WeakSet:Set,me=null;function fi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Ge(e,n,s)}else i.current=null}function eu(e,n,i){try{i()}catch(s){Ge(e,n,s)}}var yf=!1;function Py(e,n){if(fa=Yo,e=Gc(),ia(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,P=-1,A=-1,Z=0,se=0,ae=e,oe=null;t:for(;;){for(var he;ae!==i||c!==0&&ae.nodeType!==3||(P=w+c),ae!==h||s!==0&&ae.nodeType!==3||(A=w+s),ae.nodeType===3&&(w+=ae.nodeValue.length),(he=ae.firstChild)!==null;)oe=ae,ae=he;for(;;){if(ae===e)break t;if(oe===i&&++Z===c&&(P=w),oe===h&&++se===s&&(A=w),(he=ae.nextSibling)!==null)break;ae=oe,oe=ae.parentNode}ae=he}i=P===-1||A===-1?null:{start:P,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(ha={focusedElem:e,selectionRange:i},Yo=!1,me=n;me!==null;)if(n=me,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,me=e;else for(;me!==null;){n=me;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,Ke=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Gt(n.type,xe),Ke);X.__reactInternalSnapshotBeforeUpdate=O}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){Ge(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,me=e;break}me=n.return}return ve=yf,yf=!1,ve}function io(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&&eu(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function tu(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 vf(e){var n=e.alternate;n!==null&&(e.alternate=null,vf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[cn],delete n[Xi],delete n[ya],delete n[fy],delete n[hy])),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 xf(e){return e.tag===5||e.tag===3||e.tag===4}function wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 nu(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=is));else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}function ru(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(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}var dt=null,Qt=!1;function Gn(e,n,i){for(i=i.child;i!==null;)_f(e,n,i),i=i.sibling}function _f(e,n,i){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Ur,i)}catch{}switch(i.tag){case 5:mt||fi(i,n);case 6:var s=dt,c=Qt;dt=null,Gn(e,n,i),dt=s,Qt=c,dt!==null&&(Qt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Qt?(e=dt,i=i.stateNode,e.nodeType===8?ma(e.parentNode,i):e.nodeType===1&&ma(e,i),zi(e)):ma(dt,i.stateNode));break;case 4:s=dt,c=Qt,dt=i.stateNode.containerInfo,Qt=!0,Gn(e,n,i),dt=s,Qt=c;break;case 0:case 11:case 14:case 15:if(!mt&&(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)&&eu(i,n,w),c=c.next}while(c!==s)}Gn(e,n,i);break;case 1:if(!mt&&(fi(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Ge(i,n,P)}Gn(e,n,i);break;case 21:Gn(e,n,i);break;case 22:i.mode&1?(mt=(s=mt)||i.memoizedState!==null,Gn(e,n,i),mt=s):Gn(e,n,i);break;default:Gn(e,n,i)}}function Sf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,qn===null)var s=!1;else{if(e=qn,qn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,me=e.current;me!==null;){var h=me,w=h.child;if((me.flags&16)!==0){var P=h.deletions;if(P!==null){for(var A=0;AUe()-su?Nr(e,0):ou|=i),Nt(e,n)}function Af(e,n){n===0&&((e.mode&1)===0?n=1:(n=Yr,Yr<<=1,(Yr&130023424)===0&&(Yr=4194304)));var i=wt();e=En(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Af(e,i)}function Oy(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),Af(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&pd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ri(n,ht.current);ui(n,i),c=Da(null,n,s,e,c,i);var h=$a();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Ua(n,s,e,i),n=Ga(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&wa(n),xt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Gt(s,e),c){case 0:n=Xa(null,n,s,e,i);break e;case 1:n=af(null,n,s,e,i);break e;case 11:n=nf(null,n,s,e,i);break e;case 14:n=rf(null,n,s,Gt(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:Gt(s,c),Xa(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Gt(s,c),af(e,n,s,c,i);case 3:e:{if(uf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,kd(e,n),ms(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=di(Error(o(423)),n),n=cf(e,n,s,i,c);break e}else if(s!==c){c=di(Error(o(424)),n),n=cf(e,n,s,i,c);break e}else for(Lt=Bn(n.stateNode.containerInfo.firstChild),Rt=n,Be=!0,Xt=null,i=_d(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(si(),s===c){n=Cn(e,n,i);break e}xt(e,n,s,i)}n=n.child}return n;case 5:return Cd(n),e===null&&ka(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,pa(s,c)?w=null:h!==null&&pa(s,h)&&(n.flags|=32),lf(e,n),xt(e,n,w,i),n.child;case 6:return e===null&&ka(n),null;case 13:return df(e,n,i);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=li(n,null,s,i):xt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Gt(s,c),nf(e,n,s,c,i);case 7:return xt(e,n,n.pendingProps,i),n.child;case 8:return xt(e,n,n.pendingProps.children,i),n.child;case 12:return xt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Yt(h.value,w)){if(h.children===c.children&&!_t.current){n=Cn(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var A=P.firstContext;A!==null;){if(A.context===s){if(h.tag===1){A=Nn(-1,i&-i),A.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var se=Z.pending;se===null?A.next=A:(A.next=se.next,se.next=A),Z.pending=A}}h.lanes|=i,A=h.alternate,A!==null&&(A.lanes|=i),ba(h.return,i,n),P.lanes|=i;break}A=A.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,P=w.alternate,P!==null&&(P.lanes|=i),ba(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}xt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,ui(n,i),c=Ht(c),s=s(c),n.flags|=1,xt(e,n,s,i),n.child;case 14:return s=n.type,c=Gt(s,n.pendingProps),c=Gt(s.type,c),rf(e,n,s,c,i);case 15:return of(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Gt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,ui(n,i),Qd(n,s,c),Ua(n,s,c,i),Ga(null,n,s,!0,e,i);case 19:return hf(e,n,i);case 22:return sf(e,n,i)}throw Error(o(156,n.tag))};function Df(e,n){return Do(e,n)}function Fy(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 Ut(e,n,i,s){return new Fy(e,n,i,s)}function pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===Y)return 14}return 2}function Jn(e,n){var i=e.alternate;return i===null?(i=Ut(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 zs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")pu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case K:return e=Ut(12,i,n,c|2),e.elementType=K,e.lanes=h,e;case J:return e=Ut(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Ut(19,i,n,c),e.elementType=b,e.lanes=h,e;case U:return Ds(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case W:w=9;break e;case ee:w=11;break e;case Y:w=14;break e;case V:w=16,s=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=Ut(w,i,n,c),n.elementType=e,n.type=s,n.lanes=h,n}function jr(e,n,i,s){return e=Ut(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Ut(22,e,s,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function gu(e,n,i){return e=Ut(6,e,null,n),e.lanes=i,e}function mu(e,n,i){return n=Ut(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function yu(e,n,i,s,c,h,w,P,A){return e=new By(e,n,i,P,A),n===1?(n=1,h===!0&&(n|=8)):n=0,h=Ut(3,null,null,n),e.current=h,h.stateNode=e,h.memoizedState={element:s,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Pa(h),e}function Vy(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(),ku.exports=t0(),ku.exports}var Kf;function n0(){if(Kf)return Us;Kf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function a0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Mr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function $r({className:t,children:r}){return p.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 u0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function c0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function d0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function f0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function h0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function p0({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const g0="modulepreload",m0=function(t,r){return new URL(t,r).href},Zf={},y0=function(r,o,l){let a=Promise.resolve();if(o&&o.length>0){let d=function(y){return Promise.all(y.map(x=>Promise.resolve(x).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),m=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(y=>{if(y=m0(y,l),y in Zf)return;Zf[y]=!0;const x=y.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const S=f[C];if(S.href===y&&(!x||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${y}"]${v}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":g0,x||(k.as="script"),k.crossOrigin="",k.href=y,m&&k.setAttribute("nonce",m),document.head.appendChild(k),x)return new Promise((C,S)=>{k.addEventListener("load",C),k.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${y}`)))})}))}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 tt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=x0(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)),eh.hasOwnProperty(r)?{space:eh[r],local:t}:t}function _0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Fu&&r.documentElement.namespaceURI===Fu?r.createElement(t):r.createElementNS(o,t)}}function S0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?S0:_0)(r)}function k0(){}function nc(t){return t==null?k0:function(){return this.querySelector(t)}}function E0(t){typeof t!="function"&&(t=nc(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=I+1);!(R=S[N])&&++N=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function Q0(t){t||(t=q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function K0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Z0(){return Array.from(this)}function J0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?cv:typeof r=="function"?fv:dv)(t,r,o??"")):wi(this.node(),t)}function wi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function pv(t){return function(){delete this[t]}}function gv(t,r){return function(){this[t]=r}}function mv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function yv(t,r){return arguments.length>1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function rc(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=rc(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Wv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Hu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:m,dispatch:y}){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:g,enumerable:!0,configurable:!0},dy:{value:m,enumerable:!0,configurable:!0},_:{value:y}})}Hu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function tx(t){return!t.ctrlKey&&!t.button}function nx(){return this.parentNode}function rx(t,r){return r??{x:t.x,y:t.y}}function ix(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=tx,r=nx,o=rx,l=ix,a={},u=vl("start","drag","end"),d=0,f,g,m,y,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",S).on("touchmove.drag",E,ex).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(y||!t.call(this,j,R))){var T=N(this,r.call(this,j,R),j,R,"mouse");T&&(zt(j.view).on("mousemove.drag",k,vo).on("mouseup.drag",C,vo),Lp(j.view),Cu(j),m=!1,f=j.clientX,g=j.clientY,T("start",j))}}function k(j){if(vi(j),!m){var R=j.clientX-f,T=j.clientY-g;m=R*R+T*T>x}a.mouse("drag",j)}function C(j){zt(j.view).on("mousemove.drag mouseup.drag",null),Ap(j.view,m),vi(j),a.mouse("end",j)}function S(j,R){if(t.call(this,j,R)){var T=j.changedTouches,H=r.call(this,j,R),G=T.length,K,te;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=sx.exec(t))?new jt(r[1],r[2],r[3],1):(r=lx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=ax.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ux.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=cx.exec(t))?lh(r[1],r[2]/100,r[3]/100,1):(r=dx.exec(t))?lh(r[1],r[2]/100,r[3]/100,r[4]):th.hasOwnProperty(t)?ih(th[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function ih(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function px(t){return t instanceof Po||(t=Rr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Bu(t,r,o,l){return arguments.length===1?px(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}ic(jt,Bu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Ir(this.r),Ir(this.g),Ir(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:oh,formatHex:oh,formatHex8:gx,formatRgb:sh,toString:sh}));function oh(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}`}function gx(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}${Pr((isNaN(this.opacity)?1:this.opacity)*255)}`}function sh(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Ir(this.r)}, ${Ir(this.g)}, ${Ir(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ir(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Pr(t){return t=Ir(t),(t<16?"0":"")+t.toString(16)}function lh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Jt(t,r,o,l)}function $p(t){if(t instanceof Jt)return new Jt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Rr(t)),!t)return new Jt;if(t instanceof Jt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Jt(d,f,g,t.opacity)}function mx(t,r,o,l){return arguments.length===1?$p(t):new Jt(t,r,o,l??1)}function Jt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}ic(Jt,mx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Jt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Jt(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 jt(ju(t>=240?t-240:t+120,a,l),ju(t,a,l),ju(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Jt(ah(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${ah(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ah(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function ju(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 oc=t=>()=>t;function yx(t,r){return function(o){return t+o*r}}function vx(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 xx(t){return(t=+t)==1?Op:function(r,o){return o-r?vx(r,o,t):oc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?yx(t,o):oc(isNaN(t)?r:t)}const ul=(function t(r){var o=xx(r);function l(a,u){var d=o((a=Bu(a)).r,(u=Bu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),m=Op(a.opacity,u.opacity);return function(y){return a.r=d(y),a.g=f(y),a.b=g(y),a.opacity=m(y),a+""}}return l.gamma=t,l})(1);function wx(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,g.push({i:d,x:pn(l,a)})),o=bu.lastIndex;return o180?y+=360:y-m>180&&(m+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:pn(m,y)})):y&&x.push(a(x)+"rotate("+y+l)}function f(m,y,x,v){m!==y?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:pn(m,y)}):y&&x.push(a(x)+"skewX("+y+l)}function g(m,y,x,v,_,k){if(m!==x||y!==v){var C=_.push(a(_)+"scale(",null,",",null,")");k.push({i:C-4,x:pn(m,x)},{i:C-2,x:pn(y,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(m,y){var x=[],v=[];return m=t(m),y=t(y),u(m.translateX,m.translateY,y.translateX,y.translateY,x,v),d(m.rotate,y.rotate,x,v),f(m.skewX,y.skewX,x,v),g(m.scaleX,m.scaleY,y.scaleX,y.scaleY,x,v),m=y=null,function(_){for(var k=-1,C=v.length,S;++k=0&&t._call.call(void 0,r),t=t._next;--_i}function dh(){Lr=(dl=_o.now())+wl,_i=ho=0;try{Ax()}finally{_i=0,Dx(),Lr=0}}function zx(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function Dx(){for(var t,r=cl,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:cl=o);po=t,Wu(l)}function Wu(t){if(!_i){ho&&(ho=clearTimeout(ho));var r=t-Lr;r>24?(t<1/0&&(ho=setTimeout(dh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(zx,Vp)),_i=1,Up(dh))}}function fh(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var $x=vl("start","end","cancel","interrupt"),Ox=[],Yp=0,hh=1,Yu=2,rl=3,ph=4,Xu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Fx(t,o,{name:r,index:l,group:a,on:$x,tween:Ox,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function lc(t,r){var o=rn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function mn(t,r){var o=rn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function rn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Fx(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(m){o.state=hh,o.timer.restart(d,o.delay,o.time),o.delay<=m&&d(m-o.delay)}function d(m){var y,x,v,_;if(o.state!==hh)return g();for(y in l)if(_=l[y],_.name===o.name){if(_.state===rl)return fh(d);_.state===ph?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[y]):+yYu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function mw(t,r,o){var l,a,u=gw(r)?lc:mn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function yw(t,r){var o=this._id;return arguments.length<2?rn(this.node(),o).on.on(t):this.each(mw(o,t,r))}function vw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function xw(){return this.on("end.remove",vw(this._id))}function ww(t){var r=this._name,o=this._id;typeof t!="function"&&(t=nc(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Ww(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 Mn(t,r,o){this.k=t,this.x=r,this.y=o}Mn.prototype={constructor:Mn,scale:function(t){return t===1?this:new Mn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new Mn(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 Sl=new Mn(1,0,0);qp.prototype=Mn.prototype;function qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Yw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Xw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function gh(){return this.__zoom||Sl}function Gw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Qw(){return navigator.maxTouchPoints||"ontouchstart"in this}function qw(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 Kp(){var t=Yw,r=Xw,o=qw,l=Gw,a=Qw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,m=vl("start","zoom","end"),y,x,v,_=500,k=150,C=0,S=10;function E(b){b.property("__zoom",gh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",W).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(b,Y,V,U){var D=b.selection?b.selection():b;D.property("__zoom",gh),b!==D?R(b,Y,V,U):D.interrupt().each(function(){T(this,arguments).event(U).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},E.scaleBy=function(b,Y,V,U){E.scaleTo(b,function(){var D=this.__zoom.k,z=typeof Y=="function"?Y.apply(this,arguments):Y;return D*z},V,U)},E.scaleTo=function(b,Y,V,U){E.transform(b,function(){var D=r.apply(this,arguments),z=this.__zoom,B=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=z.invert(B),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(N(I(z,L),B,M),D,d)},V,U)},E.translateBy=function(b,Y,V,U){E.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,U)},E.translateTo=function(b,Y,V,U,D){E.transform(b,function(){var z=r.apply(this,arguments),B=this.__zoom,M=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Sl.translate(M[0],M[1]).scale(B.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),z,d)},U,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new Mn(Y,b.x,b.y)}function N(b,Y,V){var U=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return U===b.x&&D===b.y?b:new Mn(b.k,U,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,U){b.on("start.zoom",function(){T(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,B=T(D,z).event(U),M=r.apply(D,z),L=V==null?j(M):typeof V=="function"?V.apply(D,z):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,z):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var q=fe(de),le=ne/q[2];de=new Mn(le,L[0]-q[0]*le,L[1]-q[1]*le)}B.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new H(b,Y)}function H(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}H.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=zt(this.that).datum();m.call(b,this.that,new Ww(b,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:m}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),U=this.__zoom,D=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=Zt(b);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=U.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(U.k===D)return;V.mouse=[z,U.invert(z)],ol(this),V.start()}fo(b),V.wheel=setTimeout(B,k),V.zoom("mouse",o(N(I(U,D),V.mouse[0],V.mouse[1]),V.extent,d));function B(){V.wheel=null,V.end()}}function K(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,U=T(this,Y,!0).event(b),D=zt(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),z=Zt(b,V),B=b.clientX,M=b.clientY;Lp(b.view),Mu(b),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function L(re){if(fo(re),!U.moved){var ce=re.clientX-B,fe=re.clientY-M;U.moved=ce*ce+fe*fe>C}U.event(re).zoom("mouse",o(N(U.that.__zoom,U.mouse[0]=Zt(re,V),U.mouse[1]),U.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),Ap(re.view,U.moved),fo(re),U.event(re).end()}}function te(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,U=Zt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(U),z=V.k*(b.shiftKey?.5:2),B=o(N(I(V,z),U,D),r.apply(this,Y),d);fo(b),f>0?zt(this).transition().duration(f).call(R,B,U,b):zt(this).call(E.transform,B,U,b)}}function W(b,...Y){if(t.apply(this,arguments)){var V=b.touches,U=V.length,D=T(this,Y,b.changedTouches.length===U).event(b),z,B,M,L;for(Mu(b),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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 Si;(function(t){t.Strict="strict",t.Loose="loose"})(Si||(Si={}));var Tr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Tr||(Tr={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ir;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(ir||(ir={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const mh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Kw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),uc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=on(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Zw=(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):uc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},cc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,m=r.width/a,y=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:k=!0,hidden:C=!1}=v;if(d&&!k||C)continue;const S=_.width??v.width??v.initialWidth??0,E=_.height??v.height??v.initialHeight??0,{x:I,y:N}=v.internals.positionAbsolute,j=sg(f,g,m,y,I,N,S,E),R=S*E,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Jw=(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 e1(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}=on(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 t1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=e1(t,d),g=To(f),m=fc(g,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(m,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y:m}=f?f.internals.positionAbsolute:{x:0,y:0},y=d.origin??l;let x=d.extent||a;if(d.extent==="parent"&&!d.expandParent)if(!f)u==null||u("005",nn.error005());else{const{width:_,height:k}=on(f);_&&k&&(x=[[g,m],[g+_,m+k]])}else f&&zr(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+m],[d.extent[1][0]+g,d.extent[1][1]+m]]);const v=zr(x)?Ar(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",nn.error015())),{position:{x:v.x-g+(d.measured.width??0)*y[0],y:v.y-m+(d.measured.height??0)*y[1]},positionAbsolute:v}}async function n1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),k=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||k)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),y=Jw(d,g);for(const v of g)f.has(v.id)&&!y.find(k=>k.id===v.id)&&y.push(v);if(!a)return{edges:y,nodes:d};const x=await a({nodes:d,edges:y});return typeof x=="boolean"?x?{edges:y,nodes:d}:{edges:[],nodes:[]}:x}const ki=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Ar=(t={x:0,y:0},r,o)=>({x:ki(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:ki(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=on(o),{x:u,y:d}=o.internals.positionAbsolute;return Ar(t,[[u,d],[u+l,d+a]],r)}const yh=(t,r,o)=>to?-ki(Math.abs(t-o),1,r)/r:0,dc=(t,r,o=15,l=40)=>{const a=yh(t.x,l,r.width-l)*o,u=yh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Gu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Gu(t),Gu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),m=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*m)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),vh=t=>en(t.width)&&en(t.height)&&en(t.x)&&en(t.y),en=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Ei=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function mi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function r1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=mi(t,o),a=mi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=mi(t.top??t.y??0,o),a=mi(t.bottom??t.y??0,o),u=mi(t.left??t.x??0,r),d=mi(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 i1(t,r,o,l,a,u){const{x:d,y:f}=Ei(t,[r,o,l]),{x:g,y:m}=Ei({x:t.x+t.width,y:t.y+t.height},[r,o,l]),y=a-g,x=u-m;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(y),bottom:Math.floor(x)}}const fc=(t,r,o,l,a,u)=>{const d=r1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,m=Math.min(f,g),y=ki(m,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*y,k=o/2-v*y,C=i1(t,_,k,y,r,o),S={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.left+S.right,y:k-S.top+S.bottom,zoom:y}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function zr(t){return t!=null&&t!=="parent"}function on(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 ag(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 ug(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 xh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function o1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function s1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=tn(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y:m}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:m,...f}}const hc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},l1=["INPUT","SELECT","TEXTAREA"];function dg(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:l1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,tn=(t,r)=>{var u,d;const o=fg(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)}},wh=(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,...hc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,m=r*.125+u*.375+f*.375+l*.125,y=Math.abs(g-t),x=Math.abs(m-r);return[g,m,y,x]}function qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function _h({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 pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=_h({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[m,y]=_h({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,k]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:m,targetControlY:y});return[`M${t},${r} C${f},${g} ${m},${y} ${l},${a}`,x,v,_,k]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const c1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,d1=(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)),f1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",nn.error006()),r;const l=o.getEdgeId||c1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},d1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const Sh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},h1=({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 p1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=Sh[r],g=Sh[l],m={x:t.x+f.x*u,y:t.y+f.y*u},y={x:o.x+g.x*u,y:o.y+g.y*u},x=h1({source:m,sourcePosition:r,target:y}),v=x.x!==0?"x":"y",_=x[v];let k=[],C,S;const E={x:0,y:0},I={x:0,y:0},[,,N,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??m.x+(y.x-m.x)*d,S=a.y??(m.y+y.y)/2):(C=a.x??(m.x+y.x)/2,S=a.y??m.y+(y.y-m.y)*d);const G=[{x:C,y:m.y},{x:C,y:y.y}],K=[{x:m.x,y:S},{x:y.x,y:S}];f[v]===_?k=v==="x"?G:K:k=v==="x"?K:G}else{const G=[{x:m.x,y:y.y}],K=[{x:y.x,y:m.y}];if(v==="x"?k=f.x===_?K:G:k=f.y===_?G:K,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?E[v]=(m[v]>t[v]?-1:1)*Y:I[v]=(y[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=m[b]>y[b],U=m[b]=J?(C=(te.x+W.x)/2,S=k[0].y):(C=k[0].x,S=(te.y+W.y)/2)}const R={x:m.x+E.x,y:m.y+E.y},T={x:y.x+I.x,y:y.y+I.y};return[[t,...R.x!==k[0].x||R.y!==k[0].y?[R]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],o],C,S,N,j]}function g1(t,r,o,l){const a=Math.min(kh(t,r)/2,kh(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 m=t.xo.id===r):t[0])||null}function qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function y1(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(g=>{if(g&&typeof g=="object"){const m=qu(g,r);u.has(m)||(d.push({id:m,color:g.color||o,...g}),u.add(m))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,v1=10,pc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},x1={...pc,checkEquality:!0};function gc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function w1(t,r,o){const l=gc(pc,o);for(const a of t.values())if(a.parentId)yc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=zr(a.extent)?a.extent:l.nodeExtent,f=Ar(u,d,on(a));a.internals.positionAbsolute=f}}function _1(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 mc(t){return t==="manual"}function Ku(t,r,o,l={}){var y,x;const a=gc(x1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!mc(a.zIndexMode)?yg:0;let g=t.length>0,m=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const k=Io(v,a.nodeOrigin),C=zr(v.extent)?v.extent:a.nodeExtent,S=Ar(k,C,on(v));_={...a.defaults,...v,measured:{width:(y=v.measured)==null?void 0:y.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:S,handleBounds:_1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&yc(_,r,o,l,u),m||(m=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:m}}function S1(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 yc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=gc(pc,l),m=t.parentId,y=r.get(m);if(!y){console.warn(`Parent node ${m} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}S1(t,o),a&&!y.parentId&&y.internals.rootParentIndex===void 0&&g==="auto"&&(y.internals.rootParentIndex=++a.i,y.internals.z=y.internals.z+a.i*v1),a&&y.internals.rootParentIndex!==void 0&&(a.i=y.internals.rootParentIndex);const x=u&&!mc(g)?yg:0,{x:v,y:_,z:k}=k1(t,y,d,f,x,g),{positionAbsolute:C}=t.internals,S=v!==C.x||_!==C.y;(S||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:S?{x:v,y:_}:C,z:k}})}function vg(t,r,o){const l=en(t.zIndex)?t.zIndex:0;return mc(o)?l:l+(t.selected?r:0)}function k1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=on(t),m=Io(t,o),y=zr(t.extent)?Ar(m,t.extent,g):m;let x=Ar({x:d+y.x,y:f+y.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function vc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const m=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),y=og(m,f.rect);u.set(f.parentId,{expandedRect:y,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},m)=>{var N;const y=g.internals.positionAbsolute,x=on(g),v=g.origin??l,_=f.x0||k>0||E||I)&&(a.push({id:m,type:"position",position:{x:g.position.x-_+E,y:g.position.y-k+I}}),(N=o.get(m))==null||N.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(x.width0){const _=vc(v,r,o,a);m.push(..._)}return{changes:m,updatedInternals:g}}async function N1({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 jh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const m=l.get(d)||new Map;l.set(d,m.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},m=`${a}-${d}--${u}-${f}`,y=`${u}-${f}--${a}-${d}`;jh("source",g,y,t,a,d),jh("target",g,m,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function bh(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 C1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Pu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[m,y]of r){const x=(d=o.get(m))==null?void 0:d.internals.userNode;x&&a.push({...x,position:y.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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function j1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function b1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,m={x:0,y:0},y=null,x=!1,v=null,_=!1,k=!1,C=null;function S({noDragClassName:I,handleSelector:N,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:H=0}){v=zt(j);function G({x:ee,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:U,nodeOrigin:D,onNodeDrag:z,onSelectionDrag:B,onError:M,updateNodePositions:L}=r();u={x:ee,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Gu(To(f)):null,fe=re&&U?j1({dragItems:f,snapGrid:V,x:ee,y:J}):null;for(const[de,q]of f){if(!b.has(de))continue;let le={x:ee-q.distance.x,y:J-q.distance.y};U&&(le=fe?{x:Math.round(le.x+fe.x),y:Math.round(le.y+fe.y)}:Ro(le,V));let pe=null;if(re&&Y&&!q.extent&&ce){const{positionAbsolute:ye}=q.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+q.measured.width-ce.x2+Y[1][0],be=ye.y-ce.y+Y[0][1],Me=ye.y+q.measured.height-ce.y2+Y[1][1];pe=[[Ne,be],[Pe,Me]]}const{position:_e,positionAbsolute:ge}=rg({nodeId:de,nextPosition:le,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||q.position.x!==_e.x||q.position.y!==_e.y,q.position=_e,q.internals.positionAbsolute=ge}if(k=k||ne,!!ne&&(L(f,!0),C&&(l||z||!T&&B))){const[de,q]=Pu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,q),z==null||z(C,de,q),T||B==null||B(C,q)}}async function K(){if(!y)return;const{transform:ee,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,U]=dc(m,y,b);(V!==0||U!==0)&&(u.x=(u.x??0)-V/ee[2],u.y=(u.y??0)-U/ee[2],await J({x:V,y:U})&&G(u)),d=requestAnimationFrame(K)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:U,snapToGrid:D,selectNodesOnDrag:z,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!z||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&z&&T&&(t==null||t(T));const ne=mo(ee.sourceEvent,{transform:V,snapGrid:U,snapToGrid:D,containerBounds:y});if(u=ne,f=C1(J,Y,ne,T),f.size>0&&(o||B||!T&&M)){const[ce,fe]=Pu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(ee.sourceEvent,f,ce,fe),B==null||B(ee.sourceEvent,ce,fe),T||M==null||M(ee.sourceEvent,fe)}}const W=zp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:U}=r();y=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,k=!1,C=ee.sourceEvent,b===0&&te(ee),u=mo(ee.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:U,containerBounds:y}),m=tn(ee.sourceEvent,y)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:U,nodeLookup:D}=r(),z=mo(ee.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:y});if(C=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,K()),!x){const B=tn(ee.sourceEvent,y),M=B.x-m.x,L=B.y-m.y;Math.sqrt(M*M+L*L)>U&&te(ee)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(m=tn(ee.sourceEvent,y),G(z))}}).on("end",ee=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(k&&(b(f,!1),k=!1),a||Y||!T&&V){const[U,D]=Pu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,f,U,D),Y==null||Y(ee.sourceEvent,U,D),T||V==null||V(ee.sourceEvent,D)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!I||!bh(J,`.${I}`,j))&&(!N||bh(J,N,j))});v.call(W)}function E(){v==null||v.on(".drag",null)}return{update:S,destroy:E}}function M1(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())pl(a,No(u))>0&&l.push(u);return l}const P1=250;function I1(t,r,o,l){var f,g;let a=[],u=1/0;const d=M1(t,o,r+P1);for(const m of d){const y=[...((f=m.internals.handleBounds)==null?void 0:f.source)??[],...((g=m.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of y){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=Dr(m,x,x.position,!0),k=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const m=l.type==="source"?"target":"source";return a.find(y=>y.type===m)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var m,y,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(m=d.internals.handleBounds)==null?void 0:m[r]:[...((y=d.internals.handleBounds)==null?void 0:y.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...Dr(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function T1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function R1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:m,autoPanOnConnect:y,flowId:x,panBy:v,cancelConnection:_,onConnectStart:k,onConnect:C,onConnectEnd:S,isValidConnection:E=kg,onReconnectEnd:I,updateConnection:N,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:H=1,handleDomNode:G}){const K=cg(t.target);let te=0,W;const{x:ee,y:J}=tn(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const U=_g(a,b,l,g,r);if(!U)return;let D=tn(t,Y),z=!1,B=null,M=!1,L=null;function ne(){if(!y||!Y)return;const[_e,ge]=dc(D,Y,T);v({x:_e,y:ge}),te=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:b,position:U.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:Dr(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:mh[re.position],toNode:null,pointer:D};function q(){V=!0,N(de),k==null||k(t,{nodeId:a,handleId:l,handleType:b})}H===0&&q();function le(_e){if(!V){const{x:Me,y:nt}=tn(_e),Qe=Me-ee,Je=nt-J;if(!(Qe*Qe+Je*Je>H*H))return;q()}if(!R()||!re){pe(_e);return}const ge=j();D=tn(_e,Y),W=I1(Lo(D,ge,!1,[1,1]),o,g,re),z||(ne(),z=!0);const ye=Eg(_e,{handle:W,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:m,flowId:x,nodeLookup:g});L=ye.handleDomNode,B=ye.connection,M=T1(!!W,ye.isValid);const Ne=g.get(a),Pe=Ne?Dr(Ne,re,Se.Left,!0):de.from,be={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Ei({x:ye.toHandle.x,y:ye.toHandle.y},ge):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:mh[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};N(be),de=be}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(W||L)&&B&&M&&(C==null||C(B));const{inProgress:ge,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(te),z=!1,M=!1,B=null,L=null,K.removeEventListener("mousemove",le),K.removeEventListener("mouseup",pe),K.removeEventListener("touchmove",le),K.removeEventListener("touchend",pe)}}K.addEventListener("mousemove",le),K.addEventListener("mouseup",pe),K.addEventListener("touchmove",le),K.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:m=kg,nodeLookup:y}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=tn(t),C=d.elementFromPoint(_,k),S=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const I=Sg(void 0,S),N=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!N||!I)return E;const H={source:x?N:l,sourceHandle:x?j:a,target:x?l:N,targetHandle:x?a:j};E.connection=H;const K=R&&T&&(o===Si.Strict?x&&I==="source"||!x&&I==="target":N!==l||j!==a);E.isValid=K&&m(H),E.toHandle=_g(N,I,j,y,o,!0)}return E}const Zu={onPointerDown:R1,isValid:Eg};function L1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=zt(t);function u({translateExtent:f,width:g,height:m,zoomStep:y=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=N.sourceEvent.ctrlKey&&Co()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*y,H=j[2]*Math.pow(2,T*R);r.scaleTo(H)};let C=[0,0];const S=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 j=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*H,y:j[1]-T[1]*H},K=[[0,0],[g,m]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},K,f)},I=Kp().on("start",S).on("zoom",x?E:null).on("zoom.wheel",v?k:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Zt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),rr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),A1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Tu=(t,r=0,o=A1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function z1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:m}){return y=>{if(rr(y,r))return y.ctrlKey&&y.preventDefault(),!1;y.preventDefault(),y.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(y.ctrlKey&&d){const S=Zt(y),E=Cg(y),I=x*Math.pow(2,E);l.scaleTo(o,I,S,y);return}const v=y.deltaMode===1?20:1;let _=a===Tr.Vertical?0:y.deltaX*v,k=a===Tr.Horizontal?0:y.deltaY*v;!Co()&&y.shiftKey&&a!==Tr.Vertical&&(_=y.deltaY*v,k=0),l.translateBy(o,-(_/x)*u,-(k/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(y,C):(t.isPanScrolling=!0,f==null||f(y,C)),t.panScrollTimeout=setTimeout(()=>{m==null||m(y,C),t.isPanScrolling=!1},150)}}function D1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=rr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function $1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 O1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function F1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function H1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:m,lib:y,connectionInProgress:x}){return v=>{var E;const _=r||o,k=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(rr(v,`${y}-flow__node`)||rr(v,`${y}-flow__edge`)||rr(v,`${y}-flow__selection`)||rr(v,`${y}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||rr(v,g)&&C||rr(v,m)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((E=v.touches)==null?void 0:E.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!k&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const S=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&S}}function B1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const m={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},y=t.getBoundingClientRect();let x=[[0,0],[y.width,y.height]];const v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),k=zt(t).call(_);j({x:a.x,y:a.y,zoom:ki(a.zoom,r,o)},[[0,0],[y.width,y.height]],l);const C=k.on("wheel.zoom"),S=k.on("dblclick.zoom");_.wheelDelta(Cg);async function E(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:U,panOnDrag:D,panOnScrollMode:z,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:q,connectionInProgress:le,paneClickDistance:pe,selectionOnDrag:_e}){V&&!m.isZoomingOrPanning&&N();const ge=U&&!fe&&!V;_.clickDistance(_e?1/0:!en(pe)||pe<0?0:pe);const ye=ge?z1({zoomPanValues:m,noWheelClassName:J,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:B,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):D1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});k.on("wheel.zoom",ye,{passive:!1});const Ne=$1({zoomPanValues:m,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=O1({zoomPanValues:m,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:q});_.on("zoom",Pe);const be=F1({zoomPanValues:m,panOnDrag:D,panOnScroll:U,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",be);const Me=H1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:le});_.filter(Me),re?k.on("dblclick.zoom",S):k.on("dblclick.zoom",null)}function N(){_.on("zoom",null)}async function j(J,b,Y){const V=Iu(J),U=_==null?void 0:_.constrain()(V,b,Y);return U&&await E(U),U}async function R(J,b){const Y=Iu(J);return await E(Y,b),Y}function T(J){if(k){const b=Iu(J),Y=k.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(k,b,null,{sync:!0}))}}function H(){const J=k?qp(k.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function K(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function te(J){_==null||_.scaleExtent(J)}function W(J){_==null||_.translateExtent(J)}function ee(J){const b=!en(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:N,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:G,scaleBy:K,setScaleExtent:te,setTranslateExtent:W,syncViewport:T,setClickDistance:ee}}var Ni;(function(t){t.Line="line",t.Handle="handle"})(Ni||(Ni={}));function V1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Mh(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 tr(t,r){return Math.max(0,r-t)}function nr(t,r){return Math.max(0,t-r)}function Ks(t,r,o){return Math.max(0,r-t,t-o)}function Ph(t,r){return t?!r:r}function U1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:m}=r;const{isHorizontal:y,isVertical:x}=r,v=y&&x,{xSnapped:_,ySnapped:k}=o,{minWidth:C,maxWidth:S,minHeight:E,maxHeight:I}=l,{x:N,y:j,width:R,height:T,aspectRatio:H}=t;let G=Math.floor(y?_-t.pointerX:0),K=Math.floor(x?k-t.pointerY:0);const te=R+(g?-G:G),W=T+(m?-K:K),ee=-u[0]*R,J=-u[1]*T;let b=Ks(te,C,S),Y=Ks(W,E,I);if(d){let D=0,z=0;g&&G<0?D=tr(N+G+ee,d[0][0]):!g&&G>0&&(D=nr(N+te+ee,d[1][0])),m&&K<0?z=tr(j+K+J,d[0][1]):!m&&K>0&&(z=nr(j+W+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(f){let D=0,z=0;g&&G>0?D=nr(N+G,f[0][0]):!g&&G<0&&(D=tr(N+te,f[1][0])),m&&K>0?z=nr(j+K,f[0][1]):!m&&K<0&&(z=tr(j+W,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(a){if(y){const D=Ks(te/H,E,I)*H;if(b=Math.max(b,D),d){let z=0;!g&&!m||g&&!m&&v?z=nr(j+J+te/H,d[1][1])*H:z=tr(j+J+(g?G:-G)/H,d[0][1])*H,b=Math.max(b,z)}if(f){let z=0;!g&&!m||g&&!m&&v?z=tr(j+te/H,f[1][1])*H:z=nr(j+(g?G:-G)/H,f[0][1])*H,b=Math.max(b,z)}}if(x){const D=Ks(W*H,C,S)/H;if(Y=Math.max(Y,D),d){let z=0;!g&&!m||m&&!g&&v?z=nr(N+W*H+ee,d[1][0])/H:z=tr(N+(m?K:-K)*H+ee,d[0][0])/H,Y=Math.max(Y,z)}if(f){let z=0;!g&&!m||m&&!g&&v?z=tr(N+W*H,f[1][0])/H:z=nr(N+(m?K:-K)*H,f[0][0])/H,Y=Math.max(Y,z)}}}K=K+(K<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?te>W*H?K=(Ph(g,m)?-G:G)/H:G=(Ph(g,m)?-K:K)*H:y?(K=G/H,m=g):(G=K*H,g=m));const V=g?N+G:N,U=m?j+K:j;return{width:R+(g?-G:G),height:T+(m?-K:K),x:u[0]*G*(g?-1:1)+V,y:u[1]*K*(m?-1:1)+U}}const jg={width:0,height:0,x:0,y:0},W1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function Y1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function X1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=zt(t);let d={controlDirection:Mh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:m,boundaries:y,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:k,onResizeEnd:C,shouldResize:S}){let E={...jg},I={...W1};d={boundaries:y,resizeDirection:v,keepAspectRatio:x,controlDirection:Mh(m)};let N,j=null,R=[],T,H,G,K=!1;const te=zp().on("start",W=>{const{nodeLookup:ee,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:U}=o();if(N=ee.get(r),!N)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:z}=mo(W.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},I={...E,pointerX:D,pointerY:z,aspectRatio:E.width/E.height},T=void 0,H=zr(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=ee.get(N.parentId)),T&&N.extent==="parent"&&(H=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[B,M]of ee)if(M.parentId===r&&(R.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=Y1(M,N,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(W,{...E})}).on("drag",W=>{const{transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(W.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:b,containerBounds:j}),U=[];if(!N)return;const{x:D,y:z,width:B,height:M}=E,L={},ne=N.origin??Y,{width:re,height:ce,x:fe,y:de}=U1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,H,G),q=re!==B,le=ce!==M,pe=fe!==D&&q,_e=de!==z&≤if(!pe&&!_e&&!q&&!le)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:E.x,L.y=_e?de:E.y,E.x=L.x,E.y=L.y,R.length>0)){const Pe=fe-D,be=de-z;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-B),y:Me.position.y-be+ne[1]*(ce-M)},U.push(Me)}if((q||le)&&(L.width=q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:E.width,L.height=le&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:E.height,E.width=L.width,E.height=L.height),T&&N.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{K&&(C==null||C(W,{...E}),a==null||a({...E}),K=!1)});u.call(te)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Ru={exports:{}},Lu={},Au={exports:{}},zu={};/** + * @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 Ih;function G1(){if(Ih)return zu;Ih=1;var t=bo();function r(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,v){var _=v(),k=l({inst:{value:_,getSnapshot:v}}),C=k[0].inst,S=k[1];return u(function(){C.value=_,C.getSnapshot=v,g(C)&&S({inst:C})},[x,_,v]),a(function(){return g(C)&&S({inst:C}),x(function(){g(C)&&S({inst:C})})},[x]),d(_),_}function g(x){var v=x.getSnapshot;x=x.value;try{var _=v();return!o(x,_)}catch{return!0}}function m(x,v){return v()}var y=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:f;return zu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:y,zu}var Th;function Q1(){return Th||(Th=1,Au.exports=G1()),Au.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 Rh;function q1(){if(Rh)return Lu;Rh=1;var t=bo(),r=Q1();function o(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,g=t.useDebugValue;return Lu.useSyncExternalStoreWithSelector=function(m,y,x,v,_){var k=u(null);if(k.current===null){var C={hasValue:!1,value:null};k.current=C}else C=k.current;k=f(function(){function E(T){if(!I){if(I=!0,N=T,T=v(T),_!==void 0&&C.hasValue){var H=C.value;if(_(H,T))return j=H}return j=T}if(H=j,l(N,T))return H;var G=v(T);return _!==void 0&&_(H,G)?(N=T,H):(N=T,j=G)}var I=!1,N,j,R=x===void 0?null:x;return[function(){return E(y())},R===null?void 0:function(){return E(R())}]},[y,x,v,_]);var S=a(m,k[0],k[1]);return d(function(){C.hasValue=!0,C.value=S},[S]),g(S),S},Lu}var Lh;function K1(){return Lh||(Lh=1,Ru.exports=q1()),Ru.exports}var Z1=K1();const J1=xp(Z1),e_={},Ah=t=>{let r;const o=new Set,l=(y,x)=>{const v=typeof y=="function"?y(r):y;if(!Object.is(v,r)){const _=r;r=x??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(k=>k(r,_))}},a=()=>r,g={setState:l,getState:a,getInitialState:()=>m,subscribe:y=>(o.add(y),()=>o.delete(y)),destroy:()=>{(e_?"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()}},m=r=t(l,a,g);return g},t_=t=>t?Ah(t):Ah,{useDebugValue:n_}=Zy,{useSyncExternalStoreWithSelector:r_}=J1,i_=t=>t;function bg(t,r=i_,o){const l=r_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return n_(l),l}const zh=(t,r)=>{const o=t_(t),l=(a,u=r)=>bg(o,a,u);return Object.assign(l,o),l},o_=(t,r)=>t?zh(t,r):zh;function Xe(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}wp();const Cl=$.createContext(null),s_=Cl.Provider,Mg=nn.error001("react");function Re(t,r){const o=$.useContext(Cl);if(o===null)throw new Error(Mg);return bg(o,t,r)}function He(){const t=$.useContext(Cl);if(t===null)throw new Error(Mg);return $.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Dh={display:"none"},l_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pg="react-flow__node-desc",Ig="react-flow__edge-desc",a_="react-flow__aria-live",u_=t=>t.ariaLiveMessage,c_=t=>t.ariaLabelConfig;function d_({rfId:t}){const r=Re(u_);return p.jsx("div",{id:`${a_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:l_,children:r})}function f_({rfId:t,disableKeyboardA11y:r}){const o=Re(c_);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${Pg}-${t}`,style:Dh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${Ig}-${t}`,style:Dh,children:o["edge.a11yDescription.default"]}),!r&&p.jsx(d_,{rfId:t})]})}const jl=$.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return p.jsx("div",{className:tt(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});jl.displayName="Panel";const $h="https://reactflow.dev?utm_source=attribution";function h_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:p.jsx(jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${$h}`,children:p.jsx("a",{href:$h,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const p_=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}},Zs=t=>t.id;function g_(t,r){return Xe(t.selectedNodes.map(Zs),r.selectedNodes.map(Zs))&&Xe(t.selectedEdges.map(Zs),r.selectedEdges.map(Zs))}function m_({onSelectionChange:t}){const r=He(),{selectedNodes:o,selectedEdges:l}=Re(p_,g_);return $.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const y_=t=>!!t.onSelectionChangeHandlers;function v_({onSelectionChange:t}){const r=Re(y_);return t||r?p.jsx(m_,{onSelectionChange:t}):null}const Tg=[0,0],x_={x:0,y:0,zoom:1},w_=["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"],Oh=[...w_,"rfId"],__=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}),Fh={translateExtent:So,nodeOrigin:Tg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function S_(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:g}=Re(__,Xe),m=He();$.useEffect(()=>(g(t.defaultNodes,t.defaultEdges),()=>{y.current=Fh,f()}),[]);const y=$.useRef(Fh);return $.useEffect(()=>{for(const x of Oh){const v=t[x],_=y.current[x];v!==_&&(typeof t[x]>"u"||(x==="nodes"?r(v):x==="edges"?o(v):x==="minZoom"?l(v):x==="maxZoom"?a(v):x==="translateExtent"?u(v):x==="nodeExtent"?d(v):x==="ariaLabelConfig"?m.setState({ariaLabelConfig:s1(v)}):x==="fitView"?m.setState({fitViewQueued:v}):x==="fitViewOptions"?m.setState({fitViewOptions:v}):m.setState({[x]:v})))}y.current=t},Oh.map(x=>t[x])),null}function Hh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function k_(t){var l;const[r,o]=$.useState(t==="system"?null:t);return $.useEffect(()=>{if(t!=="system"){o(t);return}const a=Hh(),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=Hh())!=null&&l.matches?"dark":"light"}const Bh=typeof document<"u"?document:null;function jo(t=null,r={target:Bh,actInsideInputWithModifier:!0}){const[o,l]=$.useState(!1),a=$.useRef(!1),u=$.useRef(new Set([])),[d,f]=$.useMemo(()=>{if(t!==null){const m=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),y=m.reduce((x,v)=>x.concat(...v),[]);return[m,y]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Bh,m=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const y=_=>{var S,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!m)&&dg(_))return!1;const C=Uh(_.code,f);if(u.current.add(_[C]),Vh(d,u.current,!1)){const I=((E=(S=_.composedPath)==null?void 0:S.call(_))==null?void 0:E[0])||_.target,N=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&_.preventDefault(),l(!0)}},x=_=>{const k=Uh(_.code,f);Vh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",y),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",y),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Vh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Uh(t,r){return r.includes(t)?"code":"key"}const E_=()=>{const t=He();return $.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(),g=fc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),m={x:r.x-f,y:r.y-g},y=o.snapGrid??a,x=o.snapToGrid??u;return Lo(m,l,x,y)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Ei(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)N_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function N_(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 C_(t,r){return Rg(t,r)}function j_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function yi(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(br(u.id,d)))}return l}function Wh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Yh(t){return{id:t.id,type:"remove"}}const b_=lg();function M_(t,r,o={}){return f1(t,r,{...o,onError:o.onError??b_})}const Xh=t=>Kw(t),P_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const Ag=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Gh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>I_(()=>o(a=>a+BigInt(1))));return Ag(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function I_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const zg=$.createContext(null);function T_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:m,hasDefaultNodes:y,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let C=g;for(const E of f)C=typeof E=="function"?E(C):E;let S=Wh({items:C,lookup:v});for(const E of k.values())S=E(S);y&&m(C),S.length>0?x==null||x(S):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:N}=r.getState();E&&N(I)})},[]),l=Gh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:m,hasDefaultEdges:y,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const k of f)_=typeof k=="function"?k(_):k;y?m(_):x&&x(Wh({items:_,lookup:v}))},[]),u=Gh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(zg.Provider,{value:d,children:t})}function R_(){const t=$.useContext(zg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const L_=t=>!!t.panZoom;function bl(){const t=E_(),r=He(),o=R_(),l=Re(L_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var E,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),k=Xh(x)?x:v.get(x.id),C=k.parentId?ug(k.position,k.measured,k.parentId,v,_):k.position,S={...k,position:C,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((I=k.measured)==null?void 0:I.height)??k.height};return No(S)},m=(x,v,_={replace:!1})=>{d(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&Xh(S)?S:{...C,...S}}return C}))},y=(x,v,_={replace:!1})=>{f(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&P_(S)?S:{...C,...S}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[k,C,S]=_;return{nodes:x.map(E=>({...E})),edges:v.map(E=>({...E})),viewport:{x:k,y:C,zoom:S}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:k,onNodesDelete:C,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:N,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await n1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:k,onBeforeDelete:j}),H=T.length>0,G=R.length>0;if(H){const K=T.map(Yh);S==null||S(T),I(K)}if(G){const K=R.map(Yh);C==null||C(R),E(K)}return(G||H)&&(N==null||N({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const k=vh(x),C=k?x:g(x),S=_!==void 0;return C?(_||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!k&&(E.id===x.id||!I.internals.positionAbsolute))return!1;const N=No(S?E:I),j=pl(N,C);return v&&j>0||j>=N.width*N.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=vh(x)?x:g(x);if(!C)return!1;const S=pl(C,v);return _&&S>0||S>=v.width*v.height||S>=C.width*C.height},updateNode:m,updateNodeData:(x,v,_={replace:!1})=>{m(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},updateEdge:y,updateEdgeData:(x,v,_={replace:!1})=>{y(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Zw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??o1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Qh=t=>t.selected,A_=typeof window<"u"?window:void 0;function z_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=bl(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:A_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Qh),edges:d.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function D_(t){const r=He();$.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=hc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",nn.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},$_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function O_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Tr.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:m,translateExtent:y,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:k=!0,children:C,noWheelClassName:S,noPanClassName:E,onViewportChange:I,isControlledViewport:N,paneClickDistance:j,selectionOnDrag:R}){const T=He(),H=$.useRef(null),{userSelectionActive:G,lib:K,connectionInProgress:te}=Re($_,Xe),W=jo(_),ee=$.useRef();D_(H);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),N||T.setState({transform:b})},[I,N]);return $.useEffect(()=>{if(H.current){ee.current=B1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:y,viewport:m,onDraggingChange:U=>T.setState(D=>D.paneDragging===U?D:{paneDragging:U}),onPanZoomStart:(U,D)=>{const{onViewportChangeStart:z,onMoveStart:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoom:(U,D)=>{const{onViewportChange:z,onMove:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoomEnd:(U,D)=>{const{onViewportChangeEnd:z,onMoveEnd:B}=T.getState();B==null||B(U,D),z==null||z(D)}});const{x:b,y:Y,zoom:V}=ee.current.getViewport();return T.setState({panZoom:ee.current,transform:[b,Y,V],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=ee.current)==null||U.destroy()}}},[]),$.useEffect(()=>{var b;(b=ee.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:W,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:S,lib:K,onTransformChange:J,connectionInProgress:te,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,W,k,E,G,S,K,J,te,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:H,style:Ml,children:C})}const F_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function H_(){const{userSelectionActive:t,userSelectionRect:r}=Re(F_,Xe);return t&&r?p.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 Du=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},B_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function V_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:m,onPaneContextMenu:y,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:k,children:C}){const S=$.useRef(0),E=He(),{userSelectionActive:I,elementsSelectable:N,dragging:j,panBy:R,autoPanSpeed:T}=Re(B_,Xe),H=N&&(t||I),G=$.useRef(null),K=$.useRef(),te=$.useRef(new Set),W=$.useRef(new Set),ee=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}m==null||m(q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){q.preventDefault();return}y==null||y(q)},D=x?q=>x(q):void 0,z=q=>{J.current&&(q.stopPropagation(),J.current=!1)},B=q=>{var Me,nt;if(q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:le,transform:pe}=E.getState();if(K.current=le==null?void 0:le.getBoundingClientRect(),!K.current)return;const _e=q.target===G.current;if(!_e&&!!q.target.closest(".nokey")||!t||!(d&&_e||r)||q.button!==0||!q.isPrimary)return;(nt=(Me=q.target)==null?void 0:Me.setPointerCapture)==null||nt.call(Me,q.pointerId),J.current=!1;const{x:Ne,y:Pe}=tn(q.nativeEvent,K.current),be=Lo({x:Ne,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:be.x,startY:be.y,x:Ne,y:Pe}}),_e||(q.stopPropagation(),q.preventDefault())};function M(q,le){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:_e,nodeLookup:ge,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:be,defaultEdgeOptions:Me}=E.getState(),nt={x:pe.startX,y:pe.startY},{x:Qe,y:Je}=Ei(nt,_e),qe={startX:nt.x,startY:nt.y,x:qst.id)),W.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const st of te.current){const yt=Ne.get(st);if(yt)for(const{edgeId:lt}of yt.values()){const vt=ye.get(lt);vt&&(vt.selectable??ot)&&W.current.add(lt)}}if(!xh(bt,te.current)){const st=yi(ge,te.current,!0);Pe(st)}if(!xh($t,W.current)){const st=yi(ye,W.current);be(st)}E.setState({userSelectionRect:qe,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!K.current)return;const[q,le]=dc(b.current,K.current,T);R({x:q,y:le}).then(pe=>{if(!J.current||!pe){S.current=requestAnimationFrame(L);return}const{x:_e,y:ge}=b.current;M(_e,ge),S.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=q=>{const{userSelectionRect:le,transform:pe,resetSelectedElements:_e}=E.getState();if(!K.current||!le)return;const{x:ge,y:ye}=tn(q.nativeEvent,K.current);b.current={x:ge,y:ye};const Ne=Ei({x:le.startX,y:le.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(ge-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(q)}J.current=!0,Y.current||(L(),Y.current=!0),M(ge,ye)},ce=q=>{var le,pe;if(!H){q.target===G.current&&E.getState().connection.inProgress&&(ee.current=!0);return}q.button===0&&((pe=(le=q.target)==null?void 0:le.releasePointerCapture)==null||pe.call(le,q.pointerId),!I&&q.target===G.current&&E.getState().userSelectionRect&&(V==null||V(q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(q),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=q=>{var le,pe;(pe=(le=q.target)==null?void 0:le.releasePointerCapture)==null||pe.call(le,q.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:tt(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:H?void 0:Du(V,G),onContextMenu:Du(U,G),onWheel:Du(D,G),onPointerEnter:H?void 0:v,onPointerMove:H?re:_,onPointerUp:ce,onPointerCancel:H?fe:void 0,onPointerDownCapture:H?B:void 0,onClickCapture:H?z:void 0,onPointerLeave:k,ref:G,style:Ml,children:[C,p.jsx(H_,{})]})}function Ju({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),m=f.get(t);if(!m){g==null||g("012",nn.error012(t));return}r.setState({nodesSelectionActive:!1}),m.selected?(o||m.selected&&d)&&(u({nodes:[m],edges:[]}),requestAnimationFrame(()=>{var y;return(y=l==null?void 0:l.current)==null?void 0:y.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,m]=$.useState(!1),y=$.useRef();return $.useEffect(()=>{if(!r)return y.current=b1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Ju({id:x,store:f,nodeRef:t})},onDragStart:()=>{m(!0)},onDragStop:()=>{m(!1)}}),()=>{var x;(x=y.current)==null||x.destroy(),y.current=void 0}},[r,f,t]),$.useEffect(()=>{r||!t.current||!y.current||y.current.update({noDragClassName:o,handleSelector:l,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:d})},[o,l,r,u,t,a,d]),g}const U_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:m,nodeOrigin:y}=t.getState(),x=new Map,v=U_(d),_=a?u[0]:5,k=a?u[1]:5,C=o.direction.x*_*o.factor,S=o.direction.y*k*o.factor;for(const[,E]of m){if(!v(E))continue;let I={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+S};a&&(I=Ro(I,u));const{position:N,positionAbsolute:j}=rg({nodeId:E.id,nextPosition:I,nodeLookup:m,nodeExtent:l,nodeOrigin:y,onError:f});E.position=N,E.internals.positionAbsolute=j,x.set(E.id,E)}g(x)},[])}const xc=$.createContext(null),W_=xc.Provider;xc.Consumer;const Og=()=>$.useContext(xc),Y_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function X_({children:t}){const r=Re(Y_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function G_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const Q_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:m}=d;if(!f&&!a)return Q_;const y=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo:y,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Si.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:y&&m}};function K_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:m,onMouseDown:y,onTouchStart:x,...v},_){var Y,V;const k=d||null,C=t==="target",S=He(),E=Og(),{connectOnClick:I,noPanClassName:N,rfId:j}=G_(),{connectingFrom:R,connectingTo:T,clickConnecting:H,isPossibleEndHandle:G,connectionInProcess:K,clickConnectionInProcess:te,valid:W}=Re(q_(E,k,t),Xe);E||(V=(Y=S.getState()).onError)==null||V.call(Y,"010",nn.error010());const ee=U=>{const{defaultEdgeOptions:D,onConnect:z,hasDefaultEdges:B}=S.getState(),M={...D,...U};if(B){const{edges:L,setEdges:ne,onError:re}=S.getState();ne(M_(M,L,{onError:re}))}z==null||z(M),f==null||f(M)},J=U=>{if(!E)return;const D=fg(U.nativeEvent);if(a&&(D&&U.button===0||!D)){const z=S.getState();Zu.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:C,handleId:k,nodeId:E,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...B)=>{var M,L;return(L=(M=S.getState()).onConnectEnd)==null?void 0:L.call(M,...B)},updateConnection:z.updateConnection,onConnect:ee,isValidConnection:o||((...B)=>{var M,L;return((L=(M=S.getState()).isValidConnection)==null?void 0:L.call(M,...B))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}D?y==null||y(U):x==null||x(U)},b=U=>{const{onClickConnectStart:D,onClickConnectEnd:z,connectionClickStartHandle:B,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=S.getState();if(!E||!B&&!a)return;if(!B){D==null||D(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const de=cg(U.target),q=o||L,{connection:le,isValid:pe}=Zu.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:q,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&le&&ee(le);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,z==null||z(U,_e),S.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${k}-${t}`,className:tt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,m,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:R,connectingto:T,valid:W,connectionindicator:l&&(!K||G)&&(K||te?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ci=$.memo(Lg(K_));function Z_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ci,{type:"source",position:o,isConnectable:r})]})}function J_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ci,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ci,{type:"source",position:l,isConnectable:r})]})}function eS(){return null}function tS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ci,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qh={input:Z_,default:J_,output:tS,group:eS};function nS(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 rS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:en(r)?r:null,height:en(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 iS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(rS,Xe),g=$g(),m=$.useRef(null);$.useEffect(()=>{var _;o||(_=m.current)==null||_.focus({preventScroll:!0})},[o]);const y=!f&&a!==null&&u!==null;if(Dg({nodeRef:m,disabled:!y}),!y)return null;const x=t?_=>{const k=l.getState().nodes.filter(C=>C.selected);t(_,k)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:tt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Kh=typeof window<"u"?window:void 0,oS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:G,autoPanOnSelection:K,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:U,disableKeyboardA11y:D,onViewportChange:z,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(oS,Xe),ne=jo(m,{target:Kh}),re=jo(C,{target:Kh}),ce=re||G,fe=re||j,de=y&&ce!==!0,q=ne||L||de;return z_({deleteKeyCode:g,multiSelectionKeyCode:k}),p.jsx(O_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:!ne&&ce,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,zoomActivationKeyCode:S,preventScrolling:b,noWheelClassName:V,noPanClassName:U,onViewportChange:z,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(V_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:K,isSelecting:!!q,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(iS,{onSelectionContextMenu:Y,noPanClassName:U,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const sS=$.memo(Hg),lS=t=>r=>t?cc(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 aS(t){return Re($.useCallback(lS(t),[t]),Xe)}const uS=t=>t.updateNodeInternals;function cS(){const t=Re(uS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function dS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),m=$.useRef(r),y=o&&!!t.internals.handleBounds;return $.useEffect(()=>{u.current&&!t.hidden&&(!y||d.current!==u.current)&&(d.current&&(l==null||l.unobserve(d.current)),l==null||l.observe(u.current),d.current=u.current)},[y,t.hidden]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=m.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(m.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function fS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:m,nodesFocusable:y,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:k,rfId:C,nodeTypes:S,nodeClickDistance:E,onError:I}){const{node:N,internals:j,isParent:R}=Re(q=>{const le=q.nodeLookup.get(t),pe=q.parentLookup.has(t);return{node:le,internals:le.internals,isParent:pe}},Xe);let T=N.type||"default",H=(S==null?void 0:S[T])||qh[T];H===void 0&&(I==null||I("003",nn.error003(T)),T="default",H=(S==null?void 0:S.default)||qh.default);const G=!!(N.draggable||f&&typeof N.draggable>"u"),K=!!(N.selectable||g&&typeof N.selectable>"u"),te=!!(N.connectable||m&&typeof N.connectable>"u"),W=!!(N.focusable||y&&typeof N.focusable>"u"),ee=He(),J=ag(N),b=dS({node:N,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:N.hidden||!G,noDragClassName:v,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),V=$g();if(N.hidden)return null;const U=on(N),D=nS(N),z=K||G||r||o||l||a,B=o?q=>o(q,{...j.userNode}):void 0,M=l?q=>l(q,{...j.userNode}):void 0,L=a?q=>a(q,{...j.userNode}):void 0,ne=u?q=>u(q,{...j.userNode}):void 0,re=d?q=>d(q,{...j.userNode}):void 0,ce=q=>{const{selectNodesOnDrag:le,nodeDragThreshold:pe}=ee.getState();K&&(!le||!G||pe>0)&&Ju({id:t,store:ee,nodeRef:b}),r&&r(q,{...j.userNode})},fe=q=>{if(!(dg(q.nativeEvent)||k)){if(Zp.includes(q.key)&&K){const le=q.key==="Escape";Ju({id:t,store:ee,unselect:le,nodeRef:b})}else if(G&&N.selected&&Object.prototype.hasOwnProperty.call(gl,q.key)){q.preventDefault();const{ariaLabelConfig:le}=ee.getState();ee.setState({ariaLiveMessage:le["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[q.key],factor:q.shiftKey?4:1})}}},de=()=>{var Ne;if(k||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:q,width:le,height:pe,autoPanOnNodeFocus:_e,setCenter:ge}=ee.getState();if(!_e)return;cc(new Map([[t,N]]),{x:0,y:0,width:le,height:pe},q,!0).length>0||ge(N.position.x+U.width/2,N.position.y+U.height/2,{zoom:q[2]})};return p.jsx("div",{className:tt(["react-flow__node",`react-flow__node-${T}`,{[_]:G},N.className,{selected:N.selected,selectable:K,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:J?"visible":"hidden",...N.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:W?fe:void 0,tabIndex:W?0:void 0,onFocus:W?de:void 0,role:N.ariaRole??(W?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Pg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:p.jsx(W_,{value:t,children:p.jsx(H,{id:t,data:N.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:G,deletable:N.deletable??!0,isConnectable:te,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:j.z,parentId:N.parentId,...U})})})}var hS=$.memo(fS);const pS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(pS,Xe),u=aS(t.onlyRenderVisibleElements),d=cS();return p.jsx("div",{className:"react-flow__nodes",style:Ml,children:u.map(f=>p.jsx(hS,{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))})}Bg.displayName="NodeRenderer";const gS=$.memo(Bg);function mS(t){return Re($.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&&u1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},vS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zh={[Eo.Arrow]:yS,[Eo.ArrowClosed]:vS};function xS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Zh,t)?Zh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",nn.error009(t)),null)},[t])}const wS=({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 g=xS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>y1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(wS,{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};Vg.displayName="MarkerDefinitions";var _S=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:m,...y}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=tt(["react-flow__edge-textwrapper",m]),k=$.useRef(null);return $.useEffect(()=>{if(k.current){const C=k.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...y,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const SS=$.memo(Ug);function Pl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:m=20,...y}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...y,d:t,fill:"none",className:tt(["react-flow__edge-path",y.className])}),m?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}):null,l&&en(r)&&en(o)?p.jsx(SS,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function Jh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Jh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,m]=Jh({pos:u,x1:l,y1:a,x2:t,y2:r}),[y,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:m});return[`M${t},${r} C${d},${f} ${g},${m} ${l},${a}`,y,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})=>{const[I,N,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Pl,{id:R,path:I,labelX:N,labelY:j,label:g,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})})}const kS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});kS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=Qu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:S,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),qg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";qg.displayName="SmoothStepEdgeInternal";function Kg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const ES=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});ES.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})=>{const[S,E,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return p.jsx(Pl,{id:N,path:S,labelX:E,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})})}const NS=Jg({isInternal:!1}),em=Jg({isInternal:!0});NS.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:g,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:I})})}const CS=tm({isInternal:!1}),nm=tm({isInternal:!0});CS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const ep={default:nm,straight:em,step:Zg,smoothstep:qg,simplebezier:Xg},tp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},jS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,bS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,np="react-flow__edgeupdater";function rp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:tt([np,`${np}-${f}`]),cx:jS(r,l,t),cy:bS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function MS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:m,onReconnectStart:y,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const k=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:H,connectionMode:G,connectionRadius:K,lib:te,onConnectStart:W,cancelConnection:ee,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=k.getState(),U=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},z=M=>m==null?void 0:m(o,M),B=(M,L)=>{v(!0),y==null||y(j,o,R.type),W==null||W(M,L)};Zu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:K,domNode:H,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:U,edgeUpdaterType:R.type,lib:te,flowId:b,cancelConnection:ee,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=k.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:z,onConnectStart:B,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=k.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),N=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(rp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:S,onMouseEnter:I,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&p.jsx(rp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:N,type:"target"})]})}function PS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:m,reconnectRadius:y,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:k,edgeTypes:C,noPanClassName:S,onError:E,disableKeyboardA11y:I}){let N=Re(ge=>ge.edgeLookup.get(t));const j=Re(ge=>ge.defaultEdgeOptions);N=j?{...j,...N}:N;let R=N.type||"default",T=(C==null?void 0:C[R])||ep[R];T===void 0&&(E==null||E("011",nn.error011(R)),R="default",T=(C==null?void 0:C.default)||ep.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),G=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),te=$.useRef(null),[W,ee]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=N.zIndex,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L}=Re($.useCallback(ge=>{const ye=ge.nodeLookup.get(N.source),Ne=ge.nodeLookup.get(N.target);if(!ye||!Ne)return tp;const Pe=m1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:ge.connectionMode,onError:E}),be=a1({selected:N.selected,zIndex:N.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:ge.elevateEdgesOnSelect,zIndexMode:ge.zIndexMode});return{...Pe||tp,zIndex:be}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Xe),ne=$.useMemo(()=>N.markerStart?`url('#${qu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),re=$.useMemo(()=>N.markerEnd?`url('#${qu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||U===null||D===null||z===null||B===null)return null;const ce=ge=>{var be;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();K&&(Y.setState({nodesSelectionActive:!1}),N.selected&&Pe?(Ne({nodes:[],edges:[N]}),(be=te.current)==null||be.blur()):ye([t])),a&&a(ge,N)},fe=u?ge=>{u(ge,{...N})}:void 0,de=d?ge=>{d(ge,{...N})}:void 0,q=f?ge=>{f(ge,{...N})}:void 0,le=g?ge=>{g(ge,{...N})}:void 0,pe=m?ge=>{m(ge,{...N})}:void 0,_e=ge=>{var ye;if(!I&&Zp.includes(ge.key)&&K){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();ge.key==="Escape"?((ye=te.current)==null||ye.blur(),Ne({edges:[N]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:tt(["react-flow__edge",`react-flow__edge-${R}`,N.className,S,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:W,selectable:K}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:q,onMouseMove:le,onMouseLeave:pe,onKeyDown:H?_e: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?`${Ig}-${k}`:void 0,ref:te,...N.domAttributes,children:[!J&&p.jsx(T,{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:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),G&&p.jsx(MS,{edge:N,isReconnectable:G,reconnectRadius:y,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,setUpdateHover:ee,setReconnecting:b})]})})}var IS=$.memo(PS);const TS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:m,onEdgeClick:y,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:C}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,onError:N}=Re(TS,Xe),j=mS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(_S,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(IS,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:m,onClick:y,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const RS=$.memo(rm),ip=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function LS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return Ag(()=>{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=ip(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ip(l)},children:t})}function AS(t){const r=bl(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const zS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function DS(t){const r=Re(zS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function $S(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function OS(t){return $S}function FS(t){const r=OS();return Re(r,Xe)}const HS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function BS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(HS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:tt(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=ir.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:m,toNode:y,toHandle:x,toPosition:v,pointer:_}=FS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:m.x,toY:m.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:y,toHandle:x,pointer:_});let k="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:m.x,targetY:m.y,targetPosition:v};switch(r){case ir.Bezier:[k]=pg(C);break;case ir.SimpleBezier:[k]=Wg(C);break;case ir.Step:[k]=Qu({...C,borderRadius:0});break;case ir.SmoothStep:[k]=Qu(C);break;default:[k]=mg(C)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const VS={};function op(t=VS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function US(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:y,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:C,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,deleteKeyCode:G,onlyRenderVisibleElements:K,elementsSelectable:te,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:U,zoomOnPinch:D,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneScroll:le,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:ge,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:be,reconnectRadius:Me,onReconnect:nt,onReconnectStart:Qe,onReconnectEnd:Je,noDragClassName:qe,noWheelClassName:bt,noPanClassName:$t,disableKeyboardA11y:ot,nodeExtent:st,rfId:yt,viewport:lt,onViewportChange:vt,nodesDraggable:In}){return op(t),op(r),US(),AS(o),DS(lt),p.jsx(sS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneContextMenu:pe,onPaneScroll:le,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:qe,noWheelClassName:bt,noPanClassName:$t,disableKeyboardA11y:ot,onViewportChange:vt,isControlledViewport:!!lt,children:p.jsxs(LS,{children:[p.jsx(RS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:nt,onReconnectStart:Qe,onReconnectEnd:Je,onlyRenderVisibleElements:K,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:be,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:$t,disableKeyboardA11y:ot,rfId:yt}),p.jsx(BS,{style:C,type:k,component:S,containerStyle:E}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(gS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:y,nodeClickDistance:ge,onlyRenderVisibleElements:K,noPanClassName:$t,noDragClassName:qe,disableKeyboardA11y:ot,nodeExtent:st,rfId:yt,nodesDraggable:In}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const WS=$.memo(om),YS=lg(),sp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:m=2,nodeOrigin:y,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,k=new Map,C=new Map,S=new Map,E=l??r??[],I=o??t??[],N=y??[0,0],j=x??So;xg(C,S,E);const{nodesInitialized:R}=Ku(I,_,k,{nodeOrigin:N,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const H=To(_,{filter:W=>!!((W.width||W.initialWidth)&&(W.height||W.initialHeight))}),{x:G,y:K,zoom:te}=fc(H,a,u,g,m,(f==null?void 0:f.padding)??.1);T=[G,K,te]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:S,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:m,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Si.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:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:YS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},XS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:m,nodeOrigin:y,nodeExtent:x,zIndexMode:v})=>o_((_,k)=>{async function C(){const{nodeLookup:S,panZoom:E,fitViewOptions:I,fitViewResolver:N,width:j,height:R,minZoom:T,maxZoom:H}=k();E&&(await t1({nodes:S,width:j,height:R,panZoom:E,minZoom:T,maxZoom:H},I),N==null||N.resolve(!0),_({fitViewResolver:null}))}return{...sp({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:m,nodeOrigin:y,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:S=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:H,nodesSelectionActive:G}=k(),{nodesInitialized:K,hasSelectedNodes:te}=Ku(S,E,I,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:H}),W=G&&te;T&&K?(C(),_({nodes:S,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:W})):_({nodes:S,nodesInitialized:K,nodesSelectionActive:W})},setEdges:S=>{const{connectionLookup:E,edgeLookup:I}=k();xg(E,I,S),_({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:I}=k();I(S),_({hasDefaultNodes:!0})}if(E){const{setEdges:I}=k();I(E),_({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:N,domNode:j,nodeOrigin:R,nodeExtent:T,debug:H,fitViewQueued:G,zIndexMode:K}=k(),{changes:te,updatedInternals:W}=E1(S,I,N,j,R,T,K);W&&(w1(I,N,{nodeOrigin:R,nodeExtent:T,zIndexMode:K}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(H&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(S,E=!1)=>{const I=[];let N=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:H,onNodesChangeMiddlewareMap:G}=k();for(const[K,te]of S){const W=j.get(K),ee=!!(W!=null&&W.expandParent&&(W!=null&&W.parentId)&&(te!=null&&te.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(W&&T.inProgress&&T.fromNode.id===W.id){const b=Dr(W,T.fromHandle,Se.Left,!0);H({...T,from:b})}ee&&W.parentId&&I.push({id:K,parentId:W.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),N.push(J)}if(I.length>0){const{parentLookup:K,nodeOrigin:te}=k(),W=vc(I,j,K,te);N.push(...W)}for(const K of G.values())N=K(N);R(N)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:I,nodes:N,hasDefaultNodes:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=C_(S,N);I(T)}R&&console.log("React Flow: trigger node changes",S),E==null||E(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:I,edges:N,hasDefaultEdges:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=j_(S,N);I(T)}R&&console.log("React Flow: trigger edge changes",S),E==null||E(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));j(T);return}j(yi(N,new Set([...S]),!0)),R(yi(I))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));R(T);return}R(yi(I,new Set([...S]))),j(yi(N,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:I,nodes:N,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=k(),H=S||N,G=E||I,K=[];for(const W of H){if(!W.selected)continue;const ee=j.get(W.id);ee&&(ee.selected=!1),K.push(br(W.id,!1))}const te=[];for(const W of G)W.selected&&te.push(br(W.id,!1));R(K),T(te)},setMinZoom:S=>{const{panZoom:E,maxZoom:I}=k();E==null||E.setScaleExtent([S,I]),_({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:I}=k();E==null||E.setScaleExtent([I,S]),_({maxZoom:S})},setTranslateExtent:S=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(S),_({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:N,elementsSelectable:j}=k();if(!j)return;const R=E.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]),T=S.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]);I(R),N(T)},setNodeExtent:S=>{const{nodes:E,nodeLookup:I,parentLookup:N,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:H}=k();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(Ku(E,I,N,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:H}),_({nodeExtent:S}))},panBy:S=>{const{transform:E,width:I,height:N,panZoom:j,translateExtent:R}=k();return N1({delta:S,panZoom:j,transform:E,translateExtent:R,width:I,height:N})},setCenter:async(S,E,I)=>{const{width:N,height:j,maxZoom:R,panZoom:T}=k();if(!T)return!1;const H=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:N/2-S*H,y:j/2-E*H,zoom:H},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:S=>{_({connection:S})},reset:()=>_({...sp()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:m,nodeOrigin:y,nodeExtent:x,zIndexMode:v,children:_}){const[k]=$.useState(()=>XS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:m,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:y,nodeExtent:x,zIndexMode:v}));return p.jsx(s_,{value:k,children:p.jsx(T_,{children:p.jsx(X_,{children:_})})})}function GS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:m,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:m,initialMaxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const QS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function qS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:m,onMove:y,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onBeforeDelete:B,connectionMode:M,connectionLineType:L=ir.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:q=!1,selectionMode:le=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:ge=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:be,nodesDraggable:Me,autoPanOnNodeFocus:nt,nodesConnectable:Qe,nodesFocusable:Je,nodeOrigin:qe=Tg,edgesFocusable:bt,edgesReconnectable:$t,elementsSelectable:ot=!0,defaultViewport:st=x_,minZoom:yt=.5,maxZoom:lt=2,translateExtent:vt=So,preventScrolling:In=!0,nodeExtent:Wt,defaultMarkerColor:yn="#b1b1b7",zoomOnScroll:ji=!0,zoomOnPinch:Or=!0,panOnScroll:Fr=!1,panOnScrollSpeed:Hr=.5,panOnScrollMode:sr=Tr.Free,zoomOnDoubleClick:lr=!0,panOnDrag:Tn=!0,onPaneClick:vn,onPaneMouseEnter:Rn,onPaneMouseMove:sn,onPaneMouseLeave:ln,onPaneScroll:Br,onPaneContextMenu:Mt,paneClickDistance:ar=1,nodeClickDistance:ur=0,children:cr,onReconnect:Ln,onReconnectStart:dr,onReconnectEnd:an,onEdgeContextMenu:An,onEdgeDoubleClick:F,onEdgeMouseEnter:ie,onEdgeMouseMove:Ce,onEdgeMouseLeave:ze,reconnectRadius:$e=10,onNodesChange:fr,onEdgesChange:Tl,noDragClassName:Rl="nodrag",noWheelClassName:Ll="nowheel",noPanClassName:un="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Al,attributionPosition:Ao,proOptions:zo,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Vr,isValidConnection:$l,onError:Ho,style:Ur,id:Pt,nodeDragThreshold:Ol,connectionDragThreshold:It,viewport:Fl,onViewportChange:Hl,width:Bl,height:Wr,colorMode:Yr="light",debug:hr,onScroll:xn,ariaLabelConfig:Vl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Pt||"1",gr=k_(Yr),Ul=$.useCallback(Xr=>{Xr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),xn==null||xn(Xr)},[xn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Ul,style:{...Ur,...QS},ref:Vo,className:tt(["react-flow",a,gr]),id:Pt,role:"application",children:p.jsxs(GS,{nodes:t,edges:r,width:Bl,height:Wr,fitView:bi,fitViewOptions:Mi,minZoom:yt,maxZoom:lt,nodeOrigin:qe,nodeExtent:Wt,zIndexMode:Bo,children:[p.jsx(S_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Me,autoPanOnNodeFocus:nt,nodesConnectable:Qe,nodesFocusable:Je,edgesFocusable:bt,edgesReconnectable:$t,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:yt,maxZoom:lt,nodeExtent:Wt,onNodesChange:fr,onEdgesChange:Tl,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:vt,connectOnClick:Al,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:y,onMoveStart:x,onMoveEnd:v,noPanClassName:un,nodeOrigin:qe,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanSpeed:Fo,onError:Ho,connectionRadius:Vr,isValidConnection:$l,selectNodesOnDrag:be,nodeDragThreshold:Ol,connectionDragThreshold:It,onBeforeDelete:B,debug:hr,ariaLabelConfig:Vl,zIndexMode:Bo}),p.jsx(WS,{onInit:m,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:q,selectionMode:le,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Pe,defaultViewport:st,translateExtent:vt,minZoom:yt,maxZoom:lt,preventScrolling:In,zoomOnScroll:ji,zoomOnPinch:Or,zoomOnDoubleClick:lr,panOnScroll:Fr,panOnScrollSpeed:Hr,panOnScrollMode:sr,panOnDrag:Tn,autoPanOnSelection:Pi,onPaneClick:vn,onPaneMouseEnter:Rn,onPaneMouseMove:sn,onPaneMouseLeave:ln,onPaneScroll:Br,onPaneContextMenu:Mt,paneClickDistance:ar,nodeClickDistance:ur,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onReconnect:Ln,onReconnectStart:dr,onReconnectEnd:an,onEdgeContextMenu:An,onEdgeDoubleClick:F,onEdgeMouseEnter:ie,onEdgeMouseMove:Ce,onEdgeMouseLeave:ze,reconnectRadius:$e,defaultMarkerColor:yn,noDragClassName:Rl,noWheelClassName:Ll,noPanClassName:un,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Wt,viewport:Fl,onViewportChange:Hl,nodesDraggable:Me}),p.jsx(v_,{onSelectionChange:J}),cr,p.jsx(h_,{proOptions:zo,position:Ao}),p.jsx(f_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var KS=Lg(qS);function ZS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:tt(["react-flow__background-pattern",o,l])})}function JS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:tt(["react-flow__background-pattern","dots",r])})}var or;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(or||(or={}));const ek={[or.Dots]:1,[or.Lines]:1,[or.Cross]:6},tk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=or.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:m,patternClassName:y}){const x=$.useRef(null),{transform:v,patternId:_}=Re(tk,Xe),k=l||ek[r],C=r===or.Dots,S=r===or.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*v[2]||1,E[1]*v[2]||1],N=k*v[2],j=Array.isArray(u)?u:[u,u],R=S?[N,N]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],H=`${_}${t||""}`;return p.jsxs("svg",{className:tt(["react-flow__background",m]),style:{...g,...Ml,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:H,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(JS,{radius:N/2,className:y}):p.jsx(ZS,{dimensions:R,lineWidth:a,variant:r,className:y})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}lm.displayName="Background";const nk=$.memo(lm);function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 lk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:tt(["react-flow__controls-button",r]),...o,children:t})}const ak=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:m,children:y,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const k=He(),{isInteractive:C,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:I}=Re(ak,Xe),{zoomIn:N,zoomOut:j,fitView:R}=bl(),T=()=>{N(),u==null||u()},H=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},K=()=>{k.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},te=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:tt(["react-flow__controls",te,m]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:p.jsx(rk,{})}),p.jsx(Js,{onClick:H,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:S,children:p.jsx(ik,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ok,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:K,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(lk,{}):p.jsx(sk,{})}),y]})}am.displayName="Controls";const uk=$.memo(am);function ck({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:m,borderRadius:y,shapeRendering:x,selected:v,onClick:_}){const{background:k,backgroundColor:C}=u||{},S=d||k||C;return p.jsx("rect",{className:tt(["react-flow__minimap-node",{selected:v},m]),x:r,y:o,rx:y,ry:y,width:l,height:a,style:{fill:S,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?E=>_(E,t):void 0})}const dk=$.memo(ck),fk=t=>t.nodes.map(r=>r.id),$u=t=>t instanceof Function?t:()=>t;function hk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=dk,onClick:d}){const f=Re(fk,Xe),g=$u(r),m=$u(t),y=$u(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(gk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:m,nodeClassNameFunc:y,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function pk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:m,x:y,y:x,width:v,height:_}=Re(k=>{const C=k.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const S=C.internals.userNode,{x:E,y:I}=C.internals.positionAbsolute,{width:N,height:j}=on(S);return{node:S,x:E,y:I,width:N,height:j}},Xe);return!m||m.hidden||!ag(m)?null:p.jsx(f,{x:y,y:x,width:v,height:_,style:m.style,selected:!!m.selected,className:l(m),color:r(m),borderRadius:a,strokeColor:o(m),strokeWidth:u,shapeRendering:d,onClick:g,id:m.id})}const gk=$.memo(pk);var mk=$.memo(hk);const yk=200,vk=150,xk=t=>!t.hidden,wk=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?og(To(t.nodeLookup,{filter:xk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},lp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,_k=(t,r)=>lp(t.viewBB,r.viewBB)&&lp(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,Sk="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:m,maskStrokeColor:y,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:k,pannable:C=!1,zoomable:S=!1,ariaLabel:E,inversePan:I,zoomStep:N=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:H,viewBB:G,rfId:K,panZoom:te,translateExtent:W,flowWidth:ee,flowHeight:J,ariaLabelConfig:b}=Re(wk,_k),Y=(t==null?void 0:t.width)??yk,V=(t==null?void 0:t.height)??vk,U=H.width/Y,D=H.height/V,z=Math.max(U,D),B=z*Y,M=z*V,L=j*z,ne=H.x-(B-H.width)/2-L,re=H.y-(M-H.height)/2-L,ce=B+L*2,fe=M+L*2,de=`${Sk}-${K}`,q=$.useRef(0),le=$.useRef();q.current=z,$.useEffect(()=>{if(T.current&&te)return le.current=L1({domNode:T.current,panZoom:te,getTransform:()=>R.getState().transform,getViewScale:()=>q.current}),()=>{var ye;(ye=le.current)==null||ye.destroy()}},[te]),$.useEffect(()=>{var ye;(ye=le.current)==null||ye.update({translateExtent:W,width:ee,height:J,inversePan:I,pannable:C,zoomStep:N,zoomable:S})},[C,S,I,N,W,ee,J]);const pe=_?ye=>{var be;const[Ne,Pe]=((be=le.current)==null?void 0:be.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=k?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;k(ye,Pe)},[]):void 0,ge=E??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*z: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:tt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[ge&&p.jsx("title",{id:de,children:ge}),p.jsx(mk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const kk=$.memo(um),Ek=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Nk={[Ni.Line]:"right",[Ni.Handle]:"bottom-right"};function Ck({nodeId:t,position:r,variant:o=Ni.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:m=Number.MAX_VALUE,maxHeight:y=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:k,onResizeStart:C,onResize:S,onResizeEnd:E}){const I=Og(),N=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===Ni.Handle,H=Re($.useCallback(Ek(T&&_),[T,_]),Xe),G=$.useRef(null),K=r??Nk[o];$.useEffect(()=>{if(!(!R.current||!N))return G.current||(G.current=X1({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(W,ee)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),U=[],D={x:W.x,y:W.y},z=b.get(N);if(z&&z.expandParent&&z.parentId){const B=z.origin??V,M=W.width??z.measured.width??0,L=W.height??z.measured.height??0,ne={id:z.id,parentId:z.parentId,rect:{width:M,height:L,...ug({x:W.x??z.position.x,y:W.y??z.position.y},{width:M,height:L},z.parentId,b,B)}},re=vc([ne],b,Y,V);U.push(...re),D.x=W.x?Math.max(B[0]*M,W.x):void 0,D.y=W.y?Math.max(B[1]*L,W.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:N,type:"position",position:{...D}};U.push(B)}if(W.width!==void 0&&W.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:W.width,height:W.height}};U.push(M)}for(const B of ee){const M={...B,type:"position"};U.push(M)}J(U)},onEnd:({width:W,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:W,height:ee}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:K,boundaries:{minWidth:f,minHeight:g,maxWidth:m,maxHeight:y},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:S,onResizeEnd:E,shouldResize:k}),()=>{var W;(W=G.current)==null||W.destroy()}},[K,f,g,m,y,x,C,S,E,k]);const te=K.split("-");return p.jsx("div",{className:tt(["react-flow__resize-control","nodrag",...te,o,l]),ref:R,style:{...a,scale:H,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Ck);const jk={"arch.context":0,"django.app":0,"django.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"django.serializer_field":5,"django.service":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"openapi.path":9,"react.api_client":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"react.component":13,"react.form_schema":14,"react.test":14,"react.context":13};function Il(t){return jk[t]??8}const ec=208,tc=64,bk=88,Mk=28,Pk=8;function Ik(t){if(!t.length)return Number.NaN;const r=[...t].sort((l,a)=>l-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Tk(t,r=[]){const o=new Map;if(!t.length)return o;const l=new Map;for(const C of t){const S=Il(C.type),E=l.get(S)??[];E.push(C),l.set(S,E)}const u=[...l.keys()].sort((C,S)=>C-S).map(C=>[...l.get(C)??[]].sort((S,E)=>S.name.localeCompare(E.name)||S.id.localeCompare(E.id))),d=new Set(t.map(C=>C.id)),f=new Map,g=new Map;for(const C of t)f.set(C.id,[]),g.set(C.id,[]);for(const C of r)!d.has(C.src)||!d.has(C.dst)||C.src===C.dst||(g.get(C.src).push(C.dst),f.get(C.dst).push(C.src));const m=new Map,y=()=>{for(const C of u)C.forEach((S,E)=>m.set(S.id,E))};y();const x=(C,S)=>{const E=C.map((I,N)=>{const j=S(I.id).map(T=>m.get(T)).filter(T=>T!==void 0),R=Ik(j);return{n:I,bary:Number.isNaN(R)?N:R,name:I.name,id:I.id}});return E.sort((I,N)=>I.bary-N.bary||I.name.localeCompare(N.name)||I.id.localeCompare(N.id)),E.map(I=>I.n)};for(let C=0;Cf.get(E)??[]),y();for(let S=u.length-2;S>=0;S--)u[S]=x(u[S],E=>g.get(E)??[]),y()}const v=ec+bk,_=tc+Mk,k=Math.max(...u.map(C=>C.length),1);return u.forEach((C,S)=>{const E=(k-C.length)*_/2;C.forEach((I,N)=>{o.set(I.id,{x:S*v,y:E+N*_})})}),o}const cm=90,Rk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ap={"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"},Lk=Math.PI*(3-Math.sqrt(5)),dm=220,Ak=26,zk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function yE(t){return ap[t]?ap[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Dk(t){return t>=cm?"3d":"2d"}function $k(t){return t>=cm?"overview":"full"}function Ok(t,r,o=1){const l=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!Rk.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?Ok(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&d.size){l=l.filter(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function vE(t){const r=new Map;for(const l of t){const a=Il(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Ak*Math.sqrt(f+1),m=f*Lk;o.set(d.id,{x:u,y:g*Math.cos(m),z:g*Math.sin(m)})})}return o}function xE(t){const r=new Map;for(const o of t){const l=Il(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*dm,count:l}))}const el=16,Hk=12,Bk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),Vk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),up={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Uk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},cp=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],dp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Wk=new Set(["looks_idempotent_on_pk"]),Yk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Xk(t){return up[t]?up[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Gk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Bk.has(t.type)&&a.push("sink"),Vk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>fp(x,l,x.src)),m=f.slice(0,el).map(x=>fp(x,l,x.dst)),y=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:zk[Il(t.type)]??"other",purpose:Xk(t.type),name:t.name,qualifiedName:t.qualified_name,file:y,context:t.context,roles:a,facts:Qk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:m,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function fp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Qk(t){const r=[...cp.filter(a=>a in t),...Object.keys(t).filter(a=>!cp.includes(a)&&!dp.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||dp.has(a)||Yk.has(a))continue;l.add(a);const u=qk(a,t[a]);u!=null&&o.push({key:a,label:Uk[a]??yo(a),value:u})}return o}function qk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Wk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Hk),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const Kk=new Set,Zk=$.lazy(()=>y0(()=>import("./LayeredGraph3D-CN-VAdGf.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Jk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function eE({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ci,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),p.jsx(Ci,{type:"source",position:Se.Right,isConnectable:!1})]})}const tE={load:eE},nE=new Set(["django","react","stitch","arch"]);function rE({topologyKey:t}){const{fitView:r}=bl();return $.useEffect(()=>{let o=0;const l=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(o)}},[r,t]),null}function iE(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=Tk(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:ec,height:tc,style:{width:ec,height:tc}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Jk[f.weight]||"var(--edge-cheap)",m=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:m?f.type.replaceAll("_"," "):void 0,labelStyle:m?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:m?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:m?[3,5]:void 0,labelBgBorderRadius:m?4:void 0}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Gk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:Mr(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:Mr(a.context)}):null,a.file?p.jsx("div",{className:"file",children:Mr(a.file)}):null,p.jsx("div",{className:"muted",children:Mr(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:Mr(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:Mr(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function Ou({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,m]=$.useState(new Set(nE)),[y,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??Dk(t.length),k=d??$k(t.length),C=y&&_==="3d"?o:null,S=$.useMemo(()=>Fk(t,r,{detail:k,families:g,focusId:C,neighborhoodOnly:!!C}),[t,r,k,g,C]),E=$.useMemo(()=>`${S.nodes.map(W=>W.id).join("\0")}|${S.edges.map(W=>W.id).join("\0")}`,[S.nodes,S.edges]),I=$.useMemo(()=>new Map(S.nodes.map(W=>[W.id,W])),[S.nodes]),N=o?I.get(o)??null:null,{rfNodes:j,rfEdges:R}=$.useMemo(()=>{const W=iE(S.nodes,S.edges,o);return v&&(W.rfEdges=W.rfEdges.map(ee=>({...ee,animated:!1}))),W},[S.nodes,S.edges,o,v]);$.useEffect(()=>{o&&!I.has(o)&&l(null)},[I,o]);const T=(W,ee)=>{l(ee.id)},H=()=>{l(null),x(!1)},G=W=>{m(ee=>{const J=new Set(ee);if(J.has(W)){if(J.size===1)return ee;J.delete(W)}else J.add(W);return J})},K=$.useMemo(()=>{const W=new Set;for(const ee of t)W.add(fm(ee.type));return W},[t]),te=t.length-S.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:k==="overview"?"active":"","aria-pressed":k==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:k==="full"?"active":"","aria-pressed":k==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(W=>K.has(W)).map(W=>p.jsx("button",{type:"button","data-testid":`graph-family-${W}`,className:g.has(W)?"active":"","aria-pressed":g.has(W),onClick:()=>G(W),children:W},W))}),_==="3d"?p.jsx("button",{type:"button",className:y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(W=>!W),children:y?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[S.nodes.length," nodes · ",S.edges.length," edges",te?` · ${te} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Zk,{nodes:S.nodes,edges:S.edges,selectedId:o,neighborIds:C?S.neighborIds:Kk,onSelect:W=>{l(W),W||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]}):p.jsxs(sm,{children:[p.jsxs(KS,{nodes:j,edges:R,nodeTypes:tE,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:H,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(rE,{topologyKey:E}),p.jsx(nk,{}),p.jsx(kk,{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}}),p.jsx(uk,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],oE=["preset","branch","tag","commit"];function sE(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function lE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function aE(t){return oE.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function uE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[m,y]=$.useState(!1),[x,v]=$.useState(null),[_,k]=$.useState(0),C=$.useMemo(()=>{const j=sE(u);return x===null?j:lE(j,x)},[u,x]),S=$.useMemo(()=>aE(C),[C]);$.useEffect(()=>{m&&d()},[m,d]),$.useEffect(()=>{k(0)},[x,m]);const E=()=>{y(!1),v(null)},I=j=>{r(j.value),E()},N=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!m){y(!0);return}k(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!m)return;k(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&m){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&m&&(j.preventDefault(),E())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":m,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),m&&v(j.target.value)},onKeyDown:N}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":m,onMouseDown:j=>j.preventDefault(),onClick:()=>m?E():y(!0),children:p.jsx(p0,{})})]}),m?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:S.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):S.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:uE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:H=>H.preventDefault(),onMouseEnter:()=>k(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function cE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[m,y]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),k=$.useRef(0),C=async N=>{const j=k.current+1;k.current=j,v(!0);try{const R=await Ve.browse(N);if(k.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),y("")}catch(R){if(k.current!==j)return;y(R instanceof Error?R.message:String(R))}finally{k.current===j&&v(!1)}};$.useEffect(()=>{var N,j;C(t),(N=_.current)==null||N.focus(),(j=_.current)==null||j.select()},[t]);const S=f||(l==null?void 0:l.path)||u,E=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:N=>d(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),m?p.jsx("div",{className:"error",role:"alert",children:m}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(N=>{const j=f===N.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void C(N.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:S,children:S}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!S,onClick:()=>S&&r(S),children:["Use ",E]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],dE="obsidian",hm="loadpath.theme";function fE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(fE(t))return t}catch{}return dE}function hE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=hE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:u0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:c0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:d0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:f0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:h0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function pE(){var ar,ur,cr,Ln,dr,an,An;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,m]=$.useState(null),[y,x]=$.useState(null),[v,_]=$.useState([]),[k,C]=$.useState("review"),[S,E]=$.useState(""),[I,N]=$.useState(""),[j,R]=$.useState(""),[T,H]=$.useState({}),[G,K]=$.useState([]),[te,W]=$.useState([]),[ee,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,U]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,z]=$.useState(""),[B,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[q,le]=$.useState(null),[pe,_e]=$.useState(!1),ge=$.useRef(o);ge.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},be=$.useRef(""),Me=F=>{be.current=F,N(F)};$.useEffect(()=>{Ve.settings().then(H).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const nt=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ie=!1;return Ve.architecture(F).then(Ce=>{!ie&&ge.current===F&&x(Ce)}).catch(()=>{}),()=>{ie=!0}},[t,o]);const Qe=F=>{ge.current=F,l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},Je=$.useCallback(F=>{const ie=(F??ge.current).trim();return!ie||Ne.current===ie?Promise.resolve():(Ne.current=ie,Ve.gitRefs(ie).then(Ce=>{ge.current.trim()===ie&&de(Ce)}).catch(()=>{Ne.current===ie&&(Ne.current="",de(null))}))},[]),qe=(F,ie)=>{u(F),f(ie),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ie)},bt=(F,ie,Ce)=>{Y(F),J(ie),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ie),Ce!==void 0&&(U(Ce),localStorage.setItem("loadpath.prNumber",Ce))},$t=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ie;try{const Ce=await Ve.scmRepos(F);W(Ce.repos),(ie=Ce.user)!=null&&ie.login&&H(ze=>({...ze,...F==="github"?{github_user:Ce.user.login}:{bitbucket_user:Ce.user.login}}))}catch{W([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||W([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!q)return;let F=!1,ie=0;const Ce=async()=>{try{const ze=await Ve.githubOAuthPoll(q.flow_id);if(F)return;if(ze.status==="complete"){le(null);const $e=await Ve.settings();H($e),R(ze.user?`Signed in to GitHub as ${ze.user}`:"Signed in to GitHub"),ot("github");return}if(ze.status==="pending"||ze.status==="slow_down"){ie=window.setTimeout(Ce,Math.max(ze.interval||q.interval,5)*1e3);return}le(null),E(ze.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(ze){if(F)return;le(null),E(ze instanceof Error?ze.message:String(ze))}};return ie=window.setTimeout(Ce,Math.max(q.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ie)}},[q,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ie=0;const Ce=Date.now(),ze=async()=>{try{const $e=await Ve.oauthStatus();if(F)return;if($e.bitbucket.connected){_e(!1);const fr=await Ve.settings();H(fr),R($e.bitbucket.user?`Signed in to Bitbucket as ${$e.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-Ce>18e4){_e(!1),E("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ie=window.setTimeout(ze,1500)}catch($e){if(F)return;_e(!1),E($e instanceof Error?$e.message:String($e))}};return ie=window.setTimeout(ze,1500),()=>{F=!0,window.clearTimeout(ie)}},[pe,ot]);const st=async(F=o)=>{if(!F.trim())return null;const ie=await Ve.architecture(F);return ge.current===F&&x(ie),ie},yt=async F=>{const ie=F.trim();if(!(!ie||ie===ge.current)&&!be.current){E(""),R(""),m(null),x(null),Qe(ie),Me(`Loading ${a0(ie)}…`);try{await Promise.all([st(ie),Je(ie)])}catch(Ce){ge.current===ie&&E(Ce instanceof Error?Ce.message:String(Ce))}finally{ge.current===ie&&Me("")}}},lt=async()=>{if(!be.current&&nt()){E(""),R(""),Me("Tracing load path…"),Qe(o),qe(a,d);try{const F=await Ve.review(o,a,d,!0);m(F),C("review"),r("review"),await Ve.repos().then(ie=>_(ie.repos)).catch(()=>{}),await st(o)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},vt=async(F=!0)=>{if(!be.current&&nt()){E(""),R(""),Me(F?"Indexing…":"Full reindex…"),Qe(o);try{await Ve.index(o,F);const ie=await st(o);await Ve.repos().then(Ce=>_(Ce.repos)).catch(()=>{}),ie!=null&&ie.indexed&&(C("architecture"),r("architecture"))}catch(ie){E(ie instanceof Error?ie.message:String(ie))}finally{Me("")}}},In=async()=>{if(!be.current&&nt()){E(""),R(""),Me("Detecting layout…"),Qe(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ie=>_(ie.repos)).catch(()=>{})}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Wt=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){E(F instanceof Error?F.message:String(F))}},yn=async()=>{if(!be.current){if(!(g!=null&&g.markdown)||!ee||!V){E("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,ee,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},ji=async()=>{if(!be.current){E(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,ee);K(F.pull_requests);const ie=te.find(Ce=>Ce.slug.toLowerCase()===ee.trim().toLowerCase());ie!=null&&ie.local_path&&Qe(ie.local_path)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Or=async()=>{E("");try{const F=await Ve.githubOAuthStart();le(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){E(F instanceof Error?F.message:String(F))}},Fr=async()=>{E("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),E(F instanceof Error?F.message:String(F))}},Hr=async F=>{E("");try{H(await Ve.oauthDisconnect(F)),b===F&&W([]),R(`Disconnected ${F}`)}catch(ie){E(ie instanceof Error?ie.message:String(ie))}},sr=async F=>{F.preventDefault();const ie=new FormData(F.currentTarget),Ce={github_token:String(ie.get("github_token")||""),github_oauth_client_id:String(ie.get("github_oauth_client_id")||""),bitbucket_token:String(ie.get("bitbucket_token")||""),bitbucket_username:String(ie.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ie.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ie.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ie.get("ai_provider")||"none"),ai_api_key:String(ie.get("ai_api_key")||""),ai_model:String(ie.get("ai_model")||""),ai_base_url:String(ie.get("ai_base_url")||"")},ze=v.length?{...Ce,workspaces:v.map($e=>({path:$e.path,name:$e.name}))}:Ce;try{H(await Ve.saveSettings(ze)),R("Settings saved on this machine")}catch($e){E($e instanceof Error?$e.message:String($e))}},lr=async()=>{if(!(!g||be.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);z(F.note)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Tn=$.useRef(lt);Tn.current=lt;const vn=$.useRef(t);vn.current=t,$.useEffect(()=>{const F=ie=>{if(ye.current){ie.key==="Escape"&&(ie.preventDefault(),ce(!1));return}const Ce=ie.target;if(Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.tagName==="SELECT"||Ce.isContentEditable)){ie.key==="Escape"&&Ce.blur();return}if(ie.key==="Escape"){E(""),R("");return}const ze=yp.find($e=>$e.shortcut===ie.key);if(ze&&!ie.metaKey&&!ie.ctrlKey&&!ie.altKey&&r(ze.id),(ie.metaKey||ie.ctrlKey)&&ie.key==="Enter"){if(vn.current==="settings"||vn.current==="prs"||be.current)return;ie.preventDefault(),Tn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const Rn=$.useMemo(()=>k==="architecture"?(y==null?void 0:y.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,y,g]),sn=$.useMemo(()=>k==="architecture"?(y==null?void 0:y.edges)??[]:(g==null?void 0:g.edges)??[],[k,y,g]),ln=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:y!=null&&y.indexed?`${y.counts.nodes} nodes · ${y.counts.edges} edges`:"Not indexed",Br=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived),Mt=I.startsWith("Loading ");return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ie=F.icon,Ce=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:Ce?"nav-item active":"nav-item","aria-current":Ce?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ie,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:B,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ie=>ie.group===F).map(ie=>p.jsx("option",{value:ie.id,children:ie.label},ie.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||ln}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",disabled:!!I,"aria-busy":Mt,onChange:F=>{F.target.value&&yt(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ie=F.target.value;l(ie),ie.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>qe(F,d),placeholder:"base",refs:fe,onNeedRefs:Je})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>qe(a,F),placeholder:"head",refs:fe,onNeedRefs:Je})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:In,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>vt(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:lt,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[S?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:S}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((ar=g==null?void 0:g.index)!=null&&ar.stale||y!=null&&y.stale)&&(t==="review"||t==="architecture")?p.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,((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot)==="failed"||(y==null?void 0:y.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((cr=g==null?void 0:g.index)==null?void 0:cr.django_boot_detail)||(y==null?void 0:y.django_boot_detail)||"django.setup() failed"}):null,(Ln=g==null?void 0:g.workspace)!=null&&Ln.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage","aria-busy":Mt,children:[Mt?p.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[p.jsx("h2",{children:I}),p.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!Mt&&t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(gE,{review:g,findings:Br,aiNote:D,busy:!!I,onAskAi:lr,onCopy:Wt,onPost:yn}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx(Ou,{nodes:g.nodes,edges:g.edges}):null})]}),!Mt&&t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:y!=null&&y.indexed?p.jsx(mE,{architecture:y,busy:!!I,onReindex:()=>vt(!1),onReview:lt}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:y!=null&&y.indexed?p.jsx(Ou,{nodes:y.nodes,edges:y.edges}):null})]}),!Mt&&t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),Rn.length?p.jsx(Ou,{nodes:Rn,edges:sn}):p.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!Mt&&t==="prs"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,ee,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:te.length?"Search your repos":"owner/repo",value:ee,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:te.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!$t(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:ji,children:"List PRs"})]}),te.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[te.length," ",b," repositor",te.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{qe(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ie=te.find(Ce=>Ce.slug.toLowerCase()===F.repo.toLowerCase());ie!=null&&ie.local_path&&Qe(ie.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),!Mt&&t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:sr,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:B===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Hr("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!q||!T.github_oauth_ready,onClick:()=>void Or(),children:q?"Waiting for GitHub…":"Sign in with GitHub"})})]}),q?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:q.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Hr("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void Fr(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((an=T.ai)==null?void 0:an.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((An=T.ai)==null?void 0:An.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(cE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{ce(!1),yt(F)}}):null]})}function gE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,m,y,x,v,_,k,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(S=>p.jsx("li",{children:S},S))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(S=>p.jsx("span",{className:"chip",children:yo(S)},S))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((S,E)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[E+1,". ",S.path]}),p.jsx("div",{className:"why",children:S.why})]},S.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:S.title})," — ",S.files.join(", ")]},S.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(S=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${S.severity}`,children:S.severity}),S.message]},S.rule+S.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(S=>p.jsx("div",{className:"residual muted",children:S},S))]}),(y=(m=t.evolution)==null?void 0:m.notes)!=null&&y.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(S=>S.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(S=>p.jsx("div",{className:"muted",children:S},S)),(((k=t.evolution)==null?void 0:k.hotspots)||[]).filter(S=>S.commits).slice(0,6).map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:S.path})," — ",S.commits," commits, bus factor ",S.bus_factor]},S.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function mE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(pE,{})}));export{zk as L,xE as a,yE as c,p as j,vE as l,$ as r,yl as t}; diff --git a/src/loadpath/static/assets/index-Dc1-DXoM.js b/src/loadpath/static/assets/index-Dc1-DXoM.js deleted file mode 100644 index dfb0720..0000000 --- a/src/loadpath/static/assets/index-Dc1-DXoM.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 xp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _u={exports:{}},uo={},Su={exports:{}},Ie={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Vf;function Qy(){if(Vf)return Ie;Vf=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"),g=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),x=Symbol.iterator;function v(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,C={};function S(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}S.prototype.isReactComponent={},S.prototype.setState=function(M,L){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,L,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=S.prototype;function I(M,L,ne){this.props=M,this.context=L,this.refs=C,this.updater=ne||_}var N=I.prototype=new E;N.constructor=I,k(N,S.prototype),N.isPureReactComponent=!0;var j=Array.isArray,R=Object.prototype.hasOwnProperty,T={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function G(M,L,ne){var re,ce={},fe=null,de=null;if(L!=null)for(re in L.ref!==void 0&&(de=L.ref),L.key!==void 0&&(fe=""+L.key),L)R.call(L,re)&&!H.hasOwnProperty(re)&&(ce[re]=L[re]);var q=arguments.length-2;if(q===1)ce.children=ne;else if(1>>1,L=D[M];if(0>>1;Ma(ce,B))fea(de,ce)?(D[M]=de,D[fe]=B,M=fe):(D[M]=ce,D[re]=B,M=re);else if(fea(de,B))D[M]=de,D[fe]=B,M=fe;else break e}}return z}function a(D,z){var B=D.sortIndex-z.sortIndex;return B!==0?B:D.id-z.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 g=[],y=[],m=1,x=null,v=3,_=!1,k=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,I=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(D){for(var z=o(y);z!==null;){if(z.callback===null)l(y);else if(z.startTime<=D)l(y),z.sortIndex=z.expirationTime,r(g,z);else break;z=o(y)}}function j(D){if(C=!1,N(D),!k)if(o(g)!==null)k=!0,V(R);else{var z=o(y);z!==null&&U(j,z.startTime-D)}}function R(D,z){k=!1,C&&(C=!1,E(G),G=-1),_=!0;var B=v;try{for(N(z),x=o(g);x!==null&&(!(x.expirationTime>z)||D&&!W());){var M=x.callback;if(typeof M=="function"){x.callback=null,v=x.priorityLevel;var L=M(x.expirationTime<=z);z=t.unstable_now(),typeof L=="function"?x.callback=L:x===o(g)&&l(g),N(z)}else l(g);x=o(g)}if(x!==null)var ne=!0;else{var re=o(y);re!==null&&U(j,re.startTime-z),ne=!1}return ne}finally{x=null,v=B,_=!1}}var T=!1,H=null,G=-1,K=5,te=-1;function W(){return!(t.unstable_now()-teD||125M?(D.sortIndex=B,r(y,D),o(g)===null&&D===o(y)&&(C?(E(G),G=-1):C=!0,U(j,B-M))):(D.sortIndex=L,r(g,D),k||_||(k=!0,V(R))),D},t.unstable_shouldYield=W,t.unstable_wrapCallback=function(D){var z=v;return function(){var B=v;v=z;try{return D.apply(this,arguments)}finally{v=B}}}})(Nu)),Nu}var Gf;function e0(){return Gf||(Gf=1,Eu.exports=Jy()),Eu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Qf;function t0(){if(Qf)return Ct;Qf=1;var t=bo(),r=e0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},x={};function v(e){return g.call(x,e)?!0:g.call(m,e)?!1:y.test(e)?x[e]=!0:(m[e]=!0,!1)}function _(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 k(e,n,i,s){if(n===null||typeof n>"u"||_(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 S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){S[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];S[n]=new C(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){S[e]=new C(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){S[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){S[e]=new C(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){S[e]=new C(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){S[e]=new C(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){S[e]=new C(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){S[e]=new C(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function I(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,I);S[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,I);S[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,I);S[n]=new C(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!1,!1)}),S.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){S[e]=new C(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,s){var c=S.hasOwnProperty(n)?S[n]:null;(c!==null?c.type!==0:s||!(2P||c[w]!==h[P]){var A=` -`+c[w].replace(" at new "," at ");return e.displayName&&A.includes("")&&(A=A.replace("",e.displayName)),A}while(1<=w&&0<=P);break}}}finally{ne=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?L(e):""}function ce(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case T:return"Portal";case K:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case W:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Y:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function 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 pe(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 _e(e){e._valueTracker||(e._valueTracker=pe(e))}function me(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 ye(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(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 je(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Me(e,n){je(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")?Ge(e,n.type,i):n.hasOwnProperty("defaultValue")&&Ge(e,n.type,q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var 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 Ge(e,n,i){(n!=="number"||ye(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var nt=Array.isArray;function qe(e,n,i,s){if(e=e.options,n){n={};for(var c=0;c"+n.valueOf().toString()+"",n=wt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ut(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var gn={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},Ni=["Webkit","ms","Moz","O"];Object.keys(gn).forEach(function(e){Ni.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),gn[n]=gn[e]})});function Or(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||gn.hasOwnProperty(e)&&gn[e]?(""+n).trim():n+"px"}function ir(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var s=i.indexOf("--")===0,c=Or(i,n[i],s);i==="float"&&(i="cssFloat"),s?e.setProperty(i,c):e[i]=c}}var Ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function or(e,n){if(n){if(Ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Pn(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 mn=null;function In(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,on=null,sn=null;function lr(e){if(e=Gi(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=os(n),sr(e.stateNode,e.type,n))}}function ar(e){on?sn?sn.push(e):sn=[e]:on=e}function ur(){if(on){var e=on,n=sn;if(sn=on=null,lr(e),n)for(e=0;e>>=0,e===0?32:31-(Fl(e)/Hl|0)|0}var Vr=64,Ur=4194304;function hr(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 yn(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 P=w&~c;P!==0?s=hr(P):(h&=w,h!==0&&(s=hr(h)))}else w=i&~c,w!==0?s=hr(w):h!==0&&(s=hr(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 gr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Pt(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0=Oi),Ac=" ",zc=!1;function Dc(e,n){switch(e){case"keyup":return Um.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $c(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Gr=!1;function Ym(e,n){switch(e){case"compositionend":return $c(n);case"keypress":return n.which!==32?null:(zc=!0,Ac);case"textInput":return e=n.data,e===Ac&&zc?null:e;default:return null}}function Xm(e,n){if(Gr)return e==="compositionend"||!ta&&Dc(e,n)?(e=Mc(),Go=Ql=$n=null,Gr=!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=Wc(i)}}function Xc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Xc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Gc(){for(var e=window,n=ye();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ye(e.document)}return n}function ia(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 ny(e){var n=Gc(),i=e.focusedElem,s=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Xc(i.ownerDocument.documentElement,i)){if(s!==null&&ia(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=Yc(i,h);var w=Yc(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,Qr=null,oa=null,Vi=null,sa=!1;function Qc(e,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;sa||Qr==null||Qr!==ye(s)||(s=Qr,"selectionStart"in s&&ia(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}),Vi&&Bi(Vi,s)||(Vi=s,s=ns(oa,"onSelect"),0ei||(e.current=va[ei],va[ei]=null,ei--)}function De(e,n){ei++,va[ei]=e.current,e.current=n}var Bn={},pt=Hn(Bn),_t=Hn(!1),yr=Bn;function ti(e,n){var i=e.type.contextTypes;if(!i)return Bn;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 St(e){return e=e.childContextTypes,e!=null}function ss(){Fe(_t),Fe(pt)}function cd(e,n,i){if(pt.current!==Bn)throw Error(o(168));De(pt,n),De(_t,i)}function dd(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,de(e)||"Unknown",c));return B({},i,s)}function ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Bn,yr=pt.current,De(pt,e),De(_t,_t.current),!0}function fd(e,n,i){var s=e.stateNode;if(!s)throw Error(o(169));i?(e=dd(e,n,yr),s.__reactInternalMemoizedMergedChildContext=e,Fe(_t),Fe(pt),De(pt,e)):Fe(_t),De(_t,i)}var xn=null,as=!1,xa=!1;function hd(e){xn===null?xn=[e]:xn.push(e)}function py(e){as=!0,hd(e)}function Vn(){if(!xa&&xn!==null){xa=!0;var e=0,n=Ae;try{var i=xn;for(Ae=1;e>=w,c-=w,wn=1<<32-Pt(n)+c|i<Ce?(at=Ee,Ee=null):at=Ee.sibling;var Le=ie(X,Ee,Q[Ce],ue);if(Le===null){Ee===null&&(Ee=at);break}e&&Ee&&Le.alternate===null&&n(X,Ee),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le,Ee=at}if(Ce===Q.length)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;CeCe?(at=Ee,Ee=null):at=Ee.sibling;var Zn=ie(X,Ee,Le.value,ue);if(Zn===null){Ee===null&&(Ee=at);break}e&&Ee&&Zn.alternate===null&&n(X,Ee),O=h(Zn,O,Ce),ke===null?we=Zn:ke.sibling=Zn,ke=Zn,Ee=at}if(Le.done)return i(X,Ee),Be&&xr(X,Ce),we;if(Ee===null){for(;!Le.done;Ce++,Le=Q.next())Le=le(X,Le.value,ue),Le!==null&&(O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return Be&&xr(X,Ce),we}for(Ee=s(X,Ee);!Le.done;Ce++,Le=Q.next())Le=he(Ee,X,Ce,Le.value,ue),Le!==null&&(e&&Le.alternate!==null&&Ee.delete(Le.key===null?Ce:Le.key),O=h(Le,O,Ce),ke===null?we=Le:ke.sibling=Le,ke=Le);return e&&Ee.forEach(function(Gy){return n(X,Gy)}),Be&&xr(X,Ce),we}function Ke(X,O,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 R:e:{for(var we=Q.key,ke=O;ke!==null;){if(ke.key===we){if(we=Q.type,we===H){if(ke.tag===7){i(X,ke.sibling),O=c(ke,Q.props.children),O.return=X,X=O;break e}}else if(ke.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===V&&xd(we)===ke.type){i(X,ke.sibling),O=c(ke,Q.props),O.ref=Qi(X,ke,Q),O.return=X,X=O;break e}i(X,ke);break}else n(X,ke);ke=ke.sibling}Q.type===H?(O=jr(Q.props.children,X.mode,ue,Q.key),O.return=X,X=O):(ue=zs(Q.type,Q.key,Q.props,null,X.mode,ue),ue.ref=Qi(X,O,Q),ue.return=X,X=ue)}return w(X);case T:e:{for(ke=Q.key;O!==null;){if(O.key===ke)if(O.tag===4&&O.stateNode.containerInfo===Q.containerInfo&&O.stateNode.implementation===Q.implementation){i(X,O.sibling),O=c(O,Q.children||[]),O.return=X,X=O;break e}else{i(X,O);break}else n(X,O);O=O.sibling}O=mu(Q,X.mode,ue),O.return=X,X=O}return w(X);case V:return ke=Q._init,Ke(X,O,ke(Q._payload),ue)}if(nt(Q))return ve(X,O,Q,ue);if(z(Q))return xe(X,O,Q,ue);fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,O!==null&&O.tag===6?(i(X,O.sibling),O=c(O,Q),O.return=X,X=O):(i(X,O),O=gu(Q,X.mode,ue),O.return=X,X=O),w(X)):i(X,O)}return Ke}var oi=wd(!0),_d=wd(!1),hs=Hn(null),ps=null,si=null,Na=null;function Ca(){Na=si=ps=null}function ja(e){var n=hs.current;Fe(hs),e._currentValue=n}function ba(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 li(e,n){ps=e,Na=si=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(kt=!0),e.firstContext=null)}function Ft(e){var n=e._currentValue;if(Na!==e)if(e={context:e,memoizedValue:n,next:null},si===null){if(ps===null)throw Error(o(308));si=e,ps.dependencies={lanes:0,firstContext:e}}else si=si.next=e;return n}var wr=null;function Ma(e){wr===null?wr=[e]:wr.push(e)}function Sd(e,n,i,s){var c=n.interleaved;return c===null?(i.next=i,Ma(n)):(i.next=c.next,c.next=i),n.interleaved=i,Sn(e,s)}function Sn(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 Un=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function kd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Wn(e,n,i){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var c=s.pending;return c===null?n.next=n:(n.next=c.next,c.next=n),s.pending=n,Sn(e,i)}return c=s.interleaved,c===null?(n.next=n,Ma(s)):(n.next=c.next,c.next=n),s.interleaved=n,Sn(e,i)}function gs(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,Wr(e,i)}}function Ed(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 ms(e,n,i,s){var c=e.updateQueue;Un=!1;var h=c.firstBaseUpdate,w=c.lastBaseUpdate,P=c.shared.pending;if(P!==null){c.shared.pending=null;var A=P,Z=A.next;A.next=null,w===null?h=Z:w.next=Z,w=A;var oe=e.alternate;oe!==null&&(oe=oe.updateQueue,P=oe.lastBaseUpdate,P!==w&&(P===null?oe.firstBaseUpdate=Z:P.next=Z,oe.lastBaseUpdate=A))}if(h!==null){var le=c.baseState;w=0,oe=Z=A=null,P=h;do{var ie=P.lane,he=P.eventTime;if((s&ie)===ie){oe!==null&&(oe=oe.next={eventTime:he,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var ve=e,xe=P;switch(ie=n,he=i,xe.tag){case 1:if(ve=xe.payload,typeof ve=="function"){le=ve.call(he,le,ie);break e}le=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=xe.payload,ie=typeof ve=="function"?ve.call(he,le,ie):ve,ie==null)break e;le=B({},le,ie);break e;case 2:Un=!0}}P.callback!==null&&P.lane!==0&&(e.flags|=64,ie=c.effects,ie===null?c.effects=[P]:ie.push(P))}else he={eventTime:he,lane:ie,tag:P.tag,payload:P.payload,callback:P.callback,next:null},oe===null?(Z=oe=he,A=le):oe=oe.next=he,w|=ie;if(P=P.next,P===null){if(P=c.shared.pending,P===null)break;ie=P,P=ie.next,ie.next=null,c.lastBaseUpdate=ie,c.shared.pending=null}}while(!0);if(oe===null&&(A=le),c.baseState=A,c.firstBaseUpdate=Z,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);kr|=w,e.lanes=w,e.memoizedState=le}}function Nd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var s=Aa.transition;Aa.transition={};try{e(!1),n()}finally{Ae=i,Aa.transition=s}}function Ud(){return Ht().memoizedState}function vy(e,n,i){var s=Qn(e);if(i={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(e))Yd(n,i);else if(i=Sd(e,n,i,s),i!==null){var c=xt();qt(i,e,s,c),Xd(i,n,s)}}function xy(e,n,i){var s=Qn(e),c={lane:s,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(e))Yd(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,P=h(w,i);if(c.hasEagerState=!0,c.eagerState=P,Wt(P,w)){var A=n.interleaved;A===null?(c.next=c,Ma(n)):(c.next=A.next,A.next=c),n.interleaved=c;return}}catch{}finally{}i=Sd(e,n,c,s),i!==null&&(c=xt(),qt(i,e,s,c),Xd(i,n,s))}}function Wd(e){var n=e.alternate;return e===Ye||n!==null&&n===Ye}function Yd(e,n){Ji=xs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Xd(e,n,i){if((i&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,i|=s,n.lanes=i,Wr(e,i)}}var Ss={readContext:Ft,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useInsertionEffect:gt,useLayoutEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useMutableSource:gt,useSyncExternalStore:gt,useId:gt,unstable_isNewReconciler:!1},wy={readContext:Ft,useCallback:function(e,n){return cn().memoizedState=[e,n===void 0?null:n],e},useContext:Ft,useEffect:zd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,ws(4194308,4,Od.bind(null,n,e),i)},useLayoutEffect:function(e,n){return ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return ws(4,2,e,n)},useMemo:function(e,n){var i=cn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var s=cn();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=vy.bind(null,Ye,e),[s.memoizedState,e]},useRef:function(e){var n=cn();return e={current:e},n.memoizedState=e},useState:Ld,useDebugValue:Ba,useDeferredValue:function(e){return cn().memoizedState=e},useTransition:function(){var e=Ld(!1),n=e[0];return e=yy.bind(null,e[1]),cn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var s=Ye,c=cn();if(Be){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),lt===null)throw Error(o(349));(Sr&30)!==0||Md(s,n,i)}c.memoizedState=i;var h={value:i,getSnapshot:n};return c.queue=h,zd(Id.bind(null,s,h,e),[e]),s.flags|=2048,no(9,Pd.bind(null,s,h,i,n),void 0,null),i},useId:function(){var e=cn(),n=lt.identifierPrefix;if(Be){var i=_n,s=wn;i=(s&~(1<<32-Pt(s)-1)).toString(32)+i,n=":"+n+"R"+i,i=eo++,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[an]=n,e[Xi]=s,pf(e,n,!1,!1),n.stateNode=e;e:{switch(w=Pn(i,s),i){case"dialog":Oe("cancel",e),Oe("close",e),c=s;break;case"iframe":case"object":case"embed":Oe("load",e),c=s;break;case"video":case"audio":for(c=0;cfi&&(n.flags|=128,s=!0,ro(h,!1),n.lanes=4194304)}else{if(!s)if(e=ys(w),e!==null){if(n.flags|=128,s=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ro(h,!0),h.tail===null&&h.tailMode==="hidden"&&!w.alternate&&!Be)return mt(n),null}else 2*Ue()-h.renderingStartTime>fi&&i!==1073741824&&(n.flags|=128,s=!0,ro(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=Ue(),n.sibling=null,i=We.current,De(We,s?i&1|2:i&1),n):(mt(n),null);case 22:case 23:return fu(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(Lt&1073741824)!==0&&(mt(n),n.subtreeFlags&6&&(n.flags|=8192)):mt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function by(e,n){switch(_a(n),n.tag){case 1:return St(n.type)&&ss(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ai(),Fe(_t),Fe(pt),La(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ta(n),null;case 13:if(Fe(We),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ii()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Fe(We),null;case 4:return ai(),null;case 10:return ja(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Cs=!1,yt=!1,My=typeof WeakSet=="function"?WeakSet:Set,ge=null;function ci(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(s){Qe(e,n,s)}else i.current=null}function eu(e,n,i){try{i()}catch(s){Qe(e,n,s)}}var yf=!1;function Py(e,n){if(fa=Yo,e=Gc(),ia(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,P=-1,A=-1,Z=0,oe=0,le=e,ie=null;t:for(;;){for(var he;le!==i||c!==0&&le.nodeType!==3||(P=w+c),le!==h||s!==0&&le.nodeType!==3||(A=w+s),le.nodeType===3&&(w+=le.nodeValue.length),(he=le.firstChild)!==null;)ie=le,le=he;for(;;){if(le===e)break t;if(ie===i&&++Z===c&&(P=w),ie===h&&++oe===s&&(A=w),(he=le.nextSibling)!==null)break;le=ie,ie=le.parentNode}le=he}i=P===-1||A===-1?null:{start:P,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(ha={focusedElem:e,selectionRange:i},Yo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var xe=ve.memoizedProps,Ke=ve.memoizedState,X=n.stateNode,O=X.getSnapshotBeforeUpdate(n.elementType===n.type?xe:Xt(n.type,xe),Ke);X.__reactInternalSnapshotBeforeUpdate=O}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){Qe(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ve=yf,yf=!1,ve}function io(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&&eu(n,i,h)}c=c.next}while(c!==s)}}function js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var s=i.create;i.destroy=s()}i=i.next}while(i!==n)}}function tu(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 vf(e){var n=e.alternate;n!==null&&(e.alternate=null,vf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[an],delete n[Xi],delete n[ya],delete n[fy],delete n[hy])),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 xf(e){return e.tag===5||e.tag===3||e.tag===4}function wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xf(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 nu(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=is));else if(s!==4&&(e=e.child,e!==null))for(nu(e,n,i),e=e.sibling;e!==null;)nu(e,n,i),e=e.sibling}function ru(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(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}var dt=null,Gt=!1;function Yn(e,n,i){for(i=i.child;i!==null;)_f(e,n,i),i=i.sibling}function _f(e,n,i){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Br,i)}catch{}switch(i.tag){case 5:yt||ci(i,n);case 6:var s=dt,c=Gt;dt=null,Yn(e,n,i),dt=s,Gt=c,dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):dt.removeChild(i.stateNode));break;case 18:dt!==null&&(Gt?(e=dt,i=i.stateNode,e.nodeType===8?ma(e.parentNode,i):e.nodeType===1&&ma(e,i),zi(e)):ma(dt,i.stateNode));break;case 4:s=dt,c=Gt,dt=i.stateNode.containerInfo,Gt=!0,Yn(e,n,i),dt=s,Gt=c;break;case 0:case 11:case 14:case 15:if(!yt&&(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)&&eu(i,n,w),c=c.next}while(c!==s)}Yn(e,n,i);break;case 1:if(!yt&&(ci(i,n),s=i.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=i.memoizedProps,s.state=i.memoizedState,s.componentWillUnmount()}catch(P){Qe(i,n,P)}Yn(e,n,i);break;case 21:Yn(e,n,i);break;case 22:i.mode&1?(yt=(s=yt)||i.memoizedState!==null,Yn(e,n,i),yt=s):Yn(e,n,i);break;default:Yn(e,n,i)}}function Sf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new My),n.forEach(function(s){var c=Oy.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=Ue()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*Ty(s/1960))-s,10e?16:e,Gn===null)var s=!1;else{if(e=Gn,Gn=null,Ts=0,(Te&6)!==0)throw Error(o(331));var c=Te;for(Te|=4,ge=e.current;ge!==null;){var h=ge,w=h.child;if((ge.flags&16)!==0){var P=h.deletions;if(P!==null){for(var A=0;AUe()-su?Nr(e,0):ou|=i),Nt(e,n)}function Af(e,n){n===0&&((e.mode&1)===0?n=1:(n=Ur,Ur<<=1,(Ur&130023424)===0&&(Ur=4194304)));var i=xt();e=Sn(e,n),e!==null&&(gr(e,n,i),Nt(e,i))}function $y(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Af(e,i)}function Oy(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),Af(e,i)}var zf;zf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||_t.current)kt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return kt=!1,Cy(e,n,i);kt=(e.flags&131072)!==0}else kt=!1,Be&&(n.flags&1048576)!==0&&pd(n,cs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;Ns(e,n),e=n.pendingProps;var c=ti(n,pt.current);li(n,i),c=Da(null,n,s,e,c,i);var h=$a();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,St(s)?(h=!0,ls(n)):h=!1,n.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,Pa(n),c.updater=ks,n.stateNode=c,c._reactInternals=n,Ua(n,s,e,i),n=Ga(null,n,s,!0,h,i)):(n.tag=0,Be&&h&&wa(n),vt(null,n,c,i),n=n.child),n;case 16:s=n.elementType;e:{switch(Ns(e,n),e=n.pendingProps,c=s._init,s=c(s._payload),n.type=s,c=n.tag=Hy(s),e=Xt(s,e),c){case 0:n=Xa(null,n,s,e,i);break e;case 1:n=af(null,n,s,e,i);break e;case 11:n=nf(null,n,s,e,i);break e;case 14:n=rf(null,n,s,Xt(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:Xt(s,c),Xa(e,n,s,c,i);case 1:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),af(e,n,s,c,i);case 3:e:{if(uf(n),e===null)throw Error(o(387));s=n.pendingProps,h=n.memoizedState,c=h.element,kd(e,n),ms(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=ui(Error(o(423)),n),n=cf(e,n,s,i,c);break e}else if(s!==c){c=ui(Error(o(424)),n),n=cf(e,n,s,i,c);break e}else for(Rt=Fn(n.stateNode.containerInfo.firstChild),Tt=n,Be=!0,Yt=null,i=_d(n,null,s,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ii(),s===c){n=En(e,n,i);break e}vt(e,n,s,i)}n=n.child}return n;case 5:return Cd(n),e===null&&ka(n),s=n.type,c=n.pendingProps,h=e!==null?e.memoizedProps:null,w=c.children,pa(s,c)?w=null:h!==null&&pa(s,h)&&(n.flags|=32),lf(e,n),vt(e,n,w,i),n.child;case 6:return e===null&&ka(n),null;case 13:return df(e,n,i);case 4:return Ia(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=oi(n,null,s,i):vt(e,n,s,i),n.child;case 11:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),nf(e,n,s,c,i);case 7:return vt(e,n,n.pendingProps,i),n.child;case 8:return vt(e,n,n.pendingProps.children,i),n.child;case 12:return vt(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,De(hs,s._currentValue),s._currentValue=w,h!==null)if(Wt(h.value,w)){if(h.children===c.children&&!_t.current){n=En(e,n,i);break e}}else for(h=n.child,h!==null&&(h.return=n);h!==null;){var P=h.dependencies;if(P!==null){w=h.child;for(var A=P.firstContext;A!==null;){if(A.context===s){if(h.tag===1){A=kn(-1,i&-i),A.tag=2;var Z=h.updateQueue;if(Z!==null){Z=Z.shared;var oe=Z.pending;oe===null?A.next=A:(A.next=oe.next,oe.next=A),Z.pending=A}}h.lanes|=i,A=h.alternate,A!==null&&(A.lanes|=i),ba(h.return,i,n),P.lanes|=i;break}A=A.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,P=w.alternate,P!==null&&(P.lanes|=i),ba(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}vt(e,n,c.children,i),n=n.child}return n;case 9:return c=n.type,s=n.pendingProps.children,li(n,i),c=Ft(c),s=s(c),n.flags|=1,vt(e,n,s,i),n.child;case 14:return s=n.type,c=Xt(s,n.pendingProps),c=Xt(s.type,c),rf(e,n,s,c,i);case 15:return of(e,n,n.type,n.pendingProps,i);case 17:return s=n.type,c=n.pendingProps,c=n.elementType===s?c:Xt(s,c),Ns(e,n),n.tag=1,St(s)?(e=!0,ls(n)):e=!1,li(n,i),Qd(n,s,c),Ua(n,s,c,i),Ga(null,n,s,!0,e,i);case 19:return hf(e,n,i);case 22:return sf(e,n,i)}throw Error(o(156,n.tag))};function Df(e,n){return Do(e,n)}function Fy(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 Fy(e,n,i,s)}function pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Hy(e){if(typeof e=="function")return pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===Y)return 14}return 2}function Kn(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 zs(e,n,i,s,c,h){var w=2;if(s=e,typeof e=="function")pu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case H:return jr(i.children,c,h,n);case G:w=8,c|=8;break;case K:return e=Vt(12,i,n,c|2),e.elementType=K,e.lanes=h,e;case J:return e=Vt(13,i,n,c),e.elementType=J,e.lanes=h,e;case b:return e=Vt(19,i,n,c),e.elementType=b,e.lanes=h,e;case U:return Ds(i,c,h,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:w=10;break e;case W:w=9;break e;case ee:w=11;break e;case Y: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 jr(e,n,i,s){return e=Vt(7,e,s,n),e.lanes=i,e}function Ds(e,n,i,s){return e=Vt(22,e,s,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function gu(e,n,i){return e=Vt(6,e,null,n),e.lanes=i,e}function mu(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 By(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=pr(0),this.expirationTimes=pr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pr(0),this.identifierPrefix=s,this.onRecoverableError=c,this.mutableSourceEagerHydrationData=null}function yu(e,n,i,s,c,h,w,P,A){return e=new By(e,n,i,P,A),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},Pa(h),e}function Vy(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(),ku.exports=t0(),ku.exports}var Kf;function n0(){if(Kf)return Us;Kf=1;var t=wp();return Us.createRoot=t.createRoot,Us.hydrateRoot=t.hydrateRoot,Us}var r0=n0();function i0(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 Ze(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(i0(l,o.statusText||"Request failed"))}return o.json()}const o0=["github_token","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Ve={health:()=>Ze("/api/health"),settings:()=>Ze("/api/settings"),saveSettings:t=>{const r={...t};for(const o of o0)r[o]===""&&delete r[o];return Ze("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ze("/api/repos"),browse:t=>Ze(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ze(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ze("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ze(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ze(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,l=!0)=>Ze("/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)=>Ze("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,l)=>Ze("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:l})}),graph:(t,r="full")=>Ze(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ze("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ze(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ze("/api/oauth/status"),githubOAuthStart:()=>Ze("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ze("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ze("/api/oauth/bitbucket/start"),oauthDisconnect:t=>Ze("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ze("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function yo(t){return t.replaceAll("_"," ")}function s0(t){return t.replaceAll("_"," ")}function yl(t){return t.split(".").pop()||t}function l0(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function Mr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function $r({className:t,children:r}){return p.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 a0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),p.jsx("path",{d:"M9.5 3.5V7H13"}),p.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function u0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),p.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function c0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),p.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),p.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function d0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),p.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),p.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),p.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function f0({className:t}){return p.jsxs($r,{className:t,children:[p.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),p.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 _p({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function h0({className:t}){return p.jsx($r,{className:t,children:p.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const p0="modulepreload",g0=function(t,r){return new URL(t,r).href},Zf={},m0=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(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=d(o.map(m=>{if(m=g0(m,l),m in Zf)return;Zf[m]=!0;const x=m.endsWith(".css"),v=x?'[rel="stylesheet"]':"";if(!!l)for(let C=f.length-1;C>=0;C--){const S=f[C];if(S.href===m&&(!x||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":p0,x||(k.as="script"),k.crossOrigin="",k.href=m,y&&k.setAttribute("nonce",y),document.head.appendChild(k),x)return new Promise((C,S)=>{k.addEventListener("load",C),k.addEventListener("error",()=>S(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 et(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,l;o{}};function vl(){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}})}tl.prototype=vl.prototype={constructor:tl,on:function(t,r){var o=this._,l=v0(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)),eh.hasOwnProperty(r)?{space:eh[r],local:t}:t}function w0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Fu&&r.documentElement.namespaceURI===Fu?r.createElement(t):r.createElementNS(o,t)}}function _0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Sp(t){var r=xl(t);return(r.local?_0:w0)(r)}function S0(){}function nc(t){return t==null?S0:function(){return this.querySelector(t)}}function k0(t){typeof t!="function"&&(t=nc(t));for(var r=this._groups,o=r.length,l=new Array(o),a=0;a=N&&(N=I+1);!(R=S[N])&&++N=0;)(d=l[a])&&(u&&d.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(d,u),u=d);return this}function G0(t){t||(t=Q0);function r(x,v){return x&&v?t(x.__data__,v.__data__):!x-!v}for(var o=this._groups,l=o.length,a=new Array(l),u=0;ur?1:t>=r?0:NaN}function q0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function K0(){return Array.from(this)}function Z0(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?uv:typeof r=="function"?dv:cv)(t,r,o??"")):vi(this.node(),t)}function vi(t,r){return t.style.getPropertyValue(r)||jp(t).getComputedStyle(t,null).getPropertyValue(r)}function hv(t){return function(){delete this[t]}}function pv(t,r){return function(){this[t]=r}}function gv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function mv(t,r){return arguments.length>1?this.each((r==null?hv:typeof r=="function"?gv:pv)(t,r)):this.node()[t]}function bp(t){return t.trim().split(/^|\s+/)}function rc(t){return t.classList||new Mp(t)}function Mp(t){this._node=t,this._names=bp(t.getAttribute("class")||"")}Mp.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 Pp(t,r){for(var o=rc(t),l=-1,a=r.length;++l=0&&(o=r.slice(l+1),r=r.slice(0,l)),{type:r,name:o}})}function Uv(t){return function(){var r=this.__on;if(r){for(var o=0,l=-1,a=r.length,u;o()=>t;function Hu(t,{sourceEvent:r,subject:o,target:l,identifier:a,active:u,x:d,y:f,dx:g,dy:y,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:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:m}})}Hu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ex(t){return!t.ctrlKey&&!t.button}function tx(){return this.parentNode}function nx(t,r){return r??{x:t.x,y:t.y}}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function zp(){var t=ex,r=tx,o=nx,l=rx,a={},u=vl("start","drag","end"),d=0,f,g,y,m,x=0;function v(j){j.on("mousedown.drag",_).filter(l).on("touchstart.drag",S).on("touchmove.drag",E,Jv).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,R){if(!(m||!t.call(this,j,R))){var T=N(this,r.call(this,j,R),j,R,"mouse");T&&(At(j.view).on("mousemove.drag",k,vo).on("mouseup.drag",C,vo),Lp(j.view),Cu(j),y=!1,f=j.clientX,g=j.clientY,T("start",j))}}function k(j){if(mi(j),!y){var R=j.clientX-f,T=j.clientY-g;y=R*R+T*T>x}a.mouse("drag",j)}function C(j){At(j.view).on("mousemove.drag mouseup.drag",null),Ap(j.view,y),mi(j),a.mouse("end",j)}function S(j,R){if(t.call(this,j,R)){var T=j.changedTouches,H=r.call(this,j,R),G=T.length,K,te;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Ys(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Ys(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=ox.exec(t))?new jt(r[1],r[2],r[3],1):(r=sx.exec(t))?new jt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=lx.exec(t))?Ys(r[1],r[2],r[3],r[4]):(r=ax.exec(t))?Ys(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=ux.exec(t))?lh(r[1],r[2]/100,r[3]/100,1):(r=cx.exec(t))?lh(r[1],r[2]/100,r[3]/100,r[4]):th.hasOwnProperty(t)?ih(th[t]):t==="transparent"?new jt(NaN,NaN,NaN,0):null}function ih(t){return new jt(t>>16&255,t>>8&255,t&255,1)}function Ys(t,r,o,l){return l<=0&&(t=r=o=NaN),new jt(t,r,o,l)}function hx(t){return t instanceof Po||(t=Rr(t)),t?(t=t.rgb(),new jt(t.r,t.g,t.b,t.opacity)):new jt}function Bu(t,r,o,l){return arguments.length===1?hx(t):new jt(t,r,o,l??1)}function jt(t,r,o,l){this.r=+t,this.g=+r,this.b=+o,this.opacity=+l}ic(jt,Bu,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new jt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new jt(Ir(this.r),Ir(this.g),Ir(this.b),al(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:oh,formatHex:oh,formatHex8:px,formatRgb:sh,toString:sh}));function oh(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}`}function px(){return`#${Pr(this.r)}${Pr(this.g)}${Pr(this.b)}${Pr((isNaN(this.opacity)?1:this.opacity)*255)}`}function sh(){const t=al(this.opacity);return`${t===1?"rgb(":"rgba("}${Ir(this.r)}, ${Ir(this.g)}, ${Ir(this.b)}${t===1?")":`, ${t})`}`}function al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ir(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Pr(t){return t=Ir(t),(t<16?"0":"")+t.toString(16)}function lh(t,r,o,l){return l<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new Zt(t,r,o,l)}function $p(t){if(t instanceof Zt)return new Zt(t.h,t.s,t.l,t.opacity);if(t instanceof Po||(t=Rr(t)),!t)return new Zt;if(t instanceof Zt)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,g=(u+a)/2;return f?(r===u?d=(o-l)/f+(o0&&g<1?0:d,new Zt(d,f,g,t.opacity)}function gx(t,r,o,l){return arguments.length===1?$p(t):new Zt(t,r,o,l??1)}function Zt(t,r,o,l){this.h=+t,this.s=+r,this.l=+o,this.opacity=+l}ic(Zt,gx,Dp(Po,{brighter(t){return t=t==null?ll:Math.pow(ll,t),new Zt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?xo:Math.pow(xo,t),new Zt(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 jt(ju(t>=240?t-240:t+120,a,l),ju(t,a,l),ju(t<120?t+240:t-120,a,l),this.opacity)},clamp(){return new Zt(ah(this.h),Xs(this.s),Xs(this.l),al(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=al(this.opacity);return`${t===1?"hsl(":"hsla("}${ah(this.h)}, ${Xs(this.s)*100}%, ${Xs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ah(t){return t=(t||0)%360,t<0?t+360:t}function Xs(t){return Math.max(0,Math.min(1,t||0))}function ju(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 oc=t=>()=>t;function mx(t,r){return function(o){return t+o*r}}function yx(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 vx(t){return(t=+t)==1?Op:function(r,o){return o-r?yx(r,o,t):oc(isNaN(r)?o:r)}}function Op(t,r){var o=r-t;return o?mx(t,o):oc(isNaN(t)?r:t)}const ul=(function t(r){var o=vx(r);function l(a,u){var d=o((a=Bu(a)).r,(u=Bu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Op(a.opacity,u.opacity);return function(m){return a.r=d(m),a.g=f(m),a.b=g(m),a.opacity=y(m),a+""}}return l.gamma=t,l})(1);function xx(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,g.push({i:d,x:fn(l,a)})),o=bu.lastIndex;return o180?m+=360:m-y>180&&(y+=360),v.push({i:x.push(a(x)+"rotate(",null,l)-2,x:fn(y,m)})):m&&x.push(a(x)+"rotate("+m+l)}function f(y,m,x,v){y!==m?v.push({i:x.push(a(x)+"skewX(",null,l)-2,x:fn(y,m)}):m&&x.push(a(x)+"skewX("+m+l)}function g(y,m,x,v,_,k){if(y!==x||m!==v){var C=_.push(a(_)+"scale(",null,",",null,")");k.push({i:C-4,x:fn(y,x)},{i:C-2,x:fn(m,v)})}else(x!==1||v!==1)&&_.push(a(_)+"scale("+x+","+v+")")}return function(y,m){var x=[],v=[];return y=t(y),m=t(m),u(y.translateX,y.translateY,m.translateX,m.translateY,x,v),d(y.rotate,m.rotate,x,v),f(y.skewX,m.skewX,x,v),g(y.scaleX,y.scaleY,m.scaleX,m.scaleY,x,v),y=m=null,function(_){for(var k=-1,C=v.length,S;++k=0&&t._call.call(void 0,r),t=t._next;--xi}function dh(){Lr=(dl=_o.now())+wl,xi=ho=0;try{Lx()}finally{xi=0,zx(),Lr=0}}function Ax(){var t=_o.now(),r=t-dl;r>Vp&&(wl-=r,dl=t)}function zx(){for(var t,r=cl,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:cl=o);po=t,Wu(l)}function Wu(t){if(!xi){ho&&(ho=clearTimeout(ho));var r=t-Lr;r>24?(t<1/0&&(ho=setTimeout(dh,t-_o.now()-wl)),co&&(co=clearInterval(co))):(co||(dl=_o.now(),co=setInterval(Ax,Vp)),xi=1,Up(dh))}}function fh(t,r,o){var l=new fl;return r=r==null?0:+r,l.restart(a=>{l.stop(),t(a+r)},r,o),l}var Dx=vl("start","end","cancel","interrupt"),$x=[],Yp=0,hh=1,Yu=2,rl=3,ph=4,Xu=5,il=6;function _l(t,r,o,l,a,u){var d=t.__transition;if(!d)t.__transition={};else if(o in d)return;Ox(t,o,{name:r,index:l,group:a,on:Dx,tween:$x,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yp})}function lc(t,r){var o=nn(t,r);if(o.state>Yp)throw new Error("too late; already scheduled");return o}function pn(t,r){var o=nn(t,r);if(o.state>rl)throw new Error("too late; already running");return o}function nn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Ox(t,r,o){var l=t.__transition,a;l[r]=o,o.timer=Wp(u,0,o.time);function u(y){o.state=hh,o.timer.restart(d,o.delay,o.time),o.delay<=y&&d(y-o.delay)}function d(y){var m,x,v,_;if(o.state!==hh)return g();for(m in l)if(_=l[m],_.name===o.name){if(_.state===rl)return fh(d);_.state===ph?(_.state=il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete l[m]):+mYu&&l.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function gw(t,r,o){var l,a,u=pw(r)?lc:pn;return function(){var d=u(this,t),f=d.on;f!==l&&(a=(l=f).copy()).on(r,o),d.on=a}}function mw(t,r){var o=this._id;return arguments.length<2?nn(this.node(),o).on.on(t):this.each(gw(o,t,r))}function yw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function vw(){return this.on("end.remove",yw(this._id))}function xw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=nc(t));for(var l=this._groups,a=l.length,u=new Array(a),d=0;d()=>t;function Uw(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 jn(t,r,o){this.k=t,this.x=r,this.y=o}jn.prototype={constructor:jn,scale:function(t){return t===1?this:new jn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new jn(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 Sl=new jn(1,0,0);qp.prototype=jn.prototype;function qp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Sl;return t.__zoom}function Mu(t){t.stopImmediatePropagation()}function fo(t){t.preventDefault(),t.stopImmediatePropagation()}function Ww(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Yw(){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 gh(){return this.__zoom||Sl}function Xw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Gw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(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 Kp(){var t=Ww,r=Yw,o=Qw,l=Xw,a=Gw,u=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],f=250,g=nl,y=vl("start","zoom","end"),m,x,v,_=500,k=150,C=0,S=10;function E(b){b.property("__zoom",gh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",W).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(b,Y,V,U){var D=b.selection?b.selection():b;D.property("__zoom",gh),b!==D?R(b,Y,V,U):D.interrupt().each(function(){T(this,arguments).event(U).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},E.scaleBy=function(b,Y,V,U){E.scaleTo(b,function(){var D=this.__zoom.k,z=typeof Y=="function"?Y.apply(this,arguments):Y;return D*z},V,U)},E.scaleTo=function(b,Y,V,U){E.transform(b,function(){var D=r.apply(this,arguments),z=this.__zoom,B=V==null?j(D):typeof V=="function"?V.apply(this,arguments):V,M=z.invert(B),L=typeof Y=="function"?Y.apply(this,arguments):Y;return o(N(I(z,L),B,M),D,d)},V,U)},E.translateBy=function(b,Y,V,U){E.transform(b,function(){return o(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),d)},null,U)},E.translateTo=function(b,Y,V,U,D){E.transform(b,function(){var z=r.apply(this,arguments),B=this.__zoom,M=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Sl.translate(M[0],M[1]).scale(B.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof V=="function"?-V.apply(this,arguments):-V),z,d)},U,D)};function I(b,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===b.k?b:new jn(Y,b.x,b.y)}function N(b,Y,V){var U=Y[0]-V[0]*b.k,D=Y[1]-V[1]*b.k;return U===b.x&&D===b.y?b:new jn(b.k,U,D)}function j(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function R(b,Y,V,U){b.on("start.zoom",function(){T(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,B=T(D,z).event(U),M=r.apply(D,z),L=V==null?j(M):typeof V=="function"?V.apply(D,z):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=D.__zoom,ce=typeof Y=="function"?Y.apply(D,z):Y,fe=g(re.invert(L).concat(ne/re.k),ce.invert(L).concat(ne/ce.k));return function(de){if(de===1)de=ce;else{var q=fe(de),se=ne/q[2];de=new jn(se,L[0]-q[0]*se,L[1]-q[1]*se)}B.zoom(null,de)}})}function T(b,Y,V){return!V&&b.__zooming||new H(b,Y)}function H(b,Y){this.that=b,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=r.apply(b,Y),this.taps=0}H.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,Y){return this.mouse&&b!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var Y=At(this.that).datum();y.call(b,this.that,new Uw(b,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),Y)}};function G(b,...Y){if(!t.apply(this,arguments))return;var V=T(this,Y).event(b),U=this.__zoom,D=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,l.apply(this,arguments)))),z=Kt(b);if(V.wheel)(V.mouse[0][0]!==z[0]||V.mouse[0][1]!==z[1])&&(V.mouse[1]=U.invert(V.mouse[0]=z)),clearTimeout(V.wheel);else{if(U.k===D)return;V.mouse=[z,U.invert(z)],ol(this),V.start()}fo(b),V.wheel=setTimeout(B,k),V.zoom("mouse",o(N(I(U,D),V.mouse[0],V.mouse[1]),V.extent,d));function B(){V.wheel=null,V.end()}}function K(b,...Y){if(v||!t.apply(this,arguments))return;var V=b.currentTarget,U=T(this,Y,!0).event(b),D=At(b.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",ne,!0),z=Kt(b,V),B=b.clientX,M=b.clientY;Lp(b.view),Mu(b),U.mouse=[z,this.__zoom.invert(z)],ol(this),U.start();function L(re){if(fo(re),!U.moved){var ce=re.clientX-B,fe=re.clientY-M;U.moved=ce*ce+fe*fe>C}U.event(re).zoom("mouse",o(N(U.that.__zoom,U.mouse[0]=Kt(re,V),U.mouse[1]),U.extent,d))}function ne(re){D.on("mousemove.zoom mouseup.zoom",null),Ap(re.view,U.moved),fo(re),U.event(re).end()}}function te(b,...Y){if(t.apply(this,arguments)){var V=this.__zoom,U=Kt(b.changedTouches?b.changedTouches[0]:b,this),D=V.invert(U),z=V.k*(b.shiftKey?.5:2),B=o(N(I(V,z),U,D),r.apply(this,Y),d);fo(b),f>0?At(this).transition().duration(f).call(R,B,U,b):At(this).call(E.transform,B,U,b)}}function W(b,...Y){if(t.apply(this,arguments)){var V=b.touches,U=V.length,D=T(this,Y,b.changedTouches.length===U).event(b),z,B,M,L;for(Mu(b),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.`},So=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Zp=["Enter"," ","Escape"],Jp={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:r,y: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 wi;(function(t){t.Strict="strict",t.Loose="loose"})(wi||(wi={}));var Tr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Tr||(Tr={}));var ko;(function(t){t.Partial="partial",t.Full="full"})(ko||(ko={}));const eg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var nr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(nr||(nr={}));var Eo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Eo||(Eo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const mh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function tg(t){return t===null?null:t?"valid":"invalid"}const ng=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,qw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),uc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Io=(t,r=[0,0])=>{const{width:o,height:l}=rn(t),a=t.origin??r,u=o*a[0],d=l*a[1];return{x:t.position.x-u,y:t.position.y-d}},Kw=(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):uc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,kl(a,hl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?El(l):{x:0,y:0,width:0,height:0}},To=(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=kl(o,hl(a)),l=!0)}),l?El(o):{x:0,y:0,width:0,height:0}},cc=(t,r,[o,l,a]=[0,0,1],u=!1,d=!1)=>{const f=(r.x-o)/a,g=(r.y-l)/a,y=r.width/a,m=r.height/a,x=[];for(const v of t.values()){const{measured:_,selectable:k=!0,hidden:C=!1}=v;if(d&&!k||C)continue;const S=_.width??v.width??v.initialWidth??0,E=_.height??v.height??v.initialHeight??0,{x:I,y:N}=v.internals.positionAbsolute,j=sg(f,g,y,m,I,N,S,E),R=S*E,T=u&&j>0;(!v.internals.handleBounds||T||j>=R||v.dragging)&&x.push(v)}return x},Zw=(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 Jw(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}=rn(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 e1({nodes:t,width:r,height:o,panZoom:l,minZoom:a,maxZoom:u},d){if(t.size===0)return!0;const f=Jw(t,d),g=To(f),y=fc(g,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(y,{duration:d==null?void 0:d.duration,ease:d==null?void 0:d.ease,interpolate:d==null?void 0:d.interpolate}),!0}function rg({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:g,y}=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",tn.error005());else{const{width:_,height:k}=rn(f);_&&k&&(x=[[g,y],[g+_,y+k]])}else f&&zr(d.extent)&&(x=[[d.extent[0][0]+g,d.extent[0][1]+y],[d.extent[1][0]+g,d.extent[1][1]+y]]);const v=zr(x)?Ar(r,x,d.measured):r;return(d.measured.width===void 0||d.measured.height===void 0)&&(u==null||u("015",tn.error015())),{position:{x:v.x-g+(d.measured.width??0)*m[0],y:v.y-y+(d.measured.height??0)*m[1]},positionAbsolute:v}}async function t1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:l,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),d=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),k=!_&&v.parentId&&d.find(C=>C.id===v.parentId);(_||k)&&d.push(v)}const f=new Set(r.map(v=>v.id)),g=l.filter(v=>v.deletable!==!1),m=Zw(d,g);for(const v of g)f.has(v.id)&&!m.find(k=>k.id===v.id)&&m.push(v);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 _i=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Ar=(t={x:0,y:0},r,o)=>({x:_i(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:_i(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ig(t,r,o){const{width:l,height:a}=rn(o),{x:u,y:d}=o.internals.positionAbsolute;return Ar(t,[[u,d],[u+l,d+a]],r)}const yh=(t,r,o)=>to?-_i(Math.abs(t-o),1,r)/r:0,dc=(t,r,o=15,l=40)=>{const a=yh(t.x,l,r.width-l)*o,u=yh(t.y,l,r.height-l)*o;return[a,u]},kl=(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)}),Gu=({x:t,y:r,width:o,height:l})=>({x:t,y:r,x2:t+o,y2:r+l}),El=({x:t,y:r,x2:o,y2:l})=>({x:t,y:r,width:o-t,height:l-r}),No=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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}},hl=(t,r=[0,0])=>{var a,u;const{x:o,y:l}=uc(t)?t.internals.positionAbsolute:Io(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)}},og=(t,r)=>El(kl(Gu(t),Gu(r))),sg=(t,r,o,l,a,u,d,f)=>{const g=Math.max(0,Math.min(t+o,a+d)-Math.max(t,a)),y=Math.max(0,Math.min(r+l,u+f)-Math.max(r,u));return Math.ceil(g*y)},pl=(t,r)=>sg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),vh=t=>Jt(t.width)&&Jt(t.height)&&Jt(t.x)&&Jt(t.y),Jt=t=>!isNaN(t)&&isFinite(t),lg=(t,r)=>(o,l)=>{},Ro=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Lo=({x:t,y:r},[o,l,a],u=!1,d=[1,1])=>{const f={x:(t-o)/a,y:(r-l)/a};return u?Ro(f,d):f},Si=({x:t,y:r},[o,l,a])=>({x:t*a+o,y:r*a+l});function pi(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 n1(t,r,o){if(typeof t=="string"||typeof t=="number"){const l=pi(t,o),a=pi(t,r);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof t=="object"){const l=pi(t.top??t.y??0,o),a=pi(t.bottom??t.y??0,o),u=pi(t.left??t.x??0,r),d=pi(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 r1(t,r,o,l,a,u){const{x:d,y:f}=Si(t,[r,o,l]),{x:g,y}=Si({x:t.x+t.width,y:t.y+t.height},[r,o,l]),m=a-g,x=u-y;return{left:Math.floor(d),top:Math.floor(f),right:Math.floor(m),bottom:Math.floor(x)}}const fc=(t,r,o,l,a,u)=>{const d=n1(u,r,o),f=(r-d.x)/t.width,g=(o-d.y)/t.height,y=Math.min(f,g),m=_i(y,l,a),x=t.x+t.width/2,v=t.y+t.height/2,_=r/2-x*m,k=o/2-v*m,C=r1(t,_,k,m,r,o),S={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.left+S.right,y:k-S.top+S.bottom,zoom:m}},Co=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function zr(t){return t!=null&&t!=="parent"}function rn(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 ag(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 ug(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 xh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function i1(){let t,r;return{promise:new Promise((l,a)=>{t=l,r=a}),resolve:t,reject:r}}function o1(t){return{...Jp,...t||{}}}function mo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:l,containerBounds:a}){const{x:u,y:d}=en(t),f=Lo({x:u-((a==null?void 0:a.left)??0),y:d-((a==null?void 0:a.top)??0)},l),{x:g,y}=o?Ro(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const hc=t=>({width:t.offsetWidth,height:t.offsetHeight}),cg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},s1=["INPUT","SELECT","TEXTAREA"];function dg(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:s1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const fg=t=>"clientX"in t,en=(t,r)=>{var u,d;const o=fg(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)}},wh=(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,...hc(d)}})};function hg({sourceX:t,sourceY:r,targetX:o,targetY:l,sourceControlX:a,sourceControlY:u,targetControlX:d,targetControlY:f}){const g=t*.125+a*.375+d*.375+o*.125,y=r*.125+u*.375+f*.375+l*.125,m=Math.abs(g-t),x=Math.abs(y-r);return[g,y,m,x]}function qs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function _h({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 pg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top,curvature:d=.25}){const[f,g]=_h({pos:o,x1:t,y1:r,x2:l,y2:a,c:d}),[y,m]=_h({pos:u,x1:l,y1:a,x2:t,y2:r,c:d}),[x,v,_,k]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:m});return[`M${t},${r} C${f},${g} ${y},${m} ${l},${a}`,x,v,_,k]}function gg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const a=Math.abs(o-t)/2,u=o0}const u1=({source:t,sourceHandle:r,target:o,targetHandle:l})=>`xy-edge__${t}${r||""}-${o}${l||""}`,c1=(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)),d1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",tn.error006()),r;const l=o.getEdgeId||u1;let a;return ng(t)?a={...t}:a={...t,id:l(t)},c1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function mg({sourceX:t,sourceY:r,targetX:o,targetY:l}){const[a,u,d,f]=gg({sourceX:t,sourceY:r,targetX:o,targetY:l});return[`M ${t},${r}L ${o},${l}`,a,u,d,f]}const Sh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},f1=({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 h1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:l=Se.Top,center:a,offset:u,stepPosition:d}){const f=Sh[r],g=Sh[l],y={x:t.x+f.x*u,y:t.y+f.y*u},m={x:o.x+g.x*u,y:o.y+g.y*u},x=f1({source:y,sourcePosition:r,target:m}),v=x.x!==0?"x":"y",_=x[v];let k=[],C,S;const E={x:0,y:0},I={x:0,y:0},[,,N,j]=gg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[v]*g[v]===-1){v==="x"?(C=a.x??y.x+(m.x-y.x)*d,S=a.y??(y.y+m.y)/2):(C=a.x??(y.x+m.x)/2,S=a.y??y.y+(m.y-y.y)*d);const G=[{x:C,y:y.y},{x:C,y:m.y}],K=[{x:y.x,y:S},{x:m.x,y:S}];f[v]===_?k=v==="x"?G:K:k=v==="x"?K:G}else{const G=[{x:y.x,y:m.y}],K=[{x:m.x,y:y.y}];if(v==="x"?k=f.x===_?K:G:k=f.y===_?G:K,r===l){const b=Math.abs(t[v]-o[v]);if(b<=u){const Y=Math.min(u-1,u-b);f[v]===_?E[v]=(y[v]>t[v]?-1:1)*Y:I[v]=(m[v]>o[v]?-1:1)*Y}}if(r!==l){const b=v==="x"?"y":"x",Y=f[v]===g[b],V=y[b]>m[b],U=y[b]=J?(C=(te.x+W.x)/2,S=k[0].y):(C=k[0].x,S=(te.y+W.y)/2)}const R={x:y.x+E.x,y:y.y+E.y},T={x:m.x+I.x,y:m.y+I.y};return[[t,...R.x!==k[0].x||R.y!==k[0].y?[R]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],o],C,S,N,j]}function p1(t,r,o,l){const a=Math.min(kh(t,r)/2,kh(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 y=t.xo.id===r):t[0])||null}function qu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function m1(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(g=>{if(g&&typeof g=="object"){const y=qu(g,r);u.has(y)||(d.push({id:y,color:g.color||o,...g}),u.add(y))}}),d),[]).sort((d,f)=>d.id.localeCompare(f.id))}const yg=1e3,y1=10,pc={nodeOrigin:[0,0],nodeExtent:So,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},v1={...pc,checkEquality:!0};function gc(t,r){const o={...t};for(const l in r)r[l]!==void 0&&(o[l]=r[l]);return o}function x1(t,r,o){const l=gc(pc,o);for(const a of t.values())if(a.parentId)yc(a,t,r,l);else{const u=Io(a,l.nodeOrigin),d=zr(a.extent)?a.extent:l.nodeExtent,f=Ar(u,d,rn(a));a.internals.positionAbsolute=f}}function w1(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 mc(t){return t==="manual"}function Ku(t,r,o,l={}){var m,x;const a=gc(v1,l),u={i:0},d=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!mc(a.zIndexMode)?yg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const v of t){let _=d.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const k=Io(v,a.nodeOrigin),C=zr(v.extent)?v.extent:a.nodeExtent,S=Ar(k,C,rn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(x=v.measured)==null?void 0:x.height},internals:{positionAbsolute:S,handleBounds:w1(v,_),z:vg(v,f,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(g=!1),v.parentId&&yc(_,r,o,l,u),y||(y=v.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function _1(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 yc(t,r,o,l,a){const{elevateNodesOnSelect:u,nodeOrigin:d,nodeExtent:f,zIndexMode:g}=gc(pc,l),y=t.parentId,m=r.get(y);if(!m){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&g==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*y1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const x=u&&!mc(g)?yg:0,{x:v,y:_,z:k}=S1(t,m,d,f,x,g),{positionAbsolute:C}=t.internals,S=v!==C.x||_!==C.y;(S||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:S?{x:v,y:_}:C,z:k}})}function vg(t,r,o){const l=Jt(t.zIndex)?t.zIndex:0;return mc(o)?l:l+(t.selected?r:0)}function S1(t,r,o,l,a,u){const{x:d,y:f}=r.internals.positionAbsolute,g=rn(t),y=Io(t,o),m=zr(t.extent)?Ar(y,t.extent,g):y;let x=Ar({x:d+m.x,y:f+m.y},l,g);t.extent==="parent"&&(x=ig(x,g,r));const v=vg(t,a,u),_=r.internals.z??0;return{x:x.x,y:x.y,z:_>=v?_+1:v}}function vc(t,r,o,l=[0,0]){var d;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((d=u.get(f.parentId))==null?void 0:d.expandedRect)??No(g),m=og(y,f.rect);u.set(f.parentId,{expandedRect:m,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var N;const m=g.internals.positionAbsolute,x=rn(g),v=g.origin??l,_=f.x0||k>0||E||I)&&(a.push({id:y,type:"position",position:{x:g.position.x-_+E,y:g.position.y-k+I}}),(N=o.get(y))==null||N.forEach(j=>{t.some(R=>R.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(x.width0){const _=vc(v,r,o,a);y.push(..._)}return{changes:y,updatedInternals:g}}async function E1({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 jh(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 g=l.get(d)||new Map;if(l.set(d,g.set(o,r)),u){d=`${a}-${t}-${u}`;const y=l.get(d)||new Map;l.set(d,y.set(o,r))}}function xg(t,r,o){t.clear(),r.clear();for(const l of o){const{source:a,target:u,sourceHandle:d=null,targetHandle:f=null}=l,g={edgeId:l.id,source:a,target:u,sourceHandle:d,targetHandle:f},y=`${a}-${d}--${u}-${f}`,m=`${u}-${f}--${a}-${d}`;jh("source",g,m,t,a,d),jh("target",g,y,t,u,f),r.set(l.id,l)}}function wg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:wg(o,r):!1}function bh(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 N1(t,r,o,l){const a=new Map;for(const[u,d]of t)if((d.selected||d.id===l)&&(!d.parentId||!wg(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 Pu({nodeId:t,dragItems:r,nodeLookup:o,dragging:l=!0}){var d,f,g;const a=[];for(const[y,m]of r){const x=(d=o.get(y))==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:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:l}:a[0],a]}function C1({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=Ro(u,r);return{x:d.x-u.x,y:d.y-u.y}}function j1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:l,onDragStop:a}){let u={x:null,y:null},d=0,f=new Map,g=!1,y={x:0,y:0},m=null,x=!1,v=null,_=!1,k=!1,C=null;function S({noDragClassName:I,handleSelector:N,domNode:j,isSelectable:R,nodeId:T,nodeClickDistance:H=0}){v=At(j);function G({x:ee,y:J}){const{nodeLookup:b,nodeExtent:Y,snapGrid:V,snapToGrid:U,nodeOrigin:D,onNodeDrag:z,onSelectionDrag:B,onError:M,updateNodePositions:L}=r();u={x:ee,y:J};let ne=!1;const re=f.size>1,ce=re&&Y?Gu(To(f)):null,fe=re&&U?C1({dragItems:f,snapGrid:V,x:ee,y:J}):null;for(const[de,q]of f){if(!b.has(de))continue;let se={x:ee-q.distance.x,y:J-q.distance.y};U&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:Ro(se,V));let pe=null;if(re&&Y&&!q.extent&&ce){const{positionAbsolute:ye}=q.internals,Ne=ye.x-ce.x+Y[0][0],Pe=ye.x+q.measured.width-ce.x2+Y[1][0],je=ye.y-ce.y+Y[0][1],Me=ye.y+q.measured.height-ce.y2+Y[1][1];pe=[[Ne,je],[Pe,Me]]}const{position:_e,positionAbsolute:me}=rg({nodeId:de,nextPosition:se,nodeLookup:b,nodeExtent:pe||Y,nodeOrigin:D,onError:M});ne=ne||q.position.x!==_e.x||q.position.y!==_e.y,q.position=_e,q.internals.positionAbsolute=me}if(k=k||ne,!!ne&&(L(f,!0),C&&(l||z||!T&&B))){const[de,q]=Pu({nodeId:T,dragItems:f,nodeLookup:b});l==null||l(C,f,de,q),z==null||z(C,de,q),T||B==null||B(C,q)}}async function K(){if(!m)return;const{transform:ee,panBy:J,autoPanSpeed:b,autoPanOnNodeDrag:Y}=r();if(!Y){g=!1,cancelAnimationFrame(d);return}const[V,U]=dc(y,m,b);(V!==0||U!==0)&&(u.x=(u.x??0)-V/ee[2],u.y=(u.y??0)-U/ee[2],await J({x:V,y:U})&&G(u)),d=requestAnimationFrame(K)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:b,nodesDraggable:Y,transform:V,snapGrid:U,snapToGrid:D,selectNodesOnDrag:z,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:L}=r();x=!0,(!z||!R)&&!b&&T&&((re=J.get(T))!=null&&re.selected||L()),R&&z&&T&&(t==null||t(T));const ne=mo(ee.sourceEvent,{transform:V,snapGrid:U,snapToGrid:D,containerBounds:m});if(u=ne,f=N1(J,Y,ne,T),f.size>0&&(o||B||!T&&M)){const[ce,fe]=Pu({nodeId:T,dragItems:f,nodeLookup:J});o==null||o(ee.sourceEvent,f,ce,fe),B==null||B(ee.sourceEvent,ce,fe),T||M==null||M(ee.sourceEvent,fe)}}const W=zp().clickDistance(H).on("start",ee=>{const{domNode:J,nodeDragThreshold:b,transform:Y,snapGrid:V,snapToGrid:U}=r();m=(J==null?void 0:J.getBoundingClientRect())||null,_=!1,k=!1,C=ee.sourceEvent,b===0&&te(ee),u=mo(ee.sourceEvent,{transform:Y,snapGrid:V,snapToGrid:U,containerBounds:m}),y=en(ee.sourceEvent,m)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:b,snapGrid:Y,snapToGrid:V,nodeDragThreshold:U,nodeLookup:D}=r(),z=mo(ee.sourceEvent,{transform:b,snapGrid:Y,snapToGrid:V,containerBounds:m});if(C=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||T&&!D.has(T))&&(_=!0),!_){if(!g&&J&&x&&(g=!0,K()),!x){const B=en(ee.sourceEvent,m),M=B.x-y.x,L=B.y-y.y;Math.sqrt(M*M+L*L)>U&&te(ee)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&f&&x&&(y=en(ee.sourceEvent,m),G(z))}}).on("end",ee=>{if(!x||_){_&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(d),f.size>0){const{nodeLookup:J,updateNodePositions:b,onNodeDragStop:Y,onSelectionDragStop:V}=r();if(k&&(b(f,!1),k=!1),a||Y||!T&&V){const[U,D]=Pu({nodeId:T,dragItems:f,nodeLookup:J,dragging:!1});a==null||a(ee.sourceEvent,f,U,D),Y==null||Y(ee.sourceEvent,U,D),T||V==null||V(ee.sourceEvent,D)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!I||!bh(J,`.${I}`,j))&&(!N||bh(J,N,j))});v.call(W)}function E(){v==null||v.on(".drag",null)}return{update:S,destroy:E}}function b1(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())pl(a,No(u))>0&&l.push(u);return l}const M1=250;function P1(t,r,o,l){var f,g;let a=[],u=1/0;const d=b1(t,o,r+M1);for(const y of d){const m=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of m){if(l.nodeId===x.nodeId&&l.type===x.type&&l.id===x.id)continue;const{x:v,y:_}=Dr(y,x,x.position,!0),k=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=l.type==="source"?"target":"source";return a.find(m=>m.type===y)??a[0]}return a[0]}function _g(t,r,o,l,a,u=!1){var y,m,x;const d=l.get(t);if(!d)return null;const f=a==="strict"?(y=d.internals.handleBounds)==null?void 0:y[r]:[...((m=d.internals.handleBounds)==null?void 0:m.source)??[],...((x=d.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(v=>v.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...Dr(d,g,g.position,!0)}:g}function Sg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function I1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const kg=()=>!0;function T1(t,{connectionMode:r,connectionRadius:o,handleId:l,nodeId:a,edgeUpdaterType:u,isTarget:d,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:m,flowId:x,panBy:v,cancelConnection:_,onConnectStart:k,onConnect:C,onConnectEnd:S,isValidConnection:E=kg,onReconnectEnd:I,updateConnection:N,getTransform:j,getFromHandle:R,autoPanSpeed:T,dragThreshold:H=1,handleDomNode:G}){const K=cg(t.target);let te=0,W;const{x:ee,y:J}=en(t),b=Sg(u,G),Y=f==null?void 0:f.getBoundingClientRect();let V=!1;if(!Y||!b)return;const U=_g(a,b,l,g,r);if(!U)return;let D=en(t,Y),z=!1,B=null,M=!1,L=null;function ne(){if(!m||!Y)return;const[_e,me]=dc(D,Y,T);v({x:_e,y:me}),te=requestAnimationFrame(ne)}const re={...U,nodeId:a,type:b,position:U.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:Dr(ce,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ce,to:D,toHandle:null,toPosition:mh[re.position],toNode:null,pointer:D};function q(){V=!0,N(de),k==null||k(t,{nodeId:a,handleId:l,handleType:b})}H===0&&q();function se(_e){if(!V){const{x:Me,y:tt}=en(_e),Ge=Me-ee,nt=tt-J;if(!(Ge*Ge+nt*nt>H*H))return;q()}if(!R()||!re){pe(_e);return}const me=j();D=en(_e,Y),W=P1(Lo(D,me,!1,[1,1]),o,g,re),z||(ne(),z=!0);const ye=Eg(_e,{handle:W,connectionMode:r,fromNodeId:a,fromHandleId:l,fromType:d?"target":"source",isValidConnection:E,doc:K,lib:y,flowId:x,nodeLookup:g});L=ye.handleDomNode,B=ye.connection,M=I1(!!W,ye.isValid);const Ne=g.get(a),Pe=Ne?Dr(Ne,re,Se.Left,!0):de.from,je={...de,from:Pe,isValid:M,to:ye.toHandle&&M?Si({x:ye.toHandle.x,y:ye.toHandle.y},me):D,toHandle:ye.toHandle,toPosition:M&&ye.toHandle?ye.toHandle.position:mh[re.position],toNode:ye.toHandle?g.get(ye.toHandle.nodeId):null,pointer:D};N(je),de=je}function pe(_e){if(!("touches"in _e&&_e.touches.length>0)){if(V){(W||L)&&B&&M&&(C==null||C(B));const{inProgress:me,...ye}=de,Ne={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(_e,Ne),u&&(I==null||I(_e,Ne))}_(),cancelAnimationFrame(te),z=!1,M=!1,B=null,L=null,K.removeEventListener("mousemove",se),K.removeEventListener("mouseup",pe),K.removeEventListener("touchmove",se),K.removeEventListener("touchend",pe)}}K.addEventListener("mousemove",se),K.addEventListener("mouseup",pe),K.addEventListener("touchmove",se),K.addEventListener("touchend",pe)}function Eg(t,{handle:r,connectionMode:o,fromNodeId:l,fromHandleId:a,fromType:u,doc:d,lib:f,flowId:g,isValidConnection:y=kg,nodeLookup:m}){const x=u==="target",v=r?d.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=en(t),C=d.elementFromPoint(_,k),S=C!=null&&C.classList.contains(`${f}-flow__handle`)?C:v,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const I=Sg(void 0,S),N=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),R=S.classList.contains("connectable"),T=S.classList.contains("connectableend");if(!N||!I)return E;const H={source:x?N:l,sourceHandle:x?j:a,target:x?l:N,targetHandle:x?a:j};E.connection=H;const K=R&&T&&(o===wi.Strict?x&&I==="source"||!x&&I==="target":N!==l||j!==a);E.isValid=K&&y(H),E.toHandle=_g(N,I,j,m,o,!0)}return E}const Zu={onPointerDown:T1,isValid:Eg};function R1({domNode:t,panZoom:r,getTransform:o,getViewScale:l}){const a=At(t);function u({translateExtent:f,width:g,height:y,zoomStep:m=1,pannable:x=!0,zoomable:v=!0,inversePan:_=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const j=o(),R=N.sourceEvent.ctrlKey&&Co()?10:1,T=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*m,H=j[2]*Math.pow(2,T*R);r.scaleTo(H)};let C=[0,0];const S=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 j=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const R=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],T=[R[0]-C[0],R[1]-C[1]];C=R;const H=l()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-T[0]*H,y:j[1]-T[1]*H},K=[[0,0],[g,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},K,f)},I=Kp().on("start",S).on("zoom",x?E:null).on("zoom.wheel",v?k:null);a.call(I,{})}function d(){a.on("zoom",null)}return{update:u,destroy:d,pointer:Kt}}const Nl=t=>({x:t.x,y:t.y,zoom:t.k}),Iu=({x:t,y:r,zoom:o})=>Sl.translate(t,r).scale(o),tr=(t,r)=>t.target.closest(`.${r}`),Ng=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),L1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Tu=(t,r=0,o=L1,l=()=>{})=>{const a=typeof r=="number"&&r>0;return a||l(),a?t.transition().duration(r).ease(o).on("end",l):t},Cg=t=>{const r=t.ctrlKey&&Co()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function A1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:d,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return m=>{if(tr(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(m.ctrlKey&&d){const S=Kt(m),E=Cg(m),I=x*Math.pow(2,E);l.scaleTo(o,I,S,m);return}const v=m.deltaMode===1?20:1;let _=a===Tr.Vertical?0:m.deltaX*v,k=a===Tr.Horizontal?0:m.deltaY*v;!Co()&&m.shiftKey&&a!==Tr.Vertical&&(_=m.deltaY*v,k=0),l.translateBy(o,-(_/x)*u,-(k/x)*u,{internal:!0});const C=Nl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(m,C):(t.isPanScrolling=!0,f==null||f(m,C)),t.panScrollTimeout=setTimeout(()=>{y==null||y(m,C),t.isPanScrolling=!1},150)}}function z1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(l,a){const u=l.type==="wheel",d=!r&&u&&!l.ctrlKey,f=tr(l,t);if(l.ctrlKey&&u&&f&&l.preventDefault(),d||f)return null;l.preventDefault(),o.call(this,l,a)}}function D1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return l=>{var u,d,f;if((u=l.sourceEvent)!=null&&u.internal)return;const a=Nl(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 $1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:l,onPanZoom:a}){return u=>{var d,f;t.usedRightMouseButton=!!(o&&Ng(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,Nl(u.transform)))}}function O1({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&&Ng(r,t.mouseButton??0)&&!t.usedRightMouseButton&&d.sourceEvent&&u(d.sourceEvent),t.usedRightMouseButton=!1,l(!1),a)){const g=Nl(d.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(d.sourceEvent,g)},o?150:0)}}}function F1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:l,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:d,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:m,connectionInProgress:x}){return v=>{var E;const _=r||o,k=l&&v.ctrlKey,C=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(tr(v,`${m}-flow__node`)||tr(v,`${m}-flow__edge`)||tr(v,`${m}-flow__selection`)||tr(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!d&&!l||f||x&&!C||tr(v,g)&&C||tr(v,y)&&(!C||u&&C&&!r)||!l&&v.ctrlKey&&C)return!1;if(!l&&v.type==="touchstart"&&((E=v.touches)==null?void 0:E.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!k&&C||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const S=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||C||t)&&S}}function H1({domNode:t,minZoom:r,maxZoom:o,translateExtent:l,viewport:a,onPanZoom:u,onPanZoomStart:d,onPanZoomEnd:f,onDraggingChange:g}){const y={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 v=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const b=J[0];b&&(x=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null;v==null||v.observe(t);const _=Kp().extent(()=>x).scaleExtent([r,o]).translateExtent(l),k=At(t).call(_);j({x:a.x,y:a.y,zoom:_i(a.zoom,r,o)},[[0,0],[m.width,m.height]],l);const C=k.on("wheel.zoom"),S=k.on("dblclick.zoom");_.wheelDelta(Cg);async function E(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).transform(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function I({noWheelClassName:J,noPanClassName:b,onPaneContextMenu:Y,userSelectionActive:V,panOnScroll:U,panOnDrag:D,panOnScrollMode:z,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:q,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:_e}){V&&!y.isZoomingOrPanning&&N();const me=U&&!fe&&!V;_.clickDistance(_e?1/0:!Jt(pe)||pe<0?0:pe);const ye=me?A1({zoomPanValues:y,noWheelClassName:J,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:B,zoomOnPinch:L,onPanZoomStart:d,onPanZoom:u,onPanZoomEnd:f}):z1({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:C});k.on("wheel.zoom",ye,{passive:!1});const Ne=D1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:d});_.on("start",Ne);const Pe=$1({zoomPanValues:y,panOnDrag:D,onPaneContextMenu:!!Y,onPanZoom:u,onTransformChange:q});_.on("zoom",Pe);const je=O1({zoomPanValues:y,panOnDrag:D,panOnScroll:U,onPaneContextMenu:Y,onPanZoomEnd:f,onDraggingChange:g});_.on("end",je);const Me=F1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:D,zoomOnScroll:ne,panOnScroll:U,zoomOnDoubleClick:re,zoomOnPinch:L,userSelectionActive:V,noPanClassName:b,noWheelClassName:J,lib:de,connectionInProgress:se});_.filter(Me),re?k.on("dblclick.zoom",S):k.on("dblclick.zoom",null)}function N(){_.on("zoom",null)}async function j(J,b,Y){const V=Iu(J),U=_==null?void 0:_.constrain()(V,b,Y);return U&&await E(U),U}async function R(J,b){const Y=Iu(J);return await E(Y,b),Y}function T(J){if(k){const b=Iu(J),Y=k.property("__zoom");(Y.k!==J.zoom||Y.x!==J.x||Y.y!==J.y)&&(_==null||_.transform(k,b,null,{sync:!0}))}}function H(){const J=k?qp(k.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function G(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleTo(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}async function K(J,b){return k?new Promise(Y=>{_==null||_.interpolate((b==null?void 0:b.interpolate)==="linear"?go:nl).scaleBy(Tu(k,b==null?void 0:b.duration,b==null?void 0:b.ease,()=>Y(!0)),J)}):!1}function te(J){_==null||_.scaleExtent(J)}function W(J){_==null||_.translateExtent(J)}function ee(J){const b=!Jt(J)||J<0?0:J;_==null||_.clickDistance(b)}return{update:I,destroy:N,setViewport:R,setViewportConstrained:j,getViewport:H,scaleTo:G,scaleBy:K,setScaleExtent:te,setTranslateExtent:W,syncViewport:T,setClickDistance:ee}}var ki;(function(t){t.Line="line",t.Handle="handle"})(ki||(ki={}));function B1({width:t,prevWidth:r,height:o,prevHeight:l,affectsX:a,affectsY:u}){const d=t-r,f=o-l,g=[d>0?1:d<0?-1:0,f>0?1:f<0?-1:0];return d&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Mh(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 Jn(t,r){return Math.max(0,r-t)}function er(t,r){return Math.max(0,t-r)}function Ks(t,r,o){return Math.max(0,r-t,t-o)}function Ph(t,r){return t?!r:r}function V1(t,r,o,l,a,u,d,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:m,isVertical:x}=r,v=m&&x,{xSnapped:_,ySnapped:k}=o,{minWidth:C,maxWidth:S,minHeight:E,maxHeight:I}=l,{x:N,y:j,width:R,height:T,aspectRatio:H}=t;let G=Math.floor(m?_-t.pointerX:0),K=Math.floor(x?k-t.pointerY:0);const te=R+(g?-G:G),W=T+(y?-K:K),ee=-u[0]*R,J=-u[1]*T;let b=Ks(te,C,S),Y=Ks(W,E,I);if(d){let D=0,z=0;g&&G<0?D=Jn(N+G+ee,d[0][0]):!g&&G>0&&(D=er(N+te+ee,d[1][0])),y&&K<0?z=Jn(j+K+J,d[0][1]):!y&&K>0&&(z=er(j+W+J,d[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(f){let D=0,z=0;g&&G>0?D=er(N+G,f[0][0]):!g&&G<0&&(D=Jn(N+te,f[1][0])),y&&K>0?z=er(j+K,f[0][1]):!y&&K<0&&(z=Jn(j+W,f[1][1])),b=Math.max(b,D),Y=Math.max(Y,z)}if(a){if(m){const D=Ks(te/H,E,I)*H;if(b=Math.max(b,D),d){let z=0;!g&&!y||g&&!y&&v?z=er(j+J+te/H,d[1][1])*H:z=Jn(j+J+(g?G:-G)/H,d[0][1])*H,b=Math.max(b,z)}if(f){let z=0;!g&&!y||g&&!y&&v?z=Jn(j+te/H,f[1][1])*H:z=er(j+(g?G:-G)/H,f[0][1])*H,b=Math.max(b,z)}}if(x){const D=Ks(W*H,C,S)/H;if(Y=Math.max(Y,D),d){let z=0;!g&&!y||y&&!g&&v?z=er(N+W*H+ee,d[1][0])/H:z=Jn(N+(y?K:-K)*H+ee,d[0][0])/H,Y=Math.max(Y,z)}if(f){let z=0;!g&&!y||y&&!g&&v?z=Jn(N+W*H,f[1][0])/H:z=er(N+(y?K:-K)*H,f[0][0])/H,Y=Math.max(Y,z)}}}K=K+(K<0?Y:-Y),G=G+(G<0?b:-b),a&&(v?te>W*H?K=(Ph(g,y)?-G:G)/H:G=(Ph(g,y)?-K:K)*H:m?(K=G/H,y=g):(G=K*H,g=y));const V=g?N+G:N,U=y?j+K:j;return{width:R+(g?-G:G),height:T+(y?-K:K),x:u[0]*G*(g?-1:1)+V,y:u[1]*K*(y?-1:1)+U}}const jg={width:0,height:0,x:0,y:0},U1={...jg,pointerX:0,pointerY:0,aspectRatio:1};function W1(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,g=o[1]*d;return[[l-f,a-g],[l+u-f,a+d-g]]}function Y1({domNode:t,nodeId:r,getStoreItems:o,onChange:l,onEnd:a}){const u=At(t);let d={controlDirection:Mh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:m,keepAspectRatio:x,resizeDirection:v,onResizeStart:_,onResize:k,onResizeEnd:C,shouldResize:S}){let E={...jg},I={...U1};d={boundaries:m,resizeDirection:v,keepAspectRatio:x,controlDirection:Mh(y)};let N,j=null,R=[],T,H,G,K=!1;const te=zp().on("start",W=>{const{nodeLookup:ee,transform:J,snapGrid:b,snapToGrid:Y,nodeOrigin:V,paneDomNode:U}=o();if(N=ee.get(r),!N)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:z}=mo(W.sourceEvent,{transform:J,snapGrid:b,snapToGrid:Y,containerBounds:j});E={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},I={...E,pointerX:D,pointerY:z,aspectRatio:E.width/E.height},T=void 0,H=zr(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(T=ee.get(N.parentId)),T&&N.extent==="parent"&&(H=[[0,0],[T.measured.width,T.measured.height]]),R=[],G=void 0;for(const[B,M]of ee)if(M.parentId===r&&(R.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const L=W1(M,N,M.origin??V);G?G=[[Math.min(L[0][0],G[0][0]),Math.min(L[0][1],G[0][1])],[Math.max(L[1][0],G[1][0]),Math.max(L[1][1],G[1][1])]]:G=L}_==null||_(W,{...E})}).on("drag",W=>{const{transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y}=o(),V=mo(W.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:b,containerBounds:j}),U=[];if(!N)return;const{x:D,y:z,width:B,height:M}=E,L={},ne=N.origin??Y,{width:re,height:ce,x:fe,y:de}=V1(I,d.controlDirection,V,d.boundaries,d.keepAspectRatio,ne,H,G),q=re!==B,se=ce!==M,pe=fe!==D&&q,_e=de!==z&&se;if(!pe&&!_e&&!q&&!se)return;if((pe||_e||ne[0]===1||ne[1]===1)&&(L.x=pe?fe:E.x,L.y=_e?de:E.y,E.x=L.x,E.y=L.y,R.length>0)){const Pe=fe-D,je=de-z;for(const Me of R)Me.position={x:Me.position.x-Pe+ne[0]*(re-B),y:Me.position.y-je+ne[1]*(ce-M)},U.push(Me)}if((q||se)&&(L.width=q&&(!d.resizeDirection||d.resizeDirection==="horizontal")?re:E.width,L.height=se&&(!d.resizeDirection||d.resizeDirection==="vertical")?ce:E.height,E.width=L.width,E.height=L.height),T&&N.expandParent){const Pe=ne[0]*(L.width??0);L.x&&L.x{K&&(C==null||C(W,{...E}),a==null||a({...E}),K=!1)});u.call(te)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Ru={exports:{}},Lu={},Au={exports:{}},zu={};/** - * @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 Ih;function X1(){if(Ih)return zu;Ih=1;var t=bo();function r(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var o=typeof Object.is=="function"?Object.is:r,l=t.useState,a=t.useEffect,u=t.useLayoutEffect,d=t.useDebugValue;function f(x,v){var _=v(),k=l({inst:{value:_,getSnapshot:v}}),C=k[0].inst,S=k[1];return u(function(){C.value=_,C.getSnapshot=v,g(C)&&S({inst:C})},[x,_,v]),a(function(){return g(C)&&S({inst:C}),x(function(){g(C)&&S({inst:C})})},[x]),d(_),_}function g(x){var v=x.getSnapshot;x=x.value;try{var _=v();return!o(x,_)}catch{return!0}}function y(x,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:f;return zu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,zu}var Th;function G1(){return Th||(Th=1,Au.exports=X1()),Au.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 Rh;function Q1(){if(Rh)return Lu;Rh=1;var t=bo(),r=G1();function o(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var l=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,d=t.useEffect,f=t.useMemo,g=t.useDebugValue;return Lu.useSyncExternalStoreWithSelector=function(y,m,x,v,_){var k=u(null);if(k.current===null){var C={hasValue:!1,value:null};k.current=C}else C=k.current;k=f(function(){function E(T){if(!I){if(I=!0,N=T,T=v(T),_!==void 0&&C.hasValue){var H=C.value;if(_(H,T))return j=H}return j=T}if(H=j,l(N,T))return H;var G=v(T);return _!==void 0&&_(H,G)?(N=T,H):(N=T,j=G)}var I=!1,N,j,R=x===void 0?null:x;return[function(){return E(m())},R===null?void 0:function(){return E(R())}]},[m,x,v,_]);var S=a(y,k[0],k[1]);return d(function(){C.hasValue=!0,C.value=S},[S]),g(S),S},Lu}var Lh;function q1(){return Lh||(Lh=1,Ru.exports=Q1()),Ru.exports}var K1=q1();const Z1=xp(K1),J1={},Ah=t=>{let r;const o=new Set,l=(m,x)=>{const v=typeof m=="function"?m(r):m;if(!Object.is(v,r)){const _=r;r=x??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(k=>k(r,_))}},a=()=>r,g={setState:l,getState:a,getInitialState:()=>y,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(J1?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),o.clear()}},y=r=t(l,a,g);return g},e_=t=>t?Ah(t):Ah,{useDebugValue:t_}=Zy,{useSyncExternalStoreWithSelector:n_}=Z1,r_=t=>t;function bg(t,r=r_,o){const l=n_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return t_(l),l}const zh=(t,r)=>{const o=e_(t),l=(a,u=r)=>bg(o,a,u);return Object.assign(l,o),l},i_=(t,r)=>t?zh(t,r):zh;function Xe(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}wp();const Cl=$.createContext(null),o_=Cl.Provider,Mg=tn.error001("react");function Re(t,r){const o=$.useContext(Cl);if(o===null)throw new Error(Mg);return bg(o,t,r)}function He(){const t=$.useContext(Cl);if(t===null)throw new Error(Mg);return $.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Dh={display:"none"},s_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pg="react-flow__node-desc",Ig="react-flow__edge-desc",l_="react-flow__aria-live",a_=t=>t.ariaLiveMessage,u_=t=>t.ariaLabelConfig;function c_({rfId:t}){const r=Re(a_);return p.jsx("div",{id:`${l_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:s_,children:r})}function d_({rfId:t,disableKeyboardA11y:r}){const o=Re(u_);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${Pg}-${t}`,style:Dh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${Ig}-${t}`,style:Dh,children:o["edge.a11yDescription.default"]}),!r&&p.jsx(c_,{rfId:t})]})}const jl=$.forwardRef(({position:t="top-left",children:r,className:o,style:l,...a},u)=>{const d=`${t}`.split("-");return p.jsx("div",{className:et(["react-flow__panel",o,...d]),style:l,ref:u,...a,children:r})});jl.displayName="Panel";const $h="https://reactflow.dev?utm_source=attribution";function f_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:p.jsx(jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${$h}`,children:p.jsx("a",{href:$h,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const h_=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}},Zs=t=>t.id;function p_(t,r){return Xe(t.selectedNodes.map(Zs),r.selectedNodes.map(Zs))&&Xe(t.selectedEdges.map(Zs),r.selectedEdges.map(Zs))}function g_({onSelectionChange:t}){const r=He(),{selectedNodes:o,selectedEdges:l}=Re(h_,p_);return $.useEffect(()=>{const a={nodes:o,edges:l};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,l,t]),null}const m_=t=>!!t.onSelectionChangeHandlers;function y_({onSelectionChange:t}){const r=Re(m_);return t||r?p.jsx(g_,{onSelectionChange:t}):null}const Tg=[0,0],v_={x:0,y:0,zoom:1},x_=["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"],Oh=[...x_,"rfId"],w_=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}),Fh={translateExtent:So,nodeOrigin:Tg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function __(t){const{setNodes:r,setEdges:o,setMinZoom:l,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:d,reset:f,setDefaultNodesAndEdges:g}=Re(w_,Xe),y=He();$.useEffect(()=>(g(t.defaultNodes,t.defaultEdges),()=>{m.current=Fh,f()}),[]);const m=$.useRef(Fh);return $.useEffect(()=>{for(const x of Oh){const v=t[x],_=m.current[x];v!==_&&(typeof t[x]>"u"||(x==="nodes"?r(v):x==="edges"?o(v):x==="minZoom"?l(v):x==="maxZoom"?a(v):x==="translateExtent"?u(v):x==="nodeExtent"?d(v):x==="ariaLabelConfig"?y.setState({ariaLabelConfig:o1(v)}):x==="fitView"?y.setState({fitViewQueued:v}):x==="fitViewOptions"?y.setState({fitViewOptions:v}):y.setState({[x]:v})))}m.current=t},Oh.map(x=>t[x])),null}function Hh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function S_(t){var l;const[r,o]=$.useState(t==="system"?null:t);return $.useEffect(()=>{if(t!=="system"){o(t);return}const a=Hh(),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=Hh())!=null&&l.matches?"dark":"light"}const Bh=typeof document<"u"?document:null;function jo(t=null,r={target:Bh,actInsideInputWithModifier:!0}){const[o,l]=$.useState(!1),a=$.useRef(!1),u=$.useRef(new Set([])),[d,f]=$.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),m=y.reduce((x,v)=>x.concat(...v),[]);return[y,m]}return[[],[]]},[t]);return $.useEffect(()=>{const g=(r==null?void 0:r.target)??Bh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var S,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&dg(_))return!1;const C=Uh(_.code,f);if(u.current.add(_[C]),Vh(d,u.current,!1)){const I=((E=(S=_.composedPath)==null?void 0:S.call(_))==null?void 0:E[0])||_.target,N=(I==null?void 0:I.nodeName)==="BUTTON"||(I==null?void 0:I.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&_.preventDefault(),l(!0)}},x=_=>{const k=Uh(_.code,f);Vh(d,u.current,!0)?(l(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),l(!1)};return g==null||g.addEventListener("keydown",m),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{g==null||g.removeEventListener("keydown",m),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,l]),o}function Vh(t,r,o){return t.filter(l=>o||l.length===r.size).some(l=>l.every(a=>r.has(a)))}function Uh(t,r){return r.includes(t)?"code":"key"}const k_=()=>{const t=He();return $.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(),g=fc(r,l,a,u,d,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:l,snapGrid:a,snapToGrid:u,domNode:d}=t.getState();if(!d)return r;const{x:f,y:g}=d.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},m=o.snapGrid??a,x=o.snapToGrid??u;return Lo(y,l,x,m)},flowToScreenPosition:r=>{const{transform:o,domNode:l}=t.getState();if(!l)return r;const{x:a,y:u}=l.getBoundingClientRect(),d=Si(r,o);return{x:d.x+a,y:d.y+u}}}),[])};function Rg(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 g of d)E_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function E_(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 N_(t,r){return Rg(t,r)}function C_(t,r){return Rg(t,r)}function br(t,r){return{id:t,type:"select",selected:r}}function gi(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(br(u.id,d)))}return l}function Wh({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),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==d&&o.push({id:d.id,item:d,type:"replace"}),g===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 Yh(t){return{id:t.id,type:"remove"}}const j_=lg();function b_(t,r,o={}){return d1(t,r,{...o,onError:o.onError??j_})}const Xh=t=>qw(t),M_=t=>ng(t);function Lg(t){return $.forwardRef(t)}const Ag=typeof window<"u"?$.useLayoutEffect:$.useEffect;function Gh(t){const[r,o]=$.useState(BigInt(0)),[l]=$.useState(()=>P_(()=>o(a=>a+BigInt(1))));return Ag(()=>{const a=l.get();a.length&&(t(a),l.reset())},[r]),l}function P_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const zg=$.createContext(null);function I_({children:t}){const r=He(),o=$.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:m,onNodesChange:x,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let C=g;for(const E of f)C=typeof E=="function"?E(C):E;let S=Wh({items:C,lookup:v});for(const E of k.values())S=E(S);m&&y(C),S.length>0?x==null||x(S):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:I,setNodes:N}=r.getState();E&&N(I)})},[]),l=Gh(o),a=$.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:m,onEdgesChange:x,edgeLookup:v}=r.getState();let _=g;for(const k of f)_=typeof k=="function"?k(_):k;m?y(_):x&&x(Wh({items:_,lookup:v}))},[]),u=Gh(a),d=$.useMemo(()=>({nodeQueue:l,edgeQueue:u}),[]);return p.jsx(zg.Provider,{value:d,children:t})}function T_(){const t=$.useContext(zg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const R_=t=>!!t.panZoom;function bl(){const t=k_(),r=He(),o=T_(),l=Re(R_),a=$.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),d=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var E,I;const{nodeLookup:v,nodeOrigin:_}=r.getState(),k=Xh(x)?x:v.get(x.id),C=k.parentId?ug(k.position,k.measured,k.parentId,v,_):k.position,S={...k,position:C,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((I=k.measured)==null?void 0:I.height)??k.height};return No(S)},y=(x,v,_={replace:!1})=>{d(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&Xh(S)?S:{...C,...S}}return C}))},m=(x,v,_={replace:!1})=>{f(k=>k.map(C=>{if(C.id===x){const S=typeof v=="function"?v(C):v;return _.replace&&M_(S)?S:{...C,...S}}return C}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var v;return(v=u(x))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(v=>({...v}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:d,setEdges:f,addNodes:x=>{const v=Array.isArray(x)?x:[x];o.nodeQueue.push(_=>[..._,...v])},addEdges:x=>{const v=Array.isArray(x)?x:[x];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:x=[],edges:v=[],transform:_}=r.getState(),[k,C,S]=_;return{nodes:x.map(E=>({...E})),edges:v.map(E=>({...E})),viewport:{x:k,y:C,zoom:S}}},deleteElements:async({nodes:x=[],edges:v=[]})=>{const{nodes:_,edges:k,onNodesDelete:C,onEdgesDelete:S,triggerNodeChanges:E,triggerEdgeChanges:I,onDelete:N,onBeforeDelete:j}=r.getState(),{nodes:R,edges:T}=await t1({nodesToRemove:x,edgesToRemove:v,nodes:_,edges:k,onBeforeDelete:j}),H=T.length>0,G=R.length>0;if(H){const K=T.map(Yh);S==null||S(T),I(K)}if(G){const K=R.map(Yh);C==null||C(R),E(K)}return(G||H)&&(N==null||N({nodes:R,edges:T})),{deletedNodes:R,deletedEdges:T}},getIntersectingNodes:(x,v=!0,_)=>{const k=vh(x),C=k?x:g(x),S=_!==void 0;return C?(_||r.getState().nodes).filter(E=>{const I=r.getState().nodeLookup.get(E.id);if(I&&!k&&(E.id===x.id||!I.internals.positionAbsolute))return!1;const N=No(S?E:I),j=pl(N,C);return v&&j>0||j>=N.width*N.height||j>=C.width*C.height}):[]},isNodeIntersecting:(x,v,_=!0)=>{const C=vh(x)?x:g(x);if(!C)return!1;const S=pl(C,v);return _&&S>0||S>=v.width*v.height||S>=C.width*C.height},updateNode:y,updateNodeData:(x,v,_={replace:!1})=>{y(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},updateEdge:m,updateEdgeData:(x,v,_={replace:!1})=>{m(x,k=>{const C=typeof v=="function"?v(k):v;return _.replace?{...k,data:C}:{...k,data:{...k.data,...C}}},_)},getNodesBounds:x=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return Kw(x,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:x,id:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${x}${v?`-${v}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:v,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${x?v?`-${x}-${v}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const v=r.getState().fitViewResolver??i1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return $.useMemo(()=>({...a,...t,viewportInitialized:l}),[l])}const Qh=t=>t.selected,L_=typeof window<"u"?window:void 0;function A_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=He(),{deleteElements:l}=bl(),a=jo(t,{actInsideInputWithModifier:!1}),u=jo(r,{target:L_});$.useEffect(()=>{if(a){const{edges:d,nodes:f}=o.getState();l({nodes:f.filter(Qh),edges:d.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),$.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function z_(t){const r=He();$.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=hc(t.current);(l.height===0||l.width===0)&&((f=(d=r.getState()).onError)==null||f.call(d,"004",tn.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 Ml={position:"absolute",width:"100%",height:"100%",top:0,left:0},D_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:d=Tr.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:m,minZoom:x,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:k=!0,children:C,noWheelClassName:S,noPanClassName:E,onViewportChange:I,isControlledViewport:N,paneClickDistance:j,selectionOnDrag:R}){const T=He(),H=$.useRef(null),{userSelectionActive:G,lib:K,connectionInProgress:te}=Re(D_,Xe),W=jo(_),ee=$.useRef();z_(H);const J=$.useCallback(b=>{I==null||I({x:b[0],y:b[1],zoom:b[2]}),N||T.setState({transform:b})},[I,N]);return $.useEffect(()=>{if(H.current){ee.current=H1({domNode:H.current,minZoom:x,maxZoom:v,translateExtent:m,viewport:y,onDraggingChange:U=>T.setState(D=>D.paneDragging===U?D:{paneDragging:U}),onPanZoomStart:(U,D)=>{const{onViewportChangeStart:z,onMoveStart:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoom:(U,D)=>{const{onViewportChange:z,onMove:B}=T.getState();B==null||B(U,D),z==null||z(D)},onPanZoomEnd:(U,D)=>{const{onViewportChangeEnd:z,onMoveEnd:B}=T.getState();B==null||B(U,D),z==null||z(D)}});const{x:b,y:Y,zoom:V}=ee.current.getViewport();return T.setState({panZoom:ee.current,transform:[b,Y,V],domNode:H.current.closest(".react-flow")}),()=>{var U;(U=ee.current)==null||U.destroy()}}},[]),$.useEffect(()=>{var b;(b=ee.current)==null||b.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:l,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:d,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:W,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:S,lib:K,onTransformChange:J,connectionInProgress:te,selectionOnDrag:R,paneClickDistance:j})},[t,r,o,l,a,u,d,f,g,W,k,E,G,S,K,J,te,R,j]),p.jsx("div",{className:"react-flow__renderer",ref:H,style:Ml,children:C})}const O_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function F_(){const{userSelectionActive:t,userSelectionRect:r}=Re(O_,Xe);return t&&r?p.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 Du=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},H_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function B_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ko.Full,panOnDrag:l,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:d,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:m,onPaneScroll:x,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:k,children:C}){const S=$.useRef(0),E=He(),{userSelectionActive:I,elementsSelectable:N,dragging:j,panBy:R,autoPanSpeed:T}=Re(H_,Xe),H=N&&(t||I),G=$.useRef(null),K=$.useRef(),te=$.useRef(new Set),W=$.useRef(new Set),ee=$.useRef(!1),J=$.useRef(!1),b=$.useRef({x:0,y:0}),Y=$.useRef(!1),V=q=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){q.preventDefault();return}m==null||m(q)},D=x?q=>x(q):void 0,z=q=>{J.current&&(q.stopPropagation(),J.current=!1)},B=q=>{var Me,tt;if(q.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=E.getState();if(K.current=se==null?void 0:se.getBoundingClientRect(),!K.current)return;const _e=q.target===G.current;if(!_e&&!!q.target.closest(".nokey")||!t||!(d&&_e||r)||q.button!==0||!q.isPrimary)return;(tt=(Me=q.target)==null?void 0:Me.setPointerCapture)==null||tt.call(Me,q.pointerId),J.current=!1;const{x:Ne,y:Pe}=en(q.nativeEvent,K.current),je=Lo({x:Ne,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:je.x,startY:je.y,x:Ne,y:Pe}}),_e||(q.stopPropagation(),q.preventDefault())};function M(q,se){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:_e,nodeLookup:me,edgeLookup:ye,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:je,defaultEdgeOptions:Me}=E.getState(),tt={x:pe.startX,y:pe.startY},{x:Ge,y:nt}=Si(tt,_e),qe={startX:tt.x,startY:tt.y,x:qut.id)),W.current=new Set;const ot=(Me==null?void 0:Me.selectable)??!0;for(const ut of te.current){const ct=Ne.get(ut);if(ct)for(const{edgeId:ht}of ct.values()){const wt=ye.get(ht);wt&&(wt.selectable??ot)&&W.current.add(ht)}}if(!xh(bt,te.current)){const ut=gi(me,te.current,!0);Pe(ut)}if(!xh(Dt,W.current)){const ut=gi(ye,W.current);je(ut)}E.setState({userSelectionRect:qe,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!a||!K.current)return;const[q,se]=dc(b.current,K.current,T);R({x:q,y:se}).then(pe=>{if(!J.current||!pe){S.current=requestAnimationFrame(L);return}const{x:_e,y:me}=b.current;M(_e,me),S.current=requestAnimationFrame(L)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,Y.current=!1};$.useEffect(()=>()=>ne(),[]);const re=q=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:_e}=E.getState();if(!K.current||!se)return;const{x:me,y:ye}=en(q.nativeEvent,K.current);b.current={x:me,y:ye};const Ne=Si({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:u;if(Math.hypot(me-Ne.x,ye-Ne.y)<=Pe)return;_e(),f==null||f(q)}J.current=!0,Y.current||(L(),Y.current=!0),M(me,ye)},ce=q=>{var se,pe;if(!H){q.target===G.current&&E.getState().connection.inProgress&&(ee.current=!0);return}q.button===0&&((pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),!I&&q.target===G.current&&E.getState().userSelectionRect&&(V==null||V(q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(g==null||g(q),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=q=>{var se,pe;(pe=(se=q.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,q.pointerId),ne()},de=l===!0||Array.isArray(l)&&l.includes(0);return p.jsxs("div",{className:et(["react-flow__pane",{draggable:de,dragging:j,selection:t}]),onClick:H?void 0:Du(V,G),onContextMenu:Du(U,G),onWheel:Du(D,G),onPointerEnter:H?void 0:v,onPointerMove:H?re:_,onPointerUp:ce,onPointerCancel:H?fe:void 0,onPointerDownCapture:H?B:void 0,onClickCapture:H?z:void 0,onPointerLeave:k,ref:G,style:Ml,children:[C,p.jsx(F_,{})]})}function Ju({id:t,store:r,unselect:o=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:d,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",tn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&d)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([t])}function Dg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:l,nodeId:a,isSelectable:u,nodeClickDistance:d}){const f=He(),[g,y]=$.useState(!1),m=$.useRef();return $.useEffect(()=>{if(!r)return m.current=j1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{Ju({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=m.current)==null||x.destroy(),m.current=void 0}},[r,f,t]),$.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]),g}const V_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function $g(){const t=He();return $.useCallback(o=>{const{nodeExtent:l,snapToGrid:a,snapGrid:u,nodesDraggable:d,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:m}=t.getState(),x=new Map,v=V_(d),_=a?u[0]:5,k=a?u[1]:5,C=o.direction.x*_*o.factor,S=o.direction.y*k*o.factor;for(const[,E]of y){if(!v(E))continue;let I={x:E.internals.positionAbsolute.x+C,y:E.internals.positionAbsolute.y+S};a&&(I=Ro(I,u));const{position:N,positionAbsolute:j}=rg({nodeId:E.id,nextPosition:I,nodeLookup:y,nodeExtent:l,nodeOrigin:m,onError:f});E.position=N,E.internals.positionAbsolute=j,x.set(E.id,E)}g(x)},[])}const xc=$.createContext(null),U_=xc.Provider;xc.Consumer;const Og=()=>$.useContext(xc),W_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Fg=$.createContext(null);function Y_({children:t}){const r=Re(W_,Xe);return p.jsx(Fg.Provider,{value:r,children:t})}function X_(){const t=$.useContext(Fg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const G_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>l=>{const{connectionClickStartHandle:a,connectionMode:u,connection:d}=l,{fromHandle:f,toHandle:g,isValid:y}=d;if(!f&&!a)return G_;const m=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo: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===wi.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&&y}};function q_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:d,onConnect:f,children:g,className:y,onMouseDown:m,onTouchStart:x,...v},_){var Y,V;const k=d||null,C=t==="target",S=He(),E=Og(),{connectOnClick:I,noPanClassName:N,rfId:j}=X_(),{connectingFrom:R,connectingTo:T,clickConnecting:H,isPossibleEndHandle:G,connectionInProcess:K,clickConnectionInProcess:te,valid:W}=Re(Q_(E,k,t),Xe);E||(V=(Y=S.getState()).onError)==null||V.call(Y,"010",tn.error010());const ee=U=>{const{defaultEdgeOptions:D,onConnect:z,hasDefaultEdges:B}=S.getState(),M={...D,...U};if(B){const{edges:L,setEdges:ne,onError:re}=S.getState();ne(b_(M,L,{onError:re}))}z==null||z(M),f==null||f(M)},J=U=>{if(!E)return;const D=fg(U.nativeEvent);if(a&&(D&&U.button===0||!D)){const z=S.getState();Zu.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:C,handleId:k,nodeId:E,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...B)=>{var M,L;return(L=(M=S.getState()).onConnectEnd)==null?void 0:L.call(M,...B)},updateConnection:z.updateConnection,onConnect:ee,isValidConnection:o||((...B)=>{var M,L;return((L=(M=S.getState()).isValidConnection)==null?void 0:L.call(M,...B))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}D?m==null||m(U):x==null||x(U)},b=U=>{const{onClickConnectStart:D,onClickConnectEnd:z,connectionClickStartHandle:B,connectionMode:M,isValidConnection:L,lib:ne,rfId:re,nodeLookup:ce,connection:fe}=S.getState();if(!E||!B&&!a)return;if(!B){D==null||D(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),S.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const de=cg(U.target),q=o||L,{connection:se,isValid:pe}=Zu.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:q,flowId:re,doc:de,lib:ne,nodeLookup:ce});pe&&se&&ee(se);const _e=structuredClone(fe);delete _e.inProgress,_e.toPosition=_e.toHandle?_e.toHandle.position:null,z==null||z(U,_e),S.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${j}-${E}-${k}-${t}`,className:et(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,y,{source:!C,target:C,connectable:l,connectablestart:a,connectableend:u,clickconnecting:H,connectingfrom:R,connectingto:T,valid:W,connectionindicator:l&&(!K||G)&&(K||te?u:a)}]),onMouseDown:J,onTouchStart:J,onClick:I?b:void 0,ref:_,...v,children:g})}const Ei=$.memo(Lg(q_));function K_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return p.jsxs(p.Fragment,{children:[t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:o,isConnectable:r})]})}function Z_({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:l=Se.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,p.jsx(Ei,{type:"source",position:l,isConnectable:r})]})}function J_(){return null}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(Ei,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const gl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},qh={input:K_,default:Z_,output:eS,group:J_};function tS(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 nS=t=>{const{width:r,height:o,x:l,y:a}=To(t.nodeLookup,{filter:u=>!!u.selected});return{width:Jt(r)?r:null,height:Jt(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 rS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const l=He(),{width:a,height:u,transformString:d,userSelectionActive:f}=Re(nS,Xe),g=$g(),y=$.useRef(null);$.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const m=!f&&a!==null&&u!==null;if(Dg({nodeRef:y,disabled:!m}),!m)return null;const x=t?_=>{const k=l.getState().nodes.filter(C=>C.selected);t(_,k)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(gl,_.key)&&(_.preventDefault(),g({direction:gl[_.key],factor:_.shiftKey?4:1}))};return p.jsx("div",{className:et(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:p.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const Kh=typeof window<"u"?window:void 0,iS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Hg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:m,selectionMode:x,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:j,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:G,autoPanOnSelection:K,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,preventScrolling:b,onSelectionContextMenu:Y,noWheelClassName:V,noPanClassName:U,disableKeyboardA11y:D,onViewportChange:z,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:L}=Re(iS,Xe),ne=jo(y,{target:Kh}),re=jo(C,{target:Kh}),ce=re||G,fe=re||j,de=m&&ce!==!0,q=ne||L||de;return A_({deleteKeyCode:g,multiSelectionKeyCode:k}),p.jsx($_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:I,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:R,panOnScrollMode:T,zoomOnDoubleClick:H,panOnDrag:!ne&&ce,defaultViewport:te,translateExtent:W,minZoom:ee,maxZoom:J,zoomActivationKeyCode:S,preventScrolling:b,noWheelClassName:V,noPanClassName:U,onViewportChange:z,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:p.jsxs(B_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:d,panOnDrag:ce,autoPanOnSelection:K,isSelecting:!!q,selectionMode:x,selectionKeyPressed:ne,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&p.jsx(rS,{onSelectionContextMenu:Y,noPanClassName:U,disableKeyboardA11y:D})]})})}Hg.displayName="FlowRenderer";const oS=$.memo(Hg),sS=t=>r=>t?cc(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 lS(t){return Re($.useCallback(sS(t),[t]),Xe)}const aS=t=>t.updateNodeInternals;function uS(){const t=Re(aS),[r]=$.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 $.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function cS({node:t,nodeType:r,hasDimensions:o,resizeObserver:l}){const a=He(),u=$.useRef(null),d=$.useRef(null),f=$.useRef(t.sourcePosition),g=$.useRef(t.targetPosition),y=$.useRef(r),m=o&&!!t.internals.handleBounds;return $.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]),$.useEffect(()=>()=>{d.current&&(l==null||l.unobserve(d.current),d.current=null)},[]),$.useEffect(()=>{if(u.current){const x=y.current!==r,v=f.current!==t.sourcePosition,_=g.current!==t.targetPosition;(x||v||_)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function dS({id:t,onClick:r,onMouseEnter:o,onMouseMove:l,onMouseLeave:a,onContextMenu:u,onDoubleClick:d,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:m,resizeObserver:x,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:k,rfId:C,nodeTypes:S,nodeClickDistance:E,onError:I}){const{node:N,internals:j,isParent:R}=Re(q=>{const se=q.nodeLookup.get(t),pe=q.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},Xe);let T=N.type||"default",H=(S==null?void 0:S[T])||qh[T];H===void 0&&(I==null||I("003",tn.error003(T)),T="default",H=(S==null?void 0:S.default)||qh.default);const G=!!(N.draggable||f&&typeof N.draggable>"u"),K=!!(N.selectable||g&&typeof N.selectable>"u"),te=!!(N.connectable||y&&typeof N.connectable>"u"),W=!!(N.focusable||m&&typeof N.focusable>"u"),ee=He(),J=ag(N),b=cS({node:N,nodeType:T,hasDimensions:J,resizeObserver:x}),Y=Dg({nodeRef:b,disabled:N.hidden||!G,noDragClassName:v,handleSelector:N.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:E}),V=$g();if(N.hidden)return null;const U=rn(N),D=tS(N),z=K||G||r||o||l||a,B=o?q=>o(q,{...j.userNode}):void 0,M=l?q=>l(q,{...j.userNode}):void 0,L=a?q=>a(q,{...j.userNode}):void 0,ne=u?q=>u(q,{...j.userNode}):void 0,re=d?q=>d(q,{...j.userNode}):void 0,ce=q=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();K&&(!se||!G||pe>0)&&Ju({id:t,store:ee,nodeRef:b}),r&&r(q,{...j.userNode})},fe=q=>{if(!(dg(q.nativeEvent)||k)){if(Zp.includes(q.key)&&K){const se=q.key==="Escape";Ju({id:t,store:ee,unselect:se,nodeRef:b})}else if(G&&N.selected&&Object.prototype.hasOwnProperty.call(gl,q.key)){q.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),V({direction:gl[q.key],factor:q.shiftKey?4:1})}}},de=()=>{var Ne;if(k||!((Ne=b.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:q,width:se,height:pe,autoPanOnNodeFocus:_e,setCenter:me}=ee.getState();if(!_e)return;cc(new Map([[t,N]]),{x:0,y:0,width:se,height:pe},q,!0).length>0||me(N.position.x+U.width/2,N.position.y+U.height/2,{zoom:q[2]})};return p.jsx("div",{className:et(["react-flow__node",`react-flow__node-${T}`,{[_]:G},N.className,{selected:N.selected,selectable:K,parent:R,draggable:G,dragging:Y}]),ref:b,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:J?"visible":"hidden",...N.style,...D},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:L,onContextMenu:ne,onClick:ce,onDoubleClick:re,onKeyDown:W?fe:void 0,tabIndex:W?0:void 0,onFocus:W?de:void 0,role:N.ariaRole??(W?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Pg}-${C}`,"aria-label":N.ariaLabel,...N.domAttributes,children:p.jsx(U_,{value:t,children:p.jsx(H,{id:t,data:N.data,type:T,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:N.selected??!1,selectable:K,draggable:G,deletable:N.deletable??!0,isConnectable:te,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:Y,dragHandle:N.dragHandle,zIndex:j.z,parentId:N.parentId,...U})})})}var fS=$.memo(dS);const hS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Bg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:l,onError:a}=Re(hS,Xe),u=lS(t.onlyRenderVisibleElements),d=uS();return p.jsx("div",{className:"react-flow__nodes",style:Ml,children:u.map(f=>p.jsx(fS,{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))})}Bg.displayName="NodeRenderer";const pS=$.memo(Bg);function gS(t){return Re($.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&&a1({sourceNode:u,targetNode:d,width:o.width,height:o.height,transform:o.transform})&&l.push(a.id)}return l},[t]),Xe)}const mS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return p.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},yS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return p.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Zh={[Eo.Arrow]:mS,[Eo.ArrowClosed]:yS};function vS(t){const r=He();return $.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(Zh,t)?Zh[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",tn.error009(t)),null)},[t])}const xS=({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 g=vS(r);return g?p.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:p.jsx(g,{color:o,strokeWidth:d})}):null},Vg=({defaultColor:t,rfId:r})=>{const o=Re(u=>u.edges),l=Re(u=>u.defaultEdgeOptions),a=$.useMemo(()=>m1(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?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:a.map(u=>p.jsx(xS,{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};Vg.displayName="MarkerDefinitions";var wS=$.memo(Vg);function Ug({x:t,y:r,label:o,labelStyle:l,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:d=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...m}){const[x,v]=$.useState({x:1,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",y]),k=$.useRef(null);return $.useEffect(()=>{if(k.current){const C=k.current.getBBox();v({x:C.x,y:C.y,width:C.width,height:C.height})}},[o]),o?p.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:_,visibility:x.width?"visible":"hidden",...m,children:[a&&p.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}),p.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:l,children:o}),g]}):null}Ug.displayName="EdgeText";const _S=$.memo(Ug);function Pl({path:t,labelX:r,labelY:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...m}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...m,d:t,fill:"none",className:et(["react-flow__edge-path",m.className])}),y?p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Jt(r)&&Jt(o)?p.jsx(_S,{x:r,y:o,label:l,labelStyle:a,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function Jh({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 Wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:l,targetY:a,targetPosition:u=Se.Top}){const[d,f]=Jh({pos:o,x1:t,y1:r,x2:l,y2:a}),[g,y]=Jh({pos:u,x1:l,y1:a,x2:t,y2:r}),[m,x,v,_]=hg({sourceX:t,sourceY:r,targetX:l,targetY:a,sourceControlX:d,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${d},${f} ${g},${y} ${l},${a}`,m,x,v,_]}function Yg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d,targetPosition:f,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})=>{const[I,N,j]=Wg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f}),R=t.isInternal?void 0:r;return p.jsx(Pl,{id:R,path:I,labelX:N,labelY:j,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:E})})}const SS=Yg({isInternal:!1}),Xg=Yg({isInternal:!0});SS.displayName="SimpleBezierEdge";Xg.displayName="SimpleBezierEdgeInternal";function Gg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=Qu({sourceX:o,sourceY:l,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:C,markerStart:S,interactionWidth:I})})}const Qg=Gg({isInternal:!1}),qg=Gg({isInternal:!0});Qg.displayName="SmoothStepEdge";qg.displayName="SmoothStepEdgeInternal";function Kg(t){return $.memo(({id:r,...o})=>{var a;const l=t.isInternal?void 0:r;return p.jsx(Qg,{...o,id:l,pathOptions:$.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const kS=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});kS.displayName="StepEdge";Zg.displayName="StepEdgeInternal";function Jg(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})=>{const[S,E,I]=mg({sourceX:o,sourceY:l,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return p.jsx(Pl,{id:N,path:S,labelX:E,labelY:I,label:d,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:x,style:v,markerEnd:_,markerStart:k,interactionWidth:C})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StraightEdge";em.displayName="StraightEdgeInternal";function tm(t){return $.memo(({id:r,sourceX:o,sourceY:l,targetX:a,targetY:u,sourcePosition:d=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,pathOptions:E,interactionWidth:I})=>{const[N,j,R]=pg({sourceX:o,sourceY:l,sourcePosition:d,targetX:a,targetY:u,targetPosition:f,curvature:E==null?void 0:E.curvature}),T=t.isInternal?void 0:r;return p.jsx(Pl,{id:T,path:N,labelX:j,labelY:R,label:g,labelStyle:y,labelShowBg:m,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:_,style:k,markerEnd:C,markerStart:S,interactionWidth:I})})}const NS=tm({isInternal:!1}),nm=tm({isInternal:!0});NS.displayName="BezierEdge";nm.displayName="BezierEdgeInternal";const ep={default:nm,straight:em,step:Zg,smoothstep:qg,simplebezier:Xg},tp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,jS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,np="react-flow__edgeupdater";function rp({position:t,centerX:r,centerY:o,radius:l=10,onMouseDown:a,onMouseEnter:u,onMouseOut:d,type:f}){return p.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:d,className:et([np,`${np}-${f}`]),cx:CS(r,l,t),cy:jS(o,l,t),r:l,stroke:"transparent",fill:"transparent"})}function bS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:l,sourceY:a,targetX:u,targetY:d,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:m,onReconnectEnd:x,setReconnecting:v,setUpdateHover:_}){const k=He(),C=(j,R)=>{if(j.button!==0)return;const{autoPanOnConnect:T,domNode:H,connectionMode:G,connectionRadius:K,lib:te,onConnectStart:W,cancelConnection:ee,nodeLookup:J,rfId:b,panBy:Y,updateConnection:V}=k.getState(),U=R.type==="target",D=(M,L)=>{v(!1),x==null||x(M,o,R.type,L)},z=M=>y==null?void 0:y(o,M),B=(M,L)=>{v(!0),m==null||m(j,o,R.type),W==null||W(M,L)};Zu.onPointerDown(j.nativeEvent,{autoPanOnConnect:T,connectionMode:G,connectionRadius:K,domNode:H,handleId:R.id,nodeId:R.nodeId,nodeLookup:J,isTarget:U,edgeUpdaterType:R.type,lib:te,flowId:b,cancelConnection:ee,panBy:Y,isValidConnection:(...M)=>{var L,ne;return((ne=(L=k.getState()).isValidConnection)==null?void 0:ne.call(L,...M))??!0},onConnect:z,onConnectStart:B,onConnectEnd:(...M)=>{var L,ne;return(ne=(L=k.getState()).onConnectEnd)==null?void 0:ne.call(L,...M)},onReconnectEnd:D,updateConnection:V,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=j=>C(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=j=>C(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),I=()=>_(!0),N=()=>_(!1);return p.jsxs(p.Fragment,{children:[(t===!0||t==="source")&&p.jsx(rp,{position:f,centerX:l,centerY:a,radius:r,onMouseDown:S,onMouseEnter:I,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&p.jsx(rp,{position:g,centerX:u,centerY:d,radius:r,onMouseDown:E,onMouseEnter:I,onMouseOut:N,type:"target"})]})}function MS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:l,onClick:a,onDoubleClick:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,rfId:k,edgeTypes:C,noPanClassName:S,onError:E,disableKeyboardA11y:I}){let N=Re(me=>me.edgeLookup.get(t));const j=Re(me=>me.defaultEdgeOptions);N=j?{...j,...N}:N;let R=N.type||"default",T=(C==null?void 0:C[R])||ep[R];T===void 0&&(E==null||E("011",tn.error011(R)),R="default",T=(C==null?void 0:C.default)||ep.default);const H=!!(N.focusable||r&&typeof N.focusable>"u"),G=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),K=!!(N.selectable||l&&typeof N.selectable>"u"),te=$.useRef(null),[W,ee]=$.useState(!1),[J,b]=$.useState(!1),Y=He(),{zIndex:V=N.zIndex,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L}=Re($.useCallback(me=>{const ye=me.nodeLookup.get(N.source),Ne=me.nodeLookup.get(N.target);if(!ye||!Ne)return tp;const Pe=g1({id:t,sourceNode:ye,targetNode:Ne,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:me.connectionMode,onError:E}),je=l1({selected:N.selected,zIndex:N.zIndex,sourceNode:ye,targetNode:Ne,elevateOnSelect:me.elevateEdgesOnSelect,zIndexMode:me.zIndexMode});return{...Pe||tp,zIndex:je}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,E]),Xe),ne=$.useMemo(()=>N.markerStart?`url('#${qu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),re=$.useMemo(()=>N.markerEnd?`url('#${qu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||U===null||D===null||z===null||B===null)return null;const ce=me=>{var je;const{addSelectedEdges:ye,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=Y.getState();K&&(Y.setState({nodesSelectionActive:!1}),N.selected&&Pe?(Ne({nodes:[],edges:[N]}),(je=te.current)==null||je.blur()):ye([t])),a&&a(me,N)},fe=u?me=>{u(me,{...N})}:void 0,de=d?me=>{d(me,{...N})}:void 0,q=f?me=>{f(me,{...N})}:void 0,se=g?me=>{g(me,{...N})}:void 0,pe=y?me=>{y(me,{...N})}:void 0,_e=me=>{var ye;if(!I&&Zp.includes(me.key)&&K){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=Y.getState();me.key==="Escape"?((ye=te.current)==null||ye.blur(),Ne({edges:[N]})):Pe([t])}};return p.jsx("svg",{style:{zIndex:V},children:p.jsxs("g",{className:et(["react-flow__edge",`react-flow__edge-${R}`,N.className,S,{selected:N.selected,animated:N.animated,inactive:!K&&!a,updating:W,selectable:K}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:q,onMouseMove:se,onMouseLeave:pe,onKeyDown:H?_e: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?`${Ig}-${k}`:void 0,ref:te,...N.domAttributes,children:[!J&&p.jsx(T,{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:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),G&&p.jsx(bS,{edge:N,isReconnectable:G,reconnectRadius:m,onReconnect:x,onReconnectStart:v,onReconnectEnd:_,sourceX:U,sourceY:D,targetX:z,targetY:B,sourcePosition:M,targetPosition:L,setUpdateHover:ee,setReconnecting:b})]})})}var PS=$.memo(MS);const IS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function rm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:l,noPanClassName:a,onReconnect:u,onEdgeContextMenu:d,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:m,reconnectRadius:x,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:C}){const{edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,onError:N}=Re(IS,Xe),j=gS(r);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(wS,{defaultColor:t,rfId:o}),j.map(R=>p.jsx(PS,{id:R,edgesFocusable:S,edgesReconnectable:E,elementsSelectable:I,noPanClassName:a,onReconnect:u,onContextMenu:d,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:m,reconnectRadius:x,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:l,disableKeyboardA11y:C},R))]})}rm.displayName="EdgeRenderer";const TS=$.memo(rm),ip=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function RS({children:t}){const r=He(),o=$.useRef(null),[l]=$.useState(()=>r.getState().transform);return Ag(()=>{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=ip(d)))};return u(),r.subscribe(u)},[r]),p.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ip(l)},children:t})}function LS(t){const r=bl(),o=$.useRef(!1);$.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const AS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function zS(t){const r=Re(AS),o=He();return $.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function DS(t){return t.connection.inProgress?{...t.connection,to:Lo(t.connection.to,t.transform)}:{...t.connection}}function $S(t){return DS}function OS(t){const r=$S();return Re(r,Xe)}const FS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function HS({containerStyle:t,style:r,type:o,component:l}){const{nodesConnectable:a,width:u,height:d,isValid:f,inProgress:g}=Re(FS,Xe);return!(u&&a&&g)?null:p.jsx("svg",{style:t,width:u,height:d,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:et(["react-flow__connection",tg(f)]),children:p.jsx(im,{style:r,type:o,CustomComponent:l,isValid:f})})})}const im=({style:t,type:r=nr.Bezier,CustomComponent:o,isValid:l})=>{const{inProgress:a,from:u,fromNode:d,fromHandle:f,fromPosition:g,to:y,toNode:m,toHandle:x,toPosition:v,pointer:_}=OS();if(!a)return;if(o)return p.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:d,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:v,connectionStatus:tg(l),toNode:m,toHandle:x,pointer:_});let k="";const C={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:v};switch(r){case nr.Bezier:[k]=pg(C);break;case nr.SimpleBezier:[k]=Wg(C);break;case nr.Step:[k]=Qu({...C,borderRadius:0});break;case nr.SmoothStep:[k]=Qu(C);break;default:[k]=mg(C)}return p.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};im.displayName="ConnectionLine";const BS={};function op(t=BS){$.useRef(t),He(),$.useEffect(()=>{},[t])}function VS(){He(),$.useRef(!1),$.useEffect(()=>{},[])}function om({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:v,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:C,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,deleteKeyCode:G,onlyRenderVisibleElements:K,elementsSelectable:te,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,preventScrolling:Y,defaultMarkerColor:V,zoomOnScroll:U,zoomOnPinch:D,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:L,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:_e,nodeClickDistance:me,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,viewport:ht,onViewportChange:wt,nodesDraggable:Mn}){return op(t),op(r),VS(),LS(o),zS(ht),p.jsx(oS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:q,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:_e,deleteKeyCode:G,selectionKeyCode:I,selectionOnDrag:N,selectionMode:j,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:R,panActivationKeyCode:T,zoomActivationKeyCode:H,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:D,zoomOnDoubleClick:L,panOnScroll:z,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:W,translateExtent:ee,minZoom:J,maxZoom:b,onSelectionContextMenu:x,preventScrolling:Y,noDragClassName:qe,noWheelClassName:bt,noPanClassName:Dt,disableKeyboardA11y:ot,onViewportChange:wt,isControlledViewport:!!ht,children:p.jsxs(RS,{children:[p.jsx(TS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:d,onReconnect:tt,onReconnectStart:Ge,onReconnectEnd:nt,onlyRenderVisibleElements:K,onEdgeContextMenu:ye,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:je,reconnectRadius:Me,defaultMarkerColor:V,noPanClassName:Dt,disableKeyboardA11y:ot,rfId:ct}),p.jsx(HS,{style:C,type:k,component:S,containerStyle:E}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(pS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:m,nodeClickDistance:me,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:qe,disableKeyboardA11y:ot,nodeExtent:ut,rfId:ct,nodesDraggable:Mn}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}om.displayName="GraphView";const US=$.memo(om),WS=lg(),sp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:m,nodeExtent:x,zIndexMode:v="basic"}={})=>{const _=new Map,k=new Map,C=new Map,S=new Map,E=l??r??[],I=o??t??[],N=m??[0,0],j=x??So;xg(C,S,E);const{nodesInitialized:R}=Ku(I,_,k,{nodeOrigin:N,nodeExtent:j,zIndexMode:v});let T=[0,0,1];if(d&&a&&u){const H=To(_,{filter:W=>!!((W.width||W.initialWidth)&&(W.height||W.initialHeight))}),{x:G,y:K,zoom:te}=fc(H,a,u,g,y,(f==null?void 0:f.padding)??.1);T=[G,K,te]}return{rfId:"1",width:a??0,height:u??0,transform:T,nodes:I,nodesInitialized:R,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:S,connectionLookup:C,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:So,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:wi.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:{...eg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:WS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jp,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v})=>i_((_,k)=>{async function C(){const{nodeLookup:S,panZoom:E,fitViewOptions:I,fitViewResolver:N,width:j,height:R,minZoom:T,maxZoom:H}=k();E&&(await e1({nodes:S,width:j,height:R,panZoom:E,minZoom:T,maxZoom:H},I),N==null||N.resolve(!0),_({fitViewResolver:null}))}return{...sp({nodes:t,edges:r,width:a,height:u,fitView:d,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:m,nodeExtent:x,defaultNodes:o,defaultEdges:l,zIndexMode:v}),setNodes:S=>{const{nodeLookup:E,parentLookup:I,nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,fitViewQueued:T,zIndexMode:H,nodesSelectionActive:G}=k(),{nodesInitialized:K,hasSelectedNodes:te}=Ku(S,E,I,{nodeOrigin:N,nodeExtent:j,elevateNodesOnSelect:R,checkEquality:!0,zIndexMode:H}),W=G&&te;T&&K?(C(),_({nodes:S,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:W})):_({nodes:S,nodesInitialized:K,nodesSelectionActive:W})},setEdges:S=>{const{connectionLookup:E,edgeLookup:I}=k();xg(E,I,S),_({edges:S})},setDefaultNodesAndEdges:(S,E)=>{if(S){const{setNodes:I}=k();I(S),_({hasDefaultNodes:!0})}if(E){const{setEdges:I}=k();I(E),_({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:E,nodeLookup:I,parentLookup:N,domNode:j,nodeOrigin:R,nodeExtent:T,debug:H,fitViewQueued:G,zIndexMode:K}=k(),{changes:te,updatedInternals:W}=k1(S,I,N,j,R,T,K);W&&(x1(I,N,{nodeOrigin:R,nodeExtent:T,zIndexMode:K}),G?(C(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(H&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(S,E=!1)=>{const I=[];let N=[];const{nodeLookup:j,triggerNodeChanges:R,connection:T,updateConnection:H,onNodesChangeMiddlewareMap:G}=k();for(const[K,te]of S){const W=j.get(K),ee=!!(W!=null&&W.expandParent&&(W!=null&&W.parentId)&&(te!=null&&te.position)),J={id:K,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(W&&T.inProgress&&T.fromNode.id===W.id){const b=Dr(W,T.fromHandle,Se.Left,!0);H({...T,from:b})}ee&&W.parentId&&I.push({id:K,parentId:W.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),N.push(J)}if(I.length>0){const{parentLookup:K,nodeOrigin:te}=k(),W=vc(I,j,K,te);N.push(...W)}for(const K of G.values())N=K(N);R(N)},triggerNodeChanges:S=>{const{onNodesChange:E,setNodes:I,nodes:N,hasDefaultNodes:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=N_(S,N);I(T)}R&&console.log("React Flow: trigger node changes",S),E==null||E(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:E,setEdges:I,edges:N,hasDefaultEdges:j,debug:R}=k();if(S!=null&&S.length){if(j){const T=C_(S,N);I(T)}R&&console.log("React Flow: trigger edge changes",S),E==null||E(S)}},addSelectedNodes:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));j(T);return}j(gi(N,new Set([...S]),!0)),R(gi(I))},addSelectedEdges:S=>{const{multiSelectionActive:E,edgeLookup:I,nodeLookup:N,triggerNodeChanges:j,triggerEdgeChanges:R}=k();if(E){const T=S.map(H=>br(H,!0));R(T);return}R(gi(I,new Set([...S]))),j(gi(N,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:E}={})=>{const{edges:I,nodes:N,nodeLookup:j,triggerNodeChanges:R,triggerEdgeChanges:T}=k(),H=S||N,G=E||I,K=[];for(const W of H){if(!W.selected)continue;const ee=j.get(W.id);ee&&(ee.selected=!1),K.push(br(W.id,!1))}const te=[];for(const W of G)W.selected&&te.push(br(W.id,!1));R(K),T(te)},setMinZoom:S=>{const{panZoom:E,maxZoom:I}=k();E==null||E.setScaleExtent([S,I]),_({minZoom:S})},setMaxZoom:S=>{const{panZoom:E,minZoom:I}=k();E==null||E.setScaleExtent([I,S]),_({maxZoom:S})},setTranslateExtent:S=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(S),_({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:E,triggerNodeChanges:I,triggerEdgeChanges:N,elementsSelectable:j}=k();if(!j)return;const R=E.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]),T=S.reduce((H,G)=>G.selected?[...H,br(G.id,!1)]:H,[]);I(R),N(T)},setNodeExtent:S=>{const{nodes:E,nodeLookup:I,parentLookup:N,nodeOrigin:j,elevateNodesOnSelect:R,nodeExtent:T,zIndexMode:H}=k();S[0][0]===T[0][0]&&S[0][1]===T[0][1]&&S[1][0]===T[1][0]&&S[1][1]===T[1][1]||(Ku(E,I,N,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:R,checkEquality:!1,zIndexMode:H}),_({nodeExtent:S}))},panBy:S=>{const{transform:E,width:I,height:N,panZoom:j,translateExtent:R}=k();return E1({delta:S,panZoom:j,transform:E,translateExtent:R,width:I,height:N})},setCenter:async(S,E,I)=>{const{width:N,height:j,maxZoom:R,panZoom:T}=k();if(!T)return!1;const H=typeof(I==null?void 0:I.zoom)<"u"?I.zoom:R;return await T.setViewport({x:N/2-S*H,y:j/2-E*H,zoom:H},{duration:I==null?void 0:I.duration,ease:I==null?void 0:I.ease,interpolate:I==null?void 0:I.interpolate}),!0},cancelConnection:()=>{_({connection:{...eg}})},updateConnection:S=>{_({connection:S})},reset:()=>_({...sp()})}},Object.is);function sm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:l,initialWidth:a,initialHeight:u,initialMinZoom:d,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:m,nodeExtent:x,zIndexMode:v,children:_}){const[k]=$.useState(()=>YS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,width:a,height:u,fitView:y,minZoom:d,maxZoom:f,fitViewOptions:g,nodeOrigin:m,nodeExtent:x,zIndexMode:v}));return p.jsx(o_,{value:k,children:p.jsx(I_,{children:p.jsx(Y_,{children:_})})})}function XS({children:t,nodes:r,edges:o,defaultNodes:l,defaultEdges:a,width:u,height:d,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_}){return $.useContext(Cl)?p.jsx(p.Fragment,{children:t}):p.jsx(sm,{initialNodes:r,initialEdges:o,defaultNodes:l,defaultEdges:a,initialWidth:u,initialHeight:d,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:m,nodeOrigin:x,nodeExtent:v,zIndexMode:_,children:t})}const GS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:l,className:a,nodeTypes:u,edgeTypes:d,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:m,onMoveStart:x,onMoveEnd:v,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onSelectionChange:J,onSelectionDragStart:b,onSelectionDrag:Y,onSelectionDragStop:V,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onBeforeDelete:B,connectionMode:M,connectionLineType:L=nr.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:q=!1,selectionMode:se=ko.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:_e=Co()?"Meta":"Control",zoomActivationKeyCode:me=Co()?"Meta":"Control",snapToGrid:ye,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:je,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,nodeOrigin:qe=Tg,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot=!0,defaultViewport:ut=v_,minZoom:ct=.5,maxZoom:ht=2,translateExtent:wt=So,preventScrolling:Mn=!0,nodeExtent:Ut,defaultMarkerColor:gn="#b1b1b7",zoomOnScroll:Ni=!0,zoomOnPinch:Or=!0,panOnScroll:ir=!1,panOnScrollSpeed:Ci=.5,panOnScrollMode:or=Tr.Free,zoomOnDoubleClick:Pn=!0,panOnDrag:mn=!0,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur=1,nodeClickDistance:cr=0,children:dr,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Fr=10,onNodesChange:ji,onEdgesChange:Tl,noDragClassName:Rl="nodrag",noWheelClassName:Ll="nowheel",noPanClassName:ln="nopan",fitView:bi,fitViewOptions:Mi,connectOnClick:Al,attributionPosition:Ao,proOptions:zo,defaultEdgeOptions:Do,elevateNodesOnSelect:$o=!0,elevateEdgesOnSelect:zl=!1,disableKeyboardA11y:Oo=!1,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanOnSelection:Pi=!0,autoPanSpeed:Fo,connectionRadius:Hr,isValidConnection:$l,onError:Ho,style:Br,id:Mt,nodeDragThreshold:Ol,connectionDragThreshold:Pt,viewport:Fl,onViewportChange:Hl,width:Bl,height:Vr,colorMode:Ur="light",debug:hr,onScroll:yn,ariaLabelConfig:Vl,zIndexMode:Bo="basic",...Ii},Vo){const pr=Mt||"1",gr=S_(Ur),Ul=$.useCallback(Wr=>{Wr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yn==null||yn(Wr)},[yn]);return p.jsx("div",{"data-testid":"rf__wrapper",...Ii,onScroll:Ul,style:{...Br,...GS},ref:Vo,className:et(["react-flow",a,gr]),id:Mt,role:"application",children:p.jsxs(XS,{nodes:t,edges:r,width:Bl,height:Vr,fitView:bi,fitViewOptions:Mi,minZoom:ct,maxZoom:ht,nodeOrigin:qe,nodeExtent:Ut,zIndexMode:Bo,children:[p.jsx(__,{nodes:t,edges:r,defaultNodes:o,defaultEdges:l,onConnect:_,onConnectStart:k,onConnectEnd:C,onClickConnectStart:S,onClickConnectEnd:E,nodesDraggable:Me,autoPanOnNodeFocus:tt,nodesConnectable:Ge,nodesFocusable:nt,edgesFocusable:bt,edgesReconnectable:Dt,elementsSelectable:ot,elevateNodesOnSelect:$o,elevateEdgesOnSelect:zl,minZoom:ct,maxZoom:ht,nodeExtent:Ut,onNodesChange:ji,onEdgesChange:Tl,snapToGrid:ye,snapGrid:Ne,connectionMode:M,translateExtent:wt,connectOnClick:Al,defaultEdgeOptions:Do,fitView:bi,fitViewOptions:Mi,onNodesDelete:te,onEdgesDelete:W,onDelete:ee,onNodeDragStart:H,onNodeDrag:G,onNodeDragStop:K,onSelectionDrag:Y,onSelectionDragStart:b,onSelectionDragStop:V,onMove:m,onMoveStart:x,onMoveEnd:v,noPanClassName:ln,nodeOrigin:qe,rfId:pr,autoPanOnConnect:Ue,autoPanOnNodeDrag:Dl,autoPanSpeed:Fo,onError:Ho,connectionRadius:Hr,isValidConnection:$l,selectNodesOnDrag:je,nodeDragThreshold:Ol,connectionDragThreshold:Pt,onBeforeDelete:B,debug:hr,ariaLabelConfig:Vl,zIndexMode:Bo}),p.jsx(US,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:I,onNodeMouseMove:N,onNodeMouseLeave:j,onNodeContextMenu:R,onNodeDoubleClick:T,nodeTypes:u,edgeTypes:d,connectionLineType:L,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:q,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:_e,panActivationKeyCode:pe,zoomActivationKeyCode:me,onlyRenderVisibleElements:Pe,defaultViewport:ut,translateExtent:wt,minZoom:ct,maxZoom:ht,preventScrolling:Mn,zoomOnScroll:Ni,zoomOnPinch:Or,zoomOnDoubleClick:Pn,panOnScroll:ir,panOnScrollSpeed:Ci,panOnScrollMode:or,panOnDrag:mn,autoPanOnSelection:Pi,onPaneClick:In,onPaneMouseEnter:sr,onPaneMouseMove:on,onPaneMouseLeave:sn,onPaneScroll:lr,onPaneContextMenu:ar,paneClickDistance:ur,nodeClickDistance:cr,onSelectionContextMenu:U,onSelectionStart:D,onSelectionEnd:z,onReconnect:Tn,onReconnectStart:fr,onReconnectEnd:F,onEdgeContextMenu:ae,onEdgeDoubleClick:be,onEdgeMouseEnter:$e,onEdgeMouseMove:ze,onEdgeMouseLeave:Rn,reconnectRadius:Fr,defaultMarkerColor:gn,noDragClassName:Rl,noWheelClassName:Ll,noPanClassName:ln,rfId:pr,disableKeyboardA11y:Oo,nodeExtent:Ut,viewport:Fl,onViewportChange:Hl,nodesDraggable:Me}),p.jsx(y_,{onSelectionChange:J}),dr,p.jsx(f_,{proOptions:zo,position:Ao}),p.jsx(d_,{rfId:pr,disableKeyboardA11y:Oo})]})})}var qS=Lg(QS);function KS({dimensions:t,lineWidth:r,variant:o,className:l}){return p.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:et(["react-flow__background-pattern",o,l])})}function ZS({radius:t,className:r}){return p.jsx("circle",{cx:t,cy:t,r:t,className:et(["react-flow__background-pattern","dots",r])})}var rr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(rr||(rr={}));const JS={[rr.Dots]:1,[rr.Lines]:1,[rr.Cross]:6},ek=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function lm({id:t,variant:r=rr.Dots,gap:o=20,size:l,lineWidth:a=1,offset:u=0,color:d,bgColor:f,style:g,className:y,patternClassName:m}){const x=$.useRef(null),{transform:v,patternId:_}=Re(ek,Xe),k=l||JS[r],C=r===rr.Dots,S=r===rr.Cross,E=Array.isArray(o)?o:[o,o],I=[E[0]*v[2]||1,E[1]*v[2]||1],N=k*v[2],j=Array.isArray(u)?u:[u,u],R=S?[N,N]:I,T=[j[0]*v[2]+R[0]/2,j[1]*v[2]+R[1]/2],H=`${_}${t||""}`;return p.jsxs("svg",{className:et(["react-flow__background",y]),style:{...g,...Ml,"--xy-background-color-props":f,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[p.jsx("pattern",{id:H,x:v[0]%I[0],y:v[1]%I[1],width:I[0],height:I[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:C?p.jsx(ZS,{radius:N/2,className:m}):p.jsx(KS,{dimensions:R,lineWidth:a,variant:r,className:m})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}lm.displayName="Background";const tk=$.memo(lm);function nk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function rk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ik(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.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 ok(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 sk(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.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 Js({children:t,className:r,...o}){return p.jsx("button",{type:"button",className:et(["react-flow__controls-button",r]),...o,children:t})}const lk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function am({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:d,onFitView:f,onInteractiveChange:g,className:y,children:m,position:x="bottom-left",orientation:v="vertical","aria-label":_}){const k=He(),{isInteractive:C,minZoomReached:S,maxZoomReached:E,ariaLabelConfig:I}=Re(lk,Xe),{zoomIn:N,zoomOut:j,fitView:R}=bl(),T=()=>{N(),u==null||u()},H=()=>{j(),d==null||d()},G=()=>{R(a),f==null||f()},K=()=>{k.setState({nodesDraggable:!C,nodesConnectable:!C,elementsSelectable:!C}),g==null||g(!C)},te=v==="horizontal"?"horizontal":"vertical";return p.jsxs(jl,{className:et(["react-flow__controls",te,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":_??I["controls.ariaLabel"],children:[r&&p.jsxs(p.Fragment,{children:[p.jsx(Js,{onClick:T,className:"react-flow__controls-zoomin",title:I["controls.zoomIn.ariaLabel"],"aria-label":I["controls.zoomIn.ariaLabel"],disabled:E,children:p.jsx(nk,{})}),p.jsx(Js,{onClick:H,className:"react-flow__controls-zoomout",title:I["controls.zoomOut.ariaLabel"],"aria-label":I["controls.zoomOut.ariaLabel"],disabled:S,children:p.jsx(rk,{})})]}),o&&p.jsx(Js,{className:"react-flow__controls-fitview",onClick:G,title:I["controls.fitView.ariaLabel"],"aria-label":I["controls.fitView.ariaLabel"],children:p.jsx(ik,{})}),l&&p.jsx(Js,{className:"react-flow__controls-interactive",onClick:K,title:I["controls.interactive.ariaLabel"],"aria-label":I["controls.interactive.ariaLabel"],children:C?p.jsx(sk,{}):p.jsx(ok,{})}),m]})}am.displayName="Controls";const ak=$.memo(am);function uk({id:t,x:r,y:o,width:l,height:a,style:u,color:d,strokeColor:f,strokeWidth:g,className:y,borderRadius:m,shapeRendering:x,selected:v,onClick:_}){const{background:k,backgroundColor:C}=u||{},S=d||k||C;return p.jsx("rect",{className:et(["react-flow__minimap-node",{selected:v},y]),x:r,y:o,rx:m,ry:m,width:l,height:a,style:{fill:S,stroke:f,strokeWidth:g},shapeRendering:x,onClick:_?E=>_(E,t):void 0})}const ck=$.memo(uk),dk=t=>t.nodes.map(r=>r.id),$u=t=>t instanceof Function?t:()=>t;function fk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:u=ck,onClick:d}){const f=Re(dk,Xe),g=$u(r),y=$u(t),m=$u(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:f.map(v=>p.jsx(pk,{id:v,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:u,onClick:d,shapeRendering:x},v))})}function hk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:d,NodeComponent:f,onClick:g}){const{node:y,x:m,y:x,width:v,height:_}=Re(k=>{const C=k.nodeLookup.get(t);if(!C)return{node:void 0,x:0,y:0,width:0,height:0};const S=C.internals.userNode,{x:E,y:I}=C.internals.positionAbsolute,{width:N,height:j}=rn(S);return{node:S,x:E,y:I,width:N,height:j}},Xe);return!y||y.hidden||!ag(y)?null:p.jsx(f,{x:m,y:x,width:v,height:_,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:d,onClick:g,id:y.id})}const pk=$.memo(hk);var gk=$.memo(fk);const mk=200,yk=150,vk=t=>!t.hidden,xk=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?og(To(t.nodeLookup,{filter:vk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},lp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,wk=(t,r)=>lp(t.viewBB,r.viewBB)&&lp(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,_k="react-flow__minimap-desc";function um({style:t,className:r,nodeStrokeColor:o,nodeColor:l,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:d,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:m,maskStrokeWidth:x,position:v="bottom-right",onClick:_,onNodeClick:k,pannable:C=!1,zoomable:S=!1,ariaLabel:E,inversePan:I,zoomStep:N=1,offsetScale:j=5}){const R=He(),T=$.useRef(null),{boundingRect:H,viewBB:G,rfId:K,panZoom:te,translateExtent:W,flowWidth:ee,flowHeight:J,ariaLabelConfig:b}=Re(xk,wk),Y=(t==null?void 0:t.width)??mk,V=(t==null?void 0:t.height)??yk,U=H.width/Y,D=H.height/V,z=Math.max(U,D),B=z*Y,M=z*V,L=j*z,ne=H.x-(B-H.width)/2-L,re=H.y-(M-H.height)/2-L,ce=B+L*2,fe=M+L*2,de=`${_k}-${K}`,q=$.useRef(0),se=$.useRef();q.current=z,$.useEffect(()=>{if(T.current&&te)return se.current=R1({domNode:T.current,panZoom:te,getTransform:()=>R.getState().transform,getViewScale:()=>q.current}),()=>{var ye;(ye=se.current)==null||ye.destroy()}},[te]),$.useEffect(()=>{var ye;(ye=se.current)==null||ye.update({translateExtent:W,width:ee,height:J,inversePan:I,pannable:C,zoomStep:N,zoomable:S})},[C,S,I,N,W,ee,J]);const pe=_?ye=>{var je;const[Ne,Pe]=((je=se.current)==null?void 0:je.pointer(ye))||[0,0];_(ye,{x:Ne,y:Pe})}:void 0,_e=k?$.useCallback((ye,Ne)=>{const Pe=R.getState().nodeLookup.get(Ne).internals.userNode;k(ye,Pe)},[]):void 0,me=E??b["minimap.ariaLabel"];return p.jsx(jl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*z: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:et(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:Y,height:V,viewBox:`${ne} ${re} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:T,onClick:pe,children:[me&&p.jsx("title",{id:de,children:me}),p.jsx(gk,{onClick:_e,nodeColor:l,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:f}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-L},${re-L}h${ce+L*2}v${fe+L*2}h${-ce-L*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}um.displayName="MiniMap";const Sk=$.memo(um),kk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ek={[ki.Line]:"right",[ki.Handle]:"bottom-right"};function Nk({nodeId:t,position:r,variant:o=ki.Handle,className:l,style:a=void 0,children:u,color:d,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:v,autoScale:_=!0,shouldResize:k,onResizeStart:C,onResize:S,onResizeEnd:E}){const I=Og(),N=typeof t=="string"?t:I,j=He(),R=$.useRef(null),T=o===ki.Handle,H=Re($.useCallback(kk(T&&_),[T,_]),Xe),G=$.useRef(null),K=r??Ek[o];$.useEffect(()=>{if(!(!R.current||!N))return G.current||(G.current=Y1({domNode:R.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,domNode:V}=j.getState();return{nodeLookup:W,transform:ee,snapGrid:J,snapToGrid:b,nodeOrigin:Y,paneDomNode:V}},onChange:(W,ee)=>{const{triggerNodeChanges:J,nodeLookup:b,parentLookup:Y,nodeOrigin:V}=j.getState(),U=[],D={x:W.x,y:W.y},z=b.get(N);if(z&&z.expandParent&&z.parentId){const B=z.origin??V,M=W.width??z.measured.width??0,L=W.height??z.measured.height??0,ne={id:z.id,parentId:z.parentId,rect:{width:M,height:L,...ug({x:W.x??z.position.x,y:W.y??z.position.y},{width:M,height:L},z.parentId,b,B)}},re=vc([ne],b,Y,V);U.push(...re),D.x=W.x?Math.max(B[0]*M,W.x):void 0,D.y=W.y?Math.max(B[1]*L,W.y):void 0}if(D.x!==void 0&&D.y!==void 0){const B={id:N,type:"position",position:{...D}};U.push(B)}if(W.width!==void 0&&W.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:W.width,height:W.height}};U.push(M)}for(const B of ee){const M={...B,type:"position"};U.push(M)}J(U)},onEnd:({width:W,height:ee})=>{const J={id:N,type:"dimensions",resizing:!1,dimensions:{width:W,height:ee}};j.getState().triggerNodeChanges([J])}})),G.current.update({controlPosition:K,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:m},keepAspectRatio:x,resizeDirection:v,onResizeStart:C,onResize:S,onResizeEnd:E,shouldResize:k}),()=>{var W;(W=G.current)==null||W.destroy()}},[K,f,g,y,m,x,C,S,E,k]);const te=K.split("-");return p.jsx("div",{className:et(["react-flow__resize-control","nodrag",...te,o,l]),ref:R,style:{...a,scale:H,...d&&{[T?"backgroundColor":"borderColor"]:d}},children:u})}$.memo(Nk);const Ck={"arch.context":0,"django.app":0,"django.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"django.serializer_field":5,"django.service":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"openapi.path":9,"react.api_client":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"react.component":13,"react.form_schema":14,"react.test":14,"react.context":13};function Il(t){return Ck[t]??8}const ec=208,tc=64,jk=88,bk=28,Mk=8;function Pk(t){if(!t.length)return Number.NaN;const r=[...t].sort((l,a)=>l-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Ik(t,r=[]){const o=new Map;if(!t.length)return o;const l=new Map;for(const C of t){const S=Il(C.type),E=l.get(S)??[];E.push(C),l.set(S,E)}const u=[...l.keys()].sort((C,S)=>C-S).map(C=>[...l.get(C)??[]].sort((S,E)=>S.name.localeCompare(E.name)||S.id.localeCompare(E.id))),d=new Set(t.map(C=>C.id)),f=new Map,g=new Map;for(const C of t)f.set(C.id,[]),g.set(C.id,[]);for(const C of r)!d.has(C.src)||!d.has(C.dst)||C.src===C.dst||(g.get(C.src).push(C.dst),f.get(C.dst).push(C.src));const y=new Map,m=()=>{for(const C of u)C.forEach((S,E)=>y.set(S.id,E))};m();const x=(C,S)=>{const E=C.map((I,N)=>{const j=S(I.id).map(T=>y.get(T)).filter(T=>T!==void 0),R=Pk(j);return{n:I,bary:Number.isNaN(R)?N:R,name:I.name,id:I.id}});return E.sort((I,N)=>I.bary-N.bary||I.name.localeCompare(N.name)||I.id.localeCompare(N.id)),E.map(I=>I.n)};for(let C=0;Cf.get(E)??[]),m();for(let S=u.length-2;S>=0;S--)u[S]=x(u[S],E=>g.get(E)??[]),m()}const v=ec+jk,_=tc+bk,k=Math.max(...u.map(C=>C.length),1);return u.forEach((C,S)=>{const E=(k-C.length)*_/2;C.forEach((I,N)=>{o.set(I.id,{x:S*v,y:E+N*_})})}),o}const cm=90,Tk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","django.url_name","django.throttle"]),ap={"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"},Rk=Math.PI*(3-Math.sqrt(5)),dm=220,Lk=26,Ak={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function fm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function mE(t){return ap[t]?ap[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function zk(t){return t>=cm?"3d":"2d"}function Dk(t){return t>=cm?"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(fm(f.type)));o.detail==="overview"&&(l=l.filter(f=>!Tk.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(g=>d.has(g.id));const f=new Set(l.map(g=>g.id));return{nodes:l,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:d}}return{nodes:l,edges:u,neighborIds:d}}function yE(t){const r=new Map;for(const l of t){const a=Il(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*dm;a.forEach((d,f)=>{if(a.length===1){o.set(d.id,{x:u,y:0,z:0});return}const g=Lk*Math.sqrt(f+1),y=f*Rk;o.set(d.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function vE(t){const r=new Map;for(const o of t){const l=Il(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*dm,count:l}))}const el=16,Fk=12,Hk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path"]),Bk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route"]),up={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Vk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to"},cp=["field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","relation","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],dp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Uk=new Set(["looks_idempotent_on_pk"]),Wk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Yk(t){return up[t]?up[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function Xk(t,r,o){const l=new Map(r.map(x=>[x.id,x])),a=[];Hk.has(t.type)&&a.push("sink"),Bk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const d=o.filter(x=>x.dst===t.id),f=o.filter(x=>x.src===t.id),g=d.slice(0,el).map(x=>fp(x,l,x.src)),y=f.slice(0,el).map(x=>fp(x,l,x.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0;return{type:t.type,typeLabel:yo(yl(t.type)),layer:Ak[Il(t.type)]??"other",purpose:Yk(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:Gk(u).filter(x=>!(x.key==="app"&&x.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,d.length-el),extraOutputs:Math.max(0,f.length-el)}}function fp(t,r,o){const l=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(l==null?void 0:l.name)||a,type:(l==null?void 0:l.type)||"",typeLabel:l?yo(yl(l.type)):"",edgeType:t.type,edgeLabel:yo(t.type),inferred:t.confidence<.8}}function Gk(t){const r=[...cp.filter(a=>a in t),...Object.keys(t).filter(a=>!cp.includes(a)&&!dp.has(a))],o=[],l=new Set;for(const a of r){if(l.has(a)||dp.has(a)||Wk.has(a))continue;l.add(a);const u=Qk(a,t[a]);u!=null&&o.push({key:a,label:Vk[a]??yo(a),value:u})}return o}function Qk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Uk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const l=o.slice(0,Fk),a=o.length-l.length;return a>0?`${l.join(", ")} +${a} more`:l.join(", ")}return null}const qk=new Set,Kk=$.lazy(()=>m0(()=>import("./LayeredGraph3D-B5oUhOgB.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),Zk={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Jk({data:t,selected:r}){return p.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[p.jsx(Ei,{type:"target",position:Se.Left,isConnectable:!1}),p.jsx("div",{className:"t",children:yl(t.type)}),p.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),p.jsx(Ei,{type:"source",position:Se.Right,isConnectable:!1})]})}const eE={load:Jk},tE=new Set(["django","react","stitch","arch"]);function nE({topologyKey:t}){const{fitView:r}=bl();return $.useEffect(()=>{let o=0;const l=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(o)}},[r,t]),null}function rE(t,r,o=null){const l=new Map(t.map(f=>[f.id,f])),a=Ik(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:ec,height:tc,style:{width:ec,height:tc}})),d=r.filter(f=>l.has(f.src)&&l.has(f.dst)).map(f=>{const g=Zk[f.weight]||"var(--edge-cheap)",y=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Eo.ArrowClosed,width:14,height:14,color:g},label:y?f.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:u,rfEdges:d}}function hp({node:t,nodes:r,edges:o,onClose:l}){const a=Xk(t,r,o);return $.useEffect(()=>{const u=d=>{d.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]),p.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[p.jsxs("div",{className:"inspector-head",children:[p.jsx("div",{className:"t",children:a.typeLabel}),p.jsx("div",{className:"inspector-roles",children:a.roles.map(u=>p.jsx("span",{className:"inspector-chip",children:u},u))}),p.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:l,children:"×"})]}),p.jsx("div",{className:"n",children:Mr(a.name)}),p.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:a.purpose}),a.context?p.jsx("div",{className:"muted",children:Mr(a.context)}):null,a.file?p.jsx("div",{className:"file",children:Mr(a.file)}):null,p.jsx("div",{className:"muted",children:Mr(a.qualifiedName)}),p.jsxs("div",{className:"muted inspector-layer",children:["layer · ",a.layer]}),a.facts.length?p.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:a.facts.map(u=>p.jsxs("div",{className:"inspector-fact",children:[p.jsx("dt",{children:u.label}),p.jsx("dd",{children:Mr(u.value)})]},u.key))}):null,p.jsx(pp,{title:"Inputs",testId:"graph-inspector-inputs",links:a.inputs,extra:a.extraInputs,empty:"Nothing in this graph points here."}),p.jsx(pp,{title:"Outputs",testId:"graph-inspector-outputs",links:a.outputs,extra:a.extraOutputs,empty:"This node does not point at anything in this graph."})]})}function pp({title:t,testId:r,links:o,extra:l,empty:a}){return p.jsxs("section",{className:"inspector-section","data-testid":r,children:[p.jsxs("h3",{children:[t,p.jsx("span",{className:"count",children:o.length+l})]}),o.length?p.jsx("ul",{children:o.map((u,d)=>p.jsxs("li",{children:[p.jsx("span",{className:"inspector-link-name",title:u.name,children:Mr(u.name)}),p.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${d}`))}):p.jsx("p",{className:"muted",children:a}),l?p.jsxs("p",{className:"muted",children:["+",l," more"]}):null]})}function Ou({nodes:t,edges:r}){const[o,l]=$.useState(null),[a,u]=$.useState(null),[d,f]=$.useState(null),[g,y]=$.useState(new Set(tE)),[m,x]=$.useState(!1),v=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,_=a??zk(t.length),k=d??Dk(t.length),C=m&&_==="3d"?o:null,S=$.useMemo(()=>Ok(t,r,{detail:k,families:g,focusId:C,neighborhoodOnly:!!C}),[t,r,k,g,C]),E=$.useMemo(()=>`${S.nodes.map(W=>W.id).join("\0")}|${S.edges.map(W=>W.id).join("\0")}`,[S.nodes,S.edges]),I=$.useMemo(()=>new Map(S.nodes.map(W=>[W.id,W])),[S.nodes]),N=o?I.get(o)??null:null,{rfNodes:j,rfEdges:R}=$.useMemo(()=>{const W=rE(S.nodes,S.edges,o);return v&&(W.rfEdges=W.rfEdges.map(ee=>({...ee,animated:!1}))),W},[S.nodes,S.edges,o,v]);$.useEffect(()=>{o&&!I.has(o)&&l(null)},[I,o]);const T=(W,ee)=>{l(ee.id)},H=()=>{l(null),x(!1)},G=W=>{y(ee=>{const J=new Set(ee);if(J.has(W)){if(J.size===1)return ee;J.delete(W)}else J.add(W);return J})},K=$.useMemo(()=>{const W=new Set;for(const ee of t)W.add(fm(ee.type));return W},[t]),te=t.length-S.nodes.length;return p.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[p.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[p.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[p.jsx("button",{type:"button","data-testid":"graph-view-2d",className:_==="2d"?"active":"","aria-pressed":_==="2d",onClick:()=>u("2d"),children:"2D map"}),p.jsx("button",{type:"button","data-testid":"graph-view-3d",className:_==="3d"?"active":"","aria-pressed":_==="3d",onClick:()=>u("3d"),children:"3D layers"})]}),p.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[p.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:k==="overview"?"active":"","aria-pressed":k==="overview",onClick:()=>f("overview"),children:"Overview"}),p.jsx("button",{type:"button","data-testid":"graph-detail-full",className:k==="full"?"active":"","aria-pressed":k==="full",onClick:()=>f("full"),children:"Full"})]}),p.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(W=>K.has(W)).map(W=>p.jsx("button",{type:"button","data-testid":`graph-family-${W}`,className:g.has(W)?"active":"","aria-pressed":g.has(W),onClick:()=>G(W),children:W},W))}),_==="3d"?p.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!o,onClick:()=>x(W=>!W),children:m?"Neighborhood":"Focus neighbors"}):null,p.jsxs("span",{className:"muted graph-count",children:[S.nodes.length," nodes · ",S.edges.length," edges",te?` · ${te} hidden`:""]})]}),p.jsx("div",{className:"graph-stage",children:_==="3d"?p.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[p.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."}),p.jsx($.Suspense,{fallback:p.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:p.jsx(Kk,{nodes:S.nodes,edges:S.edges,selectedId:o,neighborIds:C?S.neighborIds:qk,onSelect:W=>{l(W),W||x(!1)}})}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]}):p.jsxs(sm,{children:[p.jsxs(qS,{nodes:j,edges:R,nodeTypes:eE,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:H,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[p.jsx(nE,{topologyKey:E}),p.jsx(tk,{}),p.jsx(Sk,{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}}),p.jsx(ak,{})]}),N?p.jsx(hp,{node:N,nodes:t,edges:r,onClose:H}):null]})})]})}const gp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],iE=["preset","branch","tag","commit"];function oE(t){var a;if(!(t!=null&&t.git))return[...gp];const r=((a=t.presets)!=null&&a.length?t.presets:gp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),l=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),l.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),l.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return l}function sE(t,r){const o=r.trim().toLowerCase();return o?t.filter(l=>l.value.toLowerCase().includes(o)||l.label.toLowerCase().includes(o)||(l.detail||"").toLowerCase().includes(o)):t}function lE(t){return iE.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function aE(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function mp({value:t,onChange:r,placeholder:o,testId:l,menuTestId:a,refs:u,onNeedRefs:d}){const f=$.useId(),g=$.useRef(null),[y,m]=$.useState(!1),[x,v]=$.useState(null),[_,k]=$.useState(0),C=$.useMemo(()=>{const j=oE(u);return x===null?j:sE(j,x)},[u,x]),S=$.useMemo(()=>lE(C),[C]);$.useEffect(()=>{y&&d()},[y,d]),$.useEffect(()=>{k(0)},[x,y]);const E=()=>{m(!1),v(null)},I=j=>{r(j.value),E()},N=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){m(!0);return}k(R=>Math.min(R+1,Math.max(C.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k(R=>Math.max(R-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const R=C[_];R&&I(R)}else j.key==="Escape"&&y&&(j.preventDefault(),E())};return p.jsxs("div",{className:"combo",ref:g,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||E()},children:[p.jsxs("div",{className:"combo-row",children:[p.jsx("input",{"data-testid":l,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&v(j.target.value)},onKeyDown:N}),p.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${l}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?E():m(!0),children:p.jsx(h0,{})})]}),y?p.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:S.length===0?p.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):S.map(j=>p.jsxs("div",{className:"combo-group",children:[p.jsx("div",{className:"combo-heading",children:aE(j.group)}),j.items.map(R=>{const T=C.indexOf(R);return p.jsxs("button",{type:"button",role:"option","aria-selected":T===_,className:T===_?"combo-option active":"combo-option","data-testid":`ref-option-${R.group}`,onMouseDown:H=>H.preventDefault(),onMouseEnter:()=>k(T),onClick:()=>I(R),children:[p.jsx("span",{className:"combo-label",children:R.label}),R.detail?p.jsx("span",{className:"combo-detail",children:R.detail}):null]},`${R.group}:${R.value}`)})]},j.group))}):null]})}function uE({initialPath:t,onSelect:r,onClose:o}){const[l,a]=$.useState(null),[u,d]=$.useState(t),[f,g]=$.useState(null),[y,m]=$.useState(""),[x,v]=$.useState(!1),_=$.useRef(null),k=$.useRef(0),C=async N=>{const j=k.current+1;k.current=j,v(!0);try{const R=await Ve.browse(N);if(k.current!==j)return;a(R),d(R.path),g(R.is_git?R.path:null),m("")}catch(R){if(k.current!==j)return;m(R instanceof Error?R.message:String(R))}finally{k.current===j&&v(!1)}};$.useEffect(()=>{var N,j;C(t),(N=_.current)==null||N.focus(),(j=_.current)==null||j.select()},[t]);const S=f||(l==null?void 0:l.path)||u,E=f&&f!==(l==null?void 0:l.path)?f.split(/[\\/]/).filter(Boolean).pop():l!=null&&l.is_git?"this repository":"this folder",I=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return p.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:I,children:p.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[p.jsxs("div",{className:"modal-head",children:[p.jsxs("div",{children:[p.jsx("h2",{id:"explorer-title",children:"Select repository"}),p.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),p.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),p.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),C(u)},children:[p.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:N=>d(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),p.jsx("button",{type:"button",className:"btn",disabled:!(l!=null&&l.parent),onClick:()=>(l==null?void 0:l.parent)&&void C(l.parent),children:"Up"}),p.jsx("button",{type:"button",className:"btn",onClick:()=>l&&void C(l.home),children:"Home"}),p.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?p.jsx("div",{className:"error",role:"alert",children:y}):null,p.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:l!=null&&l.entries.length?l.entries.map(N=>{const j=f===N.path;return p.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void C(N.path),children:[p.jsx(_p,{}),p.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?p.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):p.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),p.jsxs("div",{className:"modal-foot",children:[p.jsx("span",{className:"muted explorer-current",title:S,children:S}),p.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!S,onClick:()=>S&&r(S),children:["Use ",E]})]})]})})}const ml=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],cE="obsidian",hm="loadpath.theme";function dE(t){return ml.some(r=>r.id===t)}function pm(){try{const t=localStorage.getItem(hm)||"";if(dE(t))return t}catch{}return cE}function fE(t){var r;return((r=ml.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function gm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=fE(t);try{localStorage.setItem(hm,t)}catch{}}const yp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:a0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:u0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:c0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:d0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:f0}];function vp(t,r,o){let l;try{l=new URL(t)}catch{return}if(l.protocol!=="https:"||l.username||l.password)return;const a=l.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||l.pathname.startsWith(o)&&window.open(l.toString(),"_blank","noopener,noreferrer")}function hE(){var lr,ar,ur,cr,dr,Tn,fr;const[t,r]=$.useState("review"),[o,l]=$.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=$.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[d,f]=$.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=$.useState(null),[m,x]=$.useState(null),[v,_]=$.useState([]),[k,C]=$.useState("review"),[S,E]=$.useState(""),[I,N]=$.useState(""),[j,R]=$.useState(""),[T,H]=$.useState({}),[G,K]=$.useState([]),[te,W]=$.useState([]),[ee,J]=$.useState(localStorage.getItem("loadpath.scmRepo")||""),[b,Y]=$.useState(localStorage.getItem("loadpath.provider")||"github"),[V,U]=$.useState(localStorage.getItem("loadpath.prNumber")||""),[D,z]=$.useState(""),[B,M]=$.useState(pm),[L,ne]=$.useState(!1),[re,ce]=$.useState(!1),[fe,de]=$.useState(null),[q,se]=$.useState(null),[pe,_e]=$.useState(!1),me=$.useRef(o);me.current=o;const ye=$.useRef(!1);ye.current=re;const Ne=$.useRef(""),Pe=F=>{M(F),gm(F)},je=$.useRef(""),Me=F=>{je.current=F,N(F)};$.useEffect(()=>{Ve.settings().then(H).catch(()=>{}).finally(()=>ne(!0)),Ve.repos().then(F=>_(F.repos)).catch(()=>{})},[]);const tt=()=>o.trim()?!0:(E("Point at a local repository path first."),!1);$.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const F=o;let ae=!1;return Ve.architecture(F).then(be=>{!ae&&me.current===F&&x(be)}).catch(()=>{}),()=>{ae=!0}},[t,o]);const Ge=F=>{l(F),localStorage.setItem("loadpath.repo",F),F.trim()!==Ne.current&&(Ne.current="",de(null))},nt=$.useCallback(()=>{const F=me.current.trim();!F||Ne.current===F||(Ne.current=F,Ve.gitRefs(F).then(ae=>{me.current.trim()===F&&de(ae)}).catch(()=>{Ne.current===F&&(Ne.current="",de(null))}))},[]),qe=(F,ae)=>{u(F),f(ae),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",ae)},bt=(F,ae,be)=>{Y(F),J(ae),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",ae),be!==void 0&&(U(be),localStorage.setItem("loadpath.prNumber",be))},Dt=F=>F==="github"?!!T.github_token_set:!!T.bitbucket_token_set,ot=$.useCallback(async(F=b)=>{var ae;try{const be=await Ve.scmRepos(F);W(be.repos),(ae=be.user)!=null&&ae.login&&H($e=>({...$e,...F==="github"?{github_user:be.user.login}:{bitbucket_user:be.user.login}}))}catch{W([])}},[b]);$.useEffect(()=>{if(t!=="prs")return;let F=!1;return ot(b).catch(()=>{F||W([])}),()=>{F=!0}},[t,b,ot]),$.useEffect(()=>{if(!q)return;let F=!1,ae=0;const be=async()=>{try{const $e=await Ve.githubOAuthPoll(q.flow_id);if(F)return;if($e.status==="complete"){se(null);const ze=await Ve.settings();H(ze),R($e.user?`Signed in to GitHub as ${$e.user}`:"Signed in to GitHub"),ot("github");return}if($e.status==="pending"||$e.status==="slow_down"){ae=window.setTimeout(be,Math.max($e.interval||q.interval,5)*1e3);return}se(null),E($e.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch($e){if(F)return;se(null),E($e instanceof Error?$e.message:String($e))}};return ae=window.setTimeout(be,Math.max(q.interval,5)*1e3),()=>{F=!0,window.clearTimeout(ae)}},[q,ot]),$.useEffect(()=>{if(!pe)return;let F=!1,ae=0;const be=Date.now(),$e=async()=>{try{const ze=await Ve.oauthStatus();if(F)return;if(ze.bitbucket.connected){_e(!1);const Rn=await Ve.settings();H(Rn),R(ze.bitbucket.user?`Signed in to Bitbucket as ${ze.bitbucket.user}`:"Signed in to Bitbucket"),ot("bitbucket");return}if(Date.now()-be>18e4){_e(!1),E("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}ae=window.setTimeout($e,1500)}catch(ze){if(F)return;_e(!1),E(ze instanceof Error?ze.message:String(ze))}};return ae=window.setTimeout($e,1500),()=>{F=!0,window.clearTimeout(ae)}},[pe,ot]);const ut=async(F=o)=>{if(!F.trim())return null;const ae=await Ve.architecture(F);return me.current===F&&x(ae),ae},ct=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Tracing load path…"),Ge(o),qe(a,d);try{const F=await Ve.review(o,a,d,!0);y(F),C("review"),r("review"),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{}),await ut(o)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},ht=async(F=!0)=>{if(!je.current&&tt()){E(""),R(""),Me(F?"Indexing…":"Full reindex…"),Ge(o);try{await Ve.index(o,F);const ae=await ut(o);await Ve.repos().then(be=>_(be.repos)).catch(()=>{}),ae!=null&&ae.indexed&&(C("architecture"),r("architecture"))}catch(ae){E(ae instanceof Error?ae.message:String(ae))}finally{Me("")}}},wt=async()=>{if(!je.current&&tt()){E(""),R(""),Me("Detecting layout…"),Ge(o);try{const F=await Ve.init(o);R(F.message),await Ve.repos().then(ae=>_(ae.repos)).catch(()=>{})}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Mn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),R("Copied markdown brief")}catch(F){E(F instanceof Error?F.message:String(F))}},Ut=async()=>{if(!je.current){if(!(g!=null&&g.markdown)||!ee||!V){E("Pick a pull request first (Pull requests tab), then post the brief.");return}Me("Posting Loadpath brief…");try{const F=await Ve.postComment(b,ee,Number(V),g.markdown);R(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},gn=async()=>{if(!je.current){E(""),Me("Fetching pull requests…");try{const F=await Ve.prs(b,ee);K(F.pull_requests);const ae=te.find(be=>be.slug.toLowerCase()===ee.trim().toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Ni=async()=>{E("");try{const F=await Ve.githubOAuthStart();se(F),vp(F.verification_uri_complete,"github.com","/login/device")}catch(F){E(F instanceof Error?F.message:String(F))}},Or=async()=>{E("");try{const F=await Ve.bitbucketOAuthStart();_e(!0),vp(F.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(F){_e(!1),E(F instanceof Error?F.message:String(F))}},ir=async F=>{E("");try{H(await Ve.oauthDisconnect(F)),b===F&&W([]),R(`Disconnected ${F}`)}catch(ae){E(ae instanceof Error?ae.message:String(ae))}},Ci=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),be={github_token:String(ae.get("github_token")||""),github_oauth_client_id:String(ae.get("github_oauth_client_id")||""),bitbucket_token:String(ae.get("bitbucket_token")||""),bitbucket_username:String(ae.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(ae.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(ae.get("bitbucket_oauth_client_secret")||""),ai_provider:String(ae.get("ai_provider")||"none"),ai_api_key:String(ae.get("ai_api_key")||""),ai_model:String(ae.get("ai_model")||""),ai_base_url:String(ae.get("ai_base_url")||"")},$e=v.length?{...be,workspaces:v.map(ze=>({path:ze.path,name:ze.name}))}:be;try{H(await Ve.saveSettings($e)),R("Settings saved on this machine")}catch(ze){E(ze instanceof Error?ze.message:String(ze))}},or=async()=>{if(!(!g||je.current)){Me("Residual analysis…");try{const F=await Ve.residual(g);z(F.note)}catch(F){E(F instanceof Error?F.message:String(F))}finally{Me("")}}},Pn=$.useRef(ct);Pn.current=ct;const mn=$.useRef(t);mn.current=t,$.useEffect(()=>{const F=ae=>{if(ye.current){ae.key==="Escape"&&(ae.preventDefault(),ce(!1));return}const be=ae.target;if(be&&(be.tagName==="INPUT"||be.tagName==="TEXTAREA"||be.tagName==="SELECT"||be.isContentEditable)){ae.key==="Escape"&&be.blur();return}if(ae.key==="Escape"){E(""),R("");return}const $e=yp.find(ze=>ze.shortcut===ae.key);if($e&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&r($e.id),(ae.metaKey||ae.ctrlKey)&&ae.key==="Enter"){if(mn.current==="settings"||mn.current==="prs"||je.current)return;ae.preventDefault(),Pn.current()}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const In=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,m,g]),sr=$.useMemo(()=>k==="architecture"?(m==null?void 0:m.edges)??[]:(g==null?void 0:g.edges)??[],[k,m,g]),on=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",sn=((g==null?void 0:g.findings)||[]).filter(F=>!F.waived);return p.jsxs("div",{className:"app",children:[p.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),p.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[p.jsxs("div",{className:"brand",children:[p.jsx("div",{className:"brand-mark",children:"Loadpath"}),p.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),yp.map(F=>{const ae=F.icon,be=t===F.id;return p.jsxs("button",{type:"button","data-testid":F.testId,className:be?"nav-item active":"nav-item","aria-current":be?"page":void 0,"aria-label":F.label,onClick:()=>r(F.id),children:[p.jsx(ae,{}),p.jsx("span",{children:F.label})]},F.id)}),p.jsxs("div",{className:"theme-pick",children:[p.jsx("label",{htmlFor:"theme-select",children:"Theme"}),p.jsx("select",{id:"theme-select","data-testid":"theme-select",value:B,onChange:F=>Pe(F.target.value),children:["dark","light"].map(F=>p.jsx("optgroup",{label:F==="dark"?"Dark":"Light",children:ml.filter(ae=>ae.group===F).map(ae=>p.jsx("option",{value:ae.id,children:ae.label},ae.id))},F))})]}),p.jsxs("div",{className:"rail-foot",children:[p.jsx("div",{className:"muted",role:"status",children:I||on}),p.jsxs("div",{className:"kbd-hint",children:[p.jsx("kbd",{children:"1"}),"–",p.jsx("kbd",{children:"5"})," tabs · ",p.jsx("kbd",{children:"Ctrl"}),"+",p.jsx("kbd",{children:"Enter"})," review"]})]})]}),p.jsxs("div",{className:"main",id:"main",children:[I?p.jsxs("div",{className:"progress",role:"status","aria-live":"polite","aria-busy":"true",children:[p.jsx("i",{}),p.jsx("span",{className:"sr-only",children:I})]}):null,p.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?p.jsxs("label",{className:"field workspace",children:[p.jsx("span",{children:"Workspace"}),p.jsxs("select",{"data-testid":"workspace-select",value:v.some(F=>F.path===o)?o:"",onChange:F=>{F.target.value&&Ge(F.target.value)},children:[p.jsx("option",{value:"",children:"Indexed repos…"}),v.map(F=>p.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]})]}):null,p.jsxs("label",{className:"field path",children:[p.jsx("span",{children:"Repository"}),p.jsxs("div",{className:"path-row",children:[p.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:F=>{const ae=F.target.value;l(ae),ae.trim()!==Ne.current&&(Ne.current="",de(null))},spellCheck:!1}),p.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ce(!0),children:p.jsx(_p,{})})]})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Base"}),p.jsx(mp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:F=>qe(F,d),placeholder:"base",refs:fe,onNeedRefs:nt})]}),p.jsxs("label",{className:"field ref",children:[p.jsx("span",{children:"Head"}),p.jsx(mp,{testId:"head-ref",menuTestId:"head-ref-menu",value:d,onChange:F=>qe(a,F),placeholder:"head",refs:fe,onNeedRefs:nt})]}),p.jsxs("div",{className:"topbar-actions",children:[p.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!I,onClick:wt,children:"Draft config"}),p.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!I,onClick:()=>ht(!0),children:"Index"}),p.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!I,onClick:ct,children:"Review"})]})]}),p.jsxs("div",{className:"alerts",children:[S?p.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[p.jsx("span",{children:S}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>E(""),"aria-label":"Dismiss error",children:"×"})]}):null,j?p.jsxs("div",{className:"banner","data-testid":"status-note",children:[p.jsx("span",{children:j}),p.jsx("button",{type:"button",className:"dismiss",onClick:()=>R(""),"aria-label":"Dismiss",children:"×"})]}):null,((lr=g==null?void 0:g.index)!=null&&lr.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?p.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,((ar=g==null?void 0:g.index)==null?void 0:ar.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?p.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ur=g==null?void 0:g.index)==null?void 0:ur.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(cr=g==null?void 0:g.workspace)!=null&&cr.dirty_overlaps_review&&t==="review"?p.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),p.jsxs("div",{className:"stage",children:[t==="review"&&p.jsxs("div",{className:"content","data-testid":"review-layout",children:[p.jsx("aside",{className:"brief","data-testid":"brief",children:g?p.jsx(pE,{review:g,findings:sn,aiNote:D,busy:!!I,onAskAi:or,onCopy:Mn,onPost:Ut}):p.jsxs("div",{className:"empty","data-testid":"review-empty",children:[p.jsx("h2",{children:"Trace the force of this diff"}),p.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),p.jsxs("ol",{children:[p.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),p.jsxs("li",{children:["Index it. Missing ",p.jsx("code",{children:"loadpath.yml"})," is drafted from ",p.jsx("code",{children:"manage.py"})," and"," ",p.jsx("code",{children:"src/features"}),"."]}),p.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),p.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?p.jsx(Ou,{nodes:g.nodes,edges:g.edges}):null})]}),t==="architecture"&&p.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[p.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?p.jsx(gE,{architecture:m,busy:!!I,onReindex:()=>ht(!1),onReview:ct}):p.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."})}),p.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:m!=null&&m.indexed?p.jsx(Ou,{nodes:m.nodes,edges:m.edges}):null})]}),t==="graph"&&p.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[p.jsxs("div",{className:"graph-modes",children:[p.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[p.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>C("review"),children:"This review"}),p.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>C("architecture"),children:"Indexed architecture"})]}),p.jsxs("div",{className:"legend","aria-hidden":"true",children:[p.jsxs("span",{children:[p.jsx("i",{})," cheap"]}),p.jsxs("span",{children:[p.jsx("i",{className:"exp"})," expensive"]}),p.jsxs("span",{children:[p.jsx("i",{className:"crit"})," critical"]}),p.jsxs("span",{children:[p.jsx("i",{className:"dash"})," inferred"]})]})]}),In.length?p.jsx(Ou,{nodes:In,edges:sr}):p.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"&&p.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[p.jsxs("div",{className:"pr-toolbar",children:[p.jsxs("label",{className:"field provider",children:[p.jsx("span",{children:"Provider"}),p.jsxs("select",{"data-testid":"pr-provider",value:b,onChange:F=>bt(F.target.value,ee,V),children:[p.jsx("option",{value:"github",children:"GitHub"}),p.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),p.jsxs("label",{className:"field",children:[p.jsx("span",{children:"Repository"}),p.jsx("input",{"data-testid":"pr-repo",placeholder:te.length?"Search your repos":"owner/repo",value:ee,onChange:F=>bt(b,F.target.value,V),list:"scm-repos",spellCheck:!1}),p.jsx("datalist",{id:"scm-repos",children:te.map(F=>p.jsxs("option",{value:F.slug,children:[F.private?"private":"public",F.local_path?" · local":""]},F.slug))})]}),p.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!I||!Dt(b),onClick:()=>{ot(b)},children:"My repos"}),p.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!I,onClick:gn,children:"List PRs"})]}),te.length>0?p.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[te.length," ",b," repositor",te.length===1?"y":"ies",b==="github"&&T.github_user?` · @${String(T.github_user)}`:"",b==="bitbucket"&&T.bitbucket_user?` · ${String(T.bitbucket_user)}`:""]}):null,G.length===0?p.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[p.jsx("h2",{children:"No pull requests loaded"}),p.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):G.map(F=>p.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[p.jsxs("h3",{children:["#",F.number," ",F.title]}),p.jsxs("div",{className:"pr-meta muted",children:[p.jsx("span",{className:`chip ${F.draft?"":"open"}`,children:F.draft?"draft":F.state}),p.jsx("span",{children:F.author}),p.jsxs("span",{children:[F.source_branch," → ",F.target_branch]})]}),p.jsxs("div",{className:"pr-actions",children:[p.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),p.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${F.number}`,onClick:()=>{qe(F.base_sha||F.target_branch,F.head_sha||F.source_branch),bt(F.provider,F.repo,String(F.number));const ae=te.find(be=>be.slug.toLowerCase()===F.repo.toLowerCase());ae!=null&&ae.local_path&&Ge(ae.local_path),r("review")},children:"Review this range"})]})]},`${F.provider}-${F.number}`))]}),t==="settings"&&L&&p.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Ci,children:[p.jsxs("div",{children:[p.jsx("h1",{children:"Settings"}),p.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."})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Appearance"}),p.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),p.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:ml.map(F=>p.jsxs("button",{type:"button","data-theme":F.id,className:B===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>Pe(F.id),children:[p.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),p.jsx("div",{className:"name",children:F.label}),p.jsx("div",{className:"group",children:F.group})]},F.id))})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Source control"}),p.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),p.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"GitHub"}),p.jsx("p",{className:"muted",children:T.github_token_set?T.github_user?`Signed in as @${String(T.github_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.github_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void ir("github"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!q||!T.github_oauth_ready,onClick:()=>void Ni(),children:q?"Waiting for GitHub…":"Sign in with GitHub"})})]}),q?p.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",p.jsx("code",{children:q.user_code})," at GitHub if the browser did not fill it in."]}):null,T.github_oauth_ready?null:p.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),p.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),p.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(T.github_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),p.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),p.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Bitbucket"}),p.jsx("p",{className:"muted",children:T.bitbucket_token_set?T.bitbucket_user?`Signed in as ${String(T.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),p.jsx("div",{className:"btn-row",children:T.bitbucket_token_set?p.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void ir("bitbucket"),children:"Disconnect"}):p.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:pe||!T.bitbucket_oauth_ready,onClick:()=>void Or(),children:pe?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),T.bitbucket_oauth_ready?null:p.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",p.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),p.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(T.bitbucket_oauth_client_id||""),autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),p.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),p.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),p.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(T.bitbucket_username||"")})]}),p.jsxs("section",{className:"settings-card",children:[p.jsx("h2",{children:"Residual AI"}),p.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),p.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((dr=T.ai)==null?void 0:dr.provider)||"none"),children:[p.jsx("option",{value:"none",children:"none (graph only)"}),p.jsx("option",{value:"anthropic",children:"Anthropic"}),p.jsx("option",{value:"openai",children:"OpenAI"}),p.jsx("option",{value:"grok",children:"Grok / xAI"}),p.jsx("option",{value:"deepseek",children:"DeepSeek"}),p.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),p.jsx("option",{value:"ollama",children:"Ollama local"})]}),p.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),p.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),p.jsx("label",{htmlFor:"ai_model",children:"Model"}),p.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((Tn=T.ai)==null?void 0:Tn.model)||"")}),p.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),p.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((fr=T.ai)==null?void 0:fr.base_url)||"")}),p.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),re?p.jsx(uE,{initialPath:o,onClose:()=>ce(!1),onSelect:F=>{Ge(F),ce(!1)}}):null]})}function pE({review:t,findings:r,aiNote:o,busy:l,onAskAi:a,onCopy:u,onPost:d}){var g,y,m,x,v,_,k,C;const f=[...new Set(t.confidence.reasons||[])];return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[p.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),f.length?p.jsx("ul",{className:"reasons",children:f.map(S=>p.jsx("li",{children:S},S))}):null,t.low_risk?p.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(S=>p.jsx("span",{className:"chip",children:yo(S)},S))]}),p.jsxs("div",{className:"metrics",children:[p.jsxs("div",{className:"metric",children:[p.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),p.jsx("div",{className:"l",children:"Sinks tested"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:r.length}),p.jsx("div",{className:"l",children:"Findings"})]}),p.jsxs("div",{className:"metric",children:[p.jsx("div",{className:"n",children:t.residuals.length}),p.jsx("div",{className:"l",children:"Residuals"})]})]}),p.jsx("pre",{className:"headline",children:t.headline}),t.index?p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Index ",p.jsx("span",{className:"count",children:t.index.counts.nodes})]}),p.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}`:"",(g=t.workspace)!=null&&g.three_dot?" · three-dot range":""]})]}):null,p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Read this ",p.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((S,E)=>p.jsxs("div",{className:"read-item",children:[p.jsxs("span",{className:"file",children:[E+1,". ",S.path]}),p.jsx("div",{className:"why",children:S.why})]},S.path))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Clusters ",p.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:S.title})," — ",S.files.join(", ")]},S.id))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Architecture ",p.jsx("span",{className:"count",children:r.length})]}),r.length===0?p.jsx("div",{className:"muted",children:t.architecture_note}):r.map(S=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${S.severity}`,children:S.severity}),S.message]},S.rule+S.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Residual ",p.jsx("span",{className:"count",children:t.residuals.length})]}),p.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(S=>p.jsx("div",{className:"residual muted",children:S},S))]}),(m=(y=t.evolution)==null?void 0:y.notes)!=null&&m.length||(v=(x=t.evolution)==null?void 0:x.hotspots)!=null&&v.some(S=>S.commits)?p.jsxs("details",{className:"section",children:[p.jsx("summary",{children:"Churn & coupling"}),(((_=t.evolution)==null?void 0:_.notes)||[]).map(S=>p.jsx("div",{className:"muted",children:S},S)),(((k=t.evolution)==null?void 0:k.hotspots)||[]).filter(S=>S.commits).slice(0,6).map(S=>p.jsxs("div",{className:"muted",children:[p.jsx("span",{className:"file",children:S.path})," — ",S.commits," commits, bus factor ",S.bus_factor]},S.path))]}):null,p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:l,onClick:a,children:"Ask configured model"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:u,children:"Copy markdown"}),p.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:d,children:"Post to PR"})]}),o?p.jsx("pre",{className:"headline",children:o}):null,p.jsx("div",{className:"kicker",children:"Reviewers"}),p.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(C=t.knowledge_owners)!=null&&C.length?p.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function gE({architecture:t,busy:r,onReindex:o,onReview:l}){const a=t.findings.filter(u=>!u.waived);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"merge-box high",children:[p.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),p.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${l0(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),p.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?p.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>p.jsxs("div",{className:"muted",children:[p.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),p.jsxs("details",{className:"section",children:[p.jsxs("summary",{children:["Rules ",p.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>p.jsx("div",{className:"muted",children:u},u))]}),p.jsxs("details",{className:"section",open:!0,children:[p.jsxs("summary",{children:["Findings ",p.jsx("span",{className:"count",children:a.length})]}),a.length===0?p.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>p.jsxs("div",{className:"finding",children:[p.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),p.jsx(mm,{cards:t.deepening}),p.jsxs("details",{className:"section",open:!0,children:[p.jsx("summary",{children:"Types"}),p.jsx("table",{className:"type-table",children:p.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,d)=>d[1]-u[1]).slice(0,12).map(([u,d])=>p.jsxs("tr",{children:[p.jsx("td",{children:yl(u)}),p.jsx("td",{children:d})]},u))})})]}),p.jsxs("div",{className:"btn-row",children:[p.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),p.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:l,children:"Review against this index"})]})]})}function mm({cards:t}){const r=t||[];return r.length?p.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[p.jsxs("summary",{children:["Depth ",p.jsx("span",{className:"count",children:r.length})]}),p.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>p.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[p.jsx("span",{className:`chip ${o.strength}`,children:s0(o.strength)}),o.top?p.jsx("span",{className:"chip",children:"top"}):null,p.jsx("strong",{children:o.title}),p.jsx("div",{className:"why",children:o.message}),o.deletion_test?p.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?p.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}gm(pm());r0.createRoot(document.getElementById("root")).render(p.jsx($.StrictMode,{children:p.jsx(hE,{})}));export{Ak as L,vE as a,mE as c,p as j,yE as l,$ as r,yl as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 385e27d..a6f3a24 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index b78fa60..7bffc3e 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -1,5 +1,7 @@ from __future__ import annotations +import shutil + import pytest @@ -332,3 +334,56 @@ def test_ui_oauth_login_and_remote_repo_list(live_app, browser_page): page.get_by_test_id("btn-github-login").click() page.get_by_test_id("github-user-code").wait_for() assert "WXYZ-9876" in page.get_by_test_id("github-user-code").inner_text() + + +def _index_repo(page, repo) -> None: + page.get_by_test_id("repo-path").fill(str(repo)) + with page.expect_response( + lambda r: "/api/index" in r.url and r.request.method == "POST", + timeout=60_000, + ) as pending: + page.get_by_test_id("btn-index").click() + page.locator(".progress").wait_for(timeout=5_000) + if not pending.value.ok: + pytest.fail(f"index API {pending.value.status}: {pending.value.text()}") + page.wait_for_function("() => !document.querySelector('[data-testid=\"btn-index\"]')?.disabled") + + +@pytest.mark.playwright +def test_ui_workspace_switch_shows_loading(live_app, browser_page): + base_url, repo = live_app + other = repo.parent / "other-billing" + shutil.copytree(repo, other) + page = browser_page + page.goto(base_url, wait_until="networkidle") + _wait_fonts(page) + + _index_repo(page, repo) + _index_repo(page, other) + page.get_by_test_id("workspace-select").wait_for() + assert page.get_by_test_id("workspace-select").input_value() == str(other) + page.get_by_test_id("tab-review").click() + page.get_by_test_id("review-empty").wait_for() + + page.evaluate( + """() => { + const orig = window.fetch; + window.fetch = async (input, init) => { + const url = String(typeof input === "string" ? input : input.url); + if (url.includes("/api/architecture")) { + await new Promise((resolve) => setTimeout(resolve, 800)); + } + return orig.call(window, input, init); + }; + }""" + ) + + page.get_by_test_id("workspace-select").select_option(value=str(repo)) + loading = page.get_by_test_id("workspace-loading") + loading.wait_for(timeout=5_000) + assert "loading" in loading.inner_text().lower() + page.get_by_test_id("progress").wait_for() + loading.wait_for(state="hidden", timeout=15_000) + assert page.get_by_test_id("workspace-select").input_value() == str(repo) + page.get_by_test_id("review-empty").wait_for() + diff --git a/ui/src/App.tsx b/ui/src/App.tsx index c087e15..cc560fb 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useMemo, useRef, useState, type FormEvent } from "react"; import { api } from "./api"; -import { formatWhen, kindLabel, strengthLabel, typeLabel } from "./format"; +import { formatWhen, kindLabel, repoName, strengthLabel, typeLabel } from "./format"; import { IconArchitecture, IconFolder, IconGraph, IconPrs, IconReview, IconSettings } from "./icons"; import { ImpactGraph } from "./ImpactGraph"; import { RefCombobox } from "./RefCombobox"; @@ -113,6 +113,7 @@ export function App() { }, [tab, repo]); const persistRepo = (path: string) => { + repoRef.current = path; setRepo(path); localStorage.setItem("loadpath.repo", path); if (path.trim() !== gitRefsPath.current) { @@ -121,11 +122,11 @@ export function App() { } }; - const loadGitRefs = useCallback(() => { - const path = repoRef.current.trim(); - if (!path || gitRefsPath.current === path) return; + const loadGitRefs = useCallback((explicitPath?: string) => { + const path = (explicitPath ?? repoRef.current).trim(); + if (!path || gitRefsPath.current === path) return Promise.resolve(); gitRefsPath.current = path; - api + return api .gitRefs(path) .then((next) => { if (repoRef.current.trim() === path) setGitRefs(next); @@ -265,6 +266,25 @@ export function App() { return report; }; + const switchWorkspace = async (path: string) => { + const next = path.trim(); + if (!next || next === repoRef.current) return; + if (busyRef.current) return; + setError(""); + setCopied(""); + setReview(null); + setArchitecture(null); + persistRepo(next); + markBusy(`Loading ${repoName(next)}…`); + try { + await Promise.all([loadArchitecture(next), loadGitRefs(next)]); + } catch (e) { + if (repoRef.current === next) setError(e instanceof Error ? e.message : String(e)); + } finally { + if (repoRef.current === next) markBusy(""); + } + }; + const runReview = async () => { if (busyRef.current) return; if (!requireRepo()) return; @@ -496,6 +516,7 @@ export function App() { : "Not indexed"; const findings = (review?.findings || []).filter((f) => !f.waived); + const workspaceLoading = busy.startsWith("Loading "); return (
@@ -555,7 +576,7 @@ export function App() {
{busy ? ( -
+
{busy}
@@ -567,8 +588,10 @@ export function App() {