const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-BxRhUmZr.js","assets/index-BOwCLZTK.js","assets/BasemapLayer-B-5TmAfZ.js","assets/useMapViewStore-DpXuD1iT.js","assets/index-2RIoVPos.js","assets/index-DH0lUVGm.css","assets/BasemapLayer-B1CfjdFi.css"])))=>i.map(i=>d[i]);
import{d as ye,bl as as,bm as Pt,bn as ns,bo as rs,j as e,c as R,B as nt,e as ls,r as h,E as rt,x as M,bp as Mt,bq as Bt,br as Lt,R as de,bs as Rt,bt as Ht,bu as Ft,bv as he,bw as Xe,a6 as Ee,_ as is,bx as cs,by as os,bz as ds,bA as xs,bB as ms,bC as hs,m as oe,af as re,F as us,D as ps,bD as fs,bE as le,bF as ht,bG as gs,bH as ys,bI as js,bJ as bs,bK as Ns,bL as vs,bM as Ze,bN as ws,ab as ks,K as Dt,bO as Cs,bP as _s,bQ as Ss,bR as Ts,ak as At,al as Et,A as qe,bS as Ps,am as Ms,bT as Bs,bU as lt}from"./index-BOwCLZTK.js";import{a as Ls,u as Rs}from"./circle-x-BJVhIbR2.js";import{p as Hs,d as Fs,e as It,g as Ds,b as As}from"./primitives-DEqdAn1G.js";import{u as Es,r as Is,a as zs,b as $s,c as Us,d as Os,i as Vs}from"./consumer-registry-CTjikLma.js";import{D as Pe,R as Ie,P as Me,g as Gs,C as xe}from"./badge-colors-DCbxcv7o.js";import{g as zt,e as _e,a as $t}from"./chat-utils-D21OFED5.js";import{A as ue,S as ze,i as $e,a as Qs,g as ut}from"./SignalIndicator-Calk-LyB.js";import{a as Ws,A as Ut}from"./arrow-up-BqsZCBBC.js";import{C as it}from"./chevron-right-DJVm4pVP.js";import{M as Ue}from"./map-pin-C2z_C0J3.js";import{C as qs}from"./circle-question-mark-XDnZ1ChV.js";import{T as Je}from"./triangle-alert-SO3tIa8w.js";import{D as X}from"./DataBox-BVnEv6Au.js";import{L as Ks}from"./layers-Dg2mpSl7.js";import{H as Ot}from"./hash-Dwn2PbMF.js";import{A as Ys}from"./activity-D5uH2SFx.js";import{C as Xs}from"./circle-check-CmQaOkab.js";import{D as Zs}from"./database-C6oOGn9y.js";import{H as Js,D as et,u as ea}from"./useMapViewStore-DpXuD1iT.js";import{S as we}from"./shield-DYw72pvS.js";import{C as Vt}from"./MqttModeBadge-CSj5wNzF.js";import{Z as pt}from"./zap-Bd-kARJ1.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ta=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],sa=ye("corner-down-right",ta);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const aa=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ct=ye("lock",aa);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const na=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gt=ye("message-circle-question-mark",na);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ra=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],la=ye("reply",ra);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ia=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],ca=ye("route",ia);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oa=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],ft=ye("stethoscope",oa);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const da=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],gt=ye("trophy",da);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xa=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ke=ye("user",xa);function ma(t){t.values.forEach(a=>a.stop())}function tt(t,a){[...a].reverse().forEach(n=>{const r=t.getVariant(n);r&&Pt(t,r),t.variantChildren&&t.variantChildren.forEach(i=>{tt(i,a)})})}function ha(t,a){if(Array.isArray(a))return tt(t,a);if(typeof a=="string")return tt(t,[a]);Pt(t,a)}function ua(){const t=new Set,a={subscribe(s){return t.add(s),()=>void t.delete(s)},start(s,n){const r=[];return t.forEach(i=>{r.push(as(i,s,{transitionOverride:n}))}),Promise.all(r)},set(s){return t.forEach(n=>{ha(n,s)})},stop(){t.forEach(s=>{ma(s)})},mount(){return()=>{a.stop()}}};return a}function pa(){const t=ns(ua);return rs(t.mount,[]),t}function fa({"aria-label":t="Page navigation",className:a,...s}){return e.jsx("nav",{"aria-label":t,...s,className:R("flex gap-x-2",a)})}function ga({onClick:t,disabled:a=!1,className:s,children:n="Previous"}){return e.jsx("span",{className:R("grow basis-0",s),children:e.jsxs(nt,{plain:!0,onClick:t,disabled:a,"aria-label":"Previous page",className:R("gap-1",a&&"invisible"),children:[e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2.75 8H13.25M2.75 8L5.25 5.5M2.75 8L5.25 10.5",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n]})})}function ya({onClick:t,disabled:a=!1,className:s,children:n="Next"}){return e.jsx("span",{className:R("flex grow basis-0 justify-end",s),children:e.jsxs(nt,{plain:!0,onClick:t,disabled:a,"aria-label":"Next page",className:R("gap-1",a&&"invisible"),children:[n,e.jsx("svg",{className:"size-4 stroke-current",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.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 ja({className:t,...a}){return e.jsx("span",{...a,className:R("hidden items-baseline gap-x-2 sm:flex",t)})}function ba({page:t,current:a=!1,onClick:s,className:n,children:r}){return e.jsx(nt,{plain:!a,outline:a,onClick:()=>s==null?void 0:s(t),"aria-label":`Page ${t}`,"aria-current":a?"page":void 0,className:R("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:r??t})}function Na({className:t,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:R("w-[2.25rem] select-none text-center text-sm text-fg-muted",t),children:"…"})}function va(t,a,s=1){if(a<=7)return Array.from({length:a},(m,g)=>g+1);const n=Math.max(t-s,1),r=Math.min(t+s,a),i=n>2,l=r<a-1;if(!i&&l){const m=3+2*s;return[...Array.from({length:m},(u,y)=>y+1),"gap",a]}if(i&&!l){const m=3+2*s;return[1,"gap",...Array.from({length:m},(u,y)=>a-m+y+1)]}return[1,"gap",...Array.from({length:r-n+1},(m,g)=>n+g),"gap",a]}const dr=ls(t=>({requestedHash:null,requestChannel:a=>t({requestedHash:a}),clearRequest:()=>t({requestedHash:null})}));function wa(t){if(t.length===0)return[];const a=[];let s=0;for(;s<t.length;){const n=t[s],r=n.packet_hash;let i=1,l=n;if(r)for(;s+i<t.length&&t[s+i].packet_hash===r;)t[s+i].packet_origin==="tx_local"&&(l=t[s+i]),i++;a.push({packet:l,dupeCount:i}),s+=i}return a}const ka={rx:{icon:Ut,label:"Rx",badgeColor:Pe.rx,avatarBg:"bg-sys-green/15",avatarText:"text-sys-green"},forward:{icon:ue,label:"Fwd",badgeColor:Pe.forward,avatarBg:"bg-sys-cyan/15",avatarText:"text-sys-cyan"},duplicate:{icon:rt,label:"Dupe",badgeColor:Pe.duplicate,avatarBg:"bg-fg-muted/15",avatarText:"text-fg-secondary"},tx:{icon:Ws,label:"Tx",badgeColor:Pe.tx,avatarBg:"bg-sys-indigo/15",avatarText:"text-sys-indigo"},dropped:{icon:sa,label:"Drop",badgeColor:Pe.dropped,avatarBg:"bg-sys-amber/15",avatarText:"text-sys-amber"}},yt={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Ca={sm:"w-8 h-8",md:"w-9 h-9",lg:"w-10 h-10"};function _a(t){return t.packet_origin==="tx_local"?"tx":t.packet_origin==="tx_forward"?"forward":t.is_duplicate?"duplicate":t.transmitted?"forward":t.drop_reason?"dropped":"rx"}function Sa({packet:t,showLabel:a=!0,variant:s="avatar",size:n="sm"}){const r=_a(t),i=ka[r],l=i.icon;return s==="avatar"?e.jsx("div",{className:R("flex items-center justify-center rounded-full flex-shrink-0",i.avatarBg,Ca[n]),children:e.jsx(l,{className:R(yt[n],i.avatarText)})}):e.jsxs(M,{color:i.badgeColor,children:[e.jsx(l,{className:yt[n]}),a&&i.label]})}const Qt=h.memo(Sa);function Ta({path:t,localHash:a,className:s}){if(!t||t.length===0)return e.jsx("span",{className:R("text-fg-muted text-xs",s),children:"—"});const n=a?(a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase():null;return e.jsx("span",{className:R("flex items-center gap-0.5 type-data-xs overflow-hidden",s),children:t.map((r,i)=>{const l=i===t.length-1,o=n&&r.toUpperCase()===n;return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[o?e.jsx("span",{className:"px-1 py-0.5 rounded bg-sys-amber/20 text-sys-amber text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill-hover text-fg-secondary",children:r.toUpperCase()}),!l&&e.jsx(it,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${r}-${i}`)})})}const Wt=h.memo(Ta);function qt({channelName:t,onClick:a,active:s,compact:n,className:r}){const i=t.startsWith("#")?t:`#${t}`,l=R("inline-flex items-center flex-shrink-0","font-medium",n?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",s?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!s&&"hover:bg-sys-blue/20 cursor-pointer",r);return a?e.jsx("button",{type:"button",onClick:a,className:l,children:i}):e.jsx("span",{className:l,children:i})}function Se(t){return{"--data-box-accent":he[t]}}function Kt(t){const a=t.payload_type_name||Ht(t.payload_type??t.type),s=t.route_type_name||Ft(t.route_type??t.route),n=Me[a]??"zinc",r=Ie[s]??"zinc";return{payloadType:a,routeType:s,payloadColor:n,routeColor:r}}function Oe(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function Yt(t,a){if(a){const s=a(t);return{name:s.name,isCompanion:s.isCompanion,isRepeater:s.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Pa({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,onTraceHover:o,traceTag:m,onViewTraceReport:g,dupeGroupPosition:u,isDupeGroupHovered:y=!1,onDupeGroupHover:w,dupeCount:j,getDecodedContent:x,onChannelClick:k}){const B=j?!1:Mt(t.is_duplicate),d=u!==void 0,{payloadType:b,routeType:f,payloadColor:_,routeColor:v}=Kt(t),p=t.packet_origin==="tx_local",E=b==="TRACE",O=Oe(t.original_path),G=Oe(t.forwarded_path),K=G.length>0?G:O,D=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:Y,isRepeater:I}=Yt(t,r);let H=null,$=null,U=null,J=null;if(b==="GRP_TXT"&&x){const S=x(t);S!=null&&S.decrypted&&($=S.senderName,U=S.channelName,J=S.channelHash,S.text&&(H=S.text))}else if(b==="TXT_MSG"&&t.raw_packet)try{const S=Bt.fromHex(t.raw_packet);if(S.success&&S.packet){const ce=Lt(S.packet.payload);ce&&!ce.encrypted&&(H=ce.text)}}catch{}const T=$||(I?null:Y),z=!!T,te=!z&&I&&!!Y,se=!z&&!te&&b==="GRP_TXT"&&!H,c=t.payload_length??t.length??0;t.lbt_attempts;const Z=h.useCallback(()=>{E&&m&&g?g(m):a(t)},[E,m,g,a,t]),q=h.useCallback(()=>{E&&m&&o&&o(m),d&&w&&t.packet_hash&&w(t.packet_hash)},[E,m,o,d,w,t.packet_hash]),ie=h.useCallback(()=>{o&&o(null),w&&w(null)},[o,w]),P=he[_]||he.zinc,F=y,ae=()=>{const S={pointerEvents:"none"};return u==="first"?{...S,borderTop:`2px solid ${P}`,borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:u==="middle"?{...S,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:u==="last"?{...S,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:`2px solid ${P}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...S,border:`2px solid ${P}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:Z,onMouseEnter:q,onMouseLeave:ie,className:R("group relative cursor-pointer","hover:bg-subtle-fill",B&&!y&&"opacity-40",i&&"flash-row",p&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:R("absolute pointer-events-none transition-opacity duration-75",d?F?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:ae()}),e.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:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"relative flex-shrink-0",children:z?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:zt(_e(T).cleanName)},children:_e(T).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(T).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$t(T)})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):se?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gt,{className:"size-4 text-fg-muted"})}):e.jsx(Qt,{packet:t,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:z?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:T}),D&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:D})]}):te?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:Y}),D&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:D})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:D||"—"}),Y&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:Y})]})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 min-[600px]:gap-1.5 min-[900px]:gap-2 min-w-0",children:[e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se(_),children:b}),p&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se("indigo"),children:"LOCAL"}),j&&j>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",j]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se(v),children:f}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[c,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:H||U?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[U&&e.jsx(qt,{channelName:U,compact:!0,onClick:k&&J?S=>{S.stopPropagation(),k(J)}:void 0}),H&&e.jsx("span",{className:"italic truncate",children:H})]}):e.jsx(Wt,{path:K,localHash:s})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:Rt(t.timestamp)}),e.jsx(ze,{rssi:t.rssi,snr:t.snr,compact:!0,showValues:!0,validated:$e(t)})]})]})]})}function Ma({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,traceTag:o,onViewTraceReport:m,dupeGroupPosition:g,isDupeGroupHovered:u=!1,onDupeGroupHover:y,dupeCount:w,getDecodedContent:j,onChannelClick:x}){const{payloadType:k,routeType:B,payloadColor:d,routeColor:b}=Kt(t),f=t.packet_origin==="tx_local",_=k==="TRACE",v=w?!1:Mt(t.is_duplicate),p=Oe(t.original_path),E=Oe(t.forwarded_path),O=E.length>0?E:p,G=t._hopCount??O.length,K=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:D,isRepeater:Y}=Yt(t,r);let I=null,H=null,$=null,U=null;if(k==="GRP_TXT"&&j){const P=j(t);P!=null&&P.decrypted&&(H=P.senderName,$=P.channelName,U=P.channelHash,P.text&&(I=P.text))}else if(k==="TXT_MSG"&&t.raw_packet)try{const P=Bt.fromHex(t.raw_packet);if(P.success&&P.packet){const F=Lt(P.packet.payload);F&&!F.encrypted&&(I=F.text)}}catch{}const J=H||(Y?null:D),T=!!J,z=!T&&Y&&!!D,te=!T&&!z&&k==="GRP_TXT"&&!I,se=t.payload_length??t.length??0,c=t.lbt_attempts??0,Z=()=>{_&&o&&m?m(o):a(t)},q=he[d]||he.zinc,ie=()=>{if(!g)return{opacity:0};const P=u?1:.4,F=u?"3px":"2px";return g==="first"?{backgroundColor:q,opacity:P,width:F,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:g==="middle"?{backgroundColor:q,opacity:P,width:F,top:0,bottom:0,borderRadius:0}:g==="last"?{backgroundColor:q,opacity:P,width:F,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:q,opacity:P,width:F,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:Z,className:R("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",v&&"opacity-40",i&&"flash-row",f&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:ie()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:T?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:zt(_e(J).cleanName)},children:_e(J).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(J).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:$t(J)})}):z?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center bg-zinc-500/20 ring-1 ring-edge-subtle",children:e.jsx(Gt,{className:"size-4 text-fg-muted"})}):e.jsx(Qt,{packet:t,variant:"avatar",size:"sm"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[T?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:J}):z?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:D}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:K||"—"}),D&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:D})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se(d),children:k}),f&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se("indigo"),children:"LOCAL"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Se(b),children:B}),w&&w>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",w]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted w-[28px] text-right",children:t.rssi}),e.jsx(ze,{rssi:t.rssi,compact:!0,showValues:!1,validated:$e(t)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-fg-muted",children:[e.jsx("span",{className:"data-box data-box-compact flex-shrink-0",children:Rt(t.timestamp)}),se>0&&e.jsxs("span",{children:[se,"B"]}),c>0&&e.jsxs("span",{className:c>1?"text-sys-amber/60":void 0,children:["LBT:",c]}),t.snr!=null&&e.jsxs("span",{children:[t.snr.toFixed(0),"dB"]}),I||$?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[$&&e.jsx(qt,{channelName:$,compact:!0,onClick:x&&U?P=>{P.stopPropagation(),x(U)}:void 0}),I&&e.jsx("span",{className:"italic truncate",children:I})]}):G>0?e.jsx(Wt,{path:O,localHash:s}):null]})]})]})]})}const Ba=h.memo(Pa),La=h.memo(Ma);function Ra(t,a,s,n,r=!1){const i=t.toUpperCase(),l=[],o=s&&Xe(i,s);o&&l.push(s);for(const j of Object.keys(a))Xe(i,j)&&l.push(j);if(r&&o&&s&&l.length===1)return{matches:l,probability:1,bestMatch:s};if(r&&o&&l.length>1){const j=l.filter(x=>x!==s);if(j.length===1)return{matches:l,probability:1,bestMatch:j[0]}}const m=l.length>0?1/l.length:0,g=[...l].sort();let u=null,y=-1;if(g.length===1)u=g[0];else if(g.length>1&&n){for(const j of g){const x=n.get(j),k=x?typeof x=="number"?x:x.combinedScore:0;k>y&&(y=k,u=j)}u||(u=g[0])}else g.length>0&&(u=g[0]);let w=m;if(l.length>1&&n&&y>0){let j=0;for(const x of l){const k=n.get(x);j+=k?typeof k=="number"?k:k.combinedScore:0}j>0&&(w=Math.min(.95,y/j))}return{matches:l,probability:w,bestMatch:u}}function Ha(t,a,s,n){const i=(s-t)*Math.PI/180,l=(n-a)*Math.PI/180,o=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 6371e3*(2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)))}function Fa(t){return t<100?1:t<500?.9:t<1e3?.7:t<5e3?.5:t<1e4?.3:.1}const Da=h.lazy(()=>is(()=>import("./PathMapMapLibre-BxRhUmZr.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function Aa(t,a,s,n,r=!1,i,l,o){const m=cs(a);let g;l&&(g=os(l,t,{position:o,isLastHop:r}).confidence);const{matches:u,probability:y}=Ra(t,m,n,i,r),w=u.length,j=[],x=t.toUpperCase(),k=s&&s.latitude!==void 0&&s.longitude!==void 0&&(s.latitude!==0||s.longitude!==0);for(const d of u){if(n&&Xe(x,n)&&d===n&&k&&s){j.push({hash:d,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:r?1:y,isLocal:!0});continue}const b=m[d];b!=null&&b.latitude&&(b!=null&&b.longitude)&&!(b.latitude===0&&b.longitude===0)&&j.push({hash:d,name:b.node_name||b.name||"Unknown",latitude:b.latitude,longitude:b.longitude,probability:y,isLocal:!1,isDirectNeighbor:b.zero_hop===!0})}const B=j.length;if(B===1)j[0].probability=g??1;else if(B>1)if(g!==void 0&&g>0){const d=j[0];d.probability=g;const b=1-g,f=B-1;j.slice(1).forEach(_=>{_.probability=b/f})}else{let d=0;const b=j.map(f=>{if(f.isLocal)return{candidate:f,score:1};const _=i==null?void 0:i.get(f.hash);let v=.5;if(k&&s){const E=Ha(s.latitude,s.longitude,f.latitude,f.longitude);v=Fa(E)}let p;return _?p=v*.3+_.hopConsistencyScore*.3+_.frequencyScore*.4:(p=v,f.isDirectNeighbor&&(p=Math.max(p,.8))),d+=p,{candidate:f,score:p}});if(d>0)b.forEach(({candidate:f,score:_})=>{f.probability=Math.min(.95,_/d)});else{const f=1/B;j.forEach(_=>_.probability=f)}}return{candidates:j,totalMatches:w}}function Ea(t,a,s,n,r,i){if(!t||t.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=t.length-1,o=t.map((u,y)=>{const w=y===l,j=t.length-y,{candidates:x,totalMatches:k}=Aa(u,a,s,n,w,r,i,j),B=x.length>0?Math.max(...x.map(d=>d.probability)):0;return{prefix:u,candidates:x,confidence:B,totalMatches:k}}),m=o.reduce((u,y)=>y.confidence===0?0:u*y.confidence,1),g=o.some(u=>u.candidates.length>0);return{hops:o,overallConfidence:m,hasValidPath:g}}function Ia(t){return`${(t*100).toFixed(0)}%`}function za(t){return t>=1?"text-sys-green":t>=.5?"text-sys-indigo":t>=.25?"text-signal-poor":t>0?"text-sys-red":"text-fg-muted"}function $a(t,a,s){let n;return a===0?n=s.muted:t>=1?n=s.success:t>=.5?n=s.secondary:t>=.25?n=s.poor:t>0?n=s.danger:n=s.muted,{color:n}}class Ua extends h.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"h-[200px] flex items-center justify-center text-fg-muted",children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Ve({path:t,neighbors:a,localNode:s,localHash:n,srcHash:r,dstHash:i,neighborAffinity:l,prefixLookup:o,hubNodes:m,traceSnr:g,advertiserSource:u}){const[y,w]=h.useState(null),j=h.useMemo(()=>{if(!u)return null;const f=u.nodeType==="wardrive";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:f}],confidence:1,totalMatches:1,isSource:!0}},[u]),x=h.useMemo(()=>{if(u||!r)return null;const f=Ee(r),_=a[r];if((_==null?void 0:_.latitude)&&(_==null?void 0:_.longitude)&&!(_.latitude===0&&_.longitude===0))return{prefix:f,candidates:[{hash:r,name:_.node_name||_.name||"Source",latitude:_.latitude,longitude:_.longitude,probability:1,isLocal:!1,isDirectNeighbor:_.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const p=(_==null?void 0:_.node_name)||(_==null?void 0:_.name)||r.slice(0,8);return{prefix:f,candidates:[{hash:r,name:p,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[u,r,a]),k=h.useMemo(()=>{const f=i!=null&&i.startsWith("0x")?i.slice(2):i;if((!f||f==="00"||f==="0000000000000000")&&s&&n){const G=Ee(n),K=s.latitude!==0||s.longitude!==0;return{prefix:G,candidates:[{hash:n,name:s.name||"Local Node",latitude:K?s.latitude:0,longitude:K?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!i)return null;const v=Ee(i);if(n&&i===n&&s){const G=s.latitude!==0||s.longitude!==0;return{prefix:v,candidates:[{hash:i,name:s.name||"Local Node",latitude:G?s.latitude:0,longitude:G?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const p=a[i];if((p==null?void 0:p.latitude)&&(p==null?void 0:p.longitude)&&!(p.latitude===0&&p.longitude===0))return{prefix:v,candidates:[{hash:i,name:p.node_name||p.name||"Destination",latitude:p.latitude,longitude:p.longitude,probability:1,isLocal:!1,isDirectNeighbor:p.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const O=(p==null?void 0:p.node_name)||(p==null?void 0:p.name)||i.slice(0,8);return{prefix:v,candidates:[{hash:i,name:O,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,s,n]),B=h.useMemo(()=>Ea(t,a,s,n,l,o),[t,a,s,n,l,o]),d=h.useMemo(()=>{const f=[];j?f.push(j):x&&f.push(x),f.push(...B.hops),k&&f.push(k);const _=f.reduce((p,E)=>E.confidence===0?0:p*E.confidence,1),v=f.some(p=>p.candidates.some(E=>E.latitude!==0||E.longitude!==0));return{hops:f,overallConfidence:_,hasValidPath:v}},[j,x,B,k]),b=h.useMemo(()=>{const f=getComputedStyle(document.documentElement);return{success:f.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:f.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:f.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:f.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:f.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return d.hasValidPath?e.jsxs("div",{className:"h-full flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-muted",children:"Path Confidence:"}),e.jsx("span",{className:za(d.overallConfidence),children:Ia(d.overallConfidence)}),e.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:e.jsx(qs,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-green"}),e.jsx("span",{className:"text-fg-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-sys-indigo"}),e.jsx("span",{className:"text-fg-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-fg-muted"}),e.jsx("span",{className:"text-fg-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Ua,{children:e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"h-full bg-elevated flex items-center justify-center text-fg-muted text-sm",children:"Loading map..."}),children:e.jsx(Da,{resolvedPath:d,localNode:s,hubNodes:m,hoveredHopIndex:y,onHoverHop:w,traceSnr:g})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:d.hops.map((f,_)=>{var G,K,D;const v=f.isSource===!0,p=f.isDestination===!0,E=y===_;let O;return v?O=`Source: ${((G=f.candidates[0])==null?void 0:G.name)||"Unknown"}`:p?O=`Destination: ${((K=f.candidates[0])==null?void 0:K.name)||"Unknown"}`:f.totalMatches===0?O="No matching nodes found":f.totalMatches===1?O=`Exact match: ${((D=f.candidates[0])==null?void 0:D.name)||"Unknown"}`:O=`${f.totalMatches} possible matches (${(f.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:R("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",E?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",v&&"border border-sys-green/30",p&&"border border-sys-blue/30"),title:O,onMouseEnter:()=>w(_),onMouseLeave:()=>w(null),children:[v&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),p&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:$a(f.confidence,f.totalMatches,b),children:f.prefix}),!v&&!p&&f.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",f.totalMatches]}),!v&&!p&&f.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},_)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ke=16;function Ge(t){return t.match(/.{1,2}/g)||[]}function je(t){return t!==null&&t.startsWith("payload:")}const Te={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:`
    var(--depth-stroke-tl),
    var(--depth-stroke-br)
  `,selectionBorderWidth:2},st={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function Oa(t,a){return t?`inset 0 0 0 ${Te.selectionBorderWidth}px ${he[a]}`:Te.cardRestShadow}function Va(t,a){return t?a:`color-mix(in srgb, ${a} ${Te.hexRestOpacity}%, transparent)`}function Ga({segments:t,selectedSegment:a,onSegmentClick:s}){const[n,r]=h.useState(null),[i,l]=h.useState(null),o=t.some(u=>u.id!==void 0)&&s,m=[];for(const u of t){const y=Ge(u.hex);for(const w of y)m.push({byte:w.toUpperCase(),color:u.color,id:u.id})}const g=[];for(let u=0;u<m.length;u+=Ke)g.push(m.slice(u,u+Ke));return e.jsx("div",{className:"space-y-1",children:g.map((u,y)=>{const w=u.length<Ke;return e.jsx("div",{className:"flex rounded-md overflow-hidden",children:u.map(({byte:j,color:x,id:k},B)=>{const d=B===u.length-1,b=w&&d,f=he[x],p=(k?n===k:i===x)||!!(k&&a===k);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${o?"cursor-pointer":""}`,style:{backgroundColor:Va(p,f),color:p?"rgba(255,255,255,0.95)":f,transition:p?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...b?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{k?r(k):l(x)},onMouseLeave:()=>{r(null),l(null)},onClick:()=>k&&(s==null?void 0:s(k)),onTouchStart:()=>{k?r(k):l(x)},onTouchEnd:()=>{r(null),l(null)},children:j},B)})},y)})})}function Qa({rawHex:t,hexSegments:a,selectedSegment:s,onSegmentClick:n}){const[r,i]=h.useState(!1),l=h.useCallback(async()=>{await us(t.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)},[t]);return e.jsxs("div",{className:"bg-inset radius-inner p-6 relative depth-stroke-inset",children:[e.jsx(Ga,{segments:a,selectedSegment:s,onSegmentClick:n}),e.jsx("button",{onClick:l,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?e.jsxs(e.Fragment,{children:[e.jsx(ps,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"text-sys-green",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function Wa(t,a){const s=[];let n=0;const r=a.slice(0,64);s.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:r,startByte:n,endByte:n+31,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const i=a.slice(64,72);s.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:i,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:i.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.timestamp," (",le(t.timestamp),")"]})]})}),n+=4;const l=a.slice(72,200);s.push({id:"payload:signature",title:"Signature",color:"teal",hex:l,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const o=a.slice(200,202);if(s.push({id:"payload:flags",title:"Flags",color:"blue",hex:o,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",t.nodeType]})]})}),n+=1,t.latitude!==void 0){const m=a.slice(n*2,n*2+8);s.push({id:"payload:latitude",title:"Latitude",color:"green",hex:m,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:m.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),n+=4}if(t.longitude!==void 0){const m=a.slice(n*2,n*2+8);s.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:m,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:m.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),n+=4}if(t.name){const m=a.slice(n*2),g=m.length/2;s.push({id:"payload:name",title:"Name",color:"amber",hex:m,startByte:n,endByte:n+g-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:m.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',t.name,'"']})]})})}return s}function qa(t,a){return[{id:"payload:crc",title:"CRC",color:"green",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function Ka(t,a){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Message":"Ciphertext",color:t.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:t.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",t.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),s}function Ya(t,a){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:a.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Decrypted Data":"Encrypted Data",color:t.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:(t.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),s}function Xa(t,a){const s=[];if(s.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:a.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.pathLength}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathLength," hop",t.pathLength!==1?"s":""]})]})}),t.path.length>0){const n=a.slice(2,2+t.pathLength*2);s.push({id:"payload:path",title:"Path Hops",color:"amber",hex:n,startByte:1,endByte:t.pathLength,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((r,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(ue,{className:"w-3 h-3 text-fg-muted"}),e.jsx(M,{color:"amber",className:"font-mono",children:r})]},i))})})})}if(t.extraType!=null){const n=1+t.pathLength;s.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:a.slice(n*2,n*2+2),startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.extraTypeName??`0x${t.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(t.extraData){const n=1+t.pathLength+1,r=a.slice(n*2);r&&s.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:r,startByte:n,endByte:n+r.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[r.length/2," bytes"]})]})})}return s}function Za(t,a){const s=[];s.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:a.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),s.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:a.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),s.push({id:"payload:flags",title:"Flags",color:"amber",hex:a.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:t.flags===0?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const n=a.slice(18);return n&&s.push({id:"payload:path",title:"Target Path",color:"indigo",hex:n,startByte:9,endByte:9+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.pathHashes.map((r,i)=>{const l=t.snrValues[i],o=l!==void 0?Gs(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(ue,{className:"w-3 h-3 text-fg-muted"}),e.jsx(M,{color:"indigo",className:"font-mono",children:r}),l!==void 0&&e.jsxs(M,{color:o,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},i)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathHashes.length," target ",t.pathHashes.length===1?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${t.snrValues.length===1?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})}),s}function Ja(t,a){const s=[];s.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:a.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),s.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:a.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),s.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:a.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const n=a.slice(8);return n&&s.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[n.length/2," bytes"]})]})}),s}function en(t,a){switch(t.type){case"advert":return Wa(t,a);case"ack":return qa(t,a);case"grp_txt":return Ka(t,a);case"grp_data":return Ya(t,a);case"path":return Xa(t,a);case"trace":return Za(t,a);case"multipart":return Ja(t,a);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:a,startByte:0,endByte:a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-fg-secondary break-all p-2 rounded bg-body/50 font-mono",children:a.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[a.length/2," bytes"]})]})}]}}function tn(t){return t.map(a=>({id:a.id,hex:a.hex,color:a.color}))}function sn({bits:t,field:a,value:s,binary:n}){const r=()=>{if(a==="Payload Type"){const i=Me[s]||"zinc";return e.jsx(M,{color:i,children:s})}if(a==="Route Type"){const i=Ie[s]||"zinc";return e.jsx(M,{color:i,children:s})}return e.jsx("span",{className:"text-sm text-fg-primary",children:s})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:a}),e.jsx("td",{className:"py-1.5",children:r()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function jt({id:t,title:a,color:s,hexBytes:n,startByte:r,endByte:i,isSelected:l,children:o}){const m=n?Ge(n):[];return e.jsxs(oe.div,{layout:"position",layoutId:t,transition:st,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:Oa(l,s)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(M,{color:s,children:a}),m.length>0&&m.length<=16&&m.map((g,u)=>e.jsx(M,{color:s,className:"font-mono",children:g.toUpperCase()},u))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",r,"-",i]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:o})]})}function an({advert:t,timestamp:a}){const s=a?le(a):le(t.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-indigo/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(de,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.latitude!==void 0&&t.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ue,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function nn({decoded:t,timestamp:a}){const s=a?le(a):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-teal/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(Zs,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Channel: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.decrypted&&t.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(X,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function rn({decoded:t,timestamp:a,isLoading:s=!1,onDecrypted:n}){const r=a?le(a):"Unknown",[i,l]=h.useState(""),[o,m]=h.useState(!1),[g,u]=h.useState(null),[y,w]=h.useState(!1),j=h.useCallback(async()=>{if(!(!i.trim()||!t.ciphertextHex||!t.macHex)){m(!0),u(null);try{const x=parseInt(t.channelHash,16),k=ht(t.macHex),B=ht(t.ciphertextHex),d=await gs(i.trim(),x,k,B);if(d.success){const b=d.result.plaintext,f=new TextDecoder("utf-8",{fatal:!1}).decode(b.slice(5)),_=f.indexOf(": "),v={...t,channelName:d.result.channelName,decrypted:!0,timestamp:b[0]|b[1]<<8|b[2]<<16|b[3]<<24,flags:b[4],senderName:_>0?f.slice(0,_):void 0,text:_>0?f.slice(_+2):f};n==null||n(v),l(""),w(!1)}else u(d.error)}catch(x){u(x instanceof Error?x.message:"Unknown error")}finally{m(!1)}}},[i,t,n]);return s?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:`
              inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 3%, transparent),
              0 1px 2px color-mix(in srgb, black 5%, transparent)
            `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 h-[15px]",children:[e.jsx("div",{className:"h-2.5 w-12 rounded bg-subtle-fill-hover animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-subtle-fill-hover animate-pulse"})]}),e.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:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3.5 w-48 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-subtle-fill-strong animate-pulse"})]})})]})}):t.decrypted?e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-xl p-4 sm:p-5",style:{backgroundColor:"color-mix(in srgb, var(--elevated) 60%, var(--body))",boxShadow:`
              inset 0 0 0 1px color-mix(in srgb, var(--fg-primary) 6%, transparent),
              inset 0 1px 0 color-mix(in srgb, white 3%, transparent),
              0 1px 2px color-mix(in srgb, black 5%, transparent)
            `},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:t.channelName})]})]}),e.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:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}):e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-zinc-500/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(ct,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:t.isPublicHashChannel?"Public Hash Channel":"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Channel hash: ",e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),t.ciphertextHex&&t.macHex&&e.jsx("div",{className:"space-y-2",children:y?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:x=>l(x.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:x=>x.key==="Enter"&&j(),disabled:o}),e.jsx("button",{onClick:j,disabled:o||!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:o?"Testing...":"Try"}),e.jsx("button",{onClick:()=>{w(!1),u(null),l("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),g&&e.jsx("p",{className:"text-xs text-sys-red",children:g})]}):e.jsx("button",{onClick:()=>w(!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"})}),!y&&e.jsx("p",{className:"text-xs text-fg-muted",children:t.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function ln({decoded:t,timestamp:a}){const s=a?le(a):"Unknown";return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.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:e.jsx(Xs,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",t.crc]})," · ",s]})]})]})}function cn({decoded:t,timestamp:a}){const s=a?le(a):"Unknown",n=t.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-amber/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(ca,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[n," ",n===1?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.path.map((r,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[i>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-amber"}),e.jsx(M,{color:"amber",className:"font-mono",children:r})]},i))})})]})]})})}function on({decoded:t,timestamp:a}){const s=a?le(a):"Unknown",n=t.pathHashes.length,r=t.snrValues.length,i=l=>l>=7?"green":l>=0?"yellow":l>=-5?"orange":"red";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-blue/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(Ys,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:["Trace ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[n," target ",n===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[r," SNR ",r===1?"sample":"samples"]}),t.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",t.authCode]})]})]}),t.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:t.pathHashes.map((l,o)=>{const m=t.snrValues[o],g=m!==void 0?i(m):"zinc",u=m!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(M,{color:u?"blue":"zinc",className:"font-mono",children:l}),u&&e.jsxs(M,{color:g,className:"font-mono",children:[m>=0?"+":"",Number.isInteger(m)?m:m.toFixed(1),"dB"]})]})]},o)})})]})]})})}function dn({decoded:t,timestamp:a}){const s=a?le(a):"Unknown";return t.encrypted?e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.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:e.jsx(ct,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.srcHash," → ",t.destHash," · ",s]})]})]}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 px-1",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:[e.jsx("span",{className:"font-mono text-fg-secondary",children:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",s]})]}),e.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:e.jsx("p",{className:"text-sm text-white font-sans leading-relaxed whitespace-pre-wrap break-words",children:t.text})})]})}function xn({decoded:t,timestamp:a}){const s=a?le(a):"Unknown",n=(t.partNumber+1)/t.totalParts*100;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-sys-yellow/10",style:{backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 flex items-center gap-3",children:[e.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:e.jsx(Ks,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-fg-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${n}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-sans",children:["Message ID: ",e.jsx("span",{className:"font-mono",children:t.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function mn({decoded:t,timestamp:a,payloadType:s}){const n=a?le(a):"Unknown",i=(()=>{switch(s){case re.REQ:return{icon:ys,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case re.RESPONSE:return{icon:la,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case re.ANON_REQ:return{icon:ct,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Qs,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=i.icon;return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shadow-md",style:{background:`linear-gradient(135deg, ${i.gradient})`},children:e.jsx(l,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-fg-primary font-sans",children:i.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.length," bytes · ",n]})]})]})}function hn({pathHex:t}){if(!t)return null;const a=Ge(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{size:"compact",copy:!0,children:s.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function un({decoded:t,payloadType:a}){const s=fs[a]||`TYPE_${a}`;switch(t.type){case"advert":{const n=t.nodeType==="chat"?"companion":t.nodeType.replace("_"," "),r=t.latitude!==void 0&&t.longitude!==void 0&&!(t.latitude===0&&t.longitude===0);return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Role:"})," ",n]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",t.name]}),r&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",le(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",t.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-fg-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"CRC:"})," 0x",t.crc]})});case"path":return e.jsx("div",{className:"text-xs text-fg-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Path:"})," ",t.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Tag:"})," 0x",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",t.snrValues.map(n=>`${n>=0?"+":""}${Number.isInteger(n)?n:n.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",t.isComplete?"✓ Complete":`In progress (${t.snrValues.length}/${t.pathHashes.length})`]})]});case"txt_msg":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),t.encrypted?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-green",children:t.channelName}):t.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),t.decrypted?e.jsxs(e.Fragment,{children:[t.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]}):t.isPublicHashChannel?e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (public hash channel)"}):e.jsx("p",{className:"text-fg-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-sys-teal",children:t.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes ",t.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Part:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",t.messageId]})]});case"control":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Control:"})," ",t.subtypeName]}),t.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes"]})]});case"req":case"response":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});case"anon_req":return e.jsxs("div",{className:"text-xs text-fg-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[t.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[s," (","length"in t?t.length:0," bytes)"]})}}function pn({packet:t,decodedGrpTxt:a}){var D,Y;const s=t.raw_packet||"",n=s.length/2,r=ds(),[i,l]=h.useState(null),[o,m]=h.useState(null),[g,u]=h.useState(!1),[y,w]=h.useState(null),j=h.useCallback(I=>{w(H=>H===I?null:I)},[]),x=h.useMemo(()=>Hs(s),[s]),k=(D=x==null?void 0:x.packet)==null?void 0:D.payloadType,B=(x==null?void 0:x.payloadHex)||"",d=(Y=x==null?void 0:x.packet)==null?void 0:Y.payload,b=k===re.GRP_TXT,f=k===re.GRP_DATA,_=b&&!a&&(!r||g);if(h.useEffect(()=>{if(l(null),u(!1),a||!b||!d||d.length<4)return;if(!r){u(!0);return}u(!0);let I=!1;return xs(d).then(H=>{I||(l(H),u(!1))}),()=>{I=!0}},[B,b,r,a]),h.useEffect(()=>{if(m(null),!f||!d||d.length<4||!r)return;let I=!1;return ms(d).then(H=>{I||m(H)}),()=>{I=!0}},[B,f,r]),!x||s.length===0)return e.jsx("div",{className:"p-4 text-center text-fg-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:v}=x;let p=x.decoded;a&&x.decoded.type==="grp_txt"?p=a:i&&x.decoded.type==="grp_txt"?p=i:o&&x.decoded.type==="grp_data"&&(p=o);const E=()=>{switch(p.type){case"advert":return e.jsx(an,{advert:p,timestamp:t.timestamp});case"grp_data":return e.jsx(nn,{decoded:p,timestamp:t.timestamp});case"grp_txt":return e.jsx(rn,{decoded:p,timestamp:t.timestamp,isLoading:_,onDecrypted:l});case"ack":return e.jsx(ln,{decoded:p,timestamp:t.timestamp});case"path":return e.jsx(cn,{decoded:p,timestamp:t.timestamp});case"trace":return e.jsx(on,{decoded:p,timestamp:t.timestamp});case"txt_msg":return e.jsx(dn,{decoded:p,timestamp:t.timestamp});case"multipart":return e.jsx(xn,{decoded:p,timestamp:t.timestamp});case"generic":return v.payloadType===re.REQ||v.payloadType===re.RESPONSE||v.payloadType===re.ANON_REQ?e.jsx(mn,{decoded:p,timestamp:t.timestamp,payloadType:v.payloadType}):null;default:return null}},O=h.useMemo(()=>en(p,x.payloadHex),[p,x.payloadHex]),G=y==="payload"||je(y),K=h.useMemo(()=>{const I=[{id:"header",hex:x.headerHex,color:"red"},...x.transportCodesHex?[{id:"transportCodes",hex:x.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:x.pathLengthHex,color:"green"},...x.pathDataHex?[{id:"pathData",hex:x.pathDataHex,color:"amber"}]:[]];return G?[...I,...tn(O)]:[...I,{id:"payload",hex:x.payloadHex,color:"cyan"}]},[x,G,O]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[E(),e.jsx(Qa,{rawHex:s,hexSegments:K,selectedSegment:y,onSegmentClick:j}),e.jsx(hs,{children:e.jsx(oe.div,{layout:!0,transition:st,className:"space-y-2 min-w-0",children:(()=>{var T,z,te,se;const H=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${x.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"type-micro text-fg-muted font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Bits"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Field"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Value"})}),e.jsx("th",{className:"py-1 font-medium",children:e.jsx("span",{className:"underline underline-offset-4 decoration-edge-subtle",children:"Binary"})})]})}),e.jsx("tbody",{children:x.headerFields.map(c=>e.jsx(sn,{...c},c.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((T=x.transportCodesHex)==null?void 0:T.toUpperCase())||"",condition:!!x.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-fg-secondary",children:["Code 1: 0x",(z=x.transportCodesHex)==null?void 0:z.slice(0,4).toUpperCase()," | Code 2: 0x",(te=x.transportCodesHex)==null?void 0:te.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:x.transportCodesHex?5:1,endByte:x.transportCodesHex?5:1,hexBytes:`0x${x.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[v.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:x.transportCodesHex?6:2,endByte:(x.transportCodesHex?5:1)+v.pathLen,hexBytes:((se=x.pathDataHex)==null?void 0:se.toUpperCase())||"",condition:v.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(hn,{pathHex:x.pathDataHex}),e.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:x.payloadStartByte,endByte:n-1,hexBytes:x.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!je(y)&&e.jsxs("div",{className:"p-3 radius-inner bg-inset depth-stroke-inset",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(un,{decoded:p,payloadType:v.payloadType})]}),!je(y)&&O.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),je(y)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(c=>c.condition),$=je(y)?O.find(c=>c.id===y):null,U=je(y)?[...H].sort((c,Z)=>c.id==="payload"?-1:Z.id==="payload"?1:0):[...H].sort((c,Z)=>c.id===y?-1:Z.id===y?1:0),J=je(y)?O.filter(c=>c.id!==y):[];return e.jsxs(e.Fragment,{children:[$&&e.jsx(jt,{id:`subfield-${$.id}`,title:$.title,color:$.color,startByte:x.payloadStartByte+$.startByte,endByte:x.payloadStartByte+$.endByte,hexBytes:$.hex.toUpperCase(),isSelected:!0,children:$.decoded},$.id),U.map(c=>e.jsx(jt,{id:`section-${c.id}`,title:c.title,color:c.color,startByte:c.startByte,endByte:c.endByte,hexBytes:c.hexBytes,isSelected:c.id===y,children:c.content},c.id)),J.map(c=>e.jsxs(oe.div,{layout:"position",layoutId:`subfield-${c.id}`,transition:st,className:"w-full min-w-0 overflow-hidden radius-inner p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:Te.cardRestShadow},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 min-w-0",children:[e.jsx(M,{color:c.color,children:c.title}),c.hex.length<=32&&Ge(c.hex).map((Z,q)=>e.jsx(M,{color:c.color,className:"font-mono",children:Z.toUpperCase()},q))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",x.payloadStartByte+c.startByte,"-",x.payloadStartByte+c.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 radius-inner bg-inset depth-stroke-inset",children:c.decoded})]},c.id))]})})()})})]})}const bt=h.memo(pn);function Nt(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function at({hop:t,compact:a=!1,index:s=0,highlightIndex:n=-1,isTrace:r=!1}){var o;const i=s===n,l=pa();return h.useEffect(()=>{i&&r&&l.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"}})},[i,r,l]),e.jsxs(oe.div,{className:R("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:i?1.05:1,opacity:i?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(oe.div,{className:R("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",t.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:l,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[t.isLocal&&e.jsx(Js,{className:"w-3 h-3"}),e.jsx("span",{children:t.prefix}),t.confidence!==void 0&&t.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(t.confidence*100).toFixed(0),"%"]})]}),!a&&((o=t.neighborInfo)==null?void 0:o.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:t.neighborInfo.name})]})}function fn({snr:t,sf:a}){const s=vs(t,a),r=Ns()[s]||"#6b7280",i=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(M,{customColor:r,compact:!0,className:"font-mono",children:[t>=0?"+":"",i,"dB"]})}function gn({hops:t,compact:a,isTrace:s=!1,sf:n}){const[r,i]=h.useState(-1);return h.useEffect(()=>{if(t.length===0)return;const l=setTimeout(()=>{i(0)},400),o=setInterval(()=>{i(m=>{const g=m+1;return g>=t.length?(clearInterval(o),-1):g})},s?500:600);return()=>{clearTimeout(l),clearInterval(o)}},[t.length,s]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:t.map((l,o)=>{const m=o%2===0,g=o===t.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:R("flex items-center","justify-end"),children:m&&e.jsx(at,{hop:l,compact:a,index:o,highlightIndex:r,isTrace:s})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),l.snr!==void 0&&e.jsx(fn,{snr:l.snr,sf:n}),e.jsx("svg",{className:"w-3 h-3 text-fg-muted flex-shrink-0",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M6 2v8M3 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),e.jsx("div",{className:R("flex items-center","justify-start"),children:!m&&e.jsx(at,{hop:l,compact:a,index:o,highlightIndex:r,isTrace:s})})]},`${l.prefix}-${o}`)})})}function yn({packet:t,neighbors:a,localHash:s,neighborAffinity:n,ghostPrefixes:r,direction:i="horizontal",compact:l=!1,traceSnr:o,overridePath:m}){const g=o!==void 0&&o.length>0,u=js(),y=Nt(t.original_path),w=Nt(t.forwarded_path),j=m??(w.length>0?w:y),x=s?Ee(s):"",k=h.useMemo(()=>j.map((d,b)=>{const f=d.toUpperCase(),_=f===x,v=(r==null?void 0:r.has(f))??!1,p=bs(f,a,n);return{prefix:f,fullHash:p==null?void 0:p.hash,neighborInfo:p==null?void 0:p.info,isLocal:_,isGhost:v,confidence:p==null?void 0:p.confidence,snr:o==null?void 0:o[b]}}),[j,a,n,x,r,o]);if(k.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(de,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(i==="flowchart")return e.jsx(gn,{hops:k,compact:l,isTrace:g,sf:u});const B=i==="horizontal"?ue:Ut;return e.jsx("div",{className:R("flex gap-1.5",i==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:k.map((d,b)=>e.jsxs("div",{className:R("flex items-center gap-1.5",i==="vertical"&&"flex-col"),children:[e.jsx(at,{hop:d,compact:l}),b<k.length-1&&e.jsx(B,{className:"w-3 h-3 text-fg-muted flex-shrink-0"})]},`${d.prefix}-${b}`))})}const Ce=h.memo(yn);function ee(t,a){if(t!=null)return typeof t=="boolean"?String(t):typeof t=="number"&&a?`${t} ${a}`:String(t)}const V=()=>"blue",jn=[{fn:"id",group:"identity",fmt:"int",read:t=>ee(t.id),color:V},{fn:"packet_hash",group:"identity",fmt:"hex<sha256>",read:t=>t.packet_hash||void 0,color:V},{fn:"timestamp",group:"identity",fmt:"epoch<s>",read:t=>t.timestamp?String(t.timestamp):void 0,color:V,annotate:t=>t.timestamp>0?Ze(t.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum<payload_type>",read:t=>ee(t.type??t.payload_type),color:V},{fn:"route",group:"classification",fmt:"enum<route_type>",read:t=>ee(t.route??t.route_type),color:V},{fn:"rssi",group:"signal",fmt:"int<dBm>",read:t=>ee(t.rssi,"dBm"),color:V},{fn:"snr",group:"signal",fmt:"float<dB>",read:t=>ee(t.snr,"dB"),color:V},{fn:"path_length",group:"size",fmt:"int<hops>",read:t=>{if(t.path_length!=null)return t.path_length===0?"zero-hop":`${t.path_length} hops`},color:V},{fn:"payload_length",group:"size",fmt:"int<B>",read:t=>ee(t.payload_length,"B"),color:V},{fn:"airtime",group:"size",fmt:"float<ms>",read:t=>ee(t.airtime_ms,"ms"),color:V},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:t=>t.src_hash??void 0,color:V},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:t=>t.dst_hash??void 0,color:V},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:t=>Array.isArray(t.path_hash)?`[${t.path_hash.join(", ")}]`:ee(t.path_hash),color:V,renderValue:t=>Array.isArray(t.path_hash)?Ye(t.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:t=>ee(t.score),color:V},{fn:"original_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.original_path)?`[${t.original_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.original_path)&&t.original_path.length>0?Ye(t.original_path,t.src_hash||void 0,t.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.forwarded_path)?`[${t.forwarded_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.forwarded_path)&&t.forwarded_path.length>0?Ye(t.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:t=>ee(t.transmitted),color:V},{fn:"is_duplicate",group:"status",fmt:"bool",read:t=>ee(t.is_duplicate),color:V},{fn:"drop_reason",group:"status",fmt:"string|null",read:t=>t.drop_reason??void 0,color:V},{fn:"tx_delay",group:"status",fmt:"int<ms>",read:t=>ee(t.tx_delay_ms,"ms"),color:V},{fn:"origin",group:"status",fmt:"enum<rx|tx_local|tx_forward>",read:t=>t.packet_origin??void 0,color:V},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:t=>t.duplicates!=null&&t.duplicates.length>0?`${t.duplicates.length}`:ee(t.duplicates),color:V},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:t=>ee(t.lbt_attempts),color:V},{fn:"lbt_backoff",group:"lbt",fmt:"json<float[]>",read:t=>ee(t.lbt_backoff_delays_ms),color:V},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:t=>ee(t.lbt_channel_busy),color:V}];function Ye(t,a,s,n){const r=t.length>0,i=a||n,l=s||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&e.jsxs(e.Fragment,{children:[a?e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:a}):e.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||l)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),t.map((o,m)=>e.jsxs(h.Fragment,{children:[m>0&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5 font-mono text-[11px] text-sys-blue",children:o})]},m)),l&&e.jsxs(e.Fragment,{children:[r&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),s?e.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}):e.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 De=null;function bn(){if(!De){De=new Map;for(const t of jn)De.set(t.fn,t)}return De}function vt(t,a){var l;const s=bn().get(a);if(!s)return null;const n=s.read(t);if(n===void 0)return null;const r=s.color(t),i=(l=s.annotate)==null?void 0:l.call(s,t);return i?{text:n,color:r,annotation:i}:{text:n,color:r}}function wt(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function kt({packets:t,selectedIndex:a,onSelect:s,compact:n=!1}){if(t.length<=1)return null;const r=a>0,i=a<t.length-1;return e.jsxs("div",{className:R("flex items-center gap-1",n?"gap-0.5":"gap-1"),children:[e.jsx("button",{onClick:()=>r&&s(a-1),disabled:!r,className:R("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:e.jsx(Vt,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((l,o)=>{const m=o===a,u=new Date(l.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Ps,{color:m?"cyan":"zinc",filled:m,compact:n,onClick:()=>s(o),title:`Observation ${o+1} at ${u}`,className:R("transition-all duration-150",!m&&"opacity-60 hover:opacity-100"),children:n?e.jsx("span",{className:"tabular-nums",children:o+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",o+1,l.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:l.rssi})]})},`${l.timestamp}_${o}`)})}),e.jsx("button",{onClick:()=>i&&s(a+1),disabled:!i,className:R("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:e.jsx(it,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:R("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(rt,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Ae({icon:t,label:a,disabled:s=!1}){return e.jsx(oe.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:s?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:R("flex items-center justify-center size-5 radius-badge border-control transition-base",s?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:t})})}function Nn({hasDuplicates:t,hasPrev:a,hasNext:s,canPrevDupe:n,canNextDupe:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(Ls,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(Ae,{icon:e.jsx(Ms,{className:"size-3"}),label:"Next packet (↓)",disabled:!s})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-subtle-fill-strong"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Ae,{icon:e.jsx(Vt,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Ae,{icon:e.jsx(it,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}function vn({packets:t,initialIndex:a=0,onClose:s,onNavigatePrev:n,onNavigateNext:r,hasPrev:i=!1,hasNext:l=!1,resolveSource:o,getDecodedContent:m}){var He;const[g,u]=h.useState(a),y=t[g]??t[0],w=t.length>1,[j,x]=h.useState(null),[k,B]=h.useState(!1);h.useEffect(()=>{if(!y._stripped){x(null);return}let Q=!1;B(!0);const N=y.packet_hash;if(!N){B(!1);return}return ws(N).then(C=>{Q||(C.success&&C.data&&(x(C.data),(C.data.type??C.data.payload_type)===re.GRP_TXT&&C.data.raw_packet&&ks.getState().queueDecryption([C.data])),B(!1))}).catch(()=>{Q||B(!1)}),()=>{Q=!0}},[y]);const d=j??y,b=g>0,f=g<t.length-1,_=h.useCallback(Q=>{u(Math.max(0,Math.min(Q,t.length-1)))},[t.length]);h.useEffect(()=>{const Q=N=>{if(!(N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement))switch(N.key){case"ArrowUp":N.preventDefault(),n==null||n();break;case"ArrowDown":N.preventDefault(),r==null||r();break;case"ArrowLeft":N.preventDefault(),b&&u(C=>C-1);break;case"ArrowRight":N.preventDefault(),f&&u(C=>C+1);break}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[n,r,b,f]);const v=Dt(),p=Cs(),E=_s(),O=Ss(),G=h.useMemo(()=>new Set(O.map(Q=>Q.prefix.toUpperCase())),[O]),K=d.payload_type_name||Ht(d.payload_type??d.type),D=d.route_type_name||Ft(d.route_type??d.route),Y=d.payload_length??d.length??0,I=wt(d.original_path),H=wt(d.forwarded_path),$=I.length>0||H.length>0,U=H.length>0?H:I,J=h.useMemo(()=>{var Q;if((Q=v==null?void 0:v.config)!=null&&Q.repeater)return{latitude:v.config.repeater.latitude,longitude:v.config.repeater.longitude,name:v.config.node_name||"Local Node"}},[v]),T=(v==null?void 0:v.neighbors)??{},z=E.size>0?E:void 0,te=d.raw_packet&&d.raw_packet.length>0,se=y._stripped&&k,c=h.useMemo(()=>o?o(d):null,[o,d]),Z=Ts(d.packet_hash),q=h.useMemo(()=>!m||(d.payload_type??d.type)!==re.GRP_TXT?null:m(d),[m,d]),ie=h.useMemo(()=>{if((d.payload_type??d.type)!==re.GRP_TXT)return null;if(Z!=null&&Z.decoded){const N=Z.decoded;return{type:"grp_txt",channelHash:N.channelHash,channelName:N.channelName,text:N.text??"",decrypted:N.decrypted,senderName:N.senderName,timestamp:N.timestamp,flags:N.flags,macCorrupted:N.macCorrupted}}return q!=null&&q.decrypted?{type:"grp_txt",channelHash:q.channelHash??"",channelName:q.channelName??"",text:q.text??"",decrypted:!0,senderName:q.senderName??"",timestamp:0,flags:0,macCorrupted:q.corrupted}:null},[d,Z,q]),P=h.useMemo(()=>Fs(d,ie),[d,ie]),F=P.kind==="trace"?P.data:null,ae=P.kind==="trace"?P.snrValues:void 0,S=P.kind==="advert"?P.data:null,ce=P.kind==="advert"?P.sourceNode:void 0,pe=P.kind==="grp_txt"?P.wardriveSourceNode??void 0:void 0,ne=P.kind==="anon_req"?P.data:null,Be=Q=>!Q||Q===0?"Unknown":new Date(Q*1e3).toLocaleString(),be=(d.payload_type??d.type)===re.ADVERT&&(ce!==void 0||$),Le=pe!==void 0,Ne=ce??pe,We=Me[K]??"zinc",Re=he[We]||he.zinc;return e.jsxs(At,{open:!0,onClose:s,size:"5xl",motionPlus:!0,solid:!0,className:"sm:h-[85vh] sm:max-h-[800px] md:h-[80vh] md:max-h-[900px]",children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-muted","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(M,{color:Me[K]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:K}),e.jsx(M,{color:Ie[D]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:D}),e.jsxs(M,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[Y,"B"]})]}),e.jsx("button",{onClick:s,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"})]}),w&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(kt,{packets:t,selectedIndex:g,onSelect:_,compact:!0})})]}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{color:Me[K]??"zinc",children:K}),e.jsx(M,{color:Ie[D]??"zinc",children:D}),e.jsxs(M,{color:"zinc",children:[Y,"B"]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(kt,{packets:t,selectedIndex:g,onSelect:_})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Nn,{hasDuplicates:w,hasPrev:i,hasNext:l,canPrevDupe:b,canNextDupe:f}),e.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:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:Re,opacity:.6}}),e.jsxs(Et,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsx("div",{className:"md:hidden flex-1 overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-2 pt-2 space-y-2",children:[(d.rssi!=null||d.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill depth-stroke",children:[e.jsx(qe,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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:[e.jsx(ze,{rssi:d.rssi,snr:d.snr,compact:!0,showValues:!0,validated:$e(d)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:ut(d.rssi)})]},g)}),U.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[U.length," hop",U.length!==1?"s":""]})]}),($&&U.length>0||be||Le)&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ve,{path:U,neighbors:T,localNode:J,localHash:v==null?void 0:v.local_hash,srcHash:d.src_hash,dstHash:d.dst_hash,neighborAffinity:z,hubNodes:[...p],traceSnr:ae,advertiserSource:Ne})})}),F&&F.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsx("div",{className:"px-3 py-2 space-y-1.5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(M,{color:F.isComplete?"green":"amber",compact:!0,children:F.isComplete?"Complete":"In Progress"})})]})}),e.jsx(Ce,{packet:d,neighbors:T,localHash:v==null?void 0:v.local_hash,neighborAffinity:z,ghostPrefixes:G,direction:"flowchart",compact:!0,overridePath:F.pathHashes,traceSnr:F.snrValues})]}),$&&!F&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(M,{color:"zinc",compact:!0,children:[U.length," hop",U.length!==1?"s":""]})]}),e.jsx(Ce,{packet:d,neighbors:T,localHash:v==null?void 0:v.local_hash,neighborAffinity:z,ghostPrefixes:G,direction:"flowchart",compact:!0,traceSnr:ae})]}),c&&(c.name||c.hash)&&!S&&!ne&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(M,{color:c.isRepeater?"blue":c.isCompanion?"violet":c.type==="room_server"?"lime":"zinc",compact:!0,children:c.type==="room_server"?"room server":c.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[c.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:c.name}),!c.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),c.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:c.hash.length>16?`${c.hash.slice(0,16)}…${c.hash.slice(-8)}`:c.hash.startsWith("0x")?c.hash.slice(2,10)+"…":c.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(M,{color:c!=null&&c.isRepeater?"blue":c!=null&&c.isCompanion?"violet":(c==null?void 0:c.type)==="room_server"?"lime":"amber",compact:!0,children:c!=null&&c.type&&c.type!=="unknown"?c.type==="room_server"?"room server":c.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(c==null?void 0:c.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:c.name}),!c.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted break-all font-mono leading-relaxed",children:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),S&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(M,{color:"lime",compact:!0,children:S.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[S.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:S.name})]}),S.latitude&&S.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[S.latitude.toFixed(5),", ",S.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[S.publicKey.slice(0,16),"...",S.publicKey.slice(-8)]})]}),S.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Be(S.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:S.flagsDescription||`Flags: 0x${S.flags.toString(16).padStart(2,"0")}`})]})]})]}),se?e.jsx("div",{className:"pt-1 px-3 py-6 text-center",children:e.jsx("span",{className:"text-xs text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx("div",{className:"pt-1",children:e.jsx(bt,{packet:d,decodedGrpTxt:ie})}):null]})}),e.jsxs("div",{className:"hidden md:grid md:grid-cols-2 flex-1 overflow-hidden",children:[e.jsx("div",{className:"overflow-y-auto overflow-x-hidden scrollbar-none px-4 pt-4",children:se?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-sm text-fg-muted animate-pulse",children:"Loading packet details…"})}):te?e.jsx(bt,{packet:d,decodedGrpTxt:ie}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:$&&U.length>0||be||Le?e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(Ve,{path:U,neighbors:T,localNode:J,localHash:v==null?void 0:v.local_hash,srcHash:d.src_hash,dstHash:d.dst_hash,neighborAffinity:z,hubNodes:[...p],traceSnr:ae,advertiserSource:Ne})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(de,{className:"w-8 h-8 text-fg-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-fg-muted/70 mt-1",children:"Zero-hop packet — received directly from sender"})]})}),e.jsxs("div",{className:"overflow-y-auto max-h-[200px] p-2 space-y-2",children:[!F&&U.length<=1&&(d.rssi!=null||d.snr!=null)&&e.jsx("div",{className:"surface-base radius-inner p-4 depth-stroke",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"Signal"}),e.jsx(qe,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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:[e.jsx(ze,{rssi:d.rssi,snr:d.snr,validated:$e(d)}),e.jsx("span",{className:"font-medium text-fg-primary",children:ut(d.rssi)})]},g)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(qe,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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:[(He=vt(d,"rssi"))==null?void 0:He.text,(()=>{const Q=vt(d,"snr");return Q?` · ${Q.text}`:null})()]},g)})]})]})}),c&&(c.name||c.hash)&&!S&&!ne&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(M,{color:c.isRepeater?"blue":c.isCompanion?"violet":c.type==="room_server"?"lime":"zinc",compact:!0,children:c.type==="room_server"?"room server":c.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[c.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:c.name}),!c.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),c.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:c.hash.length>16?`${c.hash.slice(0,16)}…${c.hash.slice(-8)}`:c.hash.startsWith("0x")?c.hash.slice(2,10)+"…":c.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(M,{color:c!=null&&c.isRepeater?"blue":c!=null&&c.isCompanion?"violet":(c==null?void 0:c.type)==="room_server"?"lime":"amber",compact:!0,children:c!=null&&c.type&&c.type!=="unknown"?c.type==="room_server"?"room server":c.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(c==null?void 0:c.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:c.name}),!c.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:["Dest: ",e.jsx("span",{className:"font-mono",children:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-muted break-all leading-relaxed",children:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),S&&e.jsxs("div",{className:"radius-inner bg-subtle-fill overflow-hidden depth-stroke",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(M,{color:"lime",compact:!0,children:S.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[S.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:S.name})]}),S.latitude&&S.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[S.latitude.toFixed(5),", ",S.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[S.publicKey.slice(0,16),"...",S.publicKey.slice(-8)]})]}),S.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Be(S.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:S.flagsDescription||`Flags: 0x${S.flags.toString(16).padStart(2,"0")}`})]})]})]}),F&&F.pathHashes.length>0&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(M,{color:F.isComplete?"green":"amber",compact:!0,children:F.isComplete?"Complete":"In Progress"}),e.jsxs(M,{color:"teal",compact:!0,children:[F.pathHashes.length,"h"]})]})]}),e.jsx(Ce,{packet:d,neighbors:T,localHash:v==null?void 0:v.local_hash,neighborAffinity:z,ghostPrefixes:G,direction:"flowchart",compact:!0,overridePath:F.pathHashes,traceSnr:F.snrValues})]}),$&&!F&&e.jsxs("div",{className:"radius-inner bg-inset overflow-hidden depth-stroke-inset",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Path"}),e.jsxs(M,{color:"zinc",compact:!0,children:[U.length,"h"]})]}),e.jsx(Ce,{packet:d,neighbors:T,localHash:v==null?void 0:v.local_hash,neighborAffinity:z,ghostPrefixes:G,direction:"flowchart",compact:!0,traceSnr:ae})]})]})]})]})]})]})}const wn=h.memo(vn);function Ct({label:t,numericValue:a,unit:s,icon:n,subtext:r,showSign:i=!1}){return e.jsxs("div",{className:"radius-inner p-3 sm:radius-inset sm:p-4 bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-xs sm:type-micro text-fg-muted",children:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(et,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:i?"always":"auto"},className:"type-data-hero tracking-tight text-fg-primary"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-fg-muted"}),s&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:s})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:r})]})}function kn({snr:t}){const a=t>=5?"bg-sys-teal":t>=0?"bg-sys-green":t>=-5?"bg-sys-amber":t>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:R("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${t.toFixed(1)} dB`})}function _t({fromPrefix:t,toPrefix:a,fromName:s,toName:n,snr:r,maxSnr:i,isWeakest:l,isStrongest:o,index:m=0}){const u=Math.max(i+5,15),y=Math.max(0,Math.min(100,(r- -20)/(u- -20)*100)),w="bg-[#0074BE]",j=r>=5?"bg-sys-teal":r>=0?"bg-sys-green":r>=-5?"bg-sys-amber":r>=-10?"bg-sys-orange":"bg-sys-red",x=.3+m*.15;return e.jsxs("div",{className:"relative p-3 pl-5 radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle",children:[e.jsx("span",{className:R("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",j)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(kn,{snr:r})}),e.jsxs("div",{className:"sm:hidden",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-fg-secondary truncate",children:s||t}),e.jsx(ue,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:n||a})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[l&&e.jsx(M,{color:"red",compact:!0,children:"Low"}),o&&!l&&e.jsxs(M,{color:"amber",compact:!0,children:[e.jsx(gt,{className:"w-2.5 h-2.5"}),"Best"]}),e.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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",w),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:x,ease:[.25,.1,.25,1]}})})]}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"type-data-xs text-fg-muted",children:t}),s&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:s})]}),e.jsx(ue,{className:"w-3 h-3 text-fg-muted/40 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-xs font-semibold text-fg-primary",children:a}),n&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx(M,{color:"red",compact:!0,children:"Bottleneck"}),o&&!l&&e.jsxs(M,{color:"amber",compact:!0,children:[e.jsx(gt,{className:"w-3 h-3"}),"Strongest"]}),e.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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",w),initial:{width:0},animate:{width:`${y}%`},transition:{duration:1.5,delay:x,ease:[.25,.1,.25,1]}})})]})]})}function ge(t,a){if(t==="You")return"You";const s=t.toUpperCase();for(const[n,r]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===s)return r.name||r.node_name||void 0}function Cn({report:t,onClose:a}){var g,u;const s=Dt(),n=(s==null?void 0:s.neighbors)??{},r=(g=s==null?void 0:s.config)!=null&&g.repeater?{latitude:s.config.repeater.latitude,longitude:s.config.repeater.longitude,name:s.config.node_name||"Local Node"}:void 0,i=(u=t.bestObservation)==null?void 0:u.decoded.snrValues,l=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",m={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[l];return e.jsxs(At,{open:!0,onClose:a,size:"5xl",motionPlus:!0,children:[e.jsxs("div",{className:"sm:hidden",children:[e.jsx("div",{className:"flex justify-center pt-2 pb-1",children:e.jsx("div",{className:"w-9 h-1 rounded-full bg-fg-primary/30","aria-hidden":"true"})}),e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2",children:[e.jsx("h2",{className:"font-semibold text-[17px] text-fg-primary",children:"Trace Report"}),e.jsx("button",{onClick:a,className:"text-[17px] font-medium text-sys-blue active:text-sys-blue/80",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:m,opacity:.6}}),e.jsx("div",{className:"hidden sm:block px-6 pt-5 pb-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[e.jsx("h2",{className:"type-micro",children:"Trace Report"}),e.jsxs(M,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",children:[e.jsx(ft,{className:"w-3 h-3 mr-1"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:a,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:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),e.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:[e.jsxs(M,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",t.targetHopCount!==1?"s":""]})]}),e.jsxs(M,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),t.linkQuality&&e.jsxs(M,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Bs(t.duration)}),t.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted/40",children:"•"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.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:[e.jsx("span",{className:"opacity-70",children:"Min"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.minSnr.toFixed(1)})]}),e.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:[e.jsx("span",{className:"opacity-70",children:"Max"}),e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs(Et,{className:"p-0 overflow-hidden",children:[e.jsx("div",{className:"md:hidden h-[75vh] max-h-[calc(100vh-80px)] overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[t.linkQuality&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(et,{value:Math.abs(t.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:t.linkQuality.minSnr<0?"-":"",className:"text-[20px] font-bold font-mono tabular-nums flex items-center justify-center text-fg-primary"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(Je,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Min dB"})]})]}),e.jsxs("div",{className:"radius-inner bg-subtle-fill ring-1 ring-inset ring-edge-subtle p-2.5 text-center",children:[e.jsx(et,{value:t.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-fg-primary tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(pt,{className:"w-2.5 h-2.5 text-fg-muted"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(M,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",compact:!0,children:[e.jsx(ft,{className:"w-2.5 h-2.5 mr-0.5"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]}),e.jsxs(M,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(M,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ve,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-body overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg-secondary",children:"Route Path"}),t.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(Ce,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-fg-muted text-xs",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"type-micro text-fg-muted mb-2",children:["Link Quality · ",t.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:t.hopStats.length>0?t.hopStats.map((y,w)=>{var B,d,b;const j=w<t.targetPath.length-1?t.targetPath[w+1]:"You",x=ge(y.prefix,n),k=ge(j,n);return e.jsx(_t,{fromPrefix:y.prefix,toPrefix:j,fromName:x,toName:k,snr:y.snr,maxSnr:((B=t.linkQuality)==null?void 0:B.maxSnr)??10,isWeakest:((d=t.linkQuality)==null?void 0:d.weakestLinkPosition)===w,isStrongest:((b=t.linkQuality)==null?void 0:b.strongestLinkPosition)===w,index:w},`${y.prefix}-${w}`)}):e.jsx("div",{className:"text-xs text-fg-muted py-6 text-center",children:"No link data collected"})})]}),e.jsx("div",{className:"pt-1 pb-2 text-center",children:e.jsxs("span",{className:"text-xs text-fg-muted",children:["Traced ",Ze(t.firstSeen)]})})]})}),e.jsxs("div",{className:"hidden md:flex md:flex-row h-[70vh] max-h-[calc(100vh-200px)] overflow-hidden",children:[e.jsx("div",{className:"w-1/2 flex flex-col min-w-0 min-h-0 overflow-hidden border-r border-edge-subtle",children:e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[t.linkQuality&&(()=>{const y=t.targetPath[t.linkQuality.weakestLinkPosition],w=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",j=ge(y,n),x=ge(w,n),k=t.targetPath[t.linkQuality.strongestLinkPosition],B=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",d=ge(k,n),b=ge(B,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ct,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:Je,subtext:`${j||y} → ${x||w}`}),e.jsx(Ct,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:pt,subtext:`${d||k} → ${b||B}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"type-micro text-fg-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:t.hopStats.length>0?t.hopStats.map((y,w)=>{var B,d,b;const j=w<t.targetPath.length-1?t.targetPath[w+1]:"You",x=ge(y.prefix,n),k=ge(j,n);return e.jsx(_t,{fromPrefix:y.prefix,toPrefix:j,fromName:x,toName:k,snr:y.snr,maxSnr:((B=t.linkQuality)==null?void 0:B.maxSnr)??10,isWeakest:((d=t.linkQuality)==null?void 0:d.weakestLinkPosition)===w,isStrongest:((b=t.linkQuality)==null?void 0:b.strongestLinkPosition)===w,index:w},`${y.prefix}-${w}`)}):e.jsx("div",{className:"text-xs text-fg-muted py-8 text-center",children:"No link data collected"})})]}),e.jsxs("div",{className:"pt-2 text-center",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Traced "}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Ze(t.firstSeen)})]})]})}),e.jsxs("div",{className:"w-1/2 min-w-0 overflow-y-auto p-3 space-y-2",children:[t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Ve,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(M,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(M,{color:"teal",compact:!0,children:[t.targetHopCount," hop",t.targetHopCount!==1?"s":""]})]})]}),t.linkQuality&&t.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 type-data-xs text-fg-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-sys-teal tabular-nums",children:t.traceTag.slice(0,8)})]}),e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"SNR"})," ",e.jsxs("code",{className:"text-sys-indigo tabular-nums",children:[t.linkQuality.minSnr.toFixed(1),"–",t.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),t.bestObservation?e.jsx(Ce,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const _n=h.memo(Cn),Xt=[{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:zs},{target:"PacketList",fn:"src_hash",minStage:1,when:$s},{target:"PacketList",fn:"text",minStage:1,when:Us},{target:"PacketList",fn:"ack",minStage:1,when:Os},{target:"PacketList",fn:"decrypt",minStage:2,when:Vs},{target:"PacketList",fn:"duplicates",minStage:1}];Is(Xt);const Sn=48,Tn=72,Pn=100,Mn=5,Bn=600,Zt="(min-width: 640px)";let me=null;function Ln(t){return typeof window>"u"?()=>{}:(me||(me=window.matchMedia(Zt)),me.addEventListener("change",t),()=>me==null?void 0:me.removeEventListener("change",t))}function Rn(){return typeof window>"u"?!0:(me||(me=window.matchMedia(Zt)),me.matches)}function Hn(){return h.useSyncExternalStore(Ln,Rn,()=>!0)}function Fn(t,a,s){const[n,r]=h.useState(1),i=s?Math.ceil(t/a):1;h.useEffect(()=>{n>i&&i>0&&queueMicrotask(()=>r(1))},[i,n]);const l=h.useCallback(m=>r(Math.max(1,Math.min(m,i))),[i]),o=h.useMemo(()=>va(n,i),[n,i]);return{currentPage:n,totalPages:i,goToPage:l,pageRange:o}}function Dn(t,a){const[s,n]=h.useState(null),r=h.useRef(0);return h.useEffect(()=>{var u,y;if(!a||!t.length)return;const i=((u=t[0])==null?void 0:u.timestamp)??0,l=i>r.current&&r.current>0;if(r.current=i,!l)return;const o=(y=t[0])==null?void 0:y.packet_hash;if(!o)return;const m=requestAnimationFrame(()=>n(o)),g=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(m),clearTimeout(g)}},[t,a]),s}function An(t){if(!t||t.length<6)return null;const a=t,s=parseInt(a.slice(0,2),16);if(isNaN(s))return null;const n=s&3;let r=2;if((n===0||n===3)&&(r=10),r+2>a.length)return null;const i=parseInt(a.slice(r,r+2),16);if(isNaN(i)||(r+=2+i*2,r>=a.length))return null;const l=a.slice(r);return l.length>=38?l.slice(0,38):l}function En(t){if(t.length<=1)return t;const a=new Map,s=new Map,n=new Map;for(let l=0;l<t.length;l++){const{packet:o}=t[l],m=o.payload_type??o.type;if(m!==lt.GRP_TXT)continue;const g=o._payloadHexPrefix??An(o.raw_packet);if(g){const j=a.get(g);if(j!==void 0){n.set(l,j);continue}a.set(g,l)}const u=o.payload_length??o.length??0,y=Math.floor((o.timestamp??0)/60),w=`${m}:${u}:${y}`;if(!g){const j=s.get(w);if(j!==void 0){n.set(l,j);continue}}s.has(w)||s.set(w,l)}if(n.size===0)return t;const r=new Map;for(const[l,o]of n)r.set(o,(r.get(o)??0)+t[l].dupeCount);const i=[];for(let l=0;l<t.length;l++){if(n.has(l))continue;const o=r.get(l)??0;i.push(o>0?{packet:t[l].packet,dupeCount:t[l].dupeCount+o}:t[l])}return i}function In(t){const a=new Map;for(const s of t)if((s.payload_type??s.type)===lt.TRACE&&s.packet_hash){const r=s._traceTag??(s.payload?It(s.payload):null);r&&a.set(s.packet_hash,r)}return a}function zn(t){const a=new Map;if(t.length===0)return a;for(let s=0;s<t.length;s++){const n=t[s].packet_hash;if(!n)continue;const r=t[s-1],i=t[s+1],l=(r==null?void 0:r.packet_hash)===n,o=(i==null?void 0:i.packet_hash)===n;(l||o)&&(l&&o?a.set(s,"middle"):l?a.set(s,"last"):o&&a.set(s,"first"))}return a}function St({message:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[e.jsx(de,{className:"size-6 text-fg-muted mb-2"}),e.jsx("p",{className:"text-sm text-fg-primary",children:t}),e.jsx("p",{className:"text-xs text-fg-muted",children:"Packets will appear here"})]})}function Tt(){return e.jsx("div",{className:"py-14 text-center text-sm text-fg-muted",children:"Loading packets…"})}function $n({showPagination:t,currentPage:a,perPage:s,displayCount:n,totalCount:r,action:i}){const l=t?(a-1)*s+1:1,o=t?Math.min(a*s,r):n;return e.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:[e.jsxs("span",{children:["Showing"," ",e.jsx("span",{className:"font-medium text-fg-secondary",children:t?`${l}–${o}`:n})," ","of"," ",e.jsx("span",{className:"font-medium text-fg-secondary",children:r})," ","packets"]}),i]})}function xr({packets:t,allPackets:a,localHash:s,neighbors:n,loading:r=!1,maxPackets:i,perPage:l=50,showPagination:o=!1,onPacketSelect:m,flashNewest:g=!1,emptyMessage:u="No packets found",className:y,footerAction:w,hideDupes:j=!1,getDecodedContent:x,onChannelClick:k,resolveSource:B,virtualized:d=!0}){Es(Xt);const[b,f]=h.useState(null),[_,v]=h.useState(null),[p,E]=h.useState({traceTag:null,dupeGroup:null}),O=h.useRef(null),G=ea(N=>N.setModalMapOpen);h.useEffect(()=>(G(!!b),()=>G(!1)),[b,G]),h.useLayoutEffect(()=>{E({traceTag:null,dupeGroup:null})},[t]);const K=a??t,D=h.useMemo(()=>i&&i>0&&!j?t.slice(0,i):t,[t,i,j]),Y=h.useMemo(()=>{if(!j)return null;const N=wa(D),C=En(N);return i&&i>0?C.slice(0,i):C},[D,j,i]),I=Y?Y.length:D.length,{currentPage:H,totalPages:$,goToPage:U,pageRange:J}=Fn(I,l,o),T=h.useMemo(()=>{if(j||!o)return D;const N=(H-1)*l;return D.slice(N,N+l)},[D,o,H,l,j]),z=h.useMemo(()=>{if(!Y)return null;if(!o)return Y;const N=(H-1)*l;return Y.slice(N,N+l)},[Y,o,H,l]),te=h.useMemo(()=>In(T),[T]),se=h.useMemo(()=>zn(T),[T]),c=Dn(t,g),Z=Hn(),q=h.useMemo(()=>j&&z?z:T,[j,z,T]),ie=d&&q.length>Pn,P=Z?Sn:Tn,F=Rs({count:ie?q.length:0,getScrollElement:()=>O.current,estimateSize:()=>P,overscan:Mn}),ae=h.useCallback((N,C)=>{var ve,Fe;const L=N.packet_hash;if(!L)return[N];let A=C;for(;A>0&&((ve=T[A-1])==null?void 0:ve.packet_hash)===L;)A--;let W=C;for(;W<T.length-1&&((Fe=T[W+1])==null?void 0:Fe.packet_hash)===L;)W++;return A===W?[N]:T.slice(A,W+1)},[T]),S=h.useCallback(N=>{var A,W;const C=(A=T[N])==null?void 0:A.packet_hash;if(!C)return N;let L=N;for(;L>0&&((W=T[L-1])==null?void 0:W.packet_hash)===C;)L--;return L},[T]),ce=h.useCallback(N=>{var A,W;const C=(A=T[N])==null?void 0:A.packet_hash;if(!C)return N;let L=N;for(;L<T.length-1&&((W=T[L+1])==null?void 0:W.packet_hash)===C;)L++;return L},[T]),pe=h.useCallback((N,C)=>{if(m){m(N);return}if(C!==void 0){const L=ae(N,C),A=L.indexOf(N);f({packets:L,initialIndex:A>=0?A:0,rowIndex:C})}else f({packets:[N],initialIndex:0,rowIndex:0})},[m,ae]),ne=h.useCallback(()=>{if(!b)return;const C=S(b.rowIndex)-1;if(C<0)return;const L=T[C];if(!L)return;const A=ae(L,C);f({packets:A,initialIndex:0,rowIndex:C})},[b,T,S,ae]),Be=h.useCallback(()=>{if(!b)return;const C=ce(b.rowIndex)+1;if(C>=T.length)return;const L=T[C];if(!L)return;const A=ae(L,C);f({packets:A,initialIndex:0,rowIndex:C})},[b,T,ce,ae]),ot=h.useMemo(()=>b?S(b.rowIndex)>0:!1,[b,S]),dt=h.useMemo(()=>b?ce(b.rowIndex)<T.length-1:!1,[b,ce,T.length]),be=h.useCallback(N=>E(C=>({...C,traceTag:N})),[]),Qe=h.useCallback(N=>E(C=>({...C,dupeGroup:N})),[]),Le=h.useCallback(()=>{E({traceTag:null,dupeGroup:null})},[]),Ne=h.useCallback(N=>{const C=K.filter(W=>(W.payload_type??W.type)===lt.TRACE&&W.payload&&It(W.payload)===N);if(C.length===0)return;const A=Ds(C).get(N);A!=null&&A.length&&v(As(N,A))},[K]),We=h.useCallback(N=>{const C=K.find(L=>L.packet_hash===N);C&&(v(null),pe(C))},[K,pe]),Re=h.useCallback((N,C,L)=>{const A=Z?Ba:La;if(L){const{packet:fe,dupeCount:es}=N,mt=fe.packet_hash?te.get(fe.packet_hash):void 0,ts=p.traceTag!==null&&mt===p.traceTag;return e.jsx(A,{packet:fe,onClick:ss=>pe(ss,C),localHash:s,neighbors:n,resolveSource:B,isFlashing:g&&c===fe.packet_hash,traceTag:mt,isTraceHighlighted:ts,onTraceHover:be,onViewTraceReport:Ne,dupeCount:es,getDecodedContent:x,onChannelClick:k},`${fe.packet_hash}_${fe.timestamp}_${C}`)}const W=N,ve=W.packet_hash?te.get(W.packet_hash):void 0,Fe=p.traceTag!==null&&ve===p.traceTag,xt=se.get(C),Jt=xt!==void 0&&p.dupeGroup!==null&&W.packet_hash===p.dupeGroup;return e.jsx(A,{packet:W,onClick:fe=>pe(fe,C),localHash:s,neighbors:n,resolveSource:B,isFlashing:g&&c===W.packet_hash,traceTag:ve,isTraceHighlighted:Fe,onTraceHover:be,onViewTraceReport:Ne,dupeGroupPosition:xt,isDupeGroupHovered:Jt,onDupeGroupHover:Qe,getDecodedContent:x,onChannelClick:k},`${W.packet_hash}_${W.timestamp}_${C}`)},[Z,te,p.traceTag,p.dupeGroup,pe,s,n,B,g,c,be,Ne,se,Qe,x,k]),He=()=>{if(r&&t.length===0)return e.jsx(Tt,{});if(T.length===0)return e.jsx(St,{message:u});const N=j&&z!==null;return(N?z:T).map((L,A)=>Re(L,A,N))},Q=()=>{if(r&&t.length===0)return e.jsx(Tt,{});if(q.length===0)return e.jsx(St,{message:u});const N=j&&z!==null,C=F.getVirtualItems();return e.jsx("div",{style:{height:`${F.getTotalSize()}px`,width:"100%",position:"relative"},children:C.map(L=>{const A=q[L.index];return e.jsx("div",{"data-index":L.index,ref:F.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${L.start}px)`},children:Re(A,L.index,N)},L.key)})})};return e.jsxs("div",{className:R("flex flex-col",y),onMouseLeave:Le,children:[ie?e.jsx("div",{ref:O,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Bn},children:Q()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:He()}),o&&$>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(fa,{className:"justify-center",children:[e.jsx(ga,{onClick:()=>U(H-1),disabled:H===1}),e.jsx(ja,{children:J.map((N,C)=>N==="gap"?e.jsx(Na,{},`gap-${C}`):e.jsx(ba,{page:N,current:N===H,onClick:U},N))}),e.jsx(ya,{onClick:()=>U(H+1),disabled:H===$})]})}),e.jsx($n,{showPagination:o,currentPage:H,perPage:l,displayCount:z?z.length:T.length,totalCount:o?I:t.length,action:w}),!m&&b&&e.jsx(wn,{packets:b.packets,initialIndex:b.initialIndex,onClose:()=>f(null),onNavigatePrev:ne,onNavigateNext:Be,hasPrev:ot,hasNext:dt,resolveSource:B,getDecodedContent:x}),_&&e.jsx(_n,{report:_,onClose:()=>v(null),onViewPacket:We})]})}export{qt as C,xr as P,ca as R,ft as S,gt as T,_a as g,dr as u};
