mirror of
https://github.com/dmduran12/pymc_console-dist.git
synced 2026-08-07 01:13:17 +02:00
8f409ebe4b
Automated sync from private repository. Built with obfuscation enabled.
2 lines
9.6 KiB
JavaScript
2 lines
9.6 KiB
JavaScript
import{c as e,f as t,y as o,g as s,j as n,X as a}from"./index-BGpEYDgg.js";import{b as r,g as l,c as i}from"./recharts-bmHCCfxU.js";import{L as c}from"./leaflet-ClE6qLuu.js";import{T as d}from"./triangle-alert-gjNmk6Qq.js";import{M as m,a as u,C as h}from"./map-pin-M5vgOJxL.js";const x=e("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]),p=e("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]),f=e("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"}]]),y=e("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"}]]),b="#4338CA",v="#F59E0B",g="#39D98A";function w({hash:e,highlighted:t}){const[o,s]=r.useState(!1),a=r.useCallback(t=>{t.preventDefault(),t.stopPropagation(),function(e){if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const t=window.scrollX,o=window.scrollY,s=document.createElement("textarea");s.value=e,s.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",s.setAttribute("readonly",""),document.body.appendChild(s),s.focus({preventScroll:!0}),s.select(),s.setSelectionRange(0,e.length);const n=document.execCommand("copy");return document.body.removeChild(s),window.scrollTo(t,o),n}catch{return!1}}(e),s(!0),setTimeout(()=>s(!1),2e3)},[e]),l=e.length>12?`${e.slice(0,12)}…`:e;return n.jsxs("button",{type:"button",onClick:a,className:i("inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] font-mono rounded transition-all","border border-border-subtle hover:border-border-strong cursor-pointer select-none",t?"bg-accent-secondary/20 border-accent-secondary/50":"bg-bg-subtle/80 hover:bg-bg-elevated"),title:`Click to copy: ${e}`,children:[n.jsx("span",{className:i("transition-colors",o?"text-accent-success":"text-text-secondary"),children:l}),o?n.jsx(u,{className:"w-2.5 h-2.5 text-accent-success"}):n.jsx(h,{className:"w-2.5 h-2.5 opacity-40"})]})}function j({node:e,className:t}){const o=e.contactType.toLowerCase(),s="room server"===o||"room_server"===o||"room"===o||"server"===o,a="companion"===o||"client"===o||"cli"===o;return s&&e.isRepeater?n.jsxs("div",{className:i("relative",t),children:[n.jsx(p,{className:"w-full h-full",style:{color:v}}),n.jsx(y,{className:"w-1/2 h-1/2 absolute -bottom-0.5 -right-0.5",style:{color:b}})]}):s?n.jsx(p,{className:t,style:{color:v}}):a?n.jsx(f,{className:i(t,"text-text-muted")}):e.isRepeater?e.isNeighbor?n.jsx(x,{className:t,style:{color:g}}):n.jsx(y,{className:t,style:{color:b}}):n.jsx(f,{className:i(t,"text-text-muted")})}function N({node:e,isHovered:t,onMouseEnter:o,onMouseLeave:s,onTouchStart:a}){return n.jsxs("div",{className:i("flex items-center gap-3 px-3 py-2.5 transition-colors rounded-lg",t?"bg-accent-secondary/10":"hover:bg-white/[0.03]"),onMouseEnter:o,onMouseLeave:s,onTouchStart:a,children:[n.jsx("div",{className:"flex-shrink-0 w-5 h-5",children:n.jsx(j,{node:e,className:"w-5 h-5"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),e.isNeighbor&&n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium",style:{backgroundColor:"rgba(57, 217, 138, 0.2)",color:"#39D98A"},children:"NBR"}),e.isRepeater&&n.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-text-muted font-medium",children:"RPT"})]}),n.jsx("div",{className:"mt-1",children:n.jsx(w,{hash:e.hash,highlighted:t})})]})]})}function k({nodes:e,hoveredHash:t,onNodeHover:o,onNodeLeave:s}){const a=r.useRef(null),l=r.useRef(null),i=r.useRef(new Map),d=r.useMemo(()=>e.filter(e=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude),[e]);return r.useEffect(()=>{if(!l.current||a.current)return;const e=c.map(l.current,{zoomControl:!0,attributionControl:!0});return c.tileLayer("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",{attribution:'© <a href="https://www.openstreetmap.org/copyright">OSM</a> © <a href="https://carto.com/">CARTO</a>'}).addTo(e),a.current=e,()=>{e.remove(),a.current=null}},[]),r.useEffect(()=>{const e=a.current;if(!e)return;if(i.current.forEach(e=>e.remove()),i.current.clear(),0===d.length)return;const t=c.latLngBounds([]);for(const n of d){if(!n.latitude||!n.longitude)continue;const a=c.latLng(n.latitude,n.longitude);t.extend(a);const r=n.isNeighbor?g:b,l=c.circleMarker(a,{radius:8,fillColor:r,fillOpacity:.8,color:"#fff",weight:2,opacity:.9});l.bindTooltip(n.name,{permanent:!1,direction:"top",offset:[0,-8],className:"collision-tooltip"}),l.on("mouseover",()=>o(n.hash)),l.on("mouseout",()=>s()),l.addTo(e),i.current.set(n.hash,l)}t.isValid()&&e.fitBounds(t,{padding:[40,40],maxZoom:12})},[d,o,s]),r.useEffect(()=>{i.current.forEach((e,o)=>{const s=d.find(e=>e.hash===o);if(!s)return;const n=o===t,a=s.isNeighbor?g:b;e.setStyle({radius:n?12:8,fillColor:n?"#FBBF24":a,weight:n?3:2}),n?(e.openTooltip(),e.bringToFront()):e.closeTooltip()})},[t,d]),0===d.length?n.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 rounded-lg",children:n.jsxs("div",{className:"text-center text-text-muted p-4",children:[n.jsx(m,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),n.jsx("p",{className:"text-sm",children:"No location data available"}),n.jsx("p",{className:"text-xs opacity-70",children:"Nodes need GPS coordinates to appear on the map"})]})}):n.jsx("div",{ref:l,className:"h-full w-full rounded-lg overflow-hidden"})}const C=r.memo(function({isOpen:e,prefix:c,candidateHashes:m,onClose:u}){const h=t(),x=o(),p=s(),[f,y]=r.useState(null),b=r.useMemo(()=>new Set(p.map(e=>e.hash)),[p]),v=null==h?void 0:h.neighbors,g=r.useMemo(()=>v?m.map(e=>{var t,o;const s=v[e];return{hash:e,name:(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==s?void 0:s.contact_type)||"",isRepeater:(null==s?void 0:s.is_repeater)||"repeater"===(null==(t=null==s?void 0:s.contact_type)?void 0:t.toLowerCase())||"rep"===(null==(o=null==s?void 0:s.contact_type)?void 0:o.toLowerCase())||!1,isNeighbor:b.has(e),isHub:x.has(e),latitude:null==s?void 0:s.latitude,longitude:null==s?void 0:s.longitude,lastSeen:null==s?void 0:s.last_seen}}).sort((e,t)=>e.isNeighbor!==t.isNeighbor?e.isNeighbor?-1:1:e.name.localeCompare(t.name)):[],[m,v,b,x]),w=r.useCallback(e=>y(e),[]),j=r.useCallback(()=>y(null),[]);return r.useEffect(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&u()};window.addEventListener("keydown",t);const o=window.scrollY,s={overflow:document.body.style.overflow,position:document.body.style.position,width:document.body.style.width,top:document.body.style.top};return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${o}px`,()=>{window.removeEventListener("keydown",t),document.body.style.overflow=s.overflow,document.body.style.position=s.position,document.body.style.width=s.width,document.body.style.top=s.top,window.scrollTo(0,o)}},[e,u]),e?l.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[10010] flex items-end sm:items-center justify-center",onClick:u,role:"dialog","aria-modal":"true","aria-labelledby":"collision-modal-title",children:n.jsxs("div",{className:i("glass-card w-full overflow-hidden flex flex-col","max-h-[85vh] rounded-t-2xl rounded-b-none","sm:max-w-2xl sm:mx-4 sm:rounded-xl sm:max-h-[80vh]","pb-safe"),onClick:e=>e.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 rounded-lg bg-signal-fair/10",children:n.jsx(d,{className:"w-5 h-5 text-signal-fair"})}),n.jsxs("div",{children:[n.jsxs("h3",{id:"collision-modal-title",className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",n.jsx("span",{className:"font-mono text-accent-primary",children:c})]}),n.jsxs("p",{className:"text-xs text-text-muted",children:[g.length," nodes share this prefix"]})]})]}),n.jsx("button",{onClick:u,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:n.jsx(a,{className:"w-5 h-5"})})]}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-col sm:flex-row overflow-hidden",children:[n.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto sm:max-w-[280px] sm:border-r sm:border-border-subtle",children:n.jsx("div",{className:"p-2",children:g.map(e=>n.jsx(N,{node:e,isHovered:f===e.hash,onMouseEnter:()=>w(e.hash),onMouseLeave:j,onTouchStart:()=>w(e.hash)},e.hash))})}),n.jsx("div",{className:"h-48 sm:h-auto sm:flex-1 p-2 flex-shrink-0",children:n.jsx(k,{nodes:g,hoveredHash:f,onNodeHover:w,onNodeLeave:j})})]})]})}),document.body):null});export{x as A,C,p as M,y as S,f as a};
|