mirror of
https://github.com/dmduran12/pymc_console-dist.git
synced 2026-03-28 17:43:04 +01:00
3 lines
122 KiB
JavaScript
3 lines
122 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-_vG9wINu.js","assets/vendor-react-alRNW2nb.js","assets/vendor-virt-BytWoLhu.js","assets/cosmograph-DqYT4sUA.js","assets/vendor-core-FtpmsTnh.js","assets/BasemapLayer-CSqjQAiA.js","assets/index-CkRTgHHA.js","assets/vendor-charts-C916_-gs.js","assets/vendor-motion-DNp0Qg4F.js","assets/vendor-icons-TO0PZKGR.js","assets/vendor-fonts-CRZaZSFf.js","assets/maplibre-gl-B1CfjdFi.css","assets/vendor-charts-D1GxaB_c.css","assets/vendor-fonts-hkYiuhFD.css","assets/index-BawBpZYt.css"])))=>i.map(i=>d[i]);
|
||
import{c as e,a as s}from"./vendor-core-FtpmsTnh.js";import{j as t,r as a}from"./vendor-react-alRNW2nb.js";import{u as n}from"./vendor-virt-BytWoLhu.js";import{B as l,h as r,a5 as i,a6 as c,a7 as d,a8 as o,a9 as x,aa as m,H as p,ab as h,Q as u,ac as g,ad as f,ae as y,af as j,ag as b,ah as N,ai as v,aj as w,ak as k,M as C,p as _,al as S,am as P,an as H,ao as T,Y as B,_ as M,ap as F,aq as L,ar as D}from"./index-CkRTgHHA.js";import{p as z,d as $,e as R,g as A,b as E}from"./primitives-Bgn6Ik6L.js";import{u as U,r as I,a as V,b as Q,c as G,d as O,i as W}from"./consumer-registry-BUFl6buY.js";import{D as q,R as K,P as X,g as Y}from"./badge-colors-BxLppqaF.js";import{g as J,e as Z,a as ee}from"./chat-utils-mqGCinix.js";import{P as se,d as te,a as ae,b as ne}from"./payload-decoders-_TRhCJrs.js";import{S as le,i as re,g as ie}from"./SignalIndicator-Bdj3-1hL.js";import{_ as ce,$ as de,o as oe,A as xe,V as me,D as pe,R as he,a0 as ue,a1 as ge,a2 as fe,a3 as ye,a as je,a4 as be,H as Ne,a5 as ve,a6 as we,a7 as ke,a8 as Ce,a9 as _e,aa as Se,ab as Pe,ac as He,l as Te,K as Be,ad as Me,ae as Fe,af as Le,ag as De,C as ze,q as $e,Z as Re,w as Ae}from"./vendor-icons-TO0PZKGR.js";import{_ as Ee}from"./cosmograph-DqYT4sUA.js";import{f as Ue,r as Ie}from"./usePipelineStore-CLEA3Bev.js";import{D as Ve}from"./DataBox-DpDXI-WX.js";import{L as Qe,m as Ge,u as Oe,A as We}from"./vendor-motion-DNp0Qg4F.js";import{D as qe,u as Ke}from"./useMapViewStore-sFZdb1_p.js";function Xe({"aria-label":s="Page navigation",className:a,...n}){return t.jsx("nav",{"aria-label":s,...n,className:e("flex gap-x-2",a)})}function Ye({onClick:s,disabled:a=!1,className:n,children:r="Previous"}){return t.jsx("span",{className:e("grow basis-0",n),children:t.jsxs(l,{plain:!0,onClick:s,disabled:a,"aria-label":"Previous page",className:e("gap-1",a&&"invisible"),children:[t.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),r]})})}function Je({onClick:s,disabled:a=!1,className:n,children:r="Next"}){return t.jsx("span",{className:e("flex grow basis-0 justify-end",n),children:t.jsxs(l,{plain:!0,onClick:s,disabled:a,"aria-label":"Next page",className:e("gap-1",a&&"invisible"),children:[r,t.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:t.jsx("path",{d:"M13.25 8L2.75 8M13.25 8L10.75 10.5M13.25 8L10.75 5.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})]})})}function Ze({className:s,...a}){return t.jsx("span",{...a,className:e("hidden items-baseline gap-x-2 sm:flex",s)})}function es({page:s,current:a=!1,onClick:n,className:r,children:i}){return t.jsx(l,{plain:!a,outline:a,onClick:()=>null==n?void 0:n(s),"aria-label":`Page ${s}`,"aria-current":a?"page":void 0,className:e("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",r),children:i??s})}function ss({className:s,...a}){return t.jsx("span",{"aria-hidden":"true",...a,className:e("w-[2.25rem] select-none text-center text-sm text-fg-muted",s),children:"…"})}const ts=s(e=>({requestedHash:null,requestChannel:s=>e({requestedHash:s}),clearRequest:()=>e({requestedHash:null})})),as={rx:{icon:me,label:"Rx",badgeColor:q.rx,avatarBg:"bg-sys-green/15",avatarText:"text-sys-green"},forward:{icon:xe,label:"Fwd",badgeColor:q.forward,avatarBg:"bg-sys-cyan/15",avatarText:"text-sys-cyan"},duplicate:{icon:oe,label:"Dupe",badgeColor:q.duplicate,avatarBg:"bg-fg-muted/15",avatarText:"text-fg-secondary"},tx:{icon:de,label:"Tx",badgeColor:q.tx,avatarBg:"bg-sys-indigo/15",avatarText:"text-sys-indigo"},dropped:{icon:ce,label:"Drop",badgeColor:q.dropped,avatarBg:"bg-sys-amber/15",avatarText:"text-sys-amber"}},ns={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ls={sm:"w-8 h-8",md:"w-9 h-9",lg:"w-10 h-10"};function rs(e){return"tx_local"===e.packet_origin?"tx":"tx_forward"===e.packet_origin?"forward":e.is_duplicate?"duplicate":e.transmitted?"forward":e.drop_reason?"dropped":"rx"}const is=a.memo(function({packet:s,showLabel:a=!0,variant:n="avatar",size:l="sm"}){const i=rs(s),c=as[i],d=c.icon;return"avatar"===n?t.jsx("div",{className:e("flex items-center justify-center rounded-full flex-shrink-0",c.avatarBg,ls[l]),children:t.jsx(d,{className:e(ns[l],c.avatarText)})}):t.jsxs(r,{color:c.badgeColor,children:[t.jsx(d,{className:ns[l]}),a&&c.label]})}),cs=a.memo(function({path:s,localHash:a,className:n}){if(!s||0===s.length)return t.jsx("span",{className:e("text-fg-muted text-xs",n),children:"—"});const l=a?(a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase():null;return t.jsx("span",{className:e("flex items-center gap-0.5 type-data-xs overflow-hidden",n),children:s.map((e,a)=>{const n=a===s.length-1,r=l&&e.toUpperCase()===l;return t.jsxs("span",{className:"flex items-center flex-shrink-0",children:[r?t.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):t.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:e.toUpperCase()}),!n&&t.jsx(pe,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${e}-${a}`)})})});function ds({channelName:s,onClick:a,active:n,compact:l,className:r}){const i=s.startsWith("#")?s:`#${s}`,c=e("inline-flex items-center flex-shrink-0","font-medium",l?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",n?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!n&&"hover:bg-sys-blue/20 cursor-pointer",r);return a?t.jsx("button",{type:"button",onClick:a,className:c,children:i}):t.jsx("span",{className:c,children:i})}function os(e){return{"--data-box-accent":x[e]}}function xs(e){const s=e.payload_type_name||d(e.payload_type??e.type),t=e.route_type_name||o(e.route_type??e.route);return{payloadType:s,routeType:t,payloadColor:X[s]??"zinc",routeColor:K[t]??"zinc"}}function ms(e){if(!e)return[];if(Array.isArray(e))return e;try{const s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{return[]}}function ps(e,s){if(s){const t=s(e);return{name:t.name,isCompanion:t.isCompanion,isRepeater:t.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}const hs=a.memo(function({packet:s,onClick:n,localHash:l,neighbors:r,resolveSource:d,isFlashing:o=!1,isTraceHighlighted:m,onTraceHover:p,traceTag:h,onViewTraceReport:u,dupeGroupPosition:g,isDupeGroupHovered:f=!1,onDupeGroupHover:y,dupeCount:j,getDecodedContent:b,onChannelClick:N}){const v=!j&&i(s.is_duplicate),w=void 0!==g,{payloadType:k,routeType:C,payloadColor:_,routeColor:S}=xs(s),P="tx_local"===s.packet_origin,H="TRACE"===k,T=ms(s.original_path),B=ms(s.forwarded_path),M=B.length>0?B:T,F=s.src_hash?(s.src_hash.startsWith("0x")?s.src_hash.slice(2,6):s.src_hash.slice(0,4)).toUpperCase():null,{name:L,isRepeater:D}=ps(s,d);let z=null,$=null,R=null,A=null;if("GRP_TXT"===k&&b){const e=b(s);(null==e?void 0:e.decrypted)&&($=e.senderName,R=e.channelName,A=e.channelHash,e.text&&(z=e.text))}else if("TXT_MSG"===k&&s.raw_packet)try{const e=se.fromHex(s.raw_packet);if(e.success&&e.packet){const s=te(e.packet.payload);s&&!s.encrypted&&(z=s.text)}}catch{}const E=$||(D?null:L),U=!!E,I=!U&&D&&!!L,V=!U&&!I&&"GRP_TXT"===k&&!z,Q=s.payload_length??s.length??0;s.lbt_attempts;const G=a.useCallback(()=>{H&&h&&u?u(h):n(s)},[H,h,u,n,s]),O=a.useCallback(()=>{H&&h&&p&&p(h),w&&y&&s.packet_hash&&y(s.packet_hash)},[H,h,p,w,y,s.packet_hash]),W=a.useCallback(()=>{p&&p(null),y&&y(null)},[p,y]),q=x[_]||x.zinc,K=f;return t.jsxs("div",{onClick:G,onMouseEnter:O,onMouseLeave:W,className:e("group relative cursor-pointer","hover:bg-subtle-fill",v&&!f&&"opacity-40",o&&"flash-row",P&&"bg-sys-indigo/5",m&&"bg-sys-teal/10"),children:[t.jsx("div",{className:e("absolute pointer-events-none transition-opacity duration-75",w?K?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:(()=>{const e={pointerEvents:"none"};return"first"===g?{...e,borderTop:`2px solid ${q}`,borderLeft:`2px solid ${q}`,borderRight:`2px solid ${q}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:"middle"===g?{...e,borderTop:"none",borderLeft:`2px solid ${q}`,borderRight:`2px solid ${q}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:"last"===g?{...e,borderTop:"none",borderLeft:`2px solid ${q}`,borderRight:`2px solid ${q}`,borderBottom:`2px solid ${q}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...e,border:`2px solid ${q}`,borderRadius:"8px",inset:"-2px"}})()}),t.jsxs("div",{className:"relative flex items-center gap-2 min-[600px]:gap-3 px-2 py-2 min-[600px]:px-3 min-[600px]:py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[t.jsx("div",{className:"relative flex-shrink-0",children:U?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:J(Z(E).cleanName)},children:Z(E).emoji?t.jsx("span",{className:"text-base leading-none",children:Z(E).emoji}):t.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:ee(E)})}):I?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:t.jsx(he,{className:"size-5 text-sys-blue"})}):V?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:t.jsx(ue,{className:"size-4 text-fg-muted"})}):t.jsx(is,{packet:s,variant:"avatar",size:"sm"})}),t.jsx("div",{className:"min-w-0",children:U?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:E}),F&&t.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):I?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:L}),F&&t.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:F||"—"}),L&&t.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:L})]})})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[t.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:os(_),children:k}),j&&j>1&&t.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",j]}),t.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:os(S),children:C}),t.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[Q,"B"]}),t.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:z||R?t.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[R&&t.jsx(ds,{channelName:R,compact:!0,onClick:N&&A?e=>{e.stopPropagation(),N(A)}:void 0}),z&&t.jsx("span",{className:"italic truncate",children:z})]}):t.jsx(cs,{path:M,localHash:l})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[t.jsx("span",{className:"data-box data-box-compact",children:c(s.timestamp)}),t.jsx(le,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0,validated:re(s)})]})]})]})}),us=a.memo(function({packet:s,onClick:a,localHash:n,neighbors:l,resolveSource:r,isFlashing:d=!1,isTraceHighlighted:o,traceTag:m,onViewTraceReport:p,dupeGroupPosition:h,isDupeGroupHovered:u=!1,onDupeGroupHover:g,dupeCount:f,getDecodedContent:y,onChannelClick:j}){const{payloadType:b,routeType:N,payloadColor:v,routeColor:w}=xs(s),k="tx_local"===s.packet_origin,C="TRACE"===b,_=!f&&i(s.is_duplicate),S=ms(s.original_path),P=ms(s.forwarded_path),H=P.length>0?P:S,T=s._hopCount??H.length,B=s.src_hash?(s.src_hash.startsWith("0x")?s.src_hash.slice(2,6):s.src_hash.slice(0,4)).toUpperCase():null,{name:M,isRepeater:F}=ps(s,r);let L=null,D=null,z=null,$=null;if("GRP_TXT"===b&&y){const e=y(s);(null==e?void 0:e.decrypted)&&(D=e.senderName,z=e.channelName,$=e.channelHash,e.text&&(L=e.text))}else if("TXT_MSG"===b&&s.raw_packet)try{const e=se.fromHex(s.raw_packet);if(e.success&&e.packet){const s=te(e.packet.payload);s&&!s.encrypted&&(L=s.text)}}catch{}const R=D||(F?null:M),A=!!R,E=!A&&F&&!!M,U=!A&&!E&&"GRP_TXT"===b&&!L,I=s.payload_length??s.length??0,V=s.lbt_attempts??0,Q=x[v]||x.zinc;return t.jsxs("div",{onClick:()=>{C&&m&&p?p(m):a(s)},className:e("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",_&&"opacity-40",d&&"flash-row",k&&"bg-sys-indigo/5",o&&"bg-sys-teal/10"),children:[t.jsx("div",{className:"absolute left-0 transition-all",style:(()=>{if(!h)return{opacity:0};const e=u?1:.4,s=u?"3px":"2px";return"first"===h?{backgroundColor:Q,opacity:e,width:s,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:"middle"===h?{backgroundColor:Q,opacity:e,width:s,top:0,bottom:0,borderRadius:0}:"last"===h?{backgroundColor:Q,opacity:e,width:s,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:Q,opacity:e,width:s,top:"6px",bottom:"6px",borderRadius:"9999px"}})()}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:A?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:J(Z(R).cleanName)},children:Z(R).emoji?t.jsx("span",{className:"text-base leading-none",children:Z(R).emoji}):t.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:ee(R)})}):E?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:t.jsx(he,{className:"size-5 text-sys-blue"})}):U?t.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:t.jsx(ue,{className:"size-4 text-fg-muted"})}):t.jsx(is,{packet:s,variant:"avatar",size:"sm"})}),t.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[A?t.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:R}):E?t.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:M}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:B||"—"}),M&&t.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:M})]}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:os(v),children:b}),t.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:os(w),children:N}),f&&f>1&&t.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",f]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:s.rssi}),t.jsx(le,{rssi:s.rssi,compact:!0,showValues:!1,validated:re(s)})]})]}),t.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[t.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:c(s.timestamp)}),I>0&&t.jsxs("span",{children:[I,"B"]}),V>0&&t.jsxs("span",{className:V>1?"text-sys-amber/60":void 0,children:["LBT:",V]}),null!=s.snr&&t.jsxs("span",{children:[s.snr.toFixed(0),"dB"]}),L||z?t.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[z&&t.jsx(ds,{channelName:z,compact:!0,onClick:j&&$?e=>{e.stopPropagation(),j($)}:void 0}),L&&t.jsx("span",{className:"italic truncate",children:L})]}):T>0?t.jsx(cs,{path:H,localHash:n}):null]})]})]})]})}),gs=a.lazy(()=>Ee(()=>import("./PathMapMapLibre-_vG9wINu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])));function fs(e){return`${(100*e).toFixed(0)}%`}function ys(e,s,t){let a;return a=0===s?t.muted:e>=1?t.success:e>=.5?t.secondary:e>=.25?t.poor:e>0?t.danger:t.muted,{color:a}}class js extends a.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[t.jsx(ye,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function bs({path:s,neighbors:n,localNode:l,localHash:r,srcHash:i,dstHash:c,neighborAffinity:d,prefixLookup:o,hubNodes:x,traceSnr:h,advertiserSource:u}){const[g,f]=a.useState(null),y=a.useMemo(()=>{if(!u)return null;const e="wardrive"===u.nodeType;return{prefix:u.prefix||"??",candidates:[{hash:u.publicKey||u.prefix||"source",name:u.name,latitude:u.latitude,longitude:u.longitude,probability:1,isLocal:!1,isWardrive:e}],confidence:1,totalMatches:1,isSource:!0}},[u]),j=a.useMemo(()=>{if(u)return null;if(!i)return null;const e=p(i),s=n[i];if((null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&(0!==s.latitude||0!==s.longitude))return{prefix:e,candidates:[{hash:i,name:s.node_name||s.name||"Source",latitude:s.latitude,longitude:s.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===s.zero_hop}],confidence:1,totalMatches:1,isSource:!0};const t=(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||i.slice(0,8);return{prefix:e,candidates:[{hash:i,name:t,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[u,i,n]),b=a.useMemo(()=>{const e=(null==c?void 0:c.startsWith("0x"))?c.slice(2):c;if((!e||"00"===e||"0000000000000000"===e)&&l&&r){const e=p(r),s=0!==l.latitude||0!==l.longitude;return{prefix:e,candidates:[{hash:r,name:l.name||"Local Node",latitude:s?l.latitude:0,longitude:s?l.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!c)return null;const s=p(c);if(r&&c===r&&l){const e=0!==l.latitude||0!==l.longitude;return{prefix:s,candidates:[{hash:c,name:l.name||"Local Node",latitude:e?l.latitude:0,longitude:e?l.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const t=n[c];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:s,candidates:[{hash:c,name:t.node_name||t.name||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const a=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||c.slice(0,8);return{prefix:s,candidates:[{hash:c,name:a,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[c,n,l,r]),N=a.useMemo(()=>function(e,s,t,a,n,l){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const r=e.length-1,i=e.map((i,c)=>{const d=c===r,o=e.length-c,{candidates:x,totalMatches:p}=function(e,s,t,a,n=!1,l,r,i){const c=Ue(s);let d;r&&(d=Ie(r,e,{position:i,isLastHop:n}).confidence);const{matches:o,probability:x}=function(e,s,t,a,n=!1){const l=e.toUpperCase(),r=[],i=t&&m(l,t);i&&r.push(t);for(const h of Object.keys(s))m(l,h)&&r.push(h);if(n&&i&&t&&1===r.length)return{matches:r,probability:1,bestMatch:t};if(n&&i&&r.length>1){const e=r.filter(e=>e!==t);if(1===e.length)return{matches:r,probability:1,bestMatch:e[0]}}const c=r.length>0?1/r.length:0,d=[...r].sort();let o=null,x=-1;if(1===d.length)o=d[0];else if(d.length>1&&a){for(const e of d){const s=a.get(e),t=s?"number"==typeof s?s:s.combinedScore:0;t>x&&(x=t,o=e)}o||(o=d[0])}else d.length>0&&(o=d[0]);let p=c;if(r.length>1&&a&&x>0){let e=0;for(const s of r){const t=a.get(s);e+=t?"number"==typeof t?t:t.combinedScore:0}e>0&&(p=Math.min(.95,x/e))}return{matches:r,probability:p,bestMatch:o}}(e,c,a,l,n),p=o.length,h=[],u=e.toUpperCase(),g=t&&void 0!==t.latitude&&void 0!==t.longitude&&(0!==t.latitude||0!==t.longitude);for(const y of o){if(a&&m(u,a)&&y===a&&g&&t){h.push({hash:y,name:t.name||"Local Node",latitude:t.latitude,longitude:t.longitude,probability:n?1:x,isLocal:!0});continue}const e=c[y];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&h.push({hash:y,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:x,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const f=h.length;if(1===f)h[0].probability=d??1;else if(f>1)if(void 0!==d&&d>0){h[0].probability=d;const e=1-d,s=f-1;h.slice(1).forEach(t=>{t.probability=e/s})}else{let e=0;const s=h.map(s=>{if(s.isLocal)return{candidate:s,score:1};const a=null==l?void 0:l.get(s.hash);let n=.5;var r;let i;return g&&t&&(n=(r=function(e,s,t,a){const n=(t-e)*Math.PI/180,l=(a-s)*Math.PI/180,r=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r))*6371e3}(t.latitude,t.longitude,s.latitude,s.longitude))<100?1:r<500?.9:r<1e3?.7:r<5e3?.5:r<1e4?.3:.1),a?i=.3*n+.3*a.hopConsistencyScore+.4*a.frequencyScore:(i=n,s.isDirectNeighbor&&(i=Math.max(i,.8))),e+=i,{candidate:s,score:i}});if(e>0)s.forEach(({candidate:s,score:t})=>{s.probability=Math.min(.95,t/e)});else{const e=1/f;h.forEach(s=>s.probability=e)}}return{candidates:h,totalMatches:p}}(i,s,t,a,d,n,l,o),h=x.length>0?Math.max(...x.map(e=>e.probability)):0;return{prefix:i,candidates:x,confidence:h,totalMatches:p}}),c=i.reduce((e,s)=>0===s.confidence?0:e*s.confidence,1),d=i.some(e=>e.candidates.length>0);return{hops:i,overallConfidence:c,hasValidPath:d}}(s,n,l,r,d,o),[s,n,l,r,d,o]),v=a.useMemo(()=>{const e=[];y?e.push(y):j&&e.push(j),e.push(...N.hops),b&&e.push(b);const s=e.reduce((e,s)=>0===s.confidence?0:e*s.confidence,1),t=e.some(e=>e.candidates.some(e=>0!==e.latitude||0!==e.longitude));return{hops:e,overallConfidence:s,hasValidPath:t}},[y,j,N,b]),w=a.useMemo(()=>{const e=getComputedStyle(document.documentElement);return{success:e.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:e.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:e.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:e.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:e.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return v.hasValidPath?t.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),t.jsx("span",{className:(k=v.overallConfidence,k>=1?"text-sys-green":k>=.5?"text-sys-indigo":k>=.25?"text-signal-poor":k>0?"text-sys-red":"text-fg-muted"),children:fs(v.overallConfidence)}),t.jsx("button",{className:"text-fg-muted hover:text-fg-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:t.jsx(fe,{className:"w-3 h-3"})})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),t.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),t.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),t.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(js,{children:t.jsx(a.Suspense,{fallback:t.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:t.jsx(gs,{resolvedPath:v,localNode:l,hubNodes:x,hoveredHopIndex:g,onHoverHop:f,traceSnr:h})})})}),t.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:v.hops.map((s,a)=>{var n,l,r;const i=!0===s.isSource,c=!0===s.isDestination,d=g===a;let o;return o=i?`Source: ${(null==(n=s.candidates[0])?void 0:n.name)||"Unknown"}`:c?`Destination: ${(null==(l=s.candidates[0])?void 0:l.name)||"Unknown"}`:0===s.totalMatches?"No matching nodes found":1===s.totalMatches?`Exact match: ${(null==(r=s.candidates[0])?void 0:r.name)||"Unknown"}`:`${s.totalMatches} possible matches (${(100*s.confidence).toFixed(0)}% confidence)`,t.jsxs("div",{className:e("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",d?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",i&&"border border-sys-green/30",c&&"border border-sys-blue/30"),title:o,onMouseEnter:()=>f(a),onMouseLeave:()=>f(null),children:[i&&t.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),c&&t.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),t.jsx("span",{style:ys(s.confidence,s.totalMatches,w),children:s.prefix}),!i&&!c&&s.totalMatches>1&&t.jsxs("span",{className:"text-fg-muted",children:["×",s.totalMatches]}),!i&&!c&&0===s.totalMatches&&t.jsx("span",{className:"text-fg-muted",children:"?"})]},a)})})]}):t.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[t.jsx(ge,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var k}function Ns(e){return e.match(/.{1,2}/g)||[]}function vs(e){return null!==e&&e.startsWith("payload:")}const ws=15,ks="color-mix(in srgb, var(--elevated) 60%, var(--body))",Cs="\n inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n ",_s=2,Ss={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function Ps(e,s){return e?`inset 0 0 0 ${_s}px ${x[s]}`:Cs}function Hs(e,s){return e?s:`color-mix(in srgb, ${s} ${ws}%, transparent)`}function Ts({segments:e,selectedSegment:s,onSegmentClick:n}){const[l,r]=a.useState(null),[i,c]=a.useState(null),d=e.some(e=>void 0!==e.id)&&n,o=[];for(const t of e){const e=Ns(t.hex);for(const s of e)o.push({byte:s.toUpperCase(),color:t.color,id:t.id})}const m=[];for(let t=0;t<o.length;t+=16)m.push(o.slice(t,t+16));return t.jsx("div",{className:"space-y-1",children:m.map((e,a)=>{const o=e.length<16;return t.jsx("div",{className:"flex rounded-md overflow-hidden",children:e.map(({byte:a,color:m,id:p},h)=>{const u=h===e.length-1,g=o&&u,f=x[m],y=p?l===p:i===m,j=Boolean(p&&s===p),b=y||j;return t.jsx("span",{className:"w-[1.75rem] text-xs text-center py-0.5 font-mono select-text "+(d?"cursor-pointer":""),style:{backgroundColor:Hs(b,f),color:b?"rgba(255,255,255,0.95)":f,transition:b?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...g?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{p?r(p):c(m)},onMouseLeave:()=>{r(null),c(null)},onClick:()=>p&&(null==n?void 0:n(p)),onTouchStart:()=>{p?r(p):c(m)},onTouchEnd:()=>{r(null),c(null)},children:a},h)})},a)})})}function Bs({rawHex:e,hexSegments:s,selectedSegment:n,onSegmentClick:l}){const[r,i]=a.useState(!1),c=a.useCallback(async()=>{try{await navigator.clipboard.writeText(e.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)}catch(s){console.error("Failed to copy:",s)}},[e]);return t.jsxs("div",{className:"bg-black rounded-2xl p-6 relative",children:[t.jsx(Ts,{segments:s,selectedSegment:n,onSegmentClick:l}),t.jsx("button",{onClick:c,className:"absolute bottom-3 right-3 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg bg-subtle-fill-hover hover:bg-subtle-fill-strong text-fg-muted hover:text-fg-secondary transition-all text-xs font-sans",title:"Copy raw packet hex",children:r?t.jsxs(t.Fragment,{children:[t.jsx(je,{className:"w-3.5 h-3.5 text-sys-green"}),t.jsx("span",{className:"text-sys-green",children:"Copied"})]}):t.jsxs(t.Fragment,{children:[t.jsx(oe,{className:"w-3.5 h-3.5"}),t.jsx("span",{children:"Copy"})]})})]})}function Ms({bits:e,field:s,value:a,binary:n}){return t.jsxs("tr",{children:[t.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:e}),t.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:s}),t.jsx("td",{className:"py-1.5",children:(()=>{if("Payload Type"===s){const e=X[a]||"zinc";return t.jsx(r,{color:e,children:a})}if("Route Type"===s){const e=K[a]||"zinc";return t.jsx(r,{color:e,children:a})}return t.jsx("span",{className:"text-sm text-fg-primary",children:a})})()}),t.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function Fs({id:e,title:s,color:a,hexBytes:n,startByte:l,endByte:i,isSelected:c,children:d}){const o=n?Ns(n):[];return t.jsxs(Ge.div,{layout:"position",layoutId:e,transition:Ss,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:ks,boxShadow:Ps(c,a)},children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[t.jsx(r,{color:a,children:s}),o.length>0&&o.length<=16&&o.map((e,s)=>t.jsx(r,{color:a,className:"font-mono",children:e.toUpperCase()},s))]}),t.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",l,"-",i]})]}),t.jsx("div",{className:"min-w-0 overflow-hidden",children:d})]})}function Ls({advert:e,timestamp:s}){const a=f(s||e.timestamp);return t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:t.jsx(he,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:e.name||"Unknown Node"}),t.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:e.nodeType})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-2",children:[void 0!==e.latitude&&void 0!==e.longitude&&t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ge,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),t.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[e.latitude.toFixed(5),"°, ",e.longitude.toFixed(5),"°"]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:a})]})]})]})})}function Ds({decoded:e,timestamp:s}){const a=s?f(s):"Unknown";return t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-teal) 0%, var(--sys-cyan) 100%)"},children:t.jsx(Se,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:e.channelName||"Channel Data"}),t.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[e.dataLength," bytes • ",e.decrypted?"Decrypted":"Encrypted"]})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ne,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),t.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",t.jsxs("span",{className:"font-mono",children:["0x",e.channelHash]})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:a})]}),e.decrypted&&e.decryptedHex&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[t.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),t.jsx("div",{className:"max-w-full overflow-x-auto",children:t.jsx(Ve,{size:"compact",copy:!0,className:"inline-block",children:t.jsx("span",{className:"break-all text-xs",children:e.decryptedHex.toUpperCase()})})})]})]})]})})}function zs({decoded:e,timestamp:s,isLoading:n=!1,onDecrypted:l}){const r=s?f(s):"Unknown",[i,c]=a.useState(""),[d,o]=a.useState(!1),[x,m]=a.useState(null),[p,h]=a.useState(!1),u=a.useCallback(async()=>{if(i.trim()&&e.ciphertextHex&&e.macHex){o(!0),m(null);try{const s=parseInt(e.channelHash,16),t=y(e.macHex),a=y(e.ciphertextHex),n=await j(i.trim(),s,t,a);if(n.success){const s=n.result.plaintext,t=new TextDecoder("utf-8",{fatal:!1}).decode(s.slice(5)),a=t.indexOf(": "),r={...e,channelName:n.result.channelName,decrypted:!0,timestamp:s[0]|s[1]<<8|s[2]<<16|s[3]<<24,flags:s[4],senderName:a>0?t.slice(0,a):void 0,text:a>0?t.slice(a+2):t};null==l||l(r),c(""),h(!1)}else m(n.error)}catch(s){m(s instanceof Error?s.message:"Unknown error")}finally{o(!1)}}},[i,e,l]);return n?t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 h-[15px]",children:[t.jsx("div",{className:"h-2.5 w-12 rounded bg-subtle-fill-hover animate-pulse"}),t.jsx("div",{className:"h-2.5 w-16 rounded bg-subtle-fill-hover animate-pulse"})]}),t.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"color-mix(in srgb, var(--sys-blue) 30%, transparent)"},children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"h-3.5 w-48 rounded bg-subtle-fill-strong animate-pulse"}),t.jsx("div",{className:"h-3.5 w-32 rounded bg-subtle-fill-strong animate-pulse"})]})})]})}):e.decrypted?t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.senderName&&t.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",t.jsx("span",{className:"text-fg-secondary font-medium",children:e.senderName})]}),e.channelName&&t.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",t.jsx("span",{className:"text-sys-cyan font-medium",children:e.channelName})]})]}),t.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tl-md",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, color-mix(in srgb, var(--sys-blue) 85%, var(--sys-cyan)) 100%)"},children:t.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.text})})]})}):t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--zinc-500) 0%, color-mix(in srgb, var(--zinc-500) 70%, black) 100%)"},children:t.jsx(we,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:e.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),t.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",t.jsxs("span",{className:"font-mono",children:["0x",e.channelHash]})]})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),e.ciphertextHex&&e.macHex&&t.jsx("div",{className:"space-y-2",children:p?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"Channel name (e.g. south-bay)",className:"flex-1 px-3 py-1.5 text-sm rounded-lg bg-subtle-fill-strong border border-edge-subtle text-fg-primary placeholder:text-fg-muted focus:outline-none focus:border-zinc-500",onKeyDown:e=>"Enter"===e.key&&u(),disabled:d}),t.jsx("button",{onClick:u,disabled:d||!i.trim(),className:"px-3 py-1.5 text-sm font-medium rounded-lg bg-zinc-600 hover:bg-zinc-500 text-white disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:d?"Testing...":"Try"}),t.jsx("button",{onClick:()=>{h(!1),m(null),c("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),x&&t.jsx("p",{className:"text-xs text-sys-red",children:x})]}):t.jsx("button",{onClick:()=>h(!0),className:"text-xs text-zinc-400 hover:text-zinc-300 underline underline-offset-2 transition-colors",children:"Know the channel name? Try to decrypt"})}),!p&&t.jsx("p",{className:"text-xs text-fg-muted",children:e.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function $s({decoded:e,timestamp:s}){const a=s?f(s):"Unknown";return t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:t.jsx(_e,{className:"w-5 h-5 text-white"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),t.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",t.jsxs("span",{className:"font-mono text-sys-green",children:["0x",e.crc]})," · ",a]})]})]})}function Rs({decoded:e,timestamp:s}){const a=s?f(s):"Unknown",n=e.path.length;return t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-amber) 0%, var(--sys-orange) 100%)"},children:t.jsx(Ce,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),t.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",1===n?"hop":"hops"]})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:a})]}),e.path.length>0&&t.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.path.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&t.jsx(xe,{className:"w-4 h-4 text-sys-amber"}),t.jsx(r,{color:"amber",className:"font-mono",children:e})]},s))})})]})]})})}function As({decoded:e,timestamp:s}){const a=s?f(s):"Unknown",n=e.pathHashes.length,l=e.snrValues.length;return t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-blue) 0%, var(--sys-indigo) 100%)"},children:t.jsx(ke,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",e.isComplete?"Complete":"In Progress"]}),t.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",e.traceTag.slice(0,8),e.isComplete&&" • ✓"]})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary",children:a})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[t.jsxs("span",{children:[n," target ",1===n?"hop":"hops"]}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:[l," SNR ",1===l?"sample":"samples"]}),0!==e.authCode&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsxs("span",{children:["Auth: ",e.authCode]})]})]}),e.pathHashes.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:e.pathHashes.map((s,a)=>{const n=e.snrValues[a],l=void 0!==n?(e=>e>=7?"green":e>=0?"yellow":e>=-5?"orange":"red")(n):"zinc",i=void 0!==n;return t.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&t.jsx(xe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(r,{color:i?"blue":"zinc",className:"font-mono",children:s}),i&&t.jsxs(r,{color:l,className:"font-mono",children:[n>=0?"+":"",Number.isInteger(n)?n:n.toFixed(1),"dB"]})]})]},a)})})]})]})})}function Es({decoded:e,timestamp:s}){const a=s?f(s):"Unknown";return e.encrypted?t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:"linear-gradient(135deg, var(--sys-indigo) 0%, var(--sys-blue) 100%)"},children:t.jsx(we,{className:"w-5 h-5 text-white"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),t.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[e.srcHash," → ",e.destHash," · ",a]})]})]}):t.jsxs("div",{className:"mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[t.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[t.jsx("span",{className:"font-mono text-fg-secondary",children:e.srcHash})," → ",t.jsx("span",{className:"font-mono text-fg-secondary",children:e.destHash})]}),t.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",a]})]}),t.jsx("div",{className:"inline-block max-w-[85%] px-3.5 py-2 rounded-2xl rounded-tr-md ml-auto",style:{background:"linear-gradient(135deg, var(--sys-green) 0%, var(--sys-teal) 100%)"},children:t.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:e.text})})]})}function Us({decoded:e,timestamp:s}){const a=s?f(s):"Unknown",n=(e.partNumber+1)/e.totalParts*100;return t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center shadow-lg",style:{background:"linear-gradient(135deg, var(--sys-yellow) 0%, var(--sys-amber) 100%)"},children:t.jsx(be,{className:"w-6 h-6 text-white"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),t.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",e.partNumber+1," of ",e.totalParts]})]})]}),t.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),t.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.jsx("div",{children:t.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Ne,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),t.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",t.jsx("span",{className:"font-mono",children:e.messageId})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ve,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),t.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:a})]})]})]})})}function Is({decoded:e,timestamp:s,payloadType:a}){const n=s?f(s):"Unknown",l=(()=>{switch(a){case u.REQ:return{icon:Te,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case u.RESPONSE:return{icon:He,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case u.ANON_REQ:return{icon:we,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Pe,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:e.payloadTypeName}}})(),r=l.icon;return t.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${l.gradient})`},children:t.jsx(r,{className:"w-5 h-5 text-white"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:l.label}),t.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[e.length," bytes · ",n]})]})]})}function Vs({pathHex:e}){if(!e)return null;const s=Ns(e);return t.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&t.jsx(xe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ve,{size:"compact",copy:!0,children:e.toUpperCase()}),t.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:s+1})]})]},s))})}function Qs({decoded:e,payloadType:s}){const a=g[s]||`TYPE_${s}`;switch(e.type){case"advert":{const s="chat"===e.nodeType?"companion":e.nodeType.replace("_"," "),a=void 0!==e.latitude&&void 0!==e.longitude&&!(0===e.latitude&&0===e.longitude);return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",s]}),e.name&&t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",e.name]}),a&&t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",e.latitude.toFixed(4),"°, ",e.longitude.toFixed(4),"°"]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",f(e.timestamp)]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",e.flagsDescription]})]})}case"ack":return t.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",e.crc]})});case"path":return t.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",e.pathString||"(empty)"]})});case"trace":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",e.traceTag]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",e.pathString||"(empty)"]}),e.snrValues.length>0&&t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",e.snrValues.map(e=>`${e>=0?"+":""}${Number.isInteger(e)?e:e.toFixed(1)}dB`).join(" → ")]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",e.isComplete?"✓ Complete":`In progress (${e.snrValues.length}/${e.pathHashes.length})`]})]});case"txt_msg":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",e.destHash]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",e.srcHash]}),e.encrypted?t.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",e.text]})]});case"grp_txt":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",e.channelName?t.jsx("span",{className:"text-sys-green",children:e.channelName}):e.isPublicHashChannel?t.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):t.jsxs("span",{className:"font-mono",children:["0x",e.channelHash]})]}),e.decrypted?t.jsxs(t.Fragment,{children:[e.senderName&&t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"From:"})," ",e.senderName]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",e.text]})]}):e.isPublicHashChannel?t.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):t.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",e.channelName?t.jsx("span",{className:"text-sys-teal",children:e.channelName}):t.jsxs("span",{className:"font-mono",children:["0x",e.channelHash]})]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",e.dataLength," bytes ",e.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",e.partNumber+1,"/",e.totalParts]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",e.messageId]})]});case"control":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",e.subtypeName]}),e.dataLength>0&&t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",e.dataLength," bytes"]})]});case"req":case"response":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",e.destHash]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",e.srcHash]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",e.ciphertextLength," bytes"]})]});case"anon_req":return t.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",e.destHash]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",t.jsxs("span",{className:"font-mono break-all",children:[e.senderPublicKey.slice(0,16),"…"]})]}),t.jsxs("p",{children:[t.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",e.ciphertextLength," bytes"]})]});default:return t.jsxs("p",{className:"text-xs text-fg-secondary",children:[a," (","length"in e?e.length:0," bytes)"]})}}const Gs=a.memo(function({packet:e,decodedGrpTxt:s}){var n,l;const i=e.raw_packet||"",c=i.length/2,d=h(),[o,x]=a.useState(null),[m,p]=a.useState(null),[g,y]=a.useState(!1),[j,b]=a.useState(null),N=a.useCallback(e=>{b(s=>s===e?null:e)},[]),v=a.useMemo(()=>z(i),[i]),w=null==(n=null==v?void 0:v.packet)?void 0:n.payloadType,k=(null==v?void 0:v.payloadHex)||"",C=null==(l=null==v?void 0:v.packet)?void 0:l.payload,_=w===u.GRP_TXT,S=w===u.GRP_DATA,P=_&&!s&&(!d||g);if(a.useEffect(()=>{if(x(null),y(!1),s)return;if(!_||!C||C.length<4)return;if(!d)return void y(!0);y(!0);let e=!1;return ae(C).then(s=>{e||(x(s),y(!1))}),()=>{e=!0}},[k,_,d,s]),a.useEffect(()=>{if(p(null),!S||!C||C.length<4)return;if(!d)return;let e=!1;return ne(C).then(s=>{e||p(s)}),()=>{e=!0}},[k,S,d]),!v||0===i.length)return t.jsx("div",{className:"p-4 text-center text-fg-muted",children:t.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:H}=v;let T=v.decoded;s&&"grp_txt"===v.decoded.type?T=s:o&&"grp_txt"===v.decoded.type?T=o:m&&"grp_data"===v.decoded.type&&(T=m);const B=a.useMemo(()=>function(e,s){switch(e.type){case"advert":return function(e,s){const a=[];let n=0;const l=s.slice(0,64);a.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:l,startByte:n,endByte:n+31,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:e.publicKey.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const r=s.slice(64,72);a.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:r,startByte:n,endByte:n+3,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:r.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[e.timestamp," (",f(e.timestamp),")"]})]})}),n+=4;const i=s.slice(72,200);a.push({id:"payload:signature",title:"Signature",color:"teal",hex:i,startByte:n,endByte:n+63,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:e.signature.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=s.slice(200,202);if(a.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.flags.toString(16).padStart(2,"0").toUpperCase()]}),t.jsx("p",{className:"text-xs text-fg-primary mt-1",children:e.flagsDescription}),t.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",e.nodeType]})]})}),n+=1,void 0!==e.latitude){const l=s.slice(2*n,2*n+8);a.push({id:"payload:latitude",title:"Latitude",color:"green",hex:l,startByte:n,endByte:n+3,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:l.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[e.latitude.toFixed(6),"°"]})]})}),n+=4}if(void 0!==e.longitude){const l=s.slice(2*n,2*n+8);a.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:l,startByte:n,endByte:n+3,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:l.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[e.longitude.toFixed(6),"°"]})]})}),n+=4}if(e.name){const l=s.slice(2*n),r=l.length/2;a.push({id:"payload:name",title:"Name",color:"amber",hex:l,startByte:n,endByte:n+r-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:l.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',e.name,'"']})]})})}return a}(e,s);case"ack":return function(e,s){return[{id:"payload:crc",title:"CRC",color:"green",hex:s.slice(0,8),startByte:0,endByte:3,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.crc]}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}(e,s);case"grp_txt":return function(e,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.channelHash]}),e.channelName&&t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",e.channelName]})]})}),e.macHex&&a.push({id:"payload:mac",title:"MAC",color:"indigo",hex:s.slice(2,6),startByte:1,endByte:2,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.macHex.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.push({id:"payload:ciphertext",title:e.decrypted?"Message":"Ciphertext",color:e.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:e.decrypted?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm text-fg-primary",children:['"',e.text,'"']}),e.senderName&&t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",e.senderName]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),a}(e,s);case"grp_data":return function(e,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.channelHash]}),e.channelName&&t.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",e.channelName]})]})}),e.macHex&&a.push({id:"payload:mac",title:"MAC",color:"indigo",hex:s.slice(2,6),startByte:1,endByte:2,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.macHex.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.push({id:"payload:ciphertext",title:e.decrypted?"Decrypted Data":"Encrypted Data",color:e.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(e.decryptedHex||n).toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[e.dataLength," bytes",e.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),a}(e,s);case"path":return function(e,s){const a=[];if(a.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",children:e.pathLength}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[e.pathLength," hop",1!==e.pathLength?"s":""]})]})}),e.path.length>0){const n=s.slice(2,2+2*e.pathLength);a.push({id:"payload:path",title:"Path Hops",color:"amber",hex:n,startByte:1,endByte:e.pathLength,decoded:t.jsx(t.Fragment,{children:t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:e.path.map((e,s)=>t.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&t.jsx(xe,{className:"w-3 h-3 text-fg-muted"}),t.jsx(r,{color:"amber",className:"font-mono",children:e})]},s))})})})}if(null!=e.extraType){const n=1+e.pathLength;a.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:s.slice(2*n,2*n+2),startByte:n,endByte:n,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",children:e.extraTypeName??`0x${e.extraType.toString(16).padStart(2,"0")}`}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(e.extraData){const n=1+e.pathLength+1,l=s.slice(2*n);l&&a.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:l,startByte:n,endByte:n+l.length/2-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:l.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[l.length/2," bytes"]})]})})}return a}(e,s);case"trace":return function(e,s){const a=[];a.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:s.slice(0,8),startByte:0,endByte:3,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.traceTag]}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),a.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:s.slice(8,16),startByte:4,endByte:7,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.authCode}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),a.push({id:"payload:flags",title:"Flags",color:"amber",hex:s.slice(16,18),startByte:8,endByte:8,decoded:t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{size:"standard",copy:!0,children:["0x",e.flags.toString(16).toUpperCase().padStart(2,"0")]}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:0===e.flags?"No flags set":`Flags: ${e.flags.toString(2).padStart(8,"0")}b`})]})});const n=s.slice(18);return n&&a.push({id:"payload:path",title:"Target Path",color:"indigo",hex:n,startByte:9,endByte:9+n.length/2-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:e.pathHashes.map((s,a)=>{const n=e.snrValues[a],l=void 0!==n?Y(n):"zinc";return t.jsxs("span",{className:"flex items-center gap-1",children:[a>0&&t.jsx(xe,{className:"w-3 h-3 text-fg-muted"}),t.jsx(r,{color:"indigo",className:"font-mono",children:s}),void 0!==n&&t.jsxs(r,{color:l,className:"font-mono",children:[n>=0?"+":"",Number.isInteger(n)?n:n.toFixed(1),"dB"]})]},a)})}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[e.pathHashes.length," target ",1===e.pathHashes.length?"hop":"hops",e.snrValues.length>0&&` • ${e.snrValues.length} SNR ${1===e.snrValues.length?"value":"values"} collected`,e.isComplete&&" • ✓ Complete"]})]})}),a}(e,s);case"multipart":return function(e,s){const a=[];a.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:s.slice(0,4),startByte:0,endByte:1,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.messageId.toUpperCase()}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),a.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:s.slice(4,6),startByte:2,endByte:2,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.partNumber}),t.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),a.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:s.slice(6,8),startByte:3,endByte:3,decoded:t.jsxs(t.Fragment,{children:[t.jsx(Ve,{size:"standard",copy:!0,children:e.totalParts}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",e.partNumber+1," of ",e.totalParts]})]})});const n=s.slice(8);return n&&a.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}),a}(e,s);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:s,startByte:0,endByte:s.length/2-1,decoded:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:s.toUpperCase()}),t.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[s.length/2," bytes"]})]})}]}}(T,v.payloadHex),[T,v.payloadHex]),M="payload"===j||vs(j),F=a.useMemo(()=>{const e=[{id:"header",hex:v.headerHex,color:"red"},...v.transportCodesHex?[{id:"transportCodes",hex:v.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:v.pathLengthHex,color:"green"},...v.pathDataHex?[{id:"pathData",hex:v.pathDataHex,color:"amber"}]:[]];return M?[...e,...(s=B,s.map(e=>({id:e.id,hex:e.hex,color:e.color})))]:[...e,{id:"payload",hex:v.payloadHex,color:"cyan"}];var s},[v,M,B]);return t.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[(()=>{switch(T.type){case"advert":return t.jsx(Ls,{advert:T,timestamp:e.timestamp});case"grp_data":return t.jsx(Ds,{decoded:T,timestamp:e.timestamp});case"grp_txt":return t.jsx(zs,{decoded:T,timestamp:e.timestamp,isLoading:P,onDecrypted:x});case"ack":return t.jsx($s,{decoded:T,timestamp:e.timestamp});case"path":return t.jsx(Rs,{decoded:T,timestamp:e.timestamp});case"trace":return t.jsx(As,{decoded:T,timestamp:e.timestamp});case"txt_msg":return t.jsx(Es,{decoded:T,timestamp:e.timestamp});case"multipart":return t.jsx(Us,{decoded:T,timestamp:e.timestamp});case"generic":return H.payloadType===u.REQ||H.payloadType===u.RESPONSE||H.payloadType===u.ANON_REQ?t.jsx(Is,{decoded:T,timestamp:e.timestamp,payloadType:H.payloadType}):null;default:return null}})(),t.jsx(Bs,{rawHex:i,hexSegments:F,selectedSegment:j,onSegmentClick:N}),t.jsx(Qe,{children:t.jsx(Ge.div,{layout:!0,transition:Ss,className:"space-y-2 min-w-0",children:(()=>{var e,s,a,n;const l=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${v.headerHex.toUpperCase()}`,condition:!0,content:t.jsxs("table",{className:"w-full text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"type-micro text-fg-muted border-b border-edge-subtle font-sans",children:[t.jsx("th",{className:"py-1 font-medium",children:"Bits"}),t.jsx("th",{className:"py-1 font-medium",children:"Field"}),t.jsx("th",{className:"py-1 font-medium",children:"Value"}),t.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),t.jsx("tbody",{children:v.headerFields.map(e=>t.jsx(Ms,{...e},e.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:(null==(e=v.transportCodesHex)?void 0:e.toUpperCase())||"",condition:!!v.transportCodesHex,content:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),t.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",null==(s=v.transportCodesHex)?void 0:s.slice(0,4).toUpperCase()," | Code 2: 0x",null==(a=v.transportCodesHex)?void 0:a.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:v.transportCodesHex?5:1,endByte:v.transportCodesHex?5:1,hexBytes:`0x${v.pathLengthHex.toUpperCase()}`,condition:!0,content:t.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[H.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:v.transportCodesHex?6:2,endByte:(v.transportCodesHex?5:1)+H.pathLen,hexBytes:(null==(n=v.pathDataHex)?void 0:n.toUpperCase())||"",condition:H.pathLen>0,content:t.jsxs("div",{className:"space-y-3",children:[t.jsx(Vs,{pathHex:v.pathDataHex}),t.jsx("p",{className:"text-xs text-fg-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:v.payloadStartByte,endByte:c-1,hexBytes:v.payloadHex.toUpperCase(),condition:!0,content:t.jsxs(t.Fragment,{children:[!vs(j)&&t.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[t.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),t.jsx(Qs,{decoded:T,payloadType:H.payloadType})]}),!vs(j)&&B.length>0&&t.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),vs(j)&&t.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(e=>e.condition),i=vs(j)?B.find(e=>e.id===j):null,d=vs(j)?[...l].sort((e,s)=>"payload"===e.id?-1:"payload"===s.id?1:0):[...l].sort((e,s)=>e.id===j?-1:s.id===j?1:0),o=vs(j)?B.filter(e=>e.id!==j):[];return t.jsxs(t.Fragment,{children:[i&&t.jsx(Fs,{id:`subfield-${i.id}`,title:i.title,color:i.color,startByte:v.payloadStartByte+i.startByte,endByte:v.payloadStartByte+i.endByte,hexBytes:i.hex.toUpperCase(),isSelected:!0,children:i.decoded},i.id),d.map(e=>t.jsx(Fs,{id:`section-${e.id}`,title:e.title,color:e.color,startByte:e.startByte,endByte:e.endByte,hexBytes:e.hexBytes,isSelected:e.id===j,children:e.content},e.id)),o.map(e=>t.jsxs(Ge.div,{layout:"position",layoutId:`subfield-${e.id}`,transition:Ss,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:ks,boxShadow:Cs},children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[t.jsx(r,{color:e.color,children:e.title}),e.hex.length<=32&&Ns(e.hex).map((s,a)=>t.jsx(r,{color:e.color,className:"font-mono",children:s.toUpperCase()},a))]}),t.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",v.payloadStartByte+e.startByte,"-",v.payloadStartByte+e.endByte]})]}),t.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:e.decoded})]},e.id))]})})()})})]})});function Os(e){if(!e)return[];if(Array.isArray(e))return e;try{const s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{return[]}}function Ws(e){return e?(e.startsWith("0x")?e.slice(2):e).slice(0,2).toUpperCase():""}function qs({hop:s,compact:n=!1,index:l=0,highlightIndex:r=-1,isTrace:i=!1}){var c;const d=l===r,o=Oe();return a.useEffect(()=>{d&&i&&o.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[d,i,o]),t.jsxs(Ge.div,{className:e("flex items-center gap-1.5",n?"flex-row":"flex-col"),animate:{scale:d?1.05:1,opacity:d?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[t.jsxs(Ge.div,{className:e("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-sys-amber/20 text-sys-amber ring-1 ring-sys-amber/30":"bg-elevated/50 text-fg-primary ring-1 ring-edge-strong/50"),animate:o,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&t.jsx(Be,{className:"w-3 h-3"}),t.jsx("span",{children:s.prefix}),void 0!==s.confidence&&s.confidence<.9&&t.jsxs("span",{className:"text-[9px] opacity-70",children:[(100*s.confidence).toFixed(0),"%"]})]}),!n&&(null==(c=s.neighborInfo)?void 0:c.name)&&t.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function Ks({snr:e,sf:s}){const a=v(e,s),n=N()[a]||"#6b7280",l=Number.isInteger(e)?e.toString():e.toFixed(1);return t.jsxs(r,{customColor:n,compact:!0,className:"font-mono",children:[e>=0?"+":"",l,"dB"]})}function Xs({hops:s,compact:n,isTrace:l=!1,sf:r}){const[i,c]=a.useState(-1);return a.useEffect(()=>{if(0===s.length)return;const e=setTimeout(()=>{c(0)},400),t=setInterval(()=>{c(e=>{const a=e+1;return a>=s.length?(clearInterval(t),-1):a})},l?500:600);return()=>{clearTimeout(e),clearInterval(t)}},[s.length,l]),t.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((a,c)=>{const d=c%2==0,o=c===s.length-1;return t.jsxs("div",{className:"contents",children:[t.jsx("div",{className:e("flex items-center","justify-end"),children:d&&t.jsx(qs,{hop:a,compact:n,index:c,highlightIndex:i,isTrace:l})}),t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),void 0!==a.snr&&t.jsx(Ks,{snr:a.snr,sf:r}),t.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:t.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),t.jsx("div",{className:e("flex items-center","justify-start"),children:!d&&t.jsx(qs,{hop:a,compact:n,index:c,highlightIndex:i,isTrace:l})})]},`${a.prefix}-${c}`)})})}const Ys=a.memo(function({packet:s,neighbors:n,localHash:l,neighborAffinity:r,ghostPrefixes:i,direction:c="horizontal",compact:d=!1,traceSnr:o,overridePath:x}){const m=void 0!==o&&o.length>0,p=b(),h=Os(s.original_path),u=Os(s.forwarded_path),g=x??(u.length>0?u:h),f=Ws(l),y=a.useMemo(()=>g.map((e,s)=>{const t=e.toUpperCase(),a=t===f,l=(null==i?void 0:i.has(t))??!1,c=function(e,s,t){const a=e.toUpperCase();if(t){let e=null,n=0;if(t.forEach((s,t)=>{if(Ws(t)===a){const a=s.combinedScore??0;a>n&&(n=a,e=t)}}),e&&s[e])return{hash:e,info:s[e],confidence:n}}for(const[n,l]of Object.entries(s))if(Ws(n)===a)return{hash:n,info:l,confidence:void 0};return null}(t,n,r);return{prefix:t,fullHash:null==c?void 0:c.hash,neighborInfo:null==c?void 0:c.info,isLocal:a,isGhost:l,confidence:null==c?void 0:c.confidence,snr:null==o?void 0:o[s]}}),[g,n,r,f,i,o]);if(0===y.length)return t.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[t.jsx(he,{className:"w-4 h-4 opacity-50"}),t.jsx("span",{children:"Direct / No path data"})]});if("flowchart"===c)return t.jsx(Xs,{hops:y,compact:d,isTrace:m,sf:p});const j="horizontal"===c?xe:me;return t.jsx("div",{className:e("flex gap-1.5","horizontal"===c?"flex-row flex-wrap items-center":"flex-col items-start"),children:y.map((s,a)=>t.jsxs("div",{className:e("flex items-center gap-1.5","vertical"===c&&"flex-col"),children:[t.jsx(qs,{hop:s,compact:d}),a<y.length-1&&t.jsx(j,{className:"w-3 h-3 text-fg-muted flex-shrink-0"})]},`${s.prefix}-${a}`))})});function Js(e,s){if(null!=e)return"boolean"==typeof e?String(e):"number"==typeof e&&s?`${e} ${s}`:String(e)}const Zs=()=>"blue",et=[{fn:"id",group:"identity",fmt:"int",read:e=>Js(e.id),color:Zs},{fn:"packet_hash",group:"identity",fmt:"hex<sha256>",read:e=>e.packet_hash||void 0,color:Zs},{fn:"timestamp",group:"identity",fmt:"epoch<s>",read:e=>e.timestamp?String(e.timestamp):void 0,color:Zs,annotate:e=>e.timestamp>0?w(e.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum<payload_type>",read:e=>Js(e.type??e.payload_type),color:Zs},{fn:"route",group:"classification",fmt:"enum<route_type>",read:e=>Js(e.route??e.route_type),color:Zs},{fn:"rssi",group:"signal",fmt:"int<dBm>",read:e=>Js(e.rssi,"dBm"),color:Zs},{fn:"snr",group:"signal",fmt:"float<dB>",read:e=>Js(e.snr,"dB"),color:Zs},{fn:"path_length",group:"size",fmt:"int<hops>",read:e=>{if(null!=e.path_length)return 0===e.path_length?"zero-hop":`${e.path_length} hops`},color:Zs},{fn:"payload_length",group:"size",fmt:"int<B>",read:e=>Js(e.payload_length,"B"),color:Zs},{fn:"airtime",group:"size",fmt:"float<ms>",read:e=>Js(e.airtime_ms,"ms"),color:Zs},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:e=>e.src_hash??void 0,color:Zs},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:e=>e.dst_hash??void 0,color:Zs},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:e=>Array.isArray(e.path_hash)?`[${e.path_hash.join(", ")}]`:Js(e.path_hash),color:Zs,renderValue:e=>Array.isArray(e.path_hash)?st(e.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:e=>Js(e.score),color:Zs},{fn:"original_path",group:"paths",fmt:"hex[]",read:e=>Array.isArray(e.original_path)?`[${e.original_path.join(", ")}]`:void 0,color:Zs,renderValue:e=>Array.isArray(e.original_path)&&e.original_path.length>0?st(e.original_path,e.src_hash||void 0,e.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:e=>Array.isArray(e.forwarded_path)?`[${e.forwarded_path.join(", ")}]`:void 0,color:Zs,renderValue:e=>Array.isArray(e.forwarded_path)&&e.forwarded_path.length>0?st(e.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:e=>Js(e.transmitted),color:Zs},{fn:"is_duplicate",group:"status",fmt:"bool",read:e=>Js(e.is_duplicate),color:Zs},{fn:"drop_reason",group:"status",fmt:"string|null",read:e=>e.drop_reason??void 0,color:Zs},{fn:"tx_delay",group:"status",fmt:"int<ms>",read:e=>Js(e.tx_delay_ms,"ms"),color:Zs},{fn:"origin",group:"status",fmt:"enum<rx|tx_local|tx_forward>",read:e=>e.packet_origin??void 0,color:Zs},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:e=>null!=e.duplicates&&e.duplicates.length>0?`${e.duplicates.length}`:Js(e.duplicates),color:Zs},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:e=>Js(e.lbt_attempts),color:Zs},{fn:"lbt_backoff",group:"lbt",fmt:"json<float[]>",read:e=>Js(e.lbt_backoff_delays_ms),color:Zs},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:e=>Js(e.lbt_channel_busy),color:Zs}];function st(e,s,n,l){const r=e.length>0,i=s||l,c=n||l;return t.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&t.jsxs(t.Fragment,{children:[s?t.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:s}):t.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"}),(r||c)&&t.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),e.map((e,s)=>t.jsxs(a.Fragment,{children:[s>0&&t.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),t.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:e})]},s)),c&&t.jsxs(t.Fragment,{children:[r&&t.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),n?t.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:n}):t.jsx("span",{className:"inline-block border border-edge-subtle/50 rounded px-1.5 py-0.5 font-mono text-[11px] text-fg-muted/30",children:"XX"})]})]})}let tt=null;function at(e,s){var t;const a=function(){if(!tt){tt=new Map;for(const e of et)tt.set(e.fn,e)}return tt}().get(s);if(!a)return null;const n=a.read(e);if(void 0===n)return null;const l=a.color(e),r=null==(t=a.annotate)?void 0:t.call(a,e);return r?{text:n,color:l,annotation:r}:{text:n,color:l}}function nt(e){if(!e)return[];if(Array.isArray(e))return e;try{const s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{return[]}}function lt({packets:s,selectedIndex:a,onSelect:n,compact:l=!1}){if(s.length<=1)return null;const r=a>0,i=a<s.length-1;return t.jsxs("div",{className:e("flex items-center gap-1",l?"gap-0.5":"gap-1"),children:[t.jsx("button",{onClick:()=>r&&n(a-1),disabled:!r,className:e("p-0.5 radius-badge transition-base",r?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:t.jsx(Le,{className:l?"size-3":"size-4"})}),t.jsx("div",{className:"flex items-center gap-0.5",children:s.map((s,r)=>{const i=r===a,c=new Date(1e3*s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return t.jsx(F,{color:i?"cyan":"zinc",filled:i,compact:l,onClick:()=>n(r),title:`Observation ${r+1} at ${c}`,className:e("transition-all duration-150",!i&&"opacity-60 hover:opacity-100"),children:l?t.jsx("span",{className:"tabular-nums",children:r+1}):t.jsxs("span",{className:"tabular-nums text-xs",children:["#",r+1,null!=s.rssi&&t.jsx("span",{className:"ml-1 opacity-70",children:s.rssi})]})},`${s.timestamp}_${r}`)})}),t.jsx("button",{onClick:()=>i&&n(a+1),disabled:!i,className:e("p-0.5 radius-badge transition-base",i?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Next observation",children:t.jsx(pe,{className:l?"size-3":"size-4"})}),t.jsxs("span",{className:e("text-fg-muted ml-1",l?"text-[9px]":"text-xs"),children:[t.jsx(oe,{className:"inline size-3 mr-0.5 opacity-50"}),s.length]})]})}function rt({icon:s,label:a,disabled:n=!1}){return t.jsx(Ge.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:n?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:t.jsx("span",{className:e("flex items-center justify-center size-5 radius-badge border-control transition-base",n?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:s})})}function it({hasDuplicates:e,hasPrev:s,hasNext:a,canPrevDupe:n,canNextDupe:l}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx(rt,{icon:t.jsx(De,{className:"size-3"}),label:"Previous packet (↑)",disabled:!s}),t.jsx(rt,{icon:t.jsx(ze,{className:"size-3"}),label:"Next packet (↓)",disabled:!a})]}),e&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx(rt,{icon:t.jsx(Le,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),t.jsx(rt,{icon:t.jsx(pe,{className:"size-3"}),label:"Next observation (→)",disabled:!l})]})]})]})}const ct=a.memo(function({packets:e,initialIndex:s=0,onClose:n,onNavigatePrev:l,onNavigateNext:i,hasPrev:c=!1,hasNext:m=!1,resolveSource:p}){var h;const[g,f]=a.useState(s),y=e[g]??e[0],j=e.length>1,[b,N]=a.useState(null),[v,w]=a.useState(!1);a.useEffect(()=>{if(!y._stripped)return void N(null);let e=!1;w(!0);const s=y.packet_hash;if(s)return k(s).then(s=>{e||(s.success&&s.data&&(N(s.data),(s.data.type??s.data.payload_type)===u.GRP_TXT&&s.data.raw_packet&&C.getState().queueDecryption([s.data])),w(!1))}).catch(()=>{e||w(!1)}),()=>{e=!0};w(!1)},[y]);const F=b??y,L=g>0,D=g<e.length-1,z=a.useCallback(s=>{f(Math.max(0,Math.min(s,e.length-1)))},[e.length]);a.useEffect(()=>{const e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case"ArrowUp":e.preventDefault(),null==l||l();break;case"ArrowDown":e.preventDefault(),null==i||i();break;case"ArrowLeft":e.preventDefault(),L&&f(e=>e-1);break;case"ArrowRight":e.preventDefault(),D&&f(e=>e+1)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,i,L,D]);const R=_(),A=S(),E=P(),U=H(),I=a.useMemo(()=>new Set(U.map(e=>e.prefix.toUpperCase())),[U]),V=F.payload_type_name||d(F.payload_type??F.type),Q=F.route_type_name||o(F.route_type??F.route),G=F.payload_length??F.length??0,O=nt(F.original_path),W=nt(F.forwarded_path),q=O.length>0||W.length>0,Y=W.length>0?W:O,J=a.useMemo(()=>{var e;if(null==(e=null==R?void 0:R.config)?void 0:e.repeater)return{latitude:R.config.repeater.latitude,longitude:R.config.repeater.longitude,name:R.config.node_name||"Local Node"}},[R]),Z=(null==R?void 0:R.neighbors)??{},ee=E.size>0?E:void 0,se=F.raw_packet&&F.raw_packet.length>0,te=y._stripped&&v,ae=a.useMemo(()=>p?p(F):null,[p,F]),ne=T(F.packet_hash),ce=a.useMemo(()=>{if((F.payload_type??F.type)!==u.GRP_TXT)return null;if(!(null==ne?void 0:ne.decoded))return null;const e=ne.decoded;return{type:"grp_txt",channelHash:e.channelHash,channelName:e.channelName,text:e.text??"",decrypted:e.decrypted,senderName:e.senderName,timestamp:e.timestamp,flags:e.flags,macCorrupted:e.macCorrupted}},[F,ne]),de=a.useMemo(()=>$(F,ce),[F,ce]),oe="trace"===de.kind?de.data:null,xe="trace"===de.kind?de.snrValues:void 0,me="advert"===de.kind?de.data:null,pe="advert"===de.kind?de.sourceNode:void 0,ue="grp_txt"===de.kind?de.wardriveSourceNode??void 0:void 0,fe=e=>e&&0!==e?new Date(1e3*e).toLocaleString():"Unknown",ye=(F.payload_type??F.type)===u.ADVERT&&(void 0!==pe||q),je=void 0!==ue,be=pe??ue,Ne=X[V]??"zinc",we=x[Ne]||x.zinc;return t.jsxs(B,{open:!0,onClose:n,size:"5xl",motionPlus:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[t.jsxs("div",{className:"sm:hidden",children:[t.jsx("div",{className:"flex justify-center pt-2 pb-1",children:t.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),t.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(r,{color:X[V]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:V}),t.jsx(r,{color:K[Q]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:Q}),t.jsxs(r,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[G,"B"]})]}),t.jsx("button",{onClick:n,className:"px-3 py-1.5 text-[15px] font-medium text-sys-blue active:text-sys-blue/80 transition-base flex-shrink-0 radius-inner active:bg-subtle-fill",children:"Done"})]}),j&&t.jsx("div",{className:"px-3 pb-2",children:t.jsx(lt,{packets:e,selectedIndex:g,onSelect:z,compact:!0})})]}),t.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(r,{color:X[V]??"zinc",children:V}),t.jsx(r,{color:K[Q]??"zinc",children:Q}),t.jsxs(r,{color:"zinc",children:[G,"B"]}),j&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),t.jsx(lt,{packets:e,selectedIndex:g,onSelect:z})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(it,{hasDuplicates:j,hasPrev:c,hasNext:m,canPrevDupe:L,canNextDupe:D}),t.jsx("button",{onClick:n,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),t.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:we,opacity:.6}}),t.jsxs(M,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[t.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:t.jsxs("div",{className:"p-2 space-y-2",children:[(null!=F.rssi||null!=F.snr)&&t.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill",children:[t.jsx(We,{mode:"popLayout",initial:!1,children:t.jsxs(Ge.div,{className:"flex items-center gap-3",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[t.jsx(le,{rssi:F.rssi,snr:F.snr,compact:!0,showValues:!0,validated:re(F)}),t.jsx("span",{className:"text-[11px] text-fg-muted",children:ie(F.rssi)})]},g)}),Y.length>0&&t.jsxs("span",{className:"type-data-xs text-fg-muted",children:[Y.length," hop",1!==Y.length?"s":""]})]}),(q&&Y.length>0||ye||je)&&t.jsx("div",{className:"overflow-hidden radius-inset",children:t.jsx("div",{className:"aspect-[4/3] w-full",children:t.jsx(bs,{path:Y,neighbors:Z,localNode:J,localHash:null==R?void 0:R.local_hash,srcHash:F.src_hash,dstHash:F.dst_hash,neighborAffinity:ee,hubNodes:[...A],traceSnr:xe,advertiserSource:be})})}),oe&&oe.pathHashes.length>0&&t.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[t.jsx("div",{className:"px-3 py-2 space-y-1.5",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),t.jsx("div",{className:"flex items-center gap-1.5",children:t.jsx(r,{color:oe.isComplete?"green":"amber",compact:!0,children:oe.isComplete?"Complete":"In Progress"})})]})}),t.jsx(Ys,{packet:F,neighbors:Z,localHash:null==R?void 0:R.local_hash,neighborAffinity:ee,ghostPrefixes:I,direction:"flowchart",compact:!0,overridePath:oe.pathHashes,traceSnr:oe.snrValues})]}),q&&!oe&&t.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),t.jsxs(r,{color:"zinc",compact:!0,children:[Y.length," hop",1!==Y.length?"s":""]})]}),t.jsx(Ys,{packet:F,neighbors:Z,localHash:null==R?void 0:R.local_hash,neighborAffinity:ee,ghostPrefixes:I,direction:"flowchart",compact:!0,traceSnr:xe})]}),ae&&(ae.name||ae.hash)&&!me&&t.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),t.jsx(r,{color:ae.isRepeater?"blue":ae.isCompanion?"violet":"room_server"===ae.type?"lime":"zinc",compact:!0,children:"room_server"===ae.type?"room server":ae.type})]}),t.jsxs("div",{className:"p-3 space-y-1.5",children:[ae.name&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Me,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"type-label text-fg-primary truncate",children:ae.name}),!ae.confident&&t.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),ae.hash&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:[ae.hash.startsWith("0x")?ae.hash.slice(2,10):ae.hash.slice(0,8),"…"]})]})]})]}),me&&t.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),t.jsx(r,{color:"lime",compact:!0,children:me.nodeType})]}),t.jsxs("div",{className:"p-3 space-y-2",children:[me.name&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Me,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"type-label text-fg-primary truncate",children:me.name})]}),me.latitude&&me.longitude&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ge,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[me.latitude.toFixed(5),", ",me.longitude.toFixed(5)]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[me.publicKey.slice(0,16),"...",me.publicKey.slice(-8)]})]}),me.timestamp>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ve,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-xs text-fg-muted",children:fe(me.timestamp)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(he,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-xs text-fg-muted",children:me.flagsDescription||`Flags: 0x${me.flags.toString(16).padStart(2,"0")}`})]})]})]}),te?t.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:t.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):se?t.jsx("div",{className:"pt-1",children:t.jsx(Gs,{packet:F,decodedGrpTxt:ce})}):null]})}),t.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[t.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none p-4 border-r border-edge-subtle",children:te?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):se?t.jsx(Gs,{packet:F,decodedGrpTxt:ce}):null}),t.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[t.jsx("div",{className:"overflow-hidden p-2",children:q&&Y.length>0||ye||je?t.jsx("div",{className:"h-full w-full",children:t.jsx(bs,{path:Y,neighbors:Z,localNode:J,localHash:null==R?void 0:R.local_hash,srcHash:F.src_hash,dstHash:F.dst_hash,neighborAffinity:ee,hubNodes:[...A],traceSnr:xe,advertiserSource:be})}):t.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[t.jsx(he,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),t.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),t.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),t.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!oe&&Y.length<=1&&(null!=F.rssi||null!=F.snr)&&t.jsx("div",{className:"surface-base radius-inset p-4",children:t.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),t.jsx(We,{mode:"popLayout",initial:!1,children:t.jsxs(Ge.dd,{className:"flex items-center gap-2",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[t.jsx(le,{rssi:F.rssi,snr:F.snr,validated:re(F)}),t.jsx("span",{className:"font-medium text-fg-primary",children:ie(F.rssi)})]},g)})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),t.jsx(We,{mode:"popLayout",initial:!1,children:t.jsxs(Ge.dd,{className:"type-data text-fg-secondary",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[null==(h=at(F,"rssi"))?void 0:h.text,(()=>{const e=at(F,"snr");return e?` · ${e.text}`:null})()]},g)})]})]})}),ae&&(ae.name||ae.hash)&&!me&&t.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),t.jsx(r,{color:ae.isRepeater?"blue":ae.isCompanion?"violet":"room_server"===ae.type?"lime":"zinc",compact:!0,children:"room_server"===ae.type?"room server":ae.type})]}),t.jsxs("div",{className:"p-4 space-y-2",children:[ae.name&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Me,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"type-label text-fg-primary truncate",children:ae.name}),!ae.confident&&t.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),ae.hash&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[ae.hash.startsWith("0x")?ae.hash.slice(2,10):ae.hash.slice(0,8),"…"]})]})]})]}),me&&t.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),t.jsx(r,{color:"lime",compact:!0,children:me.nodeType})]}),t.jsxs("div",{className:"p-4 space-y-2.5",children:[me.name&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Me,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"type-label text-fg-primary truncate",children:me.name})]}),me.latitude&&me.longitude&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ge,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[me.latitude.toFixed(5),", ",me.longitude.toFixed(5)]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[me.publicKey.slice(0,16),"...",me.publicKey.slice(-8)]})]}),me.timestamp>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ve,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-xs text-fg-muted",children:fe(me.timestamp)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(he,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-[11px] text-fg-muted",children:me.flagsDescription||`Flags: 0x${me.flags.toString(16).padStart(2,"0")}`})]})]})]}),oe&&oe.pathHashes.length>0&&t.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(r,{color:oe.isComplete?"green":"amber",compact:!0,children:oe.isComplete?"Complete":"In Progress"}),t.jsxs(r,{color:"teal",compact:!0,children:[oe.pathHashes.length,"h"]})]})]}),t.jsx(Ys,{packet:F,neighbors:Z,localHash:null==R?void 0:R.local_hash,neighborAffinity:ee,ghostPrefixes:I,direction:"flowchart",compact:!0,overridePath:oe.pathHashes,traceSnr:oe.snrValues})]}),q&&!oe&&t.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),t.jsxs(r,{color:"zinc",compact:!0,children:[Y.length,"h"]})]}),t.jsx(Ys,{packet:F,neighbors:Z,localHash:null==R?void 0:R.local_hash,neighborAffinity:ee,ghostPrefixes:I,direction:"flowchart",compact:!0,traceSnr:xe})]})]})]})]})]})]})});function dt({label:e,numericValue:s,unit:a,icon:n,subtext:l,showSign:r=!1}){return t.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[t.jsx("div",{className:"mb-1.5 sm:mb-2",children:t.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:e})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{value:s,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:r?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),t.jsxs("div",{className:"flex flex-col items-center justify-center",children:[t.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),a&&t.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:a})]})]}),l&&t.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:l})]})}function ot({snr:s}){const a=s>=5?"bg-sys-teal":s>=0?"bg-sys-green":s>=-5?"bg-sys-amber":s>=-10?"bg-sys-orange":"bg-sys-red";return t.jsx("span",{className:e("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${s.toFixed(1)} dB`})}function xt({fromPrefix:s,toPrefix:a,fromName:n,toName:l,snr:i,maxSnr:c,isWeakest:d,isStrongest:o,index:x=0}){const m=Math.max(c+5,15),p=Math.max(0,Math.min(100,(i- -20)/(m- -20)*100)),h="bg-[#0074BE]",u=i>=5?"bg-sys-teal":i>=0?"bg-sys-green":i>=-5?"bg-sys-amber":i>=-10?"bg-sys-orange":"bg-sys-red",g=.3+.15*x;return t.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[t.jsx("span",{className:e("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",u)}),t.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:t.jsx(ot,{snr:i})}),t.jsxs("div",{className:"sm:hidden",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:n||s}),t.jsx(xe,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),t.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:l||a})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[d&&t.jsx(r,{color:"red",compact:!0,children:"Low"}),o&&!d&&t.jsxs(r,{color:"amber",compact:!0,children:[t.jsx(Ae,{className:"w-2.5 h-2.5"}),"Best"]}),t.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[12px] font-mono font-bold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),t.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:t.jsx(Ge.div,{className:e("h-full rounded-full",h),initial:{width:0},animate:{width:`${p}%`},transition:{duration:1.5,delay:g,ease:[.25,.1,.25,1]}})})]}),t.jsxs("div",{className:"hidden sm:block",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("code",{className:"type-data-xs text-fg-muted",children:s}),n&&t.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]}),t.jsx(xe,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[t.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),l&&t.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:l})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[d&&t.jsx(r,{color:"red",compact:!0,children:"Bottleneck"}),o&&!d&&t.jsxs(r,{color:"amber",compact:!0,children:[t.jsx(Ae,{className:"w-3 h-3"}),"Strongest"]}),t.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm font-mono font-semibold tabular-nums bg-subtle-fill-hover text-fg-primary ring-1 ring-inset ring-edge-subtle",children:[i>=0?"+":"−",Math.abs(i).toFixed(1)]})]})]}),t.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:t.jsx(Ge.div,{className:e("h-full rounded-full",h),initial:{width:0},animate:{width:`${p}%`},transition:{duration:1.5,delay:g,ease:[.25,.1,.25,1]}})})]})]})}function mt(e,s){if("You"===e)return"You";const t=e.toUpperCase();for(const[a,n]of Object.entries(s))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===t)return n.name||n.node_name||void 0}const pt=a.memo(function({report:e,onClose:s}){var a,n;const l=_(),i=(null==l?void 0:l.neighbors)??{},c=(null==(a=null==l?void 0:l.config)?void 0:a.repeater)?{latitude:l.config.repeater.latitude,longitude:l.config.repeater.longitude,name:l.config.node_name||"Local Node"}:void 0,d=null==(n=e.bestObservation)?void 0:n.decoded.snrValues,o=e.linkQuality?e.linkQuality.avgSnr>=5?"excellent":e.linkQuality.avgSnr>=0?"good":e.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",x={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[o];return t.jsxs(B,{open:!0,onClose:s,size:"5xl",motionPlus:!0,children:[t.jsxs("div",{className:"sm:hidden",children:[t.jsx("div",{className:"flex justify-center pt-2 pb-1",children:t.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),t.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[t.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),t.jsx("button",{onClick:s,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),t.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:x,opacity:.6}}),t.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[t.jsx("h2",{className:"type-micro",children:"Trace Report"}),t.jsxs(r,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",children:[t.jsx($e,{className:"w-3 h-3 mr-1"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]})]}),t.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:e.traceTag})]}),t.jsx("button",{onClick:s,className:"p-1.5 -m-1.5 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-elevated flex-shrink-0",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),t.jsxs("div",{className:"hidden sm:flex flex-wrap items-center gap-1.5 sm:gap-2 px-4 sm:px-6 pb-3 sm:pb-4 border-b border-edge-subtle",children:[t.jsxs(r,{color:"teal",children:[t.jsx("span",{className:"font-mono tabular-nums",children:e.targetHopCount}),t.jsxs("span",{className:"ml-1",children:["hop",1!==e.targetHopCount?"s":""]})]}),t.jsxs(r,{color:"zinc",children:[t.jsx("span",{className:"font-mono tabular-nums",children:e.observationCount}),t.jsx("span",{className:"ml-1",children:"obs"})]}),e.linkQuality&&t.jsxs(r,{color:"indigo",children:[t.jsx("span",{className:"font-mono tabular-nums",children:e.linkQuality.avgSnr.toFixed(1)}),t.jsx("span",{className:"ml-1",children:"dB avg"})]}),t.jsx("span",{className:"type-data-xs text-fg-muted",children:L(e.duration)}),e.linkQuality&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-fg-muted/40",children:"•"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-red/15 text-sys-red ring-1 ring-inset ring-sys-red/25",children:[t.jsx("span",{className:"opacity-70",children:"Min"}),t.jsx("span",{className:"font-mono tabular-nums",children:e.linkQuality.minSnr.toFixed(1)})]}),t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-sys-teal/15 text-sys-teal ring-1 ring-inset ring-sys-teal/25",children:[t.jsx("span",{className:"opacity-70",children:"Max"}),t.jsx("span",{className:"font-mono tabular-nums",children:e.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),t.jsxs(M,{className:"p-0 overflow-hidden",children:[t.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:t.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.linkQuality&&t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[t.jsx(qe,{value:Math.abs(e.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:e.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),t.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[t.jsx(ye,{className:"w-2.5 h-2.5 text-fg-muted"}),t.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),t.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[t.jsx(qe,{value:e.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),t.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[t.jsx(Re,{className:"w-2.5 h-2.5 text-fg-muted"}),t.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(r,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",compact:!0,children:[t.jsx($e,{className:"w-2.5 h-2.5 mr-0.5"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]}),t.jsxs(r,{color:"teal",compact:!0,children:[e.targetHopCount," hops"]}),t.jsxs(r,{color:"zinc",compact:!0,children:[e.observationCount," obs"]}),t.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:e.traceTag.slice(0,8)})]}),e.targetPath.length>0&&t.jsx("div",{className:"overflow-hidden radius-inset",children:t.jsx("div",{className:"aspect-[4/3] w-full",children:t.jsx(bs,{path:e.targetPath,neighbors:i,localNode:c,localHash:null==l?void 0:l.local_hash,srcHash:e.srcHash,dstHash:e.dstHash,traceSnr:d})})}),t.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[t.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),e.linkQuality&&t.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",e.linkQuality.minSnr.toFixed(1)," → ",e.linkQuality.maxSnr.toFixed(1)," dB"]})]}),e.bestObservation?t.jsx(Ys,{packet:e.bestObservation.packet,neighbors:i,localHash:null==l?void 0:l.local_hash,direction:"flowchart",compact:!0,overridePath:e.targetPath,traceSnr:e.bestObservation.decoded.snrValues}):t.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),t.jsxs("div",{children:[t.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",e.hopStats.length," hops"]}),t.jsx("div",{className:"space-y-1.5",children:e.hopStats.length>0?e.hopStats.map((s,a)=>{var n,l,r;const c=a<e.targetPath.length-1?e.targetPath[a+1]:"You",d=mt(s.prefix,i),o=mt(c,i);return t.jsx(xt,{fromPrefix:s.prefix,toPrefix:c,fromName:d,toName:o,snr:s.snr,maxSnr:(null==(n=e.linkQuality)?void 0:n.maxSnr)??10,isWeakest:(null==(l=e.linkQuality)?void 0:l.weakestLinkPosition)===a,isStrongest:(null==(r=e.linkQuality)?void 0:r.strongestLinkPosition)===a,index:a},`${s.prefix}-${a}`)}):t.jsx("div",{className:"text-xs text-fg-muted py-6 text-center",children:"No link data collected"})})]}),t.jsx("div",{className:"pt-1 pb-2 text-center",children:t.jsxs("span",{className:"text-xs text-fg-muted",children:["Traced ",w(e.firstSeen)]})})]})}),t.jsxs("div",{className:"hidden md:flex md:flex-row h-[70vh] max-h-[calc(100vh-200px)] overflow-hidden",children:[t.jsx("div",{className:"w-1/2 flex flex-col min-w-0 min-h-0 overflow-hidden border-r border-edge-subtle",children:t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[e.linkQuality&&(()=>{const s=e.targetPath[e.linkQuality.weakestLinkPosition],a=e.targetPath[e.linkQuality.weakestLinkPosition+1]||"You",n=mt(s,i),l=mt(a,i),r=e.targetPath[e.linkQuality.strongestLinkPosition],c=e.targetPath[e.linkQuality.strongestLinkPosition+1]||"You",d=mt(r,i),o=mt(c,i);return t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(dt,{label:"Weakest Link",numericValue:e.linkQuality.minSnr,unit:"dB",icon:ye,subtext:`${n||s} → ${l||a}`}),t.jsx(dt,{label:"Best Link",numericValue:e.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:Re,subtext:`${d||r} → ${o||c}`})]})})(),t.jsxs("div",{children:[t.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),t.jsx("div",{className:"space-y-2",children:e.hopStats.length>0?e.hopStats.map((s,a)=>{var n,l,r;const c=a<e.targetPath.length-1?e.targetPath[a+1]:"You",d=mt(s.prefix,i),o=mt(c,i);return t.jsx(xt,{fromPrefix:s.prefix,toPrefix:c,fromName:d,toName:o,snr:s.snr,maxSnr:(null==(n=e.linkQuality)?void 0:n.maxSnr)??10,isWeakest:(null==(l=e.linkQuality)?void 0:l.weakestLinkPosition)===a,isStrongest:(null==(r=e.linkQuality)?void 0:r.strongestLinkPosition)===a,index:a},`${s.prefix}-${a}`)}):t.jsx("div",{className:"text-xs text-fg-muted py-8 text-center",children:"No link data collected"})})]}),t.jsxs("div",{className:"pt-2 text-center",children:[t.jsx("span",{className:"text-xs text-fg-muted",children:"Traced "}),t.jsx("span",{className:"type-data-xs text-fg-muted",children:w(e.firstSeen)})]})]})}),t.jsxs("div",{className:"w-1/2 min-w-0 overflow-y-auto p-3 space-y-2",children:[e.targetPath.length>0&&t.jsx("div",{className:"overflow-hidden",children:t.jsx("div",{className:"aspect-square w-full",children:t.jsx(bs,{path:e.targetPath,neighbors:i,localNode:c,localHash:null==l?void 0:l.local_hash,srcHash:e.srcHash,dstHash:e.dstHash,traceSnr:d})})}),t.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[t.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(r,{color:e.isComplete?"green":"amber",compact:!0,children:e.isComplete?"Complete":`${e.maxHopsObserved}/${e.targetHopCount}`}),t.jsxs(r,{color:"teal",compact:!0,children:[e.targetHopCount," hop",1!==e.targetHopCount?"s":""]})]})]}),e.linkQuality&&e.bestObservation&&t.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[t.jsxs("span",{children:[t.jsx("span",{className:"opacity-60",children:"Tag"})," ",t.jsx("code",{className:"text-sys-teal tabular-nums",children:e.traceTag.slice(0,8)})]}),t.jsxs("span",{children:[t.jsx("span",{className:"opacity-60",children:"SNR"})," ",t.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[e.linkQuality.minSnr.toFixed(1),"–",e.linkQuality.maxSnr.toFixed(1)]}),t.jsx("span",{className:"opacity-60",children:" dB"})]})]}),e.bestObservation?t.jsx(Ys,{packet:e.bestObservation.packet,neighbors:i,localHash:null==l?void 0:l.local_hash,direction:"flowchart",compact:!0,overridePath:e.targetPath,traceSnr:e.bestObservation.decoded.snrValues}):t.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}),ht=[{target:"PacketList",fn:"type",minStage:1},{target:"PacketList",fn:"route",minStage:1},{target:"PacketList",fn:"rssi",minStage:1},{target:"PacketList",fn:"snr",minStage:1},{target:"PacketList",fn:"path",minStage:1,when:V},{target:"PacketList",fn:"src_hash",minStage:1,when:Q},{target:"PacketList",fn:"text",minStage:1,when:G},{target:"PacketList",fn:"ack",minStage:1,when:O},{target:"PacketList",fn:"decrypt",minStage:2,when:W},{target:"PacketList",fn:"duplicates",minStage:1}];I(ht);const ut="(min-width: 640px)";let gt=null;function ft(e){return"undefined"==typeof window?()=>{}:(gt||(gt=window.matchMedia(ut)),gt.addEventListener("change",e),()=>null==gt?void 0:gt.removeEventListener("change",e))}function yt(){return"undefined"==typeof window||(gt||(gt=window.matchMedia(ut)),gt.matches)}function jt(e){if(!e||e.length<6)return null;const s=e,t=parseInt(s.slice(0,2),16);if(isNaN(t))return null;const a=3&t;let n=2;if(0!==a&&3!==a||(n=10),n+2>s.length)return null;const l=parseInt(s.slice(n,n+2),16);if(isNaN(l))return null;if(n+=2+2*l,n>=s.length)return null;const r=s.slice(n);return r.length>=38?r.slice(0,38):r}function bt({message:e}){return t.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[t.jsx(he,{className:"size-6 text-fg-muted mb-2"}),t.jsx("p",{className:"text-sm text-fg-primary",children:e}),t.jsx("p",{className:"text-xs text-fg-muted",children:"Packets will appear here"})]})}function Nt(){return t.jsx("div",{className:"py-14 text-center text-sm text-fg-muted",children:"Loading packets…"})}function vt({showPagination:e,currentPage:s,perPage:a,displayCount:n,totalCount:l,action:r}){const i=e?(s-1)*a+1:1,c=e?Math.min(s*a,l):n;return t.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-edge-subtle px-4 py-3 text-xs text-fg-muted sm:px-6",children:[t.jsxs("span",{children:["Showing"," ",t.jsx("span",{className:"font-medium text-fg-secondary",children:e?`${i}–${c}`:n})," ","of"," ",t.jsx("span",{className:"font-medium text-fg-secondary",children:l})," ","packets"]}),r]})}function wt({packets:s,allPackets:l,localHash:r,neighbors:i,loading:c=!1,maxPackets:d,perPage:o=50,showPagination:x=!1,onPacketSelect:m,flashNewest:p=!1,emptyMessage:h="No packets found",className:u,footerAction:g,hideDupes:f=!1,getDecodedContent:y,onChannelClick:j,resolveSource:b,virtualized:N=!0}){U(ht);const[v,w]=a.useState(null),[k,C]=a.useState(null),[_,S]=a.useState({traceTag:null,dupeGroup:null}),P=a.useRef(null),H=Ke(e=>e.setModalMapOpen);a.useEffect(()=>(H(!!v),()=>H(!1)),[v,H]),a.useLayoutEffect(()=>{S({traceTag:null,dupeGroup:null})},[s]);const T=l??s,B=a.useMemo(()=>d&&d>0&&!f?s.slice(0,d):s,[s,d,f]),M=a.useMemo(()=>{if(!f)return null;const e=function(e){if(0===e.length)return[];const s=[];let t=0;for(;t<e.length;){const a=e[t],n=a.packet_hash;let l=1;if(n)for(;t+l<e.length&&e[t+l].packet_hash===n;)l++;s.push({packet:a,dupeCount:l}),t+=l}return s}(B),s=function(e){if(e.length<=1)return e;const s=new Map,t=new Map,a=new Map;for(let r=0;r<e.length;r++){const{packet:n}=e[r],l=n.payload_type??n.type;if(l!==D.GRP_TXT)continue;const i=n._payloadHexPrefix??jt(n.raw_packet);if(i){const e=s.get(i);if(void 0!==e){a.set(r,e);continue}s.set(i,r)}const c=`${l}:${n.payload_length??n.length??0}:${Math.floor((n.timestamp??0)/60)}`;if(!i){const e=t.get(c);if(void 0!==e){a.set(r,e);continue}}t.has(c)||t.set(c,r)}if(0===a.size)return e;const n=new Map;for(const[r,i]of a)n.set(i,(n.get(i)??0)+e[r].dupeCount);const l=[];for(let r=0;r<e.length;r++){if(a.has(r))continue;const s=n.get(r)??0;l.push(s>0?{packet:e[r].packet,dupeCount:e[r].dupeCount+s}:e[r])}return l}(e);return d&&d>0?s.slice(0,d):s},[B,f,d]),F=M?M.length:B.length,{currentPage:L,totalPages:z,goToPage:$,pageRange:I}=function(e,s,t){const[n,l]=a.useState(1),r=t?Math.ceil(e/s):1;a.useEffect(()=>{n>r&&r>0&&queueMicrotask(()=>l(1))},[r,n]);const i=a.useCallback(e=>l(Math.max(1,Math.min(e,r))),[r]),c=a.useMemo(()=>function(e,s,t=1){if(s<=7)return Array.from({length:s},(e,s)=>s+1);const a=Math.max(e-t,1),n=Math.min(e+t,s),l=a>2,r=n<s-1;if(!l&&r){const e=3+2*t;return[...Array.from({length:e},(e,s)=>s+1),"gap",s]}if(l&&!r){const e=3+2*t;return[1,"gap",...Array.from({length:e},(t,a)=>s-e+a+1)]}return[1,"gap",...Array.from({length:n-a+1},(e,s)=>a+s),"gap",s]}(n,r),[n,r]);return{currentPage:n,totalPages:r,goToPage:i,pageRange:c}}(F,o,x),V=a.useMemo(()=>{if(f)return B;if(!x)return B;const e=(L-1)*o;return B.slice(e,e+o)},[B,x,L,o,f]),Q=a.useMemo(()=>{if(!M)return null;if(!x)return M;const e=(L-1)*o;return M.slice(e,e+o)},[M,x,L,o]),G=a.useMemo(()=>function(e){const s=new Map;for(const t of e)if((t.payload_type??t.type)===D.TRACE&&t.packet_hash){const e=t._traceTag??(t.payload?R(t.payload):null);e&&s.set(t.packet_hash,e)}return s}(V),[V]),O=a.useMemo(()=>function(e){const s=new Map;if(0===e.length)return s;for(let t=0;t<e.length;t++){const a=e[t].packet_hash;if(!a)continue;const n=e[t-1],l=e[t+1],r=(null==n?void 0:n.packet_hash)===a,i=(null==l?void 0:l.packet_hash)===a;(r||i)&&(r&&i?s.set(t,"middle"):r?s.set(t,"last"):i&&s.set(t,"first"))}return s}(V),[V]),W=function(e,s){const[t,n]=a.useState(null),l=a.useRef(0);return a.useEffect(()=>{var t,a;if(!s||!e.length)return;const r=(null==(t=e[0])?void 0:t.timestamp)??0,i=r>l.current&&l.current>0;if(l.current=r,!i)return;const c=null==(a=e[0])?void 0:a.packet_hash;if(!c)return;const d=requestAnimationFrame(()=>n(c)),o=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(d),clearTimeout(o)}},[e,s]),t}(s,p),q=a.useSyncExternalStore(ft,yt,()=>!0),K=a.useMemo(()=>f&&Q?Q:V,[f,Q,V]),X=N&&K.length>100,Y=q?48:72,J=n({count:X?K.length:0,getScrollElement:()=>P.current,estimateSize:()=>Y,overscan:5}),Z=a.useCallback((e,s)=>{var t,a;const n=e.packet_hash;if(!n)return[e];let l=s;for(;l>0&&(null==(t=V[l-1])?void 0:t.packet_hash)===n;)l--;let r=s;for(;r<V.length-1&&(null==(a=V[r+1])?void 0:a.packet_hash)===n;)r++;return l===r?[e]:V.slice(l,r+1)},[V]),ee=a.useCallback(e=>{var s,t;const a=null==(s=V[e])?void 0:s.packet_hash;if(!a)return e;let n=e;for(;n>0&&(null==(t=V[n-1])?void 0:t.packet_hash)===a;)n--;return n},[V]),se=a.useCallback(e=>{var s,t;const a=null==(s=V[e])?void 0:s.packet_hash;if(!a)return e;let n=e;for(;n<V.length-1&&(null==(t=V[n+1])?void 0:t.packet_hash)===a;)n++;return n},[V]),te=a.useCallback((e,s)=>{if(m)m(e);else if(void 0!==s){const t=Z(e,s),a=t.indexOf(e);w({packets:t,initialIndex:a>=0?a:0,rowIndex:s})}else w({packets:[e],initialIndex:0,rowIndex:0})},[m,Z]),ae=a.useCallback(()=>{if(!v)return;const e=ee(v.rowIndex)-1;if(e<0)return;const s=V[e];if(!s)return;const t=Z(s,e);w({packets:t,initialIndex:0,rowIndex:e})},[v,V,ee,Z]),ne=a.useCallback(()=>{if(!v)return;const e=se(v.rowIndex)+1;if(e>=V.length)return;const s=V[e];if(!s)return;const t=Z(s,e);w({packets:t,initialIndex:0,rowIndex:e})},[v,V,se,Z]),le=a.useMemo(()=>!!v&&ee(v.rowIndex)>0,[v,ee]),re=a.useMemo(()=>!!v&&se(v.rowIndex)<V.length-1,[v,se,V.length]),ie=a.useCallback(e=>S(s=>({...s,traceTag:e})),[]),ce=a.useCallback(e=>S(s=>({...s,dupeGroup:e})),[]),de=a.useCallback(()=>{S({traceTag:null,dupeGroup:null})},[]),oe=a.useCallback(e=>{const s=T.filter(s=>(s.payload_type??s.type)===D.TRACE&&s.payload&&R(s.payload)===e);if(0===s.length)return;const t=A(s).get(e);(null==t?void 0:t.length)&&C(E(e,t))},[T]),xe=a.useCallback(e=>{const s=T.find(s=>s.packet_hash===e);s&&(C(null),te(s))},[T,te]),me=a.useCallback((e,s,a)=>{const n=q?hs:us;if(a){const{packet:a,dupeCount:l}=e,c=a.packet_hash?G.get(a.packet_hash):void 0,d=null!==_.traceTag&&c===_.traceTag;return t.jsx(n,{packet:a,onClick:e=>te(e,s),localHash:r,neighbors:i,resolveSource:b,isFlashing:p&&W===a.packet_hash,traceTag:c,isTraceHighlighted:d,onTraceHover:ie,onViewTraceReport:oe,dupeCount:l,getDecodedContent:y,onChannelClick:j},`${a.packet_hash}_${a.timestamp}_${s}`)}const l=e,c=l.packet_hash?G.get(l.packet_hash):void 0,d=null!==_.traceTag&&c===_.traceTag,o=O.get(s),x=void 0!==o&&null!==_.dupeGroup&&l.packet_hash===_.dupeGroup;return t.jsx(n,{packet:l,onClick:e=>te(e,s),localHash:r,neighbors:i,resolveSource:b,isFlashing:p&&W===l.packet_hash,traceTag:c,isTraceHighlighted:d,onTraceHover:ie,onViewTraceReport:oe,dupeGroupPosition:o,isDupeGroupHovered:x,onDupeGroupHover:ce,getDecodedContent:y,onChannelClick:j},`${l.packet_hash}_${l.timestamp}_${s}`)},[q,G,_.traceTag,_.dupeGroup,te,r,i,b,p,W,ie,oe,O,ce,y,j]);return t.jsxs("div",{className:e("flex flex-col",u),onMouseLeave:de,children:[X?t.jsx("div",{ref:P,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:600},children:(()=>{if(c&&0===s.length)return t.jsx(Nt,{});if(0===K.length)return t.jsx(bt,{message:h});const e=f&&null!==Q,a=J.getVirtualItems();return t.jsx("div",{style:{height:`${J.getTotalSize()}px`,width:"100%",position:"relative"},children:a.map(s=>{const a=K[s.index];return t.jsx("div",{"data-index":s.index,ref:J.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:me(a,s.index,e)},s.key)})})})()}):t.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:(()=>{if(c&&0===s.length)return t.jsx(Nt,{});if(0===V.length)return t.jsx(bt,{message:h});const e=f&&null!==Q;return(e?Q:V).map((s,t)=>me(s,t,e))})()}),x&&z>1&&t.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:t.jsxs(Xe,{className:"justify-center",children:[t.jsx(Ye,{onClick:()=>$(L-1),disabled:1===L}),t.jsx(Ze,{children:I.map((e,s)=>"gap"===e?t.jsx(ss,{},`gap-${s}`):t.jsx(es,{page:e,current:e===L,onClick:$},e))}),t.jsx(Je,{onClick:()=>$(L+1),disabled:L===z})]})}),t.jsx(vt,{showPagination:x,currentPage:L,perPage:o,displayCount:Q?Q.length:V.length,totalCount:x?F:s.length,action:g}),!m&&v&&t.jsx(ct,{packets:v.packets,initialIndex:v.initialIndex,onClose:()=>w(null),onNavigatePrev:ae,onNavigateNext:ne,hasPrev:le,hasNext:re,resolveSource:b}),k&&t.jsx(pt,{report:k,onClose:()=>C(null),onViewPacket:xe})]})}export{ds as C,wt as P,rs as g,ts as u};
|