@reposkein/mcp 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/binary-digests.json +4 -4
- package/dist/cli/view.js +27 -6
- package/dist/cli/view.js.map +1 -1
- package/dist/index.d.ts +8 -56
- package/dist/index.js +38 -402
- package/dist/index.js.map +1 -1
- package/dist/indexer/indexLock.d.ts +13 -0
- package/dist/indexer/indexLock.js +66 -0
- package/dist/indexer/indexLock.js.map +1 -0
- package/dist/indexer/runIndexer.d.ts +8 -0
- package/dist/indexer/runIndexer.js +12 -0
- package/dist/indexer/runIndexer.js.map +1 -1
- package/dist/serve/serve.d.ts +95 -0
- package/dist/serve/serve.js +581 -0
- package/dist/serve/serve.js.map +1 -0
- package/dist/serve/tokens.d.ts +49 -0
- package/dist/serve/tokens.js +108 -0
- package/dist/serve/tokens.js.map +1 -0
- package/dist/serve/watch.d.ts +73 -0
- package/dist/serve/watch.js +135 -0
- package/dist/serve/watch.js.map +1 -0
- package/dist/server/createMcpServer.d.ts +129 -0
- package/dist/server/createMcpServer.js +464 -0
- package/dist/server/createMcpServer.js.map +1 -0
- package/dist/store/JsonlGraphStore.d.ts +5 -1
- package/dist/store/JsonlGraphStore.js +6 -2
- package/dist/store/JsonlGraphStore.js.map +1 -1
- package/dist/store/teamConfig.d.ts +10 -6
- package/dist/store/teamConfig.js +23 -17
- package/dist/store/teamConfig.js.map +1 -1
- package/dist/tools/recordDecision.d.ts +3 -0
- package/dist/tools/recordDecision.js +1 -1
- package/dist/tools/recordDecision.js.map +1 -1
- package/dist/tools/writeSemanticSummary.d.ts +4 -1
- package/dist/tools/writeSemanticSummary.js +5 -2
- package/dist/tools/writeSemanticSummary.js.map +1 -1
- package/dist/viz/assets/index-BnqIVYFE.css +1 -0
- package/dist/viz/assets/index-IhtszTp0.js +5 -0
- package/dist/viz/assets/{r3f-BZY3QR6_.js → r3f-Bn9htB92.js} +1 -1
- package/dist/viz/assets/{tanstack-CjXr-L-s.js → tanstack-CSzx6NDA.js} +7 -7
- package/dist/viz/index.html +4 -4
- package/package.json +1 -1
- package/dist/viz/assets/index-CxqeGuRS.css +0 -1
- package/dist/viz/assets/index-DiNZyrXx.js +0 -9
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{b,j as f,c as Ks,d as Ps,e as $s,f as Ds,h as Fs,i as Os,Q as zs,k as Bs,l as Hs,m as qs,n as Us,o as Vs,p as Gs,O as Ws}from"./tanstack-CSzx6NDA.js";import{u as Ze,S as Ys,H as Xs,a as hn,C as Qs,b as Zs,N as Js,Y as er,c as tr}from"./r3f-Bn9htB92.js";import{a1 as nr,z as ke,G as ye,a0 as De,a2 as or,a3 as je,a4 as sr,a5 as mn,e as rr,i as jt,X as ir,$ as ar,a6 as cr}from"./three-Cpu5RUEM.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(s){if(s.ep)return;s.ep=!0;const r=n(s);fetch(s.href,r)}})();function lr(e){return new Worker(""+new URL("graph.worker-DkH6-lMU.js",import.meta.url).href,{type:"module",name:e?.name})}function Cn(e){const t=new Map;for(const g of e.clusters)t.set(g.key,g);const n=new Map;e.keys.forEach((g,k)=>n.set(g,k));const o=new Map(e.records),s=new Map;for(const g of t.values())g.nodeId&&s.set(g.nodeId,g.key);const r=new Map,i=g=>{const k=r.get(g);if(k)return k;const _=t.get(g);if(!_)return[g];const v=_.parent?[...i(_.parent),g]:[g];return r.set(g,v),v};for(const g of t.keys())i(g);let a=1/0,c=1/0,d=1/0,l=-1/0,u=-1/0,m=-1/0;for(let g=0;g<e.positions.length;g+=3){const k=e.positions[g],_=e.positions[g+1],v=e.positions[g+2];k<a&&(a=k),_<c&&(c=_),v<d&&(d=v),k>l&&(l=k),_>u&&(u=_),v>m&&(m=v)}const h=e.positions.length===0?1:Math.hypot(l-a,u-c,m-d)||1,p=new Map;for(const[g,k]of s){const _=r.get(k);if(_){for(let v=_.length-1;v>=0;v--)if(t.get(_[v])?.kind==="file"){p.set(g,_[v]);break}}}const x=new Map,y=(g,k)=>{let _=x.get(g);_||(_=new Set,x.set(g,_)),_.add(k)};for(const g of e.drawEdges)y(g.from,g.to),y(g.to,g.from);return{repoId:e.repoId,repoRoot:e.repoRoot,repoMeta:e.repoMeta??null,rootKey:e.rootKey,byKey:t,keys:e.keys,positions:e.positions,indexByKey:n,drawEdges:e.drawEdges,records:o,fingerprint:e.fingerprint,counts:e.counts,clusterOfNode:s,ancestors:r,sceneDiag:h,fileByNode:p,neighborsByNode:x}}function ae(e,t){const n=new Set,o=s=>{const r=e.byKey.get(s);if(!r)return;const i=t.has(s);if(r.children.length===0||!i){n.add(s);return}for(const a of r.children)o(a)};return o(e.rootKey),n}function oe(e,t,n){const o=e.clusterOfNode.get(t)??t,s=e.ancestors.get(o);if(!s)return n.has(o)?o:null;for(let r=s.length-1;r>=0;r--){const i=s[r];if(n.has(i))return i}return null}function Bt(e,t,n){return oe(e,t,n)}function ur(e,t,n){return oe(e,t,n)}function To(e,t,n){if(!t)return null;const o=new Set;for(const s of t.nodes){const r=oe(e,s,n);r&&o.add(r)}return o}function Ao(e,t){return e.fileByNode.get(t)??null}function dr(e,t,n){if(!t)return null;const o=new Set,s=oe(e,t,n);s&&o.add(s);const r=e.neighborsByNode.get(t);if(r)for(const i of r){const a=oe(e,i,n);a&&o.add(a)}return o}function Io(e,t){const n=e.clusterOfNode.get(t)??t,o=e.ancestors.get(n);if(!o)return[];const s=[];for(const r of o){const i=e.byKey.get(r);i&&i.children.length>0&&s.push(r)}return s}function He(e,t,n){const o=new Set(t);for(const s of n)for(const r of Io(e,s))o.add(r);return o}function fr(e,t){const n=t.audit==="ambiguous"?new Set(["ambiguous"]):t.audit==="ambiguous+name"?new Set(["ambiguous","name_match"]):null;return n!==null||t.edgeTypes.size>0||t.minConfidence>0?{...e,drawEdges:e.drawEdges.filter(s=>n?n.has(s.resolution):(t.edgeTypes.size===0||!t.edgeTypes.has(s.type))&&s.confidence>=t.minConfidence)}:e}const Tn={exact:3,name_match:2,ambiguous:1},pr="symbol",An=2500;function In(e,t,n,o){const s=oe(e,t,n);if(!s)return null;if(e.byKey.get(s)?.kind!==pr)return s;const r=Ao(e,t);return r&&o.has(r)?s:r&&n.has(r)?r:s}function Ro(e,t){const n=ae(e,t.expanded),o=fr(e,t.filters),s=new Set;for(const x of t.activeNodes){const y=Ao(e,x);y&&s.add(y)}for(const x of t.expanded)e.byKey.get(x)?.kind==="file"&&s.add(x);const r=new Map,i=new Map;for(const x of o.drawEdges){const y=In(e,x.from,n,s),g=In(e,x.to,n,s);if(!y||!g||y===g)continue;const k=`${y} ${g}`;let _=r.get(k);_||(_={srcKey:y,dstKey:g,count:0,dominantType:x.type,bestResolution:x.resolution,srcNodes:new Set,dstNodes:new Set,lengthAtten:1},r.set(k,_),i.set(k,new Map)),_.count++,_.srcNodes.add(x.from),_.dstNodes.add(x.to),Tn[x.resolution]>Tn[_.bestResolution]&&(_.bestResolution=x.resolution);const v=i.get(k);v.set(x.type,(v.get(x.type)??0)+1)}for(const[x,y]of r){const g=i.get(x);let k=y.dominantType,_=-1;for(const[v,w]of[...g.entries()].sort((N,j)=>N[0]<j[0]?-1:1))w>_&&(_=w,k=v);y.dominantType=k}const a=.35*e.sceneDiag,c=.9*e.sceneDiag,d=.12,l=e.positions,u=e.indexByKey;for(const x of r.values()){const y=u.get(x.srcKey),g=u.get(x.dstKey);if(y===void 0||g===void 0)continue;const k=l[y*3]-l[g*3],_=l[y*3+1]-l[g*3+1],v=l[y*3+2]-l[g*3+2],w=Math.sqrt(k*k+_*_+v*v);x.lengthAtten=w<=a?1:w>=c?d:1-(1-d)*((w-a)/(c-a))}const m=r.size,h=[...r.values()].sort((x,y)=>x.count!==y.count?y.count-x.count:x.srcKey!==y.srcKey?x.srcKey<y.srcKey?-1:1:x.dstKey<y.dstKey?-1:1),p=h.length>An?h.slice(0,An):h;return p.sort((x,y)=>x.srcKey===y.srcKey?x.dstKey<y.dstKey?-1:1:x.srcKey<y.srcKey?-1:1),{bundles:p,visible:n,activeFiles:s,total:m}}const Ht=["CALLS","IMPORTS","INHERITS","IMPLEMENTS","INSTANTIATES"],hr=["INHERITS","IMPLEMENTS","INSTANTIATES"];function Mt(e){const t=new Set(e);return Ht.filter(n=>!t.has(n))}const Me={all:{id:"all",label:"All",hint:"Show everything (default)",kinds:[],edgeTypes:[],minConfidence:0,emphasis:"none"},calls:{id:"calls",label:"Call graph",hint:"Only CALLS edges",kinds:[],edgeTypes:Mt(["CALLS"]),minConfidence:0,emphasis:"none"},types:{id:"types",label:"Type hierarchy",hint:"Only INHERITS / IMPLEMENTS / INSTANTIATES; emphasize Class / Interface / Enum",kinds:[],edgeTypes:Mt(hr),minConfidence:0,emphasis:"types"},imports:{id:"imports",label:"Imports",hint:"Only IMPORTS edges",kinds:[],edgeTypes:Mt(["IMPORTS"]),minConfidence:0,emphasis:"none"},tests:{id:"tests",label:"Tests ↔ code",hint:"Highlight test nodes and the edges between tests and non-tests",kinds:[],edgeTypes:[],minConfidence:0,emphasis:"tests"}},gn=["all","calls","types","imports","tests"],mr=new Set(["class","interface","enum"]);function gr(e){const t=Me[e];return{kinds:new Set(t.kinds),edgeTypes:new Set(t.edgeTypes),minConfidence:t.minConfidence,emphasis:t.emphasis}}const xr=[/(^|[/\\])test_[^/\\]*\.[^/\\]+$/i,/_tests?\.[^/\\]+$/i,/\.(test|spec)\.[^/\\]+$/i,/[^/\\]+Tests?\.(java|cs|kt|scala)$/i],yr=new Set(["test","tests","__tests__","spec","specs","testing"]);function br(e){if(!e)return!1;for(const n of xr)if(n.test(e))return!0;const t=e.split(/[/\\]/);for(const n of t)if(yr.has(n.toLowerCase()))return!0;return!1}function Lo(e){return e.role==="testing"?!0:br(e.filePath)}function vr(e,t){const n=new Map;for(const i of e.drawEdges){if(i.type!=="CALLS")continue;const a=n.get(i.to);a?a.push(i.from):n.set(i.to,[i.from])}const o=new Set,s=[t];for(;s.length>0;){const i=s.shift(),a=n.get(i);if(a)for(const c of a)c===t||o.has(c)||(o.add(c),s.push(c))}const r=new Set;for(const i of o){const a=e.records.get(i);a&&Lo(a)&&r.add(i)}return{sourceId:t,impacted:o,coveringTests:r}}const qt=1,Ko=3,Ut=2;function pt(e){return Math.max(qt,Math.min(Ko,Math.round(e)))}function Rn(e,t,n,o){const s=pt(n),r=new Map,i=(d,l)=>{const u=r.get(d);u?u.push(l):r.set(d,[l])};for(const d of e)o&&o.size>0&&!o.has(d.type)||(i(d.from,d.to),i(d.to,d.from));const a=new Set([t]);let c=[t];for(let d=0;d<s&&c.length>0;d++){const l=[];for(const u of c){const m=r.get(u);if(m)for(const h of m)a.has(h)||(a.add(h),l.push(h))}c=l}return{sourceId:t,depth:s,nodes:a}}function wr(e){let t;try{t=JSON.parse(e)}catch{return null}const n=t.id,o=t.labels;if(typeof n!="string"||!Array.isArray(o))return null;const s={...t};return delete s.id,delete s.labels,{id:n,labels:o.filter(r=>typeof r=="string"),props:s}}function _r(e){let t;try{t=JSON.parse(e)}catch{return null}const n=t.from,o=t.type,s=t.to;if(typeof n!="string"||typeof o!="string"||typeof s!="string")return null;const r={...t};return delete r.from,delete r.type,delete r.to,{from:n,type:o,to:s,props:r}}function kr(e){const t=[];for(const n of e.split(`
|
|
2
|
+
`)){if(n.trim()==="")continue;const o=wr(n);o&&t.push(o)}return t}function Nr(e){const t=[];for(const n of e.split(`
|
|
3
|
+
`)){if(n.trim()==="")continue;const o=_r(n);o&&t.push(o)}return t}function Ln(e,t){return{nodes:kr(e),edges:Nr(t)}}const Sr=new Set(["CALLS","IMPORTS","INSTANTIATES","IMPLEMENTS","INHERITS"]);function Er(e){const t=e.resolution;if(t==="exact"||t==="name_match"||t==="ambiguous")return t;const n=typeof e.confidence=="number"?e.confidence:1;return n>=.95?"exact":n>=.5?"name_match":"ambiguous"}function ee(e){return typeof e=="string"?e:null}function Vt(e,t=0){return typeof e=="number"?e:t}const jr=new Set(["Function","Class","Interface","Enum","Variable"]);function Le(e){return e.labels[0]??""}function Ct(e){const t=e.lastIndexOf("/");if(t<0)return".";const n=e.slice(0,t);return n===""?".":n}function Tt(e){if(e==="."||e==="")return".";const t=e.lastIndexOf("/");return t<0?e:e.slice(t+1)}function Mr(e){for(const t of e.nodes)if(Le(t)==="Repository"){const n=ee(t.props.name);if(n)return n}for(const t of e.nodes){const n=t.id.split(":");if(n.length>=2&&n[0]==="rs1"&&n[1])return n[1]}return"repo"}function Cr(e){const t=Mr(e),n=`galaxy:${t}`,o=new Map,s=h=>{const p=o.get(h.key);return p||(o.set(h.key,h),h)};s({key:n,kind:"galaxy",name:t,parent:null,children:[],nodeId:null});const r=h=>`dir:${t}:${h}`,i=h=>`file:${t}:${h}`,a=h=>{const p=r(h),x=o.get(p);if(x)return x;const y=h===".",g=y?null:Ct(h),k=y?n:a(g).key;return s({key:p,kind:"dir",name:y?t:Tt(h),parent:k,children:[],nodeId:null})};for(const h of e.nodes){if(Le(h)!=="Directory")continue;const p=ee(h.props.path)??".",x=a(p);x.nodeId=h.id}const c=new Map;for(const h of e.nodes){if(Le(h)!=="File")continue;const p=ee(h.props.path)??ee(h.props.file_path);if(p===null)continue;const x=a(Ct(p)),y=i(p);s({key:y,kind:"file",name:Tt(p),parent:x.key,children:[],nodeId:h.id}),c.set(p,y)}const d=new Map;for(const h of e.nodes)jr.has(Le(h))&&d.set(h.id,h);const l=new Map;for(const h of e.nodes)if(Le(h)==="File"){const p=ee(h.props.path)??ee(h.props.file_path);p!==null&&l.set(h.id,i(p))}const u=new Set,m=(h,p)=>{u.has(h.id)||(u.add(h.id),s({key:h.id,kind:"symbol",name:ee(h.props.name)??ee(h.props.qualified_name)??h.id,parent:p,children:[],nodeId:h.id,symbolKind:Le(h)}))};for(const h of e.edges){if(h.type!=="DEFINES")continue;const p=d.get(h.to);if(!p)continue;const x=l.get(h.from);x&&o.has(x)&&m(p,x)}for(const h of d.values()){if(u.has(h.id))continue;const p=ee(h.props.file_path);if(p===null)continue;let x=c.get(p);if(!x){const y=a(Ct(p));x=i(p),s({key:x,kind:"file",name:Tt(p),parent:y.key,children:[],nodeId:null}),c.set(p,x)}m(h,x)}for(const h of o.values())if(h.parent){const p=o.get(h.parent);p&&p.children.push(h.key)}for(const h of o.values())h.children.sort();return{rootKey:n,byKey:o,repoId:t}}function Tr(e){const t=[],n=o=>{const s=e.byKey.get(o);if(s){t.push(s);for(const r of s.children)n(r)}};return n(e.rootKey),t}function Ar(e,t,n){var o,s=1;e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function r(){var i,a=o.length,c,d=0,l=0,u=0;for(i=0;i<a;++i)c=o[i],d+=c.x||0,l+=c.y||0,u+=c.z||0;for(d=(d/a-e)*s,l=(l/a-t)*s,u=(u/a-n)*s,i=0;i<a;++i)c=o[i],d&&(c.x-=d),l&&(c.y-=l),u&&(c.z-=u)}return r.initialize=function(i){o=i},r.x=function(i){return arguments.length?(e=+i,r):e},r.y=function(i){return arguments.length?(t=+i,r):t},r.z=function(i){return arguments.length?(n=+i,r):n},r.strength=function(i){return arguments.length?(s=+i,r):s},r}function Ir(e){const t=+this._x.call(null,e);return Po(this.cover(t),t,e)}function Po(e,t,n){if(isNaN(t))return e;var o,s=e._root,r={data:n},i=e._x0,a=e._x1,c,d,l,u,m;if(!s)return e._root=r,e;for(;s.length;)if((l=t>=(c=(i+a)/2))?i=c:a=c,o=s,!(s=s[u=+l]))return o[u]=r,e;if(d=+e._x.call(null,s.data),t===d)return r.next=s,o?o[u]=r:e._root=r,e;do o=o?o[u]=new Array(2):e._root=new Array(2),(l=t>=(c=(i+a)/2))?i=c:a=c;while((u=+l)==(m=+(d>=c)));return o[m]=s,o[u]=r,e}function Rr(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,n=new Float64Array(t);let o=1/0,s=-1/0;for(let r=0,i;r<t;++r)isNaN(i=+this._x.call(null,e[r]))||(n[r]=i,i<o&&(o=i),i>s&&(s=i));if(o>s)return this;this.cover(o).cover(s);for(let r=0;r<t;++r)Po(this,n[r],e[r]);return this}function Lr(e){if(isNaN(e=+e))return this;var t=this._x0,n=this._x1;if(isNaN(t))n=(t=Math.floor(e))+1;else{for(var o=n-t||1,s=this._root,r,i;t>e||e>=n;)switch(i=+(e<t),r=new Array(2),r[i]=s,s=r,o*=2,i){case 0:n=t+o;break;case 1:t=n-o;break}this._root&&this._root.length&&(this._root=s)}return this._x0=t,this._x1=n,this}function Kr(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Pr(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function ve(e,t,n){this.node=e,this.x0=t,this.x1=n}function $r(e,t){var n,o=this._x0,s,r,i=this._x1,a=[],c=this._root,d,l;for(c&&a.push(new ve(c,o,i)),t==null?t=1/0:(o=e-t,i=e+t);d=a.pop();)if(!(!(c=d.node)||(s=d.x0)>i||(r=d.x1)<o))if(c.length){var u=(s+r)/2;a.push(new ve(c[1],u,r),new ve(c[0],s,u)),(l=+(e>=u))&&(d=a[a.length-1],a[a.length-1]=a[a.length-1-l],a[a.length-1-l]=d)}else{var m=Math.abs(e-+this._x.call(null,c.data));m<t&&(t=m,o=e-m,i=e+m,n=c.data)}return n}function Dr(e){if(isNaN(c=+this._x.call(null,e)))return this;var t,n=this._root,o,s,r,i=this._x0,a=this._x1,c,d,l,u,m;if(!n)return this;if(n.length)for(;;){if((l=c>=(d=(i+a)/2))?i=d:a=d,t=n,!(n=n[u=+l]))return this;if(!n.length)break;t[u+1&1]&&(o=t,m=u)}for(;n.data!==e;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):t?(r?t[u]=r:delete t[u],(n=t[0]||t[1])&&n===(t[1]||t[0])&&!n.length&&(o?o[m]=n:this._root=n),this):(this._root=r,this)}function Fr(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Or(){return this._root}function zr(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Br(e){var t=[],n,o=this._root,s,r,i;for(o&&t.push(new ve(o,this._x0,this._x1));n=t.pop();)if(!e(o=n.node,r=n.x0,i=n.x1)&&o.length){var a=(r+i)/2;(s=o[1])&&t.push(new ve(s,a,i)),(s=o[0])&&t.push(new ve(s,r,a))}return this}function Hr(e){var t=[],n=[],o;for(this._root&&t.push(new ve(this._root,this._x0,this._x1));o=t.pop();){var s=o.node;if(s.length){var r,i=o.x0,a=o.x1,c=(i+a)/2;(r=s[0])&&t.push(new ve(r,i,c)),(r=s[1])&&t.push(new ve(r,c,a))}n.push(o)}for(;o=n.pop();)e(o.node,o.x0,o.x1);return this}function qr(e){return e[0]}function Ur(e){return arguments.length?(this._x=e,this):this._x}function $o(e,t){var n=new xn(t??qr,NaN,NaN);return e==null?n:n.addAll(e)}function xn(e,t,n){this._x=e,this._x0=t,this._x1=n,this._root=void 0}function Kn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var ue=$o.prototype=xn.prototype;ue.copy=function(){var e=new xn(this._x,this._x0,this._x1),t=this._root,n,o;if(!t)return e;if(!t.length)return e._root=Kn(t),e;for(n=[{source:t,target:e._root=new Array(2)}];t=n.pop();)for(var s=0;s<2;++s)(o=t.source[s])&&(o.length?n.push({source:o,target:t.target[s]=new Array(2)}):t.target[s]=Kn(o));return e};ue.add=Ir;ue.addAll=Rr;ue.cover=Lr;ue.data=Kr;ue.extent=Pr;ue.find=$r;ue.remove=Dr;ue.removeAll=Fr;ue.root=Or;ue.size=zr;ue.visit=Br;ue.visitAfter=Hr;ue.x=Ur;function Vr(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return Do(this.cover(t,n),t,n,e)}function Do(e,t,n,o){if(isNaN(t)||isNaN(n))return e;var s,r=e._root,i={data:o},a=e._x0,c=e._y0,d=e._x1,l=e._y1,u,m,h,p,x,y,g,k;if(!r)return e._root=i,e;for(;r.length;)if((x=t>=(u=(a+d)/2))?a=u:d=u,(y=n>=(m=(c+l)/2))?c=m:l=m,s=r,!(r=r[g=y<<1|x]))return s[g]=i,e;if(h=+e._x.call(null,r.data),p=+e._y.call(null,r.data),t===h&&n===p)return i.next=r,s?s[g]=i:e._root=i,e;do s=s?s[g]=new Array(4):e._root=new Array(4),(x=t>=(u=(a+d)/2))?a=u:d=u,(y=n>=(m=(c+l)/2))?c=m:l=m;while((g=y<<1|x)===(k=(p>=m)<<1|h>=u));return s[k]=r,s[g]=i,e}function Gr(e){var t,n,o=e.length,s,r,i=new Array(o),a=new Array(o),c=1/0,d=1/0,l=-1/0,u=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,t=e[n]))||isNaN(r=+this._y.call(null,t))||(i[n]=s,a[n]=r,s<c&&(c=s),s>l&&(l=s),r<d&&(d=r),r>u&&(u=r));if(c>l||d>u)return this;for(this.cover(c,d).cover(l,u),n=0;n<o;++n)Do(this,i[n],a[n],e[n]);return this}function Wr(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(e))+1,r=(o=Math.floor(t))+1;else{for(var i=s-n||1,a=this._root,c,d;n>e||e>=s||o>t||t>=r;)switch(d=(t<o)<<1|e<n,c=new Array(4),c[d]=a,a=c,i*=2,d){case 0:s=n+i,r=o+i;break;case 1:n=s-i,r=o+i;break;case 2:s=n+i,o=r-i;break;case 3:n=s-i,o=r-i;break}this._root&&this._root.length&&(this._root=a)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function Yr(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Xr(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ie(e,t,n,o,s){this.node=e,this.x0=t,this.y0=n,this.x1=o,this.y1=s}function Qr(e,t,n){var o,s=this._x0,r=this._y0,i,a,c,d,l=this._x1,u=this._y1,m=[],h=this._root,p,x;for(h&&m.push(new ie(h,s,r,l,u)),n==null?n=1/0:(s=e-n,r=t-n,l=e+n,u=t+n,n*=n);p=m.pop();)if(!(!(h=p.node)||(i=p.x0)>l||(a=p.y0)>u||(c=p.x1)<s||(d=p.y1)<r))if(h.length){var y=(i+c)/2,g=(a+d)/2;m.push(new ie(h[3],y,g,c,d),new ie(h[2],i,g,y,d),new ie(h[1],y,a,c,g),new ie(h[0],i,a,y,g)),(x=(t>=g)<<1|e>=y)&&(p=m[m.length-1],m[m.length-1]=m[m.length-1-x],m[m.length-1-x]=p)}else{var k=e-+this._x.call(null,h.data),_=t-+this._y.call(null,h.data),v=k*k+_*_;if(v<n){var w=Math.sqrt(n=v);s=e-w,r=t-w,l=e+w,u=t+w,o=h.data}}return o}function Zr(e){if(isNaN(l=+this._x.call(null,e))||isNaN(u=+this._y.call(null,e)))return this;var t,n=this._root,o,s,r,i=this._x0,a=this._y0,c=this._x1,d=this._y1,l,u,m,h,p,x,y,g;if(!n)return this;if(n.length)for(;;){if((p=l>=(m=(i+c)/2))?i=m:c=m,(x=u>=(h=(a+d)/2))?a=h:d=h,t=n,!(n=n[y=x<<1|p]))return this;if(!n.length)break;(t[y+1&3]||t[y+2&3]||t[y+3&3])&&(o=t,g=y)}for(;n.data!==e;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):t?(r?t[y]=r:delete t[y],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(o?o[g]=n:this._root=n),this):(this._root=r,this)}function Jr(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function ei(){return this._root}function ti(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function ni(e){var t=[],n,o=this._root,s,r,i,a,c;for(o&&t.push(new ie(o,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(o=n.node,r=n.x0,i=n.y0,a=n.x1,c=n.y1)&&o.length){var d=(r+a)/2,l=(i+c)/2;(s=o[3])&&t.push(new ie(s,d,l,a,c)),(s=o[2])&&t.push(new ie(s,r,l,d,c)),(s=o[1])&&t.push(new ie(s,d,i,a,l)),(s=o[0])&&t.push(new ie(s,r,i,d,l))}return this}function oi(e){var t=[],n=[],o;for(this._root&&t.push(new ie(this._root,this._x0,this._y0,this._x1,this._y1));o=t.pop();){var s=o.node;if(s.length){var r,i=o.x0,a=o.y0,c=o.x1,d=o.y1,l=(i+c)/2,u=(a+d)/2;(r=s[0])&&t.push(new ie(r,i,a,l,u)),(r=s[1])&&t.push(new ie(r,l,a,c,u)),(r=s[2])&&t.push(new ie(r,i,u,l,d)),(r=s[3])&&t.push(new ie(r,l,u,c,d))}n.push(o)}for(;o=n.pop();)e(o.node,o.x0,o.y0,o.x1,o.y1);return this}function si(e){return e[0]}function ri(e){return arguments.length?(this._x=e,this):this._x}function ii(e){return e[1]}function ai(e){return arguments.length?(this._y=e,this):this._y}function Fo(e,t,n){var o=new yn(t??si,n??ii,NaN,NaN,NaN,NaN);return e==null?o:o.addAll(e)}function yn(e,t,n,o,s,r){this._x=e,this._y=t,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Pn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var ce=Fo.prototype=yn.prototype;ce.copy=function(){var e=new yn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,o;if(!t)return e;if(!t.length)return e._root=Pn(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var s=0;s<4;++s)(o=t.source[s])&&(o.length?n.push({source:o,target:t.target[s]=new Array(4)}):t.target[s]=Pn(o));return e};ce.add=Vr;ce.addAll=Gr;ce.cover=Wr;ce.data=Yr;ce.extent=Xr;ce.find=Qr;ce.remove=Zr;ce.removeAll=Jr;ce.root=ei;ce.size=ti;ce.visit=ni;ce.visitAfter=oi;ce.x=ri;ce.y=ai;function ci(e){const t=+this._x.call(null,e),n=+this._y.call(null,e),o=+this._z.call(null,e);return Oo(this.cover(t,n,o),t,n,o,e)}function Oo(e,t,n,o,s){if(isNaN(t)||isNaN(n)||isNaN(o))return e;var r,i=e._root,a={data:s},c=e._x0,d=e._y0,l=e._z0,u=e._x1,m=e._y1,h=e._z1,p,x,y,g,k,_,v,w,N,j,M;if(!i)return e._root=a,e;for(;i.length;)if((v=t>=(p=(c+u)/2))?c=p:u=p,(w=n>=(x=(d+m)/2))?d=x:m=x,(N=o>=(y=(l+h)/2))?l=y:h=y,r=i,!(i=i[j=N<<2|w<<1|v]))return r[j]=a,e;if(g=+e._x.call(null,i.data),k=+e._y.call(null,i.data),_=+e._z.call(null,i.data),t===g&&n===k&&o===_)return a.next=i,r?r[j]=a:e._root=a,e;do r=r?r[j]=new Array(8):e._root=new Array(8),(v=t>=(p=(c+u)/2))?c=p:u=p,(w=n>=(x=(d+m)/2))?d=x:m=x,(N=o>=(y=(l+h)/2))?l=y:h=y;while((j=N<<2|w<<1|v)===(M=(_>=y)<<2|(k>=x)<<1|g>=p));return r[M]=i,r[j]=a,e}function li(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,n=new Float64Array(t),o=new Float64Array(t),s=new Float64Array(t);let r=1/0,i=1/0,a=1/0,c=-1/0,d=-1/0,l=-1/0;for(let u=0,m,h,p,x;u<t;++u)isNaN(h=+this._x.call(null,m=e[u]))||isNaN(p=+this._y.call(null,m))||isNaN(x=+this._z.call(null,m))||(n[u]=h,o[u]=p,s[u]=x,h<r&&(r=h),h>c&&(c=h),p<i&&(i=p),p>d&&(d=p),x<a&&(a=x),x>l&&(l=x));if(r>c||i>d||a>l)return this;this.cover(r,i,a).cover(c,d,l);for(let u=0;u<t;++u)Oo(this,n[u],o[u],s[u],e[u]);return this}function ui(e,t,n){if(isNaN(e=+e)||isNaN(t=+t)||isNaN(n=+n))return this;var o=this._x0,s=this._y0,r=this._z0,i=this._x1,a=this._y1,c=this._z1;if(isNaN(o))i=(o=Math.floor(e))+1,a=(s=Math.floor(t))+1,c=(r=Math.floor(n))+1;else{for(var d=i-o||1,l=this._root,u,m;o>e||e>=i||s>t||t>=a||r>n||n>=c;)switch(m=(n<r)<<2|(t<s)<<1|e<o,u=new Array(8),u[m]=l,l=u,d*=2,m){case 0:i=o+d,a=s+d,c=r+d;break;case 1:o=i-d,a=s+d,c=r+d;break;case 2:i=o+d,s=a-d,c=r+d;break;case 3:o=i-d,s=a-d,c=r+d;break;case 4:i=o+d,a=s+d,r=c-d;break;case 5:o=i-d,a=s+d,r=c-d;break;case 6:i=o+d,s=a-d,r=c-d;break;case 7:o=i-d,s=a-d,r=c-d;break}this._root&&this._root.length&&(this._root=l)}return this._x0=o,this._y0=s,this._z0=r,this._x1=i,this._y1=a,this._z1=c,this}function di(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function fi(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function H(e,t,n,o,s,r,i){this.node=e,this.x0=t,this.y0=n,this.z0=o,this.x1=s,this.y1=r,this.z1=i}function pi(e,t,n,o){var s,r=this._x0,i=this._y0,a=this._z0,c,d,l,u,m,h,p=this._x1,x=this._y1,y=this._z1,g=[],k=this._root,_,v;for(k&&g.push(new H(k,r,i,a,p,x,y)),o==null?o=1/0:(r=e-o,i=t-o,a=n-o,p=e+o,x=t+o,y=n+o,o*=o);_=g.pop();)if(!(!(k=_.node)||(c=_.x0)>p||(d=_.y0)>x||(l=_.z0)>y||(u=_.x1)<r||(m=_.y1)<i||(h=_.z1)<a))if(k.length){var w=(c+u)/2,N=(d+m)/2,j=(l+h)/2;g.push(new H(k[7],w,N,j,u,m,h),new H(k[6],c,N,j,w,m,h),new H(k[5],w,d,j,u,N,h),new H(k[4],c,d,j,w,N,h),new H(k[3],w,N,l,u,m,j),new H(k[2],c,N,l,w,m,j),new H(k[1],w,d,l,u,N,j),new H(k[0],c,d,l,w,N,j)),(v=(n>=j)<<2|(t>=N)<<1|e>=w)&&(_=g[g.length-1],g[g.length-1]=g[g.length-1-v],g[g.length-1-v]=_)}else{var M=e-+this._x.call(null,k.data),D=t-+this._y.call(null,k.data),K=n-+this._z.call(null,k.data),F=M*M+D*D+K*K;if(F<o){var L=Math.sqrt(o=F);r=e-L,i=t-L,a=n-L,p=e+L,x=t+L,y=n+L,s=k.data}}return s}const hi=(e,t,n,o,s,r)=>Math.sqrt((e-o)**2+(t-s)**2+(n-r)**2);function mi(e,t,n,o){const s=[],r=e-o,i=t-o,a=n-o,c=e+o,d=t+o,l=n+o;return this.visit((u,m,h,p,x,y,g)=>{if(!u.length)do{const k=u.data;hi(e,t,n,this._x(k),this._y(k),this._z(k))<=o&&s.push(k)}while(u=u.next);return m>c||h>d||p>l||x<r||y<i||g<a}),s}function gi(e){if(isNaN(m=+this._x.call(null,e))||isNaN(h=+this._y.call(null,e))||isNaN(p=+this._z.call(null,e)))return this;var t,n=this._root,o,s,r,i=this._x0,a=this._y0,c=this._z0,d=this._x1,l=this._y1,u=this._z1,m,h,p,x,y,g,k,_,v,w,N;if(!n)return this;if(n.length)for(;;){if((k=m>=(x=(i+d)/2))?i=x:d=x,(_=h>=(y=(a+l)/2))?a=y:l=y,(v=p>=(g=(c+u)/2))?c=g:u=g,t=n,!(n=n[w=v<<2|_<<1|k]))return this;if(!n.length)break;(t[w+1&7]||t[w+2&7]||t[w+3&7]||t[w+4&7]||t[w+5&7]||t[w+6&7]||t[w+7&7])&&(o=t,N=w)}for(;n.data!==e;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):t?(r?t[w]=r:delete t[w],(n=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&n===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!n.length&&(o?o[N]=n:this._root=n),this):(this._root=r,this)}function xi(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function yi(){return this._root}function bi(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function vi(e){var t=[],n,o=this._root,s,r,i,a,c,d,l;for(o&&t.push(new H(o,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=t.pop();)if(!e(o=n.node,r=n.x0,i=n.y0,a=n.z0,c=n.x1,d=n.y1,l=n.z1)&&o.length){var u=(r+c)/2,m=(i+d)/2,h=(a+l)/2;(s=o[7])&&t.push(new H(s,u,m,h,c,d,l)),(s=o[6])&&t.push(new H(s,r,m,h,u,d,l)),(s=o[5])&&t.push(new H(s,u,i,h,c,m,l)),(s=o[4])&&t.push(new H(s,r,i,h,u,m,l)),(s=o[3])&&t.push(new H(s,u,m,a,c,d,h)),(s=o[2])&&t.push(new H(s,r,m,a,u,d,h)),(s=o[1])&&t.push(new H(s,u,i,a,c,m,h)),(s=o[0])&&t.push(new H(s,r,i,a,u,m,h))}return this}function wi(e){var t=[],n=[],o;for(this._root&&t.push(new H(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));o=t.pop();){var s=o.node;if(s.length){var r,i=o.x0,a=o.y0,c=o.z0,d=o.x1,l=o.y1,u=o.z1,m=(i+d)/2,h=(a+l)/2,p=(c+u)/2;(r=s[0])&&t.push(new H(r,i,a,c,m,h,p)),(r=s[1])&&t.push(new H(r,m,a,c,d,h,p)),(r=s[2])&&t.push(new H(r,i,h,c,m,l,p)),(r=s[3])&&t.push(new H(r,m,h,c,d,l,p)),(r=s[4])&&t.push(new H(r,i,a,p,m,h,u)),(r=s[5])&&t.push(new H(r,m,a,p,d,h,u)),(r=s[6])&&t.push(new H(r,i,h,p,m,l,u)),(r=s[7])&&t.push(new H(r,m,h,p,d,l,u))}n.push(o)}for(;o=n.pop();)e(o.node,o.x0,o.y0,o.z0,o.x1,o.y1,o.z1);return this}function _i(e){return e[0]}function ki(e){return arguments.length?(this._x=e,this):this._x}function Ni(e){return e[1]}function Si(e){return arguments.length?(this._y=e,this):this._y}function Ei(e){return e[2]}function ji(e){return arguments.length?(this._z=e,this):this._z}function zo(e,t,n,o){var s=new bn(t??_i,n??Ni,o??Ei,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?s:s.addAll(e)}function bn(e,t,n,o,s,r,i,a,c){this._x=e,this._y=t,this._z=n,this._x0=o,this._y0=s,this._z0=r,this._x1=i,this._y1=a,this._z1=c,this._root=void 0}function $n(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var ne=zo.prototype=bn.prototype;ne.copy=function(){var e=new bn(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),t=this._root,n,o;if(!t)return e;if(!t.length)return e._root=$n(t),e;for(n=[{source:t,target:e._root=new Array(8)}];t=n.pop();)for(var s=0;s<8;++s)(o=t.source[s])&&(o.length?n.push({source:o,target:t.target[s]=new Array(8)}):t.target[s]=$n(o));return e};ne.add=ci;ne.addAll=li;ne.cover=ui;ne.data=di;ne.extent=fi;ne.find=pi;ne.findAllWithinRadius=mi;ne.remove=gi;ne.removeAll=xi;ne.root=yi;ne.size=bi;ne.visit=vi;ne.visitAfter=wi;ne.x=ki;ne.y=Si;ne.z=ji;function Ye(e){return function(){return e}}function xe(e){return(e()-.5)*1e-6}function Mi(e){return e.index}function Dn(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function Ci(e){var t=Mi,n=m,o,s=Ye(30),r,i,a,c,d,l,u=1;e==null&&(e=[]);function m(g){return 1/Math.min(c[g.source.index],c[g.target.index])}function h(g){for(var k=0,_=e.length;k<u;++k)for(var v=0,w,N,j,M=0,D=0,K=0,F,L;v<_;++v)w=e[v],N=w.source,j=w.target,M=j.x+j.vx-N.x-N.vx||xe(l),a>1&&(D=j.y+j.vy-N.y-N.vy||xe(l)),a>2&&(K=j.z+j.vz-N.z-N.vz||xe(l)),F=Math.sqrt(M*M+D*D+K*K),F=(F-r[v])/F*g*o[v],M*=F,D*=F,K*=F,j.vx-=M*(L=d[v]),a>1&&(j.vy-=D*L),a>2&&(j.vz-=K*L),N.vx+=M*(L=1-L),a>1&&(N.vy+=D*L),a>2&&(N.vz+=K*L)}function p(){if(i){var g,k=i.length,_=e.length,v=new Map(i.map((N,j)=>[t(N,j,i),N])),w;for(g=0,c=new Array(k);g<_;++g)w=e[g],w.index=g,typeof w.source!="object"&&(w.source=Dn(v,w.source)),typeof w.target!="object"&&(w.target=Dn(v,w.target)),c[w.source.index]=(c[w.source.index]||0)+1,c[w.target.index]=(c[w.target.index]||0)+1;for(g=0,d=new Array(_);g<_;++g)w=e[g],d[g]=c[w.source.index]/(c[w.source.index]+c[w.target.index]);o=new Array(_),x(),r=new Array(_),y()}}function x(){if(i)for(var g=0,k=e.length;g<k;++g)o[g]=+n(e[g],g,e)}function y(){if(i)for(var g=0,k=e.length;g<k;++g)r[g]=+s(e[g],g,e)}return h.initialize=function(g,...k){i=g,l=k.find(_=>typeof _=="function")||Math.random,a=k.find(_=>[1,2,3].includes(_))||2,p()},h.links=function(g){return arguments.length?(e=g,p(),h):e},h.id=function(g){return arguments.length?(t=g,h):t},h.iterations=function(g){return arguments.length?(u=+g,h):u},h.strength=function(g){return arguments.length?(n=typeof g=="function"?g:Ye(+g),x(),h):n},h.distance=function(g){return arguments.length?(s=typeof g=="function"?g:Ye(+g),y(),h):s},h}var Ti={value:()=>{}};function Bo(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new lt(n)}function lt(e){this._=e}function Ai(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}lt.prototype=Bo.prototype={constructor:lt,on:function(e,t){var n=this._,o=Ai(e+"",n),s,r=-1,i=o.length;if(arguments.length<2){for(;++r<i;)if((s=(e=o[r]).type)&&(s=Ii(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<i;)if(s=(e=o[r]).type)n[s]=Fn(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Fn(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new lt(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,r;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,r=o.length;s<r;++s)o[s].value.apply(t,n)}};function Ii(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function Fn(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=Ti,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fe=0,Ge=0,qe=0,Ho=1e3,ut,We,dt=0,Te=0,ht=0,Qe=typeof performance=="object"&&performance.now?performance:Date,qo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uo(){return Te||(qo(Ri),Te=Qe.now()+ht)}function Ri(){Te=0}function Gt(){this._call=this._time=this._next=null}Gt.prototype=Vo.prototype={constructor:Gt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Uo():+n)+(t==null?0:+t),!this._next&&We!==this&&(We?We._next=this:ut=this,We=this),this._call=e,this._time=n,Wt()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wt())}};function Vo(e,t,n){var o=new Gt;return o.restart(e,t,n),o}function Li(){Uo(),++Fe;for(var e=ut,t;e;)(t=Te-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Fe}function On(){Te=(dt=Qe.now())+ht,Fe=Ge=0;try{Li()}finally{Fe=0,Pi(),Te=0}}function Ki(){var e=Qe.now(),t=e-dt;t>Ho&&(ht-=t,dt=e)}function Pi(){for(var e,t=ut,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ut=n);We=e,Wt(o)}function Wt(e){if(!Fe){Ge&&(Ge=clearTimeout(Ge));var t=e-Te;t>24?(e<1/0&&(Ge=setTimeout(On,e-Qe.now()-ht)),qe&&(qe=clearInterval(qe))):(qe||(dt=Qe.now(),qe=setInterval(Ki,Ho)),Fe=1,qo(On))}}const $i=1664525,Di=1013904223,zn=4294967296;function Fi(){let e=1;return()=>(e=($i*e+Di)%zn)/zn}var Bn=3;function At(e){return e.x}function Hn(e){return e.y}function Oi(e){return e.z}var zi=10,Bi=Math.PI*(3-Math.sqrt(5)),Hi=Math.PI*20/(9+Math.sqrt(221));function qi(e,t){t=t||2;var n=Math.min(Bn,Math.max(1,Math.round(t))),o,s=1,r=.001,i=1-Math.pow(r,1/300),a=0,c=.6,d=new Map,l=Vo(h),u=Bo("tick","end"),m=Fi();e==null&&(e=[]);function h(){p(),u.call("tick",o),s<r&&(l.stop(),u.call("end",o))}function p(g){var k,_=e.length,v;g===void 0&&(g=1);for(var w=0;w<g;++w)for(s+=(a-s)*i,d.forEach(function(N){N(s)}),k=0;k<_;++k)v=e[k],v.fx==null?v.x+=v.vx*=c:(v.x=v.fx,v.vx=0),n>1&&(v.fy==null?v.y+=v.vy*=c:(v.y=v.fy,v.vy=0)),n>2&&(v.fz==null?v.z+=v.vz*=c:(v.z=v.fz,v.vz=0));return o}function x(){for(var g=0,k=e.length,_;g<k;++g){if(_=e[g],_.index=g,_.fx!=null&&(_.x=_.fx),_.fy!=null&&(_.y=_.fy),_.fz!=null&&(_.z=_.fz),isNaN(_.x)||n>1&&isNaN(_.y)||n>2&&isNaN(_.z)){var v=zi*(n>2?Math.cbrt(.5+g):n>1?Math.sqrt(.5+g):g),w=g*Bi,N=g*Hi;n===1?_.x=v:n===2?(_.x=v*Math.cos(w),_.y=v*Math.sin(w)):(_.x=v*Math.sin(w)*Math.cos(N),_.y=v*Math.cos(w),_.z=v*Math.sin(w)*Math.sin(N))}(isNaN(_.vx)||n>1&&isNaN(_.vy)||n>2&&isNaN(_.vz))&&(_.vx=0,n>1&&(_.vy=0),n>2&&(_.vz=0))}}function y(g){return g.initialize&&g.initialize(e,m,n),g}return x(),o={tick:p,restart:function(){return l.restart(h),o},stop:function(){return l.stop(),o},numDimensions:function(g){return arguments.length?(n=Math.min(Bn,Math.max(1,Math.round(g))),d.forEach(y),o):n},nodes:function(g){return arguments.length?(e=g,x(),d.forEach(y),o):e},alpha:function(g){return arguments.length?(s=+g,o):s},alphaMin:function(g){return arguments.length?(r=+g,o):r},alphaDecay:function(g){return arguments.length?(i=+g,o):+i},alphaTarget:function(g){return arguments.length?(a=+g,o):a},velocityDecay:function(g){return arguments.length?(c=1-g,o):1-c},randomSource:function(g){return arguments.length?(m=g,d.forEach(y),o):m},force:function(g,k){return arguments.length>1?(k==null?d.delete(g):d.set(g,y(k)),o):d.get(g)},find:function(){var g=Array.prototype.slice.call(arguments),k=g.shift()||0,_=(n>1?g.shift():null)||0,v=(n>2?g.shift():null)||0,w=g.shift()||1/0,N=0,j=e.length,M,D,K,F,L,Z;for(w*=w,N=0;N<j;++N)L=e[N],M=k-L.x,D=_-(L.y||0),K=v-(L.z||0),F=M*M+D*D+K*K,F<w&&(Z=L,w=F);return Z},on:function(g,k){return arguments.length>1?(u.on(g,k),o):u.on(g)}}}function Ui(){var e,t,n,o,s,r=Ye(-30),i,a=1,c=1/0,d=.81;function l(p){var x,y=e.length,g=(t===1?$o(e,At):t===2?Fo(e,At,Hn):t===3?zo(e,At,Hn,Oi):null).visitAfter(m);for(s=p,x=0;x<y;++x)n=e[x],g.visit(h)}function u(){if(e){var p,x=e.length,y;for(i=new Array(x),p=0;p<x;++p)y=e[p],i[y.index]=+r(y,p,e)}}function m(p){var x=0,y,g,k=0,_,v,w,N,j=p.length;if(j){for(_=v=w=N=0;N<j;++N)(y=p[N])&&(g=Math.abs(y.value))&&(x+=y.value,k+=g,_+=g*(y.x||0),v+=g*(y.y||0),w+=g*(y.z||0));x*=Math.sqrt(4/j),p.x=_/k,t>1&&(p.y=v/k),t>2&&(p.z=w/k)}else{y=p,y.x=y.data.x,t>1&&(y.y=y.data.y),t>2&&(y.z=y.data.z);do x+=i[y.data.index];while(y=y.next)}p.value=x}function h(p,x,y,g,k){if(!p.value)return!0;var _=[y,g,k][t-1],v=p.x-n.x,w=t>1?p.y-n.y:0,N=t>2?p.z-n.z:0,j=_-x,M=v*v+w*w+N*N;if(j*j/d<M)return M<c&&(v===0&&(v=xe(o),M+=v*v),t>1&&w===0&&(w=xe(o),M+=w*w),t>2&&N===0&&(N=xe(o),M+=N*N),M<a&&(M=Math.sqrt(a*M)),n.vx+=v*p.value*s/M,t>1&&(n.vy+=w*p.value*s/M),t>2&&(n.vz+=N*p.value*s/M)),!0;if(p.length||M>=c)return;(p.data!==n||p.next)&&(v===0&&(v=xe(o),M+=v*v),t>1&&w===0&&(w=xe(o),M+=w*w),t>2&&N===0&&(N=xe(o),M+=N*N),M<a&&(M=Math.sqrt(a*M)));do p.data!==n&&(j=i[p.data.index]*s/M,n.vx+=v*j,t>1&&(n.vy+=w*j),t>2&&(n.vz+=N*j));while(p=p.next)}return l.initialize=function(p,...x){e=p,o=x.find(y=>typeof y=="function")||Math.random,t=x.find(y=>[1,2,3].includes(y))||2,u()},l.strength=function(p){return arguments.length?(r=typeof p=="function"?p:Ye(+p),u(),l):r},l.distanceMin=function(p){return arguments.length?(a=p*p,l):Math.sqrt(a)},l.distanceMax=function(p){return arguments.length?(c=p*p,l):Math.sqrt(c)},l.theta=function(p){return arguments.length?(d=p*p,l):Math.sqrt(d)},l}function Go(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Wo(e){let t=e>>>0;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Vi(e,t=42){const n=Wo(Go(e)),o=n(),s=n(),r=2*Math.PI*o,i=Math.acos(2*s-1),a=t*Math.cbrt(n()),c=a*Math.sin(i)*Math.cos(r),d=a*Math.sin(i)*Math.sin(r),l=a*Math.cos(i);return[c,d,l]}function Yo(e){let t=2166136261;for(const n of e){for(let o=0;o<n.length;o++)t^=n.charCodeAt(o),t=Math.imul(t,16777619);t^=10,t=Math.imul(t,16777619)}return(t>>>0).toString(16)}const Gi=1592594996,Wi=1;function Yi(e){const t=[...e].sort();return Yo([`v${Wi}`,`n${t.length}`,...t])}function Xi(e){return e<=2e3?200:e<=5e3?150:e<=1e4?100:70}function Qi(e,t){const n=Tr(e),o=n.map(u=>u.key),s=new Map;if(o.forEach((u,m)=>s.set(u,m)),t&&t.length===o.length*3)return{keys:o,positions:t.slice(),indexByKey:s};const r=n.map(u=>{const[m,h,p]=Vi(u.key);return{key:u.key,x:m,y:h,z:p}}),i=n.filter(u=>u.parent!==null).map(u=>({source:u.parent,target:u.key})),a=Wo(Go("randomSource")^Gi),c=qi(r,3).force("charge",Ui().strength(-7)).force("link",Ci(i).id(u=>u.key).distance(5).strength(.85)).force("center",Ar(0,0,0)).stop(),d=c;typeof d.randomSource=="function"&&d.randomSource(a),c.tick(Xi(r.length));const l=new Float32Array(r.length*3);for(let u=0;u<r.length;u++){const m=r[u];l[u*3]=m.x??0,l[u*3+1]=m.y??0,l[u*3+2]=m.z??0}return{keys:o,positions:l,indexByKey:s}}function Zi(e,t){const n=ee(e.props.name)??"";return{id:e.id,name:n,qualifiedName:ee(e.props.qualified_name)??n,kind:e.labels[0]??"",filePath:ee(e.props.file_path)??ee(e.props.path)??"",startLine:Vt(e.props.start_line),endLine:Vt(e.props.end_line),language:ee(e.props.language)??"",role:ee(e.props.role)??"",semanticSummary:ee(e.props.semantic_summary),summaryOfHash:ee(e.props.summary_of_hash),contentHash:ee(e.props.content_hash),degree:t}}function Ji(e,t){const n=Cr(e),o=Qi(n,t?.cachedPositions),s=[],r=new Map,i=l=>r.set(l,(r.get(l)??0)+1);for(const l of e.edges){if(!Sr.has(l.type))continue;const u=l.from.split(":"),m=l.to.split(":"),h=u[0]==="rs1"&&m[0]==="rs1"&&u[1]!==m[1];s.push({from:l.from,to:l.to,type:l.type,resolution:Er(l.props),confidence:Vt(l.props.confidence,1),crossRepo:h}),i(l.from),i(l.to)}const a=new Map;for(const l of e.nodes)a.set(l.id,Zi(l,r.get(l.id)??0));const c=[];for(const l of e.nodes)c.push(l.id,ee(l.props.content_hash)??"");const d=Yo(c);return{tree:n,layout:o,drawEdges:s,records:a,degree:r,fingerprint:d}}const ea="reposkein-layout-cache",Oe="positions",ta=1;function na(){try{if(typeof indexedDB<"u")return indexedDB}catch{}return null}function Xo(){const e=na();return e?new Promise(t=>{let n;try{n=e.open(ea,ta)}catch{t(null);return}n.onupgradeneeded=()=>{const o=n.result;o.objectStoreNames.contains(Oe)||o.createObjectStore(Oe)},n.onsuccess=()=>t(n.result),n.onerror=()=>t(null),n.onblocked=()=>t(null)}):Promise.resolve(null)}async function oa(e){const t=await Xo();return t?new Promise(n=>{let o=!1;const s=r=>{o||(o=!0,t.close(),n(r))};try{const r=t.transaction(Oe,"readonly"),i=r.objectStore(Oe).get(e);i.onsuccess=()=>{const a=i.result;a&&a.byteLength>0&&a.byteLength%12===0?s(new Float32Array(a)):s(null)},i.onerror=()=>s(null),r.onerror=()=>s(null),r.onabort=()=>s(null)}catch{s(null)}}):null}async function sa(e,t){const n=await Xo();if(n)return new Promise(o=>{let s=!1;const r=()=>{s||(s=!0,n.close(),o())};try{const i=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),a=n.transaction(Oe,"readwrite");a.objectStore(Oe).put(i,e),a.oncomplete=r,a.onerror=r,a.onabort=r}catch{r()}})}function mt(){return typeof window>"u"?null:window.__REPOSKEIN_GRAPH__??null}function gt(){return mt()!==null}async function ra(e){const t=Ln(e.nodesText,e.edgesText);for(const r of e.federatedText??[]){const i=Ln(r.nodesText,r.edgesText);t.nodes.push(...i.nodes),t.edges.push(...i.edges)}const n=Yi(t.nodes.map(r=>r.id)),o=await oa(n),s=Ji(t,{cachedPositions:o??void 0});return o||sa(n,s.layout.positions.slice()),{type:"result",repoId:s.tree.repoId,rootKey:s.tree.rootKey,clusters:[...s.tree.byKey.values()],keys:s.layout.keys,positions:s.layout.positions,drawEdges:s.drawEdges,records:[...s.records.entries()],fingerprint:s.fingerprint,counts:{nodes:t.nodes.length,edges:t.edges.length},repoRoot:e.manifest.root.repoRoot??null,repoMeta:e.meta??null}}function ia(){return mt()?.cochange??{}}function aa(e,t,n){const o=mt()?.sourceSlices;if(!o)return null;for(const s of Object.values(o))if(s.path===e&&s.start===t&&s.end===n)return s;return null}function Qo(e,t=Object.is){let n=e;const o=new Set;return{get:()=>n,set(s){if(!t(n,s)){n=s;for(const r of o)r()}},subscribe(s){return o.add(s),()=>o.delete(s)}}}function vn(e){return b.useSyncExternalStore(e.subscribe,e.get,e.get)}function Zo(e){return b.useCallback(t=>e.set(t),[e])}function qn(e,t){const n=b.useRef(null);return n.current===null&&(n.current=Qo(e,t)),n.current}let wn=null;function ca(e){wn=e}function Jo(){return wn}function la(){wn=null,_n=null}function ua(e,t){if(e===t)return!0;if(!e||!t)return!1;for(let n=0;n<3;n++)if(e.position[n]!==t.position[n]||e.target[n]!==t.target[n])return!1;return!0}let _n=null;function Un(e){_n=e}function da(e){return _n?.(e)??!1}const Vn=50;let he=[],Je=[];function fa(e,t){if(e.selected!==t.selected||!ua(e.pose,t.pose))return!1;if(e.expanded===t.expanded)return!0;if(e.expanded.size!==t.expanded.size)return!1;for(const n of e.expanded)if(!t.expanded.has(n))return!1;return!0}function pa(e){const t=he[he.length-1];t&&fa(t,e)||(he.push(e),he.length>Vn&&(he=he.slice(he.length-Vn)),Je=[])}function ha(e){const t=he.pop();return t?(Je.push(e),t):null}function ma(e){const t=Je.pop();return t?(he.push(e),t):null}function ga(){return he.length>0}function xa(){return Je.length>0}function It(){he=[],Je=[]}function ya(e,t){return(e.ancestors.get(t)?.length??1)-1}function Gn(e){return e.size===0?new Set(Ht):new Set(Ht.filter(t=>!e.has(t)))}function ba(e,t,n){if(!t)return null;const o=e.clusterOfNode.get(t)??t,s=oe(e,t,ae(e,n));return s?s===o?t:e.byKey.get(s)?.nodeId??null:null}function Wn(e,t){const n=ba(e.model,e.selected,t),o=n===e.selected;return{...e,expanded:t,selected:n,focusTarget:null,impact:o?e.impact:null,focus:o?e.focus:null,fitNonce:e.fitNonce+1}}function Rt(e,t={}){return{...e,expanded:new Set([e.model.rootKey]),selected:null,focusTarget:null,impact:null,focus:null,fitNonce:e.fitNonce+1,...t}}function Yn(){return{lens:"all",emphasis:"none",audit:"off",filters:{kinds:new Set,edgeTypes:new Set,minConfidence:0}}}function es(e,t,n){if(!t)return null;const o=e.clusterOfNode.get(t)??t,s=e.ancestors.get(o);if(!s)return null;for(let r=s.length-2;r>=0;r--){const i=s[r];if(i===e.rootKey)break;if(n.has(i))return i}return null}function va(e,t){for(const n of t)if(e.byKey.get(n)?.kind==="file")return!0;return!1}function wa(e,t){switch(t.t){case"progress":return{...e,status:{kind:"loading",phase:t.phase}};case"ready":{const n=new Set([t.model.rootKey]);return{...e,status:{kind:"ready"},model:t.model,expanded:n,fitNonce:e.fitNonce+1}}case"error":return{...e,status:{kind:"error",message:t.message}};case"toggleExpand":{const n=new Set(e.expanded);return n.has(t.key)?n.delete(t.key):n.add(t.key),{...e,expanded:n,fitNonce:e.fitNonce+1}}case"collapseBranch":{const n=e.model;if(!n)return e;const o=es(n,e.selected,e.expanded);if(o===null)return e;const s=new Set(e.expanded);return s.delete(o),Wn(e,s)}case"collapseToFileLevel":{const n=e.model;if(!n)return e;const o=new Set;let s=!1;for(const r of e.expanded){if(n.byKey.get(r)?.kind==="file"){s=!0;continue}o.add(r)}return s?Wn(e,o):e}case"select":return{...e,selected:t.id,focusTarget:null,fitNonce:t.id!==null&&t.frame!==!1?e.fitNonce+1:e.fitNonce,impact:t.id===e.selected?e.impact:null,focus:t.id===e.selected?e.focus:null};case"requestFit":return{...e,fitNonce:e.fitNonce+1};case"revealAndSelect":{if(!e.model)return e;const n=e.model,o=He(n,e.expanded,[t.id]);if(t.collapseDeeper){const r=n.clusterOfNode.get(t.id)??t.id,i=ya(n,r);for(const a of[...o]){if(a===n.rootKey)continue;const c=n.ancestors.get(a);c&&c.indexOf(r)!==-1&&c.length-1>i&&o.delete(a)}}const s=t.id===e.selected;return{...e,expanded:o,selected:t.id,focusTarget:t.fly?t.id:null,impact:s?e.impact:null,focus:s?e.focus:null,fitNonce:t.fly?e.fitNonce+1:e.fitNonce}}case"revealWithoutRefit":{if(t.keys.length===0)return e;const n=new Set(e.expanded);let o=!1;for(const s of t.keys)n.has(s)||(n.add(s),o=!0);return o?{...e,expanded:n}:e}case"hop":{if(!e.model)return e;const n=He(e.model,e.expanded,[t.id]),o=t.id===e.selected;return{...e,expanded:n,selected:t.id,focusTarget:t.fly?t.id:null,fitNonce:t.fly?e.fitNonce+1:e.fitNonce,impact:o?e.impact:null,focus:o?e.focus:null,lastHop:t.memory,hopNonce:e.hopNonce+1}}case"restoreView":{if(!e.model)return e;const{selected:n,expanded:o,pose:s}=t.snapshot;return{...e,expanded:o,selected:n,focusTarget:null,impact:null,focus:null,lastHop:null,poseTarget:s,poseNonce:e.poseNonce+1}}case"setKindFilter":{const n=new Set(e.filters.kinds);return t.hidden?n.add(t.kind):n.delete(t.kind),{...e,filters:{...e.filters,kinds:n},lens:"all",emphasis:"none"}}case"setEdgeTypeFilter":{const n=new Set(e.filters.edgeTypes);return t.hidden?n.add(t.type):n.delete(t.type),{...e,filters:{...e.filters,edgeTypes:n},lens:"all",emphasis:"none"}}case"setMinConfidence":return{...e,filters:{...e.filters,minConfidence:t.value},lens:"all",emphasis:"none"};case"clearFilters":return{...e,filters:{kinds:new Set,edgeTypes:new Set,minConfidence:0},lens:"all",emphasis:"none",audit:"off"};case"setLens":{const n=gr(t.lens);return{...e,lens:t.lens,emphasis:n.emphasis,filters:{kinds:n.kinds,edgeTypes:n.edgeTypes,minConfidence:n.minConfidence},audit:"off"}}case"setAudit":return{...e,audit:t.mode};case"toggleCoupling":return{...e,coupling:!e.coupling};case"setCochange":return{...e,cochange:t.map};case"toggleImpact":{if(e.impact)return{...e,impact:null};if(!e.model||!e.selected)return e;const n=vr(e.model,e.selected),o=He(e.model,e.expanded,[...n.impacted,...n.coveringTests,e.selected]);return{...e,impact:n,expanded:o,fitNonce:e.fitNonce+1}}case"toggleFocus":{if(e.focus)return{...e,focus:null,fitNonce:e.fitNonce+1};if(!e.model||!e.selected)return e;const n=Rn(e.model.drawEdges,e.selected,e.focusDepth,Gn(e.filters.edgeTypes)),o=He(e.model,e.expanded,n.nodes);return{...e,focus:n,impact:null,expanded:o,fitNonce:e.fitNonce+1}}case"setFocusDepth":{const n=pt(t.depth);if(n===e.focusDepth)return e;if(e.focus&&e.model&&e.selected){const o=Rn(e.model.drawEdges,e.selected,n,Gn(e.filters.edgeTypes)),s=He(e.model,e.expanded,o.nodes);return{...e,focusDepth:n,focus:o,expanded:s,fitNonce:e.fitNonce+1}}return{...e,focusDepth:n}}case"setFocusTarget":return{...e,focusTarget:t.id,fitNonce:t.id!==null?e.fitNonce+1:e.fitNonce};case"startTour":return e.model?Rt(e,{tour:!0,emphasis:"none"}):e;case"exitTour":return{...e,...Yn(),tour:!1,focus:null,selected:null};case"resetView":return e.model?Rt(e,{...Yn(),coupling:!1}):e;case"resetExpansion":return e.model?Rt(e):e;case"setBundleBeta":return{...e,bundleBeta:Math.max(0,Math.min(1,t.value))};case"setIdleDrift":return e.idleDrift===t.on?e:{...e,idleDrift:t.on};case"retryLoad":return{...e,status:{kind:"loading",phase:"starting"},loadNonce:e.loadNonce+1};case"toggleLabels":return{...e,showLabels:!e.showLabels}}}const ts=b.createContext(null),ns=b.createContext(null),os=b.createContext(null);function _a(){return{status:{kind:"loading",phase:"starting"},model:null,expanded:new Set,selected:null,fitNonce:0,filters:{kinds:new Set,edgeTypes:new Set,minConfidence:0},focusTarget:null,poseTarget:null,poseNonce:0,lastHop:null,hopNonce:0,lens:"all",emphasis:"none",audit:"off",impact:null,coupling:!1,cochange:null,focus:null,focusDepth:Ut,tour:!1,bundleBeta:.85,idleDrift:!1,showLabels:!0,loadNonce:0}}const ka=(e,t)=>e.drawn===t.drawn&&e.total===t.total;function Na({children:e}){const[t,n]=b.useReducer(wa,void 0,_a),o=b.useRef(t);o.current=t;const s=b.useCallback(()=>({selected:o.current.selected,expanded:o.current.expanded,pose:Jo()}),[]),r=b.useCallback(l=>{const u=o.current;u.model&&(l&&!l(u)||pa(s()))},[s]),i=qn(null),a=qn({drawn:0,total:0},ka),c=b.useMemo(()=>({hovered:i,edgeStats:a}),[i,a]);b.useEffect(()=>{const l=mt();if(l){let m=!1;return Promise.resolve().then(async()=>{if(!m)try{n({t:"progress",phase:"parsing baked graph"});const h=await ra(l);m||n({t:"ready",model:Cn(h)})}catch(h){m||n({t:"error",message:h instanceof Error?h.message:String(h)})}}),()=>{m=!0}}const u=new lr;return u.onmessage=m=>{const h=m.data;h.type==="progress"?n({t:"progress",phase:h.phase}):h.type==="error"?n({t:"error",message:h.message}):h.type==="result"&&n({t:"ready",model:Cn(h)})},u.onerror=m=>n({t:"error",message:m.message}),u.postMessage({cmd:"load"}),()=>u.terminate()},[t.loadNonce]);const d=b.useMemo(()=>({toggleExpand:l=>{r(),n({t:"toggleExpand",key:l})},collapseBranch:()=>{r(l=>es(l.model,l.selected,l.expanded)!==null),n({t:"collapseBranch"})},collapseToFileLevel:()=>{r(l=>va(l.model,l.expanded)),n({t:"collapseToFileLevel"})},select:l=>n({t:"select",id:l,frame:l===null?!1:!da(l)}),requestFit:()=>n({t:"requestFit"}),revealAndSelect:(l,u)=>{r(),n({t:"revealAndSelect",id:l,fly:u?.fly,collapseDeeper:u?.collapseDeeper})},revealWithoutRefit:l=>n({t:"revealWithoutRefit",keys:l}),hop:(l,u,m)=>{r(),n({t:"hop",id:l,memory:u,fly:m})},historyBack:()=>{const l=ha(s());return l?(n({t:"restoreView",snapshot:l}),!0):!1},historyForward:()=>{const l=ma(s());return l?(n({t:"restoreView",snapshot:l}),!0):!1},setKindFilter:(l,u)=>n({t:"setKindFilter",kind:l,hidden:u}),setEdgeTypeFilter:(l,u)=>n({t:"setEdgeTypeFilter",type:l,hidden:u}),setMinConfidence:l=>n({t:"setMinConfidence",value:l}),clearFilters:()=>n({t:"clearFilters"}),setFocusTarget:l=>n({t:"setFocusTarget",id:l}),setLens:l=>n({t:"setLens",lens:l}),setAudit:l=>n({t:"setAudit",mode:l}),toggleImpact:()=>n({t:"toggleImpact"}),toggleFocus:()=>n({t:"toggleFocus"}),setFocusDepth:l=>n({t:"setFocusDepth",depth:l}),toggleCoupling:()=>n({t:"toggleCoupling"}),setCochange:l=>n({t:"setCochange",map:l}),startTour:()=>{It(),n({t:"startTour"})},exitTour:()=>n({t:"exitTour"}),resetView:()=>{It(),n({t:"resetView"})},resetExpansion:()=>{It(),n({t:"resetExpansion"})},setBundleBeta:l=>n({t:"setBundleBeta",value:l}),setIdleDrift:l=>n({t:"setIdleDrift",on:l}),retryLoad:()=>n({t:"retryLoad"}),toggleLabels:()=>n({t:"toggleLabels"}),hover:l=>i.set(l),setEdgeStats:l=>a.set(l)}),[i,a,r,s]);return f.jsx(os.Provider,{value:c,children:f.jsx(ns.Provider,{value:d,children:f.jsx(ts.Provider,{value:t,children:e})})})}function pe(){const e=b.useContext(ts);if(!e)throw new Error("useStoreState must be used within StoreProvider");return e}function ss(){const e=b.useContext(ns);if(!e)throw new Error("useActions must be used within StoreProvider");return e}function xt(){const e=b.useContext(os);if(!e)throw new Error("channel hooks must be used within StoreProvider");return e}function yt(){return vn(xt().hovered)}function Sa(){return Zo(xt().hovered)}function Ea(){return vn(xt().edgeStats)}function ja(){return Zo(xt().edgeStats)}function X(){const e=pe(),t=ss();return b.useMemo(()=>({...e,...t}),[e,t])}const J=e=>{const t=parseInt(e.replace("#",""),16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]},Ee={amber:"#F2B84B",teal:"#2DD4BF",cream:"#EAE7DC",navy:"#070A12"},Be={amber:J(Ee.amber),teal:J(Ee.teal),cream:J(Ee.cream),navy:J(Ee.navy)};function Yt(e,t){if(e==="galaxy")return J("#ffffff");if(e==="dir")return J("#9aa7c7");if(e==="file")return J("#6ea8ff");switch(t){case"Function":return J("#ffe08a");case"Class":return J("#5fe0e0");case"Interface":return J("#b98aff");case"Enum":return J("#7ce08a");case"Variable":return J("#9aa0a8");default:return J("#cfd6e4")}}const rs={rust:"#ff7a45",python:"#4b8bff",typescript:"#3aa0ff",javascript:"#f4d03f",go:"#39c5cf",java:"#e76f51",csharp:"#9b6dff"},Ma="#8a93a8",Ca={rust:"Rust",python:"Python",typescript:"TypeScript",javascript:"JavaScript",go:"Go",java:"Java",csharp:"C#"};function Ta(e){return rs[e]??Ma}function Aa(e){return J(Ta(e))}const Ia={CALLS:J("#ffd166"),IMPORTS:J("#6ea8ff"),INSTANTIATES:J("#ef8aff"),IMPLEMENTS:J("#5fe0e0"),INHERITS:J("#7ce08a")};function is(e){return Ia[e]??J("#8892a6")}const as=.15;function Ra(e){switch(e){case"exact":return .75;case"name_match":return .42;case"ambiguous":return as}}function La(e,t){const o=Ra(e)*(1+.18*Math.log(1+t));return Math.min(1,Math.max(as,o))}const Xn=220,Ka=.04;function Pa(e){return e<=Xn?1:Math.max(Ka,Xn/e)}const Qn=.1;function $a(e,t,n){const o=Math.max(e,t,n);if(o>0&&o<Qn){const s=Qn/o;return[e*s,t*s,n*s]}return[e,t,n]}const Da=1,Fa=12;function Oa(e,t){const o=(e==="galaxy"?6:e==="dir"?3.5:e==="file"?2.6:1.4)+.9*Math.log(1+t);return Math.min(Fa,Math.max(Da,o))}const cs=[{type:"CALLS",color:"#ffd166",label:"Calls"},{type:"IMPORTS",color:"#6ea8ff",label:"Imports"},{type:"INSTANTIATES",color:"#ef8aff",label:"Instantiates"},{type:"IMPLEMENTS",color:"#5fe0e0",label:"Implements"},{type:"INHERITS",color:"#7ce08a",label:"Inherits"}],ls=[{kind:"galaxy",color:"#ffffff",label:"Repo"},{kind:"dir",color:"#9aa7c7",label:"Directory"},{kind:"file",color:"#6ea8ff",label:"File"},{kind:"Function",color:"#ffe08a",label:"Function"},{kind:"Class",color:"#5fe0e0",label:"Class"},{kind:"Interface",color:"#b98aff",label:"Interface"},{kind:"Enum",color:"#7ce08a",label:"Enum"},{kind:"Variable",color:"#9aa0a8",label:"Variable"}],za=["galaxy","dir","file"],Ba=ls.filter(e=>!za.includes(e.kind)).map(e=>({...e,filterKey:e.kind.toLowerCase()})),Zn=500;function Jn(e){const t=Math.min(1,Math.max(0,e));return 1-Math.pow(1-t,3)}function Ha(e,t){const n=[],o=[];for(const s of t)e.has(s)||n.push(s);for(const s of e)t.has(s)||o.push(s);return{expanded:n,collapsed:o}}const eo=new Map;function qa(e){return`${e.size}|${e.stops.map(t=>`${t.offset}:${t.alpha}`).join(",")}`}function kn(e){const t=qa(e),n=eo.get(t);if(n)return n;const{size:o,stops:s}=e,r=document.createElement("canvas");r.width=r.height=o;const i=r.getContext("2d"),a=i.createRadialGradient(o/2,o/2,0,o/2,o/2,o/2);for(const d of s)a.addColorStop(d.offset,`rgba(255,255,255,${d.alpha})`);i.fillStyle=a,i.fillRect(0,0,o,o);const c=new nr(r);return c.needsUpdate=!0,eo.set(t,c),c}const Ua={size:64,stops:[{offset:0,alpha:1},{offset:.4,alpha:.6},{offset:1,alpha:0}]},Va={size:64,stops:[{offset:0,alpha:1},{offset:.4,alpha:.5},{offset:1,alpha:0}]},Ga={size:128,stops:[{offset:0,alpha:.55},{offset:.25,alpha:.22},{offset:.6,alpha:.05},{offset:1,alpha:0}]},Wa=Be.amber,Ya=Be.teal,Xa=Be.amber,Qa=Be.teal,fe=.18,et=1.9,Za=1.1;function Ja(){const e=pe(),t=ss(),n=e.model,o=b.useRef(null),s=b.useRef(null),r=yt(),i=Sa(),a=b.useMemo(()=>[...ae(n,e.expanded)],[n,e.expanded]),c=b.useMemo(()=>dr(n,r,new Set(a)),[r,n,a]),d=b.useMemo(()=>{if(!e.impact)return null;const C=new Set(a),T=te=>oe(n,te,C),P=new Set,$=new Set,U=T(e.impact.sourceId);for(const te of e.impact.impacted){const O=T(te);O&&P.add(O)}for(const te of e.impact.coveringTests){const O=T(te);O&&$.add(O)}return{impacted:P,covering:$,sourceRep:U}},[e.impact,n,a]),l=b.useMemo(()=>{if(!e.focus)return null;const C=new Set(a),T=new Set;for(const P of e.focus.nodes){const $=oe(n,P,C);$&&T.add($)}return T},[e.focus,n,a]),u=b.useMemo(()=>{if(e.emphasis!=="tests")return null;const C=new Set(a),T=new Set;for(const P of n.records.values()){if(!Lo(P))continue;const $=oe(n,P.id,C);$&&T.add($)}return T},[e.emphasis,n,a]),m=b.useMemo(()=>e.selected?oe(n,e.selected,new Set(a)):null,[e.selected,n,a]),h=b.useMemo(()=>r?oe(n,r,new Set(a)):null,[r,n,a]),{geometry:p,keysAt:x}=b.useMemo(()=>{const C=e.filters.kinds.size>0?a.filter(S=>{const E=n.byKey.get(S);return!(E?.symbolKind&&e.filters.kinds.has(E.symbolKind.toLowerCase()))}):a,T=C.length,P=new Float32Array(T*3),$=new Float32Array(T*3),U=new Float32Array(T),te=new Array(T);for(let S=0;S<T;S++){const E=C[S],I=n.indexByKey.get(E);if(te[S]=E,I===void 0)continue;P[S*3]=n.positions[I*3],P[S*3+1]=n.positions[I*3+1],P[S*3+2]=n.positions[I*3+2];const R=n.byKey.get(E),z=R.nodeId?n.records.get(R.nodeId)?.degree??0:0;let[A,B,V]=Yt(R.kind,R.symbolKind);if(d)E===d.sourceRep||(d.covering.has(E)?[A,B,V]=Ya:d.impacted.has(E)?[A,B,V]=Wa:(A*=fe,B*=fe,V*=fe));else if(l)l.has(E)||(A*=fe,B*=fe,V*=fe);else if(e.emphasis==="types"){const de=R.symbolKind?.toLowerCase();R.kind==="symbol"&&!(de&&mr.has(de))&&(A*=fe,B*=fe,V*=fe)}else u&&(u.has(E)||(A*=fe,B*=fe,V*=fe));d||(h&&E===h?[A,B,V]=Qa:m&&E===m&&([A,B,V]=Xa));let q=et;c&&!c.has(E)&&(q*=.22),A*=q,B*=q,V*=q;const[we,Ae,le]=$a(A,B,V);$[S*3]=we,$[S*3+1]=Ae,$[S*3+2]=le;const ge=E===m||E===h?1.6:l?.has(E)?1.25:1;U[S]=Oa(R.kind,z)*ge}const O=new ke;return O.setAttribute("position",new ye(P,3)),O.setAttribute("color",new ye($,3)),O.setAttribute("aSize",new ye(U,1)),{geometry:O,keysAt:te}},[a,n,c,e.filters,d,l,u,e.emphasis,m,h]);b.useEffect(()=>()=>p.dispose(),[p]);const y=b.useRef(null),g=b.useRef(new Map),k=b.useRef(new Set(e.expanded)),_=b.useRef(null),v=b.useRef(null),[w,N]=b.useState(0);b.useEffect(()=>{const C=k.current,T=e.expanded,{expanded:P,collapsed:$}=Ha(C,T);if(k.current=new Set(T),P.length===0&&$.length===0)return;const U=performance.now(),te=new Set(P);if(P.length>0){const O=ae(n,T),S=new Map;for(const E of O){const I=n.ancestors.get(E);if(!I)continue;let R=null;for(let A=I.length-1;A>=0;A--){const B=I[A];if(B!==E&&te.has(B)){R=B;break}}if(!R)continue;const z=g.current.get(E);if(z)S.set(E,z);else{const A=n.indexByKey.get(R);if(A===void 0)continue;S.set(E,[n.positions[A*3],n.positions[A*3+1],n.positions[A*3+2]])}}y.current=S.size>0?{origin:S,start:U}:null}if($.length>0){const O=ae(n,C),S=ae(n,T),E=new Set($),I=[];for(const R of O){if(S.has(R))continue;const z=n.ancestors.get(R);if(!z)continue;let A=null;for(let B=z.length-1;B>=0;B--){const V=z[B];if(V!==R&&E.has(V)){A=V;break}}A&&I.push({key:R,into:A})}if(I.length>0){const R=I.length,z=new Float32Array(R*3),A=new Float32Array(R*3),B=new Float32Array(R*3),V=new Float32Array(R*3);for(let q=0;q<R;q++){const{key:we,into:Ae}=I[q],le=n.indexByKey.get(we),ge=n.indexByKey.get(Ae);if(le===void 0||ge===void 0)continue;const de=g.current.get(we)??[n.positions[le*3],n.positions[le*3+1],n.positions[le*3+2]];z[q*3]=de[0],z[q*3+1]=de[1],z[q*3+2]=de[2],B[q*3]=de[0],B[q*3+1]=de[1],B[q*3+2]=de[2],A[q*3]=n.positions[ge*3],A[q*3+1]=n.positions[ge*3+1],A[q*3+2]=n.positions[ge*3+2];const Se=n.byKey.get(we),Et=Se?Yt(Se.kind,Se.symbolKind):[.8,.85,.95];V[q*3]=Et[0]*et,V[q*3+1]=Et[1]*et,V[q*3+2]=Et[2]*et}v.current={positions:B,origin:z,target:A,colors:V,start:U},N(q=>q+1)}}},[e.expanded,n]);const j=b.useRef(null);b.useEffect(()=>{j.current=performance.now()},[]);const M=b.useMemo(()=>new ke,[]);b.useEffect(()=>()=>M.dispose(),[M]),Ze(({invalidate:C})=>{const T=s.current;if(T){const E=j.current;let I=1;E!==null&&(I=Math.min(1,(performance.now()-E)/1e3/Za),I<1&&C(),I=1-Math.pow(1-I,3)),T.opacity=.95*I,T.size=.3+.7*I}const P=performance.now(),$=o.current,U=$?.geometry.getAttribute("position"),te=g.current;if($&&U){const E=U.array,I=y.current,R=I?Jn((P-I.start)/Zn):1;let z=!1;te.clear();for(let A=0;A<x.length;A++){const B=x[A],V=n.indexByKey.get(B);if(V===void 0)continue;const q=n.positions[V*3],we=n.positions[V*3+1],Ae=n.positions[V*3+2],le=I&&R<1?I.origin.get(B):void 0;let ge=q,de=we,Se=Ae;le&&(ge=le[0]+(q-le[0])*R,de=le[1]+(we-le[1])*R,Se=le[2]+(Ae-le[2])*R,z=!0),E[A*3]=ge,E[A*3+1]=de,E[A*3+2]=Se,te.set(B,[ge,de,Se])}U.needsUpdate=!0,R>=1&&(y.current=null),z&&C()}const O=v.current,S=_.current;if(O&&S){const E=Jn((P-O.start)/Zn),I=O.positions.length/3;for(let A=0;A<I;A++)O.positions[A*3]=O.origin[A*3]+(O.target[A*3]-O.origin[A*3])*E,O.positions[A*3+1]=O.origin[A*3+1]+(O.target[A*3+1]-O.origin[A*3+1])*E,O.positions[A*3+2]=O.origin[A*3+2]+(O.target[A*3+2]-O.origin[A*3+2])*E;const R=S.geometry.getAttribute("position");R&&(R.needsUpdate=!0);const z=S.material;z.opacity=.95*(1-E),E>=1?(v.current=null,z.opacity=0):C()}}),b.useEffect(()=>{const C=v.current;if(!C)return;const T=new ye(C.positions,3);M.setAttribute("position",T),M.setAttribute("color",new ye(C.colors,3)),T.needsUpdate=!0},[w,M]);const D=C=>{C.stopPropagation();const T=C.index;if(T===void 0)return;const P=x[T];if(!P)return;const $=n.byKey.get(P);$&&($.kind==="symbol"?t.select($.nodeId??P):(t.toggleExpand(P),$.nodeId&&t.select($.nodeId)))},K=b.useRef(null),F=b.useRef(null),L=b.useRef(r);b.useEffect(()=>{L.current=r},[r]),b.useEffect(()=>()=>{F.current!==null&&cancelAnimationFrame(F.current)},[]);const Z=C=>{K.current=C,F.current===null&&(F.current=requestAnimationFrame(()=>{F.current=null;const T=K.current;T!==L.current&&(L.current=T,i(T))}))},se=C=>{C.stopPropagation();const T=C.index,P=T===void 0?null:x[T]??null,$=P?n.byKey.get(P):null;Z($?.nodeId??P??null)},re=()=>Z(null),me=b.useMemo(()=>kn(Ua),[]);return f.jsxs(f.Fragment,{children:[f.jsx("points",{ref:o,geometry:p,onClick:D,onPointerMove:se,onPointerOut:re,raycast:tc,renderOrder:10,children:f.jsx("pointsMaterial",{ref:s,size:1,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.95,depthWrite:!1,blending:De,map:me,onBeforeCompile:ec})}),f.jsx("points",{ref:_,geometry:M,raycast:()=>null,children:f.jsx("pointsMaterial",{size:3,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:0,depthWrite:!1,blending:De,map:me})})]})}function ec(e){e.vertexShader=e.vertexShader.replace("uniform float size;",`uniform float size;
|
|
4
|
+
attribute float aSize;`).replace("gl_PointSize = size;","gl_PointSize = size * aSize;")}function tc(e,t){const n=e.params.Points?.threshold;e.params.Points&&(e.params.Points.threshold=2.5),or.prototype.raycast.call(this,e,t),e.params.Points&&n!==void 0&&(e.params.Points.threshold=n)}function nc(e=!0){Ze(({invalidate:t})=>{e&&t()})}function oc(){return nc(),f.jsx(Ys,{radius:600,depth:120,count:2600,factor:6,saturation:0,fade:!0,speed:.6})}const sc={rs:"rust",py:"python",pyi:"python",ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",go:"go",java:"java",cs:"csharp"};function rc(e){const t=e.trim().toLowerCase();return t===""?"":t==="c#"||t==="c-sharp"||t==="cs"?"csharp":t==="ts"?"typescript":t==="js"?"javascript":t==="py"?"python":t==="golang"?"go":t}function to(e){const t=e.lastIndexOf(".");if(t<0||t===e.length-1)return"";const n=e.slice(t+1).toLowerCase();return sc[n]??""}function us(e,t){const n=e.byKey.get(t);if(!n)return"";if(n.nodeId){const o=e.records.get(n.nodeId);if(o){const s=rc(o.language);if(s)return s;const r=to(o.filePath||n.name);if(r)return r}}return to(n.name)}function ic(e){const t=new Set;for(const n of e.byKey.values()){if(n.kind!=="file")continue;const o=us(e,n.key);o&&t.add(o)}return[...t].sort()}function ac(e){const t=new Map,n=s=>{let r=t.get(s);return r||(r=new Map,t.set(s,r)),r};for(const s of e.byKey.values()){if(s.kind!=="file")continue;const r=us(e,s.key);if(!r)continue;const i=e.ancestors.get(s.key);if(i)for(const a of i){const c=n(a);c.set(r,(c.get(r)??0)+1)}}const o=new Map;for(const[s,r]of t){let i="",a=0;for(const[c,d]of[...r.entries()].sort((l,u)=>l[0]<u[0]?-1:1))d>a&&(a=d,i=c);i&&o.set(s,i)}return o}function cc(){const e=X(),t=e.model,n=b.useMemo(()=>lc(t),[t]),o=b.useMemo(()=>ac(t),[t]),s=b.useMemo(()=>{const a=ae(t,e.expanded),c=[],d=[],l=[];for(const m of a){const h=t.byKey.get(m);if(!h||h.kind==="symbol")continue;const p=t.indexByKey.get(m);if(p===void 0)continue;const x=n.get(m)??0,y=h.kind==="galaxy"?26:h.kind==="dir"?16:9,g=Math.max(y,x*2.2),k=o.get(m),_=k?Aa(k):h.kind==="galaxy"?Be.amber:Yt(h.kind,h.symbolKind),v=.34,w=_[0]*v,N=_[1]*v,j=_[2]*v;c.push(t.positions[p*3],t.positions[p*3+1],t.positions[p*3+2]),d.push(w,N,j),l.push(g)}const u=new ke;return u.setAttribute("position",new je(c,3)),u.setAttribute("color",new je(d,3)),u.setAttribute("aSize",new je(l,1)),u},[t,e.expanded,n,o]);b.useEffect(()=>()=>s.dispose(),[s]);const r=b.useMemo(()=>kn(Ga),[]),i=b.useMemo(()=>uc(r),[r]);return b.useEffect(()=>()=>i.dispose(),[i]),f.jsx("points",{geometry:s,material:i,renderOrder:-1,raycast:()=>null})}function lc(e){const t=new Map;for(const[n]of e.indexByKey){const o=e.byKey.get(n);!o||o.kind==="symbol"||t.set(n,0)}for(const[n,o]of e.indexByKey){const s=e.ancestors.get(n);if(!s)continue;const r=e.positions[o*3],i=e.positions[o*3+1],a=e.positions[o*3+2];for(const c of s){if(c===n)continue;const d=e.indexByKey.get(c);if(d===void 0)continue;const l=r-e.positions[d*3],u=i-e.positions[d*3+1],m=a-e.positions[d*3+2],h=Math.sqrt(l*l+u*u+m*m),p=t.get(c);p!==void 0&&h>p&&t.set(c,h)}}return t}function uc(e){const t=new sr({size:1,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.5,depthWrite:!1,blending:De,map:e,fog:!0});return t.onBeforeCompile=n=>{n.vertexShader=n.vertexShader.replace("uniform float size;",`uniform float size;
|
|
5
|
+
attribute float aSize;`).replace("gl_PointSize = size;","gl_PointSize = aSize;")},t}function no(e,t){const n=e.x-t.x,o=e.y-t.y,s=e.z-t.z;return n*n+o*o+s*s}function dc(e){const t=e.length;if(t<2)return[];const n=new Array(t).fill(!1),o=new Array(t).fill(1/0),s=new Array(t).fill(-1);n[0]=!0;for(let i=1;i<t;i++)o[i]=no(e[0],e[i]),s[i]=0;const r=[];for(let i=1;i<t;i++){let a=-1,c=1/0;for(let l=0;l<t;l++)n[l]||o[l]<c&&(c=o[l],a=l);if(a===-1)break;n[a]=!0;const d=s[a];r.push(d<a?[d,a]:[a,d]);for(let l=0;l<t;l++){if(n[l])continue;const u=no(e[a],e[l]);u<o[l]&&(o[l]=u,s[l]=a)}}return r.sort((i,a)=>i[0]!==a[0]?i[0]-a[0]:i[1]-a[1]),r}const oo=80;function fc(){const e=X(),t=e.model,n=b.useMemo(()=>{const s=ae(t,e.expanded),r=[];for(const a of e.expanded){const c=t.byKey.get(a);if(!c||c.children.length<2)continue;const d=[];for(const u of c.children){if(!s.has(u))continue;const m=t.indexByKey.get(u);if(m!==void 0&&(d.push({key:u,x:t.positions[m*3],y:t.positions[m*3+1],z:t.positions[m*3+2]}),d.length>oo))break}if(d.length<2||d.length>oo)continue;const l=dc(d);for(const[u,m]of l){const h=d[u],p=d[m];r.push(h.x,h.y,h.z,p.x,p.y,p.z)}}const i=new ke;return i.setAttribute("position",new je(r,3)),i},[t,e.expanded]);b.useEffect(()=>()=>n.dispose(),[n]);const o=b.useMemo(()=>{const[s,r,i]=Be.teal,a=.06;return new mn({color:new rr(s*a,r*a,i*a),transparent:!0,depthWrite:!1,blending:De,fog:!0})},[]);return b.useEffect(()=>()=>o.dispose(),[o]),f.jsx("lineSegments",{geometry:n,material:o,raycast:()=>null})}const so=15e4,pc=12,ro=8,hc=4e3;function Nn(e,t,n){const o=e.ancestors.get(t),s=e.ancestors.get(n);if(!o||!s)return[t,n];let r=0;const i=Math.min(o.length,s.length);for(;r<i&&o[r]===s[r];)r++;const a=r-1;if(a<0)return[t,n];const c=[];for(let d=o.length-1;d>=a;d--)c.push(o[d]);for(let d=a+1;d<s.length;d++)c.push(s[d]);return c}function mc(e,t){const n=t.length>hc,o=n?ro:pc,s=n?4:ro,r=t.map(c=>{const d=Nn(e,c.srcKey,c.dstKey).length;return d<=2?1:d===3?s:o}),i=r.reduce((c,d)=>c+d,0);if(i<=so)return r;const a=so/i;return r.map(c=>Math.max(1,Math.floor(c*a)))}let G=new Float64Array(64),W=new Float64Array(64),Y=new Float64Array(64);function ds(e){if(e<=G.length)return;const t=Math.max(e,G.length*2);G=new Float64Array(t),W=new Float64Array(t),Y=new Float64Array(t)}let Q=new Float64Array(64);function fs(e){e>Q.length&&(Q=new Float64Array(Math.max(e,Q.length*2)))}function gc(e,t,n,o){const s=mc(e,t);let r=0;for(const m of s)r+=m;const i=new Float32Array(r*2*3),a=new Float32Array(r*2*3);let c=0;const d=e.positions,l=e.indexByKey;for(let m=0;m<t.length;m++){const h=t[m],p=s[m],x=h.a*o,y=h.r*x,g=h.g*x,k=h.b*x,_=Nn(e,h.srcKey,h.dstKey);ds(_.length);let v=0;for(const C of _){const T=l.get(C);T!==void 0&&(G[v]=d[T*3],W[v]=d[T*3+1],Y[v]=d[T*3+2],v++)}if(v<2)continue;if(p===1||v===2){c=io(i,a,c,G[0],W[0],Y[0],G[v-1],W[v-1],Y[v-1],y,g,k);continue}const w=v-1,N=G[0],j=W[0],M=Y[0],D=G[w],K=W[w],F=Y[w];for(let C=1;C<w;C++){const T=C/w,P=N+(D-N)*T,$=j+(K-j)*T,U=M+(F-M)*T;G[C]=n*G[C]+(1-n)*P,W[C]=n*W[C]+(1-n)*$,Y[C]=n*Y[C]+(1-n)*U}fs(v),Q[0]=0;for(let C=1;C<v;C++){const T=G[C]-G[C-1],P=W[C]-W[C-1],$=Y[C]-Y[C-1],U=Math.sqrt(Math.sqrt(T*T+P*P+$*$));Q[C]=Q[C-1]+(U>1e-6?U:1e-6)}const L=Q[0],Z=Q[w];let se=G[0],re=W[0],me=Y[0];for(let C=1;C<=p;C++){const T=L+(Z-L)*C/p;let P=0;for(;P<w-1&&Q[P+1]<T;)P++;const $=Pe(G,Q,P,w,T),U=Pe(W,Q,P,w,T),te=Pe(Y,Q,P,w,T);c=io(i,a,c,se,re,me,$,U,te,y,g,k),se=$,re=U,me=te}}const u=new ke;return u.setAttribute("position",new ye(i,3)),u.setAttribute("color",new ye(a,3)),u.setDrawRange(0,c/3),u}const Ce=10;function xc(e,t,n,o,s,r){const i=e.positions,a=e.indexByKey,c=Nn(e,t,n);ds(c.length);let d=0;for(const v of c){const w=a.get(v);w!==void 0&&(G[d]=i[w*3],W[d]=i[w*3+1],Y[d]=i[w*3+2],d++)}if(d<2)return 0;const l=Ce+1;if(d===2){const v=G[0],w=W[0],N=Y[0],j=G[1],M=W[1],D=Y[1];for(let K=0;K<l;K++){const F=K/Ce;s[r+K*3]=v+(j-v)*F,s[r+K*3+1]=w+(M-w)*F,s[r+K*3+2]=N+(D-N)*F}return l}const u=d-1,m=G[0],h=W[0],p=Y[0],x=G[u],y=W[u],g=Y[u];for(let v=1;v<u;v++){const w=v/u;G[v]=o*G[v]+(1-o)*(m+(x-m)*w),W[v]=o*W[v]+(1-o)*(h+(y-h)*w),Y[v]=o*Y[v]+(1-o)*(p+(g-p)*w)}fs(d),Q[0]=0;for(let v=1;v<d;v++){const w=G[v]-G[v-1],N=W[v]-W[v-1],j=Y[v]-Y[v-1],M=Math.sqrt(Math.sqrt(w*w+N*N+j*j));Q[v]=Q[v-1]+(M>1e-6?M:1e-6)}const k=Q[0],_=Q[u];for(let v=0;v<l;v++){const w=k+(_-k)*v/Ce;let N=0;for(;N<u-1&&Q[N+1]<w;)N++;s[r+v*3]=Pe(G,Q,N,u,w),s[r+v*3+1]=Pe(W,Q,N,u,w),s[r+v*3+2]=Pe(Y,Q,N,u,w)}return l}function Pe(e,t,n,o,s){const r=n,i=n+1,a=r>0?r-1:r,c=i<o?i+1:i,d=t[a],l=t[r],u=t[i],m=t[c],h=e[a],p=e[r],x=e[i],y=e[c],g=l-d,k=u-l,_=m-u,v=g>1e-9?((l-s)*h+(s-d)*p)/g:p,w=k>1e-9?((u-s)*p+(s-l)*x)/k:p,N=_>1e-9?((m-s)*x+(s-u)*y)/_:x,j=u-d,M=m-l,D=j>1e-9?((u-s)*v+(s-d)*w)/j:w,K=M>1e-9?((m-s)*w+(s-l)*N)/M:w;return k>1e-9?((u-s)*D+(s-l)*K)/k:D}function io(e,t,n,o,s,r,i,a,c,d,l,u){return e[n]=o,e[n+1]=s,e[n+2]=r,e[n+3]=i,e[n+4]=a,e[n+5]=c,t[n]=d,t[n+1]=l,t[n+2]=u,t[n+3]=d,t[n+4]=l,t[n+5]=u,n+6}function ao(e){return e.startsWith("galaxy:")?e:e.split(":")[1]??e}function co(e,t){for(const n of e)if(t.has(n))return!0;return!1}function yc(){const e=pe(),t=e.model,n=yt(),o=ja(),{geometry:s,drawn:r,total:i}=b.useMemo(()=>{const c=[e.selected,n,...e.focus?.nodes??[]].filter(Boolean),{bundles:d,visible:l,total:u}=Ro(t,{expanded:e.expanded,filters:{edgeTypes:e.filters.edgeTypes,minConfidence:e.filters.minConfidence,audit:e.audit},activeNodes:c}),m=e.selected?Bt(t,e.selected,l):null,h=n?ur(t,n,l):null,p=To(t,e.focus,l),x=new Set;if(m&&x.add(m),h&&x.add(h),p)for(const w of p)x.add(w);const y=x.size>0,g=e.impact?new Set([e.impact.sourceId,...e.impact.impacted]):null,k=[];for(const w of d){if(!t.indexByKey.has(w.srcKey)||!t.indexByKey.has(w.dstKey))continue;let[N,j,M]=is(w.dominantType),D=La(w.bestResolution,w.count)*w.lengthAtten;if(g&&(w.dominantType==="CALLS"&&co(w.srcNodes,g)&&co(w.dstNodes,g)?(N=1,j=.42,M=.32,D=Math.min(1,D*1.8)):D*=.08),y){const K=p?p.has(w.srcKey)&&p.has(w.dstKey):!1,F=x.has(w.srcKey)||x.has(w.dstKey);K?D=Math.min(1,D*1.5):F?D=Math.min(1,D*1.3):D*=.06}ao(w.srcKey)!==ao(w.dstKey)&&(N=Math.min(1,N*1.8),j=Math.min(1,j*1.8),M=Math.min(1,M*1.8)),k.push({srcKey:w.srcKey,dstKey:w.dstKey,r:N,g:j,b:M,a:D})}const _=Pa(k.length);return{geometry:gc(t,k,e.bundleBeta,_),drawn:k.length,total:u}},[t,e.expanded,e.selected,n,e.filters,e.audit,e.impact,e.focus,e.bundleBeta]);b.useEffect(()=>()=>s.dispose(),[s]),b.useEffect(()=>{o({drawn:r,total:i})},[r,i,o]);const a=b.useMemo(()=>new mn({vertexColors:!0,transparent:!0,depthWrite:!1,blending:De}),[]);return b.useEffect(()=>()=>a.dispose(),[a]),f.jsx("lineSegments",{geometry:s,material:a,renderOrder:5})}function lo(e){return Math.min(4,1+Math.floor(Math.log2(1+e)))}function uo(e,t){return t<=1?0:e/t}function bc(e,t=3e3,n){const o=[];if(e.length===0||t<=0)return{particles:o};const s=[],r=[];for(let c=0;c<e.length;c++)n&&n(e[c],c)?s.push(c):r.push(c);const i=(c,d)=>{for(let l=0;l<d&&o.length<t;l++)o.push({bundleIndex:c,phase:uo(l,d)})};for(const c of s){if(o.length>=t)break;i(c,lo(e[c].count))}const a=t-o.length;if(a>0&&r.length>0)if(r.length<=a){for(const c of r)i(c,1);for(const c of r){if(o.length>=t)break;const d=lo(e[c].count)-1;for(let l=1;l<=d&&o.length<t;l++)o.push({bundleIndex:c,phase:uo(l,d+1)})}}else{const c=Math.ceil(r.length/a);for(let d=0;d<r.length&&o.length<t;d+=c)i(r[d],1)}return{particles:o}}const vc=3e3,wc=.32,_c=.8,kc=.55,Nc=Ce+1;function Sc(){const e=pe(),t=e.model,n=yt(),{geometry:o,curves:s,curveBase:r,phaseArr:i,count:a}=b.useMemo(()=>{const d=[e.selected,n,...e.focus?.nodes??[]].filter(Boolean),{bundles:l,visible:u}=Ro(t,{expanded:e.expanded,filters:{edgeTypes:e.filters.edgeTypes,minConfidence:e.filters.minConfidence,audit:e.audit},activeNodes:d});let m=l;if(e.focus){const L=To(t,e.focus,u);L&&(m=l.filter(Z=>L.has(Z.srcKey)&&L.has(Z.dstKey)))}const h=new Set,p=e.selected?Bt(t,e.selected,u):null,x=n?Bt(t,n,u):null;p&&h.add(p),x&&h.add(x);const y=h.size>0?L=>h.has(L.srcKey)||h.has(L.dstKey):void 0,{particles:g}=bc(m,vc,y),k=g.length,_=new Map,v=new Float32Array(k*Nc*3);let w=0;const N=new Float32Array(k),j=new Int32Array(k),M=new Float32Array(k*3),D=new Float32Array(k*3);let K=0;for(let L=0;L<k;L++){const Z=g[L],se=m[Z.bundleIndex];if(!t.indexByKey.has(se.srcKey)||!t.indexByKey.has(se.dstKey))continue;let re=_.get(Z.bundleIndex);if(re===void 0){const U=xc(t,se.srcKey,se.dstKey,e.bundleBeta,v,w*3);if(U===0)continue;re=w,_.set(Z.bundleIndex,re),w+=U}j[K]=re,M[K*3]=v[re*3],M[K*3+1]=v[re*3+1],M[K*3+2]=v[re*3+2],N[K]=Z.phase;const[me,C,T]=is(se.dominantType),P=h.size>0&&(h.has(se.srcKey)||h.has(se.dstKey)),$=kc*(P?2:1);D[K*3]=me*$,D[K*3+1]=C*$,D[K*3+2]=T*$,K++}const F=new ke;return F.setAttribute("position",new ye(M,3)),F.setAttribute("color",new ye(D,3)),F.setDrawRange(0,K),{geometry:F,curves:v,curveBase:j,phaseArr:N,count:K}},[t,e.expanded,e.filters,e.audit,e.focus,e.selected,n,e.bundleBeta]);b.useEffect(()=>()=>o.dispose(),[o]);const c=b.useRef(null);return Ze(({clock:d,invalidate:l})=>{const u=c.current;if(!u||a===0)return;const m=u.geometry.getAttribute("position");if(!m)return;const h=m.array,p=d.elapsedTime*wc;for(let x=0;x<a;x++){const y=(p+i[x])%1,g=r[x],k=y*Ce;let _=k|0;_>=Ce&&(_=Ce-1);const v=k-_,w=(g+_)*3,N=(g+_+1)*3;h[x*3]=s[w]+(s[N]-s[w])*v,h[x*3+1]=s[w+1]+(s[N+1]-s[w+1])*v,h[x*3+2]=s[w+2]+(s[N+2]-s[w+2])*v}m.needsUpdate=!0,l()}),a===0?null:f.jsx("points",{ref:c,geometry:o,raycast:()=>null,children:f.jsx("pointsMaterial",{size:_c,sizeAttenuation:!0,map:kn(Va),vertexColors:!0,transparent:!0,opacity:.85,depthWrite:!1,blending:De})})}const Ec=20;function jc(){const e=pe(),t=e.model,n=yt(),o=b.useMemo(()=>{const s=ae(t,e.expanded),r=new Set;n&&r.add(n),e.selected&&r.add(e.selected);const i=[];for(const l of r){const u=t.clusterOfNode.get(l)??l,m=t.indexByKey.get(u);if(m===void 0)continue;const p=t.byKey.get(u)?.name??t.records.get(l)?.name??u;i.push({key:`priority-${u}`,label:p,pos:[t.positions[m*3],t.positions[m*3+1],t.positions[m*3+2]],priority:!0})}const a=[];for(const l of s){const u=t.byKey.get(l);u&&u.kind!=="symbol"&&a.push({key:l,importance:u.children.length})}a.sort((l,u)=>u.importance-l.importance);const c=new Set([...r].map(l=>t.clusterOfNode.get(l)??l));let d=0;for(const{key:l}of a){if(d>=Ec)break;if(c.has(l))continue;const u=t.indexByKey.get(l);if(u===void 0)continue;const m=t.byKey.get(l);i.push({key:`cluster-${l}`,label:m.name,pos:[t.positions[u*3],t.positions[u*3+1],t.positions[u*3+2]],priority:!1}),d++}return i},[t,n,e.selected,e.expanded]);return f.jsx(f.Fragment,{children:o.map(s=>f.jsx(Xs,{position:s.pos,center:!0,distanceFactor:40,zIndexRange:[10,0],children:f.jsx("div",{style:{padding:"2px 6px",borderRadius:4,background:s.priority?"rgba(8,12,24,0.92)":"rgba(8,12,24,0.65)",border:s.priority?"1px solid rgba(120,150,210,0.5)":"1px solid rgba(120,150,210,0.25)",color:s.priority?"#dfe6f5":"rgba(180,200,230,0.7)",fontSize:s.priority?12:10,whiteSpace:"nowrap",pointerEvents:"none",transform:"translateY(-14px)"},children:s.label})},s.key))})}let Xt=null;function Qt(){return Xt}let Zt=null;function Mc(e,t,n){Zt?.(e,t,n)}let Jt=null;function ps(){return Jt}const Cc=4e3,Tc=.05,fo=1.3;function Ac(){const e=b.useRef(null),t=pe(),n=t.model,o=t.idleDrift,{invalidate:s}=hn(),r=b.useRef(performance.now()),i=b.useMemo(()=>({box:new ar,sphere:new ir,pt:new jt}),[]);b.useEffect(()=>{const d=e.current;if(!d||!n)return;if(t.focusTarget){const x=n.clusterOfNode.get(t.focusTarget)??t.focusTarget,y=n.indexByKey.get(x);if(y!==void 0){const{sphere:g,pt:k}=i;k.set(n.positions[y*3],n.positions[y*3+1],n.positions[y*3+2]),g.set(k,60*fo),d.fitToSphere(g,!0),r.current=performance.now(),s();return}}let l;if(t.focus){const x=ae(n,t.expanded),y=new Set;for(const g of t.focus.nodes){const k=oe(n,g,x);k&&y.add(k)}l=[...y]}else t.selected&&n.clusterOfNode.has(t.selected)?l=[n.clusterOfNode.get(t.selected)]:t.selected&&n.indexByKey.has(t.selected)?l=[t.selected]:l=[...ae(n,t.expanded)];const{box:u,sphere:m,pt:h}=i;u.makeEmpty();let p=!1;for(const x of l){const y=n.indexByKey.get(x);y!==void 0&&(h.set(n.positions[y*3],n.positions[y*3+1],n.positions[y*3+2]),u.expandByPoint(h),p=!0)}p&&(u.getBoundingSphere(m),m.radius=Math.max(m.radius,4)*fo,d.fitToSphere(m,!0),r.current=performance.now(),s())},[t.fitNonce,n]),b.useEffect(()=>{const d=e.current,l=t.poseTarget;if(!d||!l)return;const[u,m,h]=l.position,[p,x,y]=l.target;d.setLookAt(u,m,h,p,x,y,!0),r.current=performance.now(),s()},[t.poseNonce]),b.useEffect(()=>(Zt=(d,l,u)=>{const m=e.current;m&&(m.moveTo(d,l,u,!0),r.current=performance.now(),s())},()=>{Zt=null,Xt=null,Jt=null,la()}),[s]);const a=b.useMemo(()=>new jt,[]),c=b.useMemo(()=>new jt,[]);return Ze((d,l)=>{const u=e.current;if(!u)return;u.getTarget(a),Xt={x:a.x,y:a.y,z:a.z},u.getPosition(c),ca({position:[c.x,c.y,c.z],target:[a.x,a.y,a.z]});const m=u.camera;Jt=typeof m?.fov=="number"&&typeof m?.aspect=="number"?{distance:u.distance,fov:m.fov,aspect:m.aspect}:null;const h=performance.now();if(u.active){r.current=h;return}h-r.current<Cc||o&&(u.rotate(Tc*l,0,!1),s())}),f.jsx(Qs,{ref:e,makeDefault:!0,smoothTime:.3,minDistance:2,maxDistance:1200,onStart:()=>{r.current=performance.now()}})}const po=400;function Ic(){const e=pe(),t=e.model,n=e.lastHop,o=e.hopNonce,{invalidate:s}=hn(),r=Rc(),[i,a]=b.useState(0),c=b.useRef(0);b.useEffect(()=>{o===0||r||(c.current=performance.now(),a(o),s())},[o,r,s]);const d=b.useMemo(()=>{if(!t||!n||i!==o||r)return null;const m=ae(t,e.expanded),h=oe(t,n.from,m),p=oe(t,n.to,m);if(!h||!p||h===p)return null;const x=t.indexByKey.get(h),y=t.indexByKey.get(p);if(x===void 0||y===void 0)return null;const g=new ke;return g.setAttribute("position",new je([t.positions[x*3],t.positions[x*3+1],t.positions[x*3+2],t.positions[y*3],t.positions[y*3+1],t.positions[y*3+2]],3)),g},[t,n,i,o,r,e.expanded]);b.useEffect(()=>{const m=d;return()=>m?.dispose()},[d]);const l=b.useMemo(()=>new mn({color:16762731,transparent:!0,opacity:1,depthWrite:!1}),[]);b.useEffect(()=>()=>l.dispose(),[l]);const u=b.useRef(!1);return Ze(()=>{if(!d)return;const m=performance.now()-c.current;if(m>=po){u.current||(u.current=!0,a(0),s());return}u.current=!1;const h=m/po;l.opacity=(1-h)*(1-h),s()}),d?f.jsx("lineSegments",{geometry:d,material:l,renderOrder:12}):null}function Rc(){const[e,t]=b.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return b.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>t(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}const ho=.85;function Lt(e){const t=Math.hypot(e[0],e[1],e[2]);return!Number.isFinite(t)||t===0?[0,0,0]:[e[0]/t,e[1]/t,e[2]/t]}function mo(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}const Kt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2];function Lc(e,t,n,o,s){if(!e||!t||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(t.fov)||!Number.isFinite(t.aspect)||t.fov<=0||t.aspect<=0)return!1;const r=[e.position[0],e.position[1],e.position[2]],i=Lt([e.target[0]-r[0],e.target[1]-r[1],e.target[2]-r[2]]);if(i[0]===0&&i[1]===0&&i[2]===0)return!1;let a=mo(i,[0,1,0]);Math.hypot(a[0],a[1],a[2])<1e-6?a=[1,0,0]:a=Lt(a);const c=Lt(mo(a,i)),d=[n-r[0],o-r[1],s-r[2]],l=Kt(d,i);if(l<=0)return!1;const u=Math.tan(t.fov*Math.PI/360)*l,m=u*t.aspect;return Math.abs(Kt(d,a))<=m*ho&&Math.abs(Kt(d,c))<=u*ho}function Kc(e,t,n,o){const s=e.clusterOfNode.get(t)??t,r=e.indexByKey.get(s);return r===void 0?!1:Lc(n,o,e.positions[r*3],e.positions[r*3+1],e.positions[r*3+2])}async function Pc(){if(gt())return ia();try{const e=await fetch("/api/temporal");return e.ok?await e.json():{}}catch{return{}}}function $c(e,t){return`file:${e}:${t}`}function Dc(e,t,n){const o=new Map,s=r=>{const i=$c(e.repoId,r),a=e.byKey.get(i);if(!a)return null;const c=a.nodeId??i;return oe(e,c,n)??(n.has(i)?i:null)};for(const[r,i]of Object.entries(t)){const a=s(r);if(a)for(const{path:c,support:d,confidence:l}of i){const u=s(c);if(!u||u===a)continue;const[m,h]=a<u?[a,u]:[u,a],p=`${m} ${h}`,x=o.get(p);(!x||d>x.support||d===x.support&&l>x.confidence)&&o.set(p,{aKey:m,bKey:h,support:d,confidence:l})}}return[...o.values()].sort((r,i)=>r.aKey===i.aKey?r.bKey<i.bKey?-1:1:r.aKey<i.aKey?-1:1)}function Fc(){const e=X(),t=e.model,n=e.cochange,o=b.useMemo(()=>{if(!n)return null;const r=ae(t,e.expanded),i=Dc(t,n,r);if(i.length===0)return null;const a=[],c=[];for(const l of i){const u=t.indexByKey.get(l.aKey),m=t.indexByKey.get(l.bKey);if(u===void 0||m===void 0)continue;const h=t.positions[u*3],p=t.positions[u*3+1],x=t.positions[u*3+2],y=t.positions[m*3],g=t.positions[m*3+1],k=t.positions[m*3+2];a.push(h,p,x,y,g,k);const _=Math.hypot(y-h,g-p,k-x);c.push(0,_)}if(a.length===0)return null;const d=new ke;return d.setAttribute("position",new je(a,3)),d.setAttribute("lineDistance",new je(c,1)),d},[t,n,e.expanded]);b.useEffect(()=>{const r=o;return()=>r?.dispose()},[o]);const s=b.useMemo(()=>new cr({color:16727536,transparent:!0,opacity:.7,dashSize:2.5,gapSize:1.8,depthWrite:!1}),[]);return b.useEffect(()=>()=>s.dispose(),[s]),!e.coupling||!o?null:f.jsx("lineSegments",{geometry:o,material:s})}let hs=!1;function bt(){return hs}function Pt(e){hs=e}let ms=null;function go(e){ms=e}function Oc(){ms?.()}let Ne=null;const en=new Set;function gs(){for(const e of en)e()}function tn(){return Ne}function xs(e){Ne!==e&&(Ne=e,gs())}function Xe(){return Ne===null?!1:(Ne=null,gs(),!0)}function Sn(e){Ne===e?Xe():xs(e)}function zc(e){return en.add(e),()=>en.delete(e)}let nn=null;function Bc(){nn=Ne,Xe()}function Hc(){const e=nn;nn=null,e&&Ne===null&&xs(e)}function vt(){return b.useSyncExternalStore(zc,tn,tn)}const qc=3200;let $e=[],Uc=1;const on=new Set,sn=new Map,ft=new Map;function ys(){for(const e of on)e()}function Vc(e){const t=sn.get(e);t!==void 0&&(clearTimeout(t),sn.delete(e))}function be(e,t={}){const n=t.dedupeKey;if(n){const i=ft.get(n);i!==void 0&&rn(i)}const o=Uc++,s={id:o,text:e,tone:t.tone??"info",hint:t.hint};$e=[...$e,s].slice(-3),n&&ft.set(n,o);const r=t.duration??qc;return r>0&&sn.set(o,setTimeout(()=>rn(o),r)),ys(),o}function rn(e){Vc(e);for(const[n,o]of ft)o===e&&ft.delete(n);const t=$e.filter(n=>n.id!==e);t.length!==$e.length&&($e=t,ys())}function xo(){return $e}function Gc(e){return on.add(e),()=>on.delete(e)}function bs(){return b.useSyncExternalStore(Gc,xo,xo)}const Wc={impact:!1,focus:null,coupling:!1,audit:null},Yc={ambiguous:"ambiguous","ambiguous+name":"ambiguous-name"},Xc={ambiguous:"ambiguous","ambiguous-name":"ambiguous+name"},Qc=new Set(gn);function vs(e){const t={};e.selected&&(t.node=e.selected),e.lens!=="all"&&(t.lens=e.lens);const n=[];return e.impact&&n.push("impact"),e.focus&&n.push(`focus:${pt(e.focusDepth)}`),e.coupling&&n.push("coupling"),e.audit!=="off"&&n.push(`audit:${Yc[e.audit]}`),n.length>0&&(t.overlays=n.join(",")),t}function Zc(e){const t=typeof e.node=="string"&&e.node.length>0?e.node:null,n=typeof e.lens=="string"?e.lens:"",o=Qc.has(n)?n:null,s={...Wc},r=typeof e.overlays=="string"?e.overlays:"";for(const i of r.split(",")){const a=i.trim();if(a!==""){if(a==="impact"){s.impact=!0;continue}if(a==="coupling"){s.coupling=!0;continue}if(a==="focus"){s.focus=Ut;continue}if(a.startsWith("focus:")){const c=Number.parseInt(a.slice(6),10);s.focus=Number.isFinite(c)?pt(c):Ut;continue}if(a.startsWith("audit:")){const c=Xc[a.slice(6)];c&&(s.audit=c);continue}}}return{node:t,lens:o,overlays:s}}function Jc(e){const t={};return typeof e.node=="string"&&(t.node=e.node),typeof e.lens=="string"&&(t.lens=e.lens),typeof e.overlays=="string"&&(t.overlays=e.overlays),t}function el(e,t){return e.node===t.node&&e.lens===t.lens&&e.overlays===t.overlays}function tl(e){return e.node===null&&e.lens===null&&!e.overlays.impact&&e.overlays.focus===null&&!e.overlays.coupling&&e.overlays.audit===null}const nl=[1,2,3],tt="Select a node first";function ol(){const e=gn.map((n,o)=>({id:`lens-${n}`,label:`Lens: ${Me[n].label}`,subtitle:Me[n].hint,kbd:String(o+1),group:"commands",disabled:()=>!1,run:s=>s.setLens(n)})),t=nl.map(n=>({id:`focus-depth-${n}`,label:`Focus depth ${n}`,subtitle:"Sets the neighborhood BFS depth for the Focus overlay",disabledReason:tt,group:"commands",disabled:o=>!o.selected,run:o=>o.setFocusDepth(n)}));return[...e,{id:"impact",label:"Toggle impact overlay",subtitle:"Highlight transitive callers and covering tests of the selection",disabledReason:tt,group:"commands",disabled:n=>!n.selected,run:n=>n.toggleImpact()},{id:"focus",label:"Toggle focus neighborhood",subtitle:"Isolate the selected node's N-hop neighborhood and frame it",disabledReason:tt,group:"commands",disabled:n=>!n.selected,run:n=>n.toggleFocus()},...t,{id:"coupling",label:"Toggle coupling overlay",subtitle:"Git co-change links between files that change together",group:"commands",disabled:()=>!1,run:n=>n.toggleCoupling()},{id:"audit-ambiguous",label:"Audit: ambiguous edges only",subtitle:"Show ONLY ambiguous (guessed) edges — where the resolver is guessing",group:"commands",disabled:()=>!1,run:(n,o)=>n.setAudit(o.audit==="ambiguous"?"off":"ambiguous")},{id:"audit-ambiguous-name",label:"Audit: ambiguous + name match",subtitle:"Also include name_match edges (still low-confidence)",group:"commands",disabled:()=>!1,run:(n,o)=>n.setAudit(o.audit==="ambiguous+name"?"off":"ambiguous+name")},{id:"bundling",label:"Toggle edge bundling",subtitle:"Switch between hierarchy-hugging curves and straight chords",group:"commands",disabled:()=>!1,run:(n,o)=>n.setBundleBeta(o.bundleBeta>0?0:.85)},{id:"frame-all",label:"Frame all",subtitle:"Refit the camera to what's currently on screen",kbd:"F",group:"commands",disabled:()=>!1,run:n=>n.requestFit()},{id:"history-back",label:"Back",subtitle:"The previous view — selection, expansion and camera together",kbd:"[",disabledReason:"Nothing to go back to",group:"commands",disabled:()=>!ga(),run:n=>{n.historyBack()}},{id:"history-forward",label:"Forward",subtitle:"Undo a Back step",kbd:"]",disabledReason:"Nothing to go forward to",group:"commands",disabled:()=>!xa(),run:n=>{n.historyForward()}},{id:"collapse-branch",label:"Collapse branch",subtitle:"Close the cluster around the selection — symbol → file → folder",kbd:"X",disabledReason:tt,group:"commands",disabled:n=>!n.selected,run:n=>n.collapseBranch()},{id:"collapse-to-file-level",label:"Collapse to file level",subtitle:"Close every expansion above file level — back to clean file arcs",kbd:"⇧X",group:"commands",disabled:()=>!1,run:n=>n.collapseToFileLevel()},{id:"clean-slate",label:"Clean slate",subtitle:"Collapse expansion, clear filters/lens/overlays, and reframe — destructive",group:"commands",disabled:()=>!1,run:n=>n.resetView()},{id:"start-tour",label:"Start guided tour",subtitle:"Cinematic flythrough: overview → modules → hub → hierarchy → entry",disabledReason:"Already touring",group:"commands",disabled:n=>n.tour||!n.model,run:n=>n.startTour()},{id:"screenshot",label:"Screenshot",subtitle:"Capture a PNG of the current view",group:"commands",disabled:()=>!1,run:(n,o,s)=>s.screenshot()},{id:"copy-link",label:"Copy link to this view",subtitle:"The node, the lens and every active overlay (?node&lens&overlays)",disabledReason:"Nothing to share yet — select a node, pick a lens, or turn on an overlay",group:"commands",disabled:n=>Object.keys(vs(n)).length===0,run:(n,o,s)=>s.copyLink()},{id:"toggle-minimap",label:"Toggle map",subtitle:"Overview of the clusters currently on screen",kbd:"M",group:"commands",disabled:()=>!1,run:(n,o,s)=>s.toggleLayer("minimap")},{id:"toggle-legend",label:"Toggle legend",subtitle:"What every color and line weight means",group:"commands",disabled:()=>!1,run:(n,o,s)=>s.toggleLayer("legend")},{id:"toggle-filters",label:"Toggle filters",subtitle:"Symbol kinds, relationships, confidence, edge bundling",group:"commands",disabled:()=>!1,run:(n,o,s)=>s.toggleLayer("filters")},{id:"toggle-help",label:"Keyboard shortcuts",subtitle:"The full keymap",kbd:"?",group:"commands",disabled:()=>!1,run:(n,o,s)=>s.toggleLayer("help")},{id:"toggle-labels",label:"Toggle labels",subtitle:"Show or hide in-scene name labels",group:"commands",disabled:()=>!1,run:n=>n.toggleLabels()},{id:"toggle-drift",label:"Toggle idle drift",subtitle:"Gentle camera drift after a few seconds of no interaction",kbd:"D",group:"commands",disabled:()=>!1,run:(n,o)=>n.setIdleDrift(!o.idleDrift)}]}function sl(e,t,n=8){return[t,...e.filter(o=>o.id!==t.id)].slice(0,n)}const rl={name:10,qualifiedName:6,filePath:3,semanticSummary:1.5},il=["name","qualifiedName","filePath","semanticSummary"];function al(e,t){if(!t)return 0;const n=t.toLowerCase();if(n===e)return 1;if(n.startsWith(e))return .7;const o=n.indexOf(e);if(o<0)return 0;const s=o===0?"":n[o-1];return o===0||!/[a-z0-9]/.test(s)?.5:.25}function cl(e,t){switch(t){case"name":return e.name;case"qualifiedName":return e.qualifiedName;case"filePath":return e.filePath;case"semanticSummary":return e.semanticSummary??""}}function ll(e){return e.toLowerCase().split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function ul(e,t,n=10){const o=ll(t);if(o.length===0)return[];const s=[];for(const r of e){let i=0,a=-1,c="name",d=!0;for(const l of o){let u=0,m="name";for(const h of il){const p=al(l,cl(r,h));if(p===0)continue;const x=p*rl[h];x>u&&(u=x,m=h)}if(u===0){d=!1;break}i+=u,u>a&&(a=u,c=m)}d&&s.push({rec:r,score:i,topField:c})}return s.sort((r,i)=>i.score!==r.score?i.score-r.score:r.rec.name!==i.rec.name?r.rec.name<i.rec.name?-1:1:r.rec.id<i.rec.id?-1:r.rec.id>i.rec.id?1:0),s.slice(0,n)}const dl=new Set(["Function","Class","Interface","Enum","Variable"]);function fl(e){return dl.has(e)?"symbols":e==="File"?"files":"directories"}function ws(e){const t=new Map,n=(o,s)=>{const r=t.get(o);(r===void 0||s<r)&&t.set(o,s)};for(const o of e.drawEdges)n(o.from,o.confidence),n(o.to,o.confidence);return t}function _s(e,t){return e.get(t)??1}const pl={Repository:"galaxy",Directory:"dir",File:"file"};function ks(e){return pl[e]??e}function En(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function hl(e){return`--color-node-${En(ks(e))}`}function ml(e){return`--color-edge-${En(e)}`}function gl(e,t){return t?`--color-lang-${En(e)}`:"--color-lang-default"}function wt(e){return`var(${e})`}function _t(e){return wt(hl(e))}function Ns(e){return wt(ml(e))}function xl(e,t){return wt(gl(e,t))}function yl(e){return`--color-status-${e}`}function yo(e){return wt(yl(e))}const bl=ks,vl={galaxy:"◎",dir:"▤",file:"▯",Function:"ƒ",Class:"◆",Interface:"◇",Enum:"≡",Variable:"•"},wl="○";function Ss(e){return vl[bl(e)]??wl}function _l(e){return`reposkein-${(e??"repo").replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"repo"}.png`}let an=null;function Es(){an?.()}function kl({repoId:e}){const{gl:t,scene:n,camera:o,invalidate:s}=hn();return b.useEffect(()=>(an=()=>{try{t.render(n,o)}catch{}const r=t.domElement,i=_l(e),a=()=>s(),c=(d,l)=>{const u=document.createElement("a");u.href=d,u.download=i,document.body.appendChild(u),u.click(),u.remove(),l&&setTimeout(()=>URL.revokeObjectURL(d),1e3)};try{typeof r.toBlob=="function"?r.toBlob(d=>{d?c(URL.createObjectURL(d),!0):c(r.toDataURL("image/png"),!1),a()},"image/png"):(c(r.toDataURL("image/png"),!1),a())}catch{a()}},()=>{an=null}),[t,n,o,e,s]),null}const Nl='a[href], button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), [tabindex]:not([tabindex="-1"])',Sl=8,El=2,jl=24,Ml=6,bo={recent:"Recent",symbols:"Symbols",files:"Files",directories:"Directories",commands:"Commands"},Cl=["recent","symbols","files","directories","commands"];function cn(e){return e.kind==="command"&&e.disabled}function Tl(){const e=X(),t=b.useId(),[n,o]=b.useState(!1),[s,r]=b.useState(""),[i,a]=b.useState(0),[c,d]=b.useState(!1),[l,u]=b.useState([]),m=b.useRef(null),h=b.useRef(null),p=b.useRef(null),x=b.useRef(null),y=e.model,g=b.useMemo(()=>ol(),[]),k=b.useMemo(()=>y?ws(y):new Map,[y]),_=s.startsWith(">"),v=(_?s.slice(1):s).trim().toLowerCase(),w=s.trim(),N=b.useCallback(()=>{o(!1),Pt(!1),r(""),d(!1),a(0),x.current?.focus({preventScroll:!0})},[]),j=b.useCallback(()=>{x.current=document.activeElement,o(!0),Pt(!0)},[]);b.useEffect(()=>()=>Pt(!1),[]),b.useEffect(()=>(go(j),()=>go(null)),[j]),b.useEffect(()=>{const S=E=>{(E.metaKey||E.ctrlKey)&&E.key.toLowerCase()==="k"&&(E.preventDefault(),n?N():j())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n,N,j]),b.useEffect(()=>{n&&m.current?.focus({preventScroll:!0})},[n]);const M=b.useMemo(()=>{const S={symbols:[],files:[],directories:[]};if(_||!y||w.length<El)return S;const E=c?[...y.records.values()].filter(z=>z.kind==="file"):y.records.values(),I=ul(E,w,jl),R=S;for(const z of I){const A=fl(z.rec.kind);R[A].length>=Ml||R[A].push({kind:"node",group:A,id:z.rec.id,name:z.rec.name||z.rec.id,nodeKind:z.rec.kind,filePath:z.rec.filePath})}return R},[_,y,w,c]),D=b.useMemo(()=>{if(_)return[];const S=w.toLowerCase();return l.filter(E=>S.length===0||E.name.toLowerCase().includes(S)||E.filePath.toLowerCase().includes(S)).map(E=>({kind:"node",group:"recent",id:E.id,name:E.name,nodeKind:E.kind,filePath:E.filePath}))},[_,l,w]),K=b.useMemo(()=>g.filter(S=>v.length===0?!0:`${S.label} ${S.subtitle??""}`.toLowerCase().includes(v)).map(S=>({kind:"command",group:"commands",cmd:S,disabled:S.disabled(e)})),[g,v,e]),F=b.useMemo(()=>{const S={recent:D,symbols:M.symbols,files:M.files,directories:M.directories,commands:K};return Cl.map(E=>({group:E,rows:S[E]})).filter(E=>E.rows.length>0)},[D,M,K]),L=b.useMemo(()=>F.flatMap(S=>S.rows),[F]),Z=L.length===0;b.useEffect(()=>{a(0)},[s,c]),b.useEffect(()=>{i>=L.length&&a(Math.max(0,L.length-1))},[L.length,i]),b.useEffect(()=>{const S=p.current,E=S?.querySelector('[data-active="true"]');if(!S||!E)return;const I=S.getBoundingClientRect(),R=E.getBoundingClientRect();R.top<I.top?S.scrollTop-=I.top-R.top:R.bottom>I.bottom&&(S.scrollTop+=R.bottom-I.bottom)},[i]);function se(S){const E=L.length;if(E===0)return;let I=i;for(let R=0;R<E&&(I=(I+S+E)%E,!!cn(L[I]));R++);a(I)}const re=b.useMemo(()=>({screenshot:()=>{Es(),be("Screenshot saved",{tone:"accent",dedupeKey:"screenshot"})},copyLink:()=>{try{navigator.clipboard?.writeText(window.location.href),be("Link copied",{tone:"accent",dedupeKey:"copy-link"})}catch{be("Couldn't copy the link",{tone:"warn",dedupeKey:"copy-link"})}},toggleLayer:Sn}),[]),me=b.useCallback((S,E)=>{if(!(!S||cn(S))){if(S.kind==="command"){S.cmd.run(e,e,re),N();return}u(I=>sl(I,{id:S.id,name:S.name,kind:S.nodeKind,filePath:S.filePath},Sl)),e.revealAndSelect(S.id,{fly:E.fly}),N()}},[e,re,N]);function C(S){switch(S.key){case"ArrowDown":S.preventDefault(),se(1);break;case"ArrowUp":S.preventDefault(),se(-1);break;case"Enter":S.preventDefault(),me(L[i],{fly:!(S.metaKey||S.ctrlKey)});break;case"Escape":S.preventDefault(),S.stopPropagation(),N();break}}function T(S){if(S.key==="Escape"){S.preventDefault(),S.stopPropagation(),N();return}if(S.key!=="Tab")return;const E=h.current;if(!E)return;const I=Array.from(E.querySelectorAll(Nl));if(I.length===0)return;const R=I[0],z=I[I.length-1],A=E.ownerDocument.activeElement;S.shiftKey&&A===R?(S.preventDefault(),z.focus({preventScroll:!0})):!S.shiftKey&&A===z&&(S.preventDefault(),R.focus({preventScroll:!0}))}if(!n)return null;const P=`${t}-listbox`,U=L[i]?`${t}-row-${i}`:void 0,te=Z?_?`No commands match "${v}"`:`No matches for "${s}"`:`${L.length} result${L.length===1?"":"s"}`;let O=-1;return f.jsxs(f.Fragment,{children:[f.jsx("div",{"aria-hidden":"true",onMouseDown:N,className:"fixed inset-0 z-[200] bg-black/50 backdrop-blur-[2px]"}),f.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-label":"Command palette",onKeyDown:T,className:"fixed left-1/2 top-[12%] z-[201] flex max-h-[70vh] w-[calc(100%-2rem)] max-w-xl -translate-x-1/2 flex-col overflow-hidden rounded-[10px] border border-[rgba(148,163,207,0.14)] bg-[color-mix(in_srgb,var(--color-brand-navy)_96%,white_4%)] text-[13px] text-[var(--color-brand-cream)] shadow-[0_16px_48px_-12px_rgba(0,0,0,0.55)] backdrop-blur-md",children:[f.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-[rgba(148,163,207,0.14)] px-3 py-2.5",children:[f.jsx("span",{"aria-hidden":"true",className:"text-[13px] opacity-70",children:"⌘K"}),f.jsx("label",{htmlFor:`${t}-input`,className:"sr-only",children:"Search symbols, files, directories, or type > for commands"}),f.jsx("input",{ref:m,id:`${t}-input`,role:"combobox","aria-expanded":!Z,"aria-controls":P,"aria-activedescendant":U,"aria-autocomplete":"list",value:s,onChange:S=>r(S.target.value),onKeyDown:C,placeholder:"Search or type > for commands…",className:"min-w-0 flex-1 bg-transparent text-[13px] text-[var(--color-brand-cream)] placeholder:opacity-70 focus:outline-none"}),c&&f.jsx("button",{type:"button",onClick:()=>d(!1),className:"shrink-0 rounded-full border border-[rgba(148,163,207,0.25)] px-2 py-0.5 text-[11px] opacity-75 hover:opacity-100",children:"Files only ✕"})]}),f.jsxs("div",{ref:p,className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:[f.jsx("div",{id:P,role:"listbox","aria-label":"Results",children:!Z&&F.map(({group:S,rows:E})=>f.jsxs("div",{role:"group","aria-label":bo[S],className:"mb-1 last:mb-0",children:[f.jsx("p",{className:"px-2 pb-1 pt-1.5 text-[10px] font-medium uppercase tracking-wider opacity-70",children:bo[S]}),E.map(I=>{O+=1;const R=O;return f.jsx(Il,{rowId:`${t}-row-${R}`,row:I,active:R===i,confidenceIndex:k,onHover:()=>a(R),onCommit:z=>{a(R),me(I,{fly:z})}},`${I.group}-${I.kind==="command"?I.cmd.id:I.id}`)})]},S))}),Z&&f.jsx(Al,{query:s,isCommandMode:_,filesOnly:c,onSearchFilesOnly:()=>d(!0)})]}),f.jsx("div",{"aria-live":"polite",className:"sr-only",children:te}),f.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-3 border-t border-[rgba(148,163,207,0.14)] px-3 text-[11px] opacity-70",children:[f.jsxs("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[f.jsx(Ke,{children:"↑"}),f.jsx(Ke,{children:"↓"})," navigate"]}),f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx(Ke,{children:"↵"})," go"]}),f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx(Ke,{children:"⌘↵"})," reveal only"]}),f.jsxs("span",{className:"inline-flex items-center gap-1",children:[f.jsx(Ke,{children:"esc"})," close"]}),f.jsx("span",{className:"ml-auto shrink-0 tabular-nums",children:L.length})]})]})]})}function Al({query:e,isCommandMode:t,filesOnly:n,onSearchFilesOnly:o}){return f.jsxs("div",{className:"flex flex-col items-center px-3 py-10 text-center",children:[f.jsx("p",{className:"text-[13px] font-medium",children:t?`No commands match "${e.slice(1).trim()}"`:`No matches for "${e}"`}),f.jsx("p",{className:"mt-1 max-w-xs text-[11px] opacity-70",children:t?"Check the spelling, or clear the > prefix to search symbols and files too.":"Check the spelling, try fewer words, or narrow the search to files only."}),!t&&!n&&f.jsx("button",{type:"button",onClick:o,className:"mt-3 rounded-[8px] border border-[rgba(148,163,207,0.2)] px-2.5 py-1 text-[11px] hover:bg-white/5",children:"Search files only"})]})}function Il({rowId:e,row:t,active:n,confidenceIndex:o,onHover:s,onCommit:r}){const i=cn(t),a="flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-[8px] px-2.5 py-1.5 text-left transition-colors",c=i?"cursor-not-allowed opacity-40":n?"bg-white/10":"bg-transparent hover:bg-white/5",d=u=>{u.preventDefault(),!i&&r(!(u.metaKey||u.ctrlKey))};if(t.kind==="command"){const u=i?t.cmd.disabledReason??t.cmd.subtitle:t.cmd.subtitle;return f.jsxs("div",{id:e,role:"option","aria-selected":n,"aria-disabled":i,"data-active":n,onPointerMove:i?void 0:s,onMouseDown:d,className:`${a} ${c}`,children:[f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block truncate text-[13px] font-medium",children:t.cmd.label}),u&&f.jsx("span",{className:"block truncate text-[11px] opacity-70",children:u})]}),t.cmd.kbd&&f.jsx(Ke,{children:t.cmd.kbd})]})}const l=_s(o,t.id);return f.jsxs("div",{id:e,role:"option","aria-selected":n,"data-active":n,onPointerMove:s,onMouseDown:d,className:`${a} ${c}`,title:t.filePath||t.name,children:[f.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:_t(t.nodeKind)}}),f.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-[12px] opacity-70",children:Ss(t.nodeKind)}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block truncate text-[13px] font-medium",children:t.name}),t.filePath&&f.jsx("span",{className:"block truncate font-mono text-[11px] opacity-70",children:t.filePath})]}),l<1&&f.jsx(Rl,{value:l})]})}function Rl({value:e}){return f.jsxs("span",{title:`Touched by a low-confidence edge (${Math.round(e*100)}%)`,className:"shrink-0 rounded-full border border-[color-mix(in_srgb,var(--color-brand-amber)_45%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-brand-amber)] tabular-nums",children:[Math.round(e*100),"%"]})}function Ke({children:e}){return f.jsx("kbd",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-[6px] border border-[rgba(148,163,207,0.18)] bg-white/5 px-1.5 font-mono text-[10px] opacity-80",children:e})}function Ll({hidden:e,children:t}){return f.jsx("div",{"data-testid":"chrome-group","data-hidden":e,inert:e,className:`pointer-events-none fixed inset-0 z-[100] transition-opacity duration-500 motion-reduce:transition-none ${e?"opacity-0":"opacity-100"}`,children:t})}async function Kl(e,t,n){if(gt())return aa(e,t,n);try{const o=new URLSearchParams({path:e,start:String(t),end:String(n)}),s=await fetch(`/api/source?${o.toString()}`);return s.ok?await s.json():null}catch{return null}}const Pl={CALLS:5,INHERITS:4,IMPLEMENTS:4,INSTANTIATES:3,IMPORTS:2},$l={exact:2,name_match:1,ambiguous:0};function Dl(e){const t=Pl[e.type]??0,n=$l[e.resolution]??0;return t*100+n*10+Math.min(Math.max(e.confidence,0),1)}function Fl(e,t,n){const o=e.clusterOfNode.get(t)??t,s=e.clusterOfNode.get(n)??n,r=e.indexByKey.get(o),i=e.indexByKey.get(s);if(r===void 0||i===void 0)return 1/0;const a=e.positions[r*3]-e.positions[i*3],c=e.positions[r*3+1]-e.positions[i*3+1],d=e.positions[r*3+2]-e.positions[i*3+2];return a*a+c*c+d*d}function Ol(e,t){const n=new Map;for(const s of e.drawEdges){let r=null;if(s.from===t&&s.to!==t?r=s.to:s.to===t&&s.from!==t&&(r=s.from),r===null)continue;const i=Dl(s),a=n.get(r);(a===void 0||i>a)&&n.set(r,i)}if(n.size===0)return[];const o=new Map;for(const s of n.keys())o.set(s,Fl(e,t,s));return[...n.keys()].sort((s,r)=>{const i=n.get(r)-n.get(s);if(i!==0)return i;const a=o.get(s)-o.get(r);return a!==0?a:s<r?-1:s>r?1:0})}function zl(e,t,n,o){const s=Ol(e,t);if(s.length===0)return null;const r=o??t,i=s.indexOf(r),a=s.length;return n==="next"?s[i===-1?0:(i+1)%a]:s[i===-1?a-1:(i-1+a)%a]}const Bl={next:"prev",prev:"next"};function Hl(e,t,n,o){if(o!==null&&o.to===t&&n===Bl[o.dir])return{id:o.from,memory:{from:t,to:o.from,dir:n}};const r=o!==null&&o.to===t?o.from:void 0,i=zl(e,t,n,r);return i===null?null:{id:i,memory:{from:t,to:i,dir:n}}}const ql={"data-key-scope":""},Ul="[data-key-scope]";function Vl(e){const t=e.target;return t?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable===!0:!1}function Gl(e){const t=e.target;return!t||typeof t.closest!="function"?!1:t.closest(Ul)!=null}function Wl(e,t,n,o){if(t.tour||o.paletteOpen())return!1;const s=Vl(e);if(e.key==="Escape")return s||!t.selected?!1:(n.select(null),!0);if(s)return!1;switch(e.key){case"/":return e.preventDefault(),o.openPalette(),!0;case"?":return e.preventDefault(),o.toggleLayer("help"),!0;case"m":case"M":return e.preventDefault(),o.toggleLayer("minimap"),!0;case"f":case"F":return e.preventDefault(),n.requestFit(),!0;case"d":case"D":return e.preventDefault(),n.setIdleDrift(!t.idleDrift),!0;case"x":case"X":return e.preventDefault(),e.shiftKey||e.key==="X"?n.collapseToFileLevel():n.collapseBranch(),!0;case"[":{const c=n.historyBack();return c&&e.preventDefault(),c}case"]":{const c=n.historyForward();return c&&e.preventDefault(),c}}const r=t.model;if(!r||!t.selected||Gl(e))return!1;let i=null;if(e.key==="ArrowRight"||e.key==="ArrowDown"?i="next":e.key==="ArrowLeft"||e.key==="ArrowUp"?i="prev":e.key==="Tab"&&(i=e.shiftKey?"prev":"next"),!i)return!1;e.preventDefault();const a=Hl(r,t.selected,i,t.lastHop);return a&&n.hop(a.id,a.memory,!o.isOnScreen(a.id)),!0}function jn(){const[e,t]=b.useState(()=>typeof window>"u"?1280:window.innerWidth);return b.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}const js=900,Yl=640,Ue=Ps(),Ie={direction:"Dir",type:"Type",neighbor:"Neighbor",resolution:"Match",confidence:"Conf"};function Xl(){const e=X(),t=e.model,n=t&&e.selected?t.records.get(e.selected):null,s=jn()<js;return!t||!n?null:f.jsxs("aside",{"aria-label":`Inspector — ${n.name||n.id}`,"data-testid":"inspector","data-mode":s?"sheet":"drawer",className:s?"pointer-events-auto fixed inset-x-0 bottom-7 z-[110] flex h-[45vh] max-h-[420px] flex-col border-t border-[rgba(148,163,207,0.18)] bg-[color-mix(in_srgb,var(--color-brand-navy)_96%,white_3%)] text-[13px] text-[var(--color-brand-cream)] shadow-[0_-12px_32px_-16px_rgba(0,0,0,0.8)] motion-safe:animate-[rs-sheet-in_180ms_ease-out]":"pointer-events-auto fixed right-0 top-0 bottom-7 z-[110] flex w-[360px] max-w-[calc(100vw-1rem)] flex-col border-l border-[rgba(148,163,207,0.18)] bg-[color-mix(in_srgb,var(--color-brand-navy)_96%,white_3%)] text-[13px] text-[var(--color-brand-cream)] shadow-[-12px_0_32px_-16px_rgba(0,0,0,0.8)] motion-safe:animate-[rs-drawer-in_180ms_ease-out]",children:[f.jsx(Ql,{rec:n}),f.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-2.5",children:[f.jsx(Zl,{rec:n}),f.jsx(Jl,{}),f.jsx(eu,{rec:n,repoRoot:t.repoRoot}),f.jsx(tu,{rec:n})]}),f.jsx(ou,{})]})}function Ql({rec:e}){const t=X(),n=t.model,o=b.useMemo(()=>ws(n),[n]),s=_s(o,e.id),r=_t(e.kind),i=e.startLine>0?`:${e.startLine}-${e.endLine}`:"";return f.jsxs("header",{className:"shrink-0 border-b border-[rgba(148,163,207,0.16)] px-3 py-2.5",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("span",{"aria-hidden":"true","data-testid":"inspector-kind-glyph","data-color-var":r,className:"mt-0.5 w-4 shrink-0 text-center text-[13px]",style:{color:r},children:Ss(e.kind)}),f.jsx("h2",{"data-testid":"inspector-name",className:"min-w-0 flex-1 break-words text-[15px] font-medium leading-snug",children:e.name||e.id}),f.jsx("button",{type:"button",onClick:()=>t.select(null),"aria-label":"Close inspector",className:"min-h-6 min-w-6 shrink-0 text-[13px] opacity-70 hover:opacity-100",children:"✕"})]}),f.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.kind&&f.jsx("span",{"data-testid":"inspector-kind-badge","data-color-var":r,style:{color:r,borderColor:r},className:"rounded-full border bg-white/5 px-2 py-0.5 text-[11px]",children:e.kind}),s<1&&f.jsxs("span",{"data-testid":"inspector-confidence",title:`Touched by a low-confidence edge (${Math.round(s*100)}%)`,className:"rounded-full border border-[color-mix(in_srgb,var(--color-brand-amber)_45%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] px-1.5 py-0.5 font-mono text-[11px] tabular-nums text-[var(--color-brand-amber)]",children:[Math.round(s*100),"% confidence"]})]}),e.filePath&&f.jsxs("p",{"data-testid":"inspector-path",title:`${e.filePath}${i}`,className:"mt-1.5 truncate font-mono text-[11px] opacity-70",children:[e.filePath,i]})]})}function Zl({rec:e}){const t=[];return e.qualifiedName&&e.qualifiedName!==e.name&&t.push({label:"Qualified",value:e.qualifiedName,mono:!0}),e.language&&t.push({label:"Language",value:e.language}),e.role&&t.push({label:"Role",value:e.role}),e.startLine>0&&t.push({label:"Lines",value:`${e.startLine}–${e.endLine}`,mono:!0}),t.push({label:"Connections",value:String(e.degree),mono:!0}),f.jsx(kt,{title:"Overview",children:f.jsx("dl",{className:"flex flex-col gap-1",children:t.map(n=>f.jsxs("div",{className:"flex items-baseline gap-2",children:[f.jsx("dt",{className:"w-24 shrink-0 text-[11px] uppercase tracking-wide opacity-70",children:n.label}),f.jsx("dd",{className:`min-w-0 flex-1 break-words text-[13px] opacity-85 ${n.mono?"font-mono text-[11px] tabular-nums":""}`,children:n.value})]},n.label))})})}function Jl(){const e=X(),t=e.model,n=e.selected,[o,s]=b.useState([]),[r,i]=b.useState(0),a=b.useRef(null),c=b.useMemo(()=>{if(!n)return[];const p=[];for(const x of t.drawEdges)x.from===n?p.push({direction:"out",type:x.type,neighborId:x.to,neighbor:t.records.get(x.to)?.name??x.to,resolution:x.resolution,confidence:x.confidence}):x.to===n&&p.push({direction:"in",type:x.type,neighborId:x.from,neighbor:t.records.get(x.from)?.name??x.from,resolution:x.resolution,confidence:x.confidence});return p},[t,n]),d=b.useMemo(()=>[Ue.accessor("direction",{header:Ie.direction}),Ue.accessor("type",{header:Ie.type}),Ue.accessor("neighbor",{header:Ie.neighbor}),Ue.accessor("resolution",{header:Ie.resolution}),Ue.accessor("confidence",{header:Ie.confidence})],[]),l=Ks({data:c,columns:d,state:{sorting:o},onSortingChange:s,getCoreRowModel:Ds(),getSortedRowModel:$s()}),u=l.getRowModel().rows;b.useEffect(()=>{i(0)},[n,o]),b.useEffect(()=>{r>=u.length&&i(Math.max(0,u.length-1))},[u.length,r]);function m(p){i(p),a.current?.querySelectorAll("[data-edge-row]")?.[p]?.focus({preventScroll:!1})}function h(p,x,y){switch(p.key){case"ArrowDown":p.preventDefault(),p.stopPropagation(),m(Math.min(u.length-1,x+1));break;case"ArrowUp":p.preventDefault(),p.stopPropagation(),m(Math.max(0,x-1));break;case"Home":p.preventDefault(),p.stopPropagation(),m(0);break;case"End":p.preventDefault(),p.stopPropagation(),m(u.length-1);break;case"Enter":case" ":p.preventDefault(),p.stopPropagation(),e.revealAndSelect(y,{fly:!0});break}}return f.jsx(kt,{title:`Incident edges (${c.length})`,children:c.length===0?f.jsx("p",{className:"text-[11px] opacity-70",children:"No relationship edges touch this node."}):f.jsxs("table",{"data-testid":"inspector-edges",...ql,className:"w-full border-collapse text-left text-[11px]",children:[f.jsx("caption",{className:"sr-only",children:"Relationship edges touching the selected node. Use the column buttons to sort; arrow keys move between rows and Enter opens a neighbor."}),f.jsx("thead",{children:l.getHeaderGroups().map(p=>f.jsx("tr",{children:p.headers.map(x=>{const y=x.column.getIsSorted();return f.jsx("th",{scope:"col","aria-sort":y==="asc"?"ascending":y==="desc"?"descending":"none",className:"border-b border-[rgba(148,163,207,0.28)] p-0",children:f.jsxs("button",{type:"button","data-testid":`inspector-sort-${x.column.id}`,onClick:x.column.getToggleSortingHandler(),className:"flex w-full items-center gap-0.5 px-1 py-1 text-left text-[11px] uppercase tracking-wide opacity-70 hover:opacity-100",children:[Ie[x.column.id],f.jsx("span",{"aria-hidden":"true",className:"opacity-70",children:y==="asc"?"▲":y==="desc"?"▼":""})]})},x.id)})},p.id))}),f.jsx("tbody",{ref:a,children:u.map((p,x)=>{const y=p.original;return f.jsxs("tr",{"data-edge-row":"","data-testid":"inspector-edge-row",tabIndex:x===r?0:-1,"aria-label":`${y.direction==="out"?"to":"from"} ${y.neighbor}, ${y.type}, ${y.resolution}, confidence ${y.confidence.toFixed(2)}`,onFocus:()=>i(x),onClick:()=>e.revealAndSelect(y.neighborId,{fly:!0}),onKeyDown:g=>h(g,x,y.neighborId),className:"cursor-pointer border-b border-[rgba(148,163,207,0.1)] hover:bg-white/5 focus-visible:bg-white/10",children:[f.jsx("td",{className:"px-1 py-1 font-mono opacity-70",children:y.direction==="out"?"→":"←"}),f.jsx("td",{className:"px-1 py-1 opacity-80",children:y.type}),f.jsx("td",{className:"max-w-[7rem] truncate px-1 py-1",title:y.neighbor,children:y.neighbor}),f.jsx("td",{className:"px-1 py-1 opacity-70",children:y.resolution}),f.jsx("td",{className:"px-1 py-1 font-mono tabular-nums opacity-70",children:y.confidence.toFixed(2)})]},p.id)})})]})})}function eu({rec:e,repoRoot:t}){const[n,o]=b.useState(null),[s,r]=b.useState("idle"),i=!gt()&&!!e.filePath&&e.startLine>0;if(b.useEffect(()=>{if(!i){o(null),r("idle");return}let c=!1;r("loading"),o(null);const d=e.endLine>=e.startLine?e.endLine:e.startLine;return Kl(e.filePath,e.startLine,d).then(l=>{c||(l&&l.lines.length>0?(o(l),r("idle")):r("missing"))}),()=>{c=!0}},[e.id,e.filePath,e.startLine,e.endLine,i]),!i)return null;const a=t&&e.filePath?`vscode://file/${t.replace(/\/+$/,"")}/${e.filePath}:${e.startLine||1}`:null;return f.jsxs(kt,{title:"Source",children:[a&&f.jsx("a",{href:a,title:"Open this file at this line in VS Code",className:"mb-1.5 inline-block text-[11px] text-[var(--color-brand-teal)] hover:opacity-80",children:"Open in editor ↗"}),s==="loading"&&f.jsx("p",{className:"text-[11px] opacity-70",children:"Loading source…"}),s==="missing"&&f.jsx("p",{className:"text-[11px] opacity-70",children:"Source unavailable."}),n&&f.jsx("pre",{className:"m-0 max-h-56 overflow-auto rounded-[6px] border border-[rgba(148,163,207,0.16)] bg-black/35 px-2 py-1.5 font-mono text-[11px] leading-relaxed opacity-90",children:n.lines.map((c,d)=>{const l=n.start+d;return f.jsxs("div",{className:"flex whitespace-pre",children:[f.jsx("span",{className:"inline-block w-10 shrink-0 select-none pr-2.5 text-right opacity-70",children:l}),f.jsx("span",{className:"flex-1",children:c||" "})]},l)})})]})}function tu({rec:e}){const t=e.semanticSummary!==null&&e.summaryOfHash!==null&&e.contentHash!==null&&e.summaryOfHash!==e.contentHash;return f.jsx(kt,{title:"Semantic summary",children:e.semanticSummary?f.jsxs("div",{children:[t&&f.jsx("span",{"data-testid":"inspector-stale",title:"The summary was written against an older version of this file",className:"mb-1 inline-block rounded-full bg-[var(--color-brand-amber)] px-2 py-0.5 text-[11px] font-bold text-[var(--color-brand-navy)]",children:"⚠ Stale"}),e.semanticSummary.split(/\n\n+/).map((n,o)=>f.jsx("p",{className:"my-1 text-[13px] leading-relaxed opacity-90",children:nu(n)},o))]}):f.jsx("p",{className:"text-[11px] opacity-70",children:"No summary yet — agents write these as they explore."})})}function nu(e){return e.split(/`([^`]+)`/).map((t,n)=>n%2===1?f.jsx("code",{className:"rounded-[3px] bg-white/10 px-1 font-mono text-[11px]",children:t},n):t)}function ou(){const e=X(),t=e.impact!==null,n=e.focus!==null,o=e.impact?.impacted.size??0,s=e.impact?.coveringTests.size??0,r=e.focus?.nodes.size??0;return f.jsxs("footer",{className:"shrink-0 border-t border-[rgba(148,163,207,0.16)] px-3 py-2.5",children:[f.jsxs("div",{className:"flex gap-1.5",children:[f.jsx(vo,{testId:"inspector-impact",label:t?"Impact on":"Impact",title:"Highlight transitive callers (reverse CALLS) and the tests covering them",on:t,onClick:()=>e.toggleImpact()}),f.jsx(vo,{testId:"inspector-focus",label:n?"Focus on":"Focus",title:"Isolate this symbol's N-hop neighborhood (in + out edges) and frame it",on:n,onClick:()=>e.toggleFocus()})]}),f.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[f.jsx("span",{className:"text-[11px] uppercase tracking-wide opacity-70",children:"Depth"}),Array.from({length:Ko-qt+1},(i,a)=>{const c=qt+a,d=e.focusDepth===c;return f.jsx("button",{type:"button","data-testid":`inspector-depth-${c}`,onClick:()=>e.setFocusDepth(c),"aria-pressed":d,title:`Trace ${c} hop${c===1?"":"s"} out from this symbol`,className:`min-h-6 min-w-6 rounded-[5px] border font-mono text-[11px] transition-colors ${d?"border-[color-mix(in_srgb,var(--color-brand-teal)_55%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-teal)_16%,transparent)] text-[var(--color-brand-teal)]":"border-[rgba(148,163,207,0.2)] opacity-70 hover:opacity-100"}`,children:c},c)}),n&&f.jsxs("span",{className:"ml-auto font-mono text-[11px] tabular-nums text-[var(--color-brand-teal)]",children:[r," nodes"]})]}),t&&f.jsxs("p",{className:"mt-1.5 flex gap-3 font-mono text-[11px] tabular-nums",children:[f.jsxs("span",{style:{color:yo("danger")},children:["● ",o," impacted"]}),f.jsxs("span",{style:{color:yo("ok")},children:["● ",s," covering test",s===1?"":"s"]})]})]})}function vo({label:e,title:t,on:n,onClick:o,testId:s}){return f.jsx("button",{type:"button","data-testid":s,onClick:o,title:t,"aria-pressed":n,className:`min-h-6 flex-1 rounded-[6px] border px-2 py-1 text-[11px] transition-colors ${n?"border-[color-mix(in_srgb,var(--color-brand-amber)_55%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] text-[var(--color-brand-amber)]":"border-[rgba(148,163,207,0.2)] opacity-75 hover:opacity-100"}`,children:e})}function kt({title:e,children:t}){return f.jsxs("section",{className:"mb-3 last:mb-0",children:[f.jsx("h3",{className:"mb-1 text-[11px] font-medium uppercase tracking-wider opacity-70",children:e}),t]})}const wo="360px",$t="0.75rem";function su(e,t,n=!1){if(n)return"bottom-9 inset-x-3 max-w-none";const o=t?`max-w-[calc(100vw-${wo}-${$t}*3)]`:`max-w-[calc(100vw-${$t}*2)]`,s=t?`right-[calc(${wo}+${$t})]`:"right-3";return`bottom-9 ${e==="center"?`left-3 ${s} mx-auto`:s} ${o}`}function Nt({id:e,title:t,dock:n,width:o,children:s}){const r=pe(),i=b.useRef(null),a=jn(),c=a<Yl,d=r.status.kind==="ready"&&r.selected!==null&&r.model?.records.has(r.selected)===!0,l=d&&a>=js,u=b.useRef(r.tour);return u.current=r.tour,b.useEffect(()=>{const m=p=>{p.key==="Escape"&&(bt()||u.current||(p.preventDefault(),p.stopImmediatePropagation(),Xe()))},h=p=>{const x=p.target;i.current?.contains(x)||x?.closest?.("[data-layer-toggle]")||Xe()};return window.addEventListener("keydown",m,!0),document.addEventListener("mousedown",h),()=>{window.removeEventListener("keydown",m,!0),document.removeEventListener("mousedown",h)}},[]),f.jsxs("div",{ref:i,role:"dialog","aria-label":t,"data-layer":e,"data-testid":`layer-${e}`,"data-inspector-open":d,"data-reserve-inspector-column":l,"data-full-width-sheet":c,className:`pointer-events-auto fixed z-[120] ${su(n,l,c)} ${c?"":o} motion-safe:animate-[rs-layer-in_140ms_ease-out] overflow-hidden rounded-[10px] border border-[rgba(148,163,207,0.2)] bg-[color-mix(in_srgb,var(--color-brand-navy)_88%,white_4%)] text-[13px] text-[var(--color-brand-cream)] shadow-[0_12px_36px_-12px_rgba(0,0,0,0.7)] backdrop-blur-md`,children:[f.jsxs("div",{className:"flex h-7 items-center justify-between border-b border-[rgba(148,163,207,0.16)] px-2.5",children:[f.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wider opacity-70",children:t}),f.jsx("button",{type:"button",onClick:()=>Xe(),"aria-label":`Close ${t}`,className:"min-h-5 min-w-5 text-[11px] opacity-70 hover:opacity-100",children:"✕"})]}),s]})}function ru(){const e=X(),{filters:t,audit:n}=e,o=t.kinds.size>0||t.edgeTypes.size>0||t.minConfidence>0||n!=="off";return f.jsx(Nt,{id:"filters",title:"Filters",dock:"right",width:"w-[264px]",children:f.jsxs("div",{className:"max-h-[min(70vh,32rem)] overflow-y-auto p-2.5",children:[f.jsx(Re,{label:"Symbol kinds",hint:"Dim a kind to hide those stars",children:f.jsx("div",{className:"flex flex-wrap gap-1",children:Ba.map(({kind:s,filterKey:r,label:i})=>{const a=t.kinds.has(r);return f.jsx(_o,{testId:`filter-chip-node-${s}`,colorVar:_t(s),label:i,on:!a,onClick:()=>e.setKindFilter(r,!a)},s)})})}),f.jsx(Re,{label:"Relationships",hint:"Dim an edge type to hide those threads",children:f.jsx("div",{className:"flex flex-wrap gap-1",children:cs.map(({type:s,label:r})=>{const i=t.edgeTypes.has(s);return f.jsx(_o,{testId:`filter-chip-edge-${s}`,colorVar:Ns(s),label:r,on:!i,onClick:()=>e.setEdgeTypeFilter(s,!i)},s)})})}),f.jsxs(Re,{label:"Confidence audit — highlight low-confidence edges",hint:"Shows only the connections the resolver had to guess at",children:[f.jsxs("div",{className:"flex gap-1",children:[f.jsx(ln,{label:"Guessed only",title:"Show ONLY ambiguous (guessed) edges; hide everything else",on:n==="ambiguous",onClick:()=>e.setAudit(n==="ambiguous"?"off":"ambiguous")}),f.jsx(ln,{label:"+ name matches",title:"Also include name_match edges (still low-confidence)",on:n==="ambiguous+name",onClick:()=>e.setAudit(n==="ambiguous+name"?"off":"ambiguous+name")})]}),n!=="off"&&f.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--color-brand-amber)]",children:"Showing only low-confidence edges — this is where the resolver is guessing."})]}),f.jsx(Re,{label:"Minimum confidence",hint:"Hide connections the resolver is less sure of than this",value:t.minConfidence.toFixed(2),children:f.jsx("input",{type:"range",min:0,max:1,step:.05,value:t.minConfidence,onChange:s=>e.setMinConfidence(parseFloat(s.target.value)),"aria-label":"Minimum edge confidence",className:"w-full accent-[var(--color-brand-amber)]"})}),f.jsx(Re,{label:"Edge bundling",hint:"1 = threads hug the folder hierarchy · 0 = straight chords",value:e.bundleBeta.toFixed(2),children:f.jsx("input",{type:"range",min:0,max:1,step:.05,value:e.bundleBeta,onChange:s=>e.setBundleBeta(parseFloat(s.target.value)),"aria-label":"Edge bundling strength",className:"w-full accent-[var(--color-brand-amber)]"})}),f.jsx(Re,{label:"Overlays",children:f.jsx(iu,{})}),o&&f.jsx("button",{type:"button",onClick:()=>e.clearFilters(),className:"mt-1 w-full rounded-[6px] border border-[rgba(148,163,207,0.2)] py-1 text-[11px] opacity-70 hover:opacity-100",children:"Reset every filter"})]})})}function iu(){const e=X(),t=e.coupling,n=e.cochange!==null,o=t&&n&&Object.keys(e.cochange).length===0;return f.jsxs("div",{children:[f.jsx(ln,{label:t?"Co-change links on":"Show co-change links",title:"Draw git co-change links between files that change together",on:t,onClick:()=>e.toggleCoupling(),full:!0}),t&&!n&&f.jsx("p",{className:"mt-1 text-[11px] opacity-70",children:"Reading git history…"}),o&&f.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-[var(--color-brand-amber)]",children:"No co-change data — git history isn't available for this repo."})]})}function Re({label:e,hint:t,value:n,children:o}){return f.jsxs("section",{className:"mb-3 last:mb-0",children:[f.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[f.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wider opacity-70",children:e}),n!==void 0&&f.jsx("span",{className:"font-mono text-[11px] tabular-nums opacity-70",children:n})]}),t&&f.jsx("p",{className:"mb-1.5 mt-0.5 text-[11px] leading-tight opacity-70",children:t}),o]})}function _o({label:e,colorVar:t,on:n,onClick:o,testId:s}){return f.jsx("button",{type:"button",onClick:o,"aria-pressed":n,"data-testid":s,"data-color-var":t,title:n?`${e} — click to hide`:`${e} — click to show`,style:n?{color:t,borderColor:t}:void 0,className:`min-h-6 rounded-full border px-2 py-0.5 text-[11px] transition-colors ${n?"bg-white/5":"border-[rgba(148,163,207,0.18)] opacity-70"}`,children:e})}function ln({label:e,title:t,on:n,onClick:o,full:s}){return f.jsx("button",{type:"button",onClick:o,title:t,"aria-pressed":n,className:`min-h-6 rounded-[6px] border px-2 py-1 text-[11px] transition-colors ${s?"w-full":"flex-1"} ${n?"border-[color-mix(in_srgb,var(--color-brand-amber)_55%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] text-[var(--color-brand-amber)]":"border-[rgba(148,163,207,0.2)] opacity-70 hover:opacity-100"}`,children:e})}const au=[{title:"Find & command",bindings:[{keys:["⌘K","Ctrl K"],description:"Command palette — symbols, files, commands",binding:"k"},{keys:["/"],description:"Search (opens the same palette)",binding:"/"},{keys:[">"],description:"Inside the palette: commands only",binding:null},{keys:["↵"],description:"Open the highlighted result and fly to it",binding:null},{keys:["⌘↵"],description:"Reveal the result without moving the camera",binding:null}]},{title:"Move around",bindings:[{keys:["←","→","↑","↓"],description:"Hop to the next / previous neighbor",binding:null},{keys:["Tab","⇧Tab"],description:"Hop neighbors (same as the arrows)",binding:"Tab"},{keys:["f"],description:"Frame the current selection — camera only, nothing is reset",binding:"f"},{keys:["d"],description:"Idle drift — gentle auto-rotation after a few seconds still",binding:"d"},{keys:["Esc"],description:"Back out one step: palette → layer → mode → selection",binding:"Escape"}]},{title:"Zoom out",bindings:[{keys:["x"],description:"Collapse the selected branch one level (symbol → file → folder)",binding:"x"},{keys:["⇧X"],description:"Collapse everything to file level",binding:"X"}]},{title:"View history",bindings:[{keys:["["],description:"Back — the previous view, camera included",binding:"["},{keys:["]"],description:"Forward again",binding:"]"}]},{title:"Summon a layer",bindings:[{keys:["m"],description:"Map — overview of the visible clusters",binding:"m"},{keys:["?"],description:"This keymap",binding:"?"},{keys:["Esc"],description:"Dismiss the open layer",binding:"Escape"}]},{title:"Pointer",bindings:[{keys:["drag"],description:"Orbit",binding:null},{keys:["scroll"],description:"Zoom",binding:null},{keys:["click cluster"],description:"Expand or collapse it",binding:null},{keys:["click star"],description:"Inspect it (opens the Inspector)",binding:null},{keys:["click empty space"],description:"Deselect (never collapses, never moves the camera)",binding:null}]},{title:"Touch",bindings:[{keys:["tap"],description:"Same as click — inspect a star, expand or collapse a cluster",binding:null},{keys:["tap empty space"],description:"Deselect",binding:null},{keys:["drag"],description:"Orbit (one finger)",binding:null},{keys:["pinch"],description:"Zoom (two fingers)",binding:null}]}];function cu(){return f.jsx(Nt,{id:"help",title:"Keyboard & pointer",dock:"center",width:"w-[min(30rem,calc(100vw-1.5rem))]",children:f.jsx("div",{className:"max-h-[min(70vh,34rem)] overflow-y-auto p-3",children:au.map(e=>f.jsxs("section",{className:"mb-3 last:mb-0",children:[f.jsx("h3",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider opacity-70",children:e.title}),f.jsx("dl",{className:"flex flex-col gap-1",children:e.bindings.map(t=>f.jsxs("div",{className:"flex items-baseline gap-2",children:[f.jsx("dt",{className:"flex shrink-0 items-center gap-1",children:t.keys.map(n=>f.jsx("kbd",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border border-[rgba(148,163,207,0.2)] bg-white/5 px-1.5 font-mono text-[11px] opacity-85",children:n},n))}),f.jsx("dd",{className:"min-w-0 flex-1 text-[13px] opacity-75",children:t.description})]},`${e.title}-${t.keys.join("/")}-${t.description}`))})]},e.title))})})}function lu(){const e=pe().model,t=b.useMemo(()=>e?ic(e):[],[e]);return f.jsx(Nt,{id:"legend",title:"Legend",dock:"right",width:"w-56",children:f.jsxs("div",{className:"max-h-[min(60vh,26rem)] overflow-y-auto p-2.5",children:[f.jsx(Dt,{label:"Node kind",children:ls.map(({kind:n,label:o})=>f.jsx(Ft,{label:o,children:f.jsx(ko,{testId:`legend-swatch-node-${n}`,color:_t(n)})},n))}),f.jsx(Dt,{label:"Edge type",children:cs.map(({type:n,label:o})=>f.jsx(Ft,{label:o,children:f.jsx(uu,{testId:`legend-swatch-edge-${n}`,color:Ns(n)})},n))}),t.length>0&&f.jsx(Dt,{label:"Languages",children:t.map(n=>f.jsx(Ft,{label:Ca[n]??n,title:"Galaxy / nebula halos are tinted by their dominant language",children:f.jsx(ko,{testId:`legend-swatch-lang-${n}`,color:xl(n,n in rs)})},n))}),f.jsx("p",{className:"mt-2 border-t border-[rgba(148,163,207,0.14)] pt-2 text-[11px] leading-relaxed opacity-70",children:"Edge opacity = confidence · halo tint = language · star size = degree"})]})})}function Dt({label:e,children:t}){return f.jsxs("section",{className:"mb-2.5 last:mb-0",children:[f.jsx("h3",{className:"mb-1 text-[11px] font-medium uppercase tracking-wider opacity-70",children:e}),f.jsx("ul",{className:"flex flex-col gap-1",children:t})]})}function Ft({label:e,title:t,children:n}){return f.jsxs("li",{className:"flex items-center gap-2",title:t,children:[n,f.jsx("span",{className:"text-[13px] opacity-80",children:e})]})}function ko({color:e,testId:t}){return f.jsx("span",{"aria-hidden":"true","data-testid":t,"data-color-var":e,className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:e}})}function uu({color:e,testId:t}){return f.jsx("span",{"aria-hidden":"true","data-testid":t,"data-color-var":e,className:"inline-block h-0.5 w-4 shrink-0 rounded-full",style:{backgroundColor:e}})}function du(e,t,n,o=6){const s=Math.max(e.maxX-e.minX,1e-6),r=Math.max(e.maxY-e.minY,1e-6),i=Math.max(t-o*2,1),a=Math.max(n-o*2,1),c=Math.min(i/s,a/r),d=(e.minX+e.maxX)/2,l=(e.minY+e.maxY)/2,u=t/2-d*c,m=n/2-l*c;return{bounds:e,scale:c,offsetX:u,offsetY:m,width:t,height:n}}function nt(e,t,n){const o=t*e.scale+e.offsetX,s=e.height-(n*e.scale+e.offsetY);return{px:o,py:s}}function fu(e,t,n){const o=(t-e.offsetX)/e.scale,s=(e.height-n-e.offsetY)/e.scale;return{x:o,y:s}}function pu(e,t,n){const o=[];for(const s of n){const r=t.get(s);if(r===void 0)continue;const i=e[r*3],a=e[r*3+1];i===void 0||a===void 0||o.push(i,a)}return new Float32Array(o)}function hu(e){let t=1/0,n=-1/0,o=1/0,s=-1/0;const r=Math.floor(e.length/2);for(let i=0;i<r;i++){const a=e[i*2],c=e[i*2+1];a<t&&(t=a),a>n&&(n=a),c<o&&(o=c),c>s&&(s=c)}return Number.isFinite(t)?{minX:t,maxX:n,minY:o,maxY:s}:{minX:0,maxX:0,minY:0,maxY:0}}function mu(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||e<=0||t<=0||n<=0)return{halfW:0,halfH:0};const o=Math.tan(t*Math.PI/360)*e;return{halfW:o*n,halfH:o}}const ot=168,st=120;function gu(){const e=pe(),t=e.model,n=b.useRef(null),o=b.useMemo(()=>{if(!t)return null;const r=pu(t.positions,t.indexByKey,ae(t,e.expanded)),i=du(hu(r),ot,st),a=Math.floor(r.length/2),c=new Float32Array(a*2);for(let d=0;d<a;d++){const{px:l,py:u}=nt(i,r[d*2],r[d*2+1]);c[d*2]=l,c[d*2+1]=u}return{proj:i,pts:c,n:a}},[t,e.expanded]);b.useEffect(()=>{if(!o)return;const r=n.current;if(!r)return;const i=Math.min(window.devicePixelRatio||1,2);r.width=ot*i,r.height=st*i;const a=r.getContext("2d");if(!a)return;let c=0;const{proj:d,pts:l,n:u}=o,m=()=>{a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,ot,st),a.fillStyle="rgba(120,170,220,0.5)";for(let p=0;p<u;p++)a.fillRect(l[p*2]-.5,l[p*2+1]-.5,1.6,1.6);const h=Qt();if(h){const p=ps();if(p){const{halfW:g,halfH:k}=mu(p.distance,p.fov,p.aspect);if(g>0&&k>0){const _=nt(d,h.x-g,h.y+k),v=nt(d,h.x+g,h.y-k);a.strokeStyle=`${Ee.teal}aa`,a.lineWidth=1,a.strokeRect(_.px,_.py,v.px-_.px,v.py-_.py)}}const{px:x,py:y}=nt(d,h.x,h.y);a.strokeStyle=Ee.amber,a.lineWidth=1.2,a.beginPath(),a.arc(x,y,4,0,Math.PI*2),a.stroke(),a.beginPath(),a.moveTo(x-7,y),a.lineTo(x+7,y),a.moveTo(x,y-7),a.lineTo(x,y+7),a.strokeStyle=`${Ee.amber}99`,a.stroke()}c=requestAnimationFrame(m)};return c=requestAnimationFrame(m),()=>cancelAnimationFrame(c)},[o]);const s=r=>{if(!o)return;const i=r.currentTarget.getBoundingClientRect(),a=(r.clientX-i.left)/i.width*ot,c=(r.clientY-i.top)/i.height*st,{x:d,y:l}=fu(o.proj,a,c),u=Qt();Mc(d,l,u?u.z:0)};return f.jsx(Nt,{id:"minimap",title:"Map",dock:"right",width:"w-[184px]",children:f.jsxs("div",{className:"p-2",children:[f.jsx("canvas",{ref:n,onClick:s,"data-testid":"minimap-canvas","data-visible-points":o?.n??0,title:"Click to recenter the view here","aria-label":"Overview map of the visible constellation — click to recenter",className:"block h-[120px] w-[168px] cursor-crosshair select-none rounded-[4px]"}),f.jsxs("p",{className:"mt-1.5 text-[11px] leading-tight opacity-70",children:["Visible clusters · ",f.jsx("span",{className:"text-[var(--color-brand-teal)]",children:"frame"})," = viewport"]})]})})}function xu(){switch(vt()){case"minimap":return f.jsx(gu,{});case"legend":return f.jsx(lu,{});case"filters":return f.jsx(ru,{});case"help":return f.jsx(cu,{});case null:return null}}function yu(e){return e==="ambiguous"?"Audit: ambiguous":"Audit: ambiguous + name"}function bu(e){const t=[];return e.lens!=="all"&&t.push({kind:"lens",label:`Lens: ${Me[e.lens].label}`}),e.impact&&t.push({kind:"impact",label:"Impact"}),e.focus&&t.push({kind:"focus",label:`Focus:${e.focusDepth}`}),e.coupling&&t.push({kind:"coupling",label:"Coupling"}),e.audit!=="off"&&t.push({kind:"audit",label:yu(e.audit)}),t}function Mn(e,t){switch(e){case"lens":t.setLens("all");return;case"impact":t.toggleImpact();return;case"focus":t.toggleFocus();return;case"coupling":t.toggleCoupling();return;case"audit":t.setAudit("off");return}}function Ms(e,t){return e.byKey.get(t)?.name??t}function vu(e,t){const n=e.clusterOfNode.get(t)??t,s=(e.ancestors.get(n)??[n]).map(i=>({key:i,label:Ms(e,i),clickable:!0})),r=e.records.get(t);return r&&!e.byKey.has(n)&&s.push({key:t,label:r.name,clickable:!1}),s}function wu(e,t){const n=t??e.rootKey;return(e.ancestors.get(n)??[n]).map(s=>({key:s,label:Ms(e,s),clickable:!0}))}function _u(e,t,n){const o=t?vu(e,t):wu(e,n),s=ku(o);return s.length>0?s:[{key:e.rootKey,label:e.repoId,clickable:!1}]}function ku(e){const t=[];for(const n of e){const o=t[t.length-1];o&&o.label===n.label?t[t.length-1]=n:t.push(n)}return t}const Nu="__ellipsis__";function Su(e,t){if(e.length<=t)return e;const n=Math.max(3,t);if(e.length<=n)return e;const o=n-2,s=e[0],r=e.slice(e.length-o);return[s,{key:Nu,label:"…",clickable:!1},...r]}const Eu=396;function ju(e,t=!1){const n=t?e-Eu:e;return n>=1024?1/0:n>=640?4:3}const Mu=250,Cs=Qo(null);function Cu(e,t){return e===t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function Tu(e,t,n){const o=ae(e,t);let s=null,r=1/0;for(const i of o){const a=e.indexByKey.get(i);if(a===void 0)continue;const c=e.positions[a*3]-n.x,d=e.positions[a*3+1]-n.y,l=e.positions[a*3+2]-n.z,u=c*c+d*d+l*l;u<r&&(r=u,s=i)}return s}let Ve=null,rt=0,Ot=null;function Au(e,t){return rt+=1,Ve===null&&(Ot=null,Ve=setInterval(()=>{const n=e(),o=Qt();!n||!o||Cu(Ot,o)||(Ot=o,Cs.set(Tu(n,t(),o)))},Mu)),()=>{rt-=1,rt<=0&&Ve!==null&&(clearInterval(Ve),Ve=null,rt=0)}}function Iu(){return vn(Cs)}function Ru(e){return e.length>7?e.slice(0,7):e}function Lu(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return"unknown age";const o=Math.max(0,t-n),s=Math.floor(o/1e3);if(s<5)return"just now";if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);if(a<30)return`${a}d ago`;const c=Math.floor(a/30);return c<12?`${c}mo ago`:`${Math.floor(c/12)}y ago`}function Ku(e,t=Date.now()){if(!e||!e.commitSha)return null;const n=Ru(e.commitSha),o=e.builtAt?Lu(e.builtAt,t):null,s=o?`graph @ ${n} · ${o}`:`graph @ ${n}`,r=e.repoUrl?`${e.repoUrl}/commit/${e.commitSha}`:null;return{label:s,href:r}}function Pu(e){const t=e?.pagesUrl?.trim();return t||null}let Ts=!1,As=!1;function $u(){return Ts}function No(e){Ts=e}function Du(){return As}function So(e){As=e}const Fu=new Set(["INHERITS","IMPLEMENTS"]),Ou=3;function zu(e){const t=new Map,n=o=>{const s=t.get(o);if(s!==void 0)return s;const r=e.byKey.get(o);if(!r||r.children.length===0)return t.set(o,0),0;let i=0;for(const a of r.children)i+=1+n(a);return t.set(o,i),i};for(const o of e.byKey.keys())n(o);return t}function Bu(e,t){let n=0,o=0;const s=i=>{const a=e.byKey.get(i);if(a){a.kind==="file"?n++:a.kind==="symbol"&&o++;for(const c of a.children)s(c)}},r=e.byKey.get(t);if(r)for(const i of r.children)s(i);return{files:n,symbols:o}}function it(e,t,n){return[...e].sort((o,s)=>{const r=t(o),i=t(s);if(r!==i)return i-r;const a=n(o),c=n(s);return a<c?-1:a>c?1:0})}function Eo(e){const t=e.byKey.get(e.rootKey);if(!t)return[];let n=t.children;if(n.length===1){const s=e.byKey.get(n[0]);s&&s.kind==="dir"&&s.children.length>0&&(n=s.children)}const o=[];for(const s of n){const r=e.byKey.get(s);r&&r.children.length>0&&o.push(r)}return o}function Hu(e){const t=new Map,n=(o,s)=>{let r=t.get(o);r||(r={in:0,out:0},t.set(o,r)),r[s]++};for(const o of e.drawEdges)n(o.from,"out"),n(o.to,"in");return t}function zt(e,t){return e.records.get(t)?.name||t}function _e(e,t){return`${e} ${t}${e===1?"":"s"}`}function Is(e){const t=[],n=Eo(e).length;t.push({id:"overview",kind:"overview",targetKey:e.rootKey,expandKeys:[],expandDepth:0,lens:"all",focusNodeId:null,collapsePrevious:!0,caption:{title:e.repoId,body:`${_e(e.counts.nodes,"node")} · ${_e(e.counts.edges,"edge")} · ${_e(n,"module")}`}});const o=zu(e),s=it(Eo(e),p=>o.get(p.key)??0,p=>p.key).slice(0,Ou);for(const p of s){const{files:x,symbols:y}=Bu(e,p.key);t.push({id:`module:${p.key}`,kind:"module",targetKey:p.key,expandKeys:[p.key],expandDepth:1,lens:"imports",focusNodeId:null,collapsePrevious:!0,caption:{title:p.name,body:`${_e(x,"file")}, ${_e(y,"symbol")}`}})}const r=Hu(e),i=[...r.entries()].map(([p,x])=>({id:p,total:x.in+x.out,in:x.in})),c=it(i,p=>p.total,p=>p.id)[0];c&&c.total>0&&t.push({id:`hub:${c.id}`,kind:"node",targetKey:c.id,expandKeys:[],expandDepth:0,lens:"calls",focusNodeId:c.id,collapsePrevious:!0,caption:{title:zt(e,c.id),body:`called from ${_e(c.in,"place")}`}});const d=new Map;for(const p of e.drawEdges)Fu.has(p.type)&&(d.set(p.from,(d.get(p.from)??0)+1),d.set(p.to,(d.get(p.to)??0)+1));const l=[...d.entries()].filter(([p])=>{const x=e.records.get(p)?.kind;return x==="Class"||x==="Interface"}).map(([p,x])=>({id:p,count:x})),u=it(l,p=>p.count,p=>p.id)[0];if(u&&u.count>0){const p=e.records.get(u.id)?.kind??"Type";t.push({id:`type:${u.id}`,kind:"node",targetKey:u.id,expandKeys:[],expandDepth:0,lens:"types",focusNodeId:u.id,collapsePrevious:!0,caption:{title:zt(e,u.id),body:`${p} · ${_e(u.count,"type link")}`}})}const m=[...r.entries()].filter(([p])=>e.records.get(p)?.kind==="Function"&&p!==c?.id).map(([p,x])=>({id:p,out:x.out})),h=it(m,p=>p.out,p=>p.id)[0];return h&&h.out>0&&t.push({id:`entry:${h.id}`,kind:"node",targetKey:h.id,expandKeys:[],expandDepth:0,lens:"calls",focusNodeId:h.id,collapsePrevious:!0,caption:{title:zt(e,h.id),body:`calls out to ${_e(h.out,"place")}`}}),t}function qu(e,t,n){const o=t.collapsePrevious?new Set([e.rootKey]):new Set(n),s=[],r=i=>{o.has(i)||(o.add(i),s.push(i))};if(t.kind==="module")for(const i of t.expandKeys){const a=e.byKey.get(i);a&&a.children.length>0&&r(i)}else if(t.focusNodeId)for(const i of Io(e,t.focusNodeId))r(i);return s}const Uu=5500;function Vu(){const e=X(),t=e.model,n=e.tour,o=b.useMemo(()=>t?Is(t):[],[t]),[s,r]=b.useState(0),[i,a]=b.useState(!0),[c,d]=b.useState(!1),l=b.useCallback(y=>{t&&(y.collapsePrevious&&e.resetExpansion(),e.setLens(y.lens),e.revealWithoutRefit(qu(t,y,e.expanded)),y.focusNodeId?(e.select(y.focusNodeId),e.toggleFocus()):e.select(null),e.setFocusTarget(y.targetKey))},[t,e]),u=b.useCallback(y=>{if(o.length===0)return;const g=Math.max(0,Math.min(o.length-1,y));r(g),l(o[g])},[o,l]),m=b.useRef(!1);if(b.useEffect(()=>{n&&!m.current?(Bc(),r(0),a(!0),o.length>0&&l(o[0])):!n&&m.current&&Hc(),m.current=n},[n,o,l]),b.useEffect(()=>{if(!n)return;d(!1);const y=setTimeout(()=>d(!0),60);return()=>clearTimeout(y)},[s,n]),b.useEffect(()=>{if(!n||!i)return;const y=setTimeout(()=>{s<o.length-1?u(s+1):a(!1)},Uu);return()=>clearTimeout(y)},[n,i,s,o.length,u]),b.useEffect(()=>{if(!n)return;const y=g=>{if(g.key==="Escape"){if(bt())return;g.stopImmediatePropagation(),e.exitTour()}};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[n,e]),!t||o.length===0||!n)return null;const h=o[s],p=s===0,x=s===o.length-1;return f.jsxs(f.Fragment,{children:[f.jsx("div",{"data-testid":"tour-caption",className:`pointer-events-none fixed inset-x-0 bottom-[88px] z-[140] mx-auto w-[min(520px,calc(100vw-3rem))] text-center transition-opacity duration-500 motion-reduce:transition-none ${c?"opacity-100":"opacity-0"}`,children:f.jsxs("div",{className:"inline-block max-w-full rounded-[12px] border border-[color-mix(in_srgb,var(--color-brand-amber)_28%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-navy)_88%,transparent)] px-5 py-3.5 shadow-[0_8px_32px_rgba(0,0,0,0.5)] backdrop-blur-md",children:[f.jsxs("p",{className:"mb-1.5 text-[11px] uppercase tracking-[0.16em] text-[var(--color-brand-teal)] opacity-85",children:["Guided tour · stop ",s+1," / ",o.length]}),f.jsx("p",{className:"break-words text-[19px] font-semibold leading-snug text-[var(--color-brand-cream)]",children:h.caption.title}),f.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-[var(--color-brand-cream)] opacity-80",children:h.caption.body})]})}),f.jsxs("div",{"data-testid":"tour-transport",className:"pointer-events-auto fixed inset-x-0 bottom-10 z-[141] mx-auto flex w-fit items-center gap-2 rounded-full border border-[rgba(148,163,207,0.3)] bg-[color-mix(in_srgb,var(--color-brand-navy)_92%,transparent)] px-2.5 py-1.5 backdrop-blur-md",children:[f.jsx(at,{label:"⟨ Prev",disabled:p,onClick:()=>u(s-1)}),f.jsx(at,{label:i?"❚❚ Pause":"▶ Play",primary:!0,onClick:()=>a(y=>!y)}),f.jsx(at,{label:"Next ⟩",disabled:x,onClick:()=>{a(!1),u(s+1)}}),f.jsx("span",{className:"mx-1.5 flex gap-1","aria-hidden":"true",children:o.map((y,g)=>f.jsx("span",{className:`h-1.5 w-1.5 rounded-full transition-colors ${g===s?"bg-[var(--color-brand-amber)]":"bg-white/25"}`},y.id))}),f.jsx(at,{label:"✕ Exit",onClick:()=>e.exitTour()})]})]})}function Gu(){const e=X(),t=e.model,n=b.useMemo(()=>t?Is(t):[],[t]);return!t||n.length===0||e.tour?null:f.jsx("button",{type:"button",onClick:()=>e.startTour(),title:"Take a guided cinematic tour of the constellation",className:"min-h-6 min-w-6 rounded-full border border-[color-mix(in_srgb,var(--color-brand-teal)_40%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-teal)_12%,transparent)] px-2 py-1 text-[11px] text-[var(--color-brand-cream)] hover:opacity-85",children:"▶ Tour"})}function at({label:e,onClick:t,disabled:n,primary:o}){return f.jsx("button",{type:"button",onClick:t,disabled:n,className:`whitespace-nowrap rounded-full border px-3 py-1 text-[13px] transition-colors disabled:cursor-default disabled:opacity-35 ${o?"border-[color-mix(in_srgb,var(--color-brand-amber)_55%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] text-[var(--color-brand-cream)]":"border-[rgba(148,163,207,0.22)] bg-white/5 text-[var(--color-brand-cream)] opacity-85 hover:opacity-100"}`,children:e})}const Wu="h-7 text-[13px] text-[var(--color-brand-cream)]",ze="font-mono",un="opacity-70",St="min-h-6 min-w-6",Yu=768,Xu=640,Qu=480;function Zu(){const e=X(),t=e.model,n=jn(),o=b.useRef(e);o.current=e;const s=bu(e),r=Iu(),i=b.useMemo(()=>t?_u(t,e.selected,r):[],[t,e.selected,r]),a=t!==null&&e.selected!==null&&t.records.has(e.selected),c=b.useMemo(()=>Su(i,ju(n,a)),[i,n,a]);b.useEffect(()=>{if(t)return Au(()=>o.current.model,()=>o.current.expanded)},[t]);const d=b.useRef(s);return d.current=s,b.useEffect(()=>{const l=u=>{if(u.key!=="Escape"||bt()||$u()||Du()||o.current.tour||tn()!==null)return;const m=d.current[0];m&&(u.preventDefault(),u.stopImmediatePropagation(),Mn(m.kind,o.current))};return window.addEventListener("keydown",l,!0),()=>window.removeEventListener("keydown",l,!0)},[]),f.jsxs("footer",{role:"contentinfo",className:`${Wu} pointer-events-auto fixed inset-x-0 bottom-0 z-[100] flex items-center gap-4 overflow-x-auto border-t border-[rgba(148,163,207,0.16)] bg-[color-mix(in_srgb,var(--color-brand-navy)_94%,transparent)] px-3`,children:[f.jsx(Ju,{hideStaleness:n<Yu,hideCounts:n<Xu}),f.jsx(nd,{crumbs:c}),f.jsx(od,{chips:s,collapseChips:n<Qu})]})}function Ju({hideStaleness:e,hideCounts:t}){const o=X().model;return f.jsxs("div",{className:"flex min-w-0 shrink-0 items-center gap-2 whitespace-nowrap",children:[f.jsx("span",{"data-testid":"statusbar-repo-name",className:"font-medium text-[var(--color-brand-amber)]",children:o?.repoId??"RepoSkein"}),o&&!t&&f.jsxs("span",{className:`${ze} text-[11px] ${un}`,children:[o.counts.nodes," nodes · ",o.counts.edges," edges"]}),o&&!t&&f.jsx(ed,{}),o&&!e&&f.jsx(td,{})]})}function ed(){const{drawn:e,total:t}=Ea(),n=t>0&&e<t,o=b.useRef(!1);return b.useEffect(()=>{n&&!o.current&&be(`Edge cap engaged — drawing ${e} of ${t} bundles`,{tone:"warn",hint:"Collapse a cluster or narrow the lens to see more",dedupeKey:"edge-cap"}),o.current=n},[n,e,t]),n?f.jsxs("span",{className:`${ze} text-[11px] text-[var(--color-brand-amber)]`,title:"Edge bundles currently drawn / total bundles before the render cap",children:["capped ",e,"/",t]}):null}function td(){const e=X(),t=Ku(e.model?.repoMeta??null),n=Pu(e.model?.repoMeta??null);return!t&&!n?null:f.jsxs("span",{className:"flex items-center gap-2",children:[t&&(t.href?f.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer",className:`${ze} text-[11px] ${un} hover:opacity-90`,title:e.model?.repoMeta?.builtAt?`baked ${e.model.repoMeta.builtAt}`:void 0,children:t.label}):f.jsx("span",{className:`${ze} text-[11px] ${un}`,children:t.label})),n&&f.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:"text-[11px] text-[var(--color-brand-amber)] hover:opacity-90",title:"Open this team's published constellation",children:"team ↗"})]})}function nd({crumbs:e}){const t=X();function n(o){o.clickable&&t.revealAndSelect(o.key,{fly:!0,collapseDeeper:!0})}return e.length===0?f.jsx("div",{className:"flex-1 min-w-0"}):f.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center overflow-hidden whitespace-nowrap px-2",children:e.map((o,s)=>f.jsxs("span",{className:"flex min-w-[2ch] shrink items-center",children:[s>0&&f.jsx("span",{"aria-hidden":"true",className:"mx-1.5 shrink-0 opacity-35",children:"·"}),o.clickable?f.jsx("button",{type:"button",onClick:()=>n(o),title:o.label,className:`${ze} min-w-0 truncate text-[13px] transition-opacity motion-reduce:transition-none ${s===e.length-1?"text-[var(--color-brand-cream)] opacity-95":"opacity-70 hover:opacity-90"}`,children:o.label}):f.jsx("span",{title:o.label,className:`${ze} min-w-0 truncate text-[13px] text-[var(--color-brand-cream)] opacity-95`,children:o.label})]},`${o.key}-${s}`))})}function od({chips:e,collapseChips:t}){const n=X(),o=vt();return f.jsxs("div",{className:"flex shrink-0 items-center gap-2 whitespace-nowrap",children:[e.length>0&&(t?f.jsx(rd,{chips:e}):e.map(s=>f.jsx(sd,{chip:s},s.kind))),f.jsx(id,{}),f.jsx(ct,{id:"minimap",label:"Map",name:"map",hint:"Overview of the clusters currently on screen",open:o}),f.jsx(ct,{id:"legend",label:"Legend",name:"legend",hint:"What every color and line weight means",open:o}),f.jsx(ct,{id:"filters",label:"Filters",name:"filters",hint:"Symbol kinds, relationships, confidence, edge bundling",open:o}),n.model&&f.jsx(dn,{label:"Shot",title:"Capture a PNG screenshot of the current view",active:!1,onClick:()=>{Es(),be("Screenshot saved",{tone:"accent",dedupeKey:"screenshot"})}}),n.model&&f.jsx(dn,{label:"Frame",title:"Frame all — refit the camera to what's currently on screen",active:!1,onClick:()=>n.requestFit()}),f.jsx(Gu,{}),f.jsx(ct,{id:"help",label:"?",name:"keyboard shortcuts",hint:"Every key and pointer gesture",open:o})]})}function ct({id:e,label:t,name:n,hint:o,open:s}){const r=s===e;return f.jsx(dn,{label:t,title:`${r?"Hide":"Show"} ${n} — ${o}`,active:r,onClick:()=>Sn(e),layerToggle:!0})}function sd({chip:e}){const t=X();return f.jsxs("button",{type:"button",onClick:()=>Mn(e.kind,t),title:`${e.label} — click to dismiss`,className:`${St} flex items-center gap-1.5 rounded-full border border-[color-mix(in_srgb,var(--color-brand-amber)_45%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_14%,transparent)] px-2 py-1 text-[11px] text-[var(--color-brand-amber)] transition-opacity duration-150 ease-out hover:opacity-80`,children:[f.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--color-brand-amber)]"}),e.label]})}function rd({chips:e}){const t=X(),[n,o]=b.useState(!1),s=b.useRef(null);function r(i){o(i),So(i)}return b.useEffect(()=>{if(!n)return;const i=c=>{s.current?.contains(c.target)||r(!1)},a=c=>{c.key==="Escape"&&(c.stopPropagation(),r(!1))};return document.addEventListener("mousedown",i),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",a)}},[n]),b.useEffect(()=>()=>So(!1),[]),f.jsxs("span",{ref:s,className:"relative",children:[f.jsxs("button",{type:"button",onClick:()=>r(!n),title:`${e.length} active mode${e.length===1?"":"s"}`,"aria-expanded":n,className:`${St} flex items-center gap-1.5 rounded-full border border-[color-mix(in_srgb,var(--color-brand-amber)_45%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_14%,transparent)] px-2 py-1 text-[11px] text-[var(--color-brand-amber)]`,children:[f.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 rounded-full bg-[var(--color-brand-amber)]"}),e.length," mode",e.length===1?"":"s"," ▾"]}),n&&f.jsx("div",{role:"menu",className:"absolute bottom-full right-0 mb-2 flex w-48 flex-col gap-0.5 rounded-[8px] border border-[rgba(148,163,207,0.18)] bg-[color-mix(in_srgb,var(--color-brand-navy)_96%,white_4%)] p-1 shadow-[0_8px_24px_-8px_rgba(0,0,0,0.6)]",children:e.map(i=>f.jsxs("button",{type:"button",onClick:()=>{Mn(i.kind,t),e.length<=1&&r(!1)},title:`${i.label} — click to dismiss`,className:"flex items-center justify-between gap-2 rounded-[6px] px-2 py-1 text-left text-[12px] text-[var(--color-brand-cream)] opacity-85 hover:opacity-100",children:[f.jsx("span",{children:i.label}),f.jsx("span",{"aria-hidden":"true",className:"opacity-60",children:"✕"})]},i.kind))})]})}function id(){const e=X(),[t,n]=b.useState(!1),o=e.lens,s=b.useRef(null);function r(i){n(i),No(i)}return b.useEffect(()=>{if(!t)return;const i=c=>{s.current?.contains(c.target)||r(!1)},a=c=>{c.key==="Escape"&&(c.stopPropagation(),r(!1))};return document.addEventListener("mousedown",i),document.addEventListener("keydown",a),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",a)}},[t]),b.useEffect(()=>()=>No(!1),[]),f.jsxs("span",{ref:s,className:"relative",children:[f.jsxs("button",{type:"button",onClick:()=>r(!t),title:"Switch lens","aria-expanded":t,className:`${St} rounded-full border border-[rgba(148,163,207,0.25)] px-2 py-1 text-[11px] opacity-80 hover:opacity-100`,children:["Lens",o!=="all"?`: ${Me[o].label}`:""," ▾"]}),t&&f.jsx("div",{role:"menu",className:"absolute bottom-full right-0 mb-2 flex w-44 flex-col gap-0.5 rounded-[8px] border border-[rgba(148,163,207,0.18)] bg-[color-mix(in_srgb,var(--color-brand-navy)_96%,white_4%)] p-1 shadow-[0_8px_24px_-8px_rgba(0,0,0,0.6)]",children:gn.map(i=>{const a=i===o;return f.jsx("button",{type:"button",role:"menuitemradio","aria-checked":a,onClick:()=>{e.setLens(i),r(!1)},title:Me[i].hint,className:`rounded-[6px] px-2 py-1 text-left text-[12px] ${a?"bg-[color-mix(in_srgb,var(--color-brand-amber)_18%,transparent)] text-[var(--color-brand-amber)]":"text-[var(--color-brand-cream)] opacity-80 hover:opacity-100"}`,children:Me[i].label},i)})})]})}function dn({label:e,title:t,active:n,onClick:o,layerToggle:s}){return f.jsx("button",{type:"button",onClick:o,title:t,"aria-pressed":n,"data-layer-toggle":s?"":void 0,className:`${St} rounded-full border px-2 py-1 text-[11px] transition-colors ${n?"border-[color-mix(in_srgb,var(--color-brand-teal)_45%,transparent)] text-[var(--color-brand-teal)]":"border-[rgba(148,163,207,0.2)] opacity-70 hover:opacity-100"}`,children:e})}const ad={info:"border-[rgba(148,163,207,0.28)] text-[var(--color-brand-cream)]",accent:"border-[color-mix(in_srgb,var(--color-brand-teal)_45%,transparent)] text-[var(--color-brand-teal)]",warn:"border-[color-mix(in_srgb,var(--color-brand-amber)_50%,transparent)] text-[var(--color-brand-amber)]"};function cd(){const e=bs(),t=vt()!==null;return f.jsx("div",{"aria-live":"polite","aria-atomic":"false","data-testid":"toast-region","data-position":t?"top":"bottom",className:`pointer-events-none fixed left-1/2 z-[150] flex w-[min(360px,calc(100vw-2rem))] -translate-x-1/2 flex-col items-center gap-1.5 ${t?"top-3":"bottom-10"}`,children:e.map(n=>f.jsxs("div",{role:"status","data-testid":"toast",className:`pointer-events-auto flex w-full items-start gap-2 rounded-[8px] border bg-[color-mix(in_srgb,var(--color-brand-navy)_94%,white_6%)] px-3 py-2 text-[13px] shadow-[0_8px_24px_-10px_rgba(0,0,0,0.7)] ${ad[n.tone]}`,children:[f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block",children:n.text}),n.hint&&f.jsx("span",{className:"mt-0.5 block text-[11px] text-[var(--color-brand-cream)] opacity-70",children:n.hint})]}),f.jsx("button",{type:"button",onClick:()=>rn(n.id),"aria-label":"Dismiss notification",className:"shrink-0 text-[var(--color-brand-cream)] opacity-70 hover:opacity-100",children:"✕"})]},n.id))})}function ld(){const e=pe(),t=e.impact!==null,n=e.focus!==null,o=e.audit!=="off",s=e.coupling,r=b.useRef({impactOn:t,focusOn:n,auditOn:o,couplingOn:s,tour:e.tour});return b.useEffect(()=>{const i=r.current;t!==i.impactOn&&be(t?"Impact on":"Impact off",{tone:t?"accent":"info",hint:t?"Esc to exit":void 0,dedupeKey:"mode-impact"}),n!==i.focusOn&&be(n?`Focus on — depth ${e.focusDepth}`:"Focus off",{tone:n?"accent":"info",hint:n?"Esc to exit":void 0,dedupeKey:"mode-focus"}),o!==i.auditOn&&be(o?"Confidence audit on":"Confidence audit off",{tone:o?"warn":"info",hint:o?"Esc to exit":void 0,dedupeKey:"mode-audit"}),s!==i.couplingOn&&be(s?"Co-change links on":"Co-change links off",{tone:s?"accent":"info",hint:s?"Esc to exit":void 0,dedupeKey:"mode-coupling"}),r.current={impactOn:t,focusOn:n,auditOn:o,couplingOn:s,tour:e.tour}},[t,n,o,s,e.tour,e.focusDepth]),null}const fn=4,ud={starting:0,"fetching manifest":1,"fetching graph":2,parsing:3,"parsing baked graph":3,"fetching federated repos":3,"restoring layout":4,"charting the sky":4};function dd(e){const t=e.trim(),n=ud[t.toLowerCase()],o=n!==void 0,s=o?n:0;return{step:s,total:fn,fraction:s/fn,label:t,known:o}}function fd(){const e=pe().status,t=e.kind==="loading",n=e.kind==="loading"?e.phase:"",o=dd(n),[s,r]=b.useState(!0),[i,a]=b.useState(!0);return b.useEffect(()=>{if(t){r(!0),a(!0);return}a(!1);const c=setTimeout(()=>r(!1),700);return()=>clearTimeout(c)},[t]),s?f.jsxs("div",{"data-testid":"loading-screen","aria-live":"polite","aria-busy":t,className:`pointer-events-none fixed inset-0 z-[130] flex flex-col items-center justify-center gap-4 bg-[radial-gradient(ellipse_60%_50%_at_50%_50%,rgba(5,6,12,0.55)_0%,rgba(5,6,12,0)_70%)] transition-opacity duration-700 motion-reduce:transition-none ${i?"opacity-100":"opacity-0"}`,children:[f.jsxs("div",{className:"relative h-16 w-16",children:[f.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-[color-mix(in_srgb,var(--color-brand-teal)_35%,transparent)] border-t-[var(--color-brand-amber)] motion-safe:animate-[rs-spin_1.6s_linear_infinite]"}),f.jsx("span",{className:"absolute inset-[18px] rounded-full bg-[radial-gradient(circle,var(--color-brand-amber)_0%,transparent_70%)] motion-safe:animate-[rs-pulse_1.8s_ease-in-out_infinite]"})]}),f.jsxs("div",{className:"text-center",children:[f.jsx("p",{className:"text-[15px] tracking-wide text-[var(--color-brand-cream)]",children:"Charting the constellation…"}),o.label&&f.jsxs("p",{"data-testid":"loading-phase",className:"mt-1 text-[11px] opacity-60",children:[o.label,o.known&&f.jsxs("span",{"data-testid":"loading-fraction",className:"ml-1.5 font-mono tabular-nums",children:["step ",o.step," of ",o.total]})]})]}),f.jsx("div",{role:"progressbar","aria-label":"Graph load progress","aria-valuemin":0,"aria-valuemax":o.total,"aria-valuenow":o.known?o.step:void 0,"aria-valuetext":o.label||void 0,className:"flex gap-1",children:Array.from({length:fn},(c,d)=>f.jsx("span",{"data-testid":`loading-segment-${d+1}`,"data-filled":d<o.step,className:`h-0.5 w-8 rounded-full transition-colors ${d<o.step?"bg-[var(--color-brand-amber)]":"bg-white/12"}`},d))})]}):null}function pd({message:e}){const t=X();return f.jsxs("div",{role:"alert","data-testid":"error-screen",className:"pointer-events-auto fixed inset-0 z-[135] flex flex-col items-center justify-center gap-3 bg-[var(--color-brand-navy)] px-6 text-center",children:[f.jsx("p",{className:"text-[15px] font-medium text-[var(--color-brand-cream)]",children:"Couldn't chart the constellation"}),f.jsx("p",{"data-testid":"error-message",className:"max-w-md break-words font-mono text-[11px] leading-relaxed text-[var(--color-brand-cream)] opacity-70",children:e}),f.jsx("button",{type:"button","data-testid":"error-retry",onClick:()=>t.retryLoad(),className:"mt-1 min-h-6 rounded-[8px] border border-[color-mix(in_srgb,var(--color-brand-amber)_55%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-amber)_16%,transparent)] px-3 py-1.5 text-[13px] text-[var(--color-brand-amber)] hover:opacity-85",children:"Retry"}),f.jsxs("p",{className:"max-w-md text-[11px] leading-relaxed opacity-70",children:["The graph is read from ",f.jsx("span",{className:"font-mono",children:".reposkein"})," — if this keeps failing, re-run the indexer and reload."]})]})}const Rs="reposkein.coachmark.dismissed.v1";function hd(){try{return window.localStorage.getItem(Rs)==="1"}catch{return!1}}let pn=typeof window>"u"?!0:hd();const md=new Set;function gd(){for(const e of md)e()}function xd(){return pn}function yd(){if(!pn){pn=!0;try{window.localStorage.setItem(Rs,"1")}catch{}gd()}}function bd(){const[e,t]=b.useState(!1),n=vt()!==null,o=bs().length>0;if(b.useEffect(()=>{xd()||t(!0)},[]),!e||n||o)return null;function s(){yd(),t(!1)}return f.jsxs("div",{role:"status","data-testid":"coach-mark",className:"pointer-events-auto fixed inset-x-0 bottom-9 z-[101] mx-auto flex w-fit items-center gap-2 rounded-full border border-[rgba(148,163,207,0.22)] bg-[color-mix(in_srgb,var(--color-brand-navy)_92%,white_4%)] px-3 py-1.5 text-[12px] text-[var(--color-brand-cream)] shadow-[0_8px_24px_-10px_rgba(0,0,0,0.6)] motion-safe:animate-[rs-layer-in_180ms_ease-out] motion-reduce:animate-none",children:[f.jsxs("span",{className:"flex items-center gap-1.5 opacity-90",children:[f.jsx(jo,{children:"⌘K"})," to navigate ",f.jsx("span",{"aria-hidden":"true",className:"opacity-50",children:"·"})," ",f.jsx(jo,{children:"?"})," for keys"]}),f.jsx("button",{type:"button",onClick:s,"aria-label":"Dismiss hint",className:"shrink-0 opacity-70 hover:opacity-100",children:"✕"})]})}function jo({children:e}){return f.jsx("kbd",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border border-[rgba(148,163,207,0.22)] bg-white/5 px-1.5 font-mono text-[11px] opacity-90",children:e})}function vd(e,t){return e.button!==0?!1:(t.select(null),!0)}function Mo(e){const t=e.match(/^rs1:[^:]+(:.+)$/);return t?t[1]:null}function Co(e,t){const n=Mo(e);if(!n)return null;let o=null;for(const s of t)s!==e&&s.endsWith(n)&&Mo(s)===n&&(o===null||s<o)&&(o=s);return o}function wd(){return f.jsx(Na,{children:f.jsx(_d,{})})}function _d(){const e=X(),t=Fs({from:"/"}),n=Os({from:"/"}),o=e.model,s=b.useCallback(u=>o?Kc(o,u,Jo(),ps()):!1,[o]);b.useEffect(()=>(Un(s),()=>Un(null)),[s]),b.useEffect(()=>{const u=m=>Wl(m,e,e,{openPalette:Oc,toggleLayer:Sn,paletteOpen:bt,isOnScreen:s});return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]);const[r,i]=b.useState(null),[a]=b.useState(()=>Zc(t)),c=b.useRef(tl(a));b.useEffect(()=>{if(c.current||!e.model)return;const u=e.model;if(a.lens&&a.lens!=="all"&&e.setLens(a.lens),a.node){let y=a.node;if(!u.records.has(y)){const g=Co(y,u.records.keys());g?y=g:(i(a.node),y="")}y&&(i(null),e.revealAndSelect(y,{fly:!0}))}const{impact:m,focus:h,coupling:p,audit:x}=a.overlays;h!==null?(e.setFocusDepth(h),e.toggleFocus()):m&&e.toggleImpact(),p&&e.toggleCoupling(),x&&e.setAudit(x),c.current=!0},[e.model]);const d=t.node;b.useEffect(()=>{if(!c.current||!e.model||!d||d===e.selected)return;const u=e.model;let m=d;if(!u.records.has(m)){const h=Co(m,u.records.keys());if(!h){i(d);return}m=h}i(null),e.revealAndSelect(m,{fly:!0})},[e.model,d]),b.useEffect(()=>{if(!e.coupling||e.cochange!==null)return;let u=!1;return Pc().then(m=>{u||e.setCochange(m)}),()=>{u=!0}},[e.coupling,e.cochange]);const l=vs(e);return b.useEffect(()=>{c.current&&(el(l,t)||n({search:l,replace:!0}))},[l.node,l.lens,l.overlays]),f.jsxs("div",{className:"relative h-full w-full",children:[f.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_80%_60%_at_50%_38%,#16204a_0%,#0a1024_42%,#05060c_78%,#02030a_100%)]"}),f.jsxs(Zs,{camera:{position:[0,0,160],fov:55,near:.1,far:6e3},frameloop:"demand",gl:{antialias:!0,preserveDrawingBuffer:!0},style:{background:"transparent"},onPointerMissed:u=>vd(u,e),children:[f.jsx("fogExp2",{attach:"fog",args:[461330,.0016]}),f.jsx("ambientLight",{intensity:.6}),f.jsx(oc,{}),e.status.kind==="ready"&&e.model&&f.jsxs(f.Fragment,{children:[f.jsx(cc,{}),f.jsx(fc,{}),f.jsx(Ja,{}),f.jsx(yc,{}),f.jsx(Sc,{}),f.jsx(Fc,{}),f.jsx(Ic,{}),e.showLabels&&f.jsx(jc,{})]}),f.jsx(Ac,{}),f.jsx(kl,{repoId:e.model?.repoId}),f.jsx(Js,{children:f.jsx(er,{luminanceThreshold:.2,luminanceSmoothing:.4,intensity:.9,mipmapBlur:!0})})]}),f.jsxs(Ll,{hidden:e.tour,children:[f.jsx(Zu,{}),e.status.kind==="ready"&&f.jsx(Xl,{}),f.jsx(xu,{}),e.status.kind==="ready"&&f.jsx(bd,{}),r&&f.jsx(kd,{nodeId:r,onDismiss:()=>i(null)}),f.jsx(cd,{})]}),f.jsx(Tl,{}),f.jsx(Vu,{}),f.jsx(ld,{}),f.jsx(fd,{}),e.status.kind==="error"&&f.jsx(pd,{message:e.status.message})]})}function kd({nodeId:e,onDismiss:t}){return f.jsxs("div",{role:"status",className:"pointer-events-auto fixed left-3 top-3 z-[115] flex max-w-80 items-start gap-2 rounded-[8px] border border-[color-mix(in_srgb,var(--color-brand-amber)_40%,transparent)] bg-[color-mix(in_srgb,var(--color-brand-navy)_94%,white_4%)] px-3 py-2 text-[13px] text-[var(--color-brand-cream)]",children:[f.jsxs("span",{className:"min-w-0 flex-1",children:["Node not found — it may have been renamed or removed.",f.jsx("span",{title:e,className:"mt-0.5 block truncate font-mono text-[11px] opacity-60",children:e})]}),f.jsx("button",{type:"button",onClick:t,"aria-label":"Dismiss",className:"shrink-0 opacity-60 hover:opacity-100",children:"✕"})]})}const Nd=new zs,Ls=Bs({component:()=>f.jsx(Ws,{})}),Sd=Hs({getParentRoute:()=>Ls,path:"/",validateSearch:Jc,component:wd}),Ed=Ls.addChildren([Sd]),jd=qs({routeTree:Ed,history:gt()?Us():void 0});tr.createRoot(document.getElementById("root")).render(f.jsx(b.StrictMode,{children:f.jsx(Vs,{client:Nd,children:f.jsx(Gs,{router:jd})})}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Mg,a as Cg,R as o0,u as Ug,g as Ag,b as J,j as ul}from"./tanstack-
|
|
1
|
+
import{r as Mg,a as Cg,R as o0,u as Ug,g as Ag,b as J,j as ul}from"./tanstack-CSzx6NDA.js";import{W as Dg,R as c0,O as nm,P as lm,S as op,a as Ym,V as Rg,b as Ng,B as Bg,C as wg,L as Tp,c as Hn,N as cp,A as Hg,d as gv,e as am,f as Yi,g as Lg,U as Nu,h as kg,i as Fi,j as wn,T as jg,D as Gg,k as Vg,l as Fg,F as f0,m as ni,n as Ih,M as Yg,o as Kh,p as ac,E as zp,q as d0,r as qg,s as Vh,t as Ff,u as Zg,v as Cr,w as ct,x as h0,y as m0,z as Qg,G as yv,H as Xg,I as Op,J as fp,K as Ig,Q as p0,X as Kg,Y as Pg,Z as $g,_ as Jg,$ as Wg,a0 as e1}from"./three-Cpu5RUEM.js";var qm={exports:{}},Lf={},Zm={exports:{}},Qm={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* scheduler.production.js
|
|
4
4
|
*
|