Files
pymc_console-dist/frontend/dist/assets/PathMapMapLibre-DAcWSd5E.js
T
GitHub Actions Bot b3376cb974 Sync build v0.9.199
Automated sync from private repository.
Commit: b920c79aa34456f4be0f8e31adf7e35b77fbe5fa
2026-01-30 08:58:52 +00:00

2 lines
10 KiB
JavaScript

import{r as e,j as t,c as o}from"./vendor-react-54o2BuWt.js";import{u as r,M as n,B as i,S as a,L as s,a as l,P as d}from"./BasemapLayer-DuDL4O6m.js";import"./maplibre-gl-Bk5DsYkB.js";import{h as c,s as u,p as m}from"./useThemeColors-BvPNffvW.js";import{ai as p,B as h,m as g}from"./index-jS7dHlo8.js";import{C as x}from"./car-DtD4jdfc.js";import{H as f}from"./house-DzVJWsxe.js";import{u as b}from"./PacketList-DXLe_7Xh.js";import"./deckgl-DTsmDcfs.js";import"./vendor-core-dnrJb0w-.js";import"./channel-keys-DJWRrSwE.js";import"./SignalIndicator-UtU8ibs1.js";import"./arrow-up-DA8CPeYk.js";import"./DataBox-Do_Cl-e9.js";import"./chevron-right-BQ7Z-SWI.js";import"./loader-circle-2FAV_tMF.js";import"./map-pin-C7xi_N9y.js";import"./zap-DMp3tbuD.js";import"./triangle-alert-hs_SAlzV.js";import"./route-C1MVeQVj.js";import"./chevron-up-DdDXL6xW.js";import"./circle-check-DQRsuN6P.js";const v={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},j={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function y(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=m(e);return o?`#${o.r.toString(16).padStart(2,"0")}${o.g.toString(16).padStart(2,"0")}${o.b.toString(16).padStart(2,"0")}`:t}function C(){if("undefined"==typeof document)return j;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:y(t.getPropertyValue("--map-node-stroke").trim(),j.nodeColor),localColor:y(t.getPropertyValue("--map-local-color").trim(),j.localColor),hubColor:y(t.getPropertyValue("--map-hub-color").trim(),j.hubColor),edgeColor:y(t.getPropertyValue("--map-edge-rest").trim(),j.edgeColor),ambiguousColor:y(t.getPropertyValue("--accent-secondary").trim(),j.ambiguousColor),highlightColor:y(t.getPropertyValue("--accent-primary").trim(),j.highlightColor),sourceColor:y(t.getPropertyValue("--accent-success").trim(),j.sourceColor),destinationColor:y(t.getPropertyValue("--accent-primary").trim(),j.destinationColor)}}function k({prefix:r,isLocal:n,isSource:i,isDestination:a,isLastHop:s,isHighlighted:l,isAnimating:d,isWardrive:c,candidate:u,onHover:m,onLeave:p,onClick:v}){const j=b(),[y,C]=e.useState(!1);e.useEffect(()=>{d&&j.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[d,j]);const k=e.useCallback(()=>{C(!0),m()},[m]),N=e.useCallback(()=>{C(!1),p()},[p]);return c?t.jsxs(g.div,{className:o("flex items-center cursor-pointer","transition-all duration-150",l&&"ring-2 ring-accent-primary/50 rounded-full",y&&"relative z-50"),animate:j,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:o("flex items-center justify-center","w-7 h-7 rounded-full","bg-orange-500 text-white","shadow-lg border-2 border-orange-300/50","transition-transform duration-150",y&&"scale-110"),children:t.jsx(x,{className:"w-4 h-4",strokeWidth:2.5})}),y&&t.jsxs(h,{color:"orange",filled:!0,className:"ml-1 text-[10px] font-mono shadow-lg",children:[r,u.name&&t.jsx("span",{className:"ml-1 opacity-75",children:u.name})]})]}):t.jsx(g.div,{className:o("flex items-center cursor-pointer","transition-all duration-150",l&&"ring-2 ring-accent-primary/50 rounded",y&&"relative z-50"),animate:j,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:t.jsxs(h,{color:c?"orange":n?"amber":i?"green":s?"amber":a?"purple":"blue",filled:!0,className:"font-mono text-[10px] shadow-lg border border-current/30",children:[n&&t.jsx(f,{className:"w-2.5 h-2.5 mr-1"}),r,y&&u.name&&t.jsx("span",{className:"ml-1 opacity-75",children:u.name})]})})}function N({hopNumber:e,snr:o,edgeColor:r}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:r||"#71717a",color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e}),void 0!==o&&t.jsx(h,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:o.toFixed(1)})]})}function S({resolvedPath:m,localNode:h,hubNodes:g=[],hoveredHopIndex:x,onHoverHop:f,traceSnr:b}){const j=void 0!==b&&b.length>0,y=e.useRef(null),S=r(),w=e.useMemo(()=>new Set(g),[g]),[F,L]=e.useState(null),D=p(),[P,E]=e.useState(!1),[M,H]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=y.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},n=()=>{H(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",n),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",n)}},[M]);const{positions:$,markers:B,edges:I}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let n=0,i=!1;return m.hops.forEach((a,s)=>{const l=a.candidates.filter(e=>{return t=e.latitude,o=e.longitude,0!==t||0!==o;var t,o});if(0===l.length)return;const d=[...l].sort((e,t)=>t.probability-e.probability)[0],m=[d.longitude,d.latitude];if(r.push(m),r.length>=2){const e=r[r.length-2],t=r.length-2,n=null==b?void 0:b[t],a=m[0]-e[0],s=m[1]-e[1],l=Math.atan2(a,s)*(180/Math.PI),d=C();let p;p=i?"#F97316":void 0!==n?c()[u(n)]||"#71717a":d.edgeColor,o.push({from:e,to:m,snrFwd:n,midpoint:[(e[0]+m[0])/2,(e[1]+m[1])/2],bearing:l,color:p,isFromWardrive:i})}const p=!0===a.isSource,h=!0===a.isDestination,g=!0===d.isWardrive;i=g,l.forEach((o,r)=>{const i=[o.latitude,o.longitude];e.push(i);const d=0===r;t.push({position:i,prefix:a.prefix,confidence:a.confidence,candidateCount:l.length,hopIndex:s,candidate:o,isHub:w.has(o.hash),isPrimary:d,isSource:p,isDestination:h,validIndex:n})}),n++}),{positions:e,markers:t,edges:o}},[m,w,b]),V=e.useMemo(()=>{const e=B.filter(e=>e.isPrimary&&(e.confidence>=.5||e.isSource||e.isDestination));if(0===e.length)return null;let t=1/0,o=-1/0,r=1/0,n=-1/0;for(const i of e){const[e,a]=i.position;e<t&&(t=e),e>o&&(o=e),a<r&&(r=a),a>n&&(n=a)}return[[r,t],[n,o]]},[B]),A=e.useMemo(()=>{if(0===$.length)return h?[h.longitude,h.latitude]:[0,0];let e=0,t=0;for(const[o,r]of $)e+=o,t+=r;return[t/$.length,e/$.length]},[$,h]),W=e.useCallback(()=>{var e;const t=null==(e=y.current)?void 0:e.getMap();t&&V?(t.fitBounds(V,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{E(!0)},50)):E(!0)},[V]),z=e.useMemo(()=>V?`${V[0][0].toFixed(5)},${V[0][1].toFixed(5)},${V[1][0].toFixed(5)},${V[1][1].toFixed(5)}`:"",[V]);e.useEffect(()=>{var e;if(!P)return;const t=null==(e=y.current)?void 0:e.getMap();t&&V&&t.fitBounds(V,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[z,P,V]);const R=D&&P,O=e.useCallback(e=>{L({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return 0===$.length?t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm bg-bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[t.jsx("div",{className:o("absolute inset-0 bg-bg-elevated flex items-center justify-center","transition-opacity duration-200 ease-out pointer-events-none",R?"opacity-0":"opacity-100"),children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:R?1:0},children:t.jsxs(n,{ref:y,initialViewState:{longitude:A[0],latitude:A[1],zoom:10},onLoad:W,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(i,{mode:S}),I.map((e,o)=>{const r={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]};return t.jsx(a,{id:`edge-${o}`,type:"geojson",data:r,children:t.jsx(s,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)}),I.map((e,o)=>t.jsx(l,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(N,{hopNumber:o+1,snr:j?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=B.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const n=x===e.hopIndex,i=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(l,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(k,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:i,isHighlighted:n,isAnimating:!1,isWardrive:e.candidate.isWardrive||!1,candidate:e.candidate,onHover:()=>null==f?void 0:f(e.hopIndex),onLeave:()=>null==f?void 0:f(null),onClick:()=>O(e)})},`${e.hopIndex}-${e.candidate.hash}`)})})(),F&&t.jsx(d,{longitude:F.longitude,latitude:F.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>L(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:F.marker.candidate.name}),(()=>{const e=C();return t.jsxs(t.Fragment,{children:[F.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),F.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),F.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),F.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),F.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-text-muted font-mono text-[10px]",children:[F.marker.prefix," • ",F.marker.candidate.hash.slice(0,10),"..."]}),!F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{style:{color:C().ambiguousColor},children:["Alternative (",(100*F.marker.candidate.probability).toFixed(0),"%)"]}),F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{className:"text-text-muted",children:[F.marker.candidateCount," candidates"]})]})})]},M)})]})}export{S as default};