mirror of
https://github.com/dmduran12/pymc_console-dist.git
synced 2026-08-07 17:33:09 +02:00
025aa16b60
Automated sync from private repository. Commit: bb168aeaa2461ee0de1b68b0cee97d51b0cbdf2c
2 lines
40 KiB
JavaScript
2 lines
40 KiB
JavaScript
import{r as e,j as t,p as s,q as a}from"./vendor-react-54o2BuWt.js";import{c as n,r,b0 as o,v as i,b1 as l,b2 as c,f as d,aL as u,aY as h,T as m,b3 as x,b4 as p,A as g,m as f,X as b,R as y,b5 as v,B as j,G as w}from"./index-W7HOJkA3.js";import{D as k,E as C,M as N,a as S}from"./DeepAnalysisModal-vgXPCYfu.js";import{D as M}from"./DataBox-B3hWOq8z.js";import{L}from"./loader-circle-BFq8BFSi.js";import{E as F,S as D,T as H}from"./target-Jq9nqARB.js";import{C as E,Z as P}from"./zap-BAnS4MDP.js";import{G as B}from"./git-branch-vNLafFY9.js";import{H as $}from"./house-BPur0bhT.js";import{N as R}from"./network-DlyPXQyX.js";import{C as z}from"./chevron-right-B-fW81Tj.js";import"./deckgl-DTsmDcfs.js";import"./vendor-core-dnrJb0w-.js";const I=n("arrow-down-up",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]),G=n("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),T=n("focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]),A=n("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),Z=n("tally-5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);function O(t,s=1e3){const[a,n]=e.useState(t),r=e.useRef(Date.now()),o=e.useRef(null);return e.useEffect(()=>{const e=Date.now(),a=s-(e-r.current);return a<=0?(n(t),r.current=e):(o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{n(t),r.current=Date.now()},a)),()=>{o.current&&clearTimeout(o.current)}},[t,s]),a}const W=Math.PI/180;let V=null,q=0;function K(){const e=Date.now();if(V&&e-q<1e3)return V;q=e;const t=getComputedStyle(document.documentElement).getPropertyValue("--accent-primary").trim();if(t.startsWith("color(display-p3")){const e=t.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);if(e){const t=Math.round(255*parseFloat(e[1])),s=Math.round(255*parseFloat(e[2])),a=Math.round(255*parseFloat(e[3]));return V=`#${t.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`,V}}if(t.startsWith("rgb")){const e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){const t=parseInt(e[1]),s=parseInt(e[2]),a=parseInt(e[3]);return V=`#${t.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`,V}}return V=t.startsWith("#")?t:"#719CDF",V}function _(e,t){if(e<=0)return 0;const s=t-e;if(s>1209600)return 0;if(s<0)return 1;const a=s/3600;return Math.exp(-a/12)}const Y={spaceSize:4096,simulationRepulsion:1.2,simulationLinkDistance:30,simulationGravity:.2,simulationCenter:.5,simulationFriction:.92,simulationDecay:600,simulationLinkSpring:.6,simulationClusterStrength:.5,simulationRepulsionTheta:1.5};function J(e,t,s,a,n=3){const r=e<=0?0:Math.log10(e+1),o=Math.log10(5001),i=Math.min(1,r/o),l=6+18*Math.pow(i,n);if(a)return l;const c=s-t;return c>=te?Math.max(6,.5*l):c>=ee?Math.max(6,.7*l):l}const U={local:"#FFFFFF",hub:"#E0E0E0",gateway:"#C8C8C8",backbone:"#B0B0B0",neighbor:"#F0F0F0",mobile:"#A0A0A0",ghost:"#505050",standard:"#808080"},X={local:"Local Node",hub:"Hub (≥10% traffic)",gateway:"Gateway (7-10%)",backbone:"Backbone",neighbor:"Direct RF Neighbor",mobile:"Mobile/Volatile",ghost:"Discovered (unconfirmed)",standard:"Standard Node"},Q={local:$,hub:P,gateway:B,backbone:B,neighbor:y,mobile:A,ghost:E,standard:G},ee=432e3,te=864e3;function se(e,t,s,a,n={x:0,y:0}){const r=e*W,o=s*W,i=(t-a)*W,l=(e-s)*W,c=637100;return n.x=i*Math.cos(.5*(r+o))*c,n.y=l*c,n}const ae={background:`linear-gradient(to right, ${["#2A2A2A","#3D3D3D","#505050","#636363","#767676","#898989","#9C9C9C","#AFAFAF","#C2C2C2","#D5D5D5","#E8E8E8","#F5F5F5","#FFFFFF"].join(", ")})`},ne=["#FBBF24","#F97316","#EF4444","#A855F7","#3B82F6","#6366F1","#6B7280"],re=["Local","1-hop","2-hop","3-hop","4-hop","5-hop","6+"],oe=e.memo(function({nodeCount:s,edgeCount:a,layoutMode:n,hopStats:r}){const[o,i]=e.useState(!0),l="backbone"===n;return t.jsxs(f.div,{className:"absolute top-4 right-0 z-10 flex items-stretch",initial:!1,animate:{x:o?0:180},transition:{duration:.25,ease:[.4,0,.2,1]},children:[t.jsxs("button",{onClick:()=>i(e=>!e),className:"relative flex items-center justify-center w-4 bg-bg-elevated/95 border-y border-l border-border-subtle rounded-l-md hover:bg-subtle-fill transition-colors shrink-0 group",title:o?"Hide legend":"Show legend",children:[t.jsx("span",{className:"absolute -inset-x-3 inset-y-0 min-h-[44px]","aria-hidden":"true"}),t.jsx(f.div,{animate:{rotate:o?0:180},transition:{duration:.2,ease:"easeOut"},children:t.jsx(z,{className:"w-3 h-3 text-text-muted group-hover:text-text-secondary transition-colors"})})]}),t.jsxs("div",{className:"bg-bg-elevated/95 border-y border-r border-border-subtle rounded-r-none shadow-xl type-data-xs overflow-hidden",style:{width:180},children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-subtle/50",children:[t.jsx("span",{className:"font-medium text-text-primary",children:l?"Hop Distance":"Topology"}),t.jsxs("span",{className:"text-text-muted tabular-nums whitespace-nowrap",children:[s,"n · ",a,"e"]})]}),t.jsx("div",{className:"px-3 py-2",children:l?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-text-muted text-[10px] mb-1.5",children:"Hops from local"}),t.jsx("div",{className:"space-y-1",children:ne.slice(0,Math.min(((null==r?void 0:r.maxHops)??3)+2,7)).map((e,s)=>{const a=(null==r?void 0:r.nodesPerHop.get(s))??0;return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e}}),t.jsx("span",{className:"text-[10px] text-text-secondary flex-1",children:re[s]}),t.jsx("span",{className:"text-[10px] text-text-muted tabular-nums",children:a})]},s)})}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-border-subtle/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-primary"}),t.jsx("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:"p99 traffic"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-text-muted text-[10px] mb-1",children:"Packet count"}),t.jsx("div",{className:"h-1 rounded-sm",style:ae}),t.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-0.5",children:[t.jsx("span",{children:"0"}),t.jsx("span",{children:"10K+"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-border-subtle/30",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-primary"}),t.jsx("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:"p99 outlier"})]})]})})]})]})}),ie="▁▂▃▄▅▆▇█",le=[-5,0,4,7],ce=[-115,-105,-95,-80],de=["text-signal-critical","text-signal-poor","text-accent-secondary","text-accent-secondary","text-accent-success"],ue=["text-signal-critical","text-signal-poor","text-accent-secondary","text-accent-success","text-accent-success"],he=["░░░░","▂░░░","▂▃░░","▂▄▅░","▂▄▆█"],me={active:{color:"green",label:"Active"},recent:{color:"yellow",label:"Recent"},stale:{color:"orange",label:"Stale"},inactive:{color:"zinc",label:"Offline"}},xe=(e,t,s=6)=>{const a=t?Math.min(1,e/t):0,n=Math.floor(a*s),r=Math.floor(8*(a*s-n));return ie[7].repeat(n)+(n<s&&r?ie[r-1]:"")+" ".repeat(Math.max(0,s-n-(r?1:0)))},pe=(e,t=10)=>"●".repeat(Math.round(e*t))+"○".repeat(t-Math.round(e*t)),ge=(e,t)=>{const s=t?de:ue,a=(t?le:ce).findIndex(t=>e<t);return[he[a<0?4:a],s[a<0?4:a]]},fe=e.memo(function({c:e,maxPkts:s}){const[a,n]=(e=>e.isZeroHop?["◉","text-yellow-400"]:e.isDirectPath?["→","text-cyan-400"]:e.isLoopEdge?["↺","text-purple-400"]:["─","text-text-muted"])(e);return t.jsxs("li",{className:"flex items-center gap-1.5 py-0.5 px-1 rounded hover:bg-subtle-fill/30 transition-colors",children:[t.jsx("span",{className:`w-3 text-center shrink-0 ${n}`,children:a}),t.jsx("span",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:U[e.nodeClass]}}),t.jsx("code",{className:"shrink-0 text-text-primary",children:e.prefix}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-text-muted",children:e.name||""}),t.jsx("span",{className:"text-accent-secondary tracking-tighter shrink-0",children:xe(e.packetCount,s,4)}),t.jsx("span",{className:"tabular-nums text-text-secondary shrink-0 w-8 text-right",children:e.packetCount>=1e3?`${(e.packetCount/1e3).toFixed(1)}k`:e.packetCount})]})}),be=e.memo(function({node:s,connections:a,onClose:n}){const r=e.useMemo(()=>Math.max(s.packetCount,...a.map(e=>e.packetCount),1),[s.packetCount,a]),o=e.useMemo(()=>[...a].sort((e,t)=>e.isZeroHop!==t.isZeroHop?e.isZeroHop?-1:1:e.isDirectPath!==t.isDirectPath?e.isDirectPath?-1:1:t.packetCount-e.packetCount),[a]),i=me[s.activityLevel]??{color:"zinc",label:s.activityLevel};return t.jsxs(f.div,{variants:v,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-4 bottom-4 z-20 bg-bg-elevated/95 rounded-xl border border-border-subtle shadow-xl",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle/50",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:U[s.nodeClass]}}),t.jsx("code",{className:"text-sm font-semibold text-text-primary shrink-0",children:s.prefix}),s.name&&t.jsx("span",{className:"text-sm text-text-secondary truncate",children:s.name}),t.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.isLocal&&t.jsx(j,{color:"yellow",compact:!0,children:"LOCAL"}),void 0!==s.hopDistance&&!s.isLocal&&t.jsxs(j,{color:1===s.hopDistance?"orange":2===s.hopDistance?"red":s.hopDistance<=3?"violet":"sky",compact:!0,children:[s.hopDistance,"-HOP"]}),s.isHub&&t.jsx(j,{color:"indigo",compact:!0,children:"HUB"}),s.isGateway&&t.jsx(j,{color:"violet",compact:!0,children:"GW"}),s.isBackbone&&t.jsx(j,{color:"emerald",compact:!0,children:"BONE"}),s.isMobile&&t.jsx(j,{color:"orange",compact:!0,children:"MOB"}),s.isZeroHop&&t.jsx(j,{color:"amber",compact:!0,children:"RF"})]})]}),t.jsx(w,{plain:!0,onClick:n,title:"Close",className:"shrink-0",children:t.jsx(b,{className:"size-4"})})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-3 font-mono text-[11px]",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(j,{color:i.color,compact:!0,children:i.label}),t.jsx("span",{className:"text-text-muted",children:"•"}),t.jsx("span",{className:"text-text-secondary",children:X[s.nodeClass]}),s.hasGeo&&t.jsx(j,{color:"cyan",compact:!0,children:"GPS"}),s.hasCollision&&t.jsx(j,{color:"red",compact:!0,children:"⚠ COLLISION"})]}),t.jsx(M,{copy:!0,size:"compact",truncate:[10,6],className:"w-full",children:s.hash}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase",children:"Packets"}),t.jsx("div",{className:"text-text-primary tabular-nums",children:s.packetCount.toLocaleString()}),t.jsx("div",{className:"text-accent-primary tracking-tighter",children:xe(s.packetCount,r,6)})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase",children:"Degree"}),t.jsx("div",{className:"text-text-primary tabular-nums",children:s.degree}),t.jsx("div",{className:"text-accent-secondary tracking-tighter",children:xe(s.degree,Math.max(s.degree,10),6)})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase",children:"Central"}),t.jsxs("div",{className:"text-text-primary tabular-nums",children:[(100*s.betweenness).toFixed(0),"%"]}),t.jsx("div",{className:"text-accent-primary tracking-tighter",children:pe(s.betweenness,6)})]})]}),s.isZeroHop&&(null!==s.avgRssi||null!==s.avgSnr)&&t.jsxs("div",{className:"flex gap-4 pt-2 border-t border-border-subtle/30",children:[null!==s.avgRssi&&(()=>{const[e,a]=ge(s.avgRssi,!1);return t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase",children:"RSSI"}),t.jsxs("div",{className:"flex items-baseline gap-1",children:[t.jsx("span",{className:`${a} tracking-tight`,children:e}),t.jsx("span",{className:"tabular-nums text-text-secondary",children:s.avgRssi.toFixed(0)}),t.jsx("span",{className:"text-[9px] text-text-muted",children:"dBm"})]})]})})(),null!==s.avgSnr&&(()=>{const[e,a]=ge(s.avgSnr,!0);return t.jsxs("div",{children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase",children:"SNR"}),t.jsxs("div",{className:"flex items-baseline gap-1",children:[t.jsx("span",{className:`${a} tracking-tight`,children:e}),t.jsx("span",{className:"tabular-nums text-text-secondary",children:s.avgSnr.toFixed(1)}),t.jsx("span",{className:"text-[9px] text-text-muted",children:"dB"})]})]})})()]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-[9px] text-text-muted uppercase",children:"Connections"}),t.jsx(j,{color:"zinc",compact:!0,children:a.length})]}),o.length>0?t.jsxs("ul",{className:"max-h-32 overflow-y-auto space-y-0.5 scrollbar-thin",children:[o.slice(0,20).map(e=>t.jsx(fe,{c:e,maxPkts:r},e.hash)),o.length>20&&t.jsxs("li",{className:"text-center text-text-muted py-1",children:["+",o.length-20," more"]})]}):t.jsx("p",{className:"text-text-muted italic",children:"No connections"})]}),t.jsxs("div",{className:"hidden lg:flex lg:flex-col lg:gap-3",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[void 0!==s.hopDistance&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Hop Dist"}),t.jsx("span",{className:"tabular-nums",style:{color:ne[Math.min(s.hopDistance,ne.length-1)]},children:0===s.hopDistance?"Local":`${s.hopDistance} hop${s.hopDistance>1?"s":""}`})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Cluster"}),t.jsxs("span",{className:"text-text-secondary",children:["#",s.communityId]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Edges"}),t.jsx("span",{className:"text-text-secondary",children:s.edgeCount})]}),s.hasCollision&&t.jsxs("div",{className:"flex justify-between col-span-2",children:[t.jsx("span",{className:"text-signal-poor",children:"Prefix Conf."}),t.jsxs("span",{className:"text-signal-poor tabular-nums",children:[(100*s.prefixConfidence).toFixed(0),"%"]})]})]}),t.jsxs("div",{className:"mt-auto pt-2 border-t border-border-subtle/30",children:[t.jsx("div",{className:"text-[9px] text-text-muted uppercase mb-1.5",children:"Edge Types"}),t.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-yellow-400",children:"◉"}),t.jsx("span",{className:"text-text-muted",children:"RF"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-cyan-400",children:"→"}),t.jsx("span",{className:"text-text-muted",children:"Direct"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-purple-400",children:"↺"}),t.jsx("span",{className:"text-text-muted",children:"Loop"})]})]})]})]})]})]})});function ye(){return t.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 text-center px-8",children:[t.jsx("div",{className:"p-4 rounded-full bg-subtle-fill",children:t.jsx(R,{className:"w-8 h-8 text-text-muted"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h2",{className:"text-lg font-medium text-text-primary",children:"No Topology Data"}),t.jsx("p",{className:"text-sm text-text-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed. This typically takes a few minutes after starting."})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted mt-2",children:[t.jsx(y,{className:"w-4 h-4 animate-pulse"}),t.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}function ve(){var n;const y=r(),[v,j]=e.useState(!1),w=o(),M=i(),[E,P]=e.useState(!1),[B,$]=e.useState("fetching"),[R,z]=e.useState(0),G=e.useRef(!1);e.useEffect(()=>{y&&!G.current&&(G.current=!0,(async()=>{P(!0),$("fetching"),z(0),await w(),$("analyzing"),await new Promise(e=>setTimeout(e,200)),$("building");const e=Date.now(),t=Date.now()-e;t<600&&await new Promise(e=>setTimeout(e,600-t)),$("discovering"),await new Promise(e=>setTimeout(e,400)),$("complete"),await new Promise(e=>setTimeout(e,800)),P(!1),j(!0)})())},[y,w]),e.useEffect(()=>{"fetching"===B&&(M.loadProgress?z(M.loadProgress.loaded):M.packetCount>0&&z(M.packetCount))},[B,M.loadProgress,M.packetCount]);const A=l(),W=O(c(),2e3),V=d(),q=u(),[X,ee]=e.useState(!0),[te,ae]=e.useState(null),ne=e.useRef(void 0),[re,ie]=e.useState(""),[le,ce]=e.useState(!1),de=e.useRef(null),[ue]=e.useState(1),[he]=e.useState(.15),[me]=e.useState(2.75),[xe]=e.useState(3),pe=O(me,300),ge=O(xe,300),fe=e.useRef(ue),ve=e.useRef(he);e.useEffect(()=>{fe.current=ue},[ue]),e.useEffect(()=>{ve.current=he},[he]);const je=e.useRef({node:null,x:0,y:0}),we=e.useRef(null),[ke,Ce]=e.useState(!1),[Ne,Se]=e.useState("force"),[Me,Le]=e.useState(!0);e.useEffect(()=>{const e=e=>{var t,s;if(!(e.target instanceof HTMLInputElement))switch(e.key.toLowerCase()){case"f":e.metaKey||e.ctrlKey||(e.preventDefault(),null==(t=Ue.current)||t.fitView(800));break;case"escape":le?(ce(!1),ie("")):te&&(ne.current=void 0,ae(null),null==(s=Ue.current)||s.unselectAllPoints());break;case"/":le||(e.preventDefault(),ce(!0),setTimeout(()=>{var e;return null==(e=de.current)?void 0:e.focus()},50));break;case" ":e.preventDefault();{const e=Ue.current;e&&(X?e.pause():e.start(),ee(e=>!e))}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[le,te,X]);const Fe=(null==q?void 0:q.latitude)??0,De=(null==q?void 0:q.longitude)??0,He=null!==q,[Ee,Pe]=e.useState(Math.floor(Date.now()/1e3));e.useEffect(()=>{const e=setInterval(()=>{Pe(Math.floor(Date.now()/1e3))},3e5);return()=>clearInterval(e)},[]);const Be=e.useMemo(()=>{var e;if(!W||0===W.size||!v)return[];const t=[],s=(null==V?void 0:V.node_name)??(null==(e=null==V?void 0:V.config)?void 0:e.node_name)??null,a={x:0,y:0},n=[];for(const r of W.values()){const e=r.isLocal?1:_(r.lastSeen,Ee);if(0===e&&!r.isLocal)continue;r.isLocal||n.push(r.packetCount);const o=r.packetCount>0?Math.log10(r.packetCount+1):0,i=Math.log10(5001),l=Math.min(1,o/i);let c;c=r.isLocal?4:l<.2?0:l<.4?1:l<.6?2:l<.8?3:4;const d="#FFFFFF",u=J(r.packetCount,r.lastSeen,Ee,r.isLocal,me),h=r.isLocal?s??r.name:r.name;let m,x,p=!1;He&&(r.isLocal?(m=0,x=0,p=!0):r.latitude&&r.longitude&&(se(r.latitude,r.longitude,Fe,De,a),m=a.x,x=a.y,p=!0)),t.push({id:r.hash,label:h?`${r.prefix} ${h}`:r.prefix,color:d,trafficCategory:c,size:u,x:m,y:x,recencyWeight:e,nodeClass:r.nodeClass,name:h,prefix:r.prefix,packetCount:r.packetCount,betweenness:r.betweenness,communityId:r.communityId,isLocal:r.isLocal,isHub:r.isHub,isGateway:r.isGateway,isBackbone:r.isBackbone,isMobile:r.isMobile,isGhost:r.isGhost,isInLoop:r.isInLoop,isZeroHop:r.isZeroHop,hasGeo:p,avgRssi:r.avgRssi,avgSnr:r.avgSnr,degree:r.degree,activityLevel:r.activityLevel,prefixConfidence:r.prefixConfidence,hasCollision:r.hasCollision,lastSeen:r.lastSeen})}if(n.length>0){n.sort((e,t)=>e-t);const e=n[Math.floor(.99*n.length)]??n[n.length-1]??1/0;for(const s of t)!s.isLocal&&s.packetCount>=e&&(s.trafficCategory=5)}return t},[W,v,He,Fe,De,null==V?void 0:V.node_name,null==(n=null==V?void 0:V.config)?void 0:n.node_name,Ee,me]),$e=e.useMemo(()=>{const e=new Set;for(const t of Be)e.add(t.id);return e},[Be]),{rawLinks:Re}=e.useMemo(()=>{const e=(null==A?void 0:A.edges)??[];if(!e||0===e.length||!v)return{rawLinks:[],maxCertainCount:0,hasZeroHopEdges:!1,hasLoopEdges:!1,hasDirectPathEdges:!1};const t=K(),s=[];let a=!1,n=!1,r=!1;const o=[],i=5-4*Math.min(1,Math.max(0,(xe-.05)/2.95));for(const l of e){if(!$e.has(l.fromHash)||!$e.has(l.toHash))continue;s.push(l.certainCount),a=a||!0===l.isZeroHop,n=n||!0===l.isLoopEdge,r=r||!0===l.isDirectPathEdge;const e=l.avgRecency,t=e<0,i=null==W?void 0:W.get(l.fromHash),c=null==W?void 0:W.get(l.toHash),d=(null==i?void 0:i.isHub)||(null==i?void 0:i.isGateway)||(null==i?void 0:i.isBackbone)||(null==i?void 0:i.isLocal),u=(null==c?void 0:c.isHub)||(null==c?void 0:c.isGateway)||(null==c?void 0:c.isBackbone)||(null==c?void 0:c.isLocal);let h=0,m=300;t||(d&&u?(h=.8,m=250):d||u?(h=.4,m=50):(h=.1,m=300)),o.push({source:l.fromHash,target:l.toHash,color:t?"#1E293B":"#808080",width:t?.1:1,strength:h,distance:m,arrow:!t,trafficCategory:t?0:2,recencyWeight:e,packetCount:l.packetCount,certainCount:l.certainCount,isZeroHop:l.isZeroHop??!1,isLoopEdge:l.isLoopEdge??!1,isDirectPath:l.isDirectPathEdge,avgConfidence:l.avgConfidence})}if(s.length>0){s.sort((e,t)=>e-t);const e=s[Math.floor(.98*s.length)]??s[s.length-1]??1,a=Math.max(1,e),n=Math.log10(a+1),r=s[Math.floor(.99*s.length)]??s[s.length-1]??1/0;for(const s of o){if(0===s.trafficCategory)continue;const e=s.certainCount>0?Math.log10(s.certainCount+1):0,a=Math.min(1,e/n),o=Math.pow(a,xe),l=Math.pow(a,he);if(s.width=.1+o*(i-.1),s.certainCount>=r)s.color=t,s.trafficCategory=5;else{const e=Math.round(80+144*l).toString(16).padStart(2,"0");s.color=`#${e}${e}${e}`,s.trafficCategory=a<.25?1:a<.5?2:a<.75?3:4}}}return{rawLinks:o,maxCertainCount:s.length>0?Math.max(...s):0,hasZeroHopEdges:a,hasLoopEdges:n,hasDirectPathEdges:r}},[null==A?void 0:A.edges,v,$e,W,xe,he]),ze=e.useMemo(()=>{const e=new Map;for(const t of Re)e.set(t.source,(e.get(t.source)??0)+1),e.set(t.target,(e.get(t.target)??0)+1);return e},[Re]),Ie=e.useMemo(()=>{const e=new Map;for(const t of Be)e.set(t.id,t);return e},[Be]),Ge=e.useMemo(()=>{const e=new Map;for(const t of Re)e.has(t.source)||e.set(t.source,[]),e.get(t.source).push({link:t,otherHash:t.target,direction:"outbound"}),e.has(t.target)||e.set(t.target,[]),e.get(t.target).push({link:t,otherHash:t.source,direction:"inbound"});return e},[Re]),Te=e.useMemo(()=>{if(!te)return[];const e=Ge.get(te.hash);if(!e)return[];const t=[];for(const{link:s,otherHash:a,direction:n}of e){const e=Ie.get(a);e&&t.push({hash:a,prefix:e.prefix,name:e.name,nodeClass:e.nodeClass,packetCount:s.packetCount,certainCount:s.certainCount,isZeroHop:s.isZeroHop,isDirectPath:s.isDirectPath,isLoopEdge:s.isLoopEdge,direction:n})}return t},[te,Ge,Ie]),Ae=e.useMemo(()=>{const e=new Map;for(const t of Be)e.set(t.label,t.trafficCategory),e.set(t.prefix,t.trafficCategory);return e},[Be]),Ze=e.useMemo(()=>{if(0===Re.length||0===Be.length)return null;const e=new Map;for(const l of Re)e.has(l.source)||e.set(l.source,new Set),e.has(l.target)||e.set(l.target,new Set),e.get(l.source).add(l.target),e.get(l.target).add(l.source);const t=Be.find(e=>e.isLocal);if(!t)return null;const s=new Map,a=[t.id];s.set(t.id,0);let n=0;for(;a.length>0;){const t=a.shift(),r=s.get(t),o=e.get(t);if(o)for(const e of o)if(!s.has(e)){const t=r+1;s.set(e,t),n=Math.max(n,t),a.push(e)}}for(const l of Be)s.has(l.id)||s.set(l.id,n+1);const r=new Map;for(const l of s.values())r.set(l,(r.get(l)??0)+1);const o=new Set;for(const[l,c]of s)c<=2&&o.add(l);const i=new Set;for(const l of Re)o.has(l.source)&&o.has(l.target)&&(i.add(`${l.source}-${l.target}`),i.add(`${l.target}-${l.source}`));return{hopDistance:s,maxHops:n,nodesPerHop:r,backboneSet:o,backboneEdgeSet:i,localNodeId:t.id}},[Re,Be]),Oe=Ze,We=e.useCallback(()=>{const e=document.querySelectorAll(".css-label--label");if(0===e.length||0===Ae.size)return;const t=["meshgraph-label-cat-0","meshgraph-label-cat-1","meshgraph-label-cat-2","meshgraph-label-cat-3","meshgraph-label-cat-4","meshgraph-label-cat-5"];e.forEach(e=>{var s;const a=(null==(s=e.textContent)?void 0:s.trim())??"",n=Ae.get(a);void 0!==n&&(e.classList.remove(...t),e.classList.add(`meshgraph-label-cat-${n}`))})},[Ae]),[Ve,qe]=e.useState(null),[Ke,_e]=e.useState(null),[Ye,Je]=e.useState({}),Ue=e.useRef(null);e.useEffect(()=>()=>{var e;try{null==(e=Ue.current)||e.destroy()}catch{}Ue.current=null},[]);const Xe=e.useRef(!1),Qe=e.useRef(!1),et=e.useRef(!1),tt=e.useRef(""),st=e.useRef(!1),[at,nt]=e.useState(!0),[rt,ot]=e.useState(0),it=e.useCallback(()=>{const e=Ue.current;e&&(et.current=!1,st.current=!1,nt(!0),ee(!0),e.start())},[]),lt=e.useRef(Ne);e.useEffect(()=>{if(0===Be.length)return qe(null),_e(null),void(tt.current="");const e=lt.current!==Ne;e&&(lt.current=Ne);const t=`${Be.length}-${Re.length}-${pe.toFixed(2)}-${ge.toFixed(2)}-${Ne}`,s=tt.current;if(!e&&s&&Qe.current){const[e,t]=s.split("-").map(Number),a=Math.abs(Be.length-e)/Math.max(e,1),n=Math.abs(Re.length-t)/Math.max(t,1),r=!s.includes(`${pe.toFixed(2)}-${ge.toFixed(2)}`);if(a<.05&&n<.05&&!r)return}let n=!1,r=null;return e&&(Xe.current=!1),r=setTimeout(async()=>{if(!Xe.current){Xe.current=!0,Qe.current=!0,nt(!0);try{const r=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t,o=186,i=255,l=92,c=fe.current;let d;d=c<=1?i-c*(i-o):o-(c-1)*(o-l);const u=e=>{const t=Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${t}${t}${t}`},h=e=>u(d+(i-d)*e),m=K(),x=document.documentElement;x.style.setProperty("--meshgraph-label-0",h(0)),x.style.setProperty("--meshgraph-label-1",h(.33)),x.style.setProperty("--meshgraph-label-2",h(.66)),x.style.setProperty("--meshgraph-label-3",h(1)),x.style.setProperty("--meshgraph-label-4","#FFFFFF"),x.style.setProperty("--meshgraph-label-5",m);const p=e=>{if(g&&Ze){const t=Ze.hopDistance.get(e.id)??99;return 0===t?"Local":1===t?"Hop-1":2===t?"Hop-2":3===t?"Hop-3":"Hop-4+"}return e.isLocal?"Local":e.isHub?"Hub":e.isGateway?"Gateway":e.isBackbone?"Backbone":"Node"},g="backbone"===Ne&&Ze,f=(null==Ze?void 0:Ze.maxHops)??5,b=["#FBBF24","#F97316","#EF4444","#A855F7","#3B82F6","#6366F1","#6B7280"],y=[...Be].sort((e,t)=>{if(g){const s=Ze.hopDistance.get(e.id)??f+1,a=Ze.hopDistance.get(t.id)??f+1;if(s!==a)return a-s}const s=5===e.trafficCategory,a=5===t.trafficCategory;return s&&!a?1:!s&&a?-1:e.size-t.size}).map(e=>{const t=(null==Ze?void 0:Ze.hopDistance.get(e.id))??99,s=t<=2;let a,n;if(g){if(5===e.trafficCategory)a=m;else if(e.isLocal)a=b[0];else{const e=Math.min(t,b.length-1);a=b[e]}n=(e.isLocal?32:s?20:12)*(.8+e.trafficCategory/4*.4)}else{if(5===e.trafficCategory)a=m;else{const t=100+e.trafficCategory/4*140,s=Math.round(t).toString(16).padStart(2,"0");a=`#${s}${s}${s}`}n=r(e.size,8)}return{id:e.id,label:e.label,color:a,trafficCategory:e.trafficCategory,size:n,groupLabel:p(e)}}),v=[...Re].sort((e,t)=>(t.certainCount??t.packetCount??0)-(e.certainCount??e.packetCount??0)),j=Math.floor(1*v.length),w=new Set(v.slice(0,Math.max(j,10)).map(e=>`${e.source}-${e.target}`)),k=Math.max(1,...Re.map(e=>e.certainCount)),C=new Map;for(const e of(null==A?void 0:A.edges)??[]){const t=`${e.fromHash}-${e.toHash}`,s=`${e.toHash}-${e.fromHash}`,a={symmetryRatio:e.symmetryRatio??.5,forwardCount:e.forwardCount??0,reverseCount:e.reverseCount??0};C.set(t,a),C.set(s,a)}const N=Re.filter(e=>w.has(`${e.source}-${e.target}`)).sort((e,t)=>{if(g&&Ze){const s=Ze.backboneEdgeSet.has(`${e.source}-${e.target}`),a=Ze.backboneEdgeSet.has(`${t.source}-${t.target}`);if(s&&!a)return 1;if(!s&&a)return-1}const s=5===e.trafficCategory,a=5===t.trafficCategory;return s&&!a?1:!s&&a?-1:e.width-t.width}).map(e=>{const t=(null==Ze?void 0:Ze.hopDistance.get(e.source))??f,s=(null==Ze?void 0:Ze.hopDistance.get(e.target))??f,a=Math.min(t,s),n=Math.max(t,s)-a,o=C.get(`${e.source}-${e.target}`),i=(null==o?void 0:o.symmetryRatio)??.5,l=Math.log10(e.certainCount+1)/Math.log10(k+1);let c,d,u,h;if(g){0===n?(d=40+30*(1-l),c=.8):(d=120*n*(1+.2*a),c=.15/n);const e=(t+s)/2;e<=1.5?(u="#FB923C",h=2+4*i):e<=2.5?(u="#F87171",h=1.5+2.5*i):e<=3.5?(u="#C084FC",h=1+2*i):(u="#60A5FA",h=.5+1.5*i)}else{const t=l*(.3+.7*i);c=.1+1.9*t,d=20+180*(1-t),u=e.color,h=r(e.width,1)}return{source:e.source,target:e.target,color:u,trafficCategory:e.trafficCategory,width:h,strength:c,distance:d}}),S=y,M=N,L=S.length>0,F=new Set(M.map(e=>e.width)),D=M.length>0,H=1===F.size?F.values().next().value:null,E=new Set(M.map(e=>e.strength)),P=M.length>=2&&E.size>=2,B=new Set(M.map(e=>e.distance)),$=M.length>=2&&B.size>=2,R=new Set(S.map(e=>e.groupLabel)).size>=2,z=(e=!1)=>({points:{pointIdBy:"id",pointColorBy:"color",pointColorStrategy:"direct",pointDefaultColor:"#FFFFFF",pointLabelBy:"label",pointGreyoutOpacity:.5,pointDefaultSize:8,pointSizeScale:1,...e?{}:{pointMass:e=>1+((e.size??8)-6)/18*10},...!e&&L?{pointSizeBy:"size",pointSizeStrategy:"direct"}:{},...!e&&R?{pointClusterBy:"groupLabel"}:{},...!e&&D?{linkWidthBy:"width",linkWidthStrategy:"direct"}:{},...!e&&P?{linkStrengthBy:"strength",linkStrengthStrategy:"direct"}:{}},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",linkColorStrategy:"direct",linkDefaultWidth:null!==H?H:1,linkWidthScale:1,linkDefaultColor:"#505050",linkGreyoutOpacity:.15,...!e&&D?{linkWidthBy:"width",linkWidthStrategy:"direct"}:{},...!e&&$?{linkDistanceBy:"distance",linkDistanceStrategy:"direct"}:{}}});let I;try{I=await a(z(!1),S,M)}catch(s){I=await a(z(!0),S,M)}if(n||!I)return;const G=I.points??null,T=I.links??null,Z=I.cosmographConfig;qe(G),_e(T),Je({...Z,fitViewOnInit:!1,...Y}),tt.current=t,e&&ot(e=>e+1)}catch(r){nt(!1)}finally{Xe.current=!1}}},500),()=>{n=!0,r&&clearTimeout(r)}},[Be,Re,!1,null,pe,ge,Ne,Oe,null==A?void 0:A.edges]);const ct=e.useCallback(e=>{e&&(Ue.current=e,it())},[it]),dt=e.useCallback(()=>{var e;null==(e=Ue.current)||e.fitView(800)},[]),ut=e.useCallback(()=>{var e,t,s;const a=Ue.current;if(a){if(et.current||(et.current=!0,a.fitView(800)),nt(!1),!st.current){st.current=!0;try{const n=a._internalApi;null==(e=null==n?void 0:n.initializeLabels)||e.call(n),null==(s=null==(t=null==n?void 0:n.labels)?void 0:t.update)||s.call(t),setTimeout(()=>We(),100)}catch{}}ee(!1)}},[We]),ht=e.useCallback(()=>{const e=Ue.current;e&&(X?e.pause():e.start(),ee(!X))},[X]),mt=e.useCallback(async e=>{const t=Ue.current;if(t)try{const s=await t.getPointIndicesByIds([e]);s&&s.length>0&&void 0!==s[0]&&t.zoomToPoint(s[0],400,2.5)}catch{}},[]),xt=e.useMemo(()=>{if(!le||!re.trim())return[];const e=re.toLowerCase();return Be.filter(t=>{var s;return t.prefix.toLowerCase().includes(e)||(null==(s=t.name)?void 0:s.toLowerCase().includes(e))||t.id.toLowerCase().includes(e)}).slice(0,8)},[Be,re,le]),pt=e.useCallback(e=>{mt(e.id),ce(!1),ie(""),ae({hash:e.id,name:e.name,prefix:e.prefix,nodeClass:e.nodeClass,packetCount:e.packetCount,edgeCount:ze.get(e.id)??0,betweenness:e.betweenness,communityId:e.communityId,degree:e.degree,hasGeo:e.hasGeo,isLocal:e.isLocal,isHub:e.isHub,isGateway:e.isGateway,isBackbone:e.isBackbone,isMobile:e.isMobile,isInLoop:e.isInLoop,isZeroHop:e.isZeroHop,avgRssi:e.avgRssi,avgSnr:e.avgSnr,activityLevel:e.activityLevel,prefixConfidence:e.prefixConfidence,hasCollision:e.hasCollision,hopDistance:null==Ze?void 0:Ze.hopDistance.get(e.id)})},[mt,ze,Ze]),gt=e.useRef(void 0),ft=e.useRef(0),bt=e.useCallback(async(e,t,s)=>{const a=Date.now();if(s&&a-ft.current>=16&&(ft.current=a,je.current.x=s.clientX,je.current.y=s.clientY,je.current.node&&window.dispatchEvent(new CustomEvent("meshgraph:hover"))),e===gt.current)return;gt.current=e,we.current&&(clearTimeout(we.current),we.current=null);const n=Ue.current;if(n)if(void 0!==e)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=Ie.get(s);if(!a)return;je.current.node=a,window.dispatchEvent(new CustomEvent("meshgraph:hover")),n.selectPoint(e,!1,!0)}catch{je.current.node=null,window.dispatchEvent(new CustomEvent("meshgraph:hover"))}else we.current=setTimeout(()=>{je.current.node=null,window.dispatchEvent(new CustomEvent("meshgraph:hover")),void 0!==ne.current?n.selectPoint(ne.current,!1,!0):n.unselectAllPoints()},100)},[Ie,te]),yt=e.useCallback(()=>{Ce(e=>!e)},[]),vt=e.useCallback(async(e,t,s)=>{var a;if(je.current.node=null,window.dispatchEvent(new CustomEvent("meshgraph:hover")),gt.current=void 0,void 0===e)return ne.current=void 0,ae(null),void(null==(a=Ue.current)||a.unselectAllPoints());const n=Ue.current;if(n)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=Ie.get(s);if(!a)return;ne.current=e,n.selectPoint(e,!1,!0),ae({hash:s,name:a.name,prefix:a.prefix,nodeClass:a.nodeClass,packetCount:a.packetCount,edgeCount:ze.get(s)??0,betweenness:a.betweenness,communityId:a.communityId,degree:a.degree,hasGeo:a.hasGeo,isLocal:a.isLocal,isHub:a.isHub,isGateway:a.isGateway,isBackbone:a.isBackbone,isMobile:a.isMobile,isInLoop:a.isInLoop,isZeroHop:a.isZeroHop,avgRssi:a.avgRssi,avgSnr:a.avgSnr,activityLevel:a.activityLevel,prefixConfidence:a.prefixConfidence,hasCollision:a.hasCollision,hopDistance:null==Ze?void 0:Ze.hopDistance.get(s)})}catch{}},[Ie,ze]);if(!v)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100dvh-56px)] lg:h-dvh flex items-center justify-center bg-black",children:[t.jsx(k,{isOpen:E,currentStep:B,packetCount:R}),!E&&t.jsx(L,{className:"w-8 h-8 text-accent-primary animate-spin"})]});if(0===Be.length)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100dvh-56px)] lg:h-dvh flex flex-col bg-black overflow-hidden",children:[t.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle bg-bg-elevated/50",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(h,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]})]})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(ye,{})})]});if(!Ve)return t.jsx("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100dvh-56px)] lg:h-dvh flex items-center justify-center bg-black",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(L,{className:"w-8 h-8 text-accent-primary animate-spin"}),t.jsx("span",{className:"text-sm text-text-muted",children:"Preparing graph..."})]})});const jt=ke?"fixed inset-0 z-50 bg-black":"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100dvh-56px)] lg:h-dvh bg-black";return t.jsxs("div",{className:`${jt} flex flex-col overflow-hidden`,children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle/50 bg-black/80 backdrop-blur-sm z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(h,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]}),t.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[Be.length," nodes • ",Re.length," edges"]}),at&&t.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-accent-primary animate-pulse",children:[t.jsx(L,{className:"w-3 h-3 animate-spin"}),"Stabilizing..."]})]}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx(m,{content:"force"===Ne?"Switch to backbone view":"Switch to force layout",children:t.jsx("button",{onClick:()=>Se(e=>"force"===e?"backbone":"force"),className:"p-2 rounded-lg transition-colors "+("backbone"===Ne?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:"force"===Ne?t.jsx(Z,{className:"w-4 h-4"}):t.jsx(I,{className:"w-4 h-4"})})}),t.jsx(m,{content:Me?"Hide labels":"Show labels",children:t.jsx("button",{onClick:()=>Le(e=>!e),className:"p-2 rounded-lg transition-colors "+(Me?"hover:bg-subtle-fill text-text-muted":"bg-subtle-fill/50 text-text-muted/50"),children:Me?t.jsx(F,{className:"w-4 h-4"}):t.jsx(C,{className:"w-4 h-4"})})}),t.jsx(m,{content:"Search nodes (/)",children:t.jsx("button",{onClick:()=>{ce(!0),setTimeout(()=>{var e;return null==(e=de.current)?void 0:e.focus()},50)},className:"p-2 rounded-lg transition-colors "+(le?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:t.jsx(D,{className:"w-4 h-4"})})}),t.jsx(m,{content:(X?"Pause":"Resume")+" simulation (Space)",children:t.jsx("button",{onClick:ht,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:X?t.jsx(x,{className:"w-4 h-4 text-accent-success"}):t.jsx(p,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(m,{content:"Fit view (F)",children:t.jsx("button",{onClick:dt,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:t.jsx(T,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(m,{content:ke?"Exit fullscreen":"Fullscreen",children:t.jsx("button",{onClick:yt,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:ke?t.jsx(N,{className:"w-4 h-4 text-text-muted"}):t.jsx(S,{className:"w-4 h-4 text-text-muted"})})})]})]}),t.jsxs("div",{className:"flex-1 relative min-h-0",children:[t.jsx(s,{className:"absolute inset-0",points:Ve,links:Ke,...Ye,backgroundColor:"#000000",fitViewOnInit:!1,initialZoomLevel:10,simulationClusterStrength:.8,showLabels:Me,showDynamicLabels:Me,showTopLabels:Me,showTopLabelsLimit:100,showHoveredPointLabel:!0,pointLabelFontSize:11,showClusterLabels:!1,onClick:vt,onMouseMove:bt,onMount:ct,onSimulationEnd:ut,renderHoveredPointRing:!0,hoveredPointRingColor:"#FBBF24",hoveredPointCursor:"pointer",pointGreyoutOpacity:.2,linkGreyoutOpacity:.15},rt),t.jsx(g,{children:le&&t.jsx(f.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:t.jsxs("div",{className:"bg-bg-elevated/95 backdrop-blur-sm rounded-xl border border-border-subtle shadow-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle",children:[t.jsx(D,{className:"w-4 h-4 text-text-muted shrink-0"}),t.jsx("input",{ref:de,type:"text",value:re,onChange:e=>ie(e.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none",onKeyDown:e=>{"Escape"===e.key?(ce(!1),ie("")):"Enter"===e.key&&xt.length>0&&pt(xt[0])}}),re&&t.jsx("button",{onClick:()=>ie(""),className:"p-0.5 rounded hover:bg-subtle-fill",children:t.jsx(b,{className:"w-3 h-3 text-text-muted"})})]}),xt.length>0&&t.jsx("div",{className:"max-h-64 overflow-y-auto",children:xt.map((e,s)=>{const a=Q[e.nodeClass];return t.jsxs("button",{onClick:()=>pt(e),className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-subtle-fill transition-colors "+(0===s?"bg-subtle-fill/50":""),children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:U[e.nodeClass]}}),t.jsx(a,{className:"w-3.5 h-3.5 text-text-muted shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-text-primary truncate",children:e.name||e.prefix}),e.name&&t.jsx("div",{className:"text-[10px] text-text-muted",children:e.prefix})]}),t.jsx(H,{className:"w-3 h-3 text-text-muted shrink-0"})]},e.id)})}),re&&0===xt.length&&t.jsx("div",{className:"px-3 py-4 text-center text-sm text-text-muted",children:"No nodes found"}),!re&&t.jsx("div",{className:"px-3 py-2 text-[10px] text-text-muted",children:"Type to search • Enter to select • Esc to close"})]})})}),t.jsx(oe,{nodeCount:Be.length,edgeCount:Re.length,layoutMode:Ne,hopStats:Ze?{maxHops:Ze.maxHops,nodesPerHop:Ze.nodesPerHop}:null}),!te&&t.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 text-[10px] text-text-muted/60",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),t.jsx(g,{children:te&&t.jsx(be,{node:te,connections:Te,onClose:()=>{var e;ne.current=void 0,ae(null),null==(e=Ue.current)||e.unselectAllPoints()}})})]})]})}export{ve as default};
|