@reposkein/mcp 0.3.0 → 0.4.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.
Files changed (98) hide show
  1. package/README.md +73 -1
  2. package/binary-digests.json +4 -4
  3. package/dist/SKILL.md +19 -0
  4. package/dist/cli/agentAdapters.d.ts +68 -0
  5. package/dist/cli/agentAdapters.js +223 -0
  6. package/dist/cli/agentAdapters.js.map +1 -0
  7. package/dist/cli/ansi.d.ts +24 -0
  8. package/dist/cli/ansi.js +40 -0
  9. package/dist/cli/ansi.js.map +1 -0
  10. package/dist/cli/doctor.d.ts +34 -2
  11. package/dist/cli/doctor.js +51 -6
  12. package/dist/cli/doctor.js.map +1 -1
  13. package/dist/cli/doctorFreshness.d.ts +43 -0
  14. package/dist/cli/doctorFreshness.js +111 -0
  15. package/dist/cli/doctorFreshness.js.map +1 -0
  16. package/dist/cli/doctorSummaries.d.ts +2 -0
  17. package/dist/cli/doctorSummaries.js +95 -0
  18. package/dist/cli/doctorSummaries.js.map +1 -0
  19. package/dist/cli/federatedDiscovery.d.ts +16 -0
  20. package/dist/cli/federatedDiscovery.js +75 -0
  21. package/dist/cli/federatedDiscovery.js.map +1 -0
  22. package/dist/cli/init.d.ts +69 -6
  23. package/dist/cli/init.js +194 -28
  24. package/dist/cli/init.js.map +1 -1
  25. package/dist/cli/sourceSlices.d.ts +17 -0
  26. package/dist/cli/sourceSlices.js +59 -0
  27. package/dist/cli/sourceSlices.js.map +1 -0
  28. package/dist/cli/stats.d.ts +29 -0
  29. package/dist/cli/stats.js +180 -0
  30. package/dist/cli/stats.js.map +1 -0
  31. package/dist/cli/view.d.ts +71 -3
  32. package/dist/cli/view.js +147 -12
  33. package/dist/cli/view.js.map +1 -1
  34. package/dist/index.d.ts +8 -0
  35. package/dist/index.js +286 -123
  36. package/dist/index.js.map +1 -1
  37. package/dist/indexer/fetchBinary.d.ts +14 -0
  38. package/dist/indexer/fetchBinary.js +81 -40
  39. package/dist/indexer/fetchBinary.js.map +1 -1
  40. package/dist/indexer/runIndexer.d.ts +0 -2
  41. package/dist/indexer/runIndexer.js +8 -4
  42. package/dist/indexer/runIndexer.js.map +1 -1
  43. package/dist/store/JsonlGraphStore.d.ts +13 -3
  44. package/dist/store/JsonlGraphStore.js +55 -17
  45. package/dist/store/JsonlGraphStore.js.map +1 -1
  46. package/dist/store/decisions.d.ts +20 -2
  47. package/dist/store/decisions.js +35 -2
  48. package/dist/store/decisions.js.map +1 -1
  49. package/dist/store/indexedAt.d.ts +18 -0
  50. package/dist/store/indexedAt.js +56 -0
  51. package/dist/store/indexedAt.js.map +1 -0
  52. package/dist/store/instrumentTool.d.ts +40 -0
  53. package/dist/store/instrumentTool.js +82 -0
  54. package/dist/store/instrumentTool.js.map +1 -0
  55. package/dist/store/repoContextCache.d.ts +15 -0
  56. package/dist/store/repoContextCache.js +26 -0
  57. package/dist/store/repoContextCache.js.map +1 -0
  58. package/dist/store/repoSession.d.ts +63 -0
  59. package/dist/store/repoSession.js +123 -0
  60. package/dist/store/repoSession.js.map +1 -0
  61. package/dist/store/resolveRepoPath.d.ts +31 -0
  62. package/dist/store/resolveRepoPath.js +85 -0
  63. package/dist/store/resolveRepoPath.js.map +1 -0
  64. package/dist/store/sessionLog.d.ts +98 -0
  65. package/dist/store/sessionLog.js +216 -0
  66. package/dist/store/sessionLog.js.map +1 -0
  67. package/dist/store/sessionStats.d.ts +55 -0
  68. package/dist/store/sessionStats.js +140 -0
  69. package/dist/store/sessionStats.js.map +1 -0
  70. package/dist/store/sidecar.d.ts +39 -3
  71. package/dist/store/sidecar.js +89 -5
  72. package/dist/store/sidecar.js.map +1 -1
  73. package/dist/store/summaryShards.d.ts +117 -0
  74. package/dist/store/summaryShards.js +291 -0
  75. package/dist/store/summaryShards.js.map +1 -0
  76. package/dist/store/teamConfig.d.ts +13 -0
  77. package/dist/store/teamConfig.js +49 -0
  78. package/dist/store/teamConfig.js.map +1 -0
  79. package/dist/tools/indexerTools.d.ts +14 -2
  80. package/dist/tools/indexerTools.js +17 -5
  81. package/dist/tools/indexerTools.js.map +1 -1
  82. package/dist/tools/recordDecision.js +6 -1
  83. package/dist/tools/recordDecision.js.map +1 -1
  84. package/dist/viz/assets/{graph.worker-CC7BeE-8.js → graph.worker-DkH6-lMU.js} +1 -1
  85. package/dist/viz/assets/index-CxqeGuRS.css +1 -0
  86. package/dist/viz/assets/index-DiNZyrXx.js +9 -0
  87. package/dist/viz/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  88. package/dist/viz/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  89. package/dist/viz/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
  90. package/dist/viz/assets/r3f-BZY3QR6_.js +336 -0
  91. package/dist/viz/assets/tanstack-CjXr-L-s.js +62 -0
  92. package/dist/viz/assets/three-Cpu5RUEM.js +4116 -0
  93. package/dist/viz/index.html +5 -4
  94. package/package.json +5 -4
  95. package/dist/viz/assets/index-C_8UkiJ8.js +0 -9
  96. package/dist/viz/assets/r3f-Cku1OhB-.js +0 -277
  97. package/dist/viz/assets/tanstack-DyXcNRWk.js +0 -77
  98. package/dist/viz/assets/three-Z8XaLGmf.js +0 -3839
@@ -0,0 +1,9 @@
1
+ import{b as S,j as d,c as uo,f as Tt,d as fo,e as po,h as ho,R as go,i as yo,k as mo,Q as xo,l as bo,m as vo,n as wo,o as So,p as _o,q as ko,O as Eo}from"./tanstack-CjXr-L-s.js";import{u as Ze,S as No,H as Mo,a as Sn,C as jo,b as Ao,N as To,Y as Co,c as Io}from"./r3f-BZY3QR6_.js";import{a1 as Ro,z as _e,G as me,a0 as Te,a2 as zo,a3 as je,a4 as Lo,a5 as _n,e as Ko,i as Ct,X as Do,$ as Po,a6 as Fo}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 c of r.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).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 Bo(e){return new Worker(""+new URL("graph.worker-DkH6-lMU.js",import.meta.url).href,{type:"module",name:e?.name})}function It(e){const t=new Map;for(const h of e.clusters)t.set(h.key,h);const n=new Map;e.keys.forEach((h,_)=>n.set(h,_));const o=new Map(e.records),s=new Map;for(const h of t.values())h.nodeId&&s.set(h.nodeId,h.key);const r=new Map,c=h=>{const _=r.get(h);if(_)return _;const w=t.get(h);if(!w)return[h];const v=w.parent?[...c(w.parent),h]:[h];return r.set(h,v),v};for(const h of t.keys())c(h);let i=1/0,a=1/0,u=1/0,l=-1/0,f=-1/0,y=-1/0;for(let h=0;h<e.positions.length;h+=3){const _=e.positions[h],w=e.positions[h+1],v=e.positions[h+2];_<i&&(i=_),w<a&&(a=w),v<u&&(u=v),_>l&&(l=_),w>f&&(f=w),v>y&&(y=v)}const g=e.positions.length===0?1:Math.hypot(l-i,f-a,y-u)||1,p=new Map;for(const[h,_]of s){const w=r.get(_);if(w){for(let v=w.length-1;v>=0;v--)if(t.get(w[v])?.kind==="file"){p.set(h,w[v]);break}}}const m=new Map,x=(h,_)=>{let w=m.get(h);w||(w=new Set,m.set(h,w)),w.add(_)};for(const h of e.drawEdges)x(h.from,h.to),x(h.to,h.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:g,fileByNode:p,neighborsByNode:m}}function pe(e,t){const n=new Set,o=s=>{const r=e.byKey.get(s);if(!r)return;const c=t.has(s);if(r.children.length===0||!c){n.add(s);return}for(const i of r.children)o(i)};return o(e.rootKey),n}function fe(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 c=s[r];if(n.has(c))return c}return null}function pt(e,t,n){return fe(e,t,n)}function $o(e,t,n){return fe(e,t,n)}function kn(e,t,n){if(!t)return null;const o=new Set;for(const s of t.nodes){const r=fe(e,s,n);r&&o.add(r)}return o}function En(e,t){return e.fileByNode.get(t)??null}function Oo(e,t,n){if(!t)return null;const o=new Set,s=fe(e,t,n);s&&o.add(s);const r=e.neighborsByNode.get(t);if(r)for(const c of r){const i=fe(e,c,n);i&&o.add(i)}return o}function Nn(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 c=e.byKey.get(r);c&&c.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 Nn(e,s))o.add(r);return o}function Ho(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 Rt={exact:3,name_match:2,ambiguous:1},qo="symbol",zt=2500;function Lt(e,t,n,o){const s=fe(e,t,n);if(!s)return null;if(e.byKey.get(s)?.kind!==qo)return s;const r=En(e,t);return r&&o.has(r)?s:r&&n.has(r)?r:s}function Mn(e,t){const n=pe(e,t.expanded),o=Ho(e,t.filters),s=new Set;for(const m of t.activeNodes){const x=En(e,m);x&&s.add(x)}for(const m of t.expanded)e.byKey.get(m)?.kind==="file"&&s.add(m);const r=new Map,c=new Map;for(const m of o.drawEdges){const x=Lt(e,m.from,n,s),h=Lt(e,m.to,n,s);if(!x||!h||x===h)continue;const _=`${x} ${h}`;let w=r.get(_);w||(w={srcKey:x,dstKey:h,count:0,dominantType:m.type,bestResolution:m.resolution,srcNodes:new Set,dstNodes:new Set,lengthAtten:1},r.set(_,w),c.set(_,new Map)),w.count++,w.srcNodes.add(m.from),w.dstNodes.add(m.to),Rt[m.resolution]>Rt[w.bestResolution]&&(w.bestResolution=m.resolution);const v=c.get(_);v.set(m.type,(v.get(m.type)??0)+1)}for(const[m,x]of r){const h=c.get(m);let _=x.dominantType,w=-1;for(const[v,b]of[...h.entries()].sort((k,M)=>k[0]<M[0]?-1:1))b>w&&(w=b,_=v);x.dominantType=_}const i=.35*e.sceneDiag,a=.9*e.sceneDiag,u=.12,l=e.positions,f=e.indexByKey;for(const m of r.values()){const x=f.get(m.srcKey),h=f.get(m.dstKey);if(x===void 0||h===void 0)continue;const _=l[x*3]-l[h*3],w=l[x*3+1]-l[h*3+1],v=l[x*3+2]-l[h*3+2],b=Math.sqrt(_*_+w*w+v*v);m.lengthAtten=b<=i?1:b>=a?u:1-(1-u)*((b-i)/(a-i))}const y=r.size,g=[...r.values()].sort((m,x)=>m.count!==x.count?x.count-m.count:m.srcKey!==x.srcKey?m.srcKey<x.srcKey?-1:1:m.dstKey<x.dstKey?-1:1),p=g.length>zt?g.slice(0,zt):g;return p.sort((m,x)=>m.srcKey===x.srcKey?m.dstKey<x.dstKey?-1:1:m.srcKey<x.srcKey?-1:1),{bundles:p,visible:n,activeFiles:s,total:y}}const ht=["CALLS","IMPORTS","INHERITS","IMPLEMENTS","INSTANTIATES"],Go=["INHERITS","IMPLEMENTS","INSTANTIATES"];function rt(e){const t=new Set(e);return ht.filter(n=>!t.has(n))}const Ve={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:rt(["CALLS"]),minConfidence:0,emphasis:"none"},types:{id:"types",label:"Type hierarchy",hint:"Only INHERITS / IMPLEMENTS / INSTANTIATES; emphasize Class / Interface / Enum",kinds:[],edgeTypes:rt(Go),minConfidence:0,emphasis:"types"},imports:{id:"imports",label:"Imports",hint:"Only IMPORTS edges",kinds:[],edgeTypes:rt(["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"}},jn=["all","calls","types","imports","tests"],Uo=new Set(["class","interface","enum"]);function Wo(e){const t=Ve[e];return{kinds:new Set(t.kinds),edgeTypes:new Set(t.edgeTypes),minConfidence:t.minConfidence,emphasis:t.emphasis}}const Yo=[/(^|[/\\])test_[^/\\]*\.[^/\\]+$/i,/_tests?\.[^/\\]+$/i,/\.(test|spec)\.[^/\\]+$/i,/[^/\\]+Tests?\.(java|cs|kt|scala)$/i],Vo=new Set(["test","tests","__tests__","spec","specs","testing"]);function Xo(e){if(!e)return!1;for(const n of Yo)if(n.test(e))return!0;const t=e.split(/[/\\]/);for(const n of t)if(Vo.has(n.toLowerCase()))return!0;return!1}function An(e){return e.role==="testing"?!0:Xo(e.filePath)}function Qo(e,t){const n=new Map;for(const c of e.drawEdges){if(c.type!=="CALLS")continue;const i=n.get(c.to);i?i.push(c.from):n.set(c.to,[c.from])}const o=new Set,s=[t];for(;s.length>0;){const c=s.shift(),i=n.get(c);if(i)for(const a of i)a===t||o.has(a)||(o.add(a),s.push(a))}const r=new Set;for(const c of o){const i=e.records.get(c);i&&An(i)&&r.add(c)}return{sourceId:t,impacted:o,coveringTests:r}}const gt=1,Tn=3,Zo=2;function Cn(e){return Math.max(gt,Math.min(Tn,Math.round(e)))}function Kt(e,t,n,o){const s=Cn(n),r=new Map,c=(u,l)=>{const f=r.get(u);f?f.push(l):r.set(u,[l])};for(const u of e)o&&o.size>0&&!o.has(u.type)||(c(u.from,u.to),c(u.to,u.from));const i=new Set([t]);let a=[t];for(let u=0;u<s&&a.length>0;u++){const l=[];for(const f of a){const y=r.get(f);if(y)for(const g of y)i.has(g)||(i.add(g),l.push(g))}a=l}return{sourceId:t,depth:s,nodes:i}}function Jo(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 es(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 ts(e){const t=[];for(const n of e.split(`
2
+ `)){if(n.trim()==="")continue;const o=Jo(n);o&&t.push(o)}return t}function ns(e){const t=[];for(const n of e.split(`
3
+ `)){if(n.trim()==="")continue;const o=es(n);o&&t.push(o)}return t}function Dt(e,t){return{nodes:ts(e),edges:ns(t)}}const os=new Set(["CALLS","IMPORTS","INSTANTIATES","IMPLEMENTS","INHERITS"]);function ss(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 yt(e,t=0){return typeof e=="number"?e:t}const rs=new Set(["Function","Class","Interface","Enum","Variable"]);function Ne(e){return e.labels[0]??""}function it(e){const t=e.lastIndexOf("/");if(t<0)return".";const n=e.slice(0,t);return n===""?".":n}function ct(e){if(e==="."||e==="")return".";const t=e.lastIndexOf("/");return t<0?e:e.slice(t+1)}function is(e){for(const t of e.nodes)if(Ne(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 cs(e){const t=is(e),n=`galaxy:${t}`,o=new Map,s=g=>{const p=o.get(g.key);return p||(o.set(g.key,g),g)};s({key:n,kind:"galaxy",name:t,parent:null,children:[],nodeId:null});const r=g=>`dir:${t}:${g}`,c=g=>`file:${t}:${g}`,i=g=>{const p=r(g),m=o.get(p);if(m)return m;const x=g===".",h=x?null:it(g),_=x?n:i(h).key;return s({key:p,kind:"dir",name:x?t:ct(g),parent:_,children:[],nodeId:null})};for(const g of e.nodes){if(Ne(g)!=="Directory")continue;const p=ee(g.props.path)??".",m=i(p);m.nodeId=g.id}const a=new Map;for(const g of e.nodes){if(Ne(g)!=="File")continue;const p=ee(g.props.path)??ee(g.props.file_path);if(p===null)continue;const m=i(it(p)),x=c(p);s({key:x,kind:"file",name:ct(p),parent:m.key,children:[],nodeId:g.id}),a.set(p,x)}const u=new Map;for(const g of e.nodes)rs.has(Ne(g))&&u.set(g.id,g);const l=new Map;for(const g of e.nodes)if(Ne(g)==="File"){const p=ee(g.props.path)??ee(g.props.file_path);p!==null&&l.set(g.id,c(p))}const f=new Set,y=(g,p)=>{f.has(g.id)||(f.add(g.id),s({key:g.id,kind:"symbol",name:ee(g.props.name)??ee(g.props.qualified_name)??g.id,parent:p,children:[],nodeId:g.id,symbolKind:Ne(g)}))};for(const g of e.edges){if(g.type!=="DEFINES")continue;const p=u.get(g.to);if(!p)continue;const m=l.get(g.from);m&&o.has(m)&&y(p,m)}for(const g of u.values()){if(f.has(g.id))continue;const p=ee(g.props.file_path);if(p===null)continue;let m=a.get(p);if(!m){const x=i(it(p));m=c(p),s({key:m,kind:"file",name:ct(p),parent:x.key,children:[],nodeId:null}),a.set(p,m)}y(g,m)}for(const g of o.values())if(g.parent){const p=o.get(g.parent);p&&p.children.push(g.key)}for(const g of o.values())g.children.sort();return{rootKey:n,byKey:o,repoId:t}}function as(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 ls(e,t,n){var o,s=1;e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function r(){var c,i=o.length,a,u=0,l=0,f=0;for(c=0;c<i;++c)a=o[c],u+=a.x||0,l+=a.y||0,f+=a.z||0;for(u=(u/i-e)*s,l=(l/i-t)*s,f=(f/i-n)*s,c=0;c<i;++c)a=o[c],u&&(a.x-=u),l&&(a.y-=l),f&&(a.z-=f)}return r.initialize=function(c){o=c},r.x=function(c){return arguments.length?(e=+c,r):e},r.y=function(c){return arguments.length?(t=+c,r):t},r.z=function(c){return arguments.length?(n=+c,r):n},r.strength=function(c){return arguments.length?(s=+c,r):s},r}function us(e){const t=+this._x.call(null,e);return In(this.cover(t),t,e)}function In(e,t,n){if(isNaN(t))return e;var o,s=e._root,r={data:n},c=e._x0,i=e._x1,a,u,l,f,y;if(!s)return e._root=r,e;for(;s.length;)if((l=t>=(a=(c+i)/2))?c=a:i=a,o=s,!(s=s[f=+l]))return o[f]=r,e;if(u=+e._x.call(null,s.data),t===u)return r.next=s,o?o[f]=r:e._root=r,e;do o=o?o[f]=new Array(2):e._root=new Array(2),(l=t>=(a=(c+i)/2))?c=a:i=a;while((f=+l)==(y=+(u>=a)));return o[y]=s,o[f]=r,e}function fs(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,c;r<t;++r)isNaN(c=+this._x.call(null,e[r]))||(n[r]=c,c<o&&(o=c),c>s&&(s=c));if(o>s)return this;this.cover(o).cover(s);for(let r=0;r<t;++r)In(this,n[r],e[r]);return this}function ds(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,c;t>e||e>=n;)switch(c=+(e<t),r=new Array(2),r[c]=s,s=r,o*=2,c){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 ps(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function hs(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function xe(e,t,n){this.node=e,this.x0=t,this.x1=n}function gs(e,t){var n,o=this._x0,s,r,c=this._x1,i=[],a=this._root,u,l;for(a&&i.push(new xe(a,o,c)),t==null?t=1/0:(o=e-t,c=e+t);u=i.pop();)if(!(!(a=u.node)||(s=u.x0)>c||(r=u.x1)<o))if(a.length){var f=(s+r)/2;i.push(new xe(a[1],f,r),new xe(a[0],s,f)),(l=+(e>=f))&&(u=i[i.length-1],i[i.length-1]=i[i.length-1-l],i[i.length-1-l]=u)}else{var y=Math.abs(e-+this._x.call(null,a.data));y<t&&(t=y,o=e-y,c=e+y,n=a.data)}return n}function ys(e){if(isNaN(a=+this._x.call(null,e)))return this;var t,n=this._root,o,s,r,c=this._x0,i=this._x1,a,u,l,f,y;if(!n)return this;if(n.length)for(;;){if((l=a>=(u=(c+i)/2))?c=u:i=u,t=n,!(n=n[f=+l]))return this;if(!n.length)break;t[f+1&1]&&(o=t,y=f)}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[f]=r:delete t[f],(n=t[0]||t[1])&&n===(t[1]||t[0])&&!n.length&&(o?o[y]=n:this._root=n),this):(this._root=r,this)}function ms(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function xs(){return this._root}function bs(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function vs(e){var t=[],n,o=this._root,s,r,c;for(o&&t.push(new xe(o,this._x0,this._x1));n=t.pop();)if(!e(o=n.node,r=n.x0,c=n.x1)&&o.length){var i=(r+c)/2;(s=o[1])&&t.push(new xe(s,i,c)),(s=o[0])&&t.push(new xe(s,r,i))}return this}function ws(e){var t=[],n=[],o;for(this._root&&t.push(new xe(this._root,this._x0,this._x1));o=t.pop();){var s=o.node;if(s.length){var r,c=o.x0,i=o.x1,a=(c+i)/2;(r=s[0])&&t.push(new xe(r,c,a)),(r=s[1])&&t.push(new xe(r,a,i))}n.push(o)}for(;o=n.pop();)e(o.node,o.x0,o.x1);return this}function Ss(e){return e[0]}function _s(e){return arguments.length?(this._x=e,this):this._x}function Rn(e,t){var n=new Et(t??Ss,NaN,NaN);return e==null?n:n.addAll(e)}function Et(e,t,n){this._x=e,this._x0=t,this._x1=n,this._root=void 0}function Pt(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var le=Rn.prototype=Et.prototype;le.copy=function(){var e=new Et(this._x,this._x0,this._x1),t=this._root,n,o;if(!t)return e;if(!t.length)return e._root=Pt(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]=Pt(o));return e};le.add=us;le.addAll=fs;le.cover=ds;le.data=ps;le.extent=hs;le.find=gs;le.remove=ys;le.removeAll=ms;le.root=xs;le.size=bs;le.visit=vs;le.visitAfter=ws;le.x=_s;function ks(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return zn(this.cover(t,n),t,n,e)}function zn(e,t,n,o){if(isNaN(t)||isNaN(n))return e;var s,r=e._root,c={data:o},i=e._x0,a=e._y0,u=e._x1,l=e._y1,f,y,g,p,m,x,h,_;if(!r)return e._root=c,e;for(;r.length;)if((m=t>=(f=(i+u)/2))?i=f:u=f,(x=n>=(y=(a+l)/2))?a=y:l=y,s=r,!(r=r[h=x<<1|m]))return s[h]=c,e;if(g=+e._x.call(null,r.data),p=+e._y.call(null,r.data),t===g&&n===p)return c.next=r,s?s[h]=c:e._root=c,e;do s=s?s[h]=new Array(4):e._root=new Array(4),(m=t>=(f=(i+u)/2))?i=f:u=f,(x=n>=(y=(a+l)/2))?a=y:l=y;while((h=x<<1|m)===(_=(p>=y)<<1|g>=f));return s[_]=r,s[h]=c,e}function Es(e){var t,n,o=e.length,s,r,c=new Array(o),i=new Array(o),a=1/0,u=1/0,l=-1/0,f=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,t=e[n]))||isNaN(r=+this._y.call(null,t))||(c[n]=s,i[n]=r,s<a&&(a=s),s>l&&(l=s),r<u&&(u=r),r>f&&(f=r));if(a>l||u>f)return this;for(this.cover(a,u).cover(l,f),n=0;n<o;++n)zn(this,c[n],i[n],e[n]);return this}function Ns(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 c=s-n||1,i=this._root,a,u;n>e||e>=s||o>t||t>=r;)switch(u=(t<o)<<1|e<n,a=new Array(4),a[u]=i,i=a,c*=2,u){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=i)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function Ms(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function js(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 As(e,t,n){var o,s=this._x0,r=this._y0,c,i,a,u,l=this._x1,f=this._y1,y=[],g=this._root,p,m;for(g&&y.push(new ie(g,s,r,l,f)),n==null?n=1/0:(s=e-n,r=t-n,l=e+n,f=t+n,n*=n);p=y.pop();)if(!(!(g=p.node)||(c=p.x0)>l||(i=p.y0)>f||(a=p.x1)<s||(u=p.y1)<r))if(g.length){var x=(c+a)/2,h=(i+u)/2;y.push(new ie(g[3],x,h,a,u),new ie(g[2],c,h,x,u),new ie(g[1],x,i,a,h),new ie(g[0],c,i,x,h)),(m=(t>=h)<<1|e>=x)&&(p=y[y.length-1],y[y.length-1]=y[y.length-1-m],y[y.length-1-m]=p)}else{var _=e-+this._x.call(null,g.data),w=t-+this._y.call(null,g.data),v=_*_+w*w;if(v<n){var b=Math.sqrt(n=v);s=e-b,r=t-b,l=e+b,f=t+b,o=g.data}}return o}function Ts(e){if(isNaN(l=+this._x.call(null,e))||isNaN(f=+this._y.call(null,e)))return this;var t,n=this._root,o,s,r,c=this._x0,i=this._y0,a=this._x1,u=this._y1,l,f,y,g,p,m,x,h;if(!n)return this;if(n.length)for(;;){if((p=l>=(y=(c+a)/2))?c=y:a=y,(m=f>=(g=(i+u)/2))?i=g:u=g,t=n,!(n=n[x=m<<1|p]))return this;if(!n.length)break;(t[x+1&3]||t[x+2&3]||t[x+3&3])&&(o=t,h=x)}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[x]=r:delete t[x],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(o?o[h]=n:this._root=n),this):(this._root=r,this)}function Cs(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Is(){return this._root}function Rs(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function zs(e){var t=[],n,o=this._root,s,r,c,i,a;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,c=n.y0,i=n.x1,a=n.y1)&&o.length){var u=(r+i)/2,l=(c+a)/2;(s=o[3])&&t.push(new ie(s,u,l,i,a)),(s=o[2])&&t.push(new ie(s,r,l,u,a)),(s=o[1])&&t.push(new ie(s,u,c,i,l)),(s=o[0])&&t.push(new ie(s,r,c,u,l))}return this}function Ls(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,c=o.x0,i=o.y0,a=o.x1,u=o.y1,l=(c+a)/2,f=(i+u)/2;(r=s[0])&&t.push(new ie(r,c,i,l,f)),(r=s[1])&&t.push(new ie(r,l,i,a,f)),(r=s[2])&&t.push(new ie(r,c,f,l,u)),(r=s[3])&&t.push(new ie(r,l,f,a,u))}n.push(o)}for(;o=n.pop();)e(o.node,o.x0,o.y0,o.x1,o.y1);return this}function Ks(e){return e[0]}function Ds(e){return arguments.length?(this._x=e,this):this._x}function Ps(e){return e[1]}function Fs(e){return arguments.length?(this._y=e,this):this._y}function Ln(e,t,n){var o=new Nt(t??Ks,n??Ps,NaN,NaN,NaN,NaN);return e==null?o:o.addAll(e)}function Nt(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 Ft(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var ce=Ln.prototype=Nt.prototype;ce.copy=function(){var e=new Nt(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=Ft(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]=Ft(o));return e};ce.add=ks;ce.addAll=Es;ce.cover=Ns;ce.data=Ms;ce.extent=js;ce.find=As;ce.remove=Ts;ce.removeAll=Cs;ce.root=Is;ce.size=Rs;ce.visit=zs;ce.visitAfter=Ls;ce.x=Ds;ce.y=Fs;function Bs(e){const t=+this._x.call(null,e),n=+this._y.call(null,e),o=+this._z.call(null,e);return Kn(this.cover(t,n,o),t,n,o,e)}function Kn(e,t,n,o,s){if(isNaN(t)||isNaN(n)||isNaN(o))return e;var r,c=e._root,i={data:s},a=e._x0,u=e._y0,l=e._z0,f=e._x1,y=e._y1,g=e._z1,p,m,x,h,_,w,v,b,k,M,j;if(!c)return e._root=i,e;for(;c.length;)if((v=t>=(p=(a+f)/2))?a=p:f=p,(b=n>=(m=(u+y)/2))?u=m:y=m,(k=o>=(x=(l+g)/2))?l=x:g=x,r=c,!(c=c[M=k<<2|b<<1|v]))return r[M]=i,e;if(h=+e._x.call(null,c.data),_=+e._y.call(null,c.data),w=+e._z.call(null,c.data),t===h&&n===_&&o===w)return i.next=c,r?r[M]=i:e._root=i,e;do r=r?r[M]=new Array(8):e._root=new Array(8),(v=t>=(p=(a+f)/2))?a=p:f=p,(b=n>=(m=(u+y)/2))?u=m:y=m,(k=o>=(x=(l+g)/2))?l=x:g=x;while((M=k<<2|b<<1|v)===(j=(w>=x)<<2|(_>=m)<<1|h>=p));return r[j]=c,r[M]=i,e}function $s(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,c=1/0,i=1/0,a=-1/0,u=-1/0,l=-1/0;for(let f=0,y,g,p,m;f<t;++f)isNaN(g=+this._x.call(null,y=e[f]))||isNaN(p=+this._y.call(null,y))||isNaN(m=+this._z.call(null,y))||(n[f]=g,o[f]=p,s[f]=m,g<r&&(r=g),g>a&&(a=g),p<c&&(c=p),p>u&&(u=p),m<i&&(i=m),m>l&&(l=m));if(r>a||c>u||i>l)return this;this.cover(r,c,i).cover(a,u,l);for(let f=0;f<t;++f)Kn(this,n[f],o[f],s[f],e[f]);return this}function Os(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,c=this._x1,i=this._y1,a=this._z1;if(isNaN(o))c=(o=Math.floor(e))+1,i=(s=Math.floor(t))+1,a=(r=Math.floor(n))+1;else{for(var u=c-o||1,l=this._root,f,y;o>e||e>=c||s>t||t>=i||r>n||n>=a;)switch(y=(n<r)<<2|(t<s)<<1|e<o,f=new Array(8),f[y]=l,l=f,u*=2,y){case 0:c=o+u,i=s+u,a=r+u;break;case 1:o=c-u,i=s+u,a=r+u;break;case 2:c=o+u,s=i-u,a=r+u;break;case 3:o=c-u,s=i-u,a=r+u;break;case 4:c=o+u,i=s+u,r=a-u;break;case 5:o=c-u,i=s+u,r=a-u;break;case 6:c=o+u,s=i-u,r=a-u;break;case 7:o=c-u,s=i-u,r=a-u;break}this._root&&this._root.length&&(this._root=l)}return this._x0=o,this._y0=s,this._z0=r,this._x1=c,this._y1=i,this._z1=a,this}function Hs(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function qs(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 q(e,t,n,o,s,r,c){this.node=e,this.x0=t,this.y0=n,this.z0=o,this.x1=s,this.y1=r,this.z1=c}function Gs(e,t,n,o){var s,r=this._x0,c=this._y0,i=this._z0,a,u,l,f,y,g,p=this._x1,m=this._y1,x=this._z1,h=[],_=this._root,w,v;for(_&&h.push(new q(_,r,c,i,p,m,x)),o==null?o=1/0:(r=e-o,c=t-o,i=n-o,p=e+o,m=t+o,x=n+o,o*=o);w=h.pop();)if(!(!(_=w.node)||(a=w.x0)>p||(u=w.y0)>m||(l=w.z0)>x||(f=w.x1)<r||(y=w.y1)<c||(g=w.z1)<i))if(_.length){var b=(a+f)/2,k=(u+y)/2,M=(l+g)/2;h.push(new q(_[7],b,k,M,f,y,g),new q(_[6],a,k,M,b,y,g),new q(_[5],b,u,M,f,k,g),new q(_[4],a,u,M,b,k,g),new q(_[3],b,k,l,f,y,M),new q(_[2],a,k,l,b,y,M),new q(_[1],b,u,l,f,k,M),new q(_[0],a,u,l,b,k,M)),(v=(n>=M)<<2|(t>=k)<<1|e>=b)&&(w=h[h.length-1],h[h.length-1]=h[h.length-1-v],h[h.length-1-v]=w)}else{var j=e-+this._x.call(null,_.data),P=t-+this._y.call(null,_.data),L=n-+this._z.call(null,_.data),F=j*j+P*P+L*L;if(F<o){var z=Math.sqrt(o=F);r=e-z,c=t-z,i=n-z,p=e+z,m=t+z,x=n+z,s=_.data}}return s}const Us=(e,t,n,o,s,r)=>Math.sqrt((e-o)**2+(t-s)**2+(n-r)**2);function Ws(e,t,n,o){const s=[],r=e-o,c=t-o,i=n-o,a=e+o,u=t+o,l=n+o;return this.visit((f,y,g,p,m,x,h)=>{if(!f.length)do{const _=f.data;Us(e,t,n,this._x(_),this._y(_),this._z(_))<=o&&s.push(_)}while(f=f.next);return y>a||g>u||p>l||m<r||x<c||h<i}),s}function Ys(e){if(isNaN(y=+this._x.call(null,e))||isNaN(g=+this._y.call(null,e))||isNaN(p=+this._z.call(null,e)))return this;var t,n=this._root,o,s,r,c=this._x0,i=this._y0,a=this._z0,u=this._x1,l=this._y1,f=this._z1,y,g,p,m,x,h,_,w,v,b,k;if(!n)return this;if(n.length)for(;;){if((_=y>=(m=(c+u)/2))?c=m:u=m,(w=g>=(x=(i+l)/2))?i=x:l=x,(v=p>=(h=(a+f)/2))?a=h:f=h,t=n,!(n=n[b=v<<2|w<<1|_]))return this;if(!n.length)break;(t[b+1&7]||t[b+2&7]||t[b+3&7]||t[b+4&7]||t[b+5&7]||t[b+6&7]||t[b+7&7])&&(o=t,k=b)}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[b]=r:delete t[b],(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[k]=n:this._root=n),this):(this._root=r,this)}function Vs(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Xs(){return this._root}function Qs(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Zs(e){var t=[],n,o=this._root,s,r,c,i,a,u,l;for(o&&t.push(new q(o,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=t.pop();)if(!e(o=n.node,r=n.x0,c=n.y0,i=n.z0,a=n.x1,u=n.y1,l=n.z1)&&o.length){var f=(r+a)/2,y=(c+u)/2,g=(i+l)/2;(s=o[7])&&t.push(new q(s,f,y,g,a,u,l)),(s=o[6])&&t.push(new q(s,r,y,g,f,u,l)),(s=o[5])&&t.push(new q(s,f,c,g,a,y,l)),(s=o[4])&&t.push(new q(s,r,c,g,f,y,l)),(s=o[3])&&t.push(new q(s,f,y,i,a,u,g)),(s=o[2])&&t.push(new q(s,r,y,i,f,u,g)),(s=o[1])&&t.push(new q(s,f,c,i,a,y,g)),(s=o[0])&&t.push(new q(s,r,c,i,f,y,g))}return this}function Js(e){var t=[],n=[],o;for(this._root&&t.push(new q(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,c=o.x0,i=o.y0,a=o.z0,u=o.x1,l=o.y1,f=o.z1,y=(c+u)/2,g=(i+l)/2,p=(a+f)/2;(r=s[0])&&t.push(new q(r,c,i,a,y,g,p)),(r=s[1])&&t.push(new q(r,y,i,a,u,g,p)),(r=s[2])&&t.push(new q(r,c,g,a,y,l,p)),(r=s[3])&&t.push(new q(r,y,g,a,u,l,p)),(r=s[4])&&t.push(new q(r,c,i,p,y,g,f)),(r=s[5])&&t.push(new q(r,y,i,p,u,g,f)),(r=s[6])&&t.push(new q(r,c,g,p,y,l,f)),(r=s[7])&&t.push(new q(r,y,g,p,u,l,f))}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 er(e){return e[0]}function tr(e){return arguments.length?(this._x=e,this):this._x}function nr(e){return e[1]}function or(e){return arguments.length?(this._y=e,this):this._y}function sr(e){return e[2]}function rr(e){return arguments.length?(this._z=e,this):this._z}function Dn(e,t,n,o){var s=new Mt(t??er,n??nr,o??sr,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?s:s.addAll(e)}function Mt(e,t,n,o,s,r,c,i,a){this._x=e,this._y=t,this._z=n,this._x0=o,this._y0=s,this._z0=r,this._x1=c,this._y1=i,this._z1=a,this._root=void 0}function Bt(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var oe=Dn.prototype=Mt.prototype;oe.copy=function(){var e=new Mt(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=Bt(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]=Bt(o));return e};oe.add=Bs;oe.addAll=$s;oe.cover=Os;oe.data=Hs;oe.extent=qs;oe.find=Gs;oe.findAllWithinRadius=Ws;oe.remove=Ys;oe.removeAll=Vs;oe.root=Xs;oe.size=Qs;oe.visit=Zs;oe.visitAfter=Js;oe.x=tr;oe.y=or;oe.z=rr;function $e(e){return function(){return e}}function ye(e){return(e()-.5)*1e-6}function ir(e){return e.index}function $t(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function cr(e){var t=ir,n=y,o,s=$e(30),r,c,i,a,u,l,f=1;e==null&&(e=[]);function y(h){return 1/Math.min(a[h.source.index],a[h.target.index])}function g(h){for(var _=0,w=e.length;_<f;++_)for(var v=0,b,k,M,j=0,P=0,L=0,F,z;v<w;++v)b=e[v],k=b.source,M=b.target,j=M.x+M.vx-k.x-k.vx||ye(l),i>1&&(P=M.y+M.vy-k.y-k.vy||ye(l)),i>2&&(L=M.z+M.vz-k.z-k.vz||ye(l)),F=Math.sqrt(j*j+P*P+L*L),F=(F-r[v])/F*h*o[v],j*=F,P*=F,L*=F,M.vx-=j*(z=u[v]),i>1&&(M.vy-=P*z),i>2&&(M.vz-=L*z),k.vx+=j*(z=1-z),i>1&&(k.vy+=P*z),i>2&&(k.vz+=L*z)}function p(){if(c){var h,_=c.length,w=e.length,v=new Map(c.map((k,M)=>[t(k,M,c),k])),b;for(h=0,a=new Array(_);h<w;++h)b=e[h],b.index=h,typeof b.source!="object"&&(b.source=$t(v,b.source)),typeof b.target!="object"&&(b.target=$t(v,b.target)),a[b.source.index]=(a[b.source.index]||0)+1,a[b.target.index]=(a[b.target.index]||0)+1;for(h=0,u=new Array(w);h<w;++h)b=e[h],u[h]=a[b.source.index]/(a[b.source.index]+a[b.target.index]);o=new Array(w),m(),r=new Array(w),x()}}function m(){if(c)for(var h=0,_=e.length;h<_;++h)o[h]=+n(e[h],h,e)}function x(){if(c)for(var h=0,_=e.length;h<_;++h)r[h]=+s(e[h],h,e)}return g.initialize=function(h,..._){c=h,l=_.find(w=>typeof w=="function")||Math.random,i=_.find(w=>[1,2,3].includes(w))||2,p()},g.links=function(h){return arguments.length?(e=h,p(),g):e},g.id=function(h){return arguments.length?(t=h,g):t},g.iterations=function(h){return arguments.length?(f=+h,g):f},g.strength=function(h){return arguments.length?(n=typeof h=="function"?h:$e(+h),m(),g):n},g.distance=function(h){return arguments.length?(s=typeof h=="function"?h:$e(+h),x(),g):s},g}var ar={value:()=>{}};function Pn(){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 Ye(n)}function Ye(e){this._=e}function lr(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}})}Ye.prototype=Pn.prototype={constructor:Ye,on:function(e,t){var n=this._,o=lr(e+"",n),s,r=-1,c=o.length;if(arguments.length<2){for(;++r<c;)if((s=(e=o[r]).type)&&(s=ur(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<c;)if(s=(e=o[r]).type)n[s]=Ot(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Ot(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 Ye(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 ur(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function Ot(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=ar,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ce=0,Fe=0,Le=0,Fn=1e3,Xe,Be,Qe=0,ke=0,Je=0,Oe=typeof performance=="object"&&performance.now?performance:Date,Bn=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function $n(){return ke||(Bn(fr),ke=Oe.now()+Je)}function fr(){ke=0}function mt(){this._call=this._time=this._next=null}mt.prototype=On.prototype={constructor:mt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?$n():+n)+(t==null?0:+t),!this._next&&Be!==this&&(Be?Be._next=this:Xe=this,Be=this),this._call=e,this._time=n,xt()},stop:function(){this._call&&(this._call=null,this._time=1/0,xt())}};function On(e,t,n){var o=new mt;return o.restart(e,t,n),o}function dr(){$n(),++Ce;for(var e=Xe,t;e;)(t=ke-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ce}function Ht(){ke=(Qe=Oe.now())+Je,Ce=Fe=0;try{dr()}finally{Ce=0,hr(),ke=0}}function pr(){var e=Oe.now(),t=e-Qe;t>Fn&&(Je-=t,Qe=e)}function hr(){for(var e,t=Xe,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:Xe=n);Be=e,xt(o)}function xt(e){if(!Ce){Fe&&(Fe=clearTimeout(Fe));var t=e-ke;t>24?(e<1/0&&(Fe=setTimeout(Ht,e-Oe.now()-Je)),Le&&(Le=clearInterval(Le))):(Le||(Qe=Oe.now(),Le=setInterval(pr,Fn)),Ce=1,Bn(Ht))}}const gr=1664525,yr=1013904223,qt=4294967296;function mr(){let e=1;return()=>(e=(gr*e+yr)%qt)/qt}var Gt=3;function at(e){return e.x}function Ut(e){return e.y}function xr(e){return e.z}var br=10,vr=Math.PI*(3-Math.sqrt(5)),wr=Math.PI*20/(9+Math.sqrt(221));function Sr(e,t){t=t||2;var n=Math.min(Gt,Math.max(1,Math.round(t))),o,s=1,r=.001,c=1-Math.pow(r,1/300),i=0,a=.6,u=new Map,l=On(g),f=Pn("tick","end"),y=mr();e==null&&(e=[]);function g(){p(),f.call("tick",o),s<r&&(l.stop(),f.call("end",o))}function p(h){var _,w=e.length,v;h===void 0&&(h=1);for(var b=0;b<h;++b)for(s+=(i-s)*c,u.forEach(function(k){k(s)}),_=0;_<w;++_)v=e[_],v.fx==null?v.x+=v.vx*=a:(v.x=v.fx,v.vx=0),n>1&&(v.fy==null?v.y+=v.vy*=a:(v.y=v.fy,v.vy=0)),n>2&&(v.fz==null?v.z+=v.vz*=a:(v.z=v.fz,v.vz=0));return o}function m(){for(var h=0,_=e.length,w;h<_;++h){if(w=e[h],w.index=h,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),w.fz!=null&&(w.z=w.fz),isNaN(w.x)||n>1&&isNaN(w.y)||n>2&&isNaN(w.z)){var v=br*(n>2?Math.cbrt(.5+h):n>1?Math.sqrt(.5+h):h),b=h*vr,k=h*wr;n===1?w.x=v:n===2?(w.x=v*Math.cos(b),w.y=v*Math.sin(b)):(w.x=v*Math.sin(b)*Math.cos(k),w.y=v*Math.cos(b),w.z=v*Math.sin(b)*Math.sin(k))}(isNaN(w.vx)||n>1&&isNaN(w.vy)||n>2&&isNaN(w.vz))&&(w.vx=0,n>1&&(w.vy=0),n>2&&(w.vz=0))}}function x(h){return h.initialize&&h.initialize(e,y,n),h}return m(),o={tick:p,restart:function(){return l.restart(g),o},stop:function(){return l.stop(),o},numDimensions:function(h){return arguments.length?(n=Math.min(Gt,Math.max(1,Math.round(h))),u.forEach(x),o):n},nodes:function(h){return arguments.length?(e=h,m(),u.forEach(x),o):e},alpha:function(h){return arguments.length?(s=+h,o):s},alphaMin:function(h){return arguments.length?(r=+h,o):r},alphaDecay:function(h){return arguments.length?(c=+h,o):+c},alphaTarget:function(h){return arguments.length?(i=+h,o):i},velocityDecay:function(h){return arguments.length?(a=1-h,o):1-a},randomSource:function(h){return arguments.length?(y=h,u.forEach(x),o):y},force:function(h,_){return arguments.length>1?(_==null?u.delete(h):u.set(h,x(_)),o):u.get(h)},find:function(){var h=Array.prototype.slice.call(arguments),_=h.shift()||0,w=(n>1?h.shift():null)||0,v=(n>2?h.shift():null)||0,b=h.shift()||1/0,k=0,M=e.length,j,P,L,F,z,J;for(b*=b,k=0;k<M;++k)z=e[k],j=_-z.x,P=w-(z.y||0),L=v-(z.z||0),F=j*j+P*P+L*L,F<b&&(J=z,b=F);return J},on:function(h,_){return arguments.length>1?(f.on(h,_),o):f.on(h)}}}function _r(){var e,t,n,o,s,r=$e(-30),c,i=1,a=1/0,u=.81;function l(p){var m,x=e.length,h=(t===1?Rn(e,at):t===2?Ln(e,at,Ut):t===3?Dn(e,at,Ut,xr):null).visitAfter(y);for(s=p,m=0;m<x;++m)n=e[m],h.visit(g)}function f(){if(e){var p,m=e.length,x;for(c=new Array(m),p=0;p<m;++p)x=e[p],c[x.index]=+r(x,p,e)}}function y(p){var m=0,x,h,_=0,w,v,b,k,M=p.length;if(M){for(w=v=b=k=0;k<M;++k)(x=p[k])&&(h=Math.abs(x.value))&&(m+=x.value,_+=h,w+=h*(x.x||0),v+=h*(x.y||0),b+=h*(x.z||0));m*=Math.sqrt(4/M),p.x=w/_,t>1&&(p.y=v/_),t>2&&(p.z=b/_)}else{x=p,x.x=x.data.x,t>1&&(x.y=x.data.y),t>2&&(x.z=x.data.z);do m+=c[x.data.index];while(x=x.next)}p.value=m}function g(p,m,x,h,_){if(!p.value)return!0;var w=[x,h,_][t-1],v=p.x-n.x,b=t>1?p.y-n.y:0,k=t>2?p.z-n.z:0,M=w-m,j=v*v+b*b+k*k;if(M*M/u<j)return j<a&&(v===0&&(v=ye(o),j+=v*v),t>1&&b===0&&(b=ye(o),j+=b*b),t>2&&k===0&&(k=ye(o),j+=k*k),j<i&&(j=Math.sqrt(i*j)),n.vx+=v*p.value*s/j,t>1&&(n.vy+=b*p.value*s/j),t>2&&(n.vz+=k*p.value*s/j)),!0;if(p.length||j>=a)return;(p.data!==n||p.next)&&(v===0&&(v=ye(o),j+=v*v),t>1&&b===0&&(b=ye(o),j+=b*b),t>2&&k===0&&(k=ye(o),j+=k*k),j<i&&(j=Math.sqrt(i*j)));do p.data!==n&&(M=c[p.data.index]*s/j,n.vx+=v*M,t>1&&(n.vy+=b*M),t>2&&(n.vz+=k*M));while(p=p.next)}return l.initialize=function(p,...m){e=p,o=m.find(x=>typeof x=="function")||Math.random,t=m.find(x=>[1,2,3].includes(x))||2,f()},l.strength=function(p){return arguments.length?(r=typeof p=="function"?p:$e(+p),f(),l):r},l.distanceMin=function(p){return arguments.length?(i=p*p,l):Math.sqrt(i)},l.distanceMax=function(p){return arguments.length?(a=p*p,l):Math.sqrt(a)},l.theta=function(p){return arguments.length?(u=p*p,l):Math.sqrt(u)},l}function Hn(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 qn(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 kr(e,t=42){const n=qn(Hn(e)),o=n(),s=n(),r=2*Math.PI*o,c=Math.acos(2*s-1),i=t*Math.cbrt(n()),a=i*Math.sin(c)*Math.cos(r),u=i*Math.sin(c)*Math.sin(r),l=i*Math.cos(c);return[a,u,l]}function Gn(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 Er=1592594996,Nr=1;function Mr(e){const t=[...e].sort();return Gn([`v${Nr}`,`n${t.length}`,...t])}function jr(e){return e<=2e3?200:e<=5e3?150:e<=1e4?100:70}function Ar(e,t){const n=as(e),o=n.map(f=>f.key),s=new Map;if(o.forEach((f,y)=>s.set(f,y)),t&&t.length===o.length*3)return{keys:o,positions:t.slice(),indexByKey:s};const r=n.map(f=>{const[y,g,p]=kr(f.key);return{key:f.key,x:y,y:g,z:p}}),c=n.filter(f=>f.parent!==null).map(f=>({source:f.parent,target:f.key})),i=qn(Hn("randomSource")^Er),a=Sr(r,3).force("charge",_r().strength(-7)).force("link",cr(c).id(f=>f.key).distance(5).strength(.85)).force("center",ls(0,0,0)).stop(),u=a;typeof u.randomSource=="function"&&u.randomSource(i),a.tick(jr(r.length));const l=new Float32Array(r.length*3);for(let f=0;f<r.length;f++){const y=r[f];l[f*3]=y.x??0,l[f*3+1]=y.y??0,l[f*3+2]=y.z??0}return{keys:o,positions:l,indexByKey:s}}function Tr(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:yt(e.props.start_line),endLine:yt(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 Cr(e,t){const n=cs(e),o=Ar(n,t?.cachedPositions),s=[],r=new Map,c=l=>r.set(l,(r.get(l)??0)+1);for(const l of e.edges){if(!os.has(l.type))continue;const f=l.from.split(":"),y=l.to.split(":"),g=f[0]==="rs1"&&y[0]==="rs1"&&f[1]!==y[1];s.push({from:l.from,to:l.to,type:l.type,resolution:ss(l.props),confidence:yt(l.props.confidence,1),crossRepo:g}),c(l.from),c(l.to)}const i=new Map;for(const l of e.nodes)i.set(l.id,Tr(l,r.get(l.id)??0));const a=[];for(const l of e.nodes)a.push(l.id,ee(l.props.content_hash)??"");const u=Gn(a);return{tree:n,layout:o,drawEdges:s,records:i,degree:r,fingerprint:u}}const Ir="reposkein-layout-cache",Ie="positions",Rr=1;function zr(){try{if(typeof indexedDB<"u")return indexedDB}catch{}return null}function Un(){const e=zr();return e?new Promise(t=>{let n;try{n=e.open(Ir,Rr)}catch{t(null);return}n.onupgradeneeded=()=>{const o=n.result;o.objectStoreNames.contains(Ie)||o.createObjectStore(Ie)},n.onsuccess=()=>t(n.result),n.onerror=()=>t(null),n.onblocked=()=>t(null)}):Promise.resolve(null)}async function Lr(e){const t=await Un();return t?new Promise(n=>{let o=!1;const s=r=>{o||(o=!0,t.close(),n(r))};try{const r=t.transaction(Ie,"readonly"),c=r.objectStore(Ie).get(e);c.onsuccess=()=>{const i=c.result;i&&i.byteLength>0&&i.byteLength%12===0?s(new Float32Array(i)):s(null)},c.onerror=()=>s(null),r.onerror=()=>s(null),r.onabort=()=>s(null)}catch{s(null)}}):null}async function Kr(e,t){const n=await Un();if(n)return new Promise(o=>{let s=!1;const r=()=>{s||(s=!0,n.close(),o())};try{const c=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),i=n.transaction(Ie,"readwrite");i.objectStore(Ie).put(c,e),i.oncomplete=r,i.onerror=r,i.onabort=r}catch{r()}})}function et(){return typeof window>"u"?null:window.__REPOSKEIN_GRAPH__??null}function tt(){return et()!==null}async function Dr(e){const t=Dt(e.nodesText,e.edgesText);for(const r of e.federatedText??[]){const c=Dt(r.nodesText,r.edgesText);t.nodes.push(...c.nodes),t.edges.push(...c.edges)}const n=Mr(t.nodes.map(r=>r.id)),o=await Lr(n),s=Cr(t,{cachedPositions:o??void 0});return o||Kr(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 Pr(){return et()?.cochange??{}}function Fr(e,t,n){const o=et()?.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 Br(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 Wn(e){return S.useSyncExternalStore(e.subscribe,e.get,e.get)}function Yn(e){return S.useCallback(t=>e.set(t),[e])}function Wt(e,t){const n=S.useRef(null);return n.current===null&&(n.current=Br(e,t)),n.current}function Yt(e,t){return(e.ancestors.get(t)?.length??1)-1}function Vt(e){return e.size===0?new Set(ht):new Set(ht.filter(t=>!e.has(t)))}function lt(e,t={}){return{...e,expanded:new Set([e.model.rootKey]),selected:null,focusTarget:null,impact:null,focus:null,fitNonce:e.fitNonce+1,...t}}function Xt(){return{lens:"all",emphasis:"none",audit:"off",filters:{kinds:new Set,edgeTypes:new Set,minConfidence:0}}}function $r(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"collapseLevel":{if(!e.model||e.expanded.size===0)return e;let n=null,o=-1;for(const r of e.expanded){if(r===e.model.rootKey)continue;const c=Yt(e.model,r);c>o&&(o=c,n=r)}if(n===null)return e.selected===null?e:{...e,selected:null,fitNonce:e.fitNonce+1};const s=new Set(e.expanded);return s.delete(n),{...e,expanded:s,selected:null,fitNonce:e.fitNonce+1}}case"select":return{...e,selected:t.id,fitNonce:e.fitNonce+1,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,c=Yt(n,r);for(const i of[...o]){if(i===n.rootKey)continue;const a=n.ancestors.get(i);a&&a.indexOf(r)!==-1&&a.length-1>c&&o.delete(i)}}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"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=Wo(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=Qo(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=Kt(e.model.drawEdges,e.selected,e.focusDepth,Vt(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=Cn(t.depth);if(n===e.focusDepth)return e;if(e.focus&&e.model&&e.selected){const o=Kt(e.model.drawEdges,e.selected,n,Vt(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?lt(e,{tour:!0,emphasis:"none"}):e;case"exitTour":return{...e,...Xt(),tour:!1,focus:null,selected:null};case"resetView":return e.model?lt(e,{...Xt(),coupling:!1}):e;case"resetExpansion":return e.model?lt(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"toggleMinimap":return{...e,showMinimap:!e.showMinimap};case"toggleLegend":return{...e,showLegend:!e.showLegend};case"toggleLabels":return{...e,showLabels:!e.showLabels}}}const Vn=S.createContext(null),Xn=S.createContext(null),Qn=S.createContext(null);function Or(){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,lens:"all",emphasis:"none",audit:"off",impact:null,coupling:!1,cochange:null,focus:null,focusDepth:Zo,tour:!1,bundleBeta:.85,idleDrift:!1,showMinimap:!0,showLegend:!0,showLabels:!0}}const Hr=(e,t)=>e.drawn===t.drawn&&e.total===t.total;function qr({children:e}){const[t,n]=S.useReducer($r,void 0,Or),o=Wt(null),s=Wt({drawn:0,total:0},Hr),r=S.useMemo(()=>({hovered:o,edgeStats:s}),[o,s]);S.useEffect(()=>{const i=et();if(i){let u=!1;return Promise.resolve().then(async()=>{if(!u)try{n({t:"progress",phase:"parsing baked graph"});const l=await Dr(i);u||n({t:"ready",model:It(l)})}catch(l){u||n({t:"error",message:l instanceof Error?l.message:String(l)})}}),()=>{u=!0}}const a=new Bo;return a.onmessage=u=>{const l=u.data;l.type==="progress"?n({t:"progress",phase:l.phase}):l.type==="error"?n({t:"error",message:l.message}):l.type==="result"&&n({t:"ready",model:It(l)})},a.onerror=u=>n({t:"error",message:u.message}),a.postMessage({cmd:"load"}),()=>a.terminate()},[]);const c=S.useMemo(()=>({toggleExpand:i=>n({t:"toggleExpand",key:i}),collapseLevel:()=>n({t:"collapseLevel"}),select:i=>n({t:"select",id:i}),requestFit:()=>n({t:"requestFit"}),revealAndSelect:(i,a)=>n({t:"revealAndSelect",id:i,fly:a?.fly,collapseDeeper:a?.collapseDeeper}),revealWithoutRefit:i=>n({t:"revealWithoutRefit",keys:i}),setKindFilter:(i,a)=>n({t:"setKindFilter",kind:i,hidden:a}),setEdgeTypeFilter:(i,a)=>n({t:"setEdgeTypeFilter",type:i,hidden:a}),setMinConfidence:i=>n({t:"setMinConfidence",value:i}),clearFilters:()=>n({t:"clearFilters"}),setFocusTarget:i=>n({t:"setFocusTarget",id:i}),setLens:i=>n({t:"setLens",lens:i}),setAudit:i=>n({t:"setAudit",mode:i}),toggleImpact:()=>n({t:"toggleImpact"}),toggleFocus:()=>n({t:"toggleFocus"}),setFocusDepth:i=>n({t:"setFocusDepth",depth:i}),toggleCoupling:()=>n({t:"toggleCoupling"}),setCochange:i=>n({t:"setCochange",map:i}),startTour:()=>n({t:"startTour"}),exitTour:()=>n({t:"exitTour"}),resetView:()=>n({t:"resetView"}),resetExpansion:()=>n({t:"resetExpansion"}),setBundleBeta:i=>n({t:"setBundleBeta",value:i}),setIdleDrift:i=>n({t:"setIdleDrift",on:i}),toggleMinimap:()=>n({t:"toggleMinimap"}),toggleLegend:()=>n({t:"toggleLegend"}),toggleLabels:()=>n({t:"toggleLabels"}),hover:i=>o.set(i),setEdgeStats:i=>s.set(i)}),[o,s]);return d.jsx(Qn.Provider,{value:r,children:d.jsx(Xn.Provider,{value:c,children:d.jsx(Vn.Provider,{value:t,children:e})})})}function Re(){const e=S.useContext(Vn);if(!e)throw new Error("useStoreState must be used within StoreProvider");return e}function Zn(){const e=S.useContext(Xn);if(!e)throw new Error("useActions must be used within StoreProvider");return e}function nt(){const e=S.useContext(Qn);if(!e)throw new Error("channel hooks must be used within StoreProvider");return e}function ot(){return Wn(nt().hovered)}function Gr(){return Yn(nt().hovered)}function Ur(){return Wn(nt().edgeStats)}function Wr(){return Yn(nt().edgeStats)}function te(){const e=Re(),t=Zn();return S.useMemo(()=>({...e,...t}),[e,t])}const Z=e=>{const t=parseInt(e.replace("#",""),16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]},B={amber:"#F2B84B",teal:"#2DD4BF",cream:"#EAE7DC",navy:"#070A12"},ze={amber:Z(B.amber),teal:Z(B.teal),cream:Z(B.cream),navy:Z(B.navy)};function bt(e,t){if(e==="galaxy")return Z("#ffffff");if(e==="dir")return Z("#9aa7c7");if(e==="file")return Z("#6ea8ff");switch(t){case"Function":return Z("#ffe08a");case"Class":return Z("#5fe0e0");case"Interface":return Z("#b98aff");case"Enum":return Z("#7ce08a");case"Variable":return Z("#9aa0a8");default:return Z("#cfd6e4")}}const Yr={rust:"#ff7a45",python:"#4b8bff",typescript:"#3aa0ff",javascript:"#f4d03f",go:"#39c5cf",java:"#e76f51",csharp:"#9b6dff"},Vr="#8a93a8",Xr={rust:"Rust",python:"Python",typescript:"TypeScript",javascript:"JavaScript",go:"Go",java:"Java",csharp:"C#"};function Jn(e){return Yr[e]??Vr}function Qr(e){return Z(Jn(e))}const Zr={CALLS:Z("#ffd166"),IMPORTS:Z("#6ea8ff"),INSTANTIATES:Z("#ef8aff"),IMPLEMENTS:Z("#5fe0e0"),INHERITS:Z("#7ce08a")};function eo(e){return Zr[e]??Z("#8892a6")}const to=.15;function Jr(e){switch(e){case"exact":return .75;case"name_match":return .42;case"ambiguous":return to}}function ei(e,t){const o=Jr(e)*(1+.18*Math.log(1+t));return Math.min(1,Math.max(to,o))}const Qt=220,ti=.04;function ni(e){return e<=Qt?1:Math.max(ti,Qt/e)}const Zt=.1;function oi(e,t,n){const o=Math.max(e,t,n);if(o>0&&o<Zt){const s=Zt/o;return[e*s,t*s,n*s]}return[e,t,n]}const si=1,ri=12;function ii(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(ri,Math.max(si,o))}const ci=[{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"}],ai=[{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"}],Jt=500;function en(e){const t=Math.min(1,Math.max(0,e));return 1-Math.pow(1-t,3)}function li(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 tn=new Map;function ui(e){return`${e.size}|${e.stops.map(t=>`${t.offset}:${t.alpha}`).join(",")}`}function jt(e){const t=ui(e),n=tn.get(t);if(n)return n;const{size:o,stops:s}=e,r=document.createElement("canvas");r.width=r.height=o;const c=r.getContext("2d"),i=c.createRadialGradient(o/2,o/2,0,o/2,o/2,o/2);for(const u of s)i.addColorStop(u.offset,`rgba(255,255,255,${u.alpha})`);c.fillStyle=i,c.fillRect(0,0,o,o);const a=new Ro(r);return a.needsUpdate=!0,tn.set(t,a),a}const fi={size:64,stops:[{offset:0,alpha:1},{offset:.4,alpha:.6},{offset:1,alpha:0}]},di={size:64,stops:[{offset:0,alpha:1},{offset:.4,alpha:.5},{offset:1,alpha:0}]},pi={size:128,stops:[{offset:0,alpha:.55},{offset:.25,alpha:.22},{offset:.6,alpha:.05},{offset:1,alpha:0}]},hi=ze.amber,gi=ze.teal,yi=ze.amber,mi=ze.teal,de=.18,qe=1.9,xi=1.1;function bi(){const e=Re(),t=Zn(),n=e.model,o=S.useRef(null),s=S.useRef(null),r=ot(),c=Gr(),i=S.useMemo(()=>[...pe(n,e.expanded)],[n,e.expanded]),a=S.useMemo(()=>Oo(n,r,new Set(i)),[r,n,i]),u=S.useMemo(()=>{if(!e.impact)return null;const A=new Set(i),T=ne=>fe(n,ne,A),K=new Set,D=new Set,U=T(e.impact.sourceId);for(const ne of e.impact.impacted){const $=T(ne);$&&K.add($)}for(const ne of e.impact.coveringTests){const $=T(ne);$&&D.add($)}return{impacted:K,covering:D,sourceRep:U}},[e.impact,n,i]),l=S.useMemo(()=>{if(!e.focus)return null;const A=new Set(i),T=new Set;for(const K of e.focus.nodes){const D=fe(n,K,A);D&&T.add(D)}return T},[e.focus,n,i]),f=S.useMemo(()=>{if(e.emphasis!=="tests")return null;const A=new Set(i),T=new Set;for(const K of n.records.values()){if(!An(K))continue;const D=fe(n,K.id,A);D&&T.add(D)}return T},[e.emphasis,n,i]),y=S.useMemo(()=>e.selected?fe(n,e.selected,new Set(i)):null,[e.selected,n,i]),g=S.useMemo(()=>r?fe(n,r,new Set(i)):null,[r,n,i]),{geometry:p,keysAt:m}=S.useMemo(()=>{const A=e.filters.kinds.size>0?i.filter(E=>{const N=n.byKey.get(E);return!(N?.symbolKind&&e.filters.kinds.has(N.symbolKind.toLowerCase()))}):i,T=A.length,K=new Float32Array(T*3),D=new Float32Array(T*3),U=new Float32Array(T),ne=new Array(T);for(let E=0;E<T;E++){const N=A[E],I=n.indexByKey.get(N);if(ne[E]=N,I===void 0)continue;K[E*3]=n.positions[I*3],K[E*3+1]=n.positions[I*3+1],K[E*3+2]=n.positions[I*3+2];const R=n.byKey.get(N),O=R.nodeId?n.records.get(R.nodeId)?.degree??0:0;let[C,H,W]=bt(R.kind,R.symbolKind);if(u)N===u.sourceRep||(u.covering.has(N)?[C,H,W]=gi:u.impacted.has(N)?[C,H,W]=hi:(C*=de,H*=de,W*=de));else if(l)l.has(N)||(C*=de,H*=de,W*=de);else if(e.emphasis==="types"){const ue=R.symbolKind?.toLowerCase();R.kind==="symbol"&&!(ue&&Uo.has(ue))&&(C*=de,H*=de,W*=de)}else f&&(f.has(N)||(C*=de,H*=de,W*=de));u||(g&&N===g?[C,H,W]=mi:y&&N===y&&([C,H,W]=yi));let G=qe;a&&!a.has(N)&&(G*=.22),C*=G,H*=G,W*=G;const[be,Ee,ae]=oi(C,H,W);D[E*3]=be,D[E*3+1]=Ee,D[E*3+2]=ae;const ge=N===y||N===g?1.6:l?.has(N)?1.25:1;U[E]=ii(R.kind,O)*ge}const $=new _e;return $.setAttribute("position",new me(K,3)),$.setAttribute("color",new me(D,3)),$.setAttribute("aSize",new me(U,1)),{geometry:$,keysAt:ne}},[i,n,a,e.filters,u,l,f,e.emphasis,y,g]);S.useEffect(()=>()=>p.dispose(),[p]);const x=S.useRef(null),h=S.useRef(new Map),_=S.useRef(new Set(e.expanded)),w=S.useRef(null),v=S.useRef(null),[b,k]=S.useState(0);S.useEffect(()=>{const A=_.current,T=e.expanded,{expanded:K,collapsed:D}=li(A,T);if(_.current=new Set(T),K.length===0&&D.length===0)return;const U=performance.now(),ne=new Set(K);if(K.length>0){const $=pe(n,T),E=new Map;for(const N of $){const I=n.ancestors.get(N);if(!I)continue;let R=null;for(let C=I.length-1;C>=0;C--){const H=I[C];if(H!==N&&ne.has(H)){R=H;break}}if(!R)continue;const O=h.current.get(N);if(O)E.set(N,O);else{const C=n.indexByKey.get(R);if(C===void 0)continue;E.set(N,[n.positions[C*3],n.positions[C*3+1],n.positions[C*3+2]])}}x.current=E.size>0?{origin:E,start:U}:null}if(D.length>0){const $=pe(n,A),E=pe(n,T),N=new Set(D),I=[];for(const R of $){if(E.has(R))continue;const O=n.ancestors.get(R);if(!O)continue;let C=null;for(let H=O.length-1;H>=0;H--){const W=O[H];if(W!==R&&N.has(W)){C=W;break}}C&&I.push({key:R,into:C})}if(I.length>0){const R=I.length,O=new Float32Array(R*3),C=new Float32Array(R*3),H=new Float32Array(R*3),W=new Float32Array(R*3);for(let G=0;G<R;G++){const{key:be,into:Ee}=I[G],ae=n.indexByKey.get(be),ge=n.indexByKey.get(Ee);if(ae===void 0||ge===void 0)continue;const ue=h.current.get(be)??[n.positions[ae*3],n.positions[ae*3+1],n.positions[ae*3+2]];O[G*3]=ue[0],O[G*3+1]=ue[1],O[G*3+2]=ue[2],H[G*3]=ue[0],H[G*3+1]=ue[1],H[G*3+2]=ue[2],C[G*3]=n.positions[ge*3],C[G*3+1]=n.positions[ge*3+1],C[G*3+2]=n.positions[ge*3+2];const we=n.byKey.get(be),st=we?bt(we.kind,we.symbolKind):[.8,.85,.95];W[G*3]=st[0]*qe,W[G*3+1]=st[1]*qe,W[G*3+2]=st[2]*qe}v.current={positions:H,origin:O,target:C,colors:W,start:U},k(G=>G+1)}}},[e.expanded,n]);const M=S.useRef(null);S.useEffect(()=>{M.current=performance.now()},[]);const j=S.useMemo(()=>new _e,[]);S.useEffect(()=>()=>j.dispose(),[j]),Ze(({invalidate:A})=>{const T=s.current;if(T){const N=M.current;let I=1;N!==null&&(I=Math.min(1,(performance.now()-N)/1e3/xi),I<1&&A(),I=1-Math.pow(1-I,3)),T.opacity=.95*I,T.size=.3+.7*I}const K=performance.now(),D=o.current,U=D?.geometry.getAttribute("position"),ne=h.current;if(D&&U){const N=U.array,I=x.current,R=I?en((K-I.start)/Jt):1;let O=!1;ne.clear();for(let C=0;C<m.length;C++){const H=m[C],W=n.indexByKey.get(H);if(W===void 0)continue;const G=n.positions[W*3],be=n.positions[W*3+1],Ee=n.positions[W*3+2],ae=I&&R<1?I.origin.get(H):void 0;let ge=G,ue=be,we=Ee;ae&&(ge=ae[0]+(G-ae[0])*R,ue=ae[1]+(be-ae[1])*R,we=ae[2]+(Ee-ae[2])*R,O=!0),N[C*3]=ge,N[C*3+1]=ue,N[C*3+2]=we,ne.set(H,[ge,ue,we])}U.needsUpdate=!0,R>=1&&(x.current=null),O&&A()}const $=v.current,E=w.current;if($&&E){const N=en((K-$.start)/Jt),I=$.positions.length/3;for(let C=0;C<I;C++)$.positions[C*3]=$.origin[C*3]+($.target[C*3]-$.origin[C*3])*N,$.positions[C*3+1]=$.origin[C*3+1]+($.target[C*3+1]-$.origin[C*3+1])*N,$.positions[C*3+2]=$.origin[C*3+2]+($.target[C*3+2]-$.origin[C*3+2])*N;const R=E.geometry.getAttribute("position");R&&(R.needsUpdate=!0);const O=E.material;O.opacity=.95*(1-N),N>=1?(v.current=null,O.opacity=0):A()}}),S.useEffect(()=>{const A=v.current;if(!A)return;const T=new me(A.positions,3);j.setAttribute("position",T),j.setAttribute("color",new me(A.colors,3)),T.needsUpdate=!0},[b,j]);const P=A=>{A.stopPropagation();const T=A.index;if(T===void 0)return;const K=m[T];if(!K)return;const D=n.byKey.get(K);D&&(D.kind==="symbol"?t.select(D.nodeId??K):(t.toggleExpand(K),D.nodeId&&t.select(D.nodeId)))},L=S.useRef(null),F=S.useRef(null),z=S.useRef(r);S.useEffect(()=>{z.current=r},[r]),S.useEffect(()=>()=>{F.current!==null&&cancelAnimationFrame(F.current)},[]);const J=A=>{L.current=A,F.current===null&&(F.current=requestAnimationFrame(()=>{F.current=null;const T=L.current;T!==z.current&&(z.current=T,c(T))}))},se=A=>{A.stopPropagation();const T=A.index,K=T===void 0?null:m[T]??null,D=K?n.byKey.get(K):null;J(D?.nodeId??K??null)},re=()=>J(null),he=S.useMemo(()=>jt(fi),[]);return d.jsxs(d.Fragment,{children:[d.jsx("points",{ref:o,geometry:p,onClick:P,onPointerMove:se,onPointerOut:re,raycast:wi,renderOrder:10,children:d.jsx("pointsMaterial",{ref:s,size:1,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.95,depthWrite:!1,blending:Te,map:he,onBeforeCompile:vi})}),d.jsx("points",{ref:w,geometry:j,raycast:()=>null,children:d.jsx("pointsMaterial",{size:3,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:0,depthWrite:!1,blending:Te,map:he})})]})}function vi(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 wi(e,t){const n=e.params.Points?.threshold;e.params.Points&&(e.params.Points.threshold=2.5),zo.prototype.raycast.call(this,e,t),e.params.Points&&n!==void 0&&(e.params.Points.threshold=n)}function Si(e=!0){Ze(({invalidate:t})=>{e&&t()})}function _i(){return Si(),d.jsx(No,{radius:600,depth:120,count:2600,factor:6,saturation:0,fade:!0,speed:.6})}const ki={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 Ei(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 nn(e){const t=e.lastIndexOf(".");if(t<0||t===e.length-1)return"";const n=e.slice(t+1).toLowerCase();return ki[n]??""}function no(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=Ei(o.language);if(s)return s;const r=nn(o.filePath||n.name);if(r)return r}}return nn(n.name)}function Ni(e){const t=new Set;for(const n of e.byKey.values()){if(n.kind!=="file")continue;const o=no(e,n.key);o&&t.add(o)}return[...t].sort()}function Mi(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=no(e,s.key);if(!r)continue;const c=e.ancestors.get(s.key);if(c)for(const i of c){const a=n(i);a.set(r,(a.get(r)??0)+1)}}const o=new Map;for(const[s,r]of t){let c="",i=0;for(const[a,u]of[...r.entries()].sort((l,f)=>l[0]<f[0]?-1:1))u>i&&(i=u,c=a);c&&o.set(s,c)}return o}function ji(){const e=te(),t=e.model,n=S.useMemo(()=>Ai(t),[t]),o=S.useMemo(()=>Mi(t),[t]),s=S.useMemo(()=>{const i=pe(t,e.expanded),a=[],u=[],l=[];for(const y of i){const g=t.byKey.get(y);if(!g||g.kind==="symbol")continue;const p=t.indexByKey.get(y);if(p===void 0)continue;const m=n.get(y)??0,x=g.kind==="galaxy"?26:g.kind==="dir"?16:9,h=Math.max(x,m*2.2),_=o.get(y),w=_?Qr(_):g.kind==="galaxy"?ze.amber:bt(g.kind,g.symbolKind),v=.34,b=w[0]*v,k=w[1]*v,M=w[2]*v;a.push(t.positions[p*3],t.positions[p*3+1],t.positions[p*3+2]),u.push(b,k,M),l.push(h)}const f=new _e;return f.setAttribute("position",new je(a,3)),f.setAttribute("color",new je(u,3)),f.setAttribute("aSize",new je(l,1)),f},[t,e.expanded,n,o]);S.useEffect(()=>()=>s.dispose(),[s]);const r=S.useMemo(()=>jt(pi),[]),c=S.useMemo(()=>Ti(r),[r]);return S.useEffect(()=>()=>c.dispose(),[c]),d.jsx("points",{geometry:s,material:c,renderOrder:-1,raycast:()=>null})}function Ai(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],c=e.positions[o*3+1],i=e.positions[o*3+2];for(const a of s){if(a===n)continue;const u=e.indexByKey.get(a);if(u===void 0)continue;const l=r-e.positions[u*3],f=c-e.positions[u*3+1],y=i-e.positions[u*3+2],g=Math.sqrt(l*l+f*f+y*y),p=t.get(a);p!==void 0&&g>p&&t.set(a,g)}}return t}function Ti(e){const t=new Lo({size:1,sizeAttenuation:!0,vertexColors:!0,transparent:!0,opacity:.5,depthWrite:!1,blending:Te,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 on(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 Ci(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 c=1;c<t;c++)o[c]=on(e[0],e[c]),s[c]=0;const r=[];for(let c=1;c<t;c++){let i=-1,a=1/0;for(let l=0;l<t;l++)n[l]||o[l]<a&&(a=o[l],i=l);if(i===-1)break;n[i]=!0;const u=s[i];r.push(u<i?[u,i]:[i,u]);for(let l=0;l<t;l++){if(n[l])continue;const f=on(e[i],e[l]);f<o[l]&&(o[l]=f,s[l]=i)}}return r.sort((c,i)=>c[0]!==i[0]?c[0]-i[0]:c[1]-i[1]),r}const sn=80;function Ii(){const e=te(),t=e.model,n=S.useMemo(()=>{const s=pe(t,e.expanded),r=[];for(const i of e.expanded){const a=t.byKey.get(i);if(!a||a.children.length<2)continue;const u=[];for(const f of a.children){if(!s.has(f))continue;const y=t.indexByKey.get(f);if(y!==void 0&&(u.push({key:f,x:t.positions[y*3],y:t.positions[y*3+1],z:t.positions[y*3+2]}),u.length>sn))break}if(u.length<2||u.length>sn)continue;const l=Ci(u);for(const[f,y]of l){const g=u[f],p=u[y];r.push(g.x,g.y,g.z,p.x,p.y,p.z)}}const c=new _e;return c.setAttribute("position",new je(r,3)),c},[t,e.expanded]);S.useEffect(()=>()=>n.dispose(),[n]);const o=S.useMemo(()=>{const[s,r,c]=ze.teal,i=.06;return new _n({color:new Ko(s*i,r*i,c*i),transparent:!0,depthWrite:!1,blending:Te,fog:!0})},[]);return S.useEffect(()=>()=>o.dispose(),[o]),d.jsx("lineSegments",{geometry:n,material:o,raycast:()=>null})}const rn=15e4,Ri=12,cn=8,zi=4e3;function At(e,t,n){const o=e.ancestors.get(t),s=e.ancestors.get(n);if(!o||!s)return[t,n];let r=0;const c=Math.min(o.length,s.length);for(;r<c&&o[r]===s[r];)r++;const i=r-1;if(i<0)return[t,n];const a=[];for(let u=o.length-1;u>=i;u--)a.push(o[u]);for(let u=i+1;u<s.length;u++)a.push(s[u]);return a}function Li(e,t){const n=t.length>zi,o=n?cn:Ri,s=n?4:cn,r=t.map(a=>{const u=At(e,a.srcKey,a.dstKey).length;return u<=2?1:u===3?s:o}),c=r.reduce((a,u)=>a+u,0);if(c<=rn)return r;const i=rn/c;return r.map(a=>Math.max(1,Math.floor(a*i)))}let Y=new Float64Array(64),V=new Float64Array(64),X=new Float64Array(64);function oo(e){if(e<=Y.length)return;const t=Math.max(e,Y.length*2);Y=new Float64Array(t),V=new Float64Array(t),X=new Float64Array(t)}let Q=new Float64Array(64);function so(e){e>Q.length&&(Q=new Float64Array(Math.max(e,Q.length*2)))}function Ki(e,t,n,o){const s=Li(e,t);let r=0;for(const y of s)r+=y;const c=new Float32Array(r*2*3),i=new Float32Array(r*2*3);let a=0;const u=e.positions,l=e.indexByKey;for(let y=0;y<t.length;y++){const g=t[y],p=s[y],m=g.a*o,x=g.r*m,h=g.g*m,_=g.b*m,w=At(e,g.srcKey,g.dstKey);oo(w.length);let v=0;for(const A of w){const T=l.get(A);T!==void 0&&(Y[v]=u[T*3],V[v]=u[T*3+1],X[v]=u[T*3+2],v++)}if(v<2)continue;if(p===1||v===2){a=an(c,i,a,Y[0],V[0],X[0],Y[v-1],V[v-1],X[v-1],x,h,_);continue}const b=v-1,k=Y[0],M=V[0],j=X[0],P=Y[b],L=V[b],F=X[b];for(let A=1;A<b;A++){const T=A/b,K=k+(P-k)*T,D=M+(L-M)*T,U=j+(F-j)*T;Y[A]=n*Y[A]+(1-n)*K,V[A]=n*V[A]+(1-n)*D,X[A]=n*X[A]+(1-n)*U}so(v),Q[0]=0;for(let A=1;A<v;A++){const T=Y[A]-Y[A-1],K=V[A]-V[A-1],D=X[A]-X[A-1],U=Math.sqrt(Math.sqrt(T*T+K*K+D*D));Q[A]=Q[A-1]+(U>1e-6?U:1e-6)}const z=Q[0],J=Q[b];let se=Y[0],re=V[0],he=X[0];for(let A=1;A<=p;A++){const T=z+(J-z)*A/p;let K=0;for(;K<b-1&&Q[K+1]<T;)K++;const D=Ae(Y,Q,K,b,T),U=Ae(V,Q,K,b,T),ne=Ae(X,Q,K,b,T);a=an(c,i,a,se,re,he,D,U,ne,x,h,_),se=D,re=U,he=ne}}const f=new _e;return f.setAttribute("position",new me(c,3)),f.setAttribute("color",new me(i,3)),f.setDrawRange(0,a/3),f}const Se=10;function Di(e,t,n,o,s,r){const c=e.positions,i=e.indexByKey,a=At(e,t,n);oo(a.length);let u=0;for(const v of a){const b=i.get(v);b!==void 0&&(Y[u]=c[b*3],V[u]=c[b*3+1],X[u]=c[b*3+2],u++)}if(u<2)return 0;const l=Se+1;if(u===2){const v=Y[0],b=V[0],k=X[0],M=Y[1],j=V[1],P=X[1];for(let L=0;L<l;L++){const F=L/Se;s[r+L*3]=v+(M-v)*F,s[r+L*3+1]=b+(j-b)*F,s[r+L*3+2]=k+(P-k)*F}return l}const f=u-1,y=Y[0],g=V[0],p=X[0],m=Y[f],x=V[f],h=X[f];for(let v=1;v<f;v++){const b=v/f;Y[v]=o*Y[v]+(1-o)*(y+(m-y)*b),V[v]=o*V[v]+(1-o)*(g+(x-g)*b),X[v]=o*X[v]+(1-o)*(p+(h-p)*b)}so(u),Q[0]=0;for(let v=1;v<u;v++){const b=Y[v]-Y[v-1],k=V[v]-V[v-1],M=X[v]-X[v-1],j=Math.sqrt(Math.sqrt(b*b+k*k+M*M));Q[v]=Q[v-1]+(j>1e-6?j:1e-6)}const _=Q[0],w=Q[f];for(let v=0;v<l;v++){const b=_+(w-_)*v/Se;let k=0;for(;k<f-1&&Q[k+1]<b;)k++;s[r+v*3]=Ae(Y,Q,k,f,b),s[r+v*3+1]=Ae(V,Q,k,f,b),s[r+v*3+2]=Ae(X,Q,k,f,b)}return l}function Ae(e,t,n,o,s){const r=n,c=n+1,i=r>0?r-1:r,a=c<o?c+1:c,u=t[i],l=t[r],f=t[c],y=t[a],g=e[i],p=e[r],m=e[c],x=e[a],h=l-u,_=f-l,w=y-f,v=h>1e-9?((l-s)*g+(s-u)*p)/h:p,b=_>1e-9?((f-s)*p+(s-l)*m)/_:p,k=w>1e-9?((y-s)*m+(s-f)*x)/w:m,M=f-u,j=y-l,P=M>1e-9?((f-s)*v+(s-u)*b)/M:b,L=j>1e-9?((y-s)*b+(s-l)*k)/j:b;return _>1e-9?((f-s)*P+(s-l)*L)/_:P}function an(e,t,n,o,s,r,c,i,a,u,l,f){return e[n]=o,e[n+1]=s,e[n+2]=r,e[n+3]=c,e[n+4]=i,e[n+5]=a,t[n]=u,t[n+1]=l,t[n+2]=f,t[n+3]=u,t[n+4]=l,t[n+5]=f,n+6}function ln(e){return e.startsWith("galaxy:")?e:e.split(":")[1]??e}function un(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Pi(){const e=Re(),t=e.model,n=ot(),o=Wr(),{geometry:s,drawn:r,total:c}=S.useMemo(()=>{const a=[e.selected,n,...e.focus?.nodes??[]].filter(Boolean),{bundles:u,visible:l,total:f}=Mn(t,{expanded:e.expanded,filters:{edgeTypes:e.filters.edgeTypes,minConfidence:e.filters.minConfidence,audit:e.audit},activeNodes:a}),y=e.selected?pt(t,e.selected,l):null,g=n?$o(t,n,l):null,p=kn(t,e.focus,l),m=new Set;if(y&&m.add(y),g&&m.add(g),p)for(const b of p)m.add(b);const x=m.size>0,h=e.impact?new Set([e.impact.sourceId,...e.impact.impacted]):null,_=[];for(const b of u){if(!t.indexByKey.has(b.srcKey)||!t.indexByKey.has(b.dstKey))continue;let[k,M,j]=eo(b.dominantType),P=ei(b.bestResolution,b.count)*b.lengthAtten;if(h&&(b.dominantType==="CALLS"&&un(b.srcNodes,h)&&un(b.dstNodes,h)?(k=1,M=.42,j=.32,P=Math.min(1,P*1.8)):P*=.08),x){const L=p?p.has(b.srcKey)&&p.has(b.dstKey):!1,F=m.has(b.srcKey)||m.has(b.dstKey);L?P=Math.min(1,P*1.5):F?P=Math.min(1,P*1.3):P*=.06}ln(b.srcKey)!==ln(b.dstKey)&&(k=Math.min(1,k*1.8),M=Math.min(1,M*1.8),j=Math.min(1,j*1.8)),_.push({srcKey:b.srcKey,dstKey:b.dstKey,r:k,g:M,b:j,a:P})}const w=ni(_.length);return{geometry:Ki(t,_,e.bundleBeta,w),drawn:_.length,total:f}},[t,e.expanded,e.selected,n,e.filters,e.audit,e.impact,e.focus,e.bundleBeta]);S.useEffect(()=>()=>s.dispose(),[s]),S.useEffect(()=>{o({drawn:r,total:c})},[r,c,o]);const i=S.useMemo(()=>new _n({vertexColors:!0,transparent:!0,depthWrite:!1,blending:Te}),[]);return S.useEffect(()=>()=>i.dispose(),[i]),d.jsx("lineSegments",{geometry:s,material:i,renderOrder:5})}function fn(e){return Math.min(4,1+Math.floor(Math.log2(1+e)))}function dn(e,t){return t<=1?0:e/t}function Fi(e,t=3e3,n){const o=[];if(e.length===0||t<=0)return{particles:o};const s=[],r=[];for(let a=0;a<e.length;a++)n&&n(e[a],a)?s.push(a):r.push(a);const c=(a,u)=>{for(let l=0;l<u&&o.length<t;l++)o.push({bundleIndex:a,phase:dn(l,u)})};for(const a of s){if(o.length>=t)break;c(a,fn(e[a].count))}const i=t-o.length;if(i>0&&r.length>0)if(r.length<=i){for(const a of r)c(a,1);for(const a of r){if(o.length>=t)break;const u=fn(e[a].count)-1;for(let l=1;l<=u&&o.length<t;l++)o.push({bundleIndex:a,phase:dn(l,u+1)})}}else{const a=Math.ceil(r.length/i);for(let u=0;u<r.length&&o.length<t;u+=a)c(r[u],1)}return{particles:o}}const Bi=3e3,$i=.32,Oi=.8,Hi=.55,qi=Se+1;function Gi(){const e=Re(),t=e.model,n=ot(),{geometry:o,curves:s,curveBase:r,phaseArr:c,count:i}=S.useMemo(()=>{const u=[e.selected,n,...e.focus?.nodes??[]].filter(Boolean),{bundles:l,visible:f}=Mn(t,{expanded:e.expanded,filters:{edgeTypes:e.filters.edgeTypes,minConfidence:e.filters.minConfidence,audit:e.audit},activeNodes:u});let y=l;if(e.focus){const z=kn(t,e.focus,f);z&&(y=l.filter(J=>z.has(J.srcKey)&&z.has(J.dstKey)))}const g=new Set,p=e.selected?pt(t,e.selected,f):null,m=n?pt(t,n,f):null;p&&g.add(p),m&&g.add(m);const x=g.size>0?z=>g.has(z.srcKey)||g.has(z.dstKey):void 0,{particles:h}=Fi(y,Bi,x),_=h.length,w=new Map,v=new Float32Array(_*qi*3);let b=0;const k=new Float32Array(_),M=new Int32Array(_),j=new Float32Array(_*3),P=new Float32Array(_*3);let L=0;for(let z=0;z<_;z++){const J=h[z],se=y[J.bundleIndex];if(!t.indexByKey.has(se.srcKey)||!t.indexByKey.has(se.dstKey))continue;let re=w.get(J.bundleIndex);if(re===void 0){const U=Di(t,se.srcKey,se.dstKey,e.bundleBeta,v,b*3);if(U===0)continue;re=b,w.set(J.bundleIndex,re),b+=U}M[L]=re,j[L*3]=v[re*3],j[L*3+1]=v[re*3+1],j[L*3+2]=v[re*3+2],k[L]=J.phase;const[he,A,T]=eo(se.dominantType),K=g.size>0&&(g.has(se.srcKey)||g.has(se.dstKey)),D=Hi*(K?2:1);P[L*3]=he*D,P[L*3+1]=A*D,P[L*3+2]=T*D,L++}const F=new _e;return F.setAttribute("position",new me(j,3)),F.setAttribute("color",new me(P,3)),F.setDrawRange(0,L),{geometry:F,curves:v,curveBase:M,phaseArr:k,count:L}},[t,e.expanded,e.filters,e.audit,e.focus,e.selected,n,e.bundleBeta]);S.useEffect(()=>()=>o.dispose(),[o]);const a=S.useRef(null);return Ze(({clock:u,invalidate:l})=>{const f=a.current;if(!f||i===0)return;const y=f.geometry.getAttribute("position");if(!y)return;const g=y.array,p=u.elapsedTime*$i;for(let m=0;m<i;m++){const x=(p+c[m])%1,h=r[m],_=x*Se;let w=_|0;w>=Se&&(w=Se-1);const v=_-w,b=(h+w)*3,k=(h+w+1)*3;g[m*3]=s[b]+(s[k]-s[b])*v,g[m*3+1]=s[b+1]+(s[k+1]-s[b+1])*v,g[m*3+2]=s[b+2]+(s[k+2]-s[b+2])*v}y.needsUpdate=!0,l()}),i===0?null:d.jsx("points",{ref:a,geometry:o,raycast:()=>null,children:d.jsx("pointsMaterial",{size:Oi,sizeAttenuation:!0,map:jt(di),vertexColors:!0,transparent:!0,opacity:.85,depthWrite:!1,blending:Te})})}const Ui=20;function Wi(){const e=Re(),t=e.model,n=ot(),o=S.useMemo(()=>{const s=pe(t,e.expanded),r=new Set;n&&r.add(n),e.selected&&r.add(e.selected);const c=[];for(const l of r){const f=t.clusterOfNode.get(l)??l,y=t.indexByKey.get(f);if(y===void 0)continue;const p=t.byKey.get(f)?.name??t.records.get(l)?.name??f;c.push({key:`priority-${f}`,label:p,pos:[t.positions[y*3],t.positions[y*3+1],t.positions[y*3+2]],priority:!0})}const i=[];for(const l of s){const f=t.byKey.get(l);f&&f.kind!=="symbol"&&i.push({key:l,importance:f.children.length})}i.sort((l,f)=>f.importance-l.importance);const a=new Set([...r].map(l=>t.clusterOfNode.get(l)??l));let u=0;for(const{key:l}of i){if(u>=Ui)break;if(a.has(l))continue;const f=t.indexByKey.get(l);if(f===void 0)continue;const y=t.byKey.get(l);c.push({key:`cluster-${l}`,label:y.name,pos:[t.positions[f*3],t.positions[f*3+1],t.positions[f*3+2]],priority:!1}),u++}return c},[t,n,e.selected,e.expanded]);return d.jsx(d.Fragment,{children:o.map(s=>d.jsx(Mo,{position:s.pos,center:!0,distanceFactor:40,zIndexRange:[10,0],children:d.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 vt=null;function pn(){return vt}let wt=null;function Yi(e,t,n){wt?.(e,t,n)}const Vi=4e3,Xi=.05,hn=1.3;function Qi(){const e=S.useRef(null),t=Re(),n=t.model,o=t.idleDrift,{invalidate:s}=Sn(),r=S.useRef(performance.now()),c=S.useMemo(()=>({box:new Po,sphere:new Do,pt:new Ct}),[]);S.useEffect(()=>{const a=e.current;if(!a||!n)return;if(t.focusTarget){const p=n.clusterOfNode.get(t.focusTarget)??t.focusTarget,m=n.indexByKey.get(p);if(m!==void 0){const{sphere:x,pt:h}=c;h.set(n.positions[m*3],n.positions[m*3+1],n.positions[m*3+2]),x.set(h,60*hn),a.fitToSphere(x,!0),r.current=performance.now(),s();return}}let u;if(t.focus){const p=pe(n,t.expanded),m=new Set;for(const x of t.focus.nodes){const h=fe(n,x,p);h&&m.add(h)}u=[...m]}else t.selected&&n.clusterOfNode.has(t.selected)?u=[n.clusterOfNode.get(t.selected)]:t.selected&&n.indexByKey.has(t.selected)?u=[t.selected]:u=[...pe(n,t.expanded)];const{box:l,sphere:f,pt:y}=c;l.makeEmpty();let g=!1;for(const p of u){const m=n.indexByKey.get(p);m!==void 0&&(y.set(n.positions[m*3],n.positions[m*3+1],n.positions[m*3+2]),l.expandByPoint(y),g=!0)}g&&(l.getBoundingSphere(f),f.radius=Math.max(f.radius,4)*hn,a.fitToSphere(f,!0),r.current=performance.now(),s())},[t.fitNonce,n]),S.useEffect(()=>(wt=(a,u,l)=>{const f=e.current;f&&(f.moveTo(a,u,l,!0),r.current=performance.now(),s())},()=>{wt=null,vt=null}),[s]);const i=S.useMemo(()=>new Ct,[]);return Ze((a,u)=>{const l=e.current;if(!l)return;l.getTarget(i),vt={x:i.x,y:i.y,z:i.z};const f=performance.now();if(l.active){r.current=f;return}f-r.current<Vi||o&&(l.rotate(Xi*u,0,!1),s())}),d.jsx(jo,{ref:e,makeDefault:!0,smoothTime:.3,minDistance:2,maxDistance:1200,onStart:()=>{r.current=performance.now()}})}async function Zi(){if(tt())return Pr();try{const e=await fetch("/api/temporal");return e.ok?await e.json():{}}catch{return{}}}function Ji(e,t){return`file:${e}:${t}`}function ec(e,t,n){const o=new Map,s=r=>{const c=Ji(e.repoId,r),i=e.byKey.get(c);if(!i)return null;const a=i.nodeId??c;return fe(e,a,n)??(n.has(c)?c:null)};for(const[r,c]of Object.entries(t)){const i=s(r);if(i)for(const{path:a,support:u,confidence:l}of c){const f=s(a);if(!f||f===i)continue;const[y,g]=i<f?[i,f]:[f,i],p=`${y} ${g}`,m=o.get(p);(!m||u>m.support||u===m.support&&l>m.confidence)&&o.set(p,{aKey:y,bKey:g,support:u,confidence:l})}}return[...o.values()].sort((r,c)=>r.aKey===c.aKey?r.bKey<c.bKey?-1:1:r.aKey<c.aKey?-1:1)}function tc(){const e=te(),t=e.model,n=e.cochange,o=S.useMemo(()=>{if(!n)return null;const r=pe(t,e.expanded),c=ec(t,n,r);if(c.length===0)return null;const i=[],a=[];for(const l of c){const f=t.indexByKey.get(l.aKey),y=t.indexByKey.get(l.bKey);if(f===void 0||y===void 0)continue;const g=t.positions[f*3],p=t.positions[f*3+1],m=t.positions[f*3+2],x=t.positions[y*3],h=t.positions[y*3+1],_=t.positions[y*3+2];i.push(g,p,m,x,h,_);const w=Math.hypot(x-g,h-p,_-m);a.push(0,w)}if(i.length===0)return null;const u=new _e;return u.setAttribute("position",new je(i,3)),u.setAttribute("lineDistance",new je(a,1)),u},[t,n,e.expanded]);S.useEffect(()=>{const r=o;return()=>r?.dispose()},[o]);const s=S.useMemo(()=>new Fo({color:16727536,transparent:!0,opacity:.7,dashSize:2.5,gapSize:1.8,depthWrite:!1}),[]);return S.useEffect(()=>()=>s.dispose(),[s]),!e.coupling||!o?null:d.jsx("lineSegments",{geometry:o,material:s})}async function nc(e,t,n){if(tt())return Fr(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 Ke=fo();function oc(){const e=te(),t=e.model,[n,o]=S.useState([]),s=e.selected?t.records.get(e.selected):null,r=S.useMemo(()=>{if(!e.selected)return[];const l=e.selected,f=[];for(const y of t.drawEdges)y.from===l?f.push({direction:"out",type:y.type,neighborId:y.to,neighbor:t.records.get(y.to)?.name??y.to,resolution:y.resolution,confidence:y.confidence}):y.to===l&&f.push({direction:"in",type:y.type,neighborId:y.from,neighbor:t.records.get(y.from)?.name??y.from,resolution:y.resolution,confidence:y.confidence});return f},[t,e.selected]);function c(l){e.revealAndSelect(l,{fly:!0})}const i=S.useMemo(()=>[Ke.accessor("direction",{header:"dir"}),Ke.accessor("type",{header:"type"}),Ke.accessor("neighbor",{header:"neighbor"}),Ke.accessor("resolution",{header:"resolution"}),Ke.accessor("confidence",{header:"conf"})],[]),a=uo({data:r,columns:i,state:{sorting:n},onSortingChange:o,getCoreRowModel:ho(),getSortedRowModel:po()});if(!s)return d.jsx(gn,{children:d.jsx("div",{style:{opacity:.6,fontSize:13},children:"Click a star to inspect it. Click a cluster (galaxy / directory / file) to expand or collapse it."})});const u=s.semanticSummary!==null&&s.summaryOfHash!==null&&s.contentHash!==null&&s.summaryOfHash!==s.contentHash;return d.jsxs(gn,{children:[d.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,flexWrap:"wrap"},children:[d.jsx("strong",{style:{fontSize:15},children:s.name||s.id}),s.kind&&d.jsx(ut,{children:s.kind}),s.language&&d.jsx(ut,{children:s.language}),s.role&&d.jsx(ut,{children:s.role})]}),s.qualifiedName&&s.qualifiedName!==s.name&&d.jsx("div",{style:{fontSize:12,opacity:.7},children:s.qualifiedName}),s.filePath&&d.jsxs("div",{style:{fontSize:12,opacity:.85,marginTop:4},children:[s.filePath,s.startLine?`:${s.startLine}-${s.endLine}`:""]}),d.jsx(rc,{}),d.jsx(ic,{}),d.jsx(sc,{rec:s,repoRoot:t.repoRoot}),d.jsx(St,{title:"Semantic summary",children:d.jsx(cc,{summary:s.semanticSummary,stale:u})}),d.jsx(St,{title:`Incident edges (${r.length})`,children:r.length===0?d.jsx("div",{style:{fontSize:12,opacity:.55},children:"No relationship edges."}):d.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[d.jsx("thead",{children:a.getHeaderGroups().map(l=>d.jsx("tr",{children:l.headers.map(f=>d.jsxs("th",{onClick:f.column.getToggleSortingHandler(),style:{textAlign:"left",cursor:"pointer",borderBottom:"1px solid rgba(120,150,210,0.3)",padding:"3px 4px",userSelect:"none"},children:[Tt(f.column.columnDef.header,f.getContext()),{asc:" ▲",desc:" ▼"}[f.column.getIsSorted()]??""]},f.id))},l.id))}),d.jsx("tbody",{children:a.getRowModel().rows.map(l=>d.jsx("tr",{onClick:()=>c(l.original.neighborId),style:{cursor:"pointer"},children:l.getVisibleCells().map(f=>d.jsx("td",{style:{padding:"3px 4px",borderBottom:"1px solid rgba(120,150,210,0.12)"},children:Tt(f.column.columnDef.cell,f.getContext())},f.id))},l.id))})]})})]})}function sc({rec:e,repoRoot:t}){const[n,o]=S.useState(null),[s,r]=S.useState("idle"),c=!tt()&&!!e.filePath&&e.startLine>0;if(S.useEffect(()=>{if(!c){o(null),r("idle");return}let a=!1;r("loading"),o(null);const u=e.endLine>=e.startLine?e.endLine:e.startLine;return nc(e.filePath,e.startLine,u).then(l=>{a||(l&&l.lines.length>0?(o(l),r("idle")):r("missing"))}),()=>{a=!0}},[e.id,e.filePath,e.startLine,e.endLine,c]),!c)return null;const i=t&&e.filePath?`vscode://file/${t.replace(/\/+$/,"")}/${e.filePath}:${e.startLine||1}`:null;return d.jsxs(St,{title:"Source",children:[i&&d.jsx("a",{href:i,style:{fontSize:11,color:B.teal,textDecoration:"none",display:"inline-block",marginBottom:6},title:"Open this file at this line in VS Code",children:"Open in editor ↗"}),s==="loading"&&d.jsx("div",{style:{fontSize:11,opacity:.5},children:"Loading source…"}),s==="missing"&&d.jsx("div",{style:{fontSize:11,opacity:.5},children:"Source unavailable."}),n&&d.jsx("pre",{style:{margin:0,maxHeight:220,overflow:"auto",background:"rgba(0,0,0,0.35)",border:"1px solid rgba(120,150,210,0.18)",borderRadius:6,padding:"6px 8px",fontSize:11,lineHeight:1.45,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"rgba(220,228,245,0.78)",opacity:.92},children:n.lines.map((a,u)=>{const l=n.start+u;return d.jsxs("div",{style:{display:"flex",whiteSpace:"pre"},children:[d.jsx("span",{style:{display:"inline-block",width:40,flexShrink:0,textAlign:"right",paddingRight:10,color:"rgba(120,140,180,0.5)",userSelect:"none"},children:l}),d.jsx("span",{style:{flex:1},children:a||" "})]},l)})})]})}function rc(){const e=te(),t=e.focus!==null,n=e.focus?.nodes.size??0,o=e.focusDepth,s=B.teal;return d.jsxs("div",{style:{marginTop:10},children:[d.jsx("button",{onClick:()=>e.toggleFocus(),title:"Isolate this symbol's N-hop neighborhood (in + out edges) and frame it",style:{width:"100%",padding:"5px 0",borderRadius:6,background:t?`${s}33`:"rgba(255,255,255,0.05)",border:`1px solid ${t?s:"rgba(255,255,255,0.14)"}`,color:t?"#a9f0e6":"rgba(255,255,255,0.75)",cursor:"pointer",fontSize:12,fontWeight:t?600:400},children:t?"Focus ON — click to clear":"Focus neighborhood"}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6,fontSize:11,opacity:t?1:.7},children:[d.jsx("span",{style:{opacity:.7},children:"Depth"}),Array.from({length:Tn-gt+1},(r,c)=>{const i=gt+c,a=o===i;return d.jsx("button",{onClick:()=>e.setFocusDepth(i),style:{width:24,height:22,borderRadius:5,background:a?`${s}33`:"rgba(255,255,255,0.05)",border:`1px solid ${a?s:"rgba(255,255,255,0.14)"}`,color:a?"#a9f0e6":"rgba(255,255,255,0.6)",cursor:"pointer",fontSize:11,fontWeight:a?700:400},children:i},i)}),t&&d.jsxs("span",{style:{marginLeft:"auto",color:"#a9f0e6"},children:[n," node",n===1?"":"s"]})]})]})}function ic(){const e=te(),t=e.impact!==null,n=e.impact?.impacted.size??0,o=e.impact?.coveringTests.size??0;return d.jsxs("div",{style:{marginTop:10},children:[d.jsx("button",{onClick:()=>e.toggleImpact(),title:"Highlight transitive callers (reverse CALLS) and covering tests",style:{width:"100%",padding:"5px 0",borderRadius:6,background:t?"rgba(255,107,82,0.22)":"rgba(255,255,255,0.05)",border:`1px solid ${t?"#ff6b52":"rgba(255,255,255,0.14)"}`,color:t?"#ffb9ab":"rgba(255,255,255,0.75)",cursor:"pointer",fontSize:12,fontWeight:t?600:400},children:t?"Impact ON — click to clear":"Impact"}),t&&d.jsxs("div",{style:{display:"flex",gap:8,marginTop:6,fontSize:11},children:[d.jsxs("span",{style:{color:"#ff8a73"},children:["● ",n," impacted"]}),d.jsxs("span",{style:{color:"#74ff8e"},children:["● ",o," covering test",o===1?"":"s"]})]})]})}function cc({summary:e,stale:t}){if(!e)return d.jsx("div",{style:{fontSize:12,opacity:.55},children:"No summary yet — agents write these as they explore."});const n=e.split(/\n\n+/);function o(s){return s.split(/`([^`]+)`/).map((c,i)=>i%2===1?d.jsx("code",{style:{background:"rgba(255,255,255,0.1)",borderRadius:3,padding:"0 3px",fontFamily:"monospace"},children:c},i):c)}return d.jsxs("div",{children:[t&&d.jsx("span",{style:{display:"inline-block",background:"#ffb454",color:"#000",borderRadius:10,padding:"1px 7px",fontSize:10,fontWeight:700,marginBottom:4},children:"⚠ STALE"}),n.map((s,r)=>d.jsx("p",{style:{margin:"4px 0",fontSize:13,lineHeight:1.5},children:o(s)},r))]})}function gn({children:e}){return d.jsx("div",{style:{position:"absolute",top:12,right:12,width:360,maxHeight:"calc(100vh - 24px)",overflowY:"auto",padding:14,borderRadius:8,background:"rgba(8,11,22,0.92)",border:"1px solid rgba(90,120,180,0.35)",backdropFilter:"blur(4px)"},children:e})}function St({title:e,children:t}){return d.jsxs("div",{style:{marginTop:12},children:[d.jsx("div",{style:{fontSize:11,textTransform:"uppercase",letterSpacing:.6,opacity:.6},children:e}),d.jsx("div",{style:{marginTop:4},children:t})]})}function ut({children:e}){return d.jsx("span",{style:{fontSize:11,padding:"1px 6px",borderRadius:999,background:"rgba(90,120,180,0.25)",border:"1px solid rgba(120,150,210,0.4)"},children:e})}const ac=[{key:"function",label:"Function",color:"#e5c07b"},{key:"class",label:"Class",color:"#56b6c2"},{key:"interface",label:"Interface",color:"#c678dd"},{key:"enum",label:"Enum",color:"#98c379"},{key:"variable",label:"Variable",color:"#abb2bf"}],lc=["CALLS","IMPORTS","INHERITS","IMPLEMENTS","INSTANTIATES"];function uc(){const e=te(),[t,n]=S.useState(!0),{filters:o,audit:s}=e,r=o.kinds.size>0||o.edgeTypes.size>0||o.minConfidence>0||s!=="off";return d.jsxs("div",{style:{position:"fixed",bottom:12,right:12,background:"rgba(20,22,28,0.88)",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",backdropFilter:"blur(8px)",color:"#fff",fontSize:12,width:240,zIndex:20},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",borderBottom:t?"1px solid rgba(255,255,255,0.07)":"none",cursor:"pointer",userSelect:"none"},onClick:()=>n(c=>!c),children:[d.jsxs("span",{style:{fontWeight:600,fontSize:11,letterSpacing:1,opacity:.8},children:["FILTERS ",r?"●":""]}),d.jsx("span",{style:{opacity:.5},children:t?"▲":"▼"})]}),t&&d.jsxs("div",{style:{padding:"8px 10px"},children:[d.jsx("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:"NODE KIND"}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:ac.map(({key:c,label:i,color:a})=>{const u=o.kinds.has(c);return d.jsx("button",{onClick:()=>e.setKindFilter(c,!u),style:{background:u?"rgba(255,255,255,0.05)":a+"33",border:`1px solid ${u?"rgba(255,255,255,0.1)":a+"88"}`,color:u?"rgba(255,255,255,0.3)":a,borderRadius:12,padding:"2px 8px",cursor:"pointer",fontSize:11,transition:"all 0.15s"},children:i},c)})}),d.jsx("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:"EDGE TYPE"}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:lc.map(c=>{const i=o.edgeTypes.has(c);return d.jsx("button",{onClick:()=>e.setEdgeTypeFilter(c,!i),style:{background:i?"rgba(255,255,255,0.05)":"rgba(255,255,255,0.1)",border:`1px solid ${i?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.25)"}`,color:i?"rgba(255,255,255,0.25)":"rgba(255,255,255,0.8)",borderRadius:12,padding:"2px 8px",cursor:"pointer",fontSize:11,transition:"all 0.15s"},children:c},c)})}),d.jsxs("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:["CONFIDENCE AUDIT ",s!=="off"?"● ON":""]}),d.jsxs("div",{style:{display:"flex",gap:4,marginBottom:4},children:[d.jsx(yn,{label:"Ambiguous only",hint:"Show ONLY ambiguous (guessed) edges; hide everything else",on:s==="ambiguous",onClick:()=>e.setAudit(s==="ambiguous"?"off":"ambiguous")}),d.jsx(yn,{label:"+ name_match",hint:"Also include name_match edges (still low-confidence)",on:s==="ambiguous+name",onClick:()=>e.setAudit(s==="ambiguous+name"?"off":"ambiguous+name")})]}),s!=="off"&&d.jsx("div",{style:{fontSize:10,lineHeight:1.4,color:"#ffb454",marginBottom:8},children:"Showing only low-confidence edges — where the resolver is guessing."}),d.jsxs("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:["MIN CONFIDENCE: ",o.minConfidence.toFixed(2)]}),d.jsx("input",{type:"range",min:0,max:1,step:.05,value:o.minConfidence,onChange:c=>e.setMinConfidence(parseFloat(c.target.value)),style:{width:"100%",marginBottom:8,accentColor:"#61afef"}}),d.jsxs("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:["EDGE BUNDLING: ",e.bundleBeta.toFixed(2)]}),d.jsx("input",{type:"range",min:0,max:1,step:.05,value:e.bundleBeta,onChange:c=>e.setBundleBeta(parseFloat(c.target.value)),style:{width:"100%",marginBottom:8,accentColor:"#61afef"}}),d.jsx("div",{style:{fontSize:10,opacity:.5,margin:"4px 0"},children:"OVERLAYS"}),d.jsx(fc,{}),r&&d.jsx("button",{onClick:()=>e.clearFilters(),style:{width:"100%",padding:"4px 0",borderRadius:4,background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",cursor:"pointer",fontSize:11},children:"Reset filters"})]})]})}function fc(){const e=te(),t=e.coupling,n=e.cochange!==null,o=t&&n&&Object.keys(e.cochange).length===0;return d.jsxs("div",{style:{marginBottom:8},children:[d.jsx("button",{onClick:()=>e.toggleCoupling(),title:"Draw git co-change links between files that change together (dashed magenta)",style:{width:"100%",padding:"4px 0",borderRadius:6,background:t?"rgba(255,61,240,0.18)":"rgba(255,255,255,0.05)",border:`1px solid ${t?"#ff3df0":"rgba(255,255,255,0.12)"}`,color:t?"#ffb6f7":"rgba(255,255,255,0.65)",cursor:"pointer",fontSize:11,fontWeight:t?600:400},children:t?"Coupling ON":"Coupling (co-change)"}),t&&!n&&d.jsx("div",{style:{fontSize:10,opacity:.5,marginTop:4},children:"Loading temporal data…"}),o&&d.jsx("div",{style:{fontSize:10,color:"#ffb454",marginTop:4,lineHeight:1.4},children:"No temporal data (git history unavailable for this repo)."})]})}function yn({label:e,hint:t,on:n,onClick:o}){return d.jsx("button",{onClick:o,title:t,style:{flex:1,background:n?"rgba(255,180,84,0.22)":"rgba(255,255,255,0.05)",border:`1px solid ${n?"#ffb454":"rgba(255,255,255,0.12)"}`,color:n?"#ffd9a0":"rgba(255,255,255,0.65)",borderRadius:6,padding:"3px 6px",cursor:"pointer",fontSize:10,fontWeight:n?600:400},children:e})}const dc={name:10,qualifiedName:6,filePath:3,semanticSummary:1.5},pc=["name","qualifiedName","filePath","semanticSummary"];function hc(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 gc(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 yc(e){return e.toLowerCase().split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function ro(e,t,n=10){const o=yc(t);if(o.length===0)return[];const s=[];for(const r of e){let c=0,i=-1,a="name",u=!0;for(const l of o){let f=0,y="name";for(const g of pc){const p=hc(l,gc(r,g));if(p===0)continue;const m=p*dc[g];m>f&&(f=m,y=g)}if(f===0){u=!1;break}c+=f,f>i&&(i=f,a=y)}u&&s.push({rec:r,score:c,topField:a})}return s.sort((r,c)=>c.score!==r.score?c.score-r.score:r.rec.name!==c.rec.name?r.rec.name<c.rec.name?-1:1:r.rec.id<c.rec.id?-1:r.rec.id>c.rec.id?1:0),s.slice(0,n)}const mc=new Set(["Function","Class","Interface","Enum","Variable"]);function xc(e){return mc.has(e)?"symbols":e==="File"?"files":"directories"}function bc(e){switch(e){case"name":return"name";case"qualifiedName":return"qualified name";case"filePath":return"path";case"semanticSummary":return"summary"}}function vc(){const e=te(),[t,n]=S.useState(""),[o,s]=S.useState(!1),r=S.useRef(null),c=e.model,i=go.useMemo(()=>!c||t.trim().length<2?[]:ro(c.records.values(),t,10),[c,t]);S.useEffect(()=>{s(i.length>0)},[i]);function a(l){c&&(e.revealAndSelect(l,{fly:!0}),n(""),s(!1))}function u(l){l.key==="Escape"&&(n(""),s(!1)),l.key==="Enter"&&i.length>0&&a(i[0].rec.id)}return c?d.jsx("div",{style:{position:"relative",marginTop:8,zIndex:25},children:d.jsxs("div",{style:{position:"relative"},children:[d.jsx("input",{ref:r,id:"reposkein-search",type:"text",placeholder:"Search nodes… ( / )",value:t,onChange:l=>n(l.target.value),onKeyDown:u,style:{background:"rgba(20,22,28,0.88)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:6,color:"#fff",padding:"5px 10px",fontSize:12,width:220,backdropFilter:"blur(8px)",outline:"none"}}),o&&i.length>0&&d.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:2,background:"rgba(20,22,28,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,overflow:"hidden",backdropFilter:"blur(8px)",maxHeight:280,overflowY:"auto"},children:i.map(({rec:l,topField:f})=>d.jsxs("div",{onClick:()=>a(l.id),style:{padding:"6px 10px",cursor:"pointer",fontSize:12,borderBottom:"1px solid rgba(255,255,255,0.05)",transition:"background 0.1s"},onMouseEnter:y=>y.currentTarget.style.background="rgba(255,255,255,0.08)",onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[d.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:6},children:[d.jsx("span",{style:{color:"#fff",fontWeight:500},children:l.name}),d.jsx("span",{style:{color:"rgba(150,180,230,0.7)",fontSize:9,flexShrink:0,textTransform:"uppercase",letterSpacing:.4},children:bc(f)})]}),d.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:10,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.filePath})]},l.id))})]})}):null}let io=!1;function wc(){return io}function ft(e){io=e}const Sc=[1,2,3],Ge="Select a node first";function _c(){const e=jn.map((n,o)=>({id:`lens-${n}`,label:`Lens: ${Ve[n].label}`,subtitle:Ve[n].hint,kbd:String(o+1),group:"commands",disabled:()=>!1,run:s=>s.setLens(n)})),t=Sc.map(n=>({id:`focus-depth-${n}`,label:`Focus depth ${n}`,subtitle:"Sets the neighborhood BFS depth for the Focus overlay",disabledReason:Ge,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:Ge,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:Ge,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:"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 selected node",subtitle:"Copies the current deep link (?node=…) to the clipboard",disabledReason:Ge,group:"commands",disabled:n=>!n.selected,run:(n,o,s)=>s.copyLink()},{id:"toggle-minimap",label:"Toggle minimap",subtitle:"Show or hide the overview inset",group:"commands",disabled:()=>!1,run:n=>n.toggleMinimap()},{id:"toggle-legend",label:"Toggle legend",subtitle:"Show or hide the color legend",group:"commands",disabled:()=>!1,run:n=>n.toggleLegend()},{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",group:"commands",disabled:()=>!1,run:(n,o)=>n.setIdleDrift(!o.idleDrift)}]}function kc(e,t,n=8){return[t,...e.filter(o=>o.id!==t.id)].slice(0,n)}function Ec(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 Nc(e,t){return e.get(t)??1}const Mc={Repository:"galaxy",Directory:"dir",File:"file"};function co(e){return Mc[e]??e}const jc={galaxy:"◎",dir:"▤",file:"▯",Function:"ƒ",Class:"◆",Interface:"◇",Enum:"≡",Variable:"•"},Ac="○";function Tc(e){return jc[co(e)]??Ac}function Cc(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ic(e){return`var(--color-node-${Cc(co(e))})`}function Rc(e){return`reposkein-${(e??"repo").replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"repo"}.png`}let _t=null;function ao(){_t?.()}function zc({repoId:e}){const{gl:t,scene:n,camera:o,invalidate:s}=Sn();return S.useEffect(()=>(_t=()=>{try{t.render(n,o)}catch{}const r=t.domElement,c=Rc(e),i=()=>s(),a=(u,l)=>{const f=document.createElement("a");f.href=u,f.download=c,document.body.appendChild(f),f.click(),f.remove(),l&&setTimeout(()=>URL.revokeObjectURL(u),1e3)};try{typeof r.toBlob=="function"?r.toBlob(u=>{u?a(URL.createObjectURL(u),!0):a(r.toDataURL("image/png"),!1),i()},"image/png"):(a(r.toDataURL("image/png"),!1),i())}catch{i()}},()=>{_t=null}),[t,n,o,e,s]),null}const Lc='a[href], button:not([disabled]):not([tabindex="-1"]), input:not([disabled]), [tabindex]:not([tabindex="-1"])',Kc=8,Dc=2,Pc=24,Fc=6,mn={recent:"Recent",symbols:"Symbols",files:"Files",directories:"Directories",commands:"Commands"},Bc=["recent","symbols","files","directories","commands"];function kt(e){return e.kind==="command"&&e.disabled}function $c(){const e=te(),t=S.useId(),[n,o]=S.useState(!1),[s,r]=S.useState(""),[c,i]=S.useState(0),[a,u]=S.useState(!1),[l,f]=S.useState([]),y=S.useRef(null),g=S.useRef(null),p=S.useRef(null),m=S.useRef(null),x=e.model,h=S.useMemo(()=>_c(),[]),_=S.useMemo(()=>x?Ec(x):new Map,[x]),w=s.startsWith(">"),v=(w?s.slice(1):s).trim().toLowerCase(),b=s.trim(),k=S.useCallback(()=>{o(!1),ft(!1),r(""),u(!1),i(0),m.current?.focus({preventScroll:!0})},[]),M=S.useCallback(()=>{m.current=document.activeElement,o(!0),ft(!0)},[]);S.useEffect(()=>()=>ft(!1),[]),S.useEffect(()=>{const E=N=>{(N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"&&(N.preventDefault(),n?k():M())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[n,k,M]),S.useEffect(()=>{n&&y.current?.focus({preventScroll:!0})},[n]);const j=S.useMemo(()=>{const E={symbols:[],files:[],directories:[]};if(w||!x||b.length<Dc)return E;const N=a?[...x.records.values()].filter(O=>O.kind==="file"):x.records.values(),I=ro(N,b,Pc),R=E;for(const O of I){const C=xc(O.rec.kind);R[C].length>=Fc||R[C].push({kind:"node",group:C,id:O.rec.id,name:O.rec.name||O.rec.id,nodeKind:O.rec.kind,filePath:O.rec.filePath})}return R},[w,x,b,a]),P=S.useMemo(()=>{if(w)return[];const E=b.toLowerCase();return l.filter(N=>E.length===0||N.name.toLowerCase().includes(E)||N.filePath.toLowerCase().includes(E)).map(N=>({kind:"node",group:"recent",id:N.id,name:N.name,nodeKind:N.kind,filePath:N.filePath}))},[w,l,b]),L=S.useMemo(()=>h.filter(E=>v.length===0?!0:`${E.label} ${E.subtitle??""}`.toLowerCase().includes(v)).map(E=>({kind:"command",group:"commands",cmd:E,disabled:E.disabled(e)})),[h,v,e]),F=S.useMemo(()=>{const E={recent:P,symbols:j.symbols,files:j.files,directories:j.directories,commands:L};return Bc.map(N=>({group:N,rows:E[N]})).filter(N=>N.rows.length>0)},[P,j,L]),z=S.useMemo(()=>F.flatMap(E=>E.rows),[F]),J=z.length===0;S.useEffect(()=>{i(0)},[s,a]),S.useEffect(()=>{c>=z.length&&i(Math.max(0,z.length-1))},[z.length,c]),S.useEffect(()=>{const E=p.current,N=E?.querySelector('[data-active="true"]');if(!E||!N)return;const I=E.getBoundingClientRect(),R=N.getBoundingClientRect();R.top<I.top?E.scrollTop-=I.top-R.top:R.bottom>I.bottom&&(E.scrollTop+=R.bottom-I.bottom)},[c]);function se(E){const N=z.length;if(N===0)return;let I=c;for(let R=0;R<N&&(I=(I+E+N)%N,!!kt(z[I]));R++);i(I)}const re=S.useMemo(()=>({screenshot:()=>ao(),copyLink:()=>{try{navigator.clipboard?.writeText(window.location.href)}catch{}}}),[]),he=S.useCallback((E,N)=>{if(!(!E||kt(E))){if(E.kind==="command"){E.cmd.run(e,e,re),k();return}f(I=>kc(I,{id:E.id,name:E.name,kind:E.nodeKind,filePath:E.filePath},Kc)),e.revealAndSelect(E.id,{fly:N.fly}),k()}},[e,re,k]);function A(E){switch(E.key){case"ArrowDown":E.preventDefault(),se(1);break;case"ArrowUp":E.preventDefault(),se(-1);break;case"Enter":E.preventDefault(),he(z[c],{fly:!(E.metaKey||E.ctrlKey)});break;case"Escape":E.preventDefault(),k();break}}function T(E){if(E.key==="Escape"){E.preventDefault(),k();return}if(E.key!=="Tab")return;const N=g.current;if(!N)return;const I=Array.from(N.querySelectorAll(Lc));if(I.length===0)return;const R=I[0],O=I[I.length-1],C=N.ownerDocument.activeElement;E.shiftKey&&C===R?(E.preventDefault(),O.focus({preventScroll:!0})):!E.shiftKey&&C===O&&(E.preventDefault(),R.focus({preventScroll:!0}))}if(!n)return null;const K=`${t}-listbox`,U=z[c]?`${t}-row-${c}`:void 0,ne=J?w?`No commands match "${v}"`:`No matches for "${s}"`:`${z.length} result${z.length===1?"":"s"}`;let $=-1;return d.jsxs(d.Fragment,{children:[d.jsx("div",{"aria-hidden":"true",onMouseDown:k,className:"fixed inset-0 z-[200] bg-black/50 backdrop-blur-[2px]"}),d.jsxs("div",{ref:g,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:[d.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:[d.jsx("span",{"aria-hidden":"true",className:"text-[13px] opacity-50",children:"⌘K"}),d.jsx("label",{htmlFor:`${t}-input`,className:"sr-only",children:"Search symbols, files, directories, or type > for commands"}),d.jsx("input",{ref:y,id:`${t}-input`,role:"combobox","aria-expanded":"true","aria-controls":K,"aria-activedescendant":U,"aria-autocomplete":"list",value:s,onChange:E=>r(E.target.value),onKeyDown:A,placeholder:"Search or type > for commands…",className:"min-w-0 flex-1 bg-transparent text-[13px] text-[var(--color-brand-cream)] placeholder:opacity-45 focus:outline-none"}),a&&d.jsx("button",{type:"button",onClick:()=>u(!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 ✕"})]}),d.jsxs("div",{ref:p,className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:[d.jsx("div",{id:K,role:"listbox","aria-label":"Results",children:!J&&F.map(({group:E,rows:N})=>d.jsxs("div",{role:"group","aria-label":mn[E],className:"mb-1 last:mb-0",children:[d.jsx("p",{className:"px-2 pb-1 pt-1.5 text-[10px] font-medium uppercase tracking-wider opacity-45",children:mn[E]}),N.map(I=>{$+=1;const R=$;return d.jsx(Hc,{rowId:`${t}-row-${R}`,row:I,active:R===c,confidenceIndex:_,onHover:()=>i(R),onCommit:O=>{i(R),he(I,{fly:O})}},`${I.group}-${I.kind==="command"?I.cmd.id:I.id}`)})]},E))}),J&&d.jsx(Oc,{query:s,isCommandMode:w,filesOnly:a,onSearchFilesOnly:()=>u(!0)})]}),d.jsx("div",{"aria-live":"polite",className:"sr-only",children:ne}),d.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-55",children:[d.jsxs("span",{className:"hidden items-center gap-1 sm:inline-flex",children:[d.jsx(Me,{children:"↑"}),d.jsx(Me,{children:"↓"})," navigate"]}),d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(Me,{children:"↵"})," go"]}),d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(Me,{children:"⌘↵"})," reveal only"]}),d.jsxs("span",{className:"inline-flex items-center gap-1",children:[d.jsx(Me,{children:"esc"})," close"]}),d.jsx("span",{className:"ml-auto shrink-0 tabular-nums",children:z.length})]})]})]})}function Oc({query:e,isCommandMode:t,filesOnly:n,onSearchFilesOnly:o}){return d.jsxs("div",{className:"flex flex-col items-center px-3 py-10 text-center",children:[d.jsx("p",{className:"text-[13px] font-medium",children:t?`No commands match "${e.slice(1).trim()}"`:`No matches for "${e}"`}),d.jsx("p",{className:"mt-1 max-w-xs text-[11px] opacity-60",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&&d.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 Hc({rowId:e,row:t,active:n,confidenceIndex:o,onHover:s,onCommit:r}){const c=kt(t),i="flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-[8px] px-2.5 py-1.5 text-left transition-colors",a=c?"cursor-not-allowed opacity-40":n?"bg-white/10":"bg-transparent hover:bg-white/5",u=f=>{f.preventDefault(),!c&&r(!(f.metaKey||f.ctrlKey))};if(t.kind==="command"){const f=c?t.cmd.disabledReason??t.cmd.subtitle:t.cmd.subtitle;return d.jsxs("div",{id:e,role:"option","aria-selected":n,"aria-disabled":c,"data-active":n,onPointerMove:c?void 0:s,onMouseDown:u,className:`${i} ${a}`,children:[d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block truncate text-[13px] font-medium",children:t.cmd.label}),f&&d.jsx("span",{className:"block truncate text-[11px] opacity-55",children:f})]}),t.cmd.kbd&&d.jsx(Me,{children:t.cmd.kbd})]})}const l=Nc(o,t.id);return d.jsxs("div",{id:e,role:"option","aria-selected":n,"data-active":n,onPointerMove:s,onMouseDown:u,className:`${i} ${a}`,title:t.filePath||t.name,children:[d.jsx("span",{"aria-hidden":"true",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full",style:{backgroundColor:Ic(t.nodeKind)}}),d.jsx("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-center text-[12px] opacity-70",children:Tc(t.nodeKind)}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"block truncate text-[13px] font-medium",children:t.name}),t.filePath&&d.jsx("span",{className:"block truncate font-mono text-[11px] opacity-55",children:t.filePath})]}),l<1&&d.jsx(qc,{value:l})]})}function qc({value:e}){return d.jsxs("span",{title:`Touched by a low-confidence edge (${Math.round(e*100)}%)`,className:"shrink-0 rounded-full border border-[rgba(255,180,84,0.4)] bg-[rgba(255,180,84,0.16)] px-1.5 py-0.5 text-[10px] font-medium text-[#ffd9a0] tabular-nums",children:[Math.round(e*100),"%"]})}function Me({children:e}){return d.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 Gc(){const e=te(),t=e.showLegend,n=S.useMemo(()=>e.model?Ni(e.model):[],[e.model]);return d.jsxs("div",{style:{position:"fixed",bottom:12,left:12,background:"rgba(20,22,28,0.88)",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",backdropFilter:"blur(8px)",color:"#fff",fontSize:11,width:180,zIndex:20},children:[d.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 10px",borderBottom:t?"1px solid rgba(255,255,255,0.07)":"none",cursor:"pointer",userSelect:"none"},onClick:()=>e.toggleLegend(),children:[d.jsx("span",{style:{fontWeight:600,fontSize:11,letterSpacing:1,opacity:.8},children:"LEGEND"}),d.jsx("span",{style:{opacity:.5},children:t?"▲":"▼"})]}),t&&d.jsxs("div",{style:{padding:"8px 10px"},children:[d.jsx("div",{style:{fontSize:10,opacity:.5,marginBottom:4},children:"NODE KIND"}),ai.map(({kind:o,color:s,label:r})=>d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[d.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",background:s,flexShrink:0}}),d.jsx("span",{style:{color:"rgba(255,255,255,0.75)"},children:r})]},o)),d.jsx("div",{style:{fontSize:10,opacity:.5,marginTop:8,marginBottom:4},children:"EDGE TYPE"}),ci.map(({type:o,color:s,label:r})=>d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[d.jsx("span",{style:{display:"inline-block",width:18,height:2,background:s,flexShrink:0,borderRadius:1}}),d.jsx("span",{style:{color:"rgba(255,255,255,0.75)"},children:r})]},o)),n.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{fontSize:10,opacity:.5,marginTop:8,marginBottom:4},children:"LANGUAGES"}),n.map(o=>d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},title:"Galaxy / nebula halos are tinted by their dominant language",children:[d.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",background:Jn(o),flexShrink:0}}),d.jsx("span",{style:{color:"rgba(255,255,255,0.75)"},children:Xr[o]??o})]},o))]}),d.jsx("div",{style:{marginTop:8,fontSize:10,opacity:.45,lineHeight:1.4,borderTop:"1px solid rgba(255,255,255,0.07)",paddingTop:6},children:"Edge opacity = confidence · halo tint = language"})]})]})}function Uc(){const e=te();return d.jsxs("div",{style:{position:"fixed",top:12,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:4,background:"rgba(20,22,28,0.88)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:8,padding:"4px 6px",backdropFilter:"blur(8px)",zIndex:25},children:[d.jsx("span",{style:{fontSize:10,letterSpacing:1,opacity:.5,color:"#fff",padding:"0 4px"},children:"LENS"}),jn.map(t=>{const n=Ve[t],o=e.lens===t;return d.jsx("button",{onClick:()=>e.setLens(t),title:n.hint,style:{background:o?"rgba(97,175,239,0.28)":"rgba(255,255,255,0.04)",border:`1px solid ${o?"#61afef":"rgba(255,255,255,0.12)"}`,color:o?"#cfe6ff":"rgba(255,255,255,0.7)",borderRadius:6,padding:"3px 10px",cursor:"pointer",fontSize:11,fontWeight:o?600:400,whiteSpace:"nowrap",transition:"all 0.12s"},children:n.label},t)})]})}function Wc(e){let t=1/0,n=-1/0,o=1/0,s=-1/0;const r=Math.floor(e.length/3);for(let c=0;c<r;c++){const i=e[c*3],a=e[c*3+1];i<t&&(t=i),i>n&&(n=i),a<o&&(o=a),a>s&&(s=a)}return Number.isFinite(t)?{minX:t,maxX:n,minY:o,maxY:s}:{minX:0,maxX:0,minY:0,maxY:0}}function Yc(e,t,n,o=6){const s=Math.max(e.maxX-e.minX,1e-6),r=Math.max(e.maxY-e.minY,1e-6),c=Math.max(t-o*2,1),i=Math.max(n-o*2,1),a=Math.min(c/s,i/r),u=(e.minX+e.maxX)/2,l=(e.minY+e.maxY)/2,f=t/2-u*a,y=n/2-l*a;return{bounds:e,scale:a,offsetX:f,offsetY:y,width:t,height:n}}function xn(e,t,n){const o=t*e.scale+e.offsetX,s=e.height-(n*e.scale+e.offsetY);return{px:o,py:s}}function Vc(e,t,n){const o=(t-e.offsetX)/e.scale,s=(e.height-n-e.offsetY)/e.scale;return{x:o,y:s}}const De=160,Pe=120;function Xc(){const e=te(),t=e.model,n=S.useRef(null),o=e.showMinimap,s=S.useMemo(()=>{if(!t)return null;const c=Wc(t.positions),i=Yc(c,De,Pe),a=Math.floor(t.positions.length/3),u=new Float32Array(a*2);for(let l=0;l<a;l++){const{px:f,py:y}=xn(i,t.positions[l*3],t.positions[l*3+1]);u[l*2]=f,u[l*2+1]=y}return{proj:i,pts:u,n:a}},[t]);if(S.useEffect(()=>{if(!o||!s)return;const c=n.current;if(!c)return;const i=Math.min(window.devicePixelRatio||1,2);c.width=De*i,c.height=Pe*i;const a=c.getContext("2d");if(!a)return;let u=0;const{proj:l,pts:f,n:y}=s,g=()=>{a.setTransform(i,0,0,i,0,0),a.clearRect(0,0,De,Pe),a.fillStyle="rgba(120,170,220,0.45)";for(let m=0;m<y;m++)a.fillRect(f[m*2]-.5,f[m*2+1]-.5,1.4,1.4);const p=pn();if(p){const{px:m,py:x}=xn(l,p.x,p.y);a.strokeStyle=B.amber,a.lineWidth=1.2,a.beginPath(),a.arc(m,x,5,0,Math.PI*2),a.stroke(),a.beginPath(),a.moveTo(m-8,x),a.lineTo(m+8,x),a.moveTo(m,x-8),a.lineTo(m,x+8),a.strokeStyle=`${B.amber}99`,a.stroke()}u=requestAnimationFrame(g)};return u=requestAnimationFrame(g),()=>cancelAnimationFrame(u)},[o,s]),!t)return null;const r=c=>{if(!s)return;const i=c.currentTarget.getBoundingClientRect(),a=(c.clientX-i.left)/i.width*De,u=(c.clientY-i.top)/i.height*Pe,{x:l,y:f}=Vc(s.proj,a,u),y=pn();Yi(l,f,y?y.z:0)};return d.jsxs("div",{style:{position:"absolute",left:12,bottom:12,background:"rgba(8,11,22,0.78)",border:"1px solid rgba(90,120,180,0.30)",borderRadius:8,padding:6,userSelect:"none"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:10,letterSpacing:.4,opacity:.6,marginBottom:o?4:0,gap:8},children:[d.jsx("span",{children:"OVERVIEW"}),d.jsx("button",{onClick:()=>e.toggleMinimap(),title:o?"Hide minimap":"Show minimap",style:{border:"none",background:"transparent",color:"rgba(180,200,230,0.7)",cursor:"pointer",fontSize:11,padding:0,lineHeight:1},children:o?"▾ hide":"▸ show"})]}),o&&d.jsx("canvas",{ref:n,onClick:r,title:"Click to recenter the view here",style:{display:"block",width:De,height:Pe,cursor:"crosshair",borderRadius:4}})]})}const Qc=new Set(["INHERITS","IMPLEMENTS"]),Zc=3;function Jc(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 c=0;for(const i of r.children)c+=1+n(i);return t.set(o,c),c};for(const o of e.byKey.keys())n(o);return t}function ea(e,t){let n=0,o=0;const s=c=>{const i=e.byKey.get(c);if(i){i.kind==="file"?n++:i.kind==="symbol"&&o++;for(const a of i.children)s(a)}},r=e.byKey.get(t);if(r)for(const c of r.children)s(c);return{files:n,symbols:o}}function Ue(e,t,n){return[...e].sort((o,s)=>{const r=t(o),c=t(s);if(r!==c)return c-r;const i=n(o),a=n(s);return i<a?-1:i>a?1:0})}function bn(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 ta(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 dt(e,t){return e.records.get(t)?.name||t}function ve(e,t){return`${e} ${t}${e===1?"":"s"}`}function na(e){const t=[],n=bn(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:`${ve(e.counts.nodes,"node")} · ${ve(e.counts.edges,"edge")} · ${ve(n,"module")}`}});const o=Jc(e),s=Ue(bn(e),p=>o.get(p.key)??0,p=>p.key).slice(0,Zc);for(const p of s){const{files:m,symbols:x}=ea(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:`${ve(m,"file")}, ${ve(x,"symbol")}`}})}const r=ta(e),c=[...r.entries()].map(([p,m])=>({id:p,total:m.in+m.out,in:m.in})),a=Ue(c,p=>p.total,p=>p.id)[0];a&&a.total>0&&t.push({id:`hub:${a.id}`,kind:"node",targetKey:a.id,expandKeys:[],expandDepth:0,lens:"calls",focusNodeId:a.id,collapsePrevious:!0,caption:{title:dt(e,a.id),body:`called from ${ve(a.in,"place")}`}});const u=new Map;for(const p of e.drawEdges)Qc.has(p.type)&&(u.set(p.from,(u.get(p.from)??0)+1),u.set(p.to,(u.get(p.to)??0)+1));const l=[...u.entries()].filter(([p])=>{const m=e.records.get(p)?.kind;return m==="Class"||m==="Interface"}).map(([p,m])=>({id:p,count:m})),f=Ue(l,p=>p.count,p=>p.id)[0];if(f&&f.count>0){const p=e.records.get(f.id)?.kind??"Type";t.push({id:`type:${f.id}`,kind:"node",targetKey:f.id,expandKeys:[],expandDepth:0,lens:"types",focusNodeId:f.id,collapsePrevious:!0,caption:{title:dt(e,f.id),body:`${p} · ${ve(f.count,"type link")}`}})}const y=[...r.entries()].filter(([p])=>e.records.get(p)?.kind==="Function"&&p!==a?.id).map(([p,m])=>({id:p,out:m.out})),g=Ue(y,p=>p.out,p=>p.id)[0];return g&&g.out>0&&t.push({id:`entry:${g.id}`,kind:"node",targetKey:g.id,expandKeys:[],expandDepth:0,lens:"calls",focusNodeId:g.id,collapsePrevious:!0,caption:{title:dt(e,g.id),body:`calls out to ${ve(g.out,"place")}`}}),t}function oa(e,t,n){const o=t.collapsePrevious?new Set([e.rootKey]):new Set(n),s=[],r=c=>{o.has(c)||(o.add(c),s.push(c))};if(t.kind==="module")for(const c of t.expandKeys){const i=e.byKey.get(c);i&&i.children.length>0&&r(c)}else if(t.focusNodeId)for(const c of Nn(e,t.focusNodeId))r(c);return s}const sa=5500;function ra(){const e=te(),t=e.model,n=e.tour,o=S.useMemo(()=>t?na(t):[],[t]),[s,r]=S.useState(0),[c,i]=S.useState(!0),[a,u]=S.useState(!1),l=S.useCallback(x=>{t&&(x.collapsePrevious&&e.resetExpansion(),e.setLens(x.lens),e.revealWithoutRefit(oa(t,x,e.expanded)),x.focusNodeId?(e.select(x.focusNodeId),e.toggleFocus()):e.select(null),e.setFocusTarget(x.targetKey))},[t,e]),f=S.useCallback(x=>{if(o.length===0)return;const h=Math.max(0,Math.min(o.length-1,x));r(h),l(o[h])},[o,l]),y=S.useRef(!1);if(S.useEffect(()=>{n&&!y.current&&(r(0),i(!0),o.length>0&&l(o[0])),y.current=n},[n,o,l]),S.useEffect(()=>{if(!n)return;u(!1);const x=setTimeout(()=>u(!0),60);return()=>clearTimeout(x)},[s,n]),S.useEffect(()=>{if(!n||!c)return;const x=setTimeout(()=>{s<o.length-1?f(s+1):i(!1)},sa);return()=>clearTimeout(x)},[n,c,s,o.length,f]),S.useEffect(()=>{if(!n)return;const x=h=>{if(h.key==="Escape"){if(wc())return;h.stopImmediatePropagation(),e.exitTour()}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[n,e]),!t||o.length===0)return null;if(!n)return d.jsx("button",{onClick:()=>e.startTour(),title:"Take a guided cinematic tour of the constellation",style:{padding:"2px 10px",fontSize:11,borderRadius:5,border:`1px solid ${B.teal}66`,background:`${B.teal}1f`,color:B.cream,cursor:"pointer",letterSpacing:.3},children:"▶ Tour"});const g=o[s],p=s===0,m=s===o.length-1;return d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{position:"fixed",bottom:88,left:"50%",transform:`translateX(-50%) translateY(${a?0:8}px)`,width:"min(520px, calc(100vw - 48px))",opacity:a?1:0,transition:"opacity 0.45s ease, transform 0.45s ease",pointerEvents:"none",zIndex:40,textAlign:"center"},children:d.jsxs("div",{style:{display:"inline-block",maxWidth:"100%",padding:"14px 22px",borderRadius:12,background:"rgba(8,11,22,0.86)",border:`1px solid ${B.amber}44`,boxShadow:`0 8px 32px rgba(0,0,0,0.5), 0 0 28px ${B.amber}1a`,backdropFilter:"blur(10px)"},children:[d.jsxs("div",{style:{fontSize:10,letterSpacing:2,textTransform:"uppercase",color:B.teal,opacity:.85,marginBottom:6},children:["Guided tour · stop ",s+1," / ",o.length]}),d.jsx("div",{style:{fontSize:19,fontWeight:600,color:B.cream,letterSpacing:.3,wordBreak:"break-word"},children:g.caption.title}),d.jsx("div",{style:{fontSize:13,color:"rgba(200,210,235,0.82)",marginTop:4},children:g.caption.body})]})}),d.jsxs("div",{style:{position:"fixed",bottom:26,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderRadius:999,background:"rgba(8,11,22,0.9)",border:"1px solid rgba(90,120,180,0.35)",backdropFilter:"blur(10px)",zIndex:41},children:[d.jsx(We,{label:"⟨ Prev",disabled:p,onClick:()=>f(s-1)}),d.jsx(We,{label:c?"❚❚ Pause":"▶ Play",primary:!0,onClick:()=>i(x=>!x)}),d.jsx(We,{label:"Next ⟩",disabled:m,onClick:()=>{i(!1),f(s+1)}}),d.jsx("div",{style:{display:"flex",gap:4,margin:"0 6px"},children:o.map((x,h)=>d.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:h===s?B.amber:"rgba(255,255,255,0.25)",transition:"background 0.3s"}},x.id))}),d.jsx(We,{label:"✕ Exit",onClick:()=>e.exitTour()})]})]})}function We({label:e,onClick:t,disabled:n,primary:o}){return d.jsx("button",{onClick:t,disabled:n,style:{padding:"4px 12px",fontSize:12,borderRadius:999,border:`1px solid ${o?B.amber+"88":"rgba(255,255,255,0.18)"}`,background:o?`${B.amber}26`:"rgba(255,255,255,0.05)",color:n?"rgba(255,255,255,0.3)":o?B.cream:"rgba(230,235,245,0.85)",cursor:n?"default":"pointer",letterSpacing:.3,whiteSpace:"nowrap"},children:e})}function ia(e,t){const n=new Set;for(const o of e)o.from===t&&o.to!==t?n.add(o.to):o.to===t&&o.from!==t&&n.add(o.from);return[...n].sort()}function ca(e,t,n,o){const s=ia(e,t);if(s.length===0)return null;const r=t,c=s.indexOf(r),i=s.length;return n==="next"?s[c===-1?0:(c+1)%i]:s[c===-1?i-1:(c-1+i)%i]}function vn(e){const t=e.match(/^rs1:[^:]+(:.+)$/);return t?t[1]:null}function aa(e,t){const n=vn(e);if(!n)return null;let o=null;for(const s of t)s!==e&&s.endsWith(n)&&vn(s)===n&&(o===null||s<o)&&(o=s);return o}function la(e){return e.length>7?e.slice(0,7):e}function ua(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 c=Math.floor(r/60);if(c<24)return`${c}h ago`;const i=Math.floor(c/24);if(i<30)return`${i}d ago`;const a=Math.floor(i/30);return a<12?`${a}mo ago`:`${Math.floor(a/12)}y ago`}function fa(e,t=Date.now()){if(!e||!e.commitSha)return null;const n=la(e.commitSha),o=e.builtAt?ua(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 wn(e){const t=e?.pagesUrl?.trim();return t||null}function da(){return d.jsx(qr,{children:d.jsx(pa,{})})}function pa(){const e=te(),t=yo({from:"/"}),n=mo({from:"/"}),o=t.node;S.useEffect(()=>{const c=i=>{const a=i.target,u=a&&(a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable);if(e.tour)return;if(i.key==="Escape"){u||e.collapseLevel();return}if(u)return;if(i.key==="/"){i.preventDefault(),document.getElementById("reposkein-search")?.focus();return}if(i.key==="f"||i.key==="F"){i.preventDefault(),e.resetView();return}const l=e.model;if(!l||!e.selected)return;let f=null;if(i.key==="ArrowRight"||i.key==="ArrowDown"?f="next":i.key==="ArrowLeft"||i.key==="ArrowUp"?f="prev":i.key==="Tab"&&(f=i.shiftKey?"prev":"next"),!f)return;i.preventDefault();const y=ca(l.drawEdges,e.selected,f);y&&e.revealAndSelect(y,{fly:!0})};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e]);const[s,r]=S.useState(null);return S.useEffect(()=>{if(!e.model||!o)return;const c=e.model;let i=o;if(!c.records.has(i)){const a=aa(i,c.records.keys());if(!a){r(o);return}i=a}r(null),e.revealAndSelect(i,{fly:!0})},[e.model,o]),S.useEffect(()=>{if(!e.coupling||e.cochange!==null)return;let c=!1;return Zi().then(i=>{c||e.setCochange(i)}),()=>{c=!0}},[e.coupling,e.cochange]),S.useEffect(()=>{n({search:e.selected?{node:e.selected}:{},replace:!0})},[e.selected]),d.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[d.jsx("div",{style:{position:"absolute",inset:0,background:"radial-gradient(ellipse 80% 60% at 50% 38%, #16204a 0%, #0a1024 42%, #05060c 78%, #02030a 100%)",pointerEvents:"none"}}),d.jsxs(Ao,{camera:{position:[0,0,160],fov:55,near:.1,far:6e3},frameloop:"demand",gl:{antialias:!0,preserveDrawingBuffer:!0},style:{background:"transparent"},onPointerMissed:c=>{c.button===0&&e.collapseLevel()},children:[d.jsx("fogExp2",{attach:"fog",args:[461330,.0016]}),d.jsx("ambientLight",{intensity:.6}),d.jsx(_i,{}),e.status.kind==="ready"&&e.model&&d.jsxs(d.Fragment,{children:[d.jsx(ji,{}),d.jsx(Ii,{}),d.jsx(bi,{}),d.jsx(Pi,{}),d.jsx(Gi,{}),d.jsx(tc,{}),e.showLabels&&d.jsx(Wi,{})]}),d.jsx(Qi,{}),d.jsx(zc,{repoId:e.model?.repoId}),d.jsx(To,{children:d.jsx(Co,{luminanceThreshold:.2,luminanceSmoothing:.4,intensity:.9,mipmapBlur:!0})})]}),d.jsx(ha,{}),d.jsx($c,{}),s&&d.jsx(ma,{nodeId:s,onDismiss:()=>r(null)}),e.status.kind==="ready"&&e.model&&d.jsx(xa,{}),e.status.kind==="ready"&&d.jsx(oc,{}),e.status.kind==="ready"&&d.jsx(Uc,{}),e.status.kind==="ready"&&d.jsx(uc,{}),e.status.kind==="ready"&&d.jsx(Gc,{}),e.status.kind==="ready"&&e.model&&d.jsx(Xc,{}),d.jsx(ba,{}),e.status.kind==="error"&&d.jsx(va,{text:`Error: ${e.status.message}`,error:!0})]})}function ha(){const e=te(),t=e.model?.counts;return d.jsxs("div",{style:{position:"absolute",top:12,left:12,fontSize:13,padding:"8px 12px",borderRadius:8,background:"rgba(8,11,22,0.85)",border:"1px solid rgba(90,120,180,0.35)"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[d.jsx("span",{style:{fontWeight:600,color:B.amber},children:"RepoSkein Constellation"}),e.model&&d.jsx("button",{onClick:()=>e.resetView(),title:"Frame all — collapse to top level",style:{marginLeft:8,padding:"2px 10px",fontSize:11,borderRadius:5,border:`1px solid ${B.amber}66`,background:`${B.amber}1f`,color:B.cream,cursor:"pointer",letterSpacing:.3},children:"Frame all"}),e.model&&d.jsx("button",{onClick:()=>ao(),title:"Capture a PNG screenshot of the current view",style:{padding:"2px 10px",fontSize:11,borderRadius:5,border:`1px solid ${B.teal}66`,background:`${B.teal}1f`,color:B.cream,cursor:"pointer",letterSpacing:.3},children:"Screenshot"}),e.model&&wn(e.model.repoMeta)&&d.jsx("a",{href:wn(e.model.repoMeta),target:"_blank",rel:"noreferrer",title:"Open this team's published constellation (configured in .reposkein/config.toml [team] pages_url)",style:{padding:"2px 10px",fontSize:11,borderRadius:5,border:`1px solid ${B.amber}66`,background:`${B.amber}1f`,color:B.cream,cursor:"pointer",letterSpacing:.3,textDecoration:"none"},children:"Team constellation ↗"}),e.model&&d.jsx(ra,{})]}),e.model&&d.jsxs("div",{style:{fontSize:11,opacity:.75,marginTop:2},children:[e.model.repoId," · ",t?.nodes??0," nodes · ",t?.edges??0," edges"]}),e.model&&d.jsx(ya,{}),e.model&&d.jsx(ga,{}),d.jsx("div",{style:{fontSize:11,opacity:.55,marginTop:2},children:"scroll = zoom · drag = orbit · click cluster = expand · click star = inspect · Esc / click space = back"}),d.jsx("div",{style:{fontSize:11,opacity:.45,marginTop:1},children:"keys: / search · ⌘K commands · f frame all · ←→ / Tab hop neighbor"}),e.model&&d.jsx(vc,{})]})}function ga(){const{drawn:e,total:t}=Ur();return t<=0?null:d.jsxs("div",{style:{fontSize:11,opacity:.6,marginTop:1},title:"Edge bundles currently drawn / total bundles before the render cap",children:["showing ",e," of ",t," connections",e<t?" (capped)":""]})}function ya(){const e=te(),t=fa(e.model?.repoMeta??null);if(!t)return null;const n=d.jsx("span",{style:{color:"rgba(200,210,235,0.85)"},title:e.model?.repoMeta?.builtAt?`baked ${e.model.repoMeta.builtAt}`:void 0,children:t.label});return d.jsx("div",{style:{fontSize:11,opacity:.75,marginTop:1},children:t.href?d.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer",style:{color:"inherit",textDecoration:"none"},children:n}):n})}function ma({nodeId:e,onDismiss:t}){return d.jsxs("div",{style:{position:"absolute",top:12,right:12,maxWidth:320,fontSize:12,padding:"8px 12px",borderRadius:8,background:"rgba(8,11,22,0.9)",border:`1px solid ${B.amber}66`,color:B.cream,display:"flex",alignItems:"flex-start",gap:8},children:[d.jsxs("span",{style:{flex:1},children:["Node not found — it may have been renamed or removed.",d.jsx("span",{style:{display:"block",opacity:.6,fontSize:11,marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e,children:e})]}),d.jsx("button",{onClick:t,title:"Dismiss",style:{background:"transparent",border:"none",color:B.cream,opacity:.7,cursor:"pointer",fontSize:13,lineHeight:1,padding:0},children:"✕"})]})}function xa(){const e=te(),t=e.model;if(!e.selected)return null;const n=t.clusterOfNode.get(e.selected)??e.selected,o=t.ancestors.get(n)??[n],s=o.map(i=>{const a=t.byKey.get(i);return{key:i,label:a?.name??i}}),r=t.records.get(e.selected);r&&!t.byKey.has(e.selected)&&s.push({key:e.selected,label:r.name});function c(i){o.indexOf(i)!==-1&&e.revealAndSelect(i,{fly:!0,collapseDeeper:!0})}return d.jsx("div",{style:{position:"absolute",top:132,left:12,display:"flex",alignItems:"center",gap:4,fontSize:12,background:"rgba(8,11,22,0.78)",border:"1px solid rgba(90,120,180,0.25)",borderRadius:6,padding:"4px 10px",maxWidth:"calc(100vw - 420px)",overflow:"hidden",flexWrap:"nowrap"},children:s.map((i,a)=>d.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[a>0&&d.jsx("span",{style:{opacity:.4,flexShrink:0},children:"›"}),d.jsx("span",{onClick:()=>c(i.key),style:{cursor:a<s.length-1?"pointer":"default",color:a===s.length-1?"#dfe6f5":"rgba(160,180,220,0.7)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200},title:i.label,children:i.label})]},i.key))})}function ba(){const e=te(),t=e.status.kind==="loading",n=e.status.kind==="loading"?e.status.phase:"",[o,s]=S.useState(!0),[r,c]=S.useState(!0);return S.useEffect(()=>{if(t){s(!0),c(!0);return}c(!1);const i=setTimeout(()=>s(!1),700);return()=>clearTimeout(i)},[t]),o?d.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:18,pointerEvents:"none",opacity:r?1:0,transition:"opacity 0.7s ease",background:"radial-gradient(ellipse 60% 50% at 50% 50%, rgba(5,6,12,0.55) 0%, rgba(5,6,12,0) 70%)"},children:[d.jsx("style",{children:`@keyframes rs-pulse {
6
+ 0%,100% { transform: scale(0.9); opacity: 0.55; }
7
+ 50% { transform: scale(1.12); opacity: 1; }
8
+ }
9
+ @keyframes rs-spin { to { transform: rotate(360deg); } }`}),d.jsxs("div",{style:{position:"relative",width:64,height:64},children:[d.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:`2px solid ${B.teal}55`,borderTopColor:B.amber,animation:"rs-spin 1.6s linear infinite"}}),d.jsx("div",{style:{position:"absolute",inset:18,borderRadius:"50%",background:`radial-gradient(circle, ${B.amber} 0%, ${B.amber}00 70%)`,animation:"rs-pulse 1.8s ease-in-out infinite"}})]}),d.jsxs("div",{style:{textAlign:"center"},children:[d.jsx("div",{style:{fontSize:15,color:B.cream,letterSpacing:.4},children:"Charting the constellation…"}),n&&d.jsx("div",{style:{fontSize:11,color:"rgba(160,180,220,0.6)",marginTop:4},children:n})]})]}):null}function va({text:e,error:t}){return d.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",color:t?"#ff8a8a":"#cdd6ea",fontSize:15},children:e})}const wa=new xo,lo=bo({component:()=>d.jsx(Eo,{})}),Sa=vo({getParentRoute:()=>lo,path:"/",validateSearch:e=>({node:typeof e.node=="string"?e.node:void 0}),component:da}),_a=lo.addChildren([Sa]),ka=wo({routeTree:_a,history:tt()?So():void 0});Io.createRoot(document.getElementById("root")).render(d.jsx(S.StrictMode,{children:d.jsx(_o,{client:wa,children:d.jsx(ko,{router:ka})})}));