Files
pymc_console-dist/frontend/dist/assets/PacketDetailModal-CZsWoCT6.js
T
GitHub Actions Bot cbbe0885d9 Release v0.6.80
Automated sync from private repository.
Built with obfuscation enabled.
2025-12-28 06:08:29 +00:00

3 lines
24 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-DHnpIHEO.js","assets/index-B6-Tf7Us.js","assets/recharts-CGff6_7g.js","assets/maplibre-gl-DsiI67my.js","assets/index-CLg20r2M.css","assets/maplibre-gl-BvGn-5PG.js","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]);
import{c as e,j as t,n as a,o as n,p as s,q as r,_ as c,e as l,r as i,s as o,t as d,X as h,v as u}from"./index-B6-Tf7Us.js";import{b as m,c as x,g as p}from"./recharts-CGff6_7g.js";import{S as f,g as b}from"./SignalIndicator-B33CfoYD.js";import{H as v,M as g,a as N,C as y}from"./HashBadge-FDCoxkyp.js";import{T as w}from"./triangle-alert-CS-3a-_T.js";const k=e("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),M=e("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),T=e("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),C=e("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),D=e("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["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"}]]),P=e("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),R=e("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),A=e("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),E={0:"REQ",1:"RESPONSE",2:"TXT_MSG",3:"ACK",4:"ADVERT",5:"GRP_TXT",6:"GRP_DATA",7:"ANON_REQ",8:"PATH",9:"TRACE",10:"MULTIPART",15:"RAW_CUSTOM"},L={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"};function O(e){return null==e?"UNKNOWN":E[e]||`TYPE_${e}`}function _(e){return null==e?"UNKNOWN":L[e]||`ROUTE_${e}`}function S(e){return{ADVERT:"text-[var(--pkt-advert)]",FLOOD:"text-[var(--pkt-flood)]",TXT_MSG:"text-[var(--pkt-txt-msg)]",ACK:"text-[var(--pkt-ack)]",TRACE:"text-[var(--pkt-trace)]",REQ:"text-[var(--pkt-req)]",RESPONSE:"text-[var(--pkt-response)]",GRP_TXT:"text-[var(--pkt-grp-txt)]",GRP_DATA:"text-[var(--pkt-grp-data)]",PATH:"text-[var(--pkt-path)]",ANON_REQ:"text-[var(--pkt-anon)]"}[e]||"text-[var(--pkt-unknown)]"}function F(e){return{FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30",TRANSPORT:"bg-[var(--route-transport)]/20 text-[var(--route-transport)] border-[var(--route-transport)]/30",T_FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",T_DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30"}[e]||"bg-bg-subtle text-text-muted border-border-subtle"}function j(e){return 1===e||!0===e}function z(e){return"tx_local"===e.packet_origin?"tx":"tx_forward"===e.packet_origin?"forward":e.is_duplicate?"duplicate":e.transmitted?"forward":e.drop_reason?"dropped":"rx"}const H={rx:{icon:k,label:"RX",color:"text-accent-primary",bgColor:"bg-accent-primary/10"},tx:{icon:T,label:"TX",color:"text-[#F9D26F]",bgColor:"bg-[#F9D26F]/10"},forward:{icon:M,label:"FWD",color:"text-accent-success",bgColor:"bg-accent-success/10"},dropped:{icon:R,label:"DROP",color:"text-accent-danger",bgColor:"bg-accent-danger/10"},duplicate:{icon:k,label:"DUP",color:"text-text-muted",bgColor:"bg-white/5"}},q=m.memo(function({packet:e,showLabel:a=!0,size:n="sm"}){const s=z(e),r=H[s],c=r.icon;return t.jsxs("div",{className:x("inline-flex items-center gap-1 rounded-md",a&&"px-1.5 py-0.5",a&&r.bgColor),children:[t.jsx(c,{className:x({sm:"w-3.5 h-3.5",md:"w-4 h-4"}[n],r.color)}),a&&t.jsx("span",{className:x("text-[10px] font-semibold tracking-wide",r.color),children:r.label})]})});function U(e){return"tx_local"===e.packet_origin?"Transmitted":"tx_forward"===e.packet_origin||e.transmitted?"Forwarded":e.is_duplicate?"Duplicate":"No transport keys configured"===e.drop_reason?"Monitor Only":e.drop_reason?e.drop_reason:"Received"}function V(e){const t=z(e);return H[t].color}function $({packet:e,onClick:a,isFlashing:s=!1}){const r=e.payload_type_name||O(e.payload_type??e.type),c=e.route_type_name||_(e.route_type??e.route);return t.jsxs("tr",{onClick:()=>a(e),className:x("cursor-pointer","hover:bg-bg-subtle",j(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:[t.jsx("td",{className:"py-2.5 px-3",children:t.jsx(q,{packet:e,showLabel:!0})}),t.jsx("td",{className:"py-2.5 px-3 text-xs font-mono text-text-secondary whitespace-nowrap",children:n(e.timestamp)}),t.jsx("td",{className:"py-2.5 px-3",children:e.src_hash?t.jsx(v,{hash:e.src_hash,size:"xs"}):t.jsx("span",{className:"text-xs text-text-muted",children:"—"})}),t.jsx("td",{className:"py-2.5 px-3",children:t.jsx("span",{className:x("text-xs font-semibold",S(r)),children:r})}),t.jsx("td",{className:"py-2.5 px-3",children:t.jsx("span",{className:x("px-1.5 py-0.5 rounded text-[10px] border font-medium",F(c)),children:c})}),t.jsx("td",{className:"py-2.5 px-3 pr-4 text-right",children:t.jsx(f,{rssi:e.rssi,snr:e.snr,compact:!0,showValues:!0})})]})}const I=m.memo(function(e){return t.jsx(t.Fragment,{children:t.jsx($,{...e})})}),X=m.memo(function({packet:e,onClick:n,isFlashing:s=!1}){const r=e.payload_type_name||O(e.payload_type??e.type),c=e.route_type_name||_(e.route_type??e.route);return t.jsx("div",{onClick:()=>n(e),className:x("packet-row px-3 py-2.5 cursor-pointer","hover:bg-bg-subtle","active:bg-bg-elevated",j(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-14 flex-shrink-0",children:t.jsx(q,{packet:e,showLabel:!0,size:"sm"})}),t.jsx("span",{className:"text-[10px] font-mono text-text-muted w-7 flex-shrink-0",children:a(e.timestamp)}),t.jsx("div",{className:"w-9 flex-shrink-0",children:e.src_hash?t.jsx(v,{hash:e.src_hash,size:"xs"}):t.jsx("span",{className:"text-[10px] text-text-muted",children:"—"})}),t.jsx("span",{className:x("text-xs font-semibold truncate flex-1 min-w-0",S(r)),children:r}),t.jsx("div",{className:"w-14 flex-shrink-0",children:t.jsx("span",{className:x("px-1 py-0.5 rounded text-[9px] border font-medium",F(c)),children:c})}),t.jsx("div",{className:"w-10 flex-shrink-0 text-right",children:t.jsx(f,{rssi:e.rssi,compact:!0,showValues:!0})})]})})});function G(e){if(e.contact_type){const t=e.contact_type.toLowerCase();if("repeater"===t||"rep"===t)return!0;if("companion"===t||"client"===t||"cli"===t)return!1;if("room server"===t||"room_server"===t||"room"===t||"server"===t)return!1}return!0===e.is_repeater||(e.is_repeater,!1)}const Q=m.lazy(()=>c(()=>import("./PathMapMapLibre-DHnpIHEO.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function W(e){return`${(100*e).toFixed(0)}%`}function K(e,t){const a="#767688";let n;return n=0===t?a:e>=1?"#39D98A":e>=.5?"#F9D26F":e>=.25?"#FF8A5C":e>0?"#FF5C7A":a,{color:n}}class B extends m.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t.jsxs("div",{className:"h-[200px] flex items-center justify-center text-text-muted",children:[t.jsx(w,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function J({path:e,neighbors:a,localNode:n,localHash:c,srcHash:l,dstHash:i,neighborAffinity:o,prefixLookup:d,hubNodes:h}){const[u,p]=m.useState(null),f=m.useMemo(()=>{if(!l)return null;const e=r(l),t=a[l];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:l,name:t.node_name||t.name||"Source",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isSource:!0};const n=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||l.slice(0,8);return{prefix:e,candidates:[{hash:l,name:n,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[l,a]),b=m.useMemo(()=>{if(!i)return null;const e=r(i);if(c&&i===c&&n){const t=0!==n.latitude||0!==n.longitude;return{prefix:e,candidates:[{hash:i,name:n.name||"Local Node",latitude:t?n.latitude:0,longitude:t?n.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const t=a[i];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:i,name:t.node_name||t.name||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const s=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||i.slice(0,8);return{prefix:e,candidates:[{hash:i,name:s,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,n,c]),v=m.useMemo(()=>function(e,t,a,n,r,c){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=e.length-1,i=e.map((i,o)=>{const d=o===l,h=e.length-o,{candidates:u,totalMatches:m}=function(e,t,a,n,r=!1,c,l,i){const o=function(e){const t={};for(const[a,n]of Object.entries(e))G(n)&&(t[a]=n);return t}(t);let d;if(l){const t=function(e,t,a){const n=t.toUpperCase(),s=e.get(n);if(!s||0===s.candidates.length)return{hash:null,confidence:0};if(null==a?void 0:a.isLastHop)return{hash:s.bestMatch,confidence:s.confidence};if(1===(null==a?void 0:a.position))return{hash:s.bestMatch,confidence:s.confidence};if((null==a?void 0:a.position)&&s.bestMatchForPosition.has(a.position)){const e=s.bestMatchForPosition.get(a.position),t=Math.max(e.confidence,s.confidence);return{hash:e.hash,confidence:t}}if((null==a?void 0:a.adjacentPrefixes)&&a.adjacentPrefixes.length>0){let e=s.bestMatch,t=0;for(const n of s.candidates){let s=0;for(const e of a.adjacentPrefixes)s+=n.adjacentPrefixCounts.get(e.toUpperCase())||0;const r=n.combinedScore+s/Math.max(1,n.totalAdjacentObservations)*.3;r>t&&(t=r,e=n.hash)}return{hash:e,confidence:s.confidence}}return{hash:s.bestMatch,confidence:s.confidence}}(l,e,{position:i,isLastHop:r});d=t.confidence}const{matches:h,probability:u}=function(e,t,a,n,r=!1){const c=e.toUpperCase(),l=[],i=a&&s(c,a);i&&l.push(a);for(const x of Object.keys(t))s(c,x)&&l.push(x);if(r&&i&&a&&1===l.length)return{matches:l,probability:1,bestMatch:a};if(r&&i&&l.length>1){const e=l.filter(e=>e!==a);if(1===e.length)return{matches:l,probability:1,bestMatch:e[0]}}const o=l.length>0?1/l.length:0,d=[...l].sort();let h=null,u=-1;if(1===d.length)h=d[0];else if(d.length>1&&n){for(const e of d){const t=n.get(e),a=t?"number"==typeof t?t:t.combinedScore:0;a>u&&(u=a,h=e)}h||(h=d[0])}else d.length>0&&(h=d[0]);let m=o;if(l.length>1&&n&&u>0){let e=0;for(const t of l){const a=n.get(t);e+=a?"number"==typeof a?a:a.combinedScore:0}e>0&&(m=Math.min(.95,u/e))}return{matches:l,probability:m,bestMatch:h}}(e,o,n,c,r),m=h.length,x=[],p=e.toUpperCase(),f=a&&void 0!==a.latitude&&void 0!==a.longitude&&(0!==a.latitude||0!==a.longitude);for(const v of h){if(n&&s(p,n)&&v===n&&f&&a){x.push({hash:v,name:a.name||"Local Node",latitude:a.latitude,longitude:a.longitude,probability:r?1:u,isLocal:!0});continue}const e=o[v];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&x.push({hash:v,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:u,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const b=x.length;if(1===b)x[0].probability=d??1;else if(b>1)if(void 0!==d&&d>0){x[0].probability=d;const e=1-d,t=b-1;x.slice(1).forEach(a=>{a.probability=e/t})}else{let e=0;const t=x.map(t=>{if(t.isLocal)return{candidate:t,score:1};const n=null==c?void 0:c.get(t.hash);let s=.5;var r;let l;return f&&a&&(s=(r=function(e,t,a,n){const s=(a-e)*Math.PI/180,r=(n-t)*Math.PI/180,c=Math.sin(s/2)*Math.sin(s/2)+Math.cos(e*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3}(a.latitude,a.longitude,t.latitude,t.longitude))<100?1:r<500?.9:r<1e3?.7:r<5e3?.5:r<1e4?.3:.1),n?l=.3*s+.3*n.hopConsistencyScore+.4*n.frequencyScore:(l=s,t.isDirectNeighbor&&(l=Math.max(l,.8))),e+=l,{candidate:t,score:l}});if(e>0)t.forEach(({candidate:t,score:a})=>{t.probability=Math.min(.95,a/e)});else{const e=1/b;x.forEach(t=>t.probability=e)}}return{candidates:x,totalMatches:m}}(i,t,a,n,d,r,c,h),x=u.length>0?Math.max(...u.map(e=>e.probability)):0;return{prefix:i,candidates:u,confidence:x,totalMatches:m}}),o=i.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),d=i.some(e=>e.candidates.length>0);return{hops:i,overallConfidence:o,hasValidPath:d}}(e,a,n,c,o,d),[e,a,n,c,o,d]),N=m.useMemo(()=>{const e=[];f&&e.push(f),e.push(...v.hops),b&&e.push(b);const t=e.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),a=e.some(e=>e.candidates.some(e=>0!==e.latitude||0!==e.longitude));return{hops:e,overallConfidence:t,hasValidPath:a}},[f,v,b]);return N.hasValidPath?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-text-muted",children:"Path Confidence:"}),t.jsx("span",{className:(y=N.overallConfidence,y>=1?"text-accent-success":y>=.5?"text-accent-secondary":y>=.25?"text-signal-poor":y>0?"text-accent-danger":"text-text-muted"),children:W(N.overallConfidence)}),t.jsx("button",{className:"text-text-muted hover:text-text-secondary transition-colors",title:"Confidence is calculated based on how many known nodes match each path prefix. Multiple matches reduce confidence due to collision probability.",children:t.jsx(D,{className:"w-3 h-3"})})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),t.jsx("span",{className:"text-text-muted",children:"Exact"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),t.jsx("span",{className:"text-text-muted",children:"Multi"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),t.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),t.jsx("div",{className:"rounded-lg overflow-hidden border border-border-subtle",children:t.jsx(B,{children:t.jsx(m.Suspense,{fallback:t.jsx("div",{className:"h-[200px] bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:t.jsx(Q,{resolvedPath:N,localNode:n,hubNodes:h,hoveredHopIndex:u,onHoverHop:p})})})}),t.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:N.hops.map((e,a)=>{var n,s,r;const c=!0===e.isSource,l=!0===e.isDestination,i=u===a;let o;return o=c?`Source: ${(null==(n=e.candidates[0])?void 0:n.name)||"Unknown"}`:l?`Destination: ${(null==(s=e.candidates[0])?void 0:s.name)||"Unknown"}`:0===e.totalMatches?"No matching nodes found":1===e.totalMatches?`Exact match: ${(null==(r=e.candidates[0])?void 0:r.name)||"Unknown"}`:`${e.totalMatches} possible matches (${(100*e.confidence).toFixed(0)}% confidence)`,t.jsxs("div",{className:x("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono cursor-pointer transition-all",i?"bg-accent-primary/20 ring-1 ring-accent-primary/50":"bg-bg-elevated hover:bg-bg-subtle",c&&"border border-accent-success/30",l&&"border border-accent-primary/30"),title:o,onMouseEnter:()=>p(a),onMouseLeave:()=>p(null),children:[c&&t.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),l&&t.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),t.jsx("span",{style:K(e.confidence,e.totalMatches),children:e.prefix}),!c&&!l&&e.totalMatches>1&&t.jsxs("span",{className:"text-text-muted",children:["×",e.totalMatches]}),!c&&!l&&0===e.totalMatches&&t.jsx("span",{className:"text-text-muted",children:"?"})]},a)})})]}):t.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[t.jsx(g,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var y}function Y(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Z({label:e,children:a,compact:n=!1}){return t.jsxs("div",{className:x("flex flex-col",n?"gap-0.5":"gap-1"),children:[t.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:e}),t.jsx("span",{className:x("text-text-primary",n?"text-xs":"text-sm"),children:a})]})}function ee({onClick:e,copied:a}){return t.jsx("button",{onClick:t=>{t.stopPropagation(),e()},className:"p-1 rounded hover:bg-bg-subtle transition-colors",children:a?t.jsx(N,{className:"w-3 h-3 text-accent-success"}):t.jsx(y,{className:"w-3 h-3 text-text-muted"})})}function te({originalPath:e,forwardedPath:a}){const n=a.length>0?a:e;return 0===n.length?t.jsx("span",{className:"text-xs text-text-muted",children:"No path data"}):t.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n.map((e,a)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(v,{hash:e,size:"xs"}),a<n.length-1&&t.jsx(M,{className:"w-3 h-3 text-text-muted flex-shrink-0"})]},a))})}const ae=m.memo(function({packet:e,onClose:a}){var n;const[s,r]=m.useState(!1),[c,g]=m.useState(!0),[w,k]=m.useState(null);m.useEffect(()=>{const e=e=>{"Escape"===e.key&&a()};window.addEventListener("keydown",e);const t=document.body.style.overflow,n=document.body.style.position,s=document.body.style.width,r=document.body.style.top,c=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${c}px`,()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t,document.body.style.position=n,document.body.style.width=s,document.body.style.top=r,window.scrollTo(0,c)}},[a]);const M=l(),T=i(),D=o(),P=e.payload_type_name||O(e.payload_type??e.type),R=e.route_type_name||_(e.route_type??e.route),E=e.payload_length??e.length??0,L=e.tx_delay_ms??0,j=Y(e.original_path),z=Y(e.forwarded_path),H=j.length>0||z.length>0,$=z.length>0?z:j,I=m.useMemo(()=>{var e;if(null==(e=null==M?void 0:M.config)?void 0:e.repeater)return{latitude:M.config.repeater.latitude,longitude:M.config.repeater.longitude,name:M.config.node_name||"Local Node"}},[M]),X=(null==M?void 0:M.neighbors)??{},G=D.size>0?D:void 0,Q=function(e){var t;if(!e)return{text:null,isText:!1};try{if(/^[0-9a-fA-F]+$/.test(e)){const a=(null==(t=e.match(/.{1,2}/g))?void 0:t.map(e=>parseInt(e,16)))||[],n=String.fromCharCode(...a),s=n.replace(/[^\x20-\x7E]/g,"");if(s.length>.7*n.length)return{text:s,isText:!0}}if(/^[\x20-\x7E\s]+$/.test(e))return{text:e,isText:!0}}catch{}return{text:null,isText:!1}}(e.payload),W=e.payload&&e.payload.length>0,K=e.raw_packet&&e.raw_packet.length>0,B=m.useCallback(async(e,t)=>{try{await navigator.clipboard.writeText(e),k(t),setTimeout(()=>k(null),2e3)}catch{}},[]);return p.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:a,role:"dialog","aria-modal":"true","aria-labelledby":"packet-modal-title",children:t.jsxs("div",{className:x("glass-card w-full max-h-[90vh] overflow-hidden flex flex-col","sm:max-w-xl sm:mx-4 sm:rounded-xl","rounded-t-2xl rounded-b-none sm:rounded-b-xl","pb-safe"),onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(q,{packet:e,showLabel:!0,size:"md"}),t.jsxs("div",{children:[t.jsx("h3",{id:"packet-modal-title",className:x("text-base font-semibold",S(P)),children:P}),t.jsx("p",{className:"text-xs text-text-muted",children:d(e.timestamp)})]})]}),t.jsx("button",{onClick:a,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:t.jsx(h,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4 overscroll-contain",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Z,{label:"Packet Hash",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v,{hash:e.packet_hash,size:"sm"}),t.jsx(ee,{onClick:()=>B(e.packet_hash,"hash"),copied:"hash"===w})]})}),t.jsx(Z,{label:"Route",children:t.jsx("span",{className:x("px-2 py-0.5 rounded text-xs border font-medium",F(R)),children:R})})]}),t.jsx("div",{className:"glass-card p-3 bg-bg-elevated/50",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-text-muted mb-1",children:"Signal Quality"}),t.jsx("p",{className:"text-sm font-medium text-text-primary",children:b(e.rssi)})]}),t.jsx(f,{rssi:e.rssi,snr:e.snr,showValues:!0})]})}),(e.src_hash||e.dst_hash)&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.src_hash&&t.jsx(Z,{label:"Source",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v,{hash:e.src_hash,size:"sm"}),t.jsx(ee,{onClick:()=>B(e.src_hash,"src"),copied:"src"===w})]})}),e.dst_hash&&t.jsx(Z,{label:"Destination",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(v,{hash:e.dst_hash,size:"sm"}),t.jsx(ee,{onClick:()=>B(e.dst_hash,"dst"),copied:"dst"===w})]})})]}),H&&t.jsxs("div",{className:"glass-card p-3 bg-bg-elevated/50",children:[t.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Packet Path"}),t.jsx(te,{originalPath:j,forwardedPath:z})]}),H&&$.length>0&&t.jsxs("div",{className:"glass-card bg-bg-elevated/50 overflow-hidden",children:[t.jsxs("button",{onClick:()=>g(!c),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(A,{className:"w-4 h-4 text-accent-primary"}),t.jsx("span",{className:"text-xs text-text-secondary font-medium",children:"Path Map"})]}),c?t.jsx(u,{className:"w-4 h-4 text-text-muted"}):t.jsx(C,{className:"w-4 h-4 text-text-muted"})]}),c&&t.jsx("div",{className:"px-3 pb-3",children:t.jsx(J,{path:$,neighbors:X,localNode:I,localHash:null==M?void 0:M.local_hash,srcHash:e.src_hash,dstHash:e.dst_hash,neighborAffinity:G,hubNodes:[...T]})})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsx(Z,{label:"Size",compact:!0,children:t.jsxs("span",{className:"font-mono",children:[E,"B"]})}),t.jsx(Z,{label:"TX Delay",compact:!0,children:t.jsxs("span",{className:"font-mono",children:[L.toFixed(1),"ms"]})}),t.jsx(Z,{label:"Score",compact:!0,children:t.jsx("span",{className:"font-mono",children:void 0!==e.score?e.score.toFixed(3):"—"})})]}),t.jsx(Z,{label:"Status",children:t.jsx("span",{className:V(e),children:U(e)})}),W&&t.jsxs("div",{className:"glass-card p-3 bg-bg-elevated/50",children:[t.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Payload"}),Q.isText&&Q.text?t.jsx("div",{className:"bg-bg-base rounded p-2",children:t.jsx("p",{className:"text-sm text-text-primary font-mono break-all",children:Q.text})}):t.jsxs("p",{className:"text-xs text-text-muted font-mono break-all",children:[null==(n=e.payload)?void 0:n.slice(0,100),e.payload&&e.payload.length>100&&"..."]})]}),K&&t.jsxs("div",{className:"glass-card bg-bg-elevated/50 overflow-hidden",children:[t.jsxs("button",{onClick:()=>r(!s),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[t.jsx("span",{className:"text-xs text-text-muted",children:"Raw Packet Hex"}),s?t.jsx(u,{className:"w-4 h-4 text-text-muted"}):t.jsx(C,{className:"w-4 h-4 text-text-muted"})]}),s&&t.jsx("div",{className:"px-3 pb-3",children:t.jsxs("div",{className:"bg-bg-base rounded p-2 relative",children:[t.jsx("pre",{className:"text-[10px] text-text-secondary font-mono break-all whitespace-pre-wrap",children:e.raw_packet}),t.jsx("button",{onClick:()=>B(e.raw_packet,"raw"),className:"absolute top-2 right-2 p-1 rounded bg-bg-elevated hover:bg-bg-subtle transition-colors",children:"raw"===w?t.jsx(N,{className:"w-3 h-3 text-accent-success"}):t.jsx(y,{className:"w-3 h-3 text-text-muted"})})]})})]})]})]})}),document.body)});export{M as A,P as C,I as P,L as R,X as a,ae as b,z as c,k as d,E as e,O as g};