Files
pyMC_Repeater/repeater/web/html/assets/Neighbors-Iq3xu5XJ.js
2026-03-27 12:36:25 +00:00

66 lines
89 KiB
JavaScript

import{a as bt,e as _,h as P,f as t,t as w,x as Lt,q as k,M as Yt,r as D,c as q,E as ht,N as Rt,g as it,T as Ft,m as Dt,O as jt,k as C,F as ct,i as gt,y as It,l as et,o as Xt,P as te,j as ft,H as Pt,n as At,w as wt,Q as ie,s as Wt,v as le,L as Et}from"./index-xzvnOpJo.js";import{u as Ut}from"./useSignalQuality-DZXpd2l9.js";import{L as Q}from"./leaflet-src-BtisrQHC.js";/* empty css */import{g as _t,s as Ct}from"./preferences-DtwbSSgO.js";import"./_commonjsHelpers-CqkleIqs.js";const de={class:"bg-gray-50 dark:bg-white/5 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mb-6"},ce={class:"flex items-center gap-3"},ue={class:"flex-1 min-w-0"},pe={class:"text-content-primary dark:text-content-primary font-medium truncate"},ge={class:"text-content-secondary dark:text-content-muted text-sm font-mono"},me={key:0,class:"text-white/50 text-xs"},he={key:1,class:"text-white/50 text-xs"},be=bt({__name:"DeleteNeighborModal",props:{show:{type:Boolean},neighbor:{}},emits:["close","delete"],setup($,{emit:r}){const o=$,i=r,e=()=>{o.neighbor&&(i("delete",o.neighbor.id),d())},d=()=>{i("close")},h=s=>{s.target===s.currentTarget&&d()};return(s,a)=>s.show&&s.neighbor?(k(),_("div",{key:0,onClick:h,class:"fixed inset-0 bg-black/80 backdrop-blur-lg z-[99999] flex items-center justify-center p-4",style:{"backdrop-filter":"blur(8px) saturate(180%)",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"}},[t("div",{class:"bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] p-6 w-full max-w-md border border-stroke-subtle dark:border-white/10",onClick:a[0]||(a[0]=Lt(()=>{},["stop"]))},[t("div",{class:"flex items-center gap-3 mb-6"},[a[2]||(a[2]=t("svg",{class:"w-6 h-6 text-accent-red",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),a[3]||(a[3]=t("div",null,[t("h3",{class:"text-xl font-semibold text-content-primary dark:text-content-primary"},"Delete Neighbor"),t("p",{class:"text-content-secondary dark:text-content-muted text-sm mt-1"}," Are you sure you want to delete this neighbor? ")],-1)),t("button",{onClick:d,class:"ml-auto text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors"},a[1]||(a[1]=[t("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))]),t("div",de,[t("div",ce,[t("div",ue,[t("div",pe,w(s.neighbor?.node_name||s.neighbor?.long_name||s.neighbor?.short_name||"Unknown"),1),t("div",ge," ID: "+w(s.neighbor?.node_num_hex||s.neighbor?.node_num||s.neighbor?.id||"N/A"),1),s.neighbor?.contact_type?(k(),_("div",me,w(s.neighbor.contact_type),1)):P("",!0),s.neighbor?.hw_model?(k(),_("div",he,w(s.neighbor.hw_model),1)):P("",!0)])])]),a[4]||(a[4]=t("div",{class:"bg-accent-red/10 border border-accent-red/30 rounded-lg p-4 mb-6"},[t("div",{class:"flex items-center gap-2 text-accent-red text-sm"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),t("span",null,"This action cannot be undone")])],-1)),t("div",{class:"flex gap-3"},[t("button",{onClick:d,class:"flex-1 px-4 py-3 bg-background-mute dark:bg-white/5 hover:bg-stroke-subtle dark:hover:bg-white/10 border border-stroke-subtle dark:border-stroke/20 text-content-primary dark:text-content-primary rounded-lg transition-colors"}," Cancel "),t("button",{onClick:e,class:"flex-1 px-4 py-3 bg-accent-red/20 hover:bg-accent-red/30 border border-accent-red/50 text-accent-red rounded-lg transition-colors font-medium"}," Delete ")])])])):P("",!0)}}),xe={class:"bg-gradient-to-r from-primary/20 to-accent-cyan/20 border-b border-stroke-subtle dark:border-stroke/10 px-6 py-4"},ye={class:"flex items-center justify-between"},ve={class:"flex items-center gap-3"},ke={key:0,class:"text-sm text-content-secondary dark:text-content-muted"},fe={class:"p-6"},we={key:0,class:"text-center py-8"},_e={key:1,class:"text-center py-8"},Ce={class:"text-content-secondary dark:text-content-muted text-sm"},Me={key:2,class:"space-y-4"},$e={class:"bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4"},Ae={class:"flex items-center justify-between mb-2"},Le={class:"flex items-baseline gap-2"},Te={class:"text-3xl font-bold text-content-primary dark:text-content-primary"},Ee={class:"grid grid-cols-2 gap-3"},Se={class:"bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4"},Be={class:"flex items-center gap-2 mb-2"},Ne={class:"flex gap-0.5"},Fe={class:"flex items-baseline gap-1"},De={class:"text-xl font-bold text-content-primary dark:text-content-primary"},Pe={class:"bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4"},ze={class:"flex items-baseline gap-1"},Re={class:"text-xl font-bold text-content-primary dark:text-content-primary"},je={key:0,class:"flex items-start gap-3 bg-amber-500/10 border border-amber-500/30 rounded-[12px] p-3"},Ie={class:"text-xs leading-relaxed"},Ue={class:"font-semibold text-amber-600 dark:text-amber-400 mb-0.5"},Oe={class:"bg-background-mute dark:bg-background/50 border border-stroke-subtle dark:border-stroke/10 rounded-[15px] p-4"},He={class:"relative"},Ve={class:"flex items-center gap-2 overflow-x-auto pb-2"},Ze={key:0,class:"relative flex items-center"},We={key:0,class:"absolute left-1/2 -translate-x-1/2 animate-pulse"},Qe={class:"text-content-muted dark:text-content-muted text-xs mt-2 flex items-center justify-between"},qe={key:0,class:"text-cyan-500 dark:text-primary animate-pulse"},Ke={class:"flex items-center justify-between text-xs text-content-muted dark:text-content-muted pt-2"},Ge=bt({__name:"PingResultModal",props:{show:{type:Boolean},nodeName:{default:null},result:{default:null},error:{default:null},loading:{type:Boolean,default:!1}},emits:["close"],setup($,{emit:r}){const o=$,i=r,e=Yt(),{getSignalQuality:d}=Ut(),h=D(0),s=D(!1),a=q(()=>{const g=e.stats?.config?.radio?.spreading_factor??7,c=e.stats?.config?.radio?.bandwidth??125,T=e.stats?.config?.radio?.coding_rate??5,F=Math.pow(2,g)/c,I=8+4.25*(T-4)+20;return F*I}),f=q(()=>{if(!o.result)return{color:"text-gray-400",label:"Unknown"};const g=o.result.rtt_ms,c=a.value,T=o.result.path.length,I=2*c*T+500*T;return g<I*2.5?{color:"text-green-600 dark:text-green-400",label:"Excellent"}:g<I*4?{color:"text-yellow-600 dark:text-yellow-400",label:"Good"}:g<I*7?{color:"text-orange-600 dark:text-orange-400",label:"Fair"}:{color:"text-red-600 dark:text-red-400",label:"Poor"}}),b=q(()=>{if(!o.result)return{bars:0,color:"text-gray-400"};const g=d(o.result.rssi);return{bars:g.bars,color:g.color}}),v=q(()=>{if(!o.result)return 0;if(o.result.path_hash_mode!==void 0)return o.result.path_hash_mode;const g=o.result.path.reduce((c,T)=>{const F=T.replace(/^0x/i,"");return Math.max(c,F.length)},0);return g>4?2:g>2?1:0}),L=q(()=>v.value>0),B=q(()=>({0:"1-byte",1:"2-byte",2:"3-byte"})[v.value]??"1-byte");ht(()=>o.result,g=>{if(g&&!s.value){s.value=!0,h.value=0;const c=g.path.length,F=1500/(c*2);let I=0;const y=c*2-2,p=()=>{I<=y?(h.value=I/y,I++,setTimeout(p,F)):(s.value=!1,h.value=1)};setTimeout(p,100)}},{immediate:!0});const N=q(()=>{if(!o.result||!s.value)return-1;const g=o.result.path.length;if(g<=1)return-1;const c=h.value,T=.5;if(c<=T)return c/T*(g-1);{const F=(c-T)/T;return(g-1)*(1-F)}}),S=()=>{i("close")};return(g,c)=>(k(),Rt(jt,{to:"body"},[it(Ft,{name:"modal"},{default:Dt(()=>[g.show?(k(),_("div",{key:0,class:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-[99999] p-4",onClick:Lt(S,["self"])},[t("div",{class:"glass-card backdrop-blur-xl border border-stroke-subtle dark:border-white/20 rounded-[20px] shadow-2xl w-full max-w-md overflow-hidden",onClick:c[0]||(c[0]=Lt(()=>{},["stop"]))},[t("div",xe,[t("div",ye,[t("div",ve,[c[2]||(c[2]=t("div",{class:"p-2 bg-cyan-400/20 dark:bg-primary/20 rounded-lg"},[t("svg",{class:"w-5 h-5 text-cyan-500 dark:text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})])],-1)),t("div",null,[c[1]||(c[1]=t("h2",{class:"text-xl font-bold text-content-primary dark:text-content-primary"},"Ping Result",-1)),g.nodeName?(k(),_("p",ke,w(g.nodeName),1)):P("",!0)])]),t("button",{onClick:S,class:"p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary"},c[3]||(c[3]=[t("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))])]),t("div",fe,[g.loading?(k(),_("div",we,c[4]||(c[4]=[t("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"},null,-1),t("p",{class:"text-content-secondary dark:text-content-muted"},"Sending ping...",-1),t("p",{class:"text-content-muted dark:text-content-muted text-sm mt-1"},"Waiting for response...",-1)]))):g.error?(k(),_("div",_e,[c[5]||(c[5]=t("div",{class:"p-3 bg-accent-red/10 rounded-full w-16 h-16 mx-auto mb-4 flex items-center justify-center"},[t("svg",{class:"w-8 h-8 text-accent-red",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z"})])],-1)),c[6]||(c[6]=t("h3",{class:"text-accent-red font-semibold mb-2"},"Ping Failed",-1)),t("p",Ce,w(g.error),1)])):g.result?(k(),_("div",Me,[t("div",$e,[t("div",Ae,[c[7]||(c[7]=t("span",{class:"text-content-secondary dark:text-content-muted text-sm"},"Round-Trip Time",-1)),t("span",{class:C(["text-xs font-medium px-2 py-1 rounded-full",f.value.color,"bg-current/10"])},w(f.value.label),3)]),t("div",Le,[t("span",Te,w(g.result.rtt_ms.toFixed(2)),1),c[8]||(c[8]=t("span",{class:"text-content-secondary dark:text-content-muted"},"ms",-1))])]),t("div",Ee,[t("div",Se,[t("div",Be,[c[9]||(c[9]=t("span",{class:"text-content-secondary dark:text-content-muted text-sm"},"RSSI",-1)),t("div",Ne,[(k(),_(ct,null,gt(5,T=>t("div",{key:T,class:C(["w-1 h-3 rounded-sm",T<=b.value.bars?b.value.color:"bg-stroke-subtle dark:bg-stroke/10"])},null,2)),64))])]),t("div",Fe,[t("span",De,w(g.result.rssi),1),c[10]||(c[10]=t("span",{class:"text-content-secondary dark:text-content-muted text-xs"},"dBm",-1))])]),t("div",Pe,[c[12]||(c[12]=t("div",{class:"text-content-secondary dark:text-content-muted text-sm mb-2"},"SNR",-1)),t("div",ze,[t("span",Re,w(g.result.snr_db),1),c[11]||(c[11]=t("span",{class:"text-content-secondary dark:text-content-muted text-xs"},"dB",-1))])])]),L.value?(k(),_("div",je,[c[14]||(c[14]=t("svg",{class:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-1.964-1.333-2.732 0L3.268 16c-.77 1.333.192 3 1.732 3z"})],-1)),t("div",Ie,[t("p",Ue,w(B.value)+" path hashes active ",1),c[13]||(c[13]=t("p",{class:"text-content-secondary dark:text-content-muted"}," This result uses multi-byte path hashes. The repeater being traced must be running firmware that supports multi-byte path hashes. Repeaters on older firmware will not respond to or correctly route these trace packets. ",-1))])])):P("",!0),t("div",Oe,[c[17]||(c[17]=t("div",{class:"text-content-secondary dark:text-content-muted text-sm mb-3"},"Network Path",-1)),t("div",He,[t("div",Ve,[(k(!0),_(ct,null,gt(g.result.path,(T,F)=>(k(),_("div",{key:F,class:"flex items-center gap-2 flex-shrink-0 relative"},[t("div",{class:C(["bg-cyan-400/20 dark:bg-primary/20 text-cyan-600 dark:text-primary border border-cyan-400/40 dark:border-primary/30 px-3 py-1.5 rounded-lg text-sm font-mono transition-all duration-300",s.value&&Math.floor(N.value)===F?"ring-2 ring-cyan-400/50 dark:ring-primary/50 scale-105":""])},w(T),3),F<g.result.path.length-1?(k(),_("div",Ze,[c[16]||(c[16]=t("svg",{class:"w-4 h-4 text-white/40 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})],-1)),it(Ft,{name:"packet"},{default:Dt(()=>[s.value&&N.value>=F&&N.value<F+1?(k(),_("div",We,c[15]||(c[15]=[t("svg",{class:"w-3 h-3 text-cyan-500 dark:text-primary drop-shadow-[0_0_6px_rgba(6,182,212,0.8)] dark:drop-shadow-[0_0_6px_rgba(59,130,246,0.8)]",fill:"currentColor",viewBox:"0 0 24 24"},[t("circle",{cx:"12",cy:"12",r:"8"})],-1)]))):P("",!0)]),_:2},1024)])):P("",!0)]))),128))])]),t("div",Qe,[t("span",null,w(g.result.path.length)+" hop"+w(g.result.path.length!==1?"s":""),1),s.value?(k(),_("span",qe,"● Tracing route...")):P("",!0)])]),t("div",Ke,[t("span",null,"Target: "+w(g.result.target_id),1),t("span",null,"Tag: #"+w(g.result.tag),1)])])):P("",!0)]),t("div",{class:"border-t border-stroke-subtle dark:border-stroke/10 px-6 py-4"},[t("button",{onClick:S,class:"w-full py-2.5 bg-gradient-to-r from-cyan-400 to-cyan-500 text-white hover:from-cyan-500 hover:to-cyan-600 dark:bg-primary/20 dark:text-primary dark:border dark:border-primary/30 dark:hover:bg-primary/30 dark:from-transparent dark:to-transparent rounded-lg font-medium transition-all shadow-[0_2px_12px_rgba(6,182,212,0.3)] dark:shadow-none"}," Close ")])])])):P("",!0)]),_:1})]))}}),Je=It(Ge,[["__scopeId","data-v-c4eb8a10"]]),Ye={class:"bg-white dark:bg-surface-elevated backdrop-blur-xl rounded-[20px] shadow-2xl border border-stroke-subtle dark:border-white/20 flex flex-col h-full overflow-hidden"},Xe={class:"flex items-center justify-between p-8 pb-4 flex-shrink-0"},to={class:"flex-1 min-w-0"},eo={class:"text-2xl font-bold text-content-primary dark:text-content-primary mb-1"},oo={class:"text-content-secondary dark:text-content-muted text-sm font-mono break-all"},ro={class:"flex items-center gap-2"},no={class:"flex-1 overflow-y-auto custom-scrollbar px-8"},so={class:"mb-6"},ao={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},io={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},lo={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},co={class:"text-content-primary dark:text-content-primary font-medium"},uo={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},po={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},go={class:"text-content-primary dark:text-content-primary font-medium"},mo={class:"mb-6"},ho={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},bo={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},xo={class:"text-content-primary dark:text-content-primary font-medium"},yo={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},vo={class:"text-content-primary dark:text-content-primary font-medium"},ko={key:0,class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},fo={class:"flex items-center gap-2"},wo={class:"flex gap-0.5"},_o={class:"mb-6"},Co={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Mo={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},$o={class:"text-content-primary dark:text-content-primary text-sm"},Ao={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},Lo={class:"text-content-primary dark:text-content-primary text-sm"},To={key:0,class:"mb-6"},Eo={class:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4"},So={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},Bo={class:"text-content-primary dark:text-content-primary font-mono text-sm"},No={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},Fo={class:"text-content-primary dark:text-content-primary font-mono text-sm"},Do={class:"glass-card bg-background-mute dark:bg-black/20 p-4 rounded-[12px]"},Po={class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},zo={key:0,class:"text-content-primary dark:text-content-primary font-medium"},Ro={class:"p-8 pt-4 border-t border-stroke-subtle dark:border-white/10 flex-shrink-0"},jo=bt({name:"NeighborDetailsModal",__name:"NeighborDetailsModal",props:{neighbor:{},isOpen:{type:Boolean},baseLatitude:{default:null},baseLongitude:{default:null}},emits:["close"],setup($,{emit:r}){const{getSignalQuality:o}=Ut(),i=D("Copy"),e=$,d=r,h=D();let s=null;const a=y=>new Date(y*1e3).toLocaleString(),f=y=>y?`${y} dBm`:"N/A",b=y=>y?`${y.toFixed(1)} dB`:"N/A",v=y=>({0:"Transport Flood",1:"Flood",2:"Direct",3:"Transport Direct"})[y||0]||"Unknown",L=y=>({Unknown:"Unknown","Chat Node":"Chat Node",Repeater:"Repeater","Room Server":"Room Server","Hybrid Node":"Hybrid Node"})[y]||y,B=y=>({Unknown:"text-gray-600 dark:text-gray-400","Chat Node":"text-blue-600 dark:text-blue-400",Repeater:"text-emerald-600 dark:text-emerald-400","Room Server":"text-purple-600 dark:text-purple-400","Hybrid Node":"text-amber-600 dark:text-amber-400"})[y]||"text-gray-600 dark:text-gray-400",N=async()=>{if(!e.neighbor?.latitude||!e.neighbor?.longitude)return;const y=e.neighbor.latitude.toFixed(6),p=e.neighbor.longitude.toFixed(6),U=`${y}, ${p}`;try{await navigator.clipboard.writeText(U),i.value="Copied!",setTimeout(()=>{i.value="Copy"},2e3)}catch(Y){console.error("Failed to copy coordinates:",Y),i.value="Failed",setTimeout(()=>{i.value="Copy"},2e3)}},S=q(()=>{if(!e.neighbor?.latitude||!e.neighbor?.longitude||!e.baseLatitude||!e.baseLongitude)return null;const y=6371,p=(e.neighbor.latitude-e.baseLatitude)*Math.PI/180,U=(e.neighbor.longitude-e.baseLongitude)*Math.PI/180,Y=Math.sin(p/2)*Math.sin(p/2)+Math.cos(e.baseLatitude*Math.PI/180)*Math.cos(e.neighbor.latitude*Math.PI/180)*Math.sin(U/2)*Math.sin(U/2),ot=2*Math.atan2(Math.sqrt(Y),Math.sqrt(1-Y));return y*ot}),g=q(()=>e.neighbor?.latitude!==null&&e.neighbor?.longitude!==null&&e.neighbor?.latitude!==0&&e.neighbor?.longitude!==0&&Math.abs(e.neighbor?.latitude??0)<=90&&Math.abs(e.neighbor?.longitude??0)<=180),c=()=>{if(!h.value||!e.neighbor||!g.value)return;s&&(s.remove(),s=null);const y=document.documentElement.classList.contains("dark");s=Q.map(h.value,{center:[e.neighbor.latitude,e.neighbor.longitude],zoom:13,zoomControl:!0,attributionControl:!1});const p=y?"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png":"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png";Q.tileLayer(p,{maxZoom:19,attribution:"© OpenStreetMap © CARTO"}).addTo(s);const U=Q.divIcon({className:"custom-marker",html:`<div class="w-8 h-8 rounded-full bg-blue-500 border-2 border-white shadow-lg flex items-center justify-center text-white font-bold text-xs">${e.neighbor.node_name?.charAt(0)||"?"}</div>`,iconSize:[32,32],iconAnchor:[16,16]});if(Q.marker([e.neighbor.latitude,e.neighbor.longitude],{icon:U}).addTo(s).bindPopup(`<b>${e.neighbor.node_name||"Unknown"}</b><br>${e.neighbor.pubkey.slice(0,8)}...`),e.baseLatitude!==null&&e.baseLongitude!==null&&e.baseLatitude!==0&&e.baseLongitude!==0&&Math.abs(e.baseLatitude)<=90&&Math.abs(e.baseLongitude)<=180){const ot=Q.divIcon({className:"custom-marker",html:'<div class="w-8 h-8 rounded-full bg-green-500 border-2 border-white shadow-lg flex items-center justify-center text-white font-bold text-xs">B</div>',iconSize:[32,32],iconAnchor:[16,16]});Q.marker([e.baseLatitude,e.baseLongitude],{icon:ot}).addTo(s).bindPopup("<b>Base Station</b>"),Q.polyline([[e.baseLatitude,e.baseLongitude],[e.neighbor.latitude,e.neighbor.longitude]],{color:"#3b82f6",weight:2,opacity:.6,dashArray:"5, 10"}).addTo(s);const lt=Q.latLngBounds([e.baseLatitude,e.baseLongitude],[e.neighbor.latitude,e.neighbor.longitude]);s.fitBounds(lt,{padding:[50,50]})}},T=y=>{y.key==="Escape"&&d("close")},F=y=>{y.target===y.currentTarget&&d("close")};ht(()=>e.isOpen,y=>{y?(document.body.style.overflow="hidden",setTimeout(()=>{g.value&&c()},100)):(document.body.style.overflow="",s&&(s.remove(),s=null))},{immediate:!0});const I=q(()=>e.neighbor?.rssi?o(e.neighbor.rssi):null);return(y,p)=>(k(),Rt(jt,{to:"body"},[it(Ft,{name:"modal",appear:""},{default:Dt(()=>[y.isOpen&&y.neighbor?(k(),_("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-hidden",onClick:F,onKeydown:T,tabindex:"0"},[p[20]||(p[20]=t("div",{class:"absolute inset-0 bg-black/60 backdrop-blur-md pointer-events-none"},null,-1)),t("div",{class:"relative w-full max-w-4xl max-h-[90vh] flex flex-col",onClick:p[2]||(p[2]=Lt(()=>{},["stop"]))},[t("div",Ye,[t("div",Xe,[t("div",to,[t("h2",eo,w(y.neighbor.node_name||"Unknown Node"),1),t("p",oo,w(y.neighbor.pubkey),1)]),t("div",ro,[t("button",{onClick:p[0]||(p[0]=U=>d("close")),class:"w-8 h-8 flex items-center justify-center rounded-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors duration-200 text-gray-700 dark:text-white hover:text-gray-900 dark:hover:text-white"},p[3]||(p[3]=[t("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)]))])]),t("div",no,[t("div",so,[p[8]||(p[8]=t("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-4"},"Basic Information",-1)),t("div",ao,[t("div",io,[p[4]||(p[4]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Contact Type",-1)),t("div",{class:C(["font-medium",B(y.neighbor.contact_type)])},w(L(y.neighbor.contact_type)),3)]),t("div",lo,[p[5]||(p[5]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Route Type",-1)),t("div",co,w(v(y.neighbor.route_type)),1)]),t("div",uo,[p[6]||(p[6]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Zero Hop",-1)),t("div",{class:C(["font-medium",y.neighbor.zero_hop?"text-green-600 dark:text-green-400":"text-gray-600 dark:text-gray-400"])},w(y.neighbor.zero_hop?"Yes":"No"),3)]),t("div",po,[p[7]||(p[7]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Advert Count",-1)),t("div",go,w(y.neighbor.advert_count.toLocaleString()),1)])])]),t("div",mo,[p[12]||(p[12]=t("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-4"},"Signal Quality",-1)),t("div",ho,[t("div",bo,[p[9]||(p[9]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"RSSI",-1)),t("div",xo,w(f(y.neighbor.rssi)),1)]),t("div",yo,[p[10]||(p[10]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"SNR",-1)),t("div",vo,w(b(y.neighbor.snr)),1)]),I.value?(k(),_("div",ko,[p[11]||(p[11]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Signal Strength",-1)),t("div",fo,[t("div",wo,[(k(),_(ct,null,gt(4,U=>t("div",{key:U,class:C(["w-1 h-3 rounded-sm",U<=I.value.bars?I.value.color:"bg-gray-300 dark:bg-gray-700"])},null,2)),64))]),t("span",{class:C(["text-sm font-medium",I.value.color])},w(I.value.quality),3)])])):P("",!0)])]),t("div",_o,[p[15]||(p[15]=t("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-4"},"Timeline",-1)),t("div",Co,[t("div",Mo,[p[13]||(p[13]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"First Seen",-1)),t("div",$o,w(a(y.neighbor.first_seen)),1)]),t("div",Ao,[p[14]||(p[14]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Last Seen",-1)),t("div",Lo,w(a(y.neighbor.last_seen)),1)])])]),g.value?(k(),_("div",To,[p[19]||(p[19]=t("h3",{class:"text-lg font-semibold text-content-primary dark:text-content-primary mb-4"},"Location",-1)),t("div",Eo,[t("div",So,[p[16]||(p[16]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Latitude",-1)),t("div",Bo,w(y.neighbor.latitude?.toFixed(6)),1)]),t("div",No,[p[17]||(p[17]=t("div",{class:"text-content-muted dark:text-content-muted text-xs uppercase tracking-wide mb-1"},"Longitude",-1)),t("div",Fo,w(y.neighbor.longitude?.toFixed(6)),1)]),t("div",Do,[t("div",Po,w(S.value!==null?"Distance":"Coordinates"),1),S.value!==null?(k(),_("div",zo,w(S.value.toFixed(2))+" km ",1)):(k(),_("button",{key:1,onClick:N,class:"w-full px-3 py-1.5 bg-primary hover:bg-primary/90 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium rounded-lg transition-colors flex items-center justify-center gap-1.5"},[p[18]||(p[18]=t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)),et(" "+w(i.value),1)]))])]),t("div",{ref_key:"mapContainer",ref:h,class:"w-full h-96 rounded-[12px] overflow-hidden border border-stroke-subtle dark:border-white/10"},null,512)])):P("",!0)]),t("div",Ro,[t("button",{onClick:p[1]||(p[1]=U=>d("close")),class:"w-full px-4 py-2.5 bg-primary hover:bg-primary/90 dark:bg-gray-700 dark:hover:bg-gray-600 text-white font-medium rounded-lg transition-colors"}," Close ")])])])],32)):P("",!0)]),_:1})]))}}),Io=It(jo,[["__scopeId","data-v-5669a05a"]]),Qt=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],St=1,vt=8;class Ot{static from(r){if(!(r instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[o,i]=new Uint8Array(r,0,2);if(o!==219)throw new Error("Data does not appear to be in a KDBush format.");const e=i>>4;if(e!==St)throw new Error(`Got v${e} data when expected v${St}.`);const d=Qt[i&15];if(!d)throw new Error("Unrecognized array type.");const[h]=new Uint16Array(r,2,1),[s]=new Uint32Array(r,4,1);return new Ot(s,h,d,r)}constructor(r,o=64,i=Float64Array,e){if(isNaN(r)||r<0)throw new Error(`Unpexpected numItems value: ${r}.`);this.numItems=+r,this.nodeSize=Math.min(Math.max(+o,2),65535),this.ArrayType=i,this.IndexArrayType=r<65536?Uint16Array:Uint32Array;const d=Qt.indexOf(this.ArrayType),h=r*2*this.ArrayType.BYTES_PER_ELEMENT,s=r*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(d<0)throw new Error(`Unexpected typed array class: ${i}.`);e&&e instanceof ArrayBuffer?(this.data=e,this.ids=new this.IndexArrayType(this.data,vt,r),this.coords=new this.ArrayType(this.data,vt+s+a,r*2),this._pos=r*2,this._finished=!0):(this.data=new ArrayBuffer(vt+h+s+a),this.ids=new this.IndexArrayType(this.data,vt,r),this.coords=new this.ArrayType(this.data,vt+s+a,r*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(St<<4)+d]),new Uint16Array(this.data,2,1)[0]=o,new Uint32Array(this.data,4,1)[0]=r)}add(r,o){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=r,this.coords[this._pos++]=o,i}finish(){const r=this._pos>>1;if(r!==this.numItems)throw new Error(`Added ${r} items when expected ${this.numItems}.`);return zt(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(r,o,i,e){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:d,coords:h,nodeSize:s}=this,a=[0,d.length-1,0],f=[];for(;a.length;){const b=a.pop()||0,v=a.pop()||0,L=a.pop()||0;if(v-L<=s){for(let g=L;g<=v;g++){const c=h[2*g],T=h[2*g+1];c>=r&&c<=i&&T>=o&&T<=e&&f.push(d[g])}continue}const B=L+v>>1,N=h[2*B],S=h[2*B+1];N>=r&&N<=i&&S>=o&&S<=e&&f.push(d[B]),(b===0?r<=N:o<=S)&&(a.push(L),a.push(B-1),a.push(1-b)),(b===0?i>=N:e>=S)&&(a.push(B+1),a.push(v),a.push(1-b))}return f}within(r,o,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:e,coords:d,nodeSize:h}=this,s=[0,e.length-1,0],a=[],f=i*i;for(;s.length;){const b=s.pop()||0,v=s.pop()||0,L=s.pop()||0;if(v-L<=h){for(let g=L;g<=v;g++)qt(d[2*g],d[2*g+1],r,o)<=f&&a.push(e[g]);continue}const B=L+v>>1,N=d[2*B],S=d[2*B+1];qt(N,S,r,o)<=f&&a.push(e[B]),(b===0?r-i<=N:o-i<=S)&&(s.push(L),s.push(B-1),s.push(1-b)),(b===0?r+i>=N:o+i>=S)&&(s.push(B+1),s.push(v),s.push(1-b))}return a}}function zt($,r,o,i,e,d){if(e-i<=o)return;const h=i+e>>1;ee($,r,h,i,e,d),zt($,r,o,i,h-1,1-d),zt($,r,o,h+1,e,1-d)}function ee($,r,o,i,e,d){for(;e>i;){if(e-i>600){const f=e-i+1,b=o-i+1,v=Math.log(f),L=.5*Math.exp(2*v/3),B=.5*Math.sqrt(v*L*(f-L)/f)*(b-f/2<0?-1:1),N=Math.max(i,Math.floor(o-b*L/f+B)),S=Math.min(e,Math.floor(o+(f-b)*L/f+B));ee($,r,o,N,S,d)}const h=r[2*o+d];let s=i,a=e;for(kt($,r,i,o),r[2*e+d]>h&&kt($,r,i,e);s<a;){for(kt($,r,s,a),s++,a--;r[2*s+d]<h;)s++;for(;r[2*a+d]>h;)a--}r[2*i+d]===h?kt($,r,i,a):(a++,kt($,r,a,e)),a<=o&&(i=a+1),o<=a&&(e=a-1)}}function kt($,r,o,i){Bt($,o,i),Bt(r,2*o,2*i),Bt(r,2*o+1,2*i+1)}function Bt($,r,o){const i=$[r];$[r]=$[o],$[o]=i}function qt($,r,o,i){const e=$-o,d=r-i;return e*e+d*d}const Uo={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:$=>$},Kt=Math.fround||($=>r=>($[0]=+r,$[0]))(new Float32Array(1)),mt=2,pt=3,Nt=4,ut=5,oe=6;class Oo{constructor(r){this.options=Object.assign(Object.create(Uo),r),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(r){const{log:o,minZoom:i,maxZoom:e}=this.options;o&&console.time("total time");const d=`prepare ${r.length} points`;o&&console.time(d),this.points=r;const h=[];for(let a=0;a<r.length;a++){const f=r[a];if(!f.geometry)continue;const[b,v]=f.geometry.coordinates,L=Kt(Mt(b)),B=Kt($t(v));h.push(L,B,1/0,a,-1,1),this.options.reduce&&h.push(0)}let s=this.trees[e+1]=this._createTree(h);o&&console.timeEnd(d);for(let a=e;a>=i;a--){const f=+Date.now();s=this.trees[a]=this._createTree(this._cluster(s,a)),o&&console.log("z%d: %d clusters in %dms",a,s.numItems,+Date.now()-f)}return o&&console.timeEnd("total time"),this}getClusters(r,o){let i=((r[0]+180)%360+360)%360-180;const e=Math.max(-90,Math.min(90,r[1]));let d=r[2]===180?180:((r[2]+180)%360+360)%360-180;const h=Math.max(-90,Math.min(90,r[3]));if(r[2]-r[0]>=360)i=-180,d=180;else if(i>d){const v=this.getClusters([i,e,180,h],o),L=this.getClusters([-180,e,d,h],o);return v.concat(L)}const s=this.trees[this._limitZoom(o)],a=s.range(Mt(i),$t(h),Mt(d),$t(e)),f=s.data,b=[];for(const v of a){const L=this.stride*v;b.push(f[L+ut]>1?Gt(f,L,this.clusterProps):this.points[f[L+pt]])}return b}getChildren(r){const o=this._getOriginId(r),i=this._getOriginZoom(r),e="No cluster with the specified id.",d=this.trees[i];if(!d)throw new Error(e);const h=d.data;if(o*this.stride>=h.length)throw new Error(e);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=h[o*this.stride],f=h[o*this.stride+1],b=d.within(a,f,s),v=[];for(const L of b){const B=L*this.stride;h[B+Nt]===r&&v.push(h[B+ut]>1?Gt(h,B,this.clusterProps):this.points[h[B+pt]])}if(v.length===0)throw new Error(e);return v}getLeaves(r,o,i){o=o||10,i=i||0;const e=[];return this._appendLeaves(e,r,o,i,0),e}getTile(r,o,i){const e=this.trees[this._limitZoom(r)],d=Math.pow(2,r),{extent:h,radius:s}=this.options,a=s/h,f=(i-a)/d,b=(i+1+a)/d,v={features:[]};return this._addTileFeatures(e.range((o-a)/d,f,(o+1+a)/d,b),e.data,o,i,d,v),o===0&&this._addTileFeatures(e.range(1-a/d,f,1,b),e.data,d,i,d,v),o===d-1&&this._addTileFeatures(e.range(0,f,a/d,b),e.data,-1,i,d,v),v.features.length?v:null}getClusterExpansionZoom(r){let o=this._getOriginZoom(r)-1;for(;o<=this.options.maxZoom;){const i=this.getChildren(r);if(o++,i.length!==1)break;r=i[0].properties.cluster_id}return o}_appendLeaves(r,o,i,e,d){const h=this.getChildren(o);for(const s of h){const a=s.properties;if(a&&a.cluster?d+a.point_count<=e?d+=a.point_count:d=this._appendLeaves(r,a.cluster_id,i,e,d):d<e?d++:r.push(s),r.length===i)break}return d}_createTree(r){const o=new Ot(r.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<r.length;i+=this.stride)o.add(r[i],r[i+1]);return o.finish(),o.data=r,o}_addTileFeatures(r,o,i,e,d,h){for(const s of r){const a=s*this.stride,f=o[a+ut]>1;let b,v,L;if(f)b=re(o,a,this.clusterProps),v=o[a],L=o[a+1];else{const S=this.points[o[a+pt]];b=S.properties;const[g,c]=S.geometry.coordinates;v=Mt(g),L=$t(c)}const B={type:1,geometry:[[Math.round(this.options.extent*(v*d-i)),Math.round(this.options.extent*(L*d-e))]],tags:b};let N;f||this.options.generateId?N=o[a+pt]:N=this.points[o[a+pt]].id,N!==void 0&&(B.id=N),h.features.push(B)}}_limitZoom(r){return Math.max(this.options.minZoom,Math.min(Math.floor(+r),this.options.maxZoom+1))}_cluster(r,o){const{radius:i,extent:e,reduce:d,minPoints:h}=this.options,s=i/(e*Math.pow(2,o)),a=r.data,f=[],b=this.stride;for(let v=0;v<a.length;v+=b){if(a[v+mt]<=o)continue;a[v+mt]=o;const L=a[v],B=a[v+1],N=r.within(a[v],a[v+1],s),S=a[v+ut];let g=S;for(const c of N){const T=c*b;a[T+mt]>o&&(g+=a[T+ut])}if(g>S&&g>=h){let c=L*S,T=B*S,F,I=-1;const y=((v/b|0)<<5)+(o+1)+this.points.length;for(const p of N){const U=p*b;if(a[U+mt]<=o)continue;a[U+mt]=o;const Y=a[U+ut];c+=a[U]*Y,T+=a[U+1]*Y,a[U+Nt]=y,d&&(F||(F=this._map(a,v,!0),I=this.clusterProps.length,this.clusterProps.push(F)),d(F,this._map(a,U)))}a[v+Nt]=y,f.push(c/g,T/g,1/0,y,-1,g),d&&f.push(I)}else{for(let c=0;c<b;c++)f.push(a[v+c]);if(g>1)for(const c of N){const T=c*b;if(!(a[T+mt]<=o)){a[T+mt]=o;for(let F=0;F<b;F++)f.push(a[T+F])}}}}return f}_getOriginId(r){return r-this.points.length>>5}_getOriginZoom(r){return(r-this.points.length)%32}_map(r,o,i){if(r[o+ut]>1){const h=this.clusterProps[r[o+oe]];return i?Object.assign({},h):h}const e=this.points[r[o+pt]].properties,d=this.options.map(e);return i&&d===e?Object.assign({},d):d}}function Gt($,r,o){return{type:"Feature",id:$[r+pt],properties:re($,r,o),geometry:{type:"Point",coordinates:[Ho($[r]),Vo($[r+1])]}}}function re($,r,o){const i=$[r+ut],e=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?`${Math.round(i/100)/10}k`:i,d=$[r+oe],h=d===-1?{}:Object.assign({},o[d]);return Object.assign(h,{cluster:!0,cluster_id:$[r+pt],point_count:i,point_count_abbreviated:e})}function Mt($){return $/360+.5}function $t($){const r=Math.sin($*Math.PI/180),o=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return o<0?0:o>1?1:o}function Ho($){return($-.5)*360}function Vo($){const r=(180-$*360)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}const Zo={class:"map-container"},Wo={key:0,class:"flex items-center justify-center h-96 glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] shadow-sm dark:shadow-none"},Qo={class:"hidden sm:inline"},qo={key:3,class:"map-legend"},Ko={class:"legend-footer"},Go={key:4,class:"map-attribution"},Jo=bt({__name:"NetworkMap",props:{adverts:{},baseLatitude:{default:null},baseLongitude:{default:null},showLegend:{type:Boolean,default:!0}},emits:["update:showLegend"],setup($,{expose:r,emit:o}){typeof window<"u"&&!window.chrome&&(window.chrome={runtime:{}});const i=$,e=o,d=()=>{e("update:showLegend",!i.showLegend)},h=D();let s=null;const a=D(new Map);let f=null;const b=D(new Map),v=D([]),L=D(!0),B=D(60),N=D(14),S=D(document.documentElement.classList.contains("dark")),g=new MutationObserver(()=>{const A=document.documentElement.classList.contains("dark");A!==S.value&&(S.value=A,s&&Y())}),c=q(()=>i.baseLatitude!==null&&i.baseLongitude!==null&&typeof i.baseLatitude=="number"&&typeof i.baseLongitude=="number"&&i.baseLatitude!==0&&i.baseLongitude!==0&&Math.abs(i.baseLatitude)<=90&&Math.abs(i.baseLongitude)<=180),T=A=>new Date(A*1e3).toLocaleString(),F=A=>A?`${A} dBm`:"N/A",I=A=>A?`${A} dB`:"N/A",y=A=>({0:"Transport Flood",1:"Flood",2:"Direct",3:"Transport Direct"})[A||0]||"Unknown",p=(A,u,n,l)=>{const j=(n-A)*Math.PI/180,H=(l-u)*Math.PI/180,X=Math.sin(j/2)*Math.sin(j/2)+Math.cos(A*Math.PI/180)*Math.cos(n*Math.PI/180)*Math.sin(H/2)*Math.sin(H/2);return 6371*(2*Math.atan2(Math.sqrt(X),Math.sqrt(1-X)))},U=()=>{s&&(v.value.forEach(A=>{s&&A.remove()}),v.value.length=0,s.remove(),s=null),a.value.clear(),b.value.clear(),f=null},Y=async()=>{const A=s?.getZoom()||11,u=s?.getCenter()||(c.value?[i.baseLatitude,i.baseLongitude]:[0,0]);U(),await Pt(),await at(),s&&s.setView(u,A)},ot=A=>{const u=new Map;return A.filter(n=>n.latitude!==null&&n.longitude!==null).map(n=>{let l=n.latitude,E=n.longitude;const j=`${l.toFixed(6)}_${E.toFixed(6)}`,H=u.get(j)||0;if(u.set(j,H+1),H>0){const tt=H*60*(Math.PI/180);l+=Math.sin(tt)*.001*(H*.5),E+=Math.cos(tt)*.001*(H*.5)}return{type:"Feature",properties:{advert:{...n,jittered_latitude:l,jittered_longitude:E}},geometry:{type:"Point",coordinates:[E,l]}}})},lt=A=>{f=new Oo({radius:B.value,maxZoom:N.value,minPoints:2}),f.load(A)},at=async()=>{if(!h.value||!c.value){console.warn("Cannot initialize map: missing container or coordinates");return}U(),await Pt();const A=i.baseLatitude,u=i.baseLongitude;s=Q.map(h.value,{center:[A,u],zoom:11,zoomControl:!0,attributionControl:!1,preferCanvas:!1});try{const n=S.value?"https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png":"https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png",l=S.value?"https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}{r}.png":"https://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}{r}.png",E=Q.tileLayer(n,{maxZoom:19,attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>',errorTileUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="}),j=Q.tileLayer(l,{maxZoom:19,attribution:"",errorTileUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="});E.addTo(s),j.addTo(s)}catch(n){console.warn("Error loading tiles:",n)}try{const n=(R,V=!1)=>{const x=V?16:12;return Q.divIcon({className:"custom-div-icon",html:`<div style="background-color: ${R}; width: ${x}px; height: ${x}px; border-radius: 50%; border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.5);"></div>`,iconSize:[x+4,x+4],iconAnchor:[(x+4)/2,(x+4)/2]})},l=R=>{const V=R<10?30:R<100?40:50;return Q.divIcon({className:"custom-cluster-icon",html:`
<div style="
width: ${V}px;
height: ${V}px;
background: rgba(170, 232, 232, 0.2);
border: 2px solid #AAE8E8;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(10px);
box-shadow: 0 4px 12px rgba(170, 232, 232, 0.3);
color: #ffffff;
font-size: ${V<35?"11px":"13px"};
font-weight: bold;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
">
${R}
</div>
`,iconSize:[V,V],iconAnchor:[V/2,V/2]})},E=n("#ef4444",!0);Q.marker([A,u],{icon:E}).addTo(s).bindPopup(`
<div class="p-2">
<strong style="color: #ef4444;">Base Station</strong><br>
<span class="text-sm" style="color: #9CA3AF;">Base Station</span><br>
<span class="text-xs" style="color: #6B7280;">${A.toFixed(6)}, ${u.toFixed(6)}</span>
</div>
`);const j={Unknown:"#9CA3AF","Chat Node":"#60A5FA",Repeater:"#A5E5B6","Room Server":"#EBA0FC","Hybrid Node":"#FFC246"},H=(R,V,x,m,M=0)=>{if(!s)return;const z=R.jittered_latitude||R.latitude,Z=R.jittered_longitude||R.longitude;if(z===null||Z===null)return;const O=R.route_type||0;let K=m,W=3,G=.7,J;O===2?(K="#A5E5B6",W=4,G=.9):O===1?(K="#FFC246",J="10, 5",G=.8):O===3?(K="#059669",W=5,G=.95):O===0?(K="#ea580c",J="12, 6",G=.8):(K="#9CA3AF",J="2, 5",G=.6);const rt=[V,x],st=[z,Z],dt=Q.polyline([rt,st],{color:K,weight:W,opacity:0,dashArray:J,className:"connection-line"}).addTo(s),xt=Q.polyline([rt,rt],{color:K,weight:W,opacity:0,dashArray:J,className:"connection-line animated-line"}).addTo(s);setTimeout(()=>{let Tt=0;const Ht=30;xt.setStyle({opacity:G+.2});const Vt=()=>{Tt++;const Zt=Tt/Ht,ne=rt[0]+(st[0]-rt[0])*Zt,se=rt[1]+(st[1]-rt[1])*Zt;xt.setLatLngs([rt,[ne,se]]),Tt<Ht?setTimeout(Vt,30):setTimeout(()=>{s&&xt&&xt.remove(),dt.setStyle({opacity:G}),dt.on("mouseover",()=>{dt.setStyle({weight:W+2,opacity:Math.min(G+.3,1)})}),dt.on("mouseout",()=>{dt.setStyle({weight:W,opacity:G})});const ae=p(V,x,z,Z);dt.bindPopup(`
<div class="p-2">
<strong style="color: ${m}">Connection to ${R.node_name||"Unknown Node"}</strong><br>
<span class="text-sm" style="color: #E5E7EB;">Distance: ${ae.toFixed(2)} km</span><br>
<span class="text-sm" style="color: #E5E7EB;">Route: ${y(R.route_type)}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Signal: ${F(R.rssi)} / ${I(R.snr)}</span>
</div>
`),v.value.push(dt)},200)};Vt()},M)},X=()=>{if(!s||!f)return;const R=s.getBounds(),V=Math.floor(s.getZoom());b.value.forEach(m=>{s&&m.remove()}),b.value.clear(),v.value.forEach(m=>{s&&m.remove()}),v.value.length=0,f.getClusters([R.getWest(),R.getSouth(),R.getEast(),R.getNorth()],V).forEach(m=>{const[M,z]=m.geometry.coordinates,Z=m.properties;if(Z.cluster){const O=Q.marker([z,M],{icon:l(Z.point_count||0)}).addTo(s);O.on("click",()=>{if(s&&f){const st=f.getClusterExpansionZoom(Z.cluster_id);s.setView([z,M],st)}});const W=f.getLeaves(Z.cluster_id,1/0).map(st=>`<div style="margin: 2px 0; color: ${j[st.properties.advert.contact_type]||j.Unknown};">
${st.properties.advert.node_name||"Unknown Node"} (${st.properties.advert.contact_type})
</div>`).join("");O.bindPopup(`
<div class="p-2">
<strong style="color: #AAE8E8;">Cluster: ${Z.point_count} nodes</strong><br>
<div style="max-height: 200px; overflow-y: auto; margin-top: 8px;">
${W}
</div>
<div style="margin-top: 8px; font-size: 11px; color: #ffffff99;">
Click to zoom in and separate nodes
</div>
</div>
`),b.value.set(`cluster-${Z.cluster_id}`,O);const G=p(A,u,z,M),J=Math.min(Math.floor(G*5),200),rt={node_name:`Cluster of ${Z.point_count} nodes`,contact_type:"Cluster",route_type:2,rssi:null,snr:null,jittered_latitude:z,jittered_longitude:M,latitude:z,longitude:M};H(rt,A,u,"#AAE8E8",J)}else{const O=Z.advert,K=j[O.contact_type]||j.Unknown,W=n(K),G=z,J=M,rt=p(A,u,G,J),st=Q.marker([G,J],{icon:W}).addTo(s).bindPopup(`
<div class="p-2">
<strong style="color: ${K}">${O.node_name||"Unknown Node"}</strong><br>
<span class="text-sm" style="color: #E5E7EB;">Type: ${O.contact_type}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Distance: ${rt.toFixed(2)} km</span><br>
<span class="text-sm" style="color: #E5E7EB;">Signal: ${F(O.rssi)} / ${I(O.snr)}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Route: ${y(O.route_type)}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Last Seen: ${T(O.last_seen)}</span>
${O.jittered_latitude?'<br><span class="text-xs" style="color: #9CA3AF;">Position adjusted to separate overlapping nodes</span>':""}
</div>
`);a.value.set(O.pubkey,st),b.value.set(`node-${O.pubkey}`,st);const dt=Math.min(Math.floor(rt*5),200),xt={...O,jittered_latitude:G,jittered_longitude:J};H(xt,A,u,K,dt)}})},tt=(R,V)=>{let x=0;ot(i.adverts).forEach(M=>{const z=M.properties.advert;if(z.latitude!==null&&z.longitude!==null){const Z=j[z.contact_type]||j.Unknown,O=n(Z),K=z.jittered_latitude||z.latitude,W=z.jittered_longitude||z.longitude,G=Q.marker([K,W],{icon:O}).addTo(s).bindPopup(`
<div class="p-2">
<strong style="color: ${Z}">${z.node_name||"Unknown Node"}</strong><br>
<span class="text-sm" style="color: #E5E7EB;">Type: ${z.contact_type}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Distance: ${p(R,V,K,W).toFixed(2)} km</span><br>
<span class="text-sm" style="color: #E5E7EB;">Signal: ${F(z.rssi)} / ${I(z.snr)}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Route: ${y(z.route_type)}</span><br>
<span class="text-sm" style="color: #E5E7EB;">Last Seen: ${T(z.last_seen)}</span>
${z.jittered_latitude?'<br><span class="text-xs" style="color: #9CA3AF;">Position adjusted to separate overlapping nodes</span>':""}
</div>
`);a.value.set(z.pubkey,G);const J=G.getElement();J&&(J.style.opacity="0",J.style.transition="opacity 0.5s ease-out"),H(z,R,V,Z,x),setTimeout(()=>{J&&(J.style.opacity="1")},x+1e3),x+=100}})};if(L.value&&i.adverts.length>0)try{const R=ot(i.adverts);lt(R);const V=Math.min(14,s.getZoom());s.setZoom(V),setTimeout(()=>{try{X()}catch(x){console.warn("Error updating clusters:",x),tt(A,u)}},100),s.on("moveend",()=>{try{X()}catch(x){console.warn("Error updating clusters on move:",x)}}),s.on("zoomend",()=>{try{X()}catch(x){console.warn("Error updating clusters on zoom:",x)}})}catch(R){console.warn("Error initializing clustering:",R),tt(A,u)}else tt(A,u);setTimeout(()=>{s&&s.invalidateSize()},1e3)}catch(n){console.error("Error initializing map:",n)}};return r({highlightNode:A=>{const u=a.value.get(A);if(u){const n=u.getElement();if(n){const l=n.querySelector("div");l&&l.classList.add("marker-highlight")}}},unhighlightNode:A=>{const u=a.value.get(A);if(u){const n=u.getElement();if(n){const l=n.querySelector("div");l&&l.classList.remove("marker-highlight")}}},initializeOpenStreetMap:at}),ht(()=>i.adverts,()=>{s&&c.value&&setTimeout(()=>{at()},100)},{immediate:!1}),Xt(()=>{g.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),c.value&&i.adverts.length>0&&setTimeout(()=>{at()},300)}),te(()=>{g.disconnect(),U()}),(A,u)=>(k(),_("div",Zo,[c.value?(k(),_("div",{key:1,ref_key:"mapContainer",ref:h,class:"leaflet-map-container h-96 w-full glass-card backdrop-blur border border-black/6 dark:border-white/10 rounded-[12px] overflow-hidden shadow-sm dark:shadow-none",style:{"min-height":"384px",position:"relative"}},null,512)):(k(),_("div",Wo,u[0]||(u[0]=[ft('<div class="text-center text-content-primary dark:text-content-primary" data-v-a6a23e33><svg class="w-8 h-8 mx-auto mb-2 text-content-muted dark:text-content-muted" fill="currentColor" viewBox="0 0 20 20" data-v-a6a23e33><path d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" data-v-a6a23e33></path></svg><p class="text-sm text-content-primary dark:text-content-primary" data-v-a6a23e33>No valid coordinates available</p><p class="text-xs text-content-secondary dark:text-content-muted" data-v-a6a23e33>Configure base station location to view map</p></div>',1)]))),c.value&&A.adverts.length>0?(k(),_("button",{key:2,onClick:d,class:"absolute bottom-3 right-3 z-[1001] flex items-center gap-2 px-3 py-2 bg-black/40 border border-white/10 rounded-lg text-white/80 hover:bg-white/10 hover:text-white transition-colors text-sm backdrop-blur-sm"},[u[1]||(u[1]=t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})],-1)),t("span",Qo,w(A.showLegend?"Hide":"Show"),1)])):P("",!0),c.value&&A.adverts.length>0&&A.showLegend?(k(),_("div",qo,[u[2]||(u[2]=ft('<div class="legend-section" data-v-a6a23e33><div class="legend-subtitle" data-v-a6a23e33>Node Types</div><div class="legend-items" data-v-a6a23e33><div class="legend-item" data-v-a6a23e33><div class="legend-icon" style="background-color:#ef4444;" data-v-a6a23e33></div><span data-v-a6a23e33>Base Station</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-icon" style="background-color:#60A5FA;" data-v-a6a23e33></div><span data-v-a6a23e33>Chat Node</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-icon" style="background-color:#A5E5B6;" data-v-a6a23e33></div><span data-v-a6a23e33>Repeater</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-icon" style="background-color:#EBA0FC;" data-v-a6a23e33></div><span data-v-a6a23e33>Room Server</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-icon" style="background-color:#FFC246;" data-v-a6a23e33></div><span data-v-a6a23e33>Hybrid Node</span></div></div></div><div class="legend-section" data-v-a6a23e33><div class="legend-subtitle" data-v-a6a23e33>Route Types</div><div class="legend-items" data-v-a6a23e33><div class="legend-item" data-v-a6a23e33><div class="legend-line" style="background:#A5E5B6;height:3px;" data-v-a6a23e33></div><span data-v-a6a23e33>Direct</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-line" style="background:#059669;height:4px;" data-v-a6a23e33></div><span data-v-a6a23e33>Transport Direct</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-line legend-line-dashed" style="background:#FFC246;" data-v-a6a23e33></div><span data-v-a6a23e33>Flood</span></div><div class="legend-item" data-v-a6a23e33><div class="legend-line legend-line-dashed" style="background:#ea580c;" data-v-a6a23e33></div><span data-v-a6a23e33>Transport Flood</span></div></div></div>',2)),t("div",Ko,w(A.adverts.length)+" node"+w(A.adverts.length!==1?"s":"")+" visible ",1)])):P("",!0),c.value?(k(),_("div",Go," © OpenStreetMap contributors © CARTO ")):P("",!0)]))}}),Yo=It(Jo,[["__scopeId","data-v-a6a23e33"]]),Xo={class:"relative","data-menu-container":""},Jt=bt({__name:"NeighborMenu",props:{neighbor:{},canPing:{type:Boolean}},emits:["ping","delete","show-details"],setup($,{emit:r}){const o=window.__neighborMenuManager||{activeMenu:null,setActiveMenu:g=>{if(o.activeMenu&&o.activeMenu!==g)try{o.activeMenu.closeMenu()}catch(c){console.warn("Error closing previous menu:",c)}o.activeMenu=g}};window.__neighborMenuManager=o;const i=$,e=r,d=D(!1),h=D(),s=D({top:0,left:0}),a=()=>{d.value=!1,document.removeEventListener("click",B,!0),document.removeEventListener("keydown",N),o.activeMenu===f&&(o.activeMenu=null)},f={closeMenu:a},b=()=>{a(),e("ping",i.neighbor)},v=()=>{a(),e("show-details",i.neighbor)},L=()=>{a(),e("delete",i.neighbor)},B=g=>{g.target.closest("[data-menu-container]")||a()},N=g=>{g.key==="Escape"&&a()},S=async()=>{if(!d.value&&h.value){o.setActiveMenu(f);const g=h.value.getBoundingClientRect(),c=window.innerWidth,T=144,F=c<1024,I=g.left+T>c-16;let y=g.left;F&&I&&(y=g.right-T),y=Math.max(8,y),s.value={top:g.bottom+4,left:y},d.value=!0,await Pt(),document.addEventListener("click",B,!0),document.addEventListener("keydown",N)}else a()};return te(()=>{a()}),(g,c)=>(k(),_("div",Xo,[t("button",{ref_key:"buttonRef",ref:h,onClick:S,class:C(["p-1 rounded hover:bg-stroke-subtle dark:hover:bg-white/10 transition-colors text-content-secondary dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary/80",{"bg-background-mute dark:bg-stroke/10 text-content-primary dark:text-content-primary/80":d.value}]),"data-menu-container":""},c[0]||(c[0]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})],-1)]),2),(k(),Rt(jt,{to:"body"},[d.value?(k(),_("div",{key:0,class:"fixed w-36 bg-white dark:bg-surface-elevated backdrop-blur-lg border border-stroke-subtle dark:border-white/20 rounded-[15px] shadow-2xl z-[999999]",style:At({top:s.value.top+"px",left:s.value.left+"px"}),"data-menu-container":""},[t("div",{class:"py-2"},[t("button",{onClick:v,class:"flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10"},c[1]||(c[1]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),t("span",{class:"font-medium"},"Details",-1)])),t("button",{onClick:b,class:"flex items-center gap-3 w-full px-4 py-3 text-sm text-content-primary dark:text-content-primary hover:bg-primary/10 transition-colors border-b border-stroke-subtle dark:border-white/10"},c[2]||(c[2]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})],-1),t("span",{class:"font-medium"},"Ping",-1)])),t("button",{onClick:L,class:"flex items-center gap-3 w-full px-4 py-3 text-sm text-accent-red hover:bg-accent-red/10 transition-colors"},c[3]||(c[3]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1),t("span",{class:"font-medium"},"Delete",-1)]))])],4)):P("",!0)]))]))}}),tr={class:"glass-card/30 backdrop-blur border border-stroke-subtle dark:border-white/10 rounded-[12px] p-6 shadow-sm dark:shadow-none"},er={class:"flex items-center justify-between mb-4"},or={class:"flex items-center gap-3"},rr={class:"text-content-primary dark:text-content-primary text-lg font-semibold"},nr={class:"bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary text-xs px-2 py-1 rounded-full"},sr={key:0,class:"text-content-muted dark:text-content-muted"},ar={key:0,class:"hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 p-1"},ir={class:"hidden lg:block overflow-x-auto"},lr={class:"w-full"},dr={class:"bg-background-mute dark:bg-transparent"},cr={class:"flex items-center gap-1"},ur={class:"flex items-center gap-1"},pr={class:"flex items-center gap-1"},gr={class:"flex items-center gap-1"},mr={class:"flex items-center gap-1"},hr={class:"flex items-center gap-1"},br={class:"flex items-center gap-1"},xr={class:"flex items-center gap-1"},yr={class:"flex items-center gap-1"},vr={class:"bg-surface/50 dark:bg-transparent"},kr=["onMouseenter","onMouseleave"],fr=["onClick","title"],wr={key:0,class:"ml-1 text-xs"},_r={key:0,class:"flex items-center gap-3"},Cr={class:"text-content-secondary dark:text-content-muted"},Mr={class:"flex gap-1"},$r=["onClick"],Ar=["onClick"],Lr={key:1,class:"text-content-muted"},Tr={class:"flex items-center gap-2"},Er={class:"flex items-end gap-0.5"},Sr={class:"flex items-center gap-2"},Br=["title"],Nr=["title"],Fr={class:"lg:hidden space-y-3"},Dr=["onClick"],Pr={class:"flex items-center justify-between mb-3"},zr={class:"flex items-center gap-3"},Rr={class:"text-content-primary dark:text-content-primary font-medium text-base"},jr={class:"flex items-center gap-2"},Ir={class:"grid grid-cols-1 gap-3"},Ur={class:"grid grid-cols-2 gap-4"},Or=["onClick","title"],Hr={key:0,class:"ml-1 text-xs"},Vr={class:"flex items-center gap-2 justify-end"},Zr={class:"flex items-end gap-0.5"},Wr={class:"grid grid-cols-2 gap-4"},Qr={class:"flex items-center gap-2"},qr=["title"],Kr={class:"text-content-primary dark:text-content-primary text-sm block text-right"},Gr={key:0,class:"border-t border-white/10 pt-3"},Jr={class:"flex items-center justify-between"},Yr={class:"text-content-secondary dark:text-content-muted text-sm font-mono"},Xr={class:"flex gap-2"},tn=["onClick"],en=["onClick"],on={class:"grid grid-cols-3 gap-4 pt-3 border-t border-white/10"},rn={class:"text-center"},nn={class:"text-content-primary dark:text-content-primary text-sm font-medium"},sn={class:"text-center"},an={class:"text-content-primary dark:text-content-primary text-sm font-medium"},ln={class:"text-center"},dn=["title"],cn=bt({__name:"NeighborTable",props:{contactType:{},contactTypeKey:{},adverts:{},originalCount:{default:0},color:{},baseLatitude:{default:null},baseLongitude:{default:null},isCompactView:{type:Boolean,default:!1},isFirstTable:{type:Boolean,default:!1},showViewToggle:{type:Boolean,default:!1}},emits:["highlight-node","unhighlight-node","menu-ping","menu-delete","show-details","toggle-view"],setup($,{emit:r}){const o=D(null),{getSignalQuality:i}=Ut(),e=D("advert_count"),d=D("desc"),h=$,s=r,a=u=>new Date(u*1e3).toLocaleString(),f=u=>`${u.slice(0,4)}...${u.slice(-4)}`,b=u=>{switch(u){case 2:return{text:"Direct",bgColor:"bg-green-100 dark:bg-green-500/20",borderColor:"border-green-500 dark:border-green-400/30",textColor:"text-green-600 dark:text-green-400"};case 3:return{text:"Transport Direct",bgColor:"bg-green-100 dark:bg-green-600/20",borderColor:"border-green-600/40 dark:border-green-500/30",textColor:"text-green-700 dark:text-green-500"};case 1:return{text:"Flood",bgColor:"bg-yellow-100 dark:bg-yellow-500/20",borderColor:"border-yellow-500 dark:border-yellow-400/30",textColor:"text-yellow-600 dark:text-yellow-400"};case 0:return{text:"Transport Flood",bgColor:"bg-orange-100 dark:bg-orange-500/20",borderColor:"border-orange-500 dark:border-orange-400/30",textColor:"text-orange-600 dark:text-orange-400"};default:return{text:"Unknown",bgColor:"bg-gray-500/20",borderColor:"border-gray-400/30",textColor:"text-gray-400"}}},v=u=>u?`${u} dBm`:"N/A",L=u=>u?`${u} dB`:"N/A",B=(u,n,l,E)=>{const H=(l-u)*Math.PI/180,X=(E-n)*Math.PI/180,tt=Math.sin(H/2)*Math.sin(H/2)+Math.cos(u*Math.PI/180)*Math.cos(l*Math.PI/180)*Math.sin(X/2)*Math.sin(X/2);return 6371*(2*Math.atan2(Math.sqrt(tt),Math.sqrt(1-tt)))},N=u=>h.baseLatitude===null||h.baseLongitude===null||u.latitude===null||u.longitude===null?"N/A":`${B(h.baseLatitude,h.baseLongitude,u.latitude,u.longitude).toFixed(1)} km`,S=async u=>{try{return await navigator.clipboard.writeText(u),!0}catch{const n=document.createElement("textarea");return n.value=u,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}},g=u=>{const n=Date.now(),l=u*1e3,E=n-l,j=Math.floor(E/1e3),H=Math.floor(j/60),X=Math.floor(H/60),tt=Math.floor(X/24);return j<60?`${j}s ago`:H<60?`${H}m ago`:X<24?`${X}h ago`:`${tt}d ago`},c=u=>{const n=Date.now(),l=u*1e3,E=n-l,j=Math.floor(E/(1e3*60*60));return j<1?{color:"text-green-600 dark:text-green-400"}:j<26?{color:"text-yellow-600 dark:text-yellow-400"}:{color:"text-red-600 dark:text-red-400"}},T=async(u,n)=>{const l=`${u.toFixed(6)}, ${n.toFixed(6)}`;await S(l)},F=(u,n)=>{const l=`https://www.google.com/maps?q=${u},${n}`;window.open(l,"_blank")},I=async u=>{await S(u),o.value=u,setTimeout(()=>{o.value=null},2e3)},y=u=>{const n=i(u);return{bars:n.bars,color:n.color}},p=()=>h.isCompactView?"py-2 px-2":"py-4 px-3",U=()=>{s("toggle-view")},Y=u=>{s("highlight-node",u)},ot=u=>{s("unhighlight-node",u)},lt=u=>{s("menu-ping",u)},at=u=>{s("show-details",u)},yt=u=>{s("menu-delete",u)},nt=u=>{e.value===u?d.value=d.value==="asc"?"desc":"asc":(e.value=u,d.value=typeof h.adverts[0]?.[u]=="number"?"desc":"asc")},A=q(()=>e.value?[...h.adverts].sort((u,n)=>{const l=u[e.value],E=n[e.value];if(l==null)return 1;if(E==null)return-1;let j=0;return typeof l=="string"&&typeof E=="string"?j=l.localeCompare(E):typeof l=="number"&&typeof E=="number"?j=l-E:typeof l=="boolean"&&typeof E=="boolean"&&(j=l===E?0:l?1:-1),d.value==="asc"?j:-j}):h.adverts);return(u,n)=>(k(),_("div",tr,[t("div",er,[t("div",or,[t("div",{class:"w-3 h-3 rounded-full border border-white/20",style:At({backgroundColor:u.color})},null,4),t("h3",rr,w(u.contactType),1),t("span",nr,[et(w(u.adverts.length)+" ",1),u.originalCount>0&&u.adverts.length<u.originalCount?(k(),_("span",sr," / "+w(u.originalCount),1)):P("",!0)])]),u.isFirstTable&&u.showViewToggle?(k(),_("div",ar,[t("button",{onClick:U,class:C(["p-2 rounded-md transition-colors",u.isCompactView?"text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10":"bg-primary/20 text-primary border border-primary/30"]),title:"Comfortable view"},n[9]||(n[9]=[t("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"18",height:"6",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"12",width:"18",height:"6",rx:"2",stroke:"currentColor","stroke-width":"2"})],-1)]),2),t("button",{onClick:U,class:C(["p-2 rounded-md transition-colors",u.isCompactView?"bg-primary/20 text-primary border border-primary/30":"text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10"]),title:"Compact view"},n[10]||(n[10]=[t("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"10",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"17",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"})],-1)]),2)])):P("",!0)]),t("div",ir,[t("table",lr,[t("thead",null,[t("tr",dr,[t("th",{class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5`)},null,2),t("th",{onClick:n[0]||(n[0]=l=>nt("node_name")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",cr,[n[12]||(n[12]=et(" Node Name ",-1)),e.value==="node_name"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[11]||(n[11]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[1]||(n[1]=l=>nt("pubkey")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",ur,[n[14]||(n[14]=et(" Public Key ",-1)),e.value==="pubkey"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[13]||(n[13]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5`)},"Location",2),t("th",{class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5`)},"Distance",2),t("th",{onClick:n[2]||(n[2]=l=>nt("route_type")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",pr,[n[16]||(n[16]=et(" Route Type ",-1)),e.value==="route_type"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[15]||(n[15]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[3]||(n[3]=l=>nt("zero_hop")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",gr,[n[18]||(n[18]=et(" Zero Hop ",-1)),e.value==="zero_hop"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[17]||(n[17]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[4]||(n[4]=l=>nt("rssi")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",mr,[n[20]||(n[20]=et(" RSSI ",-1)),e.value==="rssi"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[19]||(n[19]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[5]||(n[5]=l=>nt("snr")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",hr,[n[22]||(n[22]=et(" SNR ",-1)),e.value==="snr"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[21]||(n[21]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[6]||(n[6]=l=>nt("last_seen")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",br,[n[24]||(n[24]=et(" Last Seen ",-1)),e.value==="last_seen"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[23]||(n[23]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[7]||(n[7]=l=>nt("first_seen")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",xr,[n[26]||(n[26]=et(" First Seen ",-1)),e.value==="first_seen"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[25]||(n[25]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2),t("th",{onClick:n[8]||(n[8]=l=>nt("advert_count")),class:C(`text-left text-content-secondary dark:text-content-muted text-xs font-medium py-3 ${p().split(" ")[1]} border-b border-stroke-subtle dark:border-white/5 cursor-pointer hover:text-primary transition-colors select-none`)},[t("div",yr,[n[28]||(n[28]=et(" Advert Count ",-1)),e.value==="advert_count"?(k(),_("svg",{key:0,class:C(["w-3 h-3",d.value==="asc"?"":"rotate-180"]),fill:"currentColor",viewBox:"0 0 20 20"},n[27]||(n[27]=[t("path",{"fill-rule":"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)]),2)):P("",!0)])],2)])]),t("tbody",vr,[(k(!0),_(ct,null,gt(A.value,l=>(k(),_("tr",{key:l.id,class:"hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors",onMouseenter:E=>Y(l.pubkey),onMouseleave:E=>ot(l.pubkey)},[t("td",{class:C(p())},[it(Jt,{neighbor:l,onPing:lt,onShowDetails:at,onDelete:yt},null,8,["neighbor"])],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},w(l.node_name||"Unknown"),3),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm font-mono`)},[t("button",{onClick:E=>I(l.pubkey),class:C(["text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60",o.value===l.pubkey?"text-green-600 dark:text-green-400 decoration-green-400/60":""]),title:o.value===l.pubkey?"Copied!":"Click to copy full public key"},[et(w(f(l.pubkey))+" ",1),o.value===l.pubkey?(k(),_("span",wr,"✓")):P("",!0)],10,fr)],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[l.latitude!==null&&l.longitude!==null?(k(),_("div",_r,[t("span",Cr,w(l.latitude.toFixed(4))+", "+w(l.longitude.toFixed(4)),1),t("div",Mr,[t("button",{onClick:E=>T(l.latitude,l.longitude),class:"text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors cursor-pointer",title:"Copy coordinates to clipboard"},n[29]||(n[29]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:"currentColor","stroke-width":"2"}),t("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:"currentColor","stroke-width":"2"})],-1)]),8,$r),t("button",{onClick:E=>F(l.latitude,l.longitude),class:"text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors cursor-pointer",title:"Open in Google Maps"},n[30]||(n[30]=[t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z",stroke:"currentColor","stroke-width":"2"}),t("circle",{cx:"12",cy:"10",r:"3",stroke:"currentColor","stroke-width":"2"})],-1)]),8,Ar)])])):(k(),_("span",Lr,"Unknown"))],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},w(N(l)),3),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[t("span",{class:C(["inline-block px-2 py-1 rounded-full text-xs border transition-colors",b(l.route_type).bgColor,b(l.route_type).borderColor,b(l.route_type).textColor])},w(b(l.route_type).text),3)],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[t("span",{class:C(["inline-block px-2 py-1 rounded-full text-xs border transition-colors",l.zero_hop?"bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400":"bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400"])},w(l.zero_hop?"Zero Hop":"Multi-Hop"),3)],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[t("div",Tr,[t("div",Er,[(k(),_(ct,null,gt(5,E=>t("div",{key:E,class:C(["w-1 transition-colors",E<=y(l.rssi).bars?y(l.rssi).color:"text-gray-600"]),style:At({height:`${4+E*2}px`})},n[31]||(n[31]=[t("div",{class:"w-full h-full bg-current rounded-sm"},null,-1)]),6)),64))]),t("span",{class:C(y(l.rssi).color)},w(v(l.rssi)),3)])],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},w(L(l.snr)),3),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[t("div",Sr,[t("div",{class:C(["w-2 h-2 rounded-full",c(l.last_seen).color==="text-green-600 dark:text-green-400"?"bg-green-400":"",c(l.last_seen).color==="text-yellow-600 dark:text-yellow-400"?"bg-yellow-400":"",c(l.last_seen).color==="text-red-600 dark:text-red-400"?"bg-red-400":""])},null,2),t("span",{class:C([c(l.last_seen).color,"cursor-help"]),title:a(l.last_seen)},w(g(l.last_seen)),11,Br)])],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm`)},[t("span",{title:a(l.first_seen),class:"cursor-help"},w(g(l.first_seen)),9,Nr)],2),t("td",{class:C(`${p()} text-content-primary dark:text-content-primary text-sm text-center`)},w(l.advert_count),3)],40,kr))),128))])])]),t("div",Fr,[(k(!0),_(ct,null,gt(A.value,l=>(k(),_("div",{key:l.id,class:"bg-surface/50 dark:bg-transparent border border-stroke-subtle dark:border-white/10 rounded-lg p-4 hover:bg-background-mute/50 dark:hover:bg-white/5 transition-colors",onClick:E=>Y(l.pubkey)},[t("div",Pr,[t("div",zr,[t("h4",Rr,w(l.node_name||"Unknown Node"),1),t("div",jr,[t("span",{class:C(["inline-block px-2 py-1 rounded-full text-xs border",b(l.route_type).bgColor,b(l.route_type).borderColor,b(l.route_type).textColor])},w(b(l.route_type).text),3),t("span",{class:C(["inline-block px-2 py-1 rounded-full text-xs border",l.zero_hop?"bg-green-100 dark:bg-green-500/20 border-green-500 dark:border-green-400/30 text-green-600 dark:text-green-400":"bg-orange-100 dark:bg-orange-500/20 border-orange-500 dark:border-orange-400/30 text-orange-600 dark:text-orange-400"])},w(l.zero_hop?"Zero Hop":"Multi-Hop"),3)])]),it(Jt,{neighbor:l,onPing:lt,onShowDetails:at,onDelete:yt},null,8,["neighbor"])]),t("div",Ir,[t("div",Ur,[t("div",null,[n[32]||(n[32]=t("div",{class:"text-content-muted text-xs mb-1"},"Public Key",-1)),t("button",{onClick:E=>I(l.pubkey),class:C(["text-content-primary dark:text-content-primary hover:text-primary-light transition-colors cursor-pointer font-mono text-sm underline underline-offset-2 decoration-gray-400 dark:decoration-white/30 hover:decoration-primary-light/60 break-all",o.value===l.pubkey?"text-green-600 dark:text-green-400 decoration-green-400/60":""]),title:o.value===l.pubkey?"Copied!":"Click to copy full public key"},[et(w(f(l.pubkey))+" ",1),o.value===l.pubkey?(k(),_("span",Hr,"✓")):P("",!0)],10,Or)]),t("div",null,[n[34]||(n[34]=t("div",{class:"text-content-muted text-xs mb-1"},"Signal",-1)),t("div",Vr,[t("div",Zr,[(k(),_(ct,null,gt(5,E=>t("div",{key:E,class:C(["w-1.5 transition-colors",E<=y(l.rssi).bars?y(l.rssi).color:"text-gray-600"]),style:At({height:`${6+E*2}px`})},n[33]||(n[33]=[t("div",{class:"w-full h-full bg-current rounded-sm"},null,-1)]),6)),64))]),t("span",{class:C(`${y(l.rssi).color} text-sm font-medium`)},w(v(l.rssi)),3)])])]),t("div",Wr,[t("div",null,[n[35]||(n[35]=t("div",{class:"text-content-muted text-xs mb-1"},"Last Seen",-1)),t("div",Qr,[t("div",{class:C(["w-2 h-2 rounded-full",c(l.last_seen).color==="text-green-600 dark:text-green-400"?"bg-green-400":"",c(l.last_seen).color==="text-yellow-600 dark:text-yellow-400"?"bg-yellow-400":"",c(l.last_seen).color==="text-red-600 dark:text-red-400"?"bg-red-400":""])},null,2),t("span",{class:C(`${c(l.last_seen).color} text-sm`),title:a(l.last_seen)},w(g(l.last_seen)),11,qr)])]),t("div",null,[n[36]||(n[36]=t("div",{class:"text-content-muted text-xs mb-1"},"Distance",-1)),t("span",Kr,w(N(l)),1)])]),l.latitude!==null&&l.longitude!==null?(k(),_("div",Gr,[n[39]||(n[39]=t("div",{class:"text-content-muted text-xs mb-1"},"Location",-1)),t("div",Jr,[t("span",Yr,w(l.latitude.toFixed(4))+", "+w(l.longitude.toFixed(4)),1),t("div",Xr,[t("button",{onClick:E=>T(l.latitude,l.longitude),class:"text-content-muted dark:text-content-muted hover:text-content-primary dark:hover:text-content-primary transition-colors p-2 hover:bg-stroke-subtle dark:hover:bg-white/10 rounded-lg",title:"Copy coordinates"},n[37]||(n[37]=[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2",stroke:"currentColor","stroke-width":"2"}),t("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",stroke:"currentColor","stroke-width":"2"})],-1)]),8,tn),t("button",{onClick:E=>F(l.latitude,l.longitude),class:"text-white/60 hover:text-blue-600 dark:text-blue-400 transition-colors p-2 hover:bg-white/10 rounded-lg",title:"Open in Maps"},n[38]||(n[38]=[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("path",{d:"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z",stroke:"currentColor","stroke-width":"2"}),t("circle",{cx:"12",cy:"10",r:"3",stroke:"currentColor","stroke-width":"2"})],-1)]),8,en)])])])):P("",!0),t("div",on,[t("div",rn,[n[40]||(n[40]=t("div",{class:"text-content-muted text-xs mb-1"},"SNR",-1)),t("span",nn,w(L(l.snr)),1)]),t("div",sn,[n[41]||(n[41]=t("div",{class:"text-content-muted text-xs mb-1"},"Adverts",-1)),t("span",an,w(l.advert_count),1)]),t("div",ln,[n[42]||(n[42]=t("div",{class:"text-content-muted text-xs mb-1"},"First Seen",-1)),t("span",{class:"text-content-primary dark:text-content-primary text-sm",title:a(l.first_seen)},w(g(l.first_seen)),9,dn)])])])],8,Dr))),128))])]))}}),un={class:"space-y-6"},pn={key:0,class:"flex items-center justify-center py-12"},gn={key:1,class:"bg-red-50 dark:bg-accent-red/10 border border-red-300 dark:border-accent-red/20 rounded-[15px] p-6"},mn={class:"flex items-center gap-3"},hn={class:"text-red-500 dark:text-accent-red/80 text-sm"},bn={key:0,class:""},xn={class:"flex items-center justify-between"},yn={class:"flex items-center gap-3"},vn={class:"hidden lg:flex bg-background-mute dark:bg-surface-elevated/30 backdrop-blur rounded-lg border border-stroke-subtle dark:border-stroke/10 mb p-1"},kn={class:"flex items-center gap-2"},fn={key:0,class:"ml-1 bg-accent-cyan/20 text-accent-cyan border border-accent-cyan/30 text-xs px-1.5 py-0.5 rounded-full font-medium"},wn={class:"bg-background dark:bg-background/30 border border-stroke-subtle dark:border-stroke/10 rounded-lg p-4 mt-4 space-y-4"},_n={class:"grid grid-cols-1 md:grid-cols-3 gap-4"},Cn={key:1,class:"text-center py-12"},Mn={key:2,class:"text-center py-12"},Bn=bt({name:"NeighborsView",__name:"Neighbors",setup($){const r=Yt(),o={0:"Unknown",1:"Chat Node",2:"Repeater",3:"Room Server",4:"Hybrid Node"},i={0:"#6b7280",1:"#60a5fa",2:"#34d399",3:"#a855f7",4:"#f59e0b"},e=D({}),d=D(!0),h=D(null),s=D(_t("neighbors_compactView",!1)),a=D(_t("neighbors_showMapLegend",typeof window<"u"?window.innerWidth>=1024:!0)),f=D(_t("neighbors_showFilters",!1)),b=D(_t("neighbors_filters",{zeroHop:"all",routeType:"all",searchText:""}));ht(s,x=>Ct("neighbors_compactView",x)),ht(a,x=>Ct("neighbors_showMapLegend",x)),ht(f,x=>Ct("neighbors_showFilters",x)),ht(b,x=>Ct("neighbors_filters",x),{deep:!0});const v=D(!1),L=D(!1),B=D(!1),N=D(null),S=D(null),g=D(null),c=D(null),T=D(!1),F=D(null),I=q(()=>{if(!c.value)return null;const x=c.value;return{id:x.id,pubkey:x.pubkey,node_name:x.node_name,contact_type:x.contact_type,latitude:x.latitude,longitude:x.longitude,rssi:x.rssi,snr:x.snr,route_type:x.route_type,last_seen:x.last_seen,first_seen:x.first_seen,advert_count:x.advert_count,timestamp:x.timestamp,is_repeater:x.is_repeater,is_new_neighbor:x.is_new_neighbor,zero_hop:x.zero_hop}}),y=q(()=>r.stats?.config?.repeater?.latitude),p=q(()=>r.stats?.config?.repeater?.longitude),U=x=>x.filter(m=>{if(b.value.zeroHop!=="all"){const M=m.zero_hop;if(b.value.zeroHop==="true"&&!M||b.value.zeroHop==="false"&&M)return!1}if(b.value.routeType!=="all"){const M=m.route_type;if(b.value.routeType==="direct"&&M!==2||b.value.routeType==="transport_direct"&&M!==3||b.value.routeType==="flood"&&M!==1||b.value.routeType==="transport_flood"&&M!==0)return!1}if(b.value.searchText){const M=b.value.searchText.toLowerCase(),z=m.node_name?.toLowerCase()||"",Z=m.pubkey.toLowerCase();if(!z.includes(M)&&!Z.includes(M))return!1}return!0}),Y=()=>{b.value={zeroHop:"all",routeType:"all",searchText:""}},ot=q(()=>b.value.zeroHop!=="all"||b.value.routeType!=="all"||b.value.searchText!==""),lt=q(()=>{const x={};for(const[m,M]of Object.entries(e.value))x[m]=U(M);return x}),at=q(()=>Object.entries(o).filter(([x])=>lt.value[x]?.length>0).sort(([x],[m])=>parseInt(x)-parseInt(m))),yt=q(()=>Object.values(e.value).flat().filter(x=>{const m=x.latitude,M=x.longitude;return m!=null&&m!==0&&M!==null&&M!==void 0&&M!==0&&typeof m=="number"&&typeof M=="number"&&!isNaN(m)&&!isNaN(M)&&x.zero_hop===!0})),nt=async x=>{try{const m=await Et.get(`/adverts_by_contact_type?contact_type=${encodeURIComponent(x)}&hours=168`);return m.success&&Array.isArray(m.data)?m.data:[]}catch(m){return console.error(`Error fetching adverts for contact type ${x}:`,m),[]}},A=async()=>{d.value=!0,h.value=null;try{e.value={};for(const[x,m]of Object.entries(o)){const M=await nt(m);M.length>0&&(e.value[x]=M)}}catch(x){console.error("Error loading adverts:",x),h.value=x instanceof Error?x.message:"Failed to load neighbor data"}finally{d.value=!1}},u=D(),n=x=>{u.value?.highlightNode(x)},l=x=>{u.value?.unhighlightNode(x)},E=async x=>{const m=x;N.value=null,S.value=null,B.value=!0,g.value=m.node_name||"Unknown Node",L.value=!0;try{const M=r.stats?.config?.mesh?.path_hash_mode??0,Z=(M===2?3:M===1?2:1)*2,K=`0x${parseInt(m.pubkey.substring(0,Z),16).toString(16).padStart(Z,"0")}`;console.log(`Pinging neighbor ${m.node_name||"Unknown"} (${K}, path_hash_mode=${M})...`);const W=await Et.pingNeighbor(K,10);W.success&&W.data?(N.value=W.data,console.log("Ping successful:",W.data)):(S.value=W.error||"Unknown error occurred",console.error("Failed to ping neighbor:",W.error))}catch(M){console.error("Error pinging neighbor:",M),S.value=M instanceof Error?M.message:"Unknown error occurred"}finally{B.value=!1}},j=()=>{L.value=!1,N.value=null,S.value=null,g.value=null},H=x=>{c.value=x,v.value=!0},X=x=>{F.value=x,T.value=!0},tt=()=>{T.value=!1,F.value=null},R=()=>{v.value=!1,c.value=null},V=async x=>{try{await Et.deleteAdvert(x),await A(),R()}catch(m){console.error("Error deleting neighbor:",m)}};return Xt(async()=>{await A()}),(x,m)=>(k(),_("div",un,[d.value?(k(),_("div",pn,m[7]||(m[7]=[t("div",{class:"text-center"},[t("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),t("p",{class:"text-content-secondary dark:text-content-muted"},"Loading neighbor data...")],-1)]))):h.value?(k(),_("div",gn,[t("div",mn,[m[9]||(m[9]=t("svg",{class:"w-5 h-5 text-red-600 dark:text-accent-red",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})],-1)),t("div",null,[m[8]||(m[8]=t("h3",{class:"text-red-600 dark:text-accent-red font-medium"},"Error Loading Neighbors",-1)),t("p",hn,w(h.value),1)])])])):(k(),_(ct,{key:2},[it(Yo,{ref_key:"networkMapRef",ref:u,adverts:yt.value,"base-latitude":y.value,"base-longitude":p.value,"show-legend":a.value,"onUpdate:showLegend":m[0]||(m[0]=M=>a.value=M)},null,8,["adverts","base-latitude","base-longitude","show-legend"]),Object.keys(e.value).length>0?(k(),_("div",bn,[t("div",xn,[m[14]||(m[14]=t("span",{class:"text-content-primary dark:text-content-primary text-lg font-semibold"},null,-1)),t("div",yn,[t("div",vn,[t("button",{onClick:m[1]||(m[1]=M=>s.value=!1),class:C(["p-2 rounded-md transition-colors",s.value?"text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10":"bg-primary/20 text-primary border border-primary/30"]),title:"Comfortable view"},m[10]||(m[10]=[t("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"18",height:"6",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"12",width:"18",height:"6",rx:"2",stroke:"currentColor","stroke-width":"2"})],-1)]),2),t("button",{onClick:m[2]||(m[2]=M=>s.value=!0),class:C(["p-2 rounded-md transition-colors",s.value?"bg-primary/20 text-primary border border-primary/30":"text-content-secondary dark:text-content-muted hover:text-primary hover:bg-primary/10"]),title:"Compact view"},m[11]||(m[11]=[t("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[t("rect",{x:"3",y:"3",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"10",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"}),t("rect",{x:"3",y:"17",width:"18",height:"4",rx:"2",stroke:"currentColor","stroke-width":"2"})],-1)]),2)]),t("div",kn,[t("button",{onClick:m[3]||(m[3]=M=>f.value=!f.value),class:C(["px-3 py-1.5 text-xs rounded-lg transition-colors border",ot.value?"bg-primary/20 text-primary border-primary/30":"bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20"])},[m[12]||(m[12]=t("svg",{class:"w-4 h-4 inline mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707v6.586a1 1 0 01-1.447.894l-4-2A1 1 0 717 18.586V13.414a1 1 0 00-.293-.707L.293 6.293A1 1 0 010 5.586V3a1 1 0 011-1z"})],-1)),m[13]||(m[13]=et(" Filters ",-1)),ot.value?(k(),_("span",fn," Active ")):P("",!0)],2),ot.value?(k(),_("button",{key:0,onClick:Y,class:"px-3 py-1.5 text-xs rounded-lg bg-background-mute dark:bg-white/10 text-content-secondary dark:text-content-primary border border-stroke-subtle dark:border-stroke/20 hover:bg-stroke-subtle dark:hover:bg-white/20 transition-colors"}," Clear Filters ")):P("",!0)])])]),wt(t("div",wn,[t("div",_n,[t("div",null,[m[16]||(m[16]=t("label",{class:"block text-xs font-medium text-content-secondary dark:text-content-muted mb-1"},"Zero Hop",-1)),wt(t("select",{"onUpdate:modelValue":m[4]||(m[4]=M=>b.value.zeroHop=M),class:"w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none"},m[15]||(m[15]=[t("option",{value:"all"},"All Nodes",-1),t("option",{value:"true"},"Zero Hop Only",-1),t("option",{value:"false"},"Multi-Hop Only",-1)]),512),[[Wt,b.value.zeroHop]])]),t("div",null,[m[18]||(m[18]=t("label",{class:"block text-xs font-medium text-content-secondary dark:text-content-muted mb-1"},"Route Type",-1)),wt(t("select",{"onUpdate:modelValue":m[5]||(m[5]=M=>b.value.routeType=M),class:"w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none"},m[17]||(m[17]=[ft('<option value="all">All Types</option><option value="direct">Direct</option><option value="transport_direct">Transport Direct</option><option value="flood">Flood</option><option value="transport_flood">Transport Flood</option>',5)]),512),[[Wt,b.value.routeType]])]),t("div",null,[m[19]||(m[19]=t("label",{class:"block text-xs font-medium text-content-secondary dark:text-content-muted mb-1"},"Search",-1)),wt(t("input",{"onUpdate:modelValue":m[6]||(m[6]=M=>b.value.searchText=M),type:"text",placeholder:"Node name or pubkey...",class:"w-full bg-surface dark:bg-surface/50 border border-stroke-subtle dark:border-stroke/20 rounded-lg px-3 py-2 text-content-primary dark:text-content-primary text-sm focus:border-primary/50 focus:outline-none placeholder-gray-400 dark:placeholder-white/40"},null,512),[[le,b.value.searchText]])])])],512),[[ie,f.value]])])):P("",!0),(k(!0),_(ct,null,gt(at.value,([M,z])=>(k(),_("div",{key:M,class:"space-y-6"},[it(cn,{"contact-type":z,"contact-type-key":M,adverts:lt.value[M],"original-count":e.value[M]?.length||0,color:i[parseInt(M)],"base-latitude":y.value,"base-longitude":p.value,"is-compact-view":s.value,"is-first-table":!1,"show-view-toggle":!1,onHighlightNode:n,onUnhighlightNode:l,onMenuPing:E,onMenuDelete:H,onShowDetails:X},null,8,["contact-type","contact-type-key","adverts","original-count","color","base-latitude","base-longitude","is-compact-view"])]))),128)),at.value.length===0&&Object.keys(e.value).length===0?(k(),_("div",Cn,[m[20]||(m[20]=ft('<div class="text-content-secondary dark:text-content-muted mb-4"><svg class="w-16 h-16 mx-auto mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg></div><h3 class="text-content-primary dark:text-content-primary text-lg font-medium mb-2">No Neighbors Found</h3><p class="text-content-secondary dark:text-content-muted">No mesh neighbors have been discovered in your area yet.</p>',3)),t("button",{onClick:A,class:"mt-4 px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors"}," Refresh ")])):at.value.length===0&&ot.value?(k(),_("div",Mn,[m[21]||(m[21]=ft('<div class="text-content-secondary dark:text-content-muted mb-4"><svg class="w-16 h-16 mx-auto mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg></div><h3 class="text-content-primary dark:text-content-primary text-lg font-medium mb-2">No neighbors match your filters</h3><p class="text-content-secondary dark:text-content-muted mb-4">Try adjusting your filter criteria to see more results.</p>',3)),t("button",{onClick:Y,class:"px-4 py-2 bg-primary/20 text-primary border border-primary/30 rounded-lg hover:bg-primary/30 transition-colors"}," Clear Filters ")])):P("",!0)],64)),it(be,{show:v.value,neighbor:I.value,onClose:R,onDelete:V},null,8,["show","neighbor"]),it(Je,{show:L.value,"node-name":g.value,result:N.value,error:S.value,loading:B.value,onClose:j},null,8,["show","node-name","result","error","loading"]),it(Io,{"is-open":T.value,neighbor:F.value,"base-latitude":y.value,"base-longitude":p.value,onClose:tt},null,8,["is-open","neighbor","base-latitude","base-longitude"])]))}});export{Bn as default};