mirror of
https://github.com/dmduran12/pymc_console-dist.git
synced 2026-07-06 09:51:50 +02:00
2d961cef1a
Automated sync from private repository. Built with obfuscation enabled.
2 lines
9.7 KiB
JavaScript
2 lines
9.7 KiB
JavaScript
import{r as a,d0 as ae,cc as ie,c0 as le,gz as de,Z as J,cf as ce,j as t,V as K,c as z,gA as ue}from"./index-DeL-WnAD.js";import{M as pe,S as me,L as fe,a as _,P as ge}from"./maplibre-gl-BFLemsGw.js";import{B as xe}from"./BasemapLayer-gTESIItF.js";import{C as he}from"./car-c5UUHE_Y.js";import{H as ye}from"./useMapViewStore-DU2_9KS8.js";import"./index-h4zodNdb.js";import"./index-wSLd8OPk.js";const be={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function G(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function Ce({prefix:c,isLocal:r,isSource:m,isDestination:W,isLastHop:y,isHighlighted:g,isWardrive:k,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,w]=a.useState(!1),P=a.useCallback(()=>{w(!0),E()},[E]),j=a.useCallback(()=>{w(!1),N()},[N]),D=()=>k?"orange":r?"amber":m?"green":y?"amber":W?"purple":"blue";return k?t.jsxs("div",{className:z("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:z("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",n&&"scale-110"),children:t.jsx(he,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:z("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:P,onMouseLeave:j,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:D(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(ye,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function je({hopNumber:c,snr:r,edgeColor:m}){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:m||J[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Ee({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:W,onHoverHop:y,traceSnr:g}){const k=g!==void 0&&g.length>0,x=a.useRef(null),E=ae(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,w]=a.useState(null),P=le(),[j,D]=a.useState(!1),[Z,U]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.warn("[PathMapMapLibre] WebGL context restored, remounting..."),U(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:v,markers:$,edges:I}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,V)=>p!==0||V!==0;let l=0,b=!1;return c.hops.forEach((p,V)=>{const Y=p.candidates.filter(d=>f(d.latitude,d.longitude));if(Y.length===0)return;const R=[...Y].sort((d,F)=>F.probability-d.probability),A=R[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],F=i.length-2,M=g==null?void 0:g[F],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=G();let B;b?B="#F97316":M!==void 0?B=de()[ce(M,N)]||J[500]:B=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:B,isFromWardrive:b})}const te=p.isSource===!0,oe=p.isDestination===!0;b=A.isWardrive===!0,R.forEach((d,F)=>{const M=[d.latitude,d.longitude];e.push(M);const T=F===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:R.length,hopIndex:V,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),q=a.useMemo(()=>I.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[I]),u=a.useMemo(()=>{const e=$.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;b<o&&(o=b),b>s&&(s=b),p<i&&(i=p),p>f&&(f=p)}return[[i,o],[f,s]]},[$]),O=a.useMemo(()=>{if(v.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of v)e+=s,o+=i;return[o/v.length,e/v.length]},[v,r]),H=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){D(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{D(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!j)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,j,u]);const Q=P&&j,ee=a.useCallback(e=>{w({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return v.length===0?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 radius-inner overflow-hidden depth-stroke-inset",children:[!Q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",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:Q?1:0},children:t.jsxs(pe,{ref:x,initialViewState:{longitude:O[0],latitude:O[1],zoom:10},onLoad:H,style:{height:"100%",width:"100%"},mapStyle:be,attributionControl:!1,children:[t.jsx(xe,{mode:E}),I.map((e,o)=>t.jsx(me,{id:`edge-${o}`,type:"geojson",data:q[o],children:t.jsx(fe,{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(_,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(je,{hopNumber:o+1,snr:k?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=$.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=W===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(_,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(Ce,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(ge,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>w(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:n.marker.candidate.name}),(()=>{const e=G();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.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"}),n.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:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:G().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Ee as default};
|