Files
pymc_console-dist/frontend/dist/assets/PathMapMapLibre-DDCSplNW.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
11 KiB
JavaScript

import{r as e,j as t,c as o}from"./vendor-react-j_fHog8x.js";import{u as r,M as i,B as n,S as a,L as s,a as l,P as d}from"./BasemapLayer-Dkb0XoZP.js";import"./maplibre-gl-b91ci4Kr.js";import{c,ad as u,cG as m,al as p,e as h,m as x,cH as g}from"./index-CO-NnSP8.js";import{H as f}from"./DelayedAnimateNumber-xFzqpOLo.js";import{u as b}from"./PacketList-DrVCuEEJ.js";import"./vendor-core-CDNU4oKM.js";import"./index-DNg74HZF.js";import"./config-CTM8_93T.js";import"./payload-decoders-DfKckowu.js";import"./SignalIndicator-tjeecqq-.js";import"./arrow-up-C3dAchbM.js";import"./copy-CahOsHH0.js";import"./chevron-right-Cgpj1ndR.js";import"./map-pin-CIqkzpRM.js";import"./triangle-alert-D7kg1BKJ.js";import"./DataBox-6iMqIVkm.js";import"./layers-BMI7lxOC.js";import"./route-CaY86CQp.js";import"./activity-DAryZX3s.js";import"./circle-check-DG4rlUrU.js";import"./database--v1eG4MH.js";const y=c("car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]),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 C(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=g(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 k(){if("undefined"==typeof document)return j;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:C(t.getPropertyValue("--map-node-stroke").trim(),j.nodeColor),localColor:C(t.getPropertyValue("--map-local-color").trim(),j.localColor),hubColor:C(t.getPropertyValue("--map-hub-color").trim(),j.hubColor),edgeColor:C(t.getPropertyValue("--map-edge-rest").trim(),j.edgeColor),ambiguousColor:C(t.getPropertyValue("--accent-secondary").trim(),j.ambiguousColor),highlightColor:C(t.getPropertyValue("--accent-primary").trim(),j.highlightColor),sourceColor:C(t.getPropertyValue("--accent-success").trim(),j.sourceColor),destinationColor:C(t.getPropertyValue("--accent-primary").trim(),j.destinationColor)}}function N({prefix:r,isLocal:i,isSource:n,isDestination:a,isLastHop:s,isHighlighted:l,isAnimating:d,isWardrive:c,candidate:u,onHover:m,onLeave:p,onClick:g}){const v=b(),[j,C]=e.useState(!1);e.useEffect(()=>{d&&v.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,v]);const k=e.useCallback(()=>{C(!0),m()},[m]),N=e.useCallback(()=>{C(!1),p()},[p]);return c?t.jsxs(x.div,{className:o("flex items-center cursor-pointer","transition-all duration-150",l&&"ring-2 ring-accent-primary/50 rounded-full",j&&"relative z-50"),animate:v,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:g,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",j&&"scale-110"),children:t.jsx(y,{className:"w-4 h-4",strokeWidth:2.5})}),j&&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(x.div,{className:o("flex items-center cursor-pointer","transition-all duration-150",l&&"ring-2 ring-accent-primary/50 rounded",j&&"relative z-50"),animate:v,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:g,style:{pointerEvents:"auto"},children:t.jsxs(h,{color:c?"orange":i?"amber":n?"green":s?"amber":a?"purple":"blue",filled:!0,className:"font-mono text-[10px] shadow-lg border border-current/30",children:[i&&t.jsx(f,{className:"w-2.5 h-2.5 mr-1"}),r,j&&u.name&&t.jsx("span",{className:"ml-1 opacity-75",children:u.name})]})})}function S({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 w({resolvedPath:c,localNode:h,hubNodes:x=[],hoveredHopIndex:g,onHoverHop:f,traceSnr:b}){const y=void 0!==b&&b.length>0,j=e.useRef(null),C=r(),w=e.useMemo(()=>new Set(x),[x]),[F,L]=e.useState(null),D=u(),[E,H]=e.useState(!1),[M,P]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=j.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},i=()=>{P(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",i)}},[M]);const{positions:$,markers:A,edges:B}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let i=0,n=!1;return c.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],c=[d.longitude,d.latitude];if(r.push(c),r.length>=2){const e=r[r.length-2],t=r.length-2,i=null==b?void 0:b[t],a=c[0]-e[0],s=c[1]-e[1],l=Math.atan2(a,s)*(180/Math.PI),d=k();let u;u=n?"#F97316":void 0!==i?m()[p(i)]||"#71717a":d.edgeColor,o.push({from:e,to:c,snrFwd:i,midpoint:[(e[0]+c[0])/2,(e[1]+c[1])/2],bearing:l,color:u,isFromWardrive:n})}const u=!0===a.isSource,h=!0===a.isDestination,x=!0===d.isWardrive;n=x,l.forEach((o,r)=>{const n=[o.latitude,o.longitude];e.push(n);const d=0===r;t.push({position:n,prefix:a.prefix,confidence:a.confidence,candidateCount:l.length,hopIndex:s,candidate:o,isHub:w.has(o.hash),isPrimary:d,isSource:u,isDestination:h,validIndex:i})}),i++}),{positions:e,markers:t,edges:o}},[c,w,b]),I=e.useMemo(()=>{const e=A.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,i=-1/0;for(const n of e){const[e,a]=n.position;e<t&&(t=e),e>o&&(o=e),a<r&&(r=a),a>i&&(i=a)}return[[r,t],[i,o]]},[A]),V=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=j.current)?void 0:e.getMap();t&&I?(t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{H(!0)},50)):H(!0)},[I]),z=e.useMemo(()=>I?`${I[0][0].toFixed(5)},${I[0][1].toFixed(5)},${I[1][0].toFixed(5)},${I[1][1].toFixed(5)}`:"",[I]);e.useEffect(()=>{var e;if(!E)return;const t=null==(e=j.current)?void 0:e.getMap();t&&I&&t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[z,E,I]);const R=D&&E,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(i,{ref:j,initialViewState:{longitude:V[0],latitude:V[1],zoom:10},onLoad:W,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(n,{mode:C}),B.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}`)}),B.map((e,o)=>t.jsx(l,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(S,{hopNumber:o+1,snr:y?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=A.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const i=g===e.hopIndex,n=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(l,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(N,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:n,isHighlighted:i,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=k();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:k().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{w as default};