Files
pymc_console-dist/frontend/dist/assets/PathMapMapLibre-R_64Pi7o.js
GitHub Actions Bot 09e93d0c56 Release v0.9.260
Automated sync from private repository.
Built with obfuscation enabled.
2026-02-16 03:59:17 +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 s,S as a,L as n,a as l,P as d}from"./BasemapLayer-BT1oL_wV.js";import"./maplibre-gl-b91ci4Kr.js";import{c,aj as u,c_ as m,Z as p,ar as h,j as g,m as x,c$ as f}from"./index-CtAi-cAi.js";import{H as b}from"./DelayedAnimateNumber-BdwgBh7F.js";import{a as y}from"./PacketList-BZgsC0ZO.js";import"./vendor-core-CmkNwW1A.js";import"./index-6UGu_Ahy.js";import"./payload-decoders-AhqFfior.js";import"./node-types-B0Gk6phO.js";import"./badge-colors-YAE4qQ7m.js";import"./chat-utils-BOz58-WY.js";import"./SignalIndicator-DmOBjP8S.js";import"./signal-scoring-CcBiRcks.js";import"./arrow-up-DOJptdkY.js";import"./copy-p1qJ5t9x.js";import"./chevron-right-Db6jRWIi.js";import"./map-pin-CUo_iI6z.js";import"./triangle-alert-UtYVd_CB.js";import"./DataBox-B_kNKJSu.js";import"./layers-Bwb0gzlU.js";import"./route-lHOi0YSC.js";import"./activity-DOfZGwVk.js";import"./circle-check-DHAMqh9W.js";import"./database-CQBKCKbh.js";const j=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"},C={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function k(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=f(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 N(){if("undefined"==typeof document)return C;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:k(t.getPropertyValue("--map-node-stroke").trim(),C.nodeColor),localColor:k(t.getPropertyValue("--map-local-color").trim(),C.localColor),hubColor:k(t.getPropertyValue("--map-hub-color").trim(),C.hubColor),edgeColor:k(t.getPropertyValue("--map-edge-rest").trim(),C.edgeColor),ambiguousColor:k(t.getPropertyValue("--sys-indigo").trim(),C.ambiguousColor),highlightColor:k(t.getPropertyValue("--sys-blue").trim(),C.highlightColor),sourceColor:k(t.getPropertyValue("--sys-green").trim(),C.sourceColor),destinationColor:k(t.getPropertyValue("--sys-blue").trim(),C.destinationColor)}}function S({prefix:r,isLocal:i,isSource:s,isDestination:a,isLastHop:n,isHighlighted:l,isAnimating:d,isWardrive:c,candidate:u,onHover:m,onLeave:p,onClick:h}){const f=y(),[v,C]=e.useState(!1);e.useEffect(()=>{d&&f.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,f]);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-sys-blue/50 rounded-full",v&&"relative z-50"),animate:f,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:h,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:o("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",v&&"scale-110"),children:t.jsx(j,{className:"w-4 h-4",strokeWidth:2.5})}),v&&t.jsxs(g,{color:"orange",filled:!0,className:"ml-1 type-data-xs 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-sys-blue/50 rounded",v&&"relative z-50"),animate:f,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:h,style:{pointerEvents:"auto"},children:t.jsxs(g,{color:c?"orange":i?"amber":s?"green":n?"amber":a?"purple":"blue",filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[i&&t.jsx(b,{className:"w-2.5 h-2.5 mr-1"}),r,v&&u.name&&t.jsx("span",{className:"ml-1 opacity-75",children:u.name})]})})}function w({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||p[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e}),void 0!==o&&t.jsx(g,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:o.toFixed(1)})]})}function F({resolvedPath:c,localNode:g,hubNodes:x=[],hoveredHopIndex:f,onHoverHop:b,traceSnr:y}){const j=void 0!==y&&y.length>0,C=e.useRef(null),k=r(),F=e.useMemo(()=>new Set(x),[x]),[L,M]=e.useState(null),D=u(),[E,P]=e.useState(!1),[H,$]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},i=()=>{$(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",i)}},[H]);const{positions:A,markers:I,edges:V}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let i=0,s=!1;return c.hops.forEach((a,n)=>{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==y?void 0:y[t],a=c[0]-e[0],n=c[1]-e[1],l=Math.atan2(a,n)*(180/Math.PI),d=N();let u;u=s?"#F97316":void 0!==i?m()[h(i)]||p[500]: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:s})}const u=!0===a.isSource,g=!0===a.isDestination,x=!0===d.isWardrive;s=x,l.forEach((o,r)=>{const s=[o.latitude,o.longitude];e.push(s);const d=0===r;t.push({position:s,prefix:a.prefix,confidence:a.confidence,candidateCount:l.length,hopIndex:n,candidate:o,isHub:F.has(o.hash),isPrimary:d,isSource:u,isDestination:g,validIndex:i})}),i++}),{positions:e,markers:t,edges:o}},[c,F,y]),B=e.useMemo(()=>{const e=I.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 s of e){const[e,a]=s.position;e<t&&(t=e),e>o&&(o=e),a<r&&(r=a),a>i&&(i=a)}return[[r,t],[i,o]]},[I]),W=e.useMemo(()=>{if(0===A.length)return g?[g.longitude,g.latitude]:[0,0];let e=0,t=0;for(const[o,r]of A)e+=o,t+=r;return[t/A.length,e/A.length]},[A,g]),z=e.useCallback(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();t&&B?(t.fitBounds(B,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{P(!0)},50)):P(!0)},[B]),O=e.useMemo(()=>B?`${B[0][0].toFixed(5)},${B[0][1].toFixed(5)},${B[1][0].toFixed(5)},${B[1][1].toFixed(5)}`:"",[B]);e.useEffect(()=>{var e;if(!E)return;const t=null==(e=C.current)?void 0:e.getMap();t&&B&&t.fitBounds(B,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[O,E,B]);const R=D&&E,Z=e.useCallback(e=>{M({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return 0===A.length?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm 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-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:C,initialViewState:{longitude:W[0],latitude:W[1],zoom:10},onLoad:z,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(s,{mode:k}),V.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(n,{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}`)}),V.map((e,o)=>t.jsx(l,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(w,{hopNumber:o+1,snr:j?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=I.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const i=f===e.hopIndex,s=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(l,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(S,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:s,isHighlighted:i,isAnimating:!1,isWardrive:e.candidate.isWardrive||!1,candidate:e.candidate,onHover:()=>null==b?void 0:b(e.hopIndex),onLeave:()=>null==b?void 0:b(null),onClick:()=>Z(e)})},`${e.hopIndex}-${e.candidate.hash}`)})})(),L&&t.jsx(d,{longitude:L.longitude,latitude:L.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>M(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:L.marker.candidate.name}),(()=>{const e=N();return t.jsxs(t.Fragment,{children:[L.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),L.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),L.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),L.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"}),L.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-fg-muted type-data-xs",children:[L.marker.prefix," • ",L.marker.candidate.hash.slice(0,10),"..."]}),!L.marker.isPrimary&&L.marker.candidateCount>1&&t.jsxs("div",{style:{color:N().ambiguousColor},children:["Alternative (",(100*L.marker.candidate.probability).toFixed(0),"%)"]}),L.marker.isPrimary&&L.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[L.marker.candidateCount," candidates"]})]})})]},H)})]})}export{F as default};