Files
pymc_console-dist/frontend/dist/assets/CollisionExplorerModal-DbflfWHf.js
T
GitHub Actions Bot f8dcafd718 Release v0.9.229
Automated sync from private repository.
Built with obfuscation enabled.
2026-02-11 02:50:38 +00:00

2 lines
8.6 KiB
JavaScript

import{r as e,j as s,c as t}from"./vendor-react-j_fHog8x.js";import{u as a,M as i,B as o,S as n,L as l,a as r}from"./BasemapLayer-Dkb0XoZP.js";import"./maplibre-gl-b91ci4Kr.js";import{c as d,n as c,am as h,o as u,K as m,N as x,ad as p,e as g,f as v,b2 as b}from"./index-CO-NnSP8.js";import{T as f}from"./triangle-alert-D7kg1BKJ.js";import{M as j}from"./map-pin-CIqkzpRM.js";import{C as y}from"./copy-CahOsHH0.js";const N=d("monitor-smartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]),w=d("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),M={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"};function k({node:a,isHovered:i,onHover:o}){const[n,l]=e.useState(!1),r=e.useCallback(e=>{var s,t;e.stopPropagation(),s=a.hash,(null==(t=navigator.clipboard)?void 0:t.writeText)&&navigator.clipboard.writeText(s).catch(()=>{}),l(!0),setTimeout(()=>l(!1),2e3)},[a.hash]),d=a.contactType.toLowerCase(),c=d.includes("room")||d.includes("server");let h=w,u="text-accent-primary";return c?(h=b,u="text-signal-fair"):"companion"===d||"client"===d?(h=N,u="text-text-muted"):a.isNeighbor&&(u="text-accent-success"),s.jsxs("div",{className:t("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",i?"bg-accent-primary/10":"hover:bg-subtle-fill"),onMouseEnter:()=>o(a.hash),onMouseLeave:()=>o(null),children:[s.jsx(h,{className:t("w-4 h-4 flex-shrink-0",u)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:a.name}),a.isNeighbor&&s.jsx(g,{color:"green",compact:!0,children:"NBR"}),a.isRepeater&&s.jsx(g,{color:"zinc",compact:!0,children:"RPT"}),a.isHub&&s.jsx(g,{color:"purple",compact:!0,children:"HUB"})]}),s.jsxs("button",{onClick:r,className:t("mt-1 inline-flex items-center gap-1 text-[10px] font-mono px-1.5 py-0.5 rounded","border transition-all cursor-pointer",n?"border-accent-success/50 bg-accent-success/10 text-accent-success":"border-border-subtle bg-bg-subtle/50 text-text-muted hover:border-border-strong"),title:`Copy: ${a.hash}`,children:[a.hash.slice(0,12),"…",n?s.jsx(v,{className:"w-2.5 h-2.5"}):s.jsx(y,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function H({nodes:d,hoveredHash:c,onHover:h}){const u=a(),m=e.useRef(null),x=p(),[v,b]=e.useState(!1),f=e.useMemo(()=>d.filter(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[d]),y=e.useMemo(()=>{if(0===f.length)return null;let e=1/0,s=-1/0,t=1/0,a=-1/0;for(const i of f)e=Math.min(e,i.longitude),s=Math.max(s,i.longitude),t=Math.min(t,i.latitude),a=Math.max(a,i.latitude);if(a-t<.01){const e=(a+t)/2;t=e-.005,a=e+.005}if(s-e<.01){const t=(s+e)/2;e=t-.005,s=t+.005}return[[e,t],[s,a]]},[f]),N=e.useMemo(()=>y?{longitude:(y[0][0]+y[1][0])/2,latitude:(y[0][1]+y[1][1])/2}:{longitude:0,latitude:0},[y]),w=e.useMemo(()=>{if(f.length<2)return null;const e=[];for(let s=0;s<f.length;s++)for(let t=s+1;t<f.length;t++){const a=f[s],i=f[t];e.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[[a.longitude,a.latitude],[i.longitude,i.latitude]]}})}return{type:"FeatureCollection",features:e}},[f]),k=e.useCallback(()=>{var e;const s=null==(e=m.current)?void 0:e.getMap();s&&y?(s.fitBounds(y,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>b(!0),50)):b(!0)},[y]),H=x&&v;return 0===f.length?s.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 radius-inner",children:s.jsxs("div",{className:"text-center text-text-secondary p-4",children:[s.jsx(j,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),s.jsx("p",{className:"text-sm",children:"No location data available"})]})}):s.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-bg-elevated",children:[s.jsx("div",{className:t("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",H?"opacity-0":"opacity-100 bg-bg-elevated"),children:s.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),s.jsx("div",{className:t("h-full w-full transition-opacity duration-200",H?"opacity-100":"opacity-0"),children:s.jsxs(i,{ref:m,initialViewState:{longitude:N.longitude,latitude:N.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:M,attributionControl:!1,onLoad:k,children:[s.jsx(o,{mode:u}),w&&s.jsx(n,{id:"collision-edges",type:"geojson",data:w,children:s.jsx(l,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),f.map(e=>{const t=e.hash===c,a=e.hash.startsWith("0x")?e.hash.slice(2,4).toUpperCase():e.hash.slice(0,2).toUpperCase();return s.jsx(r,{longitude:e.longitude,latitude:e.latitude,anchor:"center",children:s.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>h(e.hash),onMouseLeave:()=>h(null),style:{pointerEvents:"auto"},children:s.jsxs(g,{color:"amber",filled:!0,className:"font-mono text-[10px] shadow-lg",children:[a,t&&s.jsx("span",{className:"ml-1 opacity-75 font-sans",children:e.name})]})})},e.hash)})]})})]})}const C=e.memo(function({isOpen:t,prefix:a,candidateHashes:i,onClose:o}){const n=c(),l=h(),r=u(),[d,p]=e.useState(null),g=e.useMemo(()=>new Set(r.map(e=>e.hash)),[r]),v=(null==n?void 0:n.neighbors)??{},b=e.useMemo(()=>i.map(e=>{var s;const t=(e=>v[e]?v[e]:!e.startsWith("0x")&&v["0x"+e]?v["0x"+e]:e.startsWith("0x")&&v[e.slice(2)]?v[e.slice(2)]:void 0)(e);return{hash:e,name:(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==t?void 0:t.contact_type)||"",isRepeater:(null==t?void 0:t.is_repeater)||"repeater"===(null==(s=null==t?void 0:t.contact_type)?void 0:s.toLowerCase())||!1,isNeighbor:g.has(e)||g.has("0x"+e)||g.has(e.replace(/^0x/,"")),isHub:l.has(e),latitude:null==t?void 0:t.latitude,longitude:null==t?void 0:t.longitude}}).sort((e,s)=>e.isNeighbor!==s.isNeighbor?e.isNeighbor?-1:1:e.isHub!==s.isHub?e.isHub?-1:1:e.name.localeCompare(s.name)),[i,v,g,l]),j=e.useMemo(()=>b.some(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[b]),y=e.useCallback(e=>{p(e)},[]),N=j?"4xl":"lg";return t?s.jsxs(m,{open:t,onClose:o,size:N,motionPlus:!0,className:j?"sm:h-[500px] sm:max-h-[600px]":"",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:s.jsx(f,{className:"w-5 h-5 text-signal-fair"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",s.jsx("span",{className:"font-mono text-accent-primary",children:a})]}),s.jsxs("p",{className:"text-xs text-text-secondary",children:[b.length," nodes share this prefix"]})]})]}),s.jsx("button",{onClick:o,className:"p-2 text-text-muted hover:text-text-primary transition-base radius-inner hover:bg-bg-subtle",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs(x,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[j&&s.jsx("div",{className:"h-64 p-2 border-b border-border-subtle",children:s.jsx(H,{nodes:b,hoveredHash:d,onHover:y})}),s.jsx("div",{className:"p-2",children:b.map(e=>s.jsx(k,{node:e,isHovered:d===e.hash,onHover:y},e.hash))})]}),j?s.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[s.jsx("div",{className:"overflow-y-auto border-r border-border-subtle",children:s.jsx("div",{className:"p-2",children:b.map(e=>s.jsx(k,{node:e,isHovered:d===e.hash,onHover:y},e.hash))})}),s.jsx("div",{className:"overflow-hidden p-2",children:s.jsx(H,{nodes:b,hoveredHash:d,onHover:y})})]}):s.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:s.jsx("div",{className:"p-2",children:b.map(e=>s.jsx(k,{node:e,isHovered:d===e.hash,onHover:y},e.hash))})})]})]}):null});export{C,N as M,w as S};