From f1ba7bed238cb06bce95676db060ed2fe64dec22 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Thu, 29 Jan 2026 18:29:14 +0000 Subject: [PATCH] Sync build v0.9.195 Automated sync from private repository. Commit: f0b9f5cc884f073df6c5886e881f1792c4705296 --- frontend/dist/VERSION | 2 +- frontend/dist/assets/{Card-BeZKc0xw.js => Card-2pQSGkKC.js} | 2 +- ...erModal-Vkgg9Koo.js => CollisionExplorerModal-DTnzK_xA.js} | 2 +- .../{Configuration-_CjN4yUe.js => Configuration-BOsliPZn.js} | 2 +- .../{ConfirmModal-DlFyryXJ.js => ConfirmModal-CYXFGX_W.js} | 2 +- .../assets/{Contacts-BcOss4J-.js => Contacts-CyyU4xmf.js} | 4 ++-- ...apMapLibre-JEW0aWu6.js => ContactsMapMapLibre-ByNdgqAN.js} | 2 +- .../assets/{Dashboard-BIMfl_CK.js => Dashboard-DiETwG01.js} | 2 +- ...nalysisModal-DysenxvY.js => DeepAnalysisModal-D4eqwCNZ.js} | 2 +- frontend/dist/assets/{Login-zWarN3Ve.js => Login-CkRuF4n8.js} | 2 +- frontend/dist/assets/{Logs-EKbeyhLl.js => Logs-Cb5GXQFD.js} | 2 +- .../assets/{MeshGraph-CdoFbL_m.js => MeshGraph-DfCwG9Nt.js} | 2 +- ...mationCard-D-IeNCCX.js => NodeInformationCard-CEW2bogB.js} | 2 +- .../assets/{PacketList-CnSxB7Jy.js => PacketList-BPeOqxkB.js} | 4 ++-- .../dist/assets/{Packets-DHxvwdwr.js => Packets-BHJJxf8a.js} | 2 +- .../assets/{PageLayout-CcoYWyzO.js => PageLayout-CnF5SScd.js} | 2 +- ...athMapMapLibre-Ouls8uhs.js => PathMapMapLibre-ChIFu4o3.js} | 2 +- .../assets/{Statistics-DqgywSJF.js => Statistics-sXHAGtEF.js} | 2 +- .../dist/assets/{System-Cw2qx9Xo.js => System-BPwbPFCW.js} | 2 +- .../assets/{Terminal-BQEu4TKw.js => Terminal-jVZnyeIH.js} | 2 +- frontend/dist/assets/{index-CPdqYR4z.js => index-BJEgt3tp.js} | 4 ++-- .../{link-scoring-BNnTohl3.js => link-scoring-Cw0dJsWv.js} | 2 +- frontend/dist/assets/{ping-BvkXSZG_.js => ping-DvLgBqTv.js} | 2 +- frontend/dist/index.html | 2 +- frontend/package.json | 2 +- 25 files changed, 28 insertions(+), 28 deletions(-) rename frontend/dist/assets/{Card-BeZKc0xw.js => Card-2pQSGkKC.js} (96%) rename frontend/dist/assets/{CollisionExplorerModal-Vkgg9Koo.js => CollisionExplorerModal-DTnzK_xA.js} (99%) rename frontend/dist/assets/{Configuration-_CjN4yUe.js => Configuration-BOsliPZn.js} (99%) rename frontend/dist/assets/{ConfirmModal-DlFyryXJ.js => ConfirmModal-CYXFGX_W.js} (95%) rename frontend/dist/assets/{Contacts-BcOss4J-.js => Contacts-CyyU4xmf.js} (98%) rename frontend/dist/assets/{ContactsMapMapLibre-JEW0aWu6.js => ContactsMapMapLibre-ByNdgqAN.js} (99%) rename frontend/dist/assets/{Dashboard-BIMfl_CK.js => Dashboard-DiETwG01.js} (99%) rename frontend/dist/assets/{DeepAnalysisModal-DysenxvY.js => DeepAnalysisModal-D4eqwCNZ.js} (98%) rename frontend/dist/assets/{Login-zWarN3Ve.js => Login-CkRuF4n8.js} (99%) rename frontend/dist/assets/{Logs-EKbeyhLl.js => Logs-Cb5GXQFD.js} (92%) rename frontend/dist/assets/{MeshGraph-CdoFbL_m.js => MeshGraph-DfCwG9Nt.js} (99%) rename frontend/dist/assets/{NodeInformationCard-D-IeNCCX.js => NodeInformationCard-CEW2bogB.js} (90%) rename frontend/dist/assets/{PacketList-CnSxB7Jy.js => PacketList-BPeOqxkB.js} (99%) rename frontend/dist/assets/{Packets-DHxvwdwr.js => Packets-BHJJxf8a.js} (97%) rename frontend/dist/assets/{PageLayout-CcoYWyzO.js => PageLayout-CnF5SScd.js} (98%) rename frontend/dist/assets/{PathMapMapLibre-Ouls8uhs.js => PathMapMapLibre-ChIFu4o3.js} (99%) rename frontend/dist/assets/{Statistics-DqgywSJF.js => Statistics-sXHAGtEF.js} (99%) rename frontend/dist/assets/{System-Cw2qx9Xo.js => System-BPwbPFCW.js} (98%) rename frontend/dist/assets/{Terminal-BQEu4TKw.js => Terminal-jVZnyeIH.js} (99%) rename frontend/dist/assets/{index-CPdqYR4z.js => index-BJEgt3tp.js} (99%) rename frontend/dist/assets/{link-scoring-BNnTohl3.js => link-scoring-Cw0dJsWv.js} (94%) rename frontend/dist/assets/{ping-BvkXSZG_.js => ping-DvLgBqTv.js} (94%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index 64e40caa..9f3f28b1 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.194 +0.9.195 diff --git a/frontend/dist/assets/Card-BeZKc0xw.js b/frontend/dist/assets/Card-2pQSGkKC.js similarity index 96% rename from frontend/dist/assets/Card-BeZKc0xw.js rename to frontend/dist/assets/Card-2pQSGkKC.js index 770aeee0..e2596716 100644 --- a/frontend/dist/assets/Card-BeZKc0xw.js +++ b/frontend/dist/assets/Card-2pQSGkKC.js @@ -1 +1 @@ -import{j as e}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{B as t}from"./index-CPdqYR4z.js";function l({title:l,icon:r,badge:i,subtitle:a,actions:c,iconColor:n="text-icon-card-title",largeTitle:x=!1,listHeader:m=!1,stackActionsOnMobile:d=!1}){return d&&c?e.jsxs("div",{className:s("flex flex-col gap-1 flex-shrink-0",m?"px-4 py-3 border-b border-border-subtle bg-bg-elevated/20":"mb-3"),children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 min-h-[32px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("span",{className:s("icon-md flex items-center justify-center",n),children:r}),e.jsx("span",{className:s(x?"type-subheading text-text-primary":"type-micro"),children:l}),i&&e.jsx(t,{color:"teal",children:i})]}),e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:c})]}),a&&e.jsx("p",{className:"type-label text-text-muted ml-8",children:a})]}):e.jsxs("div",{className:s("flex flex-col gap-1 flex-shrink-0",m?"px-4 py-3 border-b border-border-subtle bg-bg-elevated/20":"mb-3"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-[32px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("span",{className:s("icon-md flex items-center justify-center",n),children:r}),e.jsx("span",{className:s(x?"type-subheading text-text-primary":"type-micro"),children:l}),i&&e.jsx(t,{color:"teal",children:i})]}),c&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:c})]}),a&&e.jsx("p",{className:"type-label text-text-muted ml-8",children:a})]})}function r({children:t,centered:l,className:r}){return e.jsx("div",{className:s("flex-1 min-h-0",l&&"flex items-center justify-center",r),children:t})}export{l as C,r as a}; +import{j as e}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{B as t}from"./index-BJEgt3tp.js";function l({title:l,icon:r,badge:i,subtitle:a,actions:c,iconColor:n="text-icon-card-title",largeTitle:x=!1,listHeader:m=!1,stackActionsOnMobile:d=!1}){return d&&c?e.jsxs("div",{className:s("flex flex-col gap-1 flex-shrink-0",m?"px-4 py-3 border-b border-border-subtle bg-bg-elevated/20":"mb-3"),children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 min-h-[32px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("span",{className:s("icon-md flex items-center justify-center",n),children:r}),e.jsx("span",{className:s(x?"type-subheading text-text-primary":"type-micro"),children:l}),i&&e.jsx(t,{color:"teal",children:i})]}),e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:c})]}),a&&e.jsx("p",{className:"type-label text-text-muted ml-8",children:a})]}):e.jsxs("div",{className:s("flex flex-col gap-1 flex-shrink-0",m?"px-4 py-3 border-b border-border-subtle bg-bg-elevated/20":"mb-3"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-[32px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx("span",{className:s("icon-md flex items-center justify-center",n),children:r}),e.jsx("span",{className:s(x?"type-subheading text-text-primary":"type-micro"),children:l}),i&&e.jsx(t,{color:"teal",children:i})]}),c&&e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:c})]}),a&&e.jsx("p",{className:"type-label text-text-muted ml-8",children:a})]})}function r({children:t,centered:l,className:r}){return e.jsx("div",{className:s("flex-1 min-h-0",l&&"flex items-center justify-center",r),children:t})}export{l as C,r as a}; diff --git a/frontend/dist/assets/CollisionExplorerModal-Vkgg9Koo.js b/frontend/dist/assets/CollisionExplorerModal-DTnzK_xA.js similarity index 99% rename from frontend/dist/assets/CollisionExplorerModal-Vkgg9Koo.js rename to frontend/dist/assets/CollisionExplorerModal-DTnzK_xA.js index e1fa1720..8439d00b 100644 --- a/frontend/dist/assets/CollisionExplorerModal-Vkgg9Koo.js +++ b/frontend/dist/assets/CollisionExplorerModal-DTnzK_xA.js @@ -1 +1 @@ -import{r as e,j as s,at as t,ar as a,bj as o,bk as i,bl as l,bm as n,aU as r,$ as d,a0 as c,bn as u,aV as h}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{n as m}from"./recharts-6XUQYgRA.js";import{e as x,J as p,f as v,N as b,O as g,H as f,B as j}from"./index-CPdqYR4z.js";import{u as N,B as y}from"./BasemapLayer-S9Ush6Hh.js";const w={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"};function H({node:t,isHovered:a,onHover:o}){const[i,l]=e.useState(!1),n=e.useCallback(e=>{var s,a;e.stopPropagation(),s=t.hash,(null==(a=navigator.clipboard)?void 0:a.writeText)&&navigator.clipboard.writeText(s).catch(()=>{}),l(!0),setTimeout(()=>l(!1),2e3)},[t.hash]),x=t.contactType.toLowerCase(),p=x.includes("room")||x.includes("server");let v=r,b="text-accent-primary";return p?(v=u,b="text-signal-fair"):"companion"===x||"client"===x?(v=h,b="text-text-muted"):t.isNeighbor&&(b="text-accent-success"),s.jsxs("div",{className:m("flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer",a?"bg-accent-primary/10":"hover:bg-white/[0.03]"),onMouseEnter:()=>o(t.hash),onMouseLeave:()=>o(null),children:[s.jsx(v,{className:m("w-4 h-4 flex-shrink-0",b)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:t.name}),t.isNeighbor&&s.jsx(j,{color:"green",compact:!0,children:"NBR"}),t.isRepeater&&s.jsx(j,{color:"zinc",compact:!0,children:"RPT"}),t.isHub&&s.jsx(j,{color:"purple",compact:!0,children:"HUB"})]}),s.jsxs("button",{onClick:n,className:m("mt-1 inline-flex items-center gap-1 text-[10px] font-mono px-1.5 py-0.5 rounded","border transition-all cursor-pointer",i?"border-accent-success/50 bg-accent-success/10 text-accent-success":"border-border-subtle bg-bg-subtle/50 text-text-muted hover:border-border-strong"),title:`Copy: ${t.hash}`,children:[t.hash.slice(0,12),"…",i?s.jsx(d,{className:"w-2.5 h-2.5"}):s.jsx(c,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:t,hoveredHash:r,onHover:d}){const c=N(),u=e.useRef(null),h=f(),[x,p]=e.useState(!1),v=e.useMemo(()=>t.filter(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[t]),b=e.useMemo(()=>{if(0===v.length)return null;let e=1/0,s=-1/0,t=1/0,a=-1/0;for(const o of v)e=Math.min(e,o.longitude),s=Math.max(s,o.longitude),t=Math.min(t,o.latitude),a=Math.max(a,o.latitude);if(a-t<.01){const e=(a+t)/2;t=e-.005,a=e+.005}if(s-e<.01){const t=(s+e)/2;e=t-.005,s=t+.005}return[[e,t],[s,a]]},[v]),g=e.useMemo(()=>b?{longitude:(b[0][0]+b[1][0])/2,latitude:(b[0][1]+b[1][1])/2}:{longitude:0,latitude:0},[b]),H=e.useMemo(()=>{if(v.length<2)return null;const e=[];for(let s=0;s{var e;const s=null==(e=u.current)?void 0:e.getMap();s&&b?(s.fitBounds(b,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>p(!0),50)):p(!0)},[b]),M=h&&x;return 0===v.length?s.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 rounded-lg",children:s.jsxs("div",{className:"text-center text-text-secondary p-4",children:[s.jsx(a,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),s.jsx("p",{className:"text-sm",children:"No location data available"})]})}):s.jsxs("div",{className:"h-full w-full relative rounded-lg overflow-hidden bg-bg-elevated",children:[s.jsx("div",{className:m("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",M?"opacity-0":"opacity-100 bg-bg-elevated"),children:s.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),s.jsx("div",{className:m("h-full w-full transition-opacity duration-200",M?"opacity-100":"opacity-0"),children:s.jsxs(o,{ref:u,initialViewState:{longitude:g.longitude,latitude:g.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:w,attributionControl:!1,onLoad:C,children:[s.jsx(y,{mode:c}),H&&s.jsx(i,{id:"collision-edges",type:"geojson",data:H,children:s.jsx(l,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),v.map(e=>{const t=e.hash===r,a=e.hash.startsWith("0x")?e.hash.slice(2,4).toUpperCase():e.hash.slice(0,2).toUpperCase();return s.jsx(n,{longitude:e.longitude,latitude:e.latitude,anchor:"center",children:s.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>d(e.hash),onMouseLeave:()=>d(null),style:{pointerEvents:"auto"},children:s.jsxs(j,{color:"amber",filled:!0,className:"font-mono text-[10px] shadow-lg",children:[a,t&&s.jsx("span",{className:"ml-1 opacity-75 font-sans",children:e.name})]})})},e.hash)})]})})]})}const M=e.memo(function({isOpen:a,prefix:o,candidateHashes:i,onClose:l}){const n=x(),r=p(),d=v(),[c,u]=e.useState(null),h=e.useMemo(()=>new Set(d.map(e=>e.hash)),[d]),m=(null==n?void 0:n.neighbors)??{},f=e.useMemo(()=>i.map(e=>{var s;const t=(e=>m[e]?m[e]:!e.startsWith("0x")&&m["0x"+e]?m["0x"+e]:e.startsWith("0x")&&m[e.slice(2)]?m[e.slice(2)]:void 0)(e);return{hash:e,name:(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==t?void 0:t.contact_type)||"",isRepeater:(null==t?void 0:t.is_repeater)||"repeater"===(null==(s=null==t?void 0:t.contact_type)?void 0:s.toLowerCase())||!1,isNeighbor:h.has(e)||h.has("0x"+e)||h.has(e.replace(/^0x/,"")),isHub:r.has(e),latitude:null==t?void 0:t.latitude,longitude:null==t?void 0:t.longitude}}).sort((e,s)=>e.isNeighbor!==s.isNeighbor?e.isNeighbor?-1:1:e.isHub!==s.isHub?e.isHub?-1:1:e.name.localeCompare(s.name)),[i,m,h,r]),j=e.useMemo(()=>f.some(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[f]),N=e.useCallback(e=>{u(e)},[]),y=j?"4xl":"lg";return a?s.jsxs(b,{open:a,onClose:l,size:y,motionPlus:!0,className:j?"sm:h-[500px] sm:max-h-[600px]":"",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-signal-fair/10",children:s.jsx(t,{className:"w-5 h-5 text-signal-fair"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",s.jsx("span",{className:"font-mono text-accent-primary",children:o})]}),s.jsxs("p",{className:"text-xs text-text-secondary",children:[f.length," nodes share this prefix"]})]})]}),s.jsx("button",{onClick:l,className:"p-2 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-bg-subtle",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs(g,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[j&&s.jsx("div",{className:"h-64 p-2 border-b border-border-subtle",children:s.jsx(C,{nodes:f,hoveredHash:c,onHover:N})}),s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})]}),j?s.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[s.jsx("div",{className:"overflow-y-auto border-r border-border-subtle",children:s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})}),s.jsx("div",{className:"overflow-hidden p-2",children:s.jsx(C,{nodes:f,hoveredHash:c,onHover:N})})]}):s.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})})]})]}):null});export{M as C}; +import{r as e,j as s,at as t,ar as a,bj as o,bk as i,bl as l,bm as n,aU as r,$ as d,a0 as c,bn as u,aV as h}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{n as m}from"./recharts-6XUQYgRA.js";import{e as x,J as p,f as v,N as b,O as g,H as f,B as j}from"./index-BJEgt3tp.js";import{u as N,B as y}from"./BasemapLayer-S9Ush6Hh.js";const w={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"};function H({node:t,isHovered:a,onHover:o}){const[i,l]=e.useState(!1),n=e.useCallback(e=>{var s,a;e.stopPropagation(),s=t.hash,(null==(a=navigator.clipboard)?void 0:a.writeText)&&navigator.clipboard.writeText(s).catch(()=>{}),l(!0),setTimeout(()=>l(!1),2e3)},[t.hash]),x=t.contactType.toLowerCase(),p=x.includes("room")||x.includes("server");let v=r,b="text-accent-primary";return p?(v=u,b="text-signal-fair"):"companion"===x||"client"===x?(v=h,b="text-text-muted"):t.isNeighbor&&(b="text-accent-success"),s.jsxs("div",{className:m("flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer",a?"bg-accent-primary/10":"hover:bg-white/[0.03]"),onMouseEnter:()=>o(t.hash),onMouseLeave:()=>o(null),children:[s.jsx(v,{className:m("w-4 h-4 flex-shrink-0",b)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:t.name}),t.isNeighbor&&s.jsx(j,{color:"green",compact:!0,children:"NBR"}),t.isRepeater&&s.jsx(j,{color:"zinc",compact:!0,children:"RPT"}),t.isHub&&s.jsx(j,{color:"purple",compact:!0,children:"HUB"})]}),s.jsxs("button",{onClick:n,className:m("mt-1 inline-flex items-center gap-1 text-[10px] font-mono px-1.5 py-0.5 rounded","border transition-all cursor-pointer",i?"border-accent-success/50 bg-accent-success/10 text-accent-success":"border-border-subtle bg-bg-subtle/50 text-text-muted hover:border-border-strong"),title:`Copy: ${t.hash}`,children:[t.hash.slice(0,12),"…",i?s.jsx(d,{className:"w-2.5 h-2.5"}):s.jsx(c,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:t,hoveredHash:r,onHover:d}){const c=N(),u=e.useRef(null),h=f(),[x,p]=e.useState(!1),v=e.useMemo(()=>t.filter(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[t]),b=e.useMemo(()=>{if(0===v.length)return null;let e=1/0,s=-1/0,t=1/0,a=-1/0;for(const o of v)e=Math.min(e,o.longitude),s=Math.max(s,o.longitude),t=Math.min(t,o.latitude),a=Math.max(a,o.latitude);if(a-t<.01){const e=(a+t)/2;t=e-.005,a=e+.005}if(s-e<.01){const t=(s+e)/2;e=t-.005,s=t+.005}return[[e,t],[s,a]]},[v]),g=e.useMemo(()=>b?{longitude:(b[0][0]+b[1][0])/2,latitude:(b[0][1]+b[1][1])/2}:{longitude:0,latitude:0},[b]),H=e.useMemo(()=>{if(v.length<2)return null;const e=[];for(let s=0;s{var e;const s=null==(e=u.current)?void 0:e.getMap();s&&b?(s.fitBounds(b,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>p(!0),50)):p(!0)},[b]),M=h&&x;return 0===v.length?s.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 rounded-lg",children:s.jsxs("div",{className:"text-center text-text-secondary p-4",children:[s.jsx(a,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),s.jsx("p",{className:"text-sm",children:"No location data available"})]})}):s.jsxs("div",{className:"h-full w-full relative rounded-lg overflow-hidden bg-bg-elevated",children:[s.jsx("div",{className:m("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",M?"opacity-0":"opacity-100 bg-bg-elevated"),children:s.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),s.jsx("div",{className:m("h-full w-full transition-opacity duration-200",M?"opacity-100":"opacity-0"),children:s.jsxs(o,{ref:u,initialViewState:{longitude:g.longitude,latitude:g.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:w,attributionControl:!1,onLoad:C,children:[s.jsx(y,{mode:c}),H&&s.jsx(i,{id:"collision-edges",type:"geojson",data:H,children:s.jsx(l,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),v.map(e=>{const t=e.hash===r,a=e.hash.startsWith("0x")?e.hash.slice(2,4).toUpperCase():e.hash.slice(0,2).toUpperCase();return s.jsx(n,{longitude:e.longitude,latitude:e.latitude,anchor:"center",children:s.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>d(e.hash),onMouseLeave:()=>d(null),style:{pointerEvents:"auto"},children:s.jsxs(j,{color:"amber",filled:!0,className:"font-mono text-[10px] shadow-lg",children:[a,t&&s.jsx("span",{className:"ml-1 opacity-75 font-sans",children:e.name})]})})},e.hash)})]})})]})}const M=e.memo(function({isOpen:a,prefix:o,candidateHashes:i,onClose:l}){const n=x(),r=p(),d=v(),[c,u]=e.useState(null),h=e.useMemo(()=>new Set(d.map(e=>e.hash)),[d]),m=(null==n?void 0:n.neighbors)??{},f=e.useMemo(()=>i.map(e=>{var s;const t=(e=>m[e]?m[e]:!e.startsWith("0x")&&m["0x"+e]?m["0x"+e]:e.startsWith("0x")&&m[e.slice(2)]?m[e.slice(2)]:void 0)(e);return{hash:e,name:(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==t?void 0:t.contact_type)||"",isRepeater:(null==t?void 0:t.is_repeater)||"repeater"===(null==(s=null==t?void 0:t.contact_type)?void 0:s.toLowerCase())||!1,isNeighbor:h.has(e)||h.has("0x"+e)||h.has(e.replace(/^0x/,"")),isHub:r.has(e),latitude:null==t?void 0:t.latitude,longitude:null==t?void 0:t.longitude}}).sort((e,s)=>e.isNeighbor!==s.isNeighbor?e.isNeighbor?-1:1:e.isHub!==s.isHub?e.isHub?-1:1:e.name.localeCompare(s.name)),[i,m,h,r]),j=e.useMemo(()=>f.some(e=>null!=e.latitude&&null!=e.longitude&&(0!==e.latitude||0!==e.longitude)),[f]),N=e.useCallback(e=>{u(e)},[]),y=j?"4xl":"lg";return a?s.jsxs(b,{open:a,onClose:l,size:y,motionPlus:!0,className:j?"sm:h-[500px] sm:max-h-[600px]":"",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-signal-fair/10",children:s.jsx(t,{className:"w-5 h-5 text-signal-fair"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",s.jsx("span",{className:"font-mono text-accent-primary",children:o})]}),s.jsxs("p",{className:"text-xs text-text-secondary",children:[f.length," nodes share this prefix"]})]})]}),s.jsx("button",{onClick:l,className:"p-2 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-bg-subtle",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs(g,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[j&&s.jsx("div",{className:"h-64 p-2 border-b border-border-subtle",children:s.jsx(C,{nodes:f,hoveredHash:c,onHover:N})}),s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})]}),j?s.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[s.jsx("div",{className:"overflow-y-auto border-r border-border-subtle",children:s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})}),s.jsx("div",{className:"overflow-hidden p-2",children:s.jsx(C,{nodes:f,hoveredHash:c,onHover:N})})]}):s.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:s.jsx("div",{className:"p-2",children:f.map(e=>s.jsx(H,{node:e,isHovered:c===e.hash,onHover:N},e.hash))})})]})]}):null});export{M as C}; diff --git a/frontend/dist/assets/Configuration-_CjN4yUe.js b/frontend/dist/assets/Configuration-BOsliPZn.js similarity index 99% rename from frontend/dist/assets/Configuration-_CjN4yUe.js rename to frontend/dist/assets/Configuration-BOsliPZn.js index 2297bac0..946cbe9d 100644 --- a/frontend/dist/assets/Configuration-_CjN4yUe.js +++ b/frontend/dist/assets/Configuration-BOsliPZn.js @@ -1 +1 @@ -import{r as e,j as t,bC as s,aZ as a,X as r,aq as l,$ as n,bD as c,be as i,p as o,B as d,bE as u,C as m,E as x,bF as p,aL as b,bG as h,bH as g,bI as y,bJ as f,az as j,bK as v,at as N,am as w,a0 as k,ap as C,bL as S}from"./vendor-react-C341c8YC.js";import{n as _}from"./recharts-6XUQYgRA.js";import{aF as T,ae as F,aG as E,aH as L,aI as P,a1 as R,aJ as D,aK as I,aD as M}from"./index-CPdqYR4z.js";import{C as A}from"./ConfirmModal-DlFyryXJ.js";import{l as z}from"./font-loader-jlbdh9Fw.js";import{N as O}from"./NodeInformationCard-D-IeNCCX.js";import{a as K,P as q,b as H}from"./PageLayout-CcoYWyzO.js";import{C as $}from"./Card-BeZKc0xw.js";import{R as Y,C as B}from"./Grid-BOO-7ObJ.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./DataBox-CRX76VsB.js";async function V(e){return T("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}const J=e.memo(function(){const{theme:e}=F(),{colorScheme:s}=e,a=E.find(e=>e.colorScheme===s)??E[0],r=a.displaySize,l=`clamp(${.8*r}rem, ${.6*r}rem + 1.5vw, ${1.4*r}rem)`;return t.jsx("div",{className:"h-10 flex items-center justify-center",children:t.jsxs("span",{className:"font-medium transition-all duration-300 leading-none text-center",style:{fontFamily:a.displayFont,color:a.displayColor,fontSize:l,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:["Theme: ",a.displayName]})})}),U=e.memo(function(){const{theme:s,setThemePreset:a,setBrightness:r}=F(),{colorScheme:l,brightness:n}=s,[c,i]=e.useState(!1),[o,d]=e.useState(!1),u=e.useRef(null),m=e.useRef(null),x=(E.find(e=>e.colorScheme===l)??E[0]).id,p=e.useCallback((e,t)=>{if(!m.current)return n;const s=(m.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,m.current.brightness+s)))},[n]),b=e.useCallback(e=>{a(e),i(!0)},[a]),h=e.useCallback(e=>{r(e)},[r]),g=e.useCallback(e=>{const t=E.find(t=>t.id===e);t&&L(t.backgroundImage)},[]);return t.jsx("div",{className:"grid grid-cols-4 gap-[3%] w-full",children:E.map(e=>{const s=x===e.id,a=!e.backgroundImage,r=s&&!a&&(c||o);return t.jsxs("div",{ref:s?u:void 0,title:e.displayName,className:_("flex flex-col items-stretch rounded-sm transition-all duration-300 ease-out overflow-hidden",s?"ring-2 ring-accent-primary scale-105 "+(a?"cursor-pointer":"cursor-ns-resize"):"cursor-pointer"),onMouseEnter:()=>{s&&!a?i(!0):s||g(e.id)},onMouseLeave:()=>!o&&i(!1),onClick:()=>!s&&b(e.id),onTouchStart:e=>{if(!s||a)return;e.preventDefault();const t=e.touches[0];m.current={y:t.clientY,brightness:n},d(!0),i(!0);const r=e=>{e.preventDefault();const t=e.touches[0];h(p(t.clientY,!0))},l=()=>{document.removeEventListener("touchmove",r),document.removeEventListener("touchend",l),m.current=null,d(!1),setTimeout(()=>i(!1),1500)};document.addEventListener("touchmove",r,{passive:!1}),document.addEventListener("touchend",l)},onMouseDown:e=>{if(!s||a)return;e.preventDefault(),m.current={y:e.clientY,brightness:n},d(!0),i(!0);const t=e=>{h(p(e.clientY,!1))},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),m.current=null,d(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)},children:[t.jsxs("div",{className:"glass-thumbnail w-full aspect-square sm:aspect-[4/3] lg:aspect-video relative !rounded-b-none",children:["kde breeze"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#242627]",style:{opacity:r?.4:1},children:t.jsx("span",{className:"text-[#58b99d] text-[1.5em] font-bold font-mono",children:">"})}):"ribbon"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#F5F5F5]",style:{opacity:r?.4:1},children:t.jsx("span",{className:"text-[#2D2D2D] text-[1.5em] font-bold font-mono",children:"R"})}):t.jsx("div",{className:"absolute bg-cover bg-center transition-opacity duration-200",style:{inset:0,backgroundImage:`url(${e.backgroundImage})`,opacity:r?.4:1,filter:"brightness(var(--thumbnail-brightness, 1.5))"}}),s&&t.jsxs("div",{className:_("absolute inset-0 transition-opacity duration-200",r?"opacity-100":"opacity-0"),children:[t.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-black/70 transition-all duration-100 ease-out",style:{height:100-n+"%"}}),t.jsx("div",{className:"absolute inset-x-[8%] h-0.5 bg-white rounded-full shadow-lg transition-all duration-100 ease-out",style:{top:100-n+"%"}}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsxs("span",{className:"text-[0.6em] font-mono font-bold text-white drop-shadow-lg",children:[n,"%"]})})]})]}),t.jsx("div",{className:"flex flex-col w-full",children:e.paletteColors.map((e,s)=>t.jsx("div",{className:"flex",children:e.map((e,s)=>t.jsx("div",{className:"flex-1 aspect-[2/1]",style:{backgroundColor:e}},s))},s))})]},e.id)})})}),G=e.memo(function({layout:s="horizontal"}){return e.useEffect(()=>{z()},[]),"logo-only"===s?t.jsx(J,{}):"thumbnails-only"===s?t.jsx(U,{}):t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(J,{}),t.jsx(U,{})]})});function X(){const{latitude:o,longitude:d,enabled:u,setLocation:m,enable:x,disable:p,clear:b}=P(),[h,g]=e.useState(!1),[y,f]=e.useState(""),[j,v]=e.useState(""),[N,w]=e.useState("idle"),[k,C]=e.useState(null),S=e.useRef(null),T=e.useRef(null),F=e.useRef(!0);e.useEffect(()=>(F.current=!0,()=>{F.current=!1,T.current&&clearTimeout(T.current)}),[]);const E=()=>{g(!1),C(null)};e.useEffect(()=>{if(!h)return;const e=e=>{"loading"!==N&&S.current&&!S.current.contains(e.target)&&E()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[h,N]);const L=null!==o&&null!==d;return t.jsx(K,{children:t.jsxs("div",{ref:S,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx($,{icon:t.jsx(s,{}),title:"Stealth",largeTitle:!0}),t.jsxs("div",{className:"flex items-center gap-1",children:[L&&!h&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{u?p():x()},className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",u?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle"),title:u?"Disable stealth location":"Enable stealth location",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",u?"translate-x-5":"translate-x-0.5")})}),t.jsx("button",{onClick:()=>{b(),g(!1)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Clear stealth location",children:t.jsx(a,{className:"w-4 h-4"})})]}),h?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:E,disabled:"loading"===N,className:_("p-2 rounded-lg transition-colors","loading"===N?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:()=>{if("loading"===N)return;T.current&&clearTimeout(T.current);const e=((e,t)=>{const s=parseFloat(e),a=parseFloat(t);return isNaN(s)||isNaN(a)?"Please enter valid numbers":s<-90||s>90?"Latitude must be between -90 and 90":a<-180||a>180?"Longitude must be between -180 and 180":0===s&&0===a?"Coordinates (0, 0) are invalid":null})(y,j);if(e)return void C(e);w("loading"),C(null);const t=parseFloat(y),s=parseFloat(j);m(t,s),u||x(),w("success"),T.current=setTimeout(()=>{F.current&&(w("idle"),g(!1))},1e3)},disabled:"loading"===N,className:_("p-2 rounded-lg transition-colors","loading"===N?"text-accent-primary cursor-wait":"success"===N?"text-accent-success":"error"===N?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===N?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===N?t.jsx(n,{className:"w-4 h-4"}):"error"===N?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{f((null==o?void 0:o.toFixed(6))??""),v((null==d?void 0:d.toFixed(6))??""),C(null),g(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:L?"Edit stealth location":"Set stealth location",children:t.jsx(c,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"bg-accent-tertiary/5 rounded-xl p-3 mb-4",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(i,{className:"w-4 h-4 text-accent-tertiary flex-shrink-0 mt-0.5"}),t.jsxs("p",{className:"type-body-sm text-text-muted",children:[t.jsx("span",{className:"text-text-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",t.jsx("span",{className:"text-accent-tertiary",children:"never sent to config.yaml or the mesh"}),"."]})]})}),k&&t.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-accent-danger bg-accent-danger/10",children:k}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:h?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",h?"bg-white/5":"bg-white/[0.02]"),children:h?t.jsx("input",{type:"number",value:y,onChange:e=>f(e.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-text-primary focus:outline-none type-data placeholder:text-text-muted/50"}):t.jsx("span",{className:_("type-data",L&&u?"text-text-primary":"text-text-muted"),children:L?o.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:h?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",h?"bg-white/5":"bg-white/[0.02]"),children:h?t.jsx("input",{type:"number",value:j,onChange:e=>v(e.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-text-primary focus:outline-none type-data placeholder:text-text-muted/50"}):t.jsx("span",{className:_("type-data",L&&u?"text-text-primary":"text-text-muted"),children:L?d.toFixed(6):"Not set"})})]})]}),L&&!h&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:_("w-2 h-2 rounded-full",u?"bg-accent-success":"bg-text-muted")}),t.jsx("span",{className:"type-body-sm text-text-muted",children:u?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const W=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Z=[5,6,7,8,9,10,11,12],Q=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],ee="radioConfig",te="repeaterSettings",se="operatingMode";function ae({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:l,onSelect:n,onToggle:c}){const i=a.has(e.id),o=r===e.id,d=e.children&&e.children.length>0,u="allow"===l;return t.jsxs("div",{children:[t.jsxs("div",{className:_("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",o?"bg-accent-primary/15":"hover:bg-subtle-fill",u&&"opacity-50 cursor-not-allowed"),style:{marginLeft:16*s+"px"},onClick:()=>!u&&n(e.id),children:[d?t.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:t.jsx(C,{className:_("w-3.5 h-3.5 text-text-muted transition-transform",i&&"rotate-90")})}):t.jsx("span",{className:"w-5"}),t.jsx(S,{className:"w-4 h-4 text-accent-primary flex-shrink-0"}),t.jsx("span",{className:"type-data text-text-primary flex-1 truncate",children:e.name}),t.jsx("span",{className:_("type-data-xs px-2 py-0.5 rounded-full","allow"===e.floodPolicy?"bg-accent-success/15 text-accent-success":"bg-accent-danger/15 text-accent-danger"),children:"allow"===e.floodPolicy?"Allow":"Deny"})]}),d&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(ae,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:l,onSelect:n,onToggle:c},e.id))})]})}function re(){var s,C,S,F,E,L;const{stats:P,setMode:z,clearModeMutation:J,setDutyCycleConfig:U,clearDutyCycleMutation:re,fetchStats:le,startMutation:ne,clearMutation:ce}=R(),ie=null==(s=null==P?void 0:P.config)?void 0:s.radio,oe=null==(C=null==P?void 0:P.config)?void 0:C.repeater,de=null==(S=null==P?void 0:P.config)?void 0:S.duty_cycle,ue=(null==P?void 0:P.node_name)||(null==(F=null==P?void 0:P.config)?void 0:F.node_name)||"Unknown Node",me=(null==oe?void 0:oe.mode)??"forward",xe=(null==de?void 0:de.enforcement_enabled)??!1,pe=null==(E=null==P?void 0:P.config)?void 0:E.delays,[be,he]=e.useState(!1),[ge,ye]=e.useState(""),[fe,je]=e.useState(62.5),[ve,Ne]=e.useState(7),[we,ke]=e.useState(5),[Ce,Se]=e.useState(""),[_e,Te]=e.useState("idle"),[Fe,Ee]=e.useState(null),Le=e.useRef(null),Pe=e.useRef(null),[Re,De]=e.useState(!1),[Ie,Me]=e.useState(""),[Ae,ze]=e.useState(""),[Oe,Ke]=e.useState(""),[qe,He]=e.useState("idle"),$e=e.useRef(null),Ye=e.useRef(null),[Be,Ve]=e.useState(!1),[Je,Ue]=e.useState(""),[Ge,Xe]=e.useState(""),[We,Ze]=e.useState(""),[Qe,et]=e.useState(""),[tt,st]=e.useState("idle"),[at,rt]=e.useState(null),lt=e.useRef(null),nt=e.useRef(null),[ct,it]=e.useState("idle"),[ot,dt]=e.useState("idle"),[ut,mt]=e.useState(null),[xt,pt]=e.useState(null),bt=e.useRef(!0),ht=e.useRef(null),gt=e.useRef(null),yt=e.useRef(null),ft=e.useRef(null),jt=e.useRef(!1),vt=e.useRef(!1);e.useEffect(()=>(bt.current=!0,()=>{bt.current=!1,ht.current&&clearTimeout(ht.current),gt.current&&clearTimeout(gt.current),yt.current&&clearTimeout(yt.current),ft.current&&clearTimeout(ft.current),_t.current&&clearTimeout(_t.current),Tt.current&&clearTimeout(Tt.current),Pe.current&&clearTimeout(Pe.current),$e.current&&clearTimeout($e.current),nt.current&&clearTimeout(nt.current)}),[]),e.useEffect(()=>{const e=e=>{if(be||Be||Re)return e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to leave?",e.returnValue};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[be,Be,Re]);const Nt=null==(L=null==P?void 0:P.config)?void 0:L.web,[wt,kt]=e.useState("idle"),[Ct,St]=e.useState(null),_t=e.useRef(null),Tt=e.useRef(null),Ft=e.useRef(!1),[Et,Lt]=e.useState([]),[Pt,Rt]=e.useState(!1),[Dt,It]=e.useState(null),[Mt,At]=e.useState(!1),[zt,Ot]=e.useState(""),[Kt,qt]=e.useState(null),[Ht,$t]=e.useState(!1),[Yt,Bt]=e.useState(null),[Vt,Jt]=e.useState(!1),[Ut,Gt]=e.useState(!1),[Xt,Wt]=e.useState(!1),[Zt,Qt]=e.useState([]),[es,ts]=e.useState(!1),[ss,as]=e.useState(null),[rs,ls]=e.useState("deny"),[ns,cs]=e.useState(!1),[is,os]=e.useState(null),[ds,us]=e.useState(new Set),[ms,xs]=e.useState(!1),[ps,bs]=e.useState(!1),[hs,gs]=e.useState(!1),[ys,fs]=e.useState(null),[js,vs]=e.useState(null),[Ns,ws]=e.useState(""),[ks,Cs]=e.useState("deny"),[Ss,_s]=e.useState(!1),[Ts,Fs]=e.useState(!0),[Es,Ls]=e.useState(!1),[Ps,Rs]=e.useState(!0),[Ds,Is]=e.useState("idle"),[Ms,As]=e.useState(!1),[zs,Os]=e.useState(!1),Ks=e.useRef(!1);e.useEffect(()=>{const e=be&&!Ks.current;Ks.current=be,ie&&e&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power)))},[ie,be]);const qs=e.useMemo(()=>{if(!ie||!be)return!1;const e=ie.frequency/1e6,t=ie.bandwidth/1e3,s=parseFloat(ge)||0;return Math.abs(s-e)>1e-4||fe!==t||ve!==ie.spreading_factor||we!==ie.coding_rate||parseInt(Ce)!==ie.tx_power},[ie,be,ge,fe,ve,we,Ce]),Hs=e.useCallback(()=>{he(!1),Ee(null),ie&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power)))},[ie]);e.useEffect(()=>{if(!be)return;const e=e=>{"loading"!==_e&&Le.current&&!Le.current.contains(e.target)&&Hs()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[be,Hs,_e]);const $s=e.useCallback(()=>{const e=null==pe?void 0:pe.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[pe]),Ys=e.useCallback(()=>{const e=null==pe?void 0:pe.direct_tx_delay_factor;return"number"==typeof e?e:.5},[pe]),Bs=e.useCallback(()=>{const e=null==de?void 0:de.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[de]),Vs=e.useCallback(()=>{Me($s().toFixed(2)),ze(Ys().toFixed(2)),Ke(Bs().toFixed(1)),De(!0)},[$s,Ys,Bs]),Js=e.useCallback(()=>{De(!1)},[]);e.useEffect(()=>{if(!Re)return;const e=e=>{"loading"!==qe&&Ye.current&&!Ye.current.contains(e.target)&&Js()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Re,Js,qe]);const Us=e.useCallback(()=>{var e,t,s;Ue(ue),Xe((null==(e=null==oe?void 0:oe.latitude)?void 0:e.toString())||"0"),Ze((null==(t=null==oe?void 0:oe.longitude)?void 0:t.toString())||"0"),et((null==(s=null==oe?void 0:oe.send_advert_interval_hours)?void 0:s.toString())||"0"),rt(null),Ve(!0)},[ue,oe]),Gs=e.useCallback(()=>{Ve(!1),rt(null)},[]);e.useEffect(()=>{if(!Be)return;const e=e=>{"loading"!==tt&<.current&&!lt.current.contains(e.target)&&Gs()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Be,Gs,tt]);const Xs=async()=>{var e;if("loading"===wt)return;const t=(null==Nt?void 0:Nt.cors_enabled)??!1,s=!t,a=t;_t.current&&clearTimeout(_t.current),Tt.current&&clearTimeout(Tt.current),Ft.current=!1,St(s),kt("loading"),_t.current=setTimeout(()=>{Ft.current||bt.current&&(St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3))},1e4);try{const t=await V({web:{cors_enabled:s}});if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!bt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await le(),kt("success"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3)):(St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3))}catch{if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!bt.current)return;St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3)}};e.useEffect(()=>{(async()=>{Rs(!0);try{const e=await async function(){return T("/api/check_pymc_console")}();e.success&&e.data?Ls(e.data.exists):Ls(!1);const t=null==Nt?void 0:Nt.web_path;Fs(!t||""===t)}catch{Ls(!1)}finally{Rs(!1)}})()},[null==Nt?void 0:Nt.web_path]);const Ws=async e=>{var t;if("loading"!==Ds){Is("loading");try{const s=await V({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!bt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Fs(e),Is("success"),As(!0),setTimeout(()=>{bt.current&&Is("idle")},2e3)):(Is("error"),setTimeout(()=>{bt.current&&Is("idle")},2e3))}catch{if(!bt.current)return;Is("error"),setTimeout(()=>{bt.current&&Is("idle")},2e3)}}},Zs=e.useCallback(async()=>{Rt(!0),It(null);try{const e=await async function(){return T("/auth/tokens")}();Lt(e.tokens||[])}catch(e){It(e instanceof Error?e.message:"Failed to fetch tokens")}finally{Rt(!1)}},[]);e.useEffect(()=>{Zs()},[Zs]);const Qs=async()=>{if(zt.trim()){Jt(!0),It(null);try{const e=await async function(e){return T("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}(zt.trim());qt(e.token||null),At(!1),$t(!0),Ot(""),await Zs()}catch(e){It(e instanceof Error?e.message:"Failed to create token")}finally{Jt(!1)}}else It("Token name is required")},ea=e=>e?new Date(1e3*e).toLocaleString():"Never",ta=e.useCallback(e=>{const t=new Map,s=[];return e.forEach(e=>{const s={id:e.id,name:e.name,floodPolicy:e.flood_policy,transport_key:e.transport_key,last_used:e.last_used,parent_id:e.parent_id,children:[]};t.set(e.id,s)}),t.forEach(e=>{e.parent_id&&t.has(e.parent_id)?t.get(e.parent_id).children.push(e):s.push(e)}),s},[]),sa=e.useCallback(async()=>{ts(!0),as(null);try{const e=await async function(){return T("/api/transport_keys")}();e.success&&e.data?Qt(ta(e.data)):as(e.error||"Failed to load transport keys")}catch(e){as(e instanceof Error?e.message:"Unknown error occurred")}finally{ts(!1)}},[ta]);e.useEffect(()=>{sa()},[sa]);const aa=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=aa(s.children,t);if(e)return e}}return null},[]),ra=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);return null==e?void 0:e.name},[is,Zt,aa]),la=e.useCallback(e=>{us(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),na=async e=>{cs(!0),as(null);try{const t=await async function(e){return T("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}("allow"===e);t.success?ls(e):as(t.error||"Failed to update global flood policy")}catch(t){as(t instanceof Error?t.message:"Failed to update global flood policy")}finally{cs(!1)}},ca=async()=>{if(Ns.trim()){_s(!0),as(null);try{const e=await async function(e){return T("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}({name:Ns.trim(),flood_policy:ks,parent_id:is??void 0});e.success?(await sa(),xs(!1),ws(""),Cs("deny")):as(e.error||"Failed to add transport key")}catch(e){as(e instanceof Error?e.message:"Failed to add transport key")}finally{_s(!1)}}else as("Key name is required")},ia=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);e&&(fs({...e}),bs(!0))},[is,Zt,aa]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(ms&&(xs(!1),ws(""),Cs("deny")),ps&&(bs(!1),fs(null)),hs&&(gs(!1),vs(null)),Mt&&(At(!1),Ot("")),Ht&&($t(!1),qt(null)))};if(ms||ps||hs||Mt||Ht)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ms,ps,hs,Mt,Ht]);const oa=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);e&&(vs(e),gs(!0))},[is,Zt,aa]);return t.jsxs(q,{children:[t.jsx(H,{title:"Configuration",icon:t.jsx(o,{})}),t.jsxs(Y,{template:"standard",children:[t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:lt,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-2",children:[t.jsx(d,{className:"icon-md text-accent-primary"}),"Repeater Settings"]}),t.jsx("div",{className:"flex items-center gap-1",children:oe&&(Be?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Gs,disabled:"loading"===tt,className:_("p-2 rounded-lg transition-colors","loading"===tt?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==tt){nt.current&&clearTimeout(nt.current),ne(te),st("loading"),rt(null);try{const e={};Je&&Je!==ue&&(e.node_name=Je);const t=parseFloat(Ge);isNaN(t)||t===(null==oe?void 0:oe.latitude)||(e.latitude=t);const s=parseFloat(We);isNaN(s)||s===(null==oe?void 0:oe.longitude)||(e.longitude=s);const a=parseInt(Qe);if(isNaN(a)||a===(null==oe?void 0:oe.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return rt({success:!0,message:"No changes to save"}),st("idle"),void ce(te);const r=await M(e);if(!bt.current)return void ce(te);if(r.success&&r.data){const e=r.data.applied.join(", ");rt({success:!0,message:`Updated: ${e}`}),await le({force:!0}),st("success"),nt.current=setTimeout(()=>{bt.current&&(st("idle"),Ve(!1),rt(null),ce(te))},1500)}else rt({success:!1,message:r.error||"Failed to save"}),st("error"),ce(te),nt.current=setTimeout(()=>{bt.current&&st("idle")},2e3)}catch(e){if(!bt.current)return void ce(te);rt({success:!1,message:String(e)}),st("error"),ce(te),nt.current=setTimeout(()=>{bt.current&&st("idle")},2e3)}}},disabled:"loading"===tt,className:_("p-2 rounded-lg transition-colors","loading"===tt?"text-accent-primary cursor-wait":"success"===tt?"text-accent-success":"error"===tt?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===tt?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===tt?t.jsx(n,{className:"w-4 h-4"}):"error"===tt?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Us,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit repeater settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),at&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",at.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:at.message}),oe?t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"col-span-2",children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Node Name"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"text",value:Je,onChange:e=>Ue(e.target.value),maxLength:50,className:"w-full bg-transparent text-text-primary focus:outline-none type-data",placeholder:"Enter node name"}):t.jsx("span",{className:"type-data text-text-primary",children:ue})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:Ge,onChange:e=>Xe(e.target.value),step:"0.000001",min:"-90",max:"90",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:0!==oe.latitude?oe.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:We,onChange:e=>Ze(e.target.value),step:"0.000001",min:"-180",max:"180",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:0!==oe.longitude?oe.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:Qe,onChange:e=>et(e.target.value),min:"0",max:"48",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:oe.send_advert_interval_hours>0?`${oe.send_advert_interval_hours}h`:"Disabled"})}),Be&&t.jsx("p",{className:"type-data-xs text-text-muted mt-1 ml-4",children:"0 = disabled, 3-48 hours"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Score-based TX"}),t.jsx("div",{className:"h-[38px] rounded-full px-4 flex items-center bg-subtle-fill",children:t.jsx("span",{className:"type-data text-text-primary",children:oe.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:Le,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-2",children:[t.jsx(u,{className:"icon-md text-accent-primary"}),"Radio Configuration"]}),t.jsx("div",{className:"flex items-center gap-1",children:ie&&(be?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Hs,disabled:"loading"===_e,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==_e){Pe.current&&clearTimeout(Pe.current),ne(ee),Te("loading"),Ee(null);try{const e={},t=parseFloat(ge),s=ie?ie.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=ie?ie.bandwidth/1e3:0;fe!==a&&(e.bandwidth_khz=fe),ve!==(null==ie?void 0:ie.spreading_factor)&&(e.spreading_factor=ve),we!==(null==ie?void 0:ie.coding_rate)&&(e.coding_rate=we);const r=parseInt(Ce);if(r!==(null==ie?void 0:ie.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return Ee({success:!0,message:"No changes to save"}),Te("idle"),void ce(ee);const l=await M(e);if(!bt.current)return void ce(ee);if(l.success&&l.data){const e=l.data.applied.join(", "),t=l.data.live_update?" (applied live)":" (restart required)";Ee({success:!0,message:`Updated: ${e}${t}`}),await le({force:!0}),Te("success"),Pe.current=setTimeout(()=>{bt.current&&(Te("idle"),he(!1),Ee(null),ce(ee))},1500)}else Ee({success:!1,message:l.error||"Failed to save"}),Te("error"),ce(ee),Pe.current=setTimeout(()=>{bt.current&&Te("idle")},2e3)}catch(e){if(!bt.current)return void ce(ee);Ee({success:!1,message:String(e)}),Te("error"),ce(ee),Pe.current=setTimeout(()=>{bt.current&&Te("idle")},2e3)}}},disabled:"loading"===_e||!qs,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-accent-primary cursor-wait":"success"===_e?"text-accent-success":"error"===_e?"text-accent-danger":qs?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:qs?"Save changes":"No changes to save",children:"loading"===_e?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===_e?t.jsx(n,{className:"w-4 h-4"}):"error"===_e?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{ie&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power))),Ee(null),he(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit radio settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),Fe&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",Fe.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:Fe.message}),ie?t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:be?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsx("input",{type:"number",value:ge,onChange:e=>ye(e.target.value),step:"0.001",min:"400",max:"930",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:D(ie.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:be?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsx("input",{type:"number",value:Ce,onChange:e=>Se(e.target.value),min:"-9",max:"22",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsxs("span",{className:"type-data text-text-primary",children:[ie.tx_power," dBm"]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Bandwidth"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:fe,onChange:e=>je(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:W.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsx("span",{className:"type-data text-text-primary",children:I(ie.bandwidth)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Spreading Factor"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:ve,onChange:e=>Ne(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:Z.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:["SF",ie.spreading_factor]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Coding Rate"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:we,onChange:e=>ke(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:Q.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:["4/",ie.coding_rate]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Preamble"}),t.jsx("div",{className:"h-[38px] rounded-full px-4 flex items-center bg-subtle-fill",children:t.jsxs("span",{className:"type-data text-text-primary",children:[ie.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(Y,{template:"standard",children:[t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:Ye,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-3",children:[t.jsx(x,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:Re?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==qe){$e.current&&clearTimeout($e.current),ne(se),He("loading");try{const e=await M({tx_delay_factor:parseFloat(Ie),direct_tx_delay_factor:parseFloat(Ae)});if(await U({max_airtime_percent:parseFloat(Oe),enforcement_enabled:xe}),!bt.current)return void ce(se);e.success&&e.data?(await le({force:!0}),He("success"),$e.current=setTimeout(()=>{bt.current&&(He("idle"),De(!1),ce(se))},1500)):(He("error"),ce(se),$e.current=setTimeout(()=>{bt.current&&He("idle")},2e3))}catch{if(!bt.current)return void ce(se);He("error"),ce(se),$e.current=setTimeout(()=>{bt.current&&He("idle")},2e3)}}},disabled:"loading"===qe,className:_("p-2 rounded-lg transition-colors","loading"===qe?"text-accent-primary cursor-wait":"success"===qe?"text-accent-success":"error"===qe?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===qe?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===qe?t.jsx(n,{className:"w-4 h-4"}):"error"===qe?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})}),t.jsx("button",{onClick:Js,className:"p-2 rounded-lg text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Vs,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit settings",children:t.jsx(c,{className:"w-4 h-4"})})})]}),t.jsx("p",{className:"type-label text-text-muted mb-3",children:"Control how the repeater handles packets"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsxs("div",{className:"flex-1 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Repeat"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==ut?ut:"forward"===me;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ct)return;const t=!e,s="forward"===me;ht.current&&clearTimeout(ht.current),gt.current&&clearTimeout(gt.current),jt.current=!1,mt(t),it("loading"),ht.current=setTimeout(()=>{jt.current||bt.current&&(mt(s),it("error"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null))},2e3))},1e4);try{if(await z(t?"forward":"monitor"),jt.current=!0,ht.current&&clearTimeout(ht.current),!bt.current)return;it("success"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null),J())},2e3)}catch{if(jt.current=!0,ht.current&&clearTimeout(ht.current),!bt.current)return;mt(s),it("error"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null))},2e3)}},disabled:"loading"===ct,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===ct&&"opacity-70"),"aria-label":"Toggle forward mode",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),t.jsx("span",{className:_("type-data text-sm w-7",e?"text-accent-success":"text-text-muted"),children:e?"On":"Off"}),"loading"===ct&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ct&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===ct&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Duty Cycle"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==xt?xt:xe;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ot)return;const t=!e,s=xe;yt.current&&clearTimeout(yt.current),ft.current&&clearTimeout(ft.current),vt.current=!1,pt(t),dt("loading"),yt.current=setTimeout(()=>{vt.current||bt.current&&(pt(s),dt("error"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null))},2e3))},1e4);try{if(await U({max_airtime_percent:Bs(),enforcement_enabled:t}),vt.current=!0,yt.current&&clearTimeout(yt.current),!bt.current)return;dt("success"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null),re())},2e3)}catch{if(vt.current=!0,yt.current&&clearTimeout(yt.current),!bt.current)return;pt(s),dt("error"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null))},2e3)}},disabled:"loading"===ot,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===ot&&"opacity-70"),"aria-label":"Toggle duty cycle",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),t.jsx("span",{className:_("type-data text-sm w-7",e?"text-accent-success":"text-text-muted"),children:e?"On":"Off"}),"loading"===ot&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ot&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===ot&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Max Airtime"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Oe,onChange:e=>Ke(e.target.value),step:"0.5",min:"0.1",max:"100",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"%"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[Bs().toFixed(1),"%"]})})]})]}),t.jsx("div",{className:"hidden sm:block w-px bg-border-subtle"}),t.jsxs("div",{className:"flex-1 pt-4 sm:pt-0 border-t sm:border-t-0 border-border-subtle",children:[t.jsx("label",{className:"type-label text-text-muted block mb-3",children:"TX Delays"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Flood"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ie,onChange:e=>Me(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"x"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[$s().toFixed(2),"x"]})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Direct"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ae,onChange:e=>ze(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"s"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[Ys().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx(B,{span:12,md:6,children:t.jsxs(K,{children:[t.jsx($,{icon:t.jsx(o,{}),title:"App Settings",largeTitle:!0}),t.jsx("p",{className:"type-body-sm text-text-muted mb-4",children:"Appearance and web server options."}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("span",{className:"type-body text-text-primary font-medium block",children:"Enable CORS"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Allow cross-origin API access"})]}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==Ct?Ct:(null==Nt?void 0:Nt.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Xs,disabled:"loading"===wt,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===wt&&"opacity-70"),title:e?"Disable CORS":"Enable CORS",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),"loading"===wt&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===wt&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===wt&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsx("div",{children:t.jsx(G,{})})]})]})})]}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(p,{className:"icon-md text-accent-primary"}),"Regions / Transport Keys"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Manage regional key hierarchy for flood control"})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsxs("button",{onClick:()=>xs(!0),disabled:"allow"===rs,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===rs?"bg-subtle-fill text-text-muted cursor-not-allowed":"bg-accent-success/10 hover:bg-accent-success/20 text-accent-success"),children:[t.jsx(b,{className:"w-3.5 h-3.5"}),"Add"]}),t.jsx("button",{onClick:ia,disabled:!is||"allow"===rs,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",is&&"allow"!==rs?"bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary":"bg-subtle-fill text-text-muted cursor-not-allowed"),children:"Edit"}),t.jsx("button",{onClick:oa,disabled:!is||"allow"===rs,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",is&&"allow"!==rs?"bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger":"bg-subtle-fill text-text-muted cursor-not-allowed"),children:"Delete"})]})]}),t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 mb-4",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:_("w-10 h-10 rounded-full flex items-center justify-center","allow"===rs?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===rs?t.jsx(h,{className:"w-5 h-5 text-accent-success"}):t.jsx(g,{className:"w-5 h-5 text-accent-danger"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:"Global Flood Policy"}),t.jsx("p",{className:"type-body-sm text-text-muted",children:"Master control for repeater flooding"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-subtle-fill rounded-full p-1",children:[t.jsx("button",{onClick:()=>na("deny"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===rs?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>na("allow"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===rs?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Allow"})]}),ns&&t.jsx(l,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),ss&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:ss}),t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 min-h-[120px]",children:es?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(l,{className:"w-5 h-5 animate-spin text-accent-primary mr-2"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Loading transport keys..."})]}):0===Zt.length?t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:t.jsx(p,{className:"w-6 h-6 text-text-muted/50"})}),t.jsx("p",{className:"type-body text-text-muted",children:"No transport keys found"}),t.jsx("p",{className:"type-body-sm text-text-muted/70 mt-1",children:"Add your first transport key to get started"})]}):t.jsx("div",{className:"space-y-1",children:Zt.map(e=>t.jsx(ae,{node:e,level:0,expandedKeys:ds,selectedKeyId:is,globalFloodPolicy:rs,onSelect:os,onToggle:la},e.id))})})]})}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(y,{className:"icon-md text-accent-primary"}),"API Tokens"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Manage API tokens for machine-to-machine authentication"})]}),t.jsxs("button",{onClick:()=>At(!0),className:"flex items-center justify-center gap-2 h-[32px] px-4 bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary rounded-full transition-colors type-body-sm font-medium",children:[t.jsx(b,{className:"w-4 h-4"}),"Create Token"]})]}),t.jsx("div",{className:"bg-accent-tertiary/5 rounded-2xl p-4 mb-4",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-accent-tertiary/20 flex items-center justify-center flex-shrink-0",children:t.jsx(i,{className:"w-4 h-4 text-accent-tertiary"})}),t.jsxs("div",{className:"type-body-sm text-text-muted",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-text-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",t.jsx("code",{className:"type-code bg-accent-tertiary/20 px-1.5 py-0.5 rounded-full text-accent-tertiary",children:"X-API-Key"})," header when making API requests."]}),t.jsx("p",{className:"mt-1 text-text-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),Dt&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Dt}),Pt&&0===Et.length?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(l,{className:"w-5 h-5 animate-spin text-accent-primary mr-2"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Loading tokens..."})]}):Et.length>0?t.jsx("div",{className:"space-y-2",children:Et.map(e=>t.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong rounded-2xl p-4 transition-colors",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-accent-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(y,{className:"w-5 h-5 text-accent-primary"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h3",{className:"type-body text-text-primary font-medium truncate",children:e.name}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Created: ",ea(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",ea(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Bt({id:e.id,name:e.name}),disabled:Ut,className:"h-[32px] px-4 bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger rounded-full transition-colors disabled:opacity-50 type-body-sm font-medium flex items-center justify-center gap-1.5",children:[t.jsx(a,{className:"w-3.5 h-3.5"}),"Revoke"]})]})},e.id))}):t.jsxs("div",{className:"bg-subtle-fill rounded-2xl p-6 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:t.jsx(y,{className:"w-7 h-7 text-text-muted/50"})}),t.jsx("h3",{className:"type-body text-text-primary font-medium mb-1",children:"No API Tokens"}),t.jsx("p",{className:"type-body-sm text-text-muted mb-4",children:"Create a token to enable API access"}),t.jsx("button",{onClick:()=>At(!0),className:"h-[32px] px-4 bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary rounded-full transition-colors type-body-sm font-medium",children:"Create Your First Token"})]})]})}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(f,{className:"icon-md text-accent-primary"}),"Web Frontend"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Choose which web interface to use"})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:_("flex items-start gap-3 p-4 bg-subtle-fill rounded-2xl border-2 cursor-pointer transition-all",Ts?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Ds&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ts,onChange:()=>Ws(!0),disabled:"loading"===Ds,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"Default Frontend"}),t.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"type-data-xs bg-accent-tertiary/15 text-accent-tertiary px-2.5 py-0.5 rounded-full font-medium hover:bg-accent-tertiary/25 transition-colors",children:"@RightUp"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Built-in pyMC Repeater web interface"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),t.jsxs("label",{className:_("flex items-start gap-3 p-4 bg-subtle-fill rounded-2xl border-2 cursor-pointer transition-all",Ts?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Ds&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ts,onChange:()=>Ws(!1),disabled:"loading"===Ds,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"PyMC Console"}),t.jsx("span",{className:"type-data-xs bg-accent-secondary/15 text-accent-secondary px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_console/web/html"})]})]})]}),!Ps&&t.jsx("div",{className:_("bg-subtle-fill rounded-2xl p-4",Es?"border border-accent-success/20":"border border-accent-tertiary/20"),children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:_("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",Es?"bg-accent-success/20":"bg-accent-tertiary/20"),children:Es?t.jsx(j,{className:"w-4 h-4 text-accent-success"}):t.jsx(i,{className:"w-4 h-4 text-accent-tertiary"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:Es?"PyMC Console has been detected":"PyMC Console Not Installed"}),Es?t.jsxs("p",{className:"type-body-sm text-text-muted mt-1",children:["PyMC Console is installed at ",t.jsx("code",{className:"type-code bg-accent-success/10 px-1.5 py-0.5 rounded-full text-accent-success",children:"/opt/pymc_console/web/html"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"type-body-sm text-text-muted mt-1 mb-3",children:["PyMC Console must be installed at ",t.jsx("code",{className:"type-code bg-accent-tertiary/10 px-1.5 py-0.5 rounded-full text-accent-tertiary",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),t.jsxs("a",{href:"https://github.com/dmduran12/pymc_console-dist",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 h-[32px] px-4 bg-accent-tertiary/10 hover:bg-accent-tertiary/20 text-accent-tertiary rounded-full type-body-sm font-medium transition-colors",children:[t.jsx(v,{className:"w-4 h-4"}),"PyMC Console Install Instructions"]})]})]})]})}),Ms&&t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 border border-accent-secondary/30",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-accent-secondary/20 flex items-center justify-center flex-shrink-0",children:t.jsx(N,{className:"w-4 h-4 text-accent-secondary"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:"Service restart required"}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),t.jsx("button",{onClick:async()=>{if(!zs){Os(!0);try{await async function(){return T("/api/restart_service",{method:"POST",body:"{}"})}(),As(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{As(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:zs,className:"h-[32px] px-4 bg-accent-secondary/10 hover:bg-accent-secondary/20 text-accent-secondary rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 whitespace-nowrap type-body-sm font-medium",children:zs?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Restarting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(w,{className:"w-4 h-4"}),"Restart Now"]})})]})})]})]})}),P&&t.jsx(Y,{template:"auto",children:t.jsx(O,{nodeName:ue,repeaterVersion:P.version,coreVersion:P.core_version,localHash:P.local_hash,publicKey:P.public_key})}),P&&(0===(null==oe?void 0:oe.latitude)||!(null==oe?void 0:oe.latitude))&&(0===(null==oe?void 0:oe.longitude)||!(null==oe?void 0:oe.longitude))&&t.jsx(Y,{template:"auto",children:t.jsx(X,{})}),Mt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&At(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"create-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Create API Token"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Token Name"}),t.jsx("input",{type:"text",value:zt,onChange:e=>Ot(e.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&Qs(),autoFocus:!0}),t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Give your token a descriptive name to identify its purpose"})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{At(!1),Ot(""),It(null)},disabled:Vt,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:Qs,disabled:Vt||!zt.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Vt?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),Ht&&Kt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&$t(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-lg w-full shadow-2xl",children:[t.jsx("h3",{id:"show-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Token Created Successfully"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(N,{className:"w-4 h-4 text-accent-secondary flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-text-secondary",children:[t.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Your API Token"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:Kt,readOnly:!0,className:"flex-1 px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary font-mono text-sm"}),t.jsxs("button",{onClick:()=>{Kt&&(navigator.clipboard.writeText(Kt),Wt(!0),setTimeout(()=>Wt(!1),2e3))},className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors flex items-center gap-2",title:"Copy to clipboard",children:[Xt?t.jsx(n,{className:"w-4 h-4 text-accent-success"}):t.jsx(k,{className:"w-4 h-4"}),Xt?"Copied!":"Copy"]})]})]}),t.jsxs("div",{className:"bg-accent-tertiary/10 border border-accent-tertiary/30 rounded-lg p-3",children:[t.jsx("p",{className:"text-sm text-text-secondary mb-2",children:t.jsx("strong",{children:"Usage Example:"})}),t.jsxs("code",{className:"block bg-accent-tertiary/20 px-3 py-2 rounded text-xs text-accent-tertiary font-mono overflow-x-auto",children:['curl -H "X-API-Key: ',Kt.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{$t(!1),qt(null)},className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors",children:"Done"})})]})]})}),t.jsx(A,{isOpen:!!Yt,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Yt?void 0:Yt.name}'? This action cannot be undone.`,confirmLabel:Ut?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Yt){Gt(!0),It(null);try{await async function(e){return T(`/auth/tokens/${e}`,{method:"DELETE"})}(Yt.id),await Zs(),Bt(null)}catch(e){It(e instanceof Error?e.message:"Failed to revoke token")}finally{Gt(!1)}}},onCancel:()=>Bt(null)}),ms&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&xs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"add-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Add Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[is&&t.jsxs("div",{className:"bg-accent-tertiary/10 border border-accent-tertiary/30 rounded-lg p-3 text-sm text-text-secondary",children:["Adding as child of: ",t.jsx("strong",{className:"text-text-primary",children:ra()})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:Ns,onChange:e=>ws(e.target.value),placeholder:"e.g., Region Name, Group Key",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&ca(),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>Cs("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ks?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>Cs("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ks?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{xs(!1),ws(""),Cs("deny")},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:ca,disabled:Ss||!Ns.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),ps&&ys&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&bs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"edit-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Edit Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:ys.name,onChange:e=>fs({...ys,name:e.target.value}),className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ys.floodPolicy?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ys.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),ys.transport_key&&t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Transport Key"}),t.jsx("code",{className:"block bg-bg-subtle px-3 py-2 rounded-lg text-xs text-text-muted font-mono overflow-x-auto",children:ys.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{bs(!1),vs(ys),gs(!0),fs(null)},disabled:Ss,className:"px-4 py-2 bg-accent-danger/20 hover:bg-accent-danger/30 text-accent-danger rounded-lg border border-accent-danger/50 transition-colors disabled:opacity-50",children:"Delete"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:()=>{bs(!1),fs(null)},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(ys){_s(!0),as(null);try{const e=await async function(e,t){return T(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}(ys.id,{name:ys.name,flood_policy:ys.floodPolicy});e.success?(await sa(),bs(!1),fs(null)):as(e.error||"Failed to update transport key")}catch(e){as(e instanceof Error?e.message:"Failed to update transport key")}finally{_s(!1)}}},disabled:Ss||!ys.name.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),hs&&js&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&gs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"delete-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Delete Transport Key"}),t.jsxs("p",{className:"text-text-secondary mb-4",children:["Are you sure you want to delete ",t.jsxs("strong",{className:"text-text-primary",children:["'",js.name,"'"]}),"?"]}),js.children&&js.children.length>0&&t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3 mb-4",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(N,{className:"w-4 h-4 text-accent-secondary flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-text-secondary",children:["This key has ",js.children.length," child key(s). Deleting will also remove all children."]})]})}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>{gs(!1),vs(null)},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(js){_s(!0),as(null);try{const e=await async function(e){return T(`/api/transport_key/${e}`,{method:"DELETE"})}(js.id);e.success?(await sa(),gs(!1),vs(null),os(null)):as(e.error||"Failed to delete transport key")}catch(e){as(e instanceof Error?e.message:"Failed to delete transport key")}finally{_s(!1)}}},disabled:Ss,className:"px-4 py-2 bg-accent-danger/20 hover:bg-accent-danger/30 text-accent-danger rounded-lg border border-accent-danger/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{re as default}; +import{r as e,j as t,bC as s,aZ as a,X as r,aq as l,$ as n,bD as c,be as i,p as o,B as d,bE as u,C as m,E as x,bF as p,aL as b,bG as h,bH as g,bI as y,bJ as f,az as j,bK as v,at as N,am as w,a0 as k,ap as C,bL as S}from"./vendor-react-C341c8YC.js";import{n as _}from"./recharts-6XUQYgRA.js";import{aF as T,ae as F,aG as E,aH as L,aI as P,a1 as R,aJ as D,aK as I,aD as M}from"./index-BJEgt3tp.js";import{C as A}from"./ConfirmModal-CYXFGX_W.js";import{l as z}from"./font-loader-jlbdh9Fw.js";import{N as O}from"./NodeInformationCard-CEW2bogB.js";import{a as K,P as q,b as H}from"./PageLayout-CnF5SScd.js";import{C as $}from"./Card-2pQSGkKC.js";import{R as Y,C as B}from"./Grid-BOO-7ObJ.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./DataBox-CRX76VsB.js";async function V(e){return T("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}const J=e.memo(function(){const{theme:e}=F(),{colorScheme:s}=e,a=E.find(e=>e.colorScheme===s)??E[0],r=a.displaySize,l=`clamp(${.8*r}rem, ${.6*r}rem + 1.5vw, ${1.4*r}rem)`;return t.jsx("div",{className:"h-10 flex items-center justify-center",children:t.jsxs("span",{className:"font-medium transition-all duration-300 leading-none text-center",style:{fontFamily:a.displayFont,color:a.displayColor,fontSize:l,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:["Theme: ",a.displayName]})})}),U=e.memo(function(){const{theme:s,setThemePreset:a,setBrightness:r}=F(),{colorScheme:l,brightness:n}=s,[c,i]=e.useState(!1),[o,d]=e.useState(!1),u=e.useRef(null),m=e.useRef(null),x=(E.find(e=>e.colorScheme===l)??E[0]).id,p=e.useCallback((e,t)=>{if(!m.current)return n;const s=(m.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,m.current.brightness+s)))},[n]),b=e.useCallback(e=>{a(e),i(!0)},[a]),h=e.useCallback(e=>{r(e)},[r]),g=e.useCallback(e=>{const t=E.find(t=>t.id===e);t&&L(t.backgroundImage)},[]);return t.jsx("div",{className:"grid grid-cols-4 gap-[3%] w-full",children:E.map(e=>{const s=x===e.id,a=!e.backgroundImage,r=s&&!a&&(c||o);return t.jsxs("div",{ref:s?u:void 0,title:e.displayName,className:_("flex flex-col items-stretch rounded-sm transition-all duration-300 ease-out overflow-hidden",s?"ring-2 ring-accent-primary scale-105 "+(a?"cursor-pointer":"cursor-ns-resize"):"cursor-pointer"),onMouseEnter:()=>{s&&!a?i(!0):s||g(e.id)},onMouseLeave:()=>!o&&i(!1),onClick:()=>!s&&b(e.id),onTouchStart:e=>{if(!s||a)return;e.preventDefault();const t=e.touches[0];m.current={y:t.clientY,brightness:n},d(!0),i(!0);const r=e=>{e.preventDefault();const t=e.touches[0];h(p(t.clientY,!0))},l=()=>{document.removeEventListener("touchmove",r),document.removeEventListener("touchend",l),m.current=null,d(!1),setTimeout(()=>i(!1),1500)};document.addEventListener("touchmove",r,{passive:!1}),document.addEventListener("touchend",l)},onMouseDown:e=>{if(!s||a)return;e.preventDefault(),m.current={y:e.clientY,brightness:n},d(!0),i(!0);const t=e=>{h(p(e.clientY,!1))},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),m.current=null,d(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)},children:[t.jsxs("div",{className:"glass-thumbnail w-full aspect-square sm:aspect-[4/3] lg:aspect-video relative !rounded-b-none",children:["kde breeze"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#242627]",style:{opacity:r?.4:1},children:t.jsx("span",{className:"text-[#58b99d] text-[1.5em] font-bold font-mono",children:">"})}):"ribbon"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#F5F5F5]",style:{opacity:r?.4:1},children:t.jsx("span",{className:"text-[#2D2D2D] text-[1.5em] font-bold font-mono",children:"R"})}):t.jsx("div",{className:"absolute bg-cover bg-center transition-opacity duration-200",style:{inset:0,backgroundImage:`url(${e.backgroundImage})`,opacity:r?.4:1,filter:"brightness(var(--thumbnail-brightness, 1.5))"}}),s&&t.jsxs("div",{className:_("absolute inset-0 transition-opacity duration-200",r?"opacity-100":"opacity-0"),children:[t.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-black/70 transition-all duration-100 ease-out",style:{height:100-n+"%"}}),t.jsx("div",{className:"absolute inset-x-[8%] h-0.5 bg-white rounded-full shadow-lg transition-all duration-100 ease-out",style:{top:100-n+"%"}}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsxs("span",{className:"text-[0.6em] font-mono font-bold text-white drop-shadow-lg",children:[n,"%"]})})]})]}),t.jsx("div",{className:"flex flex-col w-full",children:e.paletteColors.map((e,s)=>t.jsx("div",{className:"flex",children:e.map((e,s)=>t.jsx("div",{className:"flex-1 aspect-[2/1]",style:{backgroundColor:e}},s))},s))})]},e.id)})})}),G=e.memo(function({layout:s="horizontal"}){return e.useEffect(()=>{z()},[]),"logo-only"===s?t.jsx(J,{}):"thumbnails-only"===s?t.jsx(U,{}):t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(J,{}),t.jsx(U,{})]})});function X(){const{latitude:o,longitude:d,enabled:u,setLocation:m,enable:x,disable:p,clear:b}=P(),[h,g]=e.useState(!1),[y,f]=e.useState(""),[j,v]=e.useState(""),[N,w]=e.useState("idle"),[k,C]=e.useState(null),S=e.useRef(null),T=e.useRef(null),F=e.useRef(!0);e.useEffect(()=>(F.current=!0,()=>{F.current=!1,T.current&&clearTimeout(T.current)}),[]);const E=()=>{g(!1),C(null)};e.useEffect(()=>{if(!h)return;const e=e=>{"loading"!==N&&S.current&&!S.current.contains(e.target)&&E()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[h,N]);const L=null!==o&&null!==d;return t.jsx(K,{children:t.jsxs("div",{ref:S,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx($,{icon:t.jsx(s,{}),title:"Stealth",largeTitle:!0}),t.jsxs("div",{className:"flex items-center gap-1",children:[L&&!h&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>{u?p():x()},className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",u?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle"),title:u?"Disable stealth location":"Enable stealth location",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",u?"translate-x-5":"translate-x-0.5")})}),t.jsx("button",{onClick:()=>{b(),g(!1)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Clear stealth location",children:t.jsx(a,{className:"w-4 h-4"})})]}),h?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:E,disabled:"loading"===N,className:_("p-2 rounded-lg transition-colors","loading"===N?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:()=>{if("loading"===N)return;T.current&&clearTimeout(T.current);const e=((e,t)=>{const s=parseFloat(e),a=parseFloat(t);return isNaN(s)||isNaN(a)?"Please enter valid numbers":s<-90||s>90?"Latitude must be between -90 and 90":a<-180||a>180?"Longitude must be between -180 and 180":0===s&&0===a?"Coordinates (0, 0) are invalid":null})(y,j);if(e)return void C(e);w("loading"),C(null);const t=parseFloat(y),s=parseFloat(j);m(t,s),u||x(),w("success"),T.current=setTimeout(()=>{F.current&&(w("idle"),g(!1))},1e3)},disabled:"loading"===N,className:_("p-2 rounded-lg transition-colors","loading"===N?"text-accent-primary cursor-wait":"success"===N?"text-accent-success":"error"===N?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===N?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===N?t.jsx(n,{className:"w-4 h-4"}):"error"===N?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{f((null==o?void 0:o.toFixed(6))??""),v((null==d?void 0:d.toFixed(6))??""),C(null),g(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:L?"Edit stealth location":"Set stealth location",children:t.jsx(c,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"bg-accent-tertiary/5 rounded-xl p-3 mb-4",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(i,{className:"w-4 h-4 text-accent-tertiary flex-shrink-0 mt-0.5"}),t.jsxs("p",{className:"type-body-sm text-text-muted",children:[t.jsx("span",{className:"text-text-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",t.jsx("span",{className:"text-accent-tertiary",children:"never sent to config.yaml or the mesh"}),"."]})]})}),k&&t.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-accent-danger bg-accent-danger/10",children:k}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:h?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",h?"bg-white/5":"bg-white/[0.02]"),children:h?t.jsx("input",{type:"number",value:y,onChange:e=>f(e.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-text-primary focus:outline-none type-data placeholder:text-text-muted/50"}):t.jsx("span",{className:_("type-data",L&&u?"text-text-primary":"text-text-muted"),children:L?o.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:h?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",h?"bg-white/5":"bg-white/[0.02]"),children:h?t.jsx("input",{type:"number",value:j,onChange:e=>v(e.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-text-primary focus:outline-none type-data placeholder:text-text-muted/50"}):t.jsx("span",{className:_("type-data",L&&u?"text-text-primary":"text-text-muted"),children:L?d.toFixed(6):"Not set"})})]})]}),L&&!h&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:_("w-2 h-2 rounded-full",u?"bg-accent-success":"bg-text-muted")}),t.jsx("span",{className:"type-body-sm text-text-muted",children:u?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const W=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Z=[5,6,7,8,9,10,11,12],Q=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],ee="radioConfig",te="repeaterSettings",se="operatingMode";function ae({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:l,onSelect:n,onToggle:c}){const i=a.has(e.id),o=r===e.id,d=e.children&&e.children.length>0,u="allow"===l;return t.jsxs("div",{children:[t.jsxs("div",{className:_("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",o?"bg-accent-primary/15":"hover:bg-subtle-fill",u&&"opacity-50 cursor-not-allowed"),style:{marginLeft:16*s+"px"},onClick:()=>!u&&n(e.id),children:[d?t.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:t.jsx(C,{className:_("w-3.5 h-3.5 text-text-muted transition-transform",i&&"rotate-90")})}):t.jsx("span",{className:"w-5"}),t.jsx(S,{className:"w-4 h-4 text-accent-primary flex-shrink-0"}),t.jsx("span",{className:"type-data text-text-primary flex-1 truncate",children:e.name}),t.jsx("span",{className:_("type-data-xs px-2 py-0.5 rounded-full","allow"===e.floodPolicy?"bg-accent-success/15 text-accent-success":"bg-accent-danger/15 text-accent-danger"),children:"allow"===e.floodPolicy?"Allow":"Deny"})]}),d&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(ae,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:l,onSelect:n,onToggle:c},e.id))})]})}function re(){var s,C,S,F,E,L;const{stats:P,setMode:z,clearModeMutation:J,setDutyCycleConfig:U,clearDutyCycleMutation:re,fetchStats:le,startMutation:ne,clearMutation:ce}=R(),ie=null==(s=null==P?void 0:P.config)?void 0:s.radio,oe=null==(C=null==P?void 0:P.config)?void 0:C.repeater,de=null==(S=null==P?void 0:P.config)?void 0:S.duty_cycle,ue=(null==P?void 0:P.node_name)||(null==(F=null==P?void 0:P.config)?void 0:F.node_name)||"Unknown Node",me=(null==oe?void 0:oe.mode)??"forward",xe=(null==de?void 0:de.enforcement_enabled)??!1,pe=null==(E=null==P?void 0:P.config)?void 0:E.delays,[be,he]=e.useState(!1),[ge,ye]=e.useState(""),[fe,je]=e.useState(62.5),[ve,Ne]=e.useState(7),[we,ke]=e.useState(5),[Ce,Se]=e.useState(""),[_e,Te]=e.useState("idle"),[Fe,Ee]=e.useState(null),Le=e.useRef(null),Pe=e.useRef(null),[Re,De]=e.useState(!1),[Ie,Me]=e.useState(""),[Ae,ze]=e.useState(""),[Oe,Ke]=e.useState(""),[qe,He]=e.useState("idle"),$e=e.useRef(null),Ye=e.useRef(null),[Be,Ve]=e.useState(!1),[Je,Ue]=e.useState(""),[Ge,Xe]=e.useState(""),[We,Ze]=e.useState(""),[Qe,et]=e.useState(""),[tt,st]=e.useState("idle"),[at,rt]=e.useState(null),lt=e.useRef(null),nt=e.useRef(null),[ct,it]=e.useState("idle"),[ot,dt]=e.useState("idle"),[ut,mt]=e.useState(null),[xt,pt]=e.useState(null),bt=e.useRef(!0),ht=e.useRef(null),gt=e.useRef(null),yt=e.useRef(null),ft=e.useRef(null),jt=e.useRef(!1),vt=e.useRef(!1);e.useEffect(()=>(bt.current=!0,()=>{bt.current=!1,ht.current&&clearTimeout(ht.current),gt.current&&clearTimeout(gt.current),yt.current&&clearTimeout(yt.current),ft.current&&clearTimeout(ft.current),_t.current&&clearTimeout(_t.current),Tt.current&&clearTimeout(Tt.current),Pe.current&&clearTimeout(Pe.current),$e.current&&clearTimeout($e.current),nt.current&&clearTimeout(nt.current)}),[]),e.useEffect(()=>{const e=e=>{if(be||Be||Re)return e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to leave?",e.returnValue};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[be,Be,Re]);const Nt=null==(L=null==P?void 0:P.config)?void 0:L.web,[wt,kt]=e.useState("idle"),[Ct,St]=e.useState(null),_t=e.useRef(null),Tt=e.useRef(null),Ft=e.useRef(!1),[Et,Lt]=e.useState([]),[Pt,Rt]=e.useState(!1),[Dt,It]=e.useState(null),[Mt,At]=e.useState(!1),[zt,Ot]=e.useState(""),[Kt,qt]=e.useState(null),[Ht,$t]=e.useState(!1),[Yt,Bt]=e.useState(null),[Vt,Jt]=e.useState(!1),[Ut,Gt]=e.useState(!1),[Xt,Wt]=e.useState(!1),[Zt,Qt]=e.useState([]),[es,ts]=e.useState(!1),[ss,as]=e.useState(null),[rs,ls]=e.useState("deny"),[ns,cs]=e.useState(!1),[is,os]=e.useState(null),[ds,us]=e.useState(new Set),[ms,xs]=e.useState(!1),[ps,bs]=e.useState(!1),[hs,gs]=e.useState(!1),[ys,fs]=e.useState(null),[js,vs]=e.useState(null),[Ns,ws]=e.useState(""),[ks,Cs]=e.useState("deny"),[Ss,_s]=e.useState(!1),[Ts,Fs]=e.useState(!0),[Es,Ls]=e.useState(!1),[Ps,Rs]=e.useState(!0),[Ds,Is]=e.useState("idle"),[Ms,As]=e.useState(!1),[zs,Os]=e.useState(!1),Ks=e.useRef(!1);e.useEffect(()=>{const e=be&&!Ks.current;Ks.current=be,ie&&e&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power)))},[ie,be]);const qs=e.useMemo(()=>{if(!ie||!be)return!1;const e=ie.frequency/1e6,t=ie.bandwidth/1e3,s=parseFloat(ge)||0;return Math.abs(s-e)>1e-4||fe!==t||ve!==ie.spreading_factor||we!==ie.coding_rate||parseInt(Ce)!==ie.tx_power},[ie,be,ge,fe,ve,we,Ce]),Hs=e.useCallback(()=>{he(!1),Ee(null),ie&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power)))},[ie]);e.useEffect(()=>{if(!be)return;const e=e=>{"loading"!==_e&&Le.current&&!Le.current.contains(e.target)&&Hs()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[be,Hs,_e]);const $s=e.useCallback(()=>{const e=null==pe?void 0:pe.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[pe]),Ys=e.useCallback(()=>{const e=null==pe?void 0:pe.direct_tx_delay_factor;return"number"==typeof e?e:.5},[pe]),Bs=e.useCallback(()=>{const e=null==de?void 0:de.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[de]),Vs=e.useCallback(()=>{Me($s().toFixed(2)),ze(Ys().toFixed(2)),Ke(Bs().toFixed(1)),De(!0)},[$s,Ys,Bs]),Js=e.useCallback(()=>{De(!1)},[]);e.useEffect(()=>{if(!Re)return;const e=e=>{"loading"!==qe&&Ye.current&&!Ye.current.contains(e.target)&&Js()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Re,Js,qe]);const Us=e.useCallback(()=>{var e,t,s;Ue(ue),Xe((null==(e=null==oe?void 0:oe.latitude)?void 0:e.toString())||"0"),Ze((null==(t=null==oe?void 0:oe.longitude)?void 0:t.toString())||"0"),et((null==(s=null==oe?void 0:oe.send_advert_interval_hours)?void 0:s.toString())||"0"),rt(null),Ve(!0)},[ue,oe]),Gs=e.useCallback(()=>{Ve(!1),rt(null)},[]);e.useEffect(()=>{if(!Be)return;const e=e=>{"loading"!==tt&<.current&&!lt.current.contains(e.target)&&Gs()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Be,Gs,tt]);const Xs=async()=>{var e;if("loading"===wt)return;const t=(null==Nt?void 0:Nt.cors_enabled)??!1,s=!t,a=t;_t.current&&clearTimeout(_t.current),Tt.current&&clearTimeout(Tt.current),Ft.current=!1,St(s),kt("loading"),_t.current=setTimeout(()=>{Ft.current||bt.current&&(St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3))},1e4);try{const t=await V({web:{cors_enabled:s}});if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!bt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await le(),kt("success"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3)):(St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3))}catch{if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!bt.current)return;St(a),kt("error"),Tt.current=setTimeout(()=>{bt.current&&(kt("idle"),St(null))},2e3)}};e.useEffect(()=>{(async()=>{Rs(!0);try{const e=await async function(){return T("/api/check_pymc_console")}();e.success&&e.data?Ls(e.data.exists):Ls(!1);const t=null==Nt?void 0:Nt.web_path;Fs(!t||""===t)}catch{Ls(!1)}finally{Rs(!1)}})()},[null==Nt?void 0:Nt.web_path]);const Ws=async e=>{var t;if("loading"!==Ds){Is("loading");try{const s=await V({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!bt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Fs(e),Is("success"),As(!0),setTimeout(()=>{bt.current&&Is("idle")},2e3)):(Is("error"),setTimeout(()=>{bt.current&&Is("idle")},2e3))}catch{if(!bt.current)return;Is("error"),setTimeout(()=>{bt.current&&Is("idle")},2e3)}}},Zs=e.useCallback(async()=>{Rt(!0),It(null);try{const e=await async function(){return T("/auth/tokens")}();Lt(e.tokens||[])}catch(e){It(e instanceof Error?e.message:"Failed to fetch tokens")}finally{Rt(!1)}},[]);e.useEffect(()=>{Zs()},[Zs]);const Qs=async()=>{if(zt.trim()){Jt(!0),It(null);try{const e=await async function(e){return T("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}(zt.trim());qt(e.token||null),At(!1),$t(!0),Ot(""),await Zs()}catch(e){It(e instanceof Error?e.message:"Failed to create token")}finally{Jt(!1)}}else It("Token name is required")},ea=e=>e?new Date(1e3*e).toLocaleString():"Never",ta=e.useCallback(e=>{const t=new Map,s=[];return e.forEach(e=>{const s={id:e.id,name:e.name,floodPolicy:e.flood_policy,transport_key:e.transport_key,last_used:e.last_used,parent_id:e.parent_id,children:[]};t.set(e.id,s)}),t.forEach(e=>{e.parent_id&&t.has(e.parent_id)?t.get(e.parent_id).children.push(e):s.push(e)}),s},[]),sa=e.useCallback(async()=>{ts(!0),as(null);try{const e=await async function(){return T("/api/transport_keys")}();e.success&&e.data?Qt(ta(e.data)):as(e.error||"Failed to load transport keys")}catch(e){as(e instanceof Error?e.message:"Unknown error occurred")}finally{ts(!1)}},[ta]);e.useEffect(()=>{sa()},[sa]);const aa=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=aa(s.children,t);if(e)return e}}return null},[]),ra=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);return null==e?void 0:e.name},[is,Zt,aa]),la=e.useCallback(e=>{us(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),na=async e=>{cs(!0),as(null);try{const t=await async function(e){return T("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}("allow"===e);t.success?ls(e):as(t.error||"Failed to update global flood policy")}catch(t){as(t instanceof Error?t.message:"Failed to update global flood policy")}finally{cs(!1)}},ca=async()=>{if(Ns.trim()){_s(!0),as(null);try{const e=await async function(e){return T("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}({name:Ns.trim(),flood_policy:ks,parent_id:is??void 0});e.success?(await sa(),xs(!1),ws(""),Cs("deny")):as(e.error||"Failed to add transport key")}catch(e){as(e instanceof Error?e.message:"Failed to add transport key")}finally{_s(!1)}}else as("Key name is required")},ia=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);e&&(fs({...e}),bs(!0))},[is,Zt,aa]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(ms&&(xs(!1),ws(""),Cs("deny")),ps&&(bs(!1),fs(null)),hs&&(gs(!1),vs(null)),Mt&&(At(!1),Ot("")),Ht&&($t(!1),qt(null)))};if(ms||ps||hs||Mt||Ht)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ms,ps,hs,Mt,Ht]);const oa=e.useCallback(()=>{if(!is)return;const e=aa(Zt,is);e&&(vs(e),gs(!0))},[is,Zt,aa]);return t.jsxs(q,{children:[t.jsx(H,{title:"Configuration",icon:t.jsx(o,{})}),t.jsxs(Y,{template:"standard",children:[t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:lt,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-2",children:[t.jsx(d,{className:"icon-md text-accent-primary"}),"Repeater Settings"]}),t.jsx("div",{className:"flex items-center gap-1",children:oe&&(Be?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Gs,disabled:"loading"===tt,className:_("p-2 rounded-lg transition-colors","loading"===tt?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==tt){nt.current&&clearTimeout(nt.current),ne(te),st("loading"),rt(null);try{const e={};Je&&Je!==ue&&(e.node_name=Je);const t=parseFloat(Ge);isNaN(t)||t===(null==oe?void 0:oe.latitude)||(e.latitude=t);const s=parseFloat(We);isNaN(s)||s===(null==oe?void 0:oe.longitude)||(e.longitude=s);const a=parseInt(Qe);if(isNaN(a)||a===(null==oe?void 0:oe.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return rt({success:!0,message:"No changes to save"}),st("idle"),void ce(te);const r=await M(e);if(!bt.current)return void ce(te);if(r.success&&r.data){const e=r.data.applied.join(", ");rt({success:!0,message:`Updated: ${e}`}),await le({force:!0}),st("success"),nt.current=setTimeout(()=>{bt.current&&(st("idle"),Ve(!1),rt(null),ce(te))},1500)}else rt({success:!1,message:r.error||"Failed to save"}),st("error"),ce(te),nt.current=setTimeout(()=>{bt.current&&st("idle")},2e3)}catch(e){if(!bt.current)return void ce(te);rt({success:!1,message:String(e)}),st("error"),ce(te),nt.current=setTimeout(()=>{bt.current&&st("idle")},2e3)}}},disabled:"loading"===tt,className:_("p-2 rounded-lg transition-colors","loading"===tt?"text-accent-primary cursor-wait":"success"===tt?"text-accent-success":"error"===tt?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===tt?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===tt?t.jsx(n,{className:"w-4 h-4"}):"error"===tt?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Us,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit repeater settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),at&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",at.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:at.message}),oe?t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"col-span-2",children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Node Name"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"text",value:Je,onChange:e=>Ue(e.target.value),maxLength:50,className:"w-full bg-transparent text-text-primary focus:outline-none type-data",placeholder:"Enter node name"}):t.jsx("span",{className:"type-data text-text-primary",children:ue})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:Ge,onChange:e=>Xe(e.target.value),step:"0.000001",min:"-90",max:"90",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:0!==oe.latitude?oe.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:We,onChange:e=>Ze(e.target.value),step:"0.000001",min:"-180",max:"180",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:0!==oe.longitude?oe.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Be?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Be?t.jsx("input",{type:"number",value:Qe,onChange:e=>et(e.target.value),min:"0",max:"48",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:oe.send_advert_interval_hours>0?`${oe.send_advert_interval_hours}h`:"Disabled"})}),Be&&t.jsx("p",{className:"type-data-xs text-text-muted mt-1 ml-4",children:"0 = disabled, 3-48 hours"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Score-based TX"}),t.jsx("div",{className:"h-[38px] rounded-full px-4 flex items-center bg-subtle-fill",children:t.jsx("span",{className:"type-data text-text-primary",children:oe.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:Le,children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-2",children:[t.jsx(u,{className:"icon-md text-accent-primary"}),"Radio Configuration"]}),t.jsx("div",{className:"flex items-center gap-1",children:ie&&(be?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Hs,disabled:"loading"===_e,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==_e){Pe.current&&clearTimeout(Pe.current),ne(ee),Te("loading"),Ee(null);try{const e={},t=parseFloat(ge),s=ie?ie.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=ie?ie.bandwidth/1e3:0;fe!==a&&(e.bandwidth_khz=fe),ve!==(null==ie?void 0:ie.spreading_factor)&&(e.spreading_factor=ve),we!==(null==ie?void 0:ie.coding_rate)&&(e.coding_rate=we);const r=parseInt(Ce);if(r!==(null==ie?void 0:ie.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return Ee({success:!0,message:"No changes to save"}),Te("idle"),void ce(ee);const l=await M(e);if(!bt.current)return void ce(ee);if(l.success&&l.data){const e=l.data.applied.join(", "),t=l.data.live_update?" (applied live)":" (restart required)";Ee({success:!0,message:`Updated: ${e}${t}`}),await le({force:!0}),Te("success"),Pe.current=setTimeout(()=>{bt.current&&(Te("idle"),he(!1),Ee(null),ce(ee))},1500)}else Ee({success:!1,message:l.error||"Failed to save"}),Te("error"),ce(ee),Pe.current=setTimeout(()=>{bt.current&&Te("idle")},2e3)}catch(e){if(!bt.current)return void ce(ee);Ee({success:!1,message:String(e)}),Te("error"),ce(ee),Pe.current=setTimeout(()=>{bt.current&&Te("idle")},2e3)}}},disabled:"loading"===_e||!qs,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-accent-primary cursor-wait":"success"===_e?"text-accent-success":"error"===_e?"text-accent-danger":qs?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:qs?"Save changes":"No changes to save",children:"loading"===_e?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===_e?t.jsx(n,{className:"w-4 h-4"}):"error"===_e?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{ie&&(ye((ie.frequency/1e6).toFixed(3)),je(ie.bandwidth/1e3),Ne(ie.spreading_factor),ke(ie.coding_rate),Se(String(ie.tx_power))),Ee(null),he(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit radio settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),Fe&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",Fe.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:Fe.message}),ie?t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:be?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsx("input",{type:"number",value:ge,onChange:e=>ye(e.target.value),step:"0.001",min:"400",max:"930",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:D(ie.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:be?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsx("input",{type:"number",value:Ce,onChange:e=>Se(e.target.value),min:"-9",max:"22",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsxs("span",{className:"type-data text-text-primary",children:[ie.tx_power," dBm"]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Bandwidth"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:fe,onChange:e=>je(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:W.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsx("span",{className:"type-data text-text-primary",children:I(ie.bandwidth)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Spreading Factor"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:ve,onChange:e=>Ne(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:Z.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:["SF",ie.spreading_factor]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Coding Rate"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors relative",be?"bg-subtle-fill-hover":"bg-subtle-fill"),children:be?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:we,onChange:e=>ke(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:Q.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(m,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:["4/",ie.coding_rate]})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:"Preamble"}),t.jsx("div",{className:"h-[38px] rounded-full px-4 flex items-center bg-subtle-fill",children:t.jsxs("span",{className:"type-data text-text-primary",children:[ie.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(Y,{template:"standard",children:[t.jsx(B,{span:12,md:6,children:t.jsx(K,{children:t.jsxs("div",{ref:Ye,children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h2",{className:"type-subheading text-text-primary flex items-center gap-3",children:[t.jsx(x,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:Re?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==qe){$e.current&&clearTimeout($e.current),ne(se),He("loading");try{const e=await M({tx_delay_factor:parseFloat(Ie),direct_tx_delay_factor:parseFloat(Ae)});if(await U({max_airtime_percent:parseFloat(Oe),enforcement_enabled:xe}),!bt.current)return void ce(se);e.success&&e.data?(await le({force:!0}),He("success"),$e.current=setTimeout(()=>{bt.current&&(He("idle"),De(!1),ce(se))},1500)):(He("error"),ce(se),$e.current=setTimeout(()=>{bt.current&&He("idle")},2e3))}catch{if(!bt.current)return void ce(se);He("error"),ce(se),$e.current=setTimeout(()=>{bt.current&&He("idle")},2e3)}}},disabled:"loading"===qe,className:_("p-2 rounded-lg transition-colors","loading"===qe?"text-accent-primary cursor-wait":"success"===qe?"text-accent-success":"error"===qe?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===qe?t.jsx(l,{className:"w-4 h-4 animate-spin"}):"success"===qe?t.jsx(n,{className:"w-4 h-4"}):"error"===qe?t.jsx(r,{className:"w-4 h-4"}):t.jsx(n,{className:"w-4 h-4"})}),t.jsx("button",{onClick:Js,className:"p-2 rounded-lg text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Vs,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit settings",children:t.jsx(c,{className:"w-4 h-4"})})})]}),t.jsx("p",{className:"type-label text-text-muted mb-3",children:"Control how the repeater handles packets"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsxs("div",{className:"flex-1 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Repeat"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==ut?ut:"forward"===me;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ct)return;const t=!e,s="forward"===me;ht.current&&clearTimeout(ht.current),gt.current&&clearTimeout(gt.current),jt.current=!1,mt(t),it("loading"),ht.current=setTimeout(()=>{jt.current||bt.current&&(mt(s),it("error"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null))},2e3))},1e4);try{if(await z(t?"forward":"monitor"),jt.current=!0,ht.current&&clearTimeout(ht.current),!bt.current)return;it("success"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null),J())},2e3)}catch{if(jt.current=!0,ht.current&&clearTimeout(ht.current),!bt.current)return;mt(s),it("error"),gt.current=setTimeout(()=>{bt.current&&(it("idle"),mt(null))},2e3)}},disabled:"loading"===ct,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===ct&&"opacity-70"),"aria-label":"Toggle forward mode",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),t.jsx("span",{className:_("type-data text-sm w-7",e?"text-accent-success":"text-text-muted"),children:e?"On":"Off"}),"loading"===ct&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ct&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===ct&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Duty Cycle"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==xt?xt:xe;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ot)return;const t=!e,s=xe;yt.current&&clearTimeout(yt.current),ft.current&&clearTimeout(ft.current),vt.current=!1,pt(t),dt("loading"),yt.current=setTimeout(()=>{vt.current||bt.current&&(pt(s),dt("error"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null))},2e3))},1e4);try{if(await U({max_airtime_percent:Bs(),enforcement_enabled:t}),vt.current=!0,yt.current&&clearTimeout(yt.current),!bt.current)return;dt("success"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null),re())},2e3)}catch{if(vt.current=!0,yt.current&&clearTimeout(yt.current),!bt.current)return;pt(s),dt("error"),ft.current=setTimeout(()=>{bt.current&&(dt("idle"),pt(null))},2e3)}},disabled:"loading"===ot,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===ot&&"opacity-70"),"aria-label":"Toggle duty cycle",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),t.jsx("span",{className:_("type-data text-sm w-7",e?"text-accent-success":"text-text-muted"),children:e?"On":"Off"}),"loading"===ot&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ot&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===ot&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Max Airtime"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Oe,onChange:e=>Ke(e.target.value),step:"0.5",min:"0.1",max:"100",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"%"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[Bs().toFixed(1),"%"]})})]})]}),t.jsx("div",{className:"hidden sm:block w-px bg-border-subtle"}),t.jsxs("div",{className:"flex-1 pt-4 sm:pt-0 border-t sm:border-t-0 border-border-subtle",children:[t.jsx("label",{className:"type-label text-text-muted block mb-3",children:"TX Delays"}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Flood"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ie,onChange:e=>Me(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"x"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[$s().toFixed(2),"x"]})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Direct"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Re?"bg-subtle-fill-hover":"bg-subtle-fill"),children:Re?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ae,onChange:e=>ze(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"s"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[Ys().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx(B,{span:12,md:6,children:t.jsxs(K,{children:[t.jsx($,{icon:t.jsx(o,{}),title:"App Settings",largeTitle:!0}),t.jsx("p",{className:"type-body-sm text-text-muted mb-4",children:"Appearance and web server options."}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("span",{className:"type-body text-text-primary font-medium block",children:"Enable CORS"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Allow cross-origin API access"})]}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==Ct?Ct:(null==Nt?void 0:Nt.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Xs,disabled:"loading"===wt,className:_("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2",e?"bg-toggle-on border-toggle-on":"bg-toggle-off border-border-subtle","loading"===wt&&"opacity-70"),title:e?"Disable CORS":"Enable CORS",children:t.jsx("span",{className:_("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",e?"translate-x-5":"translate-x-0.5")})}),"loading"===wt&&t.jsx(l,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===wt&&t.jsx(n,{className:"w-4 h-4 text-accent-success"}),"error"===wt&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsx("div",{children:t.jsx(G,{})})]})]})})]}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(p,{className:"icon-md text-accent-primary"}),"Regions / Transport Keys"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Manage regional key hierarchy for flood control"})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsxs("button",{onClick:()=>xs(!0),disabled:"allow"===rs,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===rs?"bg-subtle-fill text-text-muted cursor-not-allowed":"bg-accent-success/10 hover:bg-accent-success/20 text-accent-success"),children:[t.jsx(b,{className:"w-3.5 h-3.5"}),"Add"]}),t.jsx("button",{onClick:ia,disabled:!is||"allow"===rs,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",is&&"allow"!==rs?"bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary":"bg-subtle-fill text-text-muted cursor-not-allowed"),children:"Edit"}),t.jsx("button",{onClick:oa,disabled:!is||"allow"===rs,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",is&&"allow"!==rs?"bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger":"bg-subtle-fill text-text-muted cursor-not-allowed"),children:"Delete"})]})]}),t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 mb-4",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:_("w-10 h-10 rounded-full flex items-center justify-center","allow"===rs?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===rs?t.jsx(h,{className:"w-5 h-5 text-accent-success"}):t.jsx(g,{className:"w-5 h-5 text-accent-danger"})}),t.jsxs("div",{children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:"Global Flood Policy"}),t.jsx("p",{className:"type-body-sm text-text-muted",children:"Master control for repeater flooding"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-subtle-fill rounded-full p-1",children:[t.jsx("button",{onClick:()=>na("deny"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===rs?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>na("allow"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===rs?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Allow"})]}),ns&&t.jsx(l,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),ss&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:ss}),t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 min-h-[120px]",children:es?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(l,{className:"w-5 h-5 animate-spin text-accent-primary mr-2"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Loading transport keys..."})]}):0===Zt.length?t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:t.jsx(p,{className:"w-6 h-6 text-text-muted/50"})}),t.jsx("p",{className:"type-body text-text-muted",children:"No transport keys found"}),t.jsx("p",{className:"type-body-sm text-text-muted/70 mt-1",children:"Add your first transport key to get started"})]}):t.jsx("div",{className:"space-y-1",children:Zt.map(e=>t.jsx(ae,{node:e,level:0,expandedKeys:ds,selectedKeyId:is,globalFloodPolicy:rs,onSelect:os,onToggle:la},e.id))})})]})}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(y,{className:"icon-md text-accent-primary"}),"API Tokens"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Manage API tokens for machine-to-machine authentication"})]}),t.jsxs("button",{onClick:()=>At(!0),className:"flex items-center justify-center gap-2 h-[32px] px-4 bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary rounded-full transition-colors type-body-sm font-medium",children:[t.jsx(b,{className:"w-4 h-4"}),"Create Token"]})]}),t.jsx("div",{className:"bg-accent-tertiary/5 rounded-2xl p-4 mb-4",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-accent-tertiary/20 flex items-center justify-center flex-shrink-0",children:t.jsx(i,{className:"w-4 h-4 text-accent-tertiary"})}),t.jsxs("div",{className:"type-body-sm text-text-muted",children:[t.jsxs("p",{children:[t.jsx("span",{className:"text-text-secondary",children:"API tokens"})," are used for machine-to-machine authentication. Include the token in the ",t.jsx("code",{className:"type-code bg-accent-tertiary/20 px-1.5 py-0.5 rounded-full text-accent-tertiary",children:"X-API-Key"})," header when making API requests."]}),t.jsx("p",{className:"mt-1 text-text-muted/70",children:"Tokens are only shown once at creation. Store them securely."})]})]})}),Dt&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Dt}),Pt&&0===Et.length?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(l,{className:"w-5 h-5 animate-spin text-accent-primary mr-2"}),t.jsx("span",{className:"type-body-sm text-text-muted",children:"Loading tokens..."})]}):Et.length>0?t.jsx("div",{className:"space-y-2",children:Et.map(e=>t.jsx("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong rounded-2xl p-4 transition-colors",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-accent-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(y,{className:"w-5 h-5 text-accent-primary"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h3",{className:"type-body text-text-primary font-medium truncate",children:e.name}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-4 mt-0.5",children:[t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Created: ",ea(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",ea(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Bt({id:e.id,name:e.name}),disabled:Ut,className:"h-[32px] px-4 bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger rounded-full transition-colors disabled:opacity-50 type-body-sm font-medium flex items-center justify-center gap-1.5",children:[t.jsx(a,{className:"w-3.5 h-3.5"}),"Revoke"]})]})},e.id))}):t.jsxs("div",{className:"bg-subtle-fill rounded-2xl p-6 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:t.jsx(y,{className:"w-7 h-7 text-text-muted/50"})}),t.jsx("h3",{className:"type-body text-text-primary font-medium mb-1",children:"No API Tokens"}),t.jsx("p",{className:"type-body-sm text-text-muted mb-4",children:"Create a token to enable API access"}),t.jsx("button",{onClick:()=>At(!0),className:"h-[32px] px-4 bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary rounded-full transition-colors type-body-sm font-medium",children:"Create Your First Token"})]})]})}),t.jsx(Y,{template:"auto",children:t.jsxs(K,{children:[t.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:t.jsxs("div",{children:[t.jsxs("h2",{className:"type-heading text-text-primary flex items-center gap-2",children:[t.jsx(f,{className:"icon-md text-accent-primary"}),"Web Frontend"]}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Choose which web interface to use"})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("label",{className:_("flex items-start gap-3 p-4 bg-subtle-fill rounded-2xl border-2 cursor-pointer transition-all",Ts?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Ds&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ts,onChange:()=>Ws(!0),disabled:"loading"===Ds,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"Default Frontend"}),t.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"type-data-xs bg-accent-tertiary/15 text-accent-tertiary px-2.5 py-0.5 rounded-full font-medium hover:bg-accent-tertiary/25 transition-colors",children:"@RightUp"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Built-in pyMC Repeater web interface"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),t.jsxs("label",{className:_("flex items-start gap-3 p-4 bg-subtle-fill rounded-2xl border-2 cursor-pointer transition-all",Ts?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Ds&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ts,onChange:()=>Ws(!1),disabled:"loading"===Ds,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"PyMC Console"}),t.jsx("span",{className:"type-data-xs bg-accent-secondary/15 text-accent-secondary px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_console/web/html"})]})]})]}),!Ps&&t.jsx("div",{className:_("bg-subtle-fill rounded-2xl p-4",Es?"border border-accent-success/20":"border border-accent-tertiary/20"),children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:_("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",Es?"bg-accent-success/20":"bg-accent-tertiary/20"),children:Es?t.jsx(j,{className:"w-4 h-4 text-accent-success"}):t.jsx(i,{className:"w-4 h-4 text-accent-tertiary"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:Es?"PyMC Console has been detected":"PyMC Console Not Installed"}),Es?t.jsxs("p",{className:"type-body-sm text-text-muted mt-1",children:["PyMC Console is installed at ",t.jsx("code",{className:"type-code bg-accent-success/10 px-1.5 py-0.5 rounded-full text-accent-success",children:"/opt/pymc_console/web/html"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"type-body-sm text-text-muted mt-1 mb-3",children:["PyMC Console must be installed at ",t.jsx("code",{className:"type-code bg-accent-tertiary/10 px-1.5 py-0.5 rounded-full text-accent-tertiary",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),t.jsxs("a",{href:"https://github.com/dmduran12/pymc_console-dist",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 h-[32px] px-4 bg-accent-tertiary/10 hover:bg-accent-tertiary/20 text-accent-tertiary rounded-full type-body-sm font-medium transition-colors",children:[t.jsx(v,{className:"w-4 h-4"}),"PyMC Console Install Instructions"]})]})]})]})}),Ms&&t.jsx("div",{className:"bg-subtle-fill rounded-2xl p-4 border border-accent-secondary/30",children:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-accent-secondary/20 flex items-center justify-center flex-shrink-0",children:t.jsx(N,{className:"w-4 h-4 text-accent-secondary"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h4",{className:"type-body text-text-primary font-medium",children:"Service restart required"}),t.jsx("p",{className:"type-body-sm text-text-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),t.jsx("button",{onClick:async()=>{if(!zs){Os(!0);try{await async function(){return T("/api/restart_service",{method:"POST",body:"{}"})}(),As(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{As(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:zs,className:"h-[32px] px-4 bg-accent-secondary/10 hover:bg-accent-secondary/20 text-accent-secondary rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 whitespace-nowrap type-body-sm font-medium",children:zs?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Restarting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(w,{className:"w-4 h-4"}),"Restart Now"]})})]})})]})]})}),P&&t.jsx(Y,{template:"auto",children:t.jsx(O,{nodeName:ue,repeaterVersion:P.version,coreVersion:P.core_version,localHash:P.local_hash,publicKey:P.public_key})}),P&&(0===(null==oe?void 0:oe.latitude)||!(null==oe?void 0:oe.latitude))&&(0===(null==oe?void 0:oe.longitude)||!(null==oe?void 0:oe.longitude))&&t.jsx(Y,{template:"auto",children:t.jsx(X,{})}),Mt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&At(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"create-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Create API Token"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Token Name"}),t.jsx("input",{type:"text",value:zt,onChange:e=>Ot(e.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&Qs(),autoFocus:!0}),t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Give your token a descriptive name to identify its purpose"})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{At(!1),Ot(""),It(null)},disabled:Vt,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:Qs,disabled:Vt||!zt.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Vt?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),Ht&&Kt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&$t(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-lg w-full shadow-2xl",children:[t.jsx("h3",{id:"show-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Token Created Successfully"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(N,{className:"w-4 h-4 text-accent-secondary flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-text-secondary",children:[t.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Your API Token"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:Kt,readOnly:!0,className:"flex-1 px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary font-mono text-sm"}),t.jsxs("button",{onClick:()=>{Kt&&(navigator.clipboard.writeText(Kt),Wt(!0),setTimeout(()=>Wt(!1),2e3))},className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors flex items-center gap-2",title:"Copy to clipboard",children:[Xt?t.jsx(n,{className:"w-4 h-4 text-accent-success"}):t.jsx(k,{className:"w-4 h-4"}),Xt?"Copied!":"Copy"]})]})]}),t.jsxs("div",{className:"bg-accent-tertiary/10 border border-accent-tertiary/30 rounded-lg p-3",children:[t.jsx("p",{className:"text-sm text-text-secondary mb-2",children:t.jsx("strong",{children:"Usage Example:"})}),t.jsxs("code",{className:"block bg-accent-tertiary/20 px-3 py-2 rounded text-xs text-accent-tertiary font-mono overflow-x-auto",children:['curl -H "X-API-Key: ',Kt.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{$t(!1),qt(null)},className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors",children:"Done"})})]})]})}),t.jsx(A,{isOpen:!!Yt,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Yt?void 0:Yt.name}'? This action cannot be undone.`,confirmLabel:Ut?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Yt){Gt(!0),It(null);try{await async function(e){return T(`/auth/tokens/${e}`,{method:"DELETE"})}(Yt.id),await Zs(),Bt(null)}catch(e){It(e instanceof Error?e.message:"Failed to revoke token")}finally{Gt(!1)}}},onCancel:()=>Bt(null)}),ms&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&xs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"add-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Add Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[is&&t.jsxs("div",{className:"bg-accent-tertiary/10 border border-accent-tertiary/30 rounded-lg p-3 text-sm text-text-secondary",children:["Adding as child of: ",t.jsx("strong",{className:"text-text-primary",children:ra()})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:Ns,onChange:e=>ws(e.target.value),placeholder:"e.g., Region Name, Group Key",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&ca(),autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>Cs("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ks?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>Cs("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ks?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{xs(!1),ws(""),Cs("deny")},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:ca,disabled:Ss||!Ns.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),ps&&ys&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&bs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"edit-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Edit Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:ys.name,onChange:e=>fs({...ys,name:e.target.value}),className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ys.floodPolicy?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>fs({...ys,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ys.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),ys.transport_key&&t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Transport Key"}),t.jsx("code",{className:"block bg-bg-subtle px-3 py-2 rounded-lg text-xs text-text-muted font-mono overflow-x-auto",children:ys.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{bs(!1),vs(ys),gs(!0),fs(null)},disabled:Ss,className:"px-4 py-2 bg-accent-danger/20 hover:bg-accent-danger/30 text-accent-danger rounded-lg border border-accent-danger/50 transition-colors disabled:opacity-50",children:"Delete"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx("button",{onClick:()=>{bs(!1),fs(null)},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(ys){_s(!0),as(null);try{const e=await async function(e,t){return T(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}(ys.id,{name:ys.name,flood_policy:ys.floodPolicy});e.success?(await sa(),bs(!1),fs(null)):as(e.error||"Failed to update transport key")}catch(e){as(e instanceof Error?e.message:"Failed to update transport key")}finally{_s(!1)}}},disabled:Ss||!ys.name.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),hs&&js&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&gs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"delete-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Delete Transport Key"}),t.jsxs("p",{className:"text-text-secondary mb-4",children:["Are you sure you want to delete ",t.jsxs("strong",{className:"text-text-primary",children:["'",js.name,"'"]}),"?"]}),js.children&&js.children.length>0&&t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3 mb-4",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(N,{className:"w-4 h-4 text-accent-secondary flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-text-secondary",children:["This key has ",js.children.length," child key(s). Deleting will also remove all children."]})]})}),t.jsxs("div",{className:"flex justify-end gap-3",children:[t.jsx("button",{onClick:()=>{gs(!1),vs(null)},disabled:Ss,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(js){_s(!0),as(null);try{const e=await async function(e){return T(`/api/transport_key/${e}`,{method:"DELETE"})}(js.id);e.success?(await sa(),gs(!1),vs(null),os(null)):as(e.error||"Failed to delete transport key")}catch(e){as(e instanceof Error?e.message:"Failed to delete transport key")}finally{_s(!1)}}},disabled:Ss,className:"px-4 py-2 bg-accent-danger/20 hover:bg-accent-danger/30 text-accent-danger rounded-lg border border-accent-danger/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Ss?t.jsxs(t.Fragment,{children:[t.jsx(l,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{re as default}; diff --git a/frontend/dist/assets/ConfirmModal-DlFyryXJ.js b/frontend/dist/assets/ConfirmModal-CYXFGX_W.js similarity index 95% rename from frontend/dist/assets/ConfirmModal-DlFyryXJ.js rename to frontend/dist/assets/ConfirmModal-CYXFGX_W.js index f657f943..426e4ce3 100644 --- a/frontend/dist/assets/ConfirmModal-DlFyryXJ.js +++ b/frontend/dist/assets/ConfirmModal-CYXFGX_W.js @@ -1 +1 @@ -import{r as e,j as t,at as n}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{N as r,aL as o,O as a,aM as c}from"./index-CPdqYR4z.js";const i={danger:{icon:"text-accent-danger",button:"bg-accent-danger hover:brightness-110 active:brightness-90"},warning:{icon:"text-accent-secondary",button:"bg-accent-secondary hover:brightness-110 active:brightness-90 text-bg-body"},default:{icon:"text-accent-primary",button:"bg-accent-primary hover:brightness-110 active:brightness-90 text-bg-body"}},l=e.memo(function({isOpen:e,title:l="Confirm",message:b,confirmLabel:d="Confirm",cancelLabel:m="Cancel",variant:x="default",onConfirm:g,onCancel:h}){const u=i[x];return t.jsxs(r,{open:e,onClose:h,size:"sm",children:[t.jsx(o,{icon:t.jsx(n,{className:s("w-5 h-5",u.icon)}),title:l,onClose:h}),t.jsx(a,{children:t.jsx("p",{className:"text-sm text-text-secondary",children:b})}),t.jsxs(c,{children:[t.jsx("button",{onClick:h,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-secondary bg-bg-subtle hover:bg-bg-elevated border border-border-subtle transition-colors",children:m}),t.jsx("button",{onClick:g,className:s("flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-primary transition-colors",u.button),children:d})]})]})});export{l as C}; +import{r as e,j as t,at as n}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{N as r,aL as o,O as a,aM as c}from"./index-BJEgt3tp.js";const i={danger:{icon:"text-accent-danger",button:"bg-accent-danger hover:brightness-110 active:brightness-90"},warning:{icon:"text-accent-secondary",button:"bg-accent-secondary hover:brightness-110 active:brightness-90 text-bg-body"},default:{icon:"text-accent-primary",button:"bg-accent-primary hover:brightness-110 active:brightness-90 text-bg-body"}},l=e.memo(function({isOpen:e,title:l="Confirm",message:b,confirmLabel:d="Confirm",cancelLabel:m="Cancel",variant:x="default",onConfirm:g,onCancel:h}){const u=i[x];return t.jsxs(r,{open:e,onClose:h,size:"sm",children:[t.jsx(o,{icon:t.jsx(n,{className:s("w-5 h-5",u.icon)}),title:l,onClose:h}),t.jsx(a,{children:t.jsx("p",{className:"text-sm text-text-secondary",children:b})}),t.jsxs(c,{children:[t.jsx("button",{onClick:h,className:"flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-secondary bg-bg-subtle hover:bg-bg-elevated border border-border-subtle transition-colors",children:m}),t.jsx("button",{onClick:g,className:s("flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-text-primary transition-colors",u.button),children:d})]})]})});export{l as C}; diff --git a/frontend/dist/assets/Contacts-BcOss4J-.js b/frontend/dist/assets/Contacts-CyyU4xmf.js similarity index 98% rename from frontend/dist/assets/Contacts-BcOss4J-.js rename to frontend/dist/assets/Contacts-CyyU4xmf.js index 1c35a50b..d1e713aa 100644 --- a/frontend/dist/assets/Contacts-BcOss4J-.js +++ b/frontend/dist/assets/Contacts-CyyU4xmf.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-JEW0aWu6.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-BNnTohl3.js","assets/index-CPdqYR4z.js","assets/ConfirmModal-DlFyryXJ.js","assets/DeepAnalysisModal-DysenxvY.js","assets/useThemeColors-AeHMyThq.js","assets/font-loader-jlbdh9Fw.js","assets/BasemapLayer-S9Ush6Hh.js","assets/SignalIndicator-BLrEkFNb.js","assets/ping-BvkXSZG_.js","assets/PageLayout-CcoYWyzO.js","assets/DataBox-CRX76VsB.js","assets/CollisionExplorerModal-Vkgg9Koo.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-CIefRaAd.css"])))=>i.map(i=>d[i]); -import{j as e,r as s,aJ as t,at as a,Z as n,q as l,aH as c,C as i,aK as r,a9 as o,ax as d,Y as x,_ as m,al as h,aL as p,aM as u,$ as g,as as j,ak as N,ar as b,aN as v,D as f,aO as y,az as w,ad as k,aP as C,E as S,aQ as M,X as L,aR as P,aS as H,aT as F,aU as E,aV as R,aW as $,aX as T,aq as _,aY as O,aZ as A}from"./vendor-react-C341c8YC.js";import{X as D,Y as z,M as W,Z as G,_ as U,$ as I,r as K,a0 as B,n as V,a1 as q,h as Y,a2 as Z,a3 as X,a4 as J,f as Q,p as ee,a5 as se,B as te,a6 as ae}from"./index-CPdqYR4z.js";import{p as ne}from"./ping-BvkXSZG_.js";import{P as le,b as ce}from"./PageLayout-CcoYWyzO.js";import{_ as ie}from"./deckgl-DTsmDcfs.js";import{n as re,L as oe,T as de,u as xe}from"./recharts-6XUQYgRA.js";import{D as me}from"./DataBox-CRX76VsB.js";import{C as he,a as pe}from"./SignalIndicator-BLrEkFNb.js";import{C as ue}from"./CollisionExplorerModal-Vkgg9Koo.js";import{C as ge}from"./ConfirmModal-DlFyryXJ.js";class je extends s.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var s;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 glass-card flex items-center justify-center",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-white/50 p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-white/30",children:(null==(s=this.state.error)?void 0:s.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-white/20 mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const Ne=s.lazy(()=>ie(()=>import("./ContactsMapMapLibre-JEW0aWu6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])));function be({neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o}){return e.jsx(je,{children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 glass-card flex items-center justify-center",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-white/50 flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(Ne,{neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o})})})}function ve(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function fe(e){return`${Math.round(100*e)}%`}function ye(e,s){return s.has(e.toUpperCase())}const we=s.memo(function({path:s,isHighlighted:t,onHighlight:c,ghostPrefixes:i}){const r=function(s){return s>.2?{icon:e.jsx(x,{className:"w-3 h-3"}),color:"text-accent-success"}:s<-.2?{icon:e.jsx(n,{className:"w-3 h-3"}),color:"text-accent-danger"}:{icon:e.jsx(m,{className:"w-3 h-3"}),color:"text-text-muted"}}(s.observationTrend),h=s.weakestLinkKey&&s.weakestLinkConfidence<.5,p=s.hops.some(e=>ye(e,i));return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md transition-colors cursor-pointer "+(t?"bg-accent-primary/20 border border-accent-primary/40":"hover:bg-white/5"),onClick:()=>c(t?null:s.weakestLinkKey),children:[e.jsx("div",{className:"flex-shrink-0 w-12 text-center py-1 rounded-md "+(u=s.healthScore,u>=.7?"bg-accent-success/10":u>=.5?"bg-accent-secondary/10":u>=.3?"bg-signal-poor/10":"bg-accent-danger/10"),children:e.jsx("span",{className:`text-xs font-semibold tabular-nums ${ve(s.healthScore)}`,children:fe(s.healthScore)})}),e.jsx("div",{className:"flex-1 flex items-center gap-0.5 overflow-x-auto min-w-0",children:s.hops.map((t,a)=>{var n;const c=ye(t,i),r=h&&(null==(n=s.weakestLinkKey)?void 0:n.includes(t));return e.jsxs("span",{className:"flex items-center",children:[e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded flex items-center gap-0.5 "+(c?"bg-accent-tertiary/20 text-accent-tertiary border border-accent-tertiary/30":r?"bg-accent-danger/20 text-accent-danger":"bg-white/10 text-text-secondary"),children:[c&&e.jsx(l,{className:"w-2.5 h-2.5"}),t]}),anew Set(p.map(e=>e.prefix.toUpperCase())),[p]),N=s.useMemo(()=>m.slice(0,o),[m,o]),b=s.useMemo(()=>0===m.length?null:{avgHealth:m.reduce((e,s)=>e+s.healthScore,0)/m.length,declining:m.filter(e=>e.observationTrend<-.2).length,weakLinks:m.filter(e=>e.weakestLinkConfidence<.5).length,pathsWithGhosts:m.filter(e=>e.hops.some(e=>j.has(e.toUpperCase()))).length},[m,j]),v=e=>{null==d||d(e)};return 0===m.length?null:e.jsxs("div",{className:"chart-container",children:[e.jsxs("button",{onClick:()=>g(!u),className:"w-full chart-header hover:bg-white/5 transition-colors rounded-t-lg cursor-pointer",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(t,{className:"chart-title-icon"}),"Path Health",e.jsxs("span",{className:"ml-2 text-[10px] font-normal text-text-muted",children:["(",m.length," paths)"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[b&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[e.jsxs("span",{className:`tabular-nums ${ve(b.avgHealth)}`,children:["Avg: ",fe(b.avgHealth)]}),b.weakLinks>0&&e.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[e.jsx(a,{className:"w-3 h-3"}),b.weakLinks," weak"]}),b.declining>0&&e.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}),b.declining," declining"]}),b.pathsWithGhosts>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),b.pathsWithGhosts," ghost"]})]}),u?e.jsx(c,{className:"w-4 h-4 text-text-muted"}):e.jsx(i,{className:"w-4 h-4 text-text-muted"})]})]}),u&&e.jsxs("div",{className:"p-3 pt-0 space-y-1",children:[h.totalPaths>0&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3 text-accent-primary"}),e.jsx("span",{className:"text-text-secondary",children:h.totalPaths.toLocaleString()})," Viterbi decoded"]}),h.observationOverrideCount>0&&e.jsxs("span",{className:"text-accent-success",children:[Math.round(h.observationOverrideCount/h.totalPaths*100),"% observation override"]}),p.length>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),p.length," ghost",1!==p.length?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-success"})," Healthy (≥70%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-secondary"})," Fair (50-70%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-signal-poor"})," Weak (30-50%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-danger"})," Critical (<30%)"]}),p.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3 text-accent-tertiary"})," Ghost"]})]}),e.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:N.map(s=>e.jsx(we,{path:s,isHighlighted:x===s.weakestLinkKey,onHighlight:v,ghostPrefixes:j},s.pathKey))}),m.length>o&&e.jsxs("div",{className:"text-center text-[10px] text-text-muted pt-2",children:["Showing top ",o," of ",m.length," paths"]})]})]})});function Ce(e){switch(e){case"rf_intersection":return"RF Circle Intersection";case"weighted_centroid":return"Weighted Centroid";case"single_anchor":return"Single Anchor (less reliable)";default:return e}}const Se={confirmed:{label:"Confirmed",icon:e.jsx(u,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-success/40",bgClass:"bg-accent-success/10",textClass:"text-accent-success",badgeClass:"bg-accent-success/20 text-accent-success"},likely:{label:"Likely",icon:e.jsx(g,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-tertiary/30",bgClass:"bg-accent-tertiary/5",textClass:"text-accent-tertiary",badgeClass:"bg-accent-tertiary/20 text-accent-tertiary"},possible:{label:"Possible",icon:e.jsx(j,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-secondary/20",bgClass:"bg-accent-secondary/5",textClass:"text-accent-secondary",badgeClass:"bg-accent-secondary/20 text-accent-secondary"},noise:{label:"Noise",icon:e.jsx(a,{className:"w-3.5 h-3.5"}),borderClass:"border-border-muted",bgClass:"bg-bg-card/30",textClass:"text-text-muted",badgeClass:"bg-bg-elevated text-text-muted"}};function Me({ghost:t,neighbors:n,isExpanded:o,onToggle:x,compact:m}){var h,p;const u=(null==(h=t.classification)?void 0:h.tier)??"noise",g=Se[u],j="clusterId"in(w=t)&&"temporal"in w;var w;const k=s.useMemo(()=>Array.from(t.commonNeighbors).map(e=>{var s;return{hash:e,name:null==(s=n[e])?void 0:s.name}}),[t.commonNeighbors,n]),C=t.estimatedLocation?t.estimatedLocation.uncertaintyM>=1e3?`±${(t.estimatedLocation.uncertaintyM/1e3).toFixed(1)}km`:`±${Math.round(t.estimatedLocation.uncertaintyM)}m`:null,S=j&&t.temporal?(M=t.temporal.consistency)>=.7?{label:"Steady",color:"text-accent-success"}:M>=.4?{label:"Regular",color:"text-accent-tertiary"}:M>=.2?{label:"Sporadic",color:"text-accent-secondary"}:{label:"Bursty",color:"text-signal-poor"}:null;var M;const L=j&&t.collisionCandidates&&t.collisionCandidates.length>0,P=L?t.collisionCandidates[0]:null;return m?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded bg-bg-elevated/50 text-sm",children:[e.jsx("span",{className:"font-mono font-medium text-text-secondary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:"text-text-muted",children:t.observationCount})]}):e.jsxs("div",{className:re("rounded-lg border transition-all duration-150",g.borderClass,g.bgClass),children:[e.jsxs("button",{onClick:x,className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-white/5 rounded-lg",children:[e.jsx(l,{className:re("w-5 h-5 flex-shrink-0",g.textClass)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-semibold text-text-primary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:re("px-1.5 py-0.5 rounded text-sm font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:re("text-sm mt-0.5",g.textClass),children:(null==(p=t.classification)?void 0:p.reason)??"Unknown"}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-text-muted mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3"}),t.observationCount]}),e.jsxs("span",{children:[(100*t.confidence).toFixed(0),"%"]}),t.commonNeighbors.size>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"}),t.commonNeighbors.size]}),t.estimatedLocation&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(b,{className:"w-3 h-3"}),C]}),S&&e.jsxs("span",{className:re("flex items-center gap-1",S.color),children:[e.jsx(d,{className:"w-3 h-3"}),S.label]}),L&&e.jsxs("span",{className:"flex items-center gap-1 text-signal-poor",children:[e.jsx(v,{className:"w-3 h-3"}),"Collision?"]})]})]}),o?e.jsx(c,{className:"w-4 h-4 text-text-muted"}):e.jsx(i,{className:"w-4 h-4 text-text-muted"})]}),o&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border-muted/50 mt-1 pt-3",children:[L&&P&&e.jsx("div",{className:"p-2 rounded bg-signal-poor/10 border border-signal-poor/30",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(v,{className:"w-4 h-4 text-signal-poor flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-signal-poor font-medium",children:"Possible collision with known node"}),e.jsx("div",{className:"text-text-secondary mt-0.5",children:P.knownNodeName?e.jsxs("span",{children:["May match ",e.jsx("span",{className:"font-medium",children:P.knownNodeName})," ","(",(100*P.collisionProbability).toFixed(0),"% probability)"]}):e.jsxs("span",{children:["May match ",e.jsx(me,{copy:!0,size:"compact",className:"inline",children:P.knownNodeHash})," ","(",(100*P.collisionProbability).toFixed(0),"% probability)"]})}),P.evidence&&e.jsxs("div",{className:"text-text-muted mt-1 text-[10px]",children:[P.evidence.sharedEdgeCount>0&&e.jsxs("span",{className:"mr-2",children:[P.evidence.sharedEdgeCount," shared edges"]}),void 0!==P.evidence.distanceKm&&e.jsxs("span",{className:"mr-2",children:[P.evidence.distanceKm.toFixed(1),"km apart"]}),P.evidence.withinUncertainty&&e.jsx("span",{className:"text-accent-secondary",children:"Within uncertainty radius"})]})]})]})}),t.estimatedLocation?e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-accent-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:[t.estimatedLocation.lat.toFixed(5),", ",t.estimatedLocation.lon.toFixed(5)]}),e.jsxs("div",{className:"text-text-muted",children:["Uncertainty: ",C]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",Ce(t.location.method)]}),t.location.anchors&&t.location.anchors.length>0&&e.jsxs("div",{children:[t.location.anchors.length," anchor",1!==t.location.anchors.length?"s":""," used"," · ",(100*t.location.locationConfidence).toFixed(0),"% confidence"]})]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[e.jsx(a,{className:"w-4 h-4 text-signal-poor"}),"Location unknown (neighbors lack coordinates)"]}),j&&t.temporal&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:["Temporal Pattern: ",e.jsx("span",{className:null==S?void 0:S.color,children:null==S?void 0:S.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 mt-1 text-text-muted",children:[e.jsxs("span",{children:["Distinct hours: ",t.temporal.distinctHours]}),e.jsxs("span",{children:["Distinct days: ",t.temporal.distinctDays]}),e.jsxs("span",{children:["Burstiness: ",(100*t.temporal.burstiness).toFixed(0),"%"]}),e.jsxs("span",{children:["Consistency: ",(100*t.temporal.consistency).toFixed(0),"%"]}),e.jsxs("span",{children:["Last 24h: ",t.temporal.last24HourCount," obs"]}),e.jsxs("span",{children:["Active hours: ",t.temporal.activeHoursLast24,"/24"]})]})]})]}),!j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(f,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",G(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",G(t.lastSeen)," ago"]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(y,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",G(t.firstSeen)," – ",G(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),k.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(N,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",k.length," known node",1!==k.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,5).map(({hash:s})=>e.jsx(me,{copy:!0,size:"compact",children:s},s)),k.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",k.length-5," more"]})]})]})]}),j&&t.validationStages&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1.5 uppercase tracking-wide",children:"Validation Stages"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(Le,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(Le,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(Le,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(Le,{label:"Location",passed:t.validationStages.locationPlausible})]})]}),t.classification&&!j&&e.jsx("div",{className:"pt-2 border-t border-border-muted/30",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.classification.criteria.hasVeryHighObservations&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-success/20 text-accent-success",children:"200+ obs"}),t.classification.criteria.hasHighObservations&&!t.classification.criteria.hasVeryHighObservations&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-tertiary/20 text-accent-tertiary",children:"50+ obs"}),t.classification.criteria.hasHighConfidence&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-success/20 text-accent-success",children:"70%+ conf"}),t.classification.criteria.hasCommonNeighbors&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-primary/20 text-accent-primary",children:"2+ neighbors"}),t.classification.criteria.hasGoodLocation&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-primary/20 text-accent-primary",children:"good loc"}),t.classification.criteria.isRecent&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-text-muted/20 text-text-muted",children:"recent"})]})}),j&&t.upgradeRequirements&&t.upgradeRequirements.length>0&&"confirmed"!==u&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1 uppercase tracking-wide",children:"To upgrade tier:"}),e.jsx("ul",{className:"text-xs text-text-secondary space-y-0.5",children:t.upgradeRequirements.slice(0,3).map((s,t)=>e.jsxs("li",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-accent-tertiary",children:"•"})," ",s]},t))})]})]})]})}function Le({label:s,passed:t}){return e.jsxs("span",{className:re("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium",t?"bg-accent-success/20 text-accent-success":"bg-bg-elevated text-text-muted"),children:[t?e.jsx(w,{className:"w-2.5 h-2.5"}):e.jsx(k,{className:"w-2.5 h-2.5"}),s]})}function Pe({neighbors:t,className:n,onGhostSelect:r}){const o=W(),d=z(),[x,N]=s.useState(new Set),[b,v]=s.useState("actionable"),[f,y]=s.useState(!1),[w,k]=s.useState(!0),[C,S]=s.useState(Date.now);s.useEffect(()=>{S(Date.now())},[o]);const M=s.useMemo(()=>o.filter(e=>!function(e,s){return s-1e3*e.lastSeen>6048e5}(e,C)),[o,C]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),P=s.useMemo(()=>L?M.find(e=>e.prefix===L)??null:null,[L,M]);s.useEffect(()=>{r&&r(P&&!w?{prefix:P.prefix,commonNeighbors:Array.from(P.commonNeighbors),estimatedLocation:P.estimatedLocation}:null)},[P,w,r]),s.useEffect(()=>{w&&N(new Set)},[w]);const{confirmed:H,likely:F,possible:E,noise:R,actionableCount:$}=s.useMemo(()=>{var e;const s=[],t=[],a=[],n=[];for(const c of M)switch((null==(e=c.classification)?void 0:e.tier)??"noise"){case"confirmed":s.push(c);break;case"likely":t.push(c);break;case"possible":a.push(c);break;case"noise":n.push(c)}const l=(e,s)=>s.observationCount-e.observationCount;return s.sort(l),t.sort(l),a.sort(l),n.sort(l),{confirmed:s,likely:t,possible:a,noise:n,actionableCount:s.length+t.length}},[M]);if(0===M.length)return null;const T=e=>{N(s=>s.has(e)?new Set:new Set([e]))},_="all"===b,O=H.length+F.length+(_?E.length:0)+(f?R.length:0);return e.jsxs("div",{className:n,children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(l,{className:"chart-title-icon"}),"Ghost Buster",$>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-accent-success/20 text-accent-success",children:[$," actionable"]}),w&&M.length>0&&e.jsxs("span",{className:"text-xs text-text-muted ml-2",children:["(",M.length," total)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!w&&e.jsxs("button",{onClick:()=>v(e=>"actionable"===e?"all":"actionable"),className:re("flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors","all"===b?"bg-accent-primary/20 text-accent-primary":"bg-bg-elevated text-text-muted hover:text-text-secondary"),children:[e.jsx(h,{className:"w-3 h-3"}),"actionable"===b?"Actionable":"All"]}),e.jsx("button",{onClick:()=>k(e=>!e),className:"flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-elevated text-text-muted hover:text-text-secondary transition-colors",title:w?"Expand panel":"Minimize panel",children:w?e.jsx(p,{className:"w-3 h-3"}):e.jsx(m,{className:"w-3 h-3"})})]})]}),w?e.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 text-xs cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>k(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[H.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-success",children:[e.jsx(u,{className:"w-3 h-3"}),H.length," confirmed"]}),F.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-tertiary",children:[e.jsx(g,{className:"w-3 h-3"}),F.length," likely"]}),E.length>0&&e.jsxs("span",{className:"text-accent-secondary",children:[E.length," possible"]}),R.length>0&&e.jsxs("span",{className:"text-text-muted",children:[R.length," noise"]})]}),e.jsx("span",{className:"text-text-muted ml-auto",children:"Click to expand"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 py-2 flex items-center gap-3 text-xs border-b border-border-muted/30",children:[e.jsxs("span",{className:"text-text-muted",children:[d.pathsWithGhosts.toLocaleString()," / ",d.totalPaths.toLocaleString()," paths"]}),e.jsx("span",{className:"text-text-muted",children:"•"}),e.jsxs("div",{className:"flex items-center gap-2",children:[H.length>0&&e.jsxs("span",{className:"text-accent-success",children:[H.length," confirmed"]}),F.length>0&&e.jsxs("span",{className:"text-accent-tertiary",children:[F.length," likely"]}),E.length>0&&e.jsxs("span",{className:"text-accent-secondary",children:[E.length," possible"]}),R.length>0&&e.jsxs("span",{className:"text-text-muted",children:[R.length," noise"]})]})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4",children:[H.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-success",children:[e.jsx(u,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Confirmed Repeaters (",H.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:H.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix))})]}),F.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-tertiary",children:[e.jsx(g,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Likely Repeaters (",F.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:F.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix))})]}),_&&E.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-secondary",children:[e.jsx(j,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Possible (",E.length,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[E.slice(0,10).map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix)),E.length>10&&e.jsxs("div",{className:"text-xs text-text-muted text-center py-1",children:["+",E.length-10," more possible nodes"]})]})]}),R.length>0&&"all"===b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>y(!f),className:"flex items-center gap-2 text-xs text-text-muted hover:text-text-secondary transition-colors",children:[f?e.jsx(c,{className:"w-3.5 h-3.5"}):e.jsx(i,{className:"w-3.5 h-3.5"}),e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Noise (",R.length,")"]})]}),f&&e.jsx("div",{className:"flex flex-wrap gap-1",children:R.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===b&&0===$&&e.jsxs("div",{className:"text-center py-6 text-sm text-text-muted",children:[e.jsx(l,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No confirmed or likely repeaters yet."}),e.jsxs("p",{className:"text-xs mt-1",children:[E.length+R.length," prefixes need more evidence."]}),e.jsxs("button",{onClick:()=>v("all"),className:"mt-3 text-accent-primary hover:underline",children:["View all ",M.length," discovered nodes"]})]}),d.observationOverrideCount>0&&O>0&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30 text-xs text-text-muted",children:[e.jsx("span",{className:"text-accent-primary",children:d.observationOverrideCount})," observation overrides • Avg confidence: ",e.jsxs("span",{className:"text-accent-secondary",children:[(100*d.avgPathConfidence).toFixed(0),"%"]})]})]})]})]})}const He="var(--sparkline-critical)",Fe="var(--sparkline-poor)",Ee="var(--sparkline-fair)",Re="var(--sparkline-good)",$e="var(--sparkline-excellent)";function Te({active:s,payload:t}){if(!s||!t||!t.length)return null;const a=t[0].payload,n=new Date(a.timestamp),l=`${(n.getMonth()+1).toString().padStart(2,"0")}/${n.getDate().toString().padStart(2,"0")}`;return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded px-1.5 py-0.5 text-[10px] shadow-xl",children:[e.jsx("span",{className:"text-text-muted",children:l}),e.jsx("span",{className:"ml-1.5 font-semibold tabular-nums",children:a.count})]})}const _e=s.memo(function({nodeHash:s,width:t=60,height:a=20,color:n,showArea:l=!0,showTooltip:c=!1,className:i=""}){const r=U(s),o=I(),d=!K().backgroundLoadComplete||o,x=n??(r.length>0?function(e){if(0===e.length)return He;const s=e.slice(-4),t=s.reduce((e,s)=>e+s.count,0),a=t/s.length,n=e.reduce((e,s)=>e+s.count,0)/e.length;if(0===t)return He;if(n>0){const e=a/n;return e>=1.2?$e:e>=.8?Re:e>=.4?Ee:e>=.1?Fe:He}return t>=10?$e:t>=5?Re:t>=2?Ee:t>=1?Fe:He}(r):"var(--text-muted)"),m="number"==typeof t?t:60,h=a;return d&&r.length<2?e.jsx("div",{className:`flex items-center justify-center ${i}`,style:{width:m,height:h},children:e.jsx("div",{className:"rounded animate-pulse bg-white/[0.06]",style:{width:m-8,height:h-6}})}):r.length<2?e.jsx("div",{className:`flex items-center justify-center ${i}`,style:{width:m,height:h,color:He},children:e.jsx("svg",{width:m,height:h,viewBox:`0 0 ${m} ${h}`,preserveAspectRatio:"none",children:e.jsx("line",{x1:4,y1:h/2,x2:m-4,y2:h/2,stroke:"currentColor",strokeWidth:1.5,strokeDasharray:"3,2"})})}):e.jsx("div",{className:i,style:{width:m,height:h},children:e.jsxs(oe,{data:r,width:m,height:h,margin:{top:1,right:1,bottom:1,left:1},children:[c&&e.jsx(de,{content:e.jsx(Te,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),e.jsx(xe,{type:"monotone",dataKey:"count",stroke:x,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),Oe=s.memo(function({hash:t,className:a="",size:n="sm"}){const l=B(),c=z(),[i,o]=s.useState(!1),d=s.useMemo(()=>V(t),[t]),x=s.useMemo(()=>d?l.find(e=>e.prefix===d)??null:null,[d,l]),m=c.totalPaths>0&&c.avgPathConfidence>=.7,h=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),o(!0)},[]),p=s.useCallback(()=>{o(!1)},[]);if(!x)return null;const u="sm"===n?"w-3.5 h-3.5":"w-4 h-4",j=m?"text-accent-tertiary hover:text-accent-tertiary hover:bg-accent-tertiary/10 focus:ring-accent-tertiary/50":"text-signal-fair hover:text-accent-secondary hover:bg-signal-fair/10 focus:ring-signal-fair/50",N=m?`Prefix conflict resolved by Viterbi HMM (${(100*c.avgPathConfidence).toFixed(0)}% confidence)`:`Prefix conflict: ${x.candidateCount} nodes share prefix "${d}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:h,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${j} ${a}`,title:N,"aria-label":`View prefix conflict for ${d}${m?" (Viterbi resolved)":""}`,children:m?e.jsxs("span",{className:"relative",children:[e.jsx(r,{className:u}),e.jsx(g,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-accent-success"})]}):e.jsx(C,{className:u})}),e.jsx(ue,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function Ae(e,s,t,a){const n=(t-e)*Math.PI/180,l=(a-s)*Math.PI/180,c=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3}const De=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:t}=q(),a=Y(),n=Z(),l=X(),c=J(),r=Q(),o=W(),x=ee(),[m,h]=s.useState(null),[p,u]=s.useState("lastHeard"),[j,v]=s.useState("desc"),[y,w]=s.useState(""),[k,C]=s.useState(!1),[D,z]=s.useState(null),[G,U]=s.useState(null),[I,K]=s.useState(null),[B,V]=s.useState(null),[ie,re]=s.useState(new Map),[oe,de]=s.useState(new Map),[xe,ue]=s.useState(25),[je,Ne]=s.useState(25),ve=s.useRef(null),[fe,ye]=s.useState(!1),we=s.useMemo(()=>(null==t?void 0:t.neighbors)??{},[null==t?void 0:t.neighbors]),Ce=s.useMemo(()=>Object.fromEntries(Object.entries(we).filter(([e])=>!a.has(e))),[we,a]),Se=se(),Me=null==t?void 0:t.local_hash,Le=s.useMemo(()=>{const e=new Map;if(!(null==Se?void 0:Se.latitude)||!(null==Se?void 0:Se.longitude))return e;for(const[s,t]of Object.entries(Ce))t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude?e.set(s,Ae(Se.latitude,Se.longitude,t.latitude,t.longitude)):e.set(s,null);return e},[Ce,Se]),{neighborHashSet:He,neighborSignalMap:Fe}=s.useMemo(()=>{const e=new Set,s=new Map;for(const t of r)e.add(t.hash),s.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:e,neighborSignalMap:s}},[r]),Ee=s.useMemo(()=>{const e=y.toLowerCase().trim(),s="neighbor"===e||"neighbors"===e,t=k||s;return Object.fromEntries(Object.entries(Ce).filter(([a,n])=>{if(t&&!He.has(a))return!1;if(s)return!0;if(!e)return!0;const l=(n.node_name||n.name||"").toLowerCase(),c=a.slice(2,4).toLowerCase();return l.includes(e)||c.includes(e)||a.toLowerCase().includes(e)}))},[Ce,y,k,He]),Re=s.useMemo(()=>Object.entries(Ee).sort(([e,s],[t,a])=>{let n=0;switch(p){case"lastHeard":n=(s.last_seen||0)-(a.last_seen||0);break;case"distance":{const s=Le.get(e)??null,a=Le.get(t)??null;n=null===s&&null===a?0:null===s?1:null===a?-1:s-a;break}case"centrality":n=(c.get(e)||0)-(c.get(t)||0)}return"desc"===j?-n:n}),[Ee,p,j,Le,c]),$e=Re.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,Te=s.useMemo(()=>new Set(l),[l]),De=s.useMemo(()=>0===xe?Re:Re.slice(0,je),[Re,je,xe]);s.useEffect(()=>{Ne(xe||Re.length)},[p,j,y,k,xe,Re.length]),s.useEffect(()=>{if(0===xe)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting&&jeMath.min(e+xe,Re.length))},{threshold:.1,rootMargin:"100px"});return ve.current&&e.observe(ve.current),()=>e.disconnect()},[xe,je,Re.length]);const ze=s.useCallback(e=>{ue(e),Ne(e||Re.length),ye(!1)},[Re.length]),We=s.useCallback(e=>{p===e?v(e=>"desc"===e?"asc":"desc"):(u(e),v("desc"))},[p]),Ge=s.useCallback(e=>{const s=Ce[e];(null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&0!==s.latitude&&0!==s.longitude&&z(e)},[Ce]),Ue=s.useCallback(()=>{z(null)},[]),Ie=s.useCallback(async(e,s)=>{if(s.stopPropagation(),!B){V(e),re(s=>{const t=new Map(s);return t.delete(e),t}),de(s=>{const t=new Map(s);return t.delete(e),t});try{const s=e.startsWith("0x")?e.slice(0,4):`0x${e.slice(0,2)}`,t=await ne(s,30);t.success&&t.data?(re(s=>new Map(s).set(e,t.data)),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},1e4)):(de(s=>new Map(s).set(e,t.error||"Ping failed")),setTimeout(()=>{de(s=>{const t=new Map(s);return t.delete(e),t})},5e3))}catch(t){const s=t instanceof Error?t.message:"Ping failed";de(t=>new Map(t).set(e,s)),setTimeout(()=>{de(s=>{const t=new Map(s);return t.delete(e),t})},5e3)}finally{V(null)}}},[B]);return e.jsxs(le,{children:[e.jsx(ce,{title:"Contacts",icon:e.jsx(N,{}),controls:e.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[e.jsxs("span",{className:"roster-title tabular-nums",children:[Re.length," node",1!==Re.length?"s":""]}),$e>0&&e.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[e.jsx(b,{className:"w-3.5 h-3.5 relative top-[2px]"}),$e," with location"]})]})}),x?e.jsx(be,{neighbors:Ce,localNode:Se??void 0,localHash:Me,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:Ue,highlightedEdgeKey:G,highlightedGhost:I}):e.jsx("div",{className:"glass-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),e.jsx(ke,{maxPaths:10,highlightedEdge:G,onHighlightEdge:U}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Pe,{neighbors:Ce,onGhostSelect:K})}):e.jsxs("div",{className:"glass-card",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-6 h-6 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-20 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]})})]})),e.jsx("div",{className:"chart-container",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(N,{className:"chart-title-icon"}),"Discovered Contacts"]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[He.size>0&&e.jsxs("button",{onClick:()=>C(!k),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-sm rounded-lg transition-colors "+(k?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:k?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),e.jsx("span",{className:"sm:hidden tabular-nums",children:He.size})]}),e.jsxs("div",{className:"relative",children:[e.jsx(M,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted"}),e.jsx("input",{type:"text",name:"contact-search",id:"contact-search",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"Search...",className:"w-20 sm:w-28 lg:w-32 pl-6 sm:pl-7 pr-6 py-1.5 text-sm bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),y&&e.jsx("button",{onClick:()=>{w(""),"neighbor"!==y.toLowerCase().trim()&&"neighbors"!==y.toLowerCase().trim()||C(!1)},className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:e.jsx(L,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[e.jsxs("button",{onClick:()=>We("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("lastHeard"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[e.jsx(f,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>We("distance"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("distance"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>We("centrality"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("centrality"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[e.jsx(d,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ye(!fe),className:"flex items-center gap-1 px-2 py-1.5 text-sm text-text-muted hover:text-text-secondary hover:bg-white/5 rounded-lg transition-colors",title:"Items per page",children:[e.jsx("span",{className:"tabular-nums",children:0===xe?"All":xe}),e.jsx(i,{className:"w-3 h-3 transition-transform "+(fe?"rotate-180":"")})]}),fe&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg-surface border border-border-subtle rounded-lg shadow-lg py-1 min-w-[80px]",children:[25,50,100,0].map(s=>e.jsx("button",{onClick:()=>ze(s),className:"w-full px-3 py-1.5 text-sm text-left hover:bg-white/5 transition-colors "+(xe===s?"text-accent-primary":"text-text-secondary"),children:0===s?"All":s},s))})]})]})]}),Re.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-border-subtle/50 px-3 py-2 text-[10px] uppercase tracking-wider text-text-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-activity text-center",children:"Activity"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-border-subtle/30",children:De.map(([s,t])=>{var a;const n=t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude,l=t.node_name||t.name||"Unknown",i=Te.has(s),r=He.has(s),o=Le.get(s),x=c.get(s)||0,m=r?Fe.get(s):void 0,p=r&&m,u=null==(a=t.contact_type)?void 0:a.toLowerCase(),j="room server"===u||"room_server"===u||"room"===u||"server"===u,N="companion"===u,b="client"===u||"cli"===u,v=t.is_repeater||"repeater"===u||"rep"===u,f=r?"direct":"flood",y=r?"Direct RF contact (zero-hop neighbor)":"Flood routing (multi-hop via mesh)";return e.jsxs("div",{className:`contacts-grid-row ${i?"bg-amber-500/5 border-l-2 border-l-amber-400":""} ${n?"cursor-pointer hover:bg-white/[0.02]":""}`,onClick:()=>Ge(s),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[p&&null!==(null==m?void 0:m.avgSnr)?e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0 self-center "+(k=m.avgSnr,void 0===k?"bg-[var(--signal-unknown)]":k>=5?"bg-[var(--signal-excellent)]":k>=0?"bg-[var(--signal-good)]":k>=-5?"bg-[var(--signal-fair)]":k>=-10?"bg-[var(--signal-poor)]":"bg-[var(--signal-critical)]")}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"roster-icon flex-shrink-0",title:y,children:j&&v?e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(F,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(E,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]}):j?e.jsx(F,{className:"w-5 h-5 text-sys-pink"}):N?e.jsx(R,{className:"w-5 h-5 text-text-muted"}):v?"direct"===f?e.jsx($,{className:"w-5 h-5 text-sys-green"}):e.jsx(E,{className:"w-5 h-5 text-sys-cyan"}):e.jsx(R,{className:"w-5 h-5 text-text-muted"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:l,children:l}),r&&e.jsx(te,{color:he.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),i&&e.jsxs(te,{color:he.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(T,{className:"w-3 h-3"}),"HUB"]}),v&&e.jsx(te,{color:he.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),j&&e.jsx(te,{color:he.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),N&&e.jsx(te,{color:he.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),b&&e.jsx(te,{color:he.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(me,{copy:!0,size:"compact",truncate:[8,6],children:s}),e.jsx(Oe,{hash:s})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[p&&null!==(null==m?void 0:m.avgRssi)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(pe,{rssi:m.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs tabular-nums text-text-muted",children:Math.round(m.avgRssi)})]}),p&&null!==(null==m?void 0:m.avgSnr)&&e.jsxs("span",{className:"type-data-xs tabular-nums text-text-muted",children:[m.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-text-muted",children:null!=o&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs tabular-nums",children:(w=o,w<1e3?`${Math.round(w)}m`:`${(w/1e3).toFixed(1)}km`)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:x>0&&e.jsxs(e.Fragment,{children:[e.jsx(d,{className:"w-3 h-3 text-accent-secondary"}),e.jsxs("span",{className:"type-data-xs tabular-nums text-text-muted",children:[(100*x).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-activity flex items-center justify-center",children:e.jsx(_e,{nodeHash:s,width:48,height:16})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs tabular-nums text-text-primary whitespace-nowrap",children:t.last_seen?ae(t.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[r&&e.jsx(e.Fragment,{children:ie.has(s)?e.jsxs("div",{className:"flex items-center gap-1 text-accent-success",title:`RTT: ${ie.get(s).rtt_ms.toFixed(0)}ms`,children:[e.jsx(g,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs tabular-nums hidden sm:inline",children:[ie.get(s).snr_db.toFixed(1),"dB"]})]}):oe.has(s)?e.jsx("span",{className:"text-red-400 text-[10px]",title:oe.get(s),children:"✗"}):e.jsx("button",{onClick:e=>Ie(s,e),disabled:null!==B,className:"p-1 sm:p-1.5 rounded-lg text-text-muted/50 hover:text-accent-primary hover:bg-accent-primary/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:B===s?e.jsx(_,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(O,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:e=>{e.stopPropagation(),h({hash:s,name:l})},className:"p-1 sm:p-1.5 rounded-lg text-text-muted/50 hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Remove contact",children:e.jsx(A,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]},s);var w,k})}),xe>0&&je0&&jeNe(e=>Math.min(e+xe,Re.length)),className:"text-accent-primary hover:text-accent-primary/80 transition-colors",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(N,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-text-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-text-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]},t))})]})}),e.jsx(ge,{isOpen:!!m,title:"Remove Contact",message:`Are you sure you would like to remove ${(null==m?void 0:m.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{m&&n(m.hash),h(null)},onCancel:()=>h(null)})]})}},Symbol.toStringTag,{value:"Module"}));export{De as C,_e as N,Oe as P}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-ByNdgqAN.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-Cw0dJsWv.js","assets/index-BJEgt3tp.js","assets/ConfirmModal-CYXFGX_W.js","assets/DeepAnalysisModal-D4eqwCNZ.js","assets/useThemeColors-AeHMyThq.js","assets/font-loader-jlbdh9Fw.js","assets/BasemapLayer-S9Ush6Hh.js","assets/SignalIndicator-BLrEkFNb.js","assets/ping-DvLgBqTv.js","assets/PageLayout-CnF5SScd.js","assets/DataBox-CRX76VsB.js","assets/CollisionExplorerModal-DTnzK_xA.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-CIefRaAd.css"])))=>i.map(i=>d[i]); +import{j as e,r as s,aJ as t,at as a,Z as n,q as l,aH as c,C as i,aK as r,a9 as o,ax as d,Y as x,_ as m,al as h,aL as p,aM as u,$ as g,as as j,ak as N,ar as b,aN as v,D as f,aO as y,az as w,ad as k,aP as C,E as S,aQ as M,X as L,aR as P,aS as H,aT as F,aU as E,aV as R,aW as $,aX as T,aq as _,aY as O,aZ as A}from"./vendor-react-C341c8YC.js";import{X as D,Y as z,M as W,Z as G,_ as U,$ as I,r as K,a0 as B,n as V,a1 as q,h as Y,a2 as Z,a3 as X,a4 as J,f as Q,p as ee,a5 as se,B as te,a6 as ae}from"./index-BJEgt3tp.js";import{p as ne}from"./ping-DvLgBqTv.js";import{P as le,b as ce}from"./PageLayout-CnF5SScd.js";import{_ as ie}from"./deckgl-DTsmDcfs.js";import{n as re,L as oe,T as de,u as xe}from"./recharts-6XUQYgRA.js";import{D as me}from"./DataBox-CRX76VsB.js";import{C as he,a as pe}from"./SignalIndicator-BLrEkFNb.js";import{C as ue}from"./CollisionExplorerModal-DTnzK_xA.js";import{C as ge}from"./ConfirmModal-CYXFGX_W.js";class je extends s.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var s;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 glass-card flex items-center justify-center",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-white/50 p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-white/30",children:(null==(s=this.state.error)?void 0:s.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-white/20 mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const Ne=s.lazy(()=>ie(()=>import("./ContactsMapMapLibre-ByNdgqAN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])));function be({neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o}){return e.jsx(je,{children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 glass-card flex items-center justify-center",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-white/50 flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(Ne,{neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o})})})}function ve(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function fe(e){return`${Math.round(100*e)}%`}function ye(e,s){return s.has(e.toUpperCase())}const we=s.memo(function({path:s,isHighlighted:t,onHighlight:c,ghostPrefixes:i}){const r=function(s){return s>.2?{icon:e.jsx(x,{className:"w-3 h-3"}),color:"text-accent-success"}:s<-.2?{icon:e.jsx(n,{className:"w-3 h-3"}),color:"text-accent-danger"}:{icon:e.jsx(m,{className:"w-3 h-3"}),color:"text-text-muted"}}(s.observationTrend),h=s.weakestLinkKey&&s.weakestLinkConfidence<.5,p=s.hops.some(e=>ye(e,i));return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md transition-colors cursor-pointer "+(t?"bg-accent-primary/20 border border-accent-primary/40":"hover:bg-white/5"),onClick:()=>c(t?null:s.weakestLinkKey),children:[e.jsx("div",{className:"flex-shrink-0 w-12 text-center py-1 rounded-md "+(u=s.healthScore,u>=.7?"bg-accent-success/10":u>=.5?"bg-accent-secondary/10":u>=.3?"bg-signal-poor/10":"bg-accent-danger/10"),children:e.jsx("span",{className:`text-xs font-semibold tabular-nums ${ve(s.healthScore)}`,children:fe(s.healthScore)})}),e.jsx("div",{className:"flex-1 flex items-center gap-0.5 overflow-x-auto min-w-0",children:s.hops.map((t,a)=>{var n;const c=ye(t,i),r=h&&(null==(n=s.weakestLinkKey)?void 0:n.includes(t));return e.jsxs("span",{className:"flex items-center",children:[e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded flex items-center gap-0.5 "+(c?"bg-accent-tertiary/20 text-accent-tertiary border border-accent-tertiary/30":r?"bg-accent-danger/20 text-accent-danger":"bg-white/10 text-text-secondary"),children:[c&&e.jsx(l,{className:"w-2.5 h-2.5"}),t]}),anew Set(p.map(e=>e.prefix.toUpperCase())),[p]),N=s.useMemo(()=>m.slice(0,o),[m,o]),b=s.useMemo(()=>0===m.length?null:{avgHealth:m.reduce((e,s)=>e+s.healthScore,0)/m.length,declining:m.filter(e=>e.observationTrend<-.2).length,weakLinks:m.filter(e=>e.weakestLinkConfidence<.5).length,pathsWithGhosts:m.filter(e=>e.hops.some(e=>j.has(e.toUpperCase()))).length},[m,j]),v=e=>{null==d||d(e)};return 0===m.length?null:e.jsxs("div",{className:"chart-container",children:[e.jsxs("button",{onClick:()=>g(!u),className:"w-full chart-header hover:bg-white/5 transition-colors rounded-t-lg cursor-pointer",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(t,{className:"chart-title-icon"}),"Path Health",e.jsxs("span",{className:"ml-2 text-[10px] font-normal text-text-muted",children:["(",m.length," paths)"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[b&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[e.jsxs("span",{className:`tabular-nums ${ve(b.avgHealth)}`,children:["Avg: ",fe(b.avgHealth)]}),b.weakLinks>0&&e.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[e.jsx(a,{className:"w-3 h-3"}),b.weakLinks," weak"]}),b.declining>0&&e.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}),b.declining," declining"]}),b.pathsWithGhosts>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),b.pathsWithGhosts," ghost"]})]}),u?e.jsx(c,{className:"w-4 h-4 text-text-muted"}):e.jsx(i,{className:"w-4 h-4 text-text-muted"})]})]}),u&&e.jsxs("div",{className:"p-3 pt-0 space-y-1",children:[h.totalPaths>0&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3 text-accent-primary"}),e.jsx("span",{className:"text-text-secondary",children:h.totalPaths.toLocaleString()})," Viterbi decoded"]}),h.observationOverrideCount>0&&e.jsxs("span",{className:"text-accent-success",children:[Math.round(h.observationOverrideCount/h.totalPaths*100),"% observation override"]}),p.length>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),p.length," ghost",1!==p.length?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-text-muted pb-2 border-b border-white/5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-success"})," Healthy (≥70%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-secondary"})," Fair (50-70%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-signal-poor"})," Weak (30-50%)"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-accent-danger"})," Critical (<30%)"]}),p.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3 text-accent-tertiary"})," Ghost"]})]}),e.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:N.map(s=>e.jsx(we,{path:s,isHighlighted:x===s.weakestLinkKey,onHighlight:v,ghostPrefixes:j},s.pathKey))}),m.length>o&&e.jsxs("div",{className:"text-center text-[10px] text-text-muted pt-2",children:["Showing top ",o," of ",m.length," paths"]})]})]})});function Ce(e){switch(e){case"rf_intersection":return"RF Circle Intersection";case"weighted_centroid":return"Weighted Centroid";case"single_anchor":return"Single Anchor (less reliable)";default:return e}}const Se={confirmed:{label:"Confirmed",icon:e.jsx(u,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-success/40",bgClass:"bg-accent-success/10",textClass:"text-accent-success",badgeClass:"bg-accent-success/20 text-accent-success"},likely:{label:"Likely",icon:e.jsx(g,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-tertiary/30",bgClass:"bg-accent-tertiary/5",textClass:"text-accent-tertiary",badgeClass:"bg-accent-tertiary/20 text-accent-tertiary"},possible:{label:"Possible",icon:e.jsx(j,{className:"w-3.5 h-3.5"}),borderClass:"border-accent-secondary/20",bgClass:"bg-accent-secondary/5",textClass:"text-accent-secondary",badgeClass:"bg-accent-secondary/20 text-accent-secondary"},noise:{label:"Noise",icon:e.jsx(a,{className:"w-3.5 h-3.5"}),borderClass:"border-border-muted",bgClass:"bg-bg-card/30",textClass:"text-text-muted",badgeClass:"bg-bg-elevated text-text-muted"}};function Me({ghost:t,neighbors:n,isExpanded:o,onToggle:x,compact:m}){var h,p;const u=(null==(h=t.classification)?void 0:h.tier)??"noise",g=Se[u],j="clusterId"in(w=t)&&"temporal"in w;var w;const k=s.useMemo(()=>Array.from(t.commonNeighbors).map(e=>{var s;return{hash:e,name:null==(s=n[e])?void 0:s.name}}),[t.commonNeighbors,n]),C=t.estimatedLocation?t.estimatedLocation.uncertaintyM>=1e3?`±${(t.estimatedLocation.uncertaintyM/1e3).toFixed(1)}km`:`±${Math.round(t.estimatedLocation.uncertaintyM)}m`:null,S=j&&t.temporal?(M=t.temporal.consistency)>=.7?{label:"Steady",color:"text-accent-success"}:M>=.4?{label:"Regular",color:"text-accent-tertiary"}:M>=.2?{label:"Sporadic",color:"text-accent-secondary"}:{label:"Bursty",color:"text-signal-poor"}:null;var M;const L=j&&t.collisionCandidates&&t.collisionCandidates.length>0,P=L?t.collisionCandidates[0]:null;return m?e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded bg-bg-elevated/50 text-sm",children:[e.jsx("span",{className:"font-mono font-medium text-text-secondary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:"text-text-muted",children:t.observationCount})]}):e.jsxs("div",{className:re("rounded-lg border transition-all duration-150",g.borderClass,g.bgClass),children:[e.jsxs("button",{onClick:x,className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-white/5 rounded-lg",children:[e.jsx(l,{className:re("w-5 h-5 flex-shrink-0",g.textClass)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-semibold text-text-primary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:re("px-1.5 py-0.5 rounded text-sm font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:re("text-sm mt-0.5",g.textClass),children:(null==(p=t.classification)?void 0:p.reason)??"Unknown"}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-text-muted mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3"}),t.observationCount]}),e.jsxs("span",{children:[(100*t.confidence).toFixed(0),"%"]}),t.commonNeighbors.size>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"}),t.commonNeighbors.size]}),t.estimatedLocation&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(b,{className:"w-3 h-3"}),C]}),S&&e.jsxs("span",{className:re("flex items-center gap-1",S.color),children:[e.jsx(d,{className:"w-3 h-3"}),S.label]}),L&&e.jsxs("span",{className:"flex items-center gap-1 text-signal-poor",children:[e.jsx(v,{className:"w-3 h-3"}),"Collision?"]})]})]}),o?e.jsx(c,{className:"w-4 h-4 text-text-muted"}):e.jsx(i,{className:"w-4 h-4 text-text-muted"})]}),o&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border-muted/50 mt-1 pt-3",children:[L&&P&&e.jsx("div",{className:"p-2 rounded bg-signal-poor/10 border border-signal-poor/30",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(v,{className:"w-4 h-4 text-signal-poor flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-signal-poor font-medium",children:"Possible collision with known node"}),e.jsx("div",{className:"text-text-secondary mt-0.5",children:P.knownNodeName?e.jsxs("span",{children:["May match ",e.jsx("span",{className:"font-medium",children:P.knownNodeName})," ","(",(100*P.collisionProbability).toFixed(0),"% probability)"]}):e.jsxs("span",{children:["May match ",e.jsx(me,{copy:!0,size:"compact",className:"inline",children:P.knownNodeHash})," ","(",(100*P.collisionProbability).toFixed(0),"% probability)"]})}),P.evidence&&e.jsxs("div",{className:"text-text-muted mt-1 text-[10px]",children:[P.evidence.sharedEdgeCount>0&&e.jsxs("span",{className:"mr-2",children:[P.evidence.sharedEdgeCount," shared edges"]}),void 0!==P.evidence.distanceKm&&e.jsxs("span",{className:"mr-2",children:[P.evidence.distanceKm.toFixed(1),"km apart"]}),P.evidence.withinUncertainty&&e.jsx("span",{className:"text-accent-secondary",children:"Within uncertainty radius"})]})]})]})}),t.estimatedLocation?e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-accent-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:[t.estimatedLocation.lat.toFixed(5),", ",t.estimatedLocation.lon.toFixed(5)]}),e.jsxs("div",{className:"text-text-muted",children:["Uncertainty: ",C]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",Ce(t.location.method)]}),t.location.anchors&&t.location.anchors.length>0&&e.jsxs("div",{children:[t.location.anchors.length," anchor",1!==t.location.anchors.length?"s":""," used"," · ",(100*t.location.locationConfidence).toFixed(0),"% confidence"]})]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[e.jsx(a,{className:"w-4 h-4 text-signal-poor"}),"Location unknown (neighbors lack coordinates)"]}),j&&t.temporal&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:["Temporal Pattern: ",e.jsx("span",{className:null==S?void 0:S.color,children:null==S?void 0:S.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 mt-1 text-text-muted",children:[e.jsxs("span",{children:["Distinct hours: ",t.temporal.distinctHours]}),e.jsxs("span",{children:["Distinct days: ",t.temporal.distinctDays]}),e.jsxs("span",{children:["Burstiness: ",(100*t.temporal.burstiness).toFixed(0),"%"]}),e.jsxs("span",{children:["Consistency: ",(100*t.temporal.consistency).toFixed(0),"%"]}),e.jsxs("span",{children:["Last 24h: ",t.temporal.last24HourCount," obs"]}),e.jsxs("span",{children:["Active hours: ",t.temporal.activeHoursLast24,"/24"]})]})]})]}),!j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(f,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",G(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",G(t.lastSeen)," ago"]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(y,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",G(t.firstSeen)," – ",G(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),k.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(N,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",k.length," known node",1!==k.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,5).map(({hash:s})=>e.jsx(me,{copy:!0,size:"compact",children:s},s)),k.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",k.length-5," more"]})]})]})]}),j&&t.validationStages&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1.5 uppercase tracking-wide",children:"Validation Stages"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(Le,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(Le,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(Le,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(Le,{label:"Location",passed:t.validationStages.locationPlausible})]})]}),t.classification&&!j&&e.jsx("div",{className:"pt-2 border-t border-border-muted/30",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.classification.criteria.hasVeryHighObservations&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-success/20 text-accent-success",children:"200+ obs"}),t.classification.criteria.hasHighObservations&&!t.classification.criteria.hasVeryHighObservations&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-tertiary/20 text-accent-tertiary",children:"50+ obs"}),t.classification.criteria.hasHighConfidence&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-success/20 text-accent-success",children:"70%+ conf"}),t.classification.criteria.hasCommonNeighbors&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-primary/20 text-accent-primary",children:"2+ neighbors"}),t.classification.criteria.hasGoodLocation&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-accent-primary/20 text-accent-primary",children:"good loc"}),t.classification.criteria.isRecent&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-text-muted/20 text-text-muted",children:"recent"})]})}),j&&t.upgradeRequirements&&t.upgradeRequirements.length>0&&"confirmed"!==u&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1 uppercase tracking-wide",children:"To upgrade tier:"}),e.jsx("ul",{className:"text-xs text-text-secondary space-y-0.5",children:t.upgradeRequirements.slice(0,3).map((s,t)=>e.jsxs("li",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-accent-tertiary",children:"•"})," ",s]},t))})]})]})]})}function Le({label:s,passed:t}){return e.jsxs("span",{className:re("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium",t?"bg-accent-success/20 text-accent-success":"bg-bg-elevated text-text-muted"),children:[t?e.jsx(w,{className:"w-2.5 h-2.5"}):e.jsx(k,{className:"w-2.5 h-2.5"}),s]})}function Pe({neighbors:t,className:n,onGhostSelect:r}){const o=W(),d=z(),[x,N]=s.useState(new Set),[b,v]=s.useState("actionable"),[f,y]=s.useState(!1),[w,k]=s.useState(!0),[C,S]=s.useState(Date.now);s.useEffect(()=>{S(Date.now())},[o]);const M=s.useMemo(()=>o.filter(e=>!function(e,s){return s-1e3*e.lastSeen>6048e5}(e,C)),[o,C]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),P=s.useMemo(()=>L?M.find(e=>e.prefix===L)??null:null,[L,M]);s.useEffect(()=>{r&&r(P&&!w?{prefix:P.prefix,commonNeighbors:Array.from(P.commonNeighbors),estimatedLocation:P.estimatedLocation}:null)},[P,w,r]),s.useEffect(()=>{w&&N(new Set)},[w]);const{confirmed:H,likely:F,possible:E,noise:R,actionableCount:$}=s.useMemo(()=>{var e;const s=[],t=[],a=[],n=[];for(const c of M)switch((null==(e=c.classification)?void 0:e.tier)??"noise"){case"confirmed":s.push(c);break;case"likely":t.push(c);break;case"possible":a.push(c);break;case"noise":n.push(c)}const l=(e,s)=>s.observationCount-e.observationCount;return s.sort(l),t.sort(l),a.sort(l),n.sort(l),{confirmed:s,likely:t,possible:a,noise:n,actionableCount:s.length+t.length}},[M]);if(0===M.length)return null;const T=e=>{N(s=>s.has(e)?new Set:new Set([e]))},_="all"===b,O=H.length+F.length+(_?E.length:0)+(f?R.length:0);return e.jsxs("div",{className:n,children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(l,{className:"chart-title-icon"}),"Ghost Buster",$>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-accent-success/20 text-accent-success",children:[$," actionable"]}),w&&M.length>0&&e.jsxs("span",{className:"text-xs text-text-muted ml-2",children:["(",M.length," total)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!w&&e.jsxs("button",{onClick:()=>v(e=>"actionable"===e?"all":"actionable"),className:re("flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors","all"===b?"bg-accent-primary/20 text-accent-primary":"bg-bg-elevated text-text-muted hover:text-text-secondary"),children:[e.jsx(h,{className:"w-3 h-3"}),"actionable"===b?"Actionable":"All"]}),e.jsx("button",{onClick:()=>k(e=>!e),className:"flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-elevated text-text-muted hover:text-text-secondary transition-colors",title:w?"Expand panel":"Minimize panel",children:w?e.jsx(p,{className:"w-3 h-3"}):e.jsx(m,{className:"w-3 h-3"})})]})]}),w?e.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 text-xs cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>k(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[H.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-success",children:[e.jsx(u,{className:"w-3 h-3"}),H.length," confirmed"]}),F.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-tertiary",children:[e.jsx(g,{className:"w-3 h-3"}),F.length," likely"]}),E.length>0&&e.jsxs("span",{className:"text-accent-secondary",children:[E.length," possible"]}),R.length>0&&e.jsxs("span",{className:"text-text-muted",children:[R.length," noise"]})]}),e.jsx("span",{className:"text-text-muted ml-auto",children:"Click to expand"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 py-2 flex items-center gap-3 text-xs border-b border-border-muted/30",children:[e.jsxs("span",{className:"text-text-muted",children:[d.pathsWithGhosts.toLocaleString()," / ",d.totalPaths.toLocaleString()," paths"]}),e.jsx("span",{className:"text-text-muted",children:"•"}),e.jsxs("div",{className:"flex items-center gap-2",children:[H.length>0&&e.jsxs("span",{className:"text-accent-success",children:[H.length," confirmed"]}),F.length>0&&e.jsxs("span",{className:"text-accent-tertiary",children:[F.length," likely"]}),E.length>0&&e.jsxs("span",{className:"text-accent-secondary",children:[E.length," possible"]}),R.length>0&&e.jsxs("span",{className:"text-text-muted",children:[R.length," noise"]})]})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4",children:[H.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-success",children:[e.jsx(u,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Confirmed Repeaters (",H.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:H.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix))})]}),F.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-tertiary",children:[e.jsx(g,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Likely Repeaters (",F.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:F.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix))})]}),_&&E.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-secondary",children:[e.jsx(j,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"font-medium",children:["Possible (",E.length,")"]})]}),e.jsxs("div",{className:"space-y-2",children:[E.slice(0,10).map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>T(s.prefix)},s.prefix)),E.length>10&&e.jsxs("div",{className:"text-xs text-text-muted text-center py-1",children:["+",E.length-10," more possible nodes"]})]})]}),R.length>0&&"all"===b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>y(!f),className:"flex items-center gap-2 text-xs text-text-muted hover:text-text-secondary transition-colors",children:[f?e.jsx(c,{className:"w-3.5 h-3.5"}):e.jsx(i,{className:"w-3.5 h-3.5"}),e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Noise (",R.length,")"]})]}),f&&e.jsx("div",{className:"flex flex-wrap gap-1",children:R.map(s=>e.jsx(Me,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===b&&0===$&&e.jsxs("div",{className:"text-center py-6 text-sm text-text-muted",children:[e.jsx(l,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No confirmed or likely repeaters yet."}),e.jsxs("p",{className:"text-xs mt-1",children:[E.length+R.length," prefixes need more evidence."]}),e.jsxs("button",{onClick:()=>v("all"),className:"mt-3 text-accent-primary hover:underline",children:["View all ",M.length," discovered nodes"]})]}),d.observationOverrideCount>0&&O>0&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30 text-xs text-text-muted",children:[e.jsx("span",{className:"text-accent-primary",children:d.observationOverrideCount})," observation overrides • Avg confidence: ",e.jsxs("span",{className:"text-accent-secondary",children:[(100*d.avgPathConfidence).toFixed(0),"%"]})]})]})]})]})}const He="var(--sparkline-critical)",Fe="var(--sparkline-poor)",Ee="var(--sparkline-fair)",Re="var(--sparkline-good)",$e="var(--sparkline-excellent)";function Te({active:s,payload:t}){if(!s||!t||!t.length)return null;const a=t[0].payload,n=new Date(a.timestamp),l=`${(n.getMonth()+1).toString().padStart(2,"0")}/${n.getDate().toString().padStart(2,"0")}`;return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded px-1.5 py-0.5 text-[10px] shadow-xl",children:[e.jsx("span",{className:"text-text-muted",children:l}),e.jsx("span",{className:"ml-1.5 font-semibold tabular-nums",children:a.count})]})}const _e=s.memo(function({nodeHash:s,width:t=60,height:a=20,color:n,showArea:l=!0,showTooltip:c=!1,className:i=""}){const r=U(s),o=I(),d=!K().backgroundLoadComplete||o,x=n??(r.length>0?function(e){if(0===e.length)return He;const s=e.slice(-4),t=s.reduce((e,s)=>e+s.count,0),a=t/s.length,n=e.reduce((e,s)=>e+s.count,0)/e.length;if(0===t)return He;if(n>0){const e=a/n;return e>=1.2?$e:e>=.8?Re:e>=.4?Ee:e>=.1?Fe:He}return t>=10?$e:t>=5?Re:t>=2?Ee:t>=1?Fe:He}(r):"var(--text-muted)"),m="number"==typeof t?t:60,h=a;return d&&r.length<2?e.jsx("div",{className:`flex items-center justify-center ${i}`,style:{width:m,height:h},children:e.jsx("div",{className:"rounded animate-pulse bg-white/[0.06]",style:{width:m-8,height:h-6}})}):r.length<2?e.jsx("div",{className:`flex items-center justify-center ${i}`,style:{width:m,height:h,color:He},children:e.jsx("svg",{width:m,height:h,viewBox:`0 0 ${m} ${h}`,preserveAspectRatio:"none",children:e.jsx("line",{x1:4,y1:h/2,x2:m-4,y2:h/2,stroke:"currentColor",strokeWidth:1.5,strokeDasharray:"3,2"})})}):e.jsx("div",{className:i,style:{width:m,height:h},children:e.jsxs(oe,{data:r,width:m,height:h,margin:{top:1,right:1,bottom:1,left:1},children:[c&&e.jsx(de,{content:e.jsx(Te,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),e.jsx(xe,{type:"monotone",dataKey:"count",stroke:x,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),Oe=s.memo(function({hash:t,className:a="",size:n="sm"}){const l=B(),c=z(),[i,o]=s.useState(!1),d=s.useMemo(()=>V(t),[t]),x=s.useMemo(()=>d?l.find(e=>e.prefix===d)??null:null,[d,l]),m=c.totalPaths>0&&c.avgPathConfidence>=.7,h=s.useCallback(e=>{e.preventDefault(),e.stopPropagation(),o(!0)},[]),p=s.useCallback(()=>{o(!1)},[]);if(!x)return null;const u="sm"===n?"w-3.5 h-3.5":"w-4 h-4",j=m?"text-accent-tertiary hover:text-accent-tertiary hover:bg-accent-tertiary/10 focus:ring-accent-tertiary/50":"text-signal-fair hover:text-accent-secondary hover:bg-signal-fair/10 focus:ring-signal-fair/50",N=m?`Prefix conflict resolved by Viterbi HMM (${(100*c.avgPathConfidence).toFixed(0)}% confidence)`:`Prefix conflict: ${x.candidateCount} nodes share prefix "${d}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:h,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${j} ${a}`,title:N,"aria-label":`View prefix conflict for ${d}${m?" (Viterbi resolved)":""}`,children:m?e.jsxs("span",{className:"relative",children:[e.jsx(r,{className:u}),e.jsx(g,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-accent-success"})]}):e.jsx(C,{className:u})}),e.jsx(ue,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function Ae(e,s,t,a){const n=(t-e)*Math.PI/180,l=(a-s)*Math.PI/180,c=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3}const De=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:t}=q(),a=Y(),n=Z(),l=X(),c=J(),r=Q(),o=W(),x=ee(),[m,h]=s.useState(null),[p,u]=s.useState("lastHeard"),[j,v]=s.useState("desc"),[y,w]=s.useState(""),[k,C]=s.useState(!1),[D,z]=s.useState(null),[G,U]=s.useState(null),[I,K]=s.useState(null),[B,V]=s.useState(null),[ie,re]=s.useState(new Map),[oe,de]=s.useState(new Map),[xe,ue]=s.useState(25),[je,Ne]=s.useState(25),ve=s.useRef(null),[fe,ye]=s.useState(!1),we=s.useMemo(()=>(null==t?void 0:t.neighbors)??{},[null==t?void 0:t.neighbors]),Ce=s.useMemo(()=>Object.fromEntries(Object.entries(we).filter(([e])=>!a.has(e))),[we,a]),Se=se(),Me=null==t?void 0:t.local_hash,Le=s.useMemo(()=>{const e=new Map;if(!(null==Se?void 0:Se.latitude)||!(null==Se?void 0:Se.longitude))return e;for(const[s,t]of Object.entries(Ce))t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude?e.set(s,Ae(Se.latitude,Se.longitude,t.latitude,t.longitude)):e.set(s,null);return e},[Ce,Se]),{neighborHashSet:He,neighborSignalMap:Fe}=s.useMemo(()=>{const e=new Set,s=new Map;for(const t of r)e.add(t.hash),s.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:e,neighborSignalMap:s}},[r]),Ee=s.useMemo(()=>{const e=y.toLowerCase().trim(),s="neighbor"===e||"neighbors"===e,t=k||s;return Object.fromEntries(Object.entries(Ce).filter(([a,n])=>{if(t&&!He.has(a))return!1;if(s)return!0;if(!e)return!0;const l=(n.node_name||n.name||"").toLowerCase(),c=a.slice(2,4).toLowerCase();return l.includes(e)||c.includes(e)||a.toLowerCase().includes(e)}))},[Ce,y,k,He]),Re=s.useMemo(()=>Object.entries(Ee).sort(([e,s],[t,a])=>{let n=0;switch(p){case"lastHeard":n=(s.last_seen||0)-(a.last_seen||0);break;case"distance":{const s=Le.get(e)??null,a=Le.get(t)??null;n=null===s&&null===a?0:null===s?1:null===a?-1:s-a;break}case"centrality":n=(c.get(e)||0)-(c.get(t)||0)}return"desc"===j?-n:n}),[Ee,p,j,Le,c]),$e=Re.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,Te=s.useMemo(()=>new Set(l),[l]),De=s.useMemo(()=>0===xe?Re:Re.slice(0,je),[Re,je,xe]);s.useEffect(()=>{Ne(xe||Re.length)},[p,j,y,k,xe,Re.length]),s.useEffect(()=>{if(0===xe)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting&&jeMath.min(e+xe,Re.length))},{threshold:.1,rootMargin:"100px"});return ve.current&&e.observe(ve.current),()=>e.disconnect()},[xe,je,Re.length]);const ze=s.useCallback(e=>{ue(e),Ne(e||Re.length),ye(!1)},[Re.length]),We=s.useCallback(e=>{p===e?v(e=>"desc"===e?"asc":"desc"):(u(e),v("desc"))},[p]),Ge=s.useCallback(e=>{const s=Ce[e];(null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&0!==s.latitude&&0!==s.longitude&&z(e)},[Ce]),Ue=s.useCallback(()=>{z(null)},[]),Ie=s.useCallback(async(e,s)=>{if(s.stopPropagation(),!B){V(e),re(s=>{const t=new Map(s);return t.delete(e),t}),de(s=>{const t=new Map(s);return t.delete(e),t});try{const s=e.startsWith("0x")?e.slice(0,4):`0x${e.slice(0,2)}`,t=await ne(s,30);t.success&&t.data?(re(s=>new Map(s).set(e,t.data)),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},1e4)):(de(s=>new Map(s).set(e,t.error||"Ping failed")),setTimeout(()=>{de(s=>{const t=new Map(s);return t.delete(e),t})},5e3))}catch(t){const s=t instanceof Error?t.message:"Ping failed";de(t=>new Map(t).set(e,s)),setTimeout(()=>{de(s=>{const t=new Map(s);return t.delete(e),t})},5e3)}finally{V(null)}}},[B]);return e.jsxs(le,{children:[e.jsx(ce,{title:"Contacts",icon:e.jsx(N,{}),controls:e.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[e.jsxs("span",{className:"roster-title tabular-nums",children:[Re.length," node",1!==Re.length?"s":""]}),$e>0&&e.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[e.jsx(b,{className:"w-3.5 h-3.5 relative top-[2px]"}),$e," with location"]})]})}),x?e.jsx(be,{neighbors:Ce,localNode:Se??void 0,localHash:Me,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:Ue,highlightedEdgeKey:G,highlightedGhost:I}):e.jsx("div",{className:"glass-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),e.jsx(ke,{maxPaths:10,highlightedEdge:G,onHighlightEdge:U}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Pe,{neighbors:Ce,onGhostSelect:K})}):e.jsxs("div",{className:"glass-card",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-6 h-6 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-20 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]})})]})),e.jsx("div",{className:"chart-container",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(N,{className:"chart-title-icon"}),"Discovered Contacts"]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[He.size>0&&e.jsxs("button",{onClick:()=>C(!k),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-sm rounded-lg transition-colors "+(k?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:k?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),e.jsx("span",{className:"sm:hidden tabular-nums",children:He.size})]}),e.jsxs("div",{className:"relative",children:[e.jsx(M,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted"}),e.jsx("input",{type:"text",name:"contact-search",id:"contact-search",autoComplete:"off",value:y,onChange:e=>w(e.target.value),placeholder:"Search...",className:"w-20 sm:w-28 lg:w-32 pl-6 sm:pl-7 pr-6 py-1.5 text-sm bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),y&&e.jsx("button",{onClick:()=>{w(""),"neighbor"!==y.toLowerCase().trim()&&"neighbors"!==y.toLowerCase().trim()||C(!1)},className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:e.jsx(L,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[e.jsxs("button",{onClick:()=>We("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("lastHeard"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[e.jsx(f,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>We("distance"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("distance"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>We("centrality"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("centrality"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[e.jsx(d,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===p&&e.jsx(P,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>ye(!fe),className:"flex items-center gap-1 px-2 py-1.5 text-sm text-text-muted hover:text-text-secondary hover:bg-white/5 rounded-lg transition-colors",title:"Items per page",children:[e.jsx("span",{className:"tabular-nums",children:0===xe?"All":xe}),e.jsx(i,{className:"w-3 h-3 transition-transform "+(fe?"rotate-180":"")})]}),fe&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-bg-surface border border-border-subtle rounded-lg shadow-lg py-1 min-w-[80px]",children:[25,50,100,0].map(s=>e.jsx("button",{onClick:()=>ze(s),className:"w-full px-3 py-1.5 text-sm text-left hover:bg-white/5 transition-colors "+(xe===s?"text-accent-primary":"text-text-secondary"),children:0===s?"All":s},s))})]})]})]}),Re.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-border-subtle/50 px-3 py-2 text-[10px] uppercase tracking-wider text-text-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-activity text-center",children:"Activity"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-border-subtle/30",children:De.map(([s,t])=>{var a;const n=t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude,l=t.node_name||t.name||"Unknown",i=Te.has(s),r=He.has(s),o=Le.get(s),x=c.get(s)||0,m=r?Fe.get(s):void 0,p=r&&m,u=null==(a=t.contact_type)?void 0:a.toLowerCase(),j="room server"===u||"room_server"===u||"room"===u||"server"===u,N="companion"===u,b="client"===u||"cli"===u,v=t.is_repeater||"repeater"===u||"rep"===u,f=r?"direct":"flood",y=r?"Direct RF contact (zero-hop neighbor)":"Flood routing (multi-hop via mesh)";return e.jsxs("div",{className:`contacts-grid-row ${i?"bg-amber-500/5 border-l-2 border-l-amber-400":""} ${n?"cursor-pointer hover:bg-white/[0.02]":""}`,onClick:()=>Ge(s),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[p&&null!==(null==m?void 0:m.avgSnr)?e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0 self-center "+(k=m.avgSnr,void 0===k?"bg-[var(--signal-unknown)]":k>=5?"bg-[var(--signal-excellent)]":k>=0?"bg-[var(--signal-good)]":k>=-5?"bg-[var(--signal-fair)]":k>=-10?"bg-[var(--signal-poor)]":"bg-[var(--signal-critical)]")}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"roster-icon flex-shrink-0",title:y,children:j&&v?e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(F,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(E,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]}):j?e.jsx(F,{className:"w-5 h-5 text-sys-pink"}):N?e.jsx(R,{className:"w-5 h-5 text-text-muted"}):v?"direct"===f?e.jsx($,{className:"w-5 h-5 text-sys-green"}):e.jsx(E,{className:"w-5 h-5 text-sys-cyan"}):e.jsx(R,{className:"w-5 h-5 text-text-muted"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:l,children:l}),r&&e.jsx(te,{color:he.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),i&&e.jsxs(te,{color:he.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(T,{className:"w-3 h-3"}),"HUB"]}),v&&e.jsx(te,{color:he.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),j&&e.jsx(te,{color:he.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),N&&e.jsx(te,{color:he.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),b&&e.jsx(te,{color:he.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(me,{copy:!0,size:"compact",truncate:[8,6],children:s}),e.jsx(Oe,{hash:s})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[p&&null!==(null==m?void 0:m.avgRssi)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(pe,{rssi:m.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs tabular-nums text-text-muted",children:Math.round(m.avgRssi)})]}),p&&null!==(null==m?void 0:m.avgSnr)&&e.jsxs("span",{className:"type-data-xs tabular-nums text-text-muted",children:[m.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-text-muted",children:null!=o&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs tabular-nums",children:(w=o,w<1e3?`${Math.round(w)}m`:`${(w/1e3).toFixed(1)}km`)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:x>0&&e.jsxs(e.Fragment,{children:[e.jsx(d,{className:"w-3 h-3 text-accent-secondary"}),e.jsxs("span",{className:"type-data-xs tabular-nums text-text-muted",children:[(100*x).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-activity flex items-center justify-center",children:e.jsx(_e,{nodeHash:s,width:48,height:16})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs tabular-nums text-text-primary whitespace-nowrap",children:t.last_seen?ae(t.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[r&&e.jsx(e.Fragment,{children:ie.has(s)?e.jsxs("div",{className:"flex items-center gap-1 text-accent-success",title:`RTT: ${ie.get(s).rtt_ms.toFixed(0)}ms`,children:[e.jsx(g,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs tabular-nums hidden sm:inline",children:[ie.get(s).snr_db.toFixed(1),"dB"]})]}):oe.has(s)?e.jsx("span",{className:"text-red-400 text-[10px]",title:oe.get(s),children:"✗"}):e.jsx("button",{onClick:e=>Ie(s,e),disabled:null!==B,className:"p-1 sm:p-1.5 rounded-lg text-text-muted/50 hover:text-accent-primary hover:bg-accent-primary/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:B===s?e.jsx(_,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(O,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:e=>{e.stopPropagation(),h({hash:s,name:l})},className:"p-1 sm:p-1.5 rounded-lg text-text-muted/50 hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Remove contact",children:e.jsx(A,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]},s);var w,k})}),xe>0&&je0&&jeNe(e=>Math.min(e+xe,Re.length)),className:"text-accent-primary hover:text-accent-primary/80 transition-colors",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(N,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-text-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-text-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]},t))})]})}),e.jsx(ge,{isOpen:!!m,title:"Remove Contact",message:`Are you sure you would like to remove ${(null==m?void 0:m.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{m&&n(m.hash),h(null)},onCancel:()=>h(null)})]})}},Symbol.toStringTag,{value:"Module"}));export{De as C,_e as N,Oe as P}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-JEW0aWu6.js b/frontend/dist/assets/ContactsMapMapLibre-ByNdgqAN.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-JEW0aWu6.js rename to frontend/dist/assets/ContactsMapMapLibre-ByNdgqAN.js index 059d4173..f7fc8727 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-JEW0aWu6.js +++ b/frontend/dist/assets/ContactsMapMapLibre-ByNdgqAN.js @@ -1 +1 @@ -import{r as A,j as e,aT as t,ab as r,q as n,am as o,aK as i,m as a,C as s,A as l,W as c,bP as u,bQ as f,bR as d,bS as g,bq as h,br as m,aL as b,_ as p,bb as v,aq as w,aJ as x,a9 as y,bT as k,i as C,bN as B,X as M,bU as D,$ as E,bV as Q,bo as j,aZ as N,bW as S,bX as F,bY as P,ak as T,bZ as L,bO as I,bk as R,bl as _,a0 as H,D as z,aS as G,ar as O,b_ as U,bM as Y,bj as W,b$ as V}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as Z,c as K}from"./link-scoring-BNnTohl3.js";import{M as J,Y as X,T as q,y as $,Q as AA,m as eA,aN as tA,aO as rA,n as nA,aP as oA,B as iA,a6 as aA,al as sA,ak as lA,f as cA,r as uA,aQ as fA,aR as dA}from"./index-CPdqYR4z.js";import{C as gA}from"./ConfirmModal-DlFyryXJ.js";import{D as hA}from"./DeepAnalysisModal-DysenxvY.js";import{i as mA,j as bA,k as pA,l as vA}from"./useThemeColors-AeHMyThq.js";import{l as wA}from"./font-loader-jlbdh9Fw.js";import{p as xA,a as yA}from"./vendor-core-WoOfkQwm.js";import{x as kA}from"./recharts-6XUQYgRA.js";import{u as CA,a as BA,B as MA}from"./BasemapLayer-S9Ush6Hh.js";import{P as DA,N as EA}from"./Contacts-BcOss4J-.js";import{H as QA,C as jA,N as NA,b as SA}from"./SignalIndicator-BLrEkFNb.js";import"./deckgl-DTsmDcfs.js";import"./ping-BvkXSZG_.js";import"./PageLayout-CcoYWyzO.js";import"./DataBox-CRX76VsB.js";import"./CollisionExplorerModal-Vkgg9Koo.js";function FA(A,e,t,r){const n=(t-A)*Math.PI/180,o=(r-e)*Math.PI/180,i=Math.sin(n/2)*Math.sin(n/2)+Math.cos(A*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2);return 2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i))*6371e3}function PA(A,e){const t=Math.max(5,Math.min(A,300)),r=Math.log(5),n=Math.log(300);return 1+(Math.log(t)-r)/(n-r)*5}const TA={nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",nodeColor:"#4338CA",localColor:"#FFB224",hubColor:"#8E4EC6",gatewayColor:"#5B5BD6",mobileColor:"#F76B15",roomServerColor:"#D6409F",neighborColor:"#FFB224",edges:{rest:"#4B4B4B",restBright:"#616161",restDim:"#3F3F3F",hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:"#8A8A8A",hoverNeighbor:"#FBBF24",neighborRest:"#6B7280",neighborHover:"#FBBF24",highlight:"#FFD700"},edgeOpacity:.82};function LA(){if("undefined"==typeof window)return TA;const A=mA(),e=bA();return{nodeFill:A.nodeFill,nodeStroke:A.nodeStroke,nodeColor:TA.nodeColor,localColor:A.localColor,hubColor:A.hubColor,gatewayColor:A.gatewayColor,mobileColor:A.mobileColor,roomServerColor:A.roomColor,neighborColor:A.neighborColor,edges:{rest:e.rest,restBright:e.restBright,restDim:e.restDim,hoverDirect:e.hoverDirect,hoverLoop:e.hoverLoop,hoverStandard:e.hoverStandard,hoverNeighbor:e.hoverNeighbor,neighborRest:TA.edges.neighborRest,neighborHover:TA.edges.neighborHover,highlight:e.highlight},edgeOpacity:TA.edgeOpacity}}const IA=2e3,RA={type:"spring",stiffness:500,damping:35};function _A({color:A,ring:t}){return e.jsx("span",{className:"shrink-0 rounded-full",style:{width:14,height:14,backgroundColor:t?"transparent":A,border:t?`4px solid ${A}`:void 0,boxSizing:"border-box"}})}function HA({color:A}){return e.jsx("span",{className:"shrink-0 rounded-sm",style:{width:16,height:3,backgroundColor:A}})}function zA({indicator:A,label:t,tooltip:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[A,e.jsx("span",{className:"text-text-secondary",children:t}),r&&e.jsx(q,{content:r,delay:200,children:e.jsx("span",{className:"text-text-muted cursor-help text-[10px] opacity-60 hover:opacity-100 transition-opacity",children:"ⓘ"})})]})}function GA({title:A,tooltip:t,isOpen:r,onToggle:n,showDivider:o,children:i}){return e.jsxs("div",{className:o?"mt-2 pt-2 border-t border-map-ui-border":"",children:[e.jsxs("button",{type:"button",onClick:n,className:"group w-full flex items-center justify-between py-1 text-text-secondary font-medium hover:text-text-primary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[A,e.jsx(q,{content:t,delay:200,children:e.jsx("span",{className:"text-text-muted cursor-help text-[10px] opacity-60 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),e.jsx(a.span,{animate:{rotate:r?0:-90},transition:{duration:.15},children:e.jsx(s,{className:"w-3 h-3 text-text-muted"})})]}),e.jsx(l,{initial:!1,children:r&&e.jsx(a.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:RA,className:"overflow-hidden",children:e.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:i})})})]})}function OA({label:A,value:t,color:r}){return e.jsxs("div",{className:"flex justify-between tabular-nums text-text-muted",children:[e.jsx("span",{children:A}),e.jsx("span",{className:"text-text-secondary",style:r?{color:r}:void 0,children:t})]})}function UA({icon:A,color:t,title:r,subtitle:n}){return e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-map-ui-border",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0",style:{color:t},children:A}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"font-medium truncate",style:{color:t},children:r}),e.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:n})]})]})})}function YA({showTopology:a,validatedPolylineCount:s,filteredNeighborCount:l,hasLocalNode:c,meshTopology:u,zeroHopNeighbors:f,neighborsWithLocation:d}){const g=pA(),h=J(),m=X(),b=h.filter(A=>A.isLikelyReal).length,p=function(A){let e=0;for(const t of A.txDelayRecommendations.values())"backbone"===t.networkRole&&e++;return e}(u),v=f.size>0,[w,x]=A.useState(!0),[y,k]=A.useState(!0),[C,B]=A.useState(!0);return e.jsxs("div",{className:"map-control-glass p-2.5 text-xs",children:[e.jsxs(GA,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:w,onToggle:()=>x(A=>!A),children:[e.jsx(zA,{indicator:e.jsx(_A,{color:g.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),e.jsx(zA,{indicator:e.jsx(_A,{color:g.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),(M=d,M.some(([,A])=>{var e;const t=null==(e=A.contact_type)?void 0:e.toLowerCase();return"room server"===t||"room_server"===t||"room"===t||"server"===t})&&e.jsx(zA,{indicator:e.jsx(t,{className:"w-3 h-3 shrink-0",style:{color:g.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."})),e.jsx(zA,{indicator:e.jsx(r,{className:"w-3 h-3 shrink-0",style:{color:g.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),v&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),u.gatewayNodes.length>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),p>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),u.mobileNodes.length>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),b>0&&e.jsx(zA,{indicator:e.jsx(n,{className:"w-3 h-3 shrink-0",style:{color:g.ghostColor},strokeWidth:2.5}),label:`Ghost (${b})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),v&&e.jsxs(GA,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:y,onToggle:()=>k(A=>!A),showDivider:!0,children:[e.jsx(zA,{indicator:e.jsx(HA,{color:Z.YELLOW}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),e.jsx(zA,{indicator:e.jsx(HA,{color:Z.GREEN}),label:"Listener",tooltip:">67% listener. They hear us well."}),e.jsx(zA,{indicator:e.jsx(HA,{color:Z.RED}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),a&&s>0&&e.jsxs(GA,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:C,onToggle:()=>B(A=>!A),showDivider:!0,children:[e.jsx(OA,{label:"Nodes",value:l+(c?1:0)}),u.hubNodes.length>0&&e.jsx(OA,{label:"Hubs",value:u.hubNodes.length,color:TA.hubColor}),u.loops.length>0&&e.jsx(UA,{icon:e.jsx(o,{className:"w-3 h-3"}),color:TA.edges.hoverLoop,title:`${u.loops.length} ${1===u.loops.length?"Loop":"Loops"}`,subtitle:"Redundant paths"}),m.totalPaths>0&&e.jsx(UA,{icon:e.jsx(i,{className:"w-3 h-3"}),color:g.ghostColor,title:`${m.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]});var M}function WA({mapRef:A,showNeighborLines:t,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:w,showMinCut:x=!1,onToggleMinCut:y,hasMinCutData:k=!1,show3DTerrain:C,onToggle3DTerrain:B,basemapMode:M,onToggleBasemap:D,isFullscreen:E,onToggleFullscreen:Q}){const j="w-4 h-4";return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4",children:[e.jsxs("div",{className:"map-control-glass flex items-center gap-1 p-1",children:[n&&e.jsx($,{plain:!0,color:t?"warning":"muted",onClick:r,title:t?"Hide edge lines":"Show edge lines","aria-label":t?"Hide edge lines":"Show edge lines","aria-pressed":t,className:"!p-1.5 !rounded-md",children:e.jsx(c,{className:j})}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(AA,{color:"all"===o?"green":"zinc",onClick:()=>i("all"),title:"Show all nodes",children:"All"}),a&&e.jsx(AA,{color:"hubs"===o?"green":"zinc",onClick:()=>i("hubs"),title:"Show only hub nodes and their connections",children:"Hubs"}),s&&e.jsx(AA,{color:"direct"===o?"green":"zinc",onClick:()=>i("direct"),title:"Show only zero-hop (direct RF) neighbors",children:"Direct"})]}),k&&y&&e.jsx($,{plain:!0,color:x?"primary":"muted",onClick:y,title:x?"Hide community partition":"Show community partition","aria-label":x?"Hide community partition":"Show community partition","aria-pressed":x,className:"!p-1.5 !rounded-md",children:e.jsx(u,{className:j})}),e.jsx($,{plain:!0,color:"light"===M?"primary":"muted",onClick:D,title:"light"===M?"Switch to dark map":"Switch to light map","aria-label":"light"===M?"Switch to dark map":"Switch to light map","aria-pressed":"light"===M,className:"!p-1.5 !rounded-md",children:"light"===M?e.jsx(f,{className:j}):e.jsx(d,{className:j})}),e.jsx($,{plain:!0,color:C?"success":"muted",onClick:B,title:C?"Disable 3D terrain":"Enable 3D terrain","aria-label":C?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":C,className:"!p-1.5 !rounded-md",children:e.jsx(g,{className:j})}),e.jsx($,{plain:!0,color:"muted",onClick:Q,title:E?"Exit fullscreen":"Fullscreen","aria-label":E?"Exit fullscreen":"Enter fullscreen","aria-pressed":E,className:"!p-1.5 !rounded-md",children:E?e.jsx(h,{className:j}):e.jsx(m,{className:j})})]}),e.jsxs("div",{className:"map-control-glass flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomIn()},title:"Zoom in","aria-label":"Zoom in",className:"!p-1.5 !rounded-none",children:e.jsx(b,{className:j})}),e.jsx("div",{className:"h-px bg-border-subtle"}),e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomOut()},title:"Zoom out","aria-label":"Zoom out",className:"!p-1.5 !rounded-none",children:e.jsx(p,{className:j})}),e.jsx("div",{className:"h-px bg-border-subtle"}),e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e;const t=null==(e=A.current)?void 0:e.getMap();t&&t.easeTo({bearing:0,pitch:0,duration:300})},title:"Reset bearing to north","aria-label":"Reset bearing to north",className:"!p-1.5 !rounded-none",children:e.jsx(v,{className:j})})]})]})})}const VA="#4ADE80",ZA="DeepAnalysis";function KA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function JA({isActive:t,hasAnalyzed:r,isLoading:n,onClick:o}){const[i,a]=A.useState(!1),[s,l]=A.useState(ZA),c=A.useRef(!1),u=A.useRef(null),[f]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),d=i&&!t&&!n&&f;A.useEffect(()=>{if(i&&!t&&!n&&!c.current){c.current=!0;const A=performance.now(),e=t=>{const r=t-A,n=Math.min(r/700,1),o=Math.floor(12*n);let i="";for(let A=0;A<12;A++)i+=A{u.current&&cancelAnimationFrame(u.current)}},[i,t,n]);const g=n?"Analyzing...":s;return e.jsxs("button",{onClick:o,onMouseEnter:()=>f&&a(!0),onMouseLeave:()=>f&&a(!1),onPointerEnter:()=>f&&a(!0),onPointerLeave:()=>f&&a(!1),disabled:n,className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors "+(n?"cursor-wait":""),style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-green)":"var(--map-ui-bg, var(--bg-surface))"},title:n?"Analyzing packet history...":r?t?"Hide topology edges":"Show topology edges":"Load full packet history and build topology",children:[n?e.jsx(w,{className:"w-3.5 h-3.5 flex-shrink-0 text-green-400 animate-spin"}):e.jsx(x,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(t?"text-green-400":"text-text-secondary"),style:d?{color:VA}:void 0}),e.jsx("span",{className:t?"text-green-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:t||d?700:500,letterSpacing:"-0.01em",lineHeight:1,...d?{color:VA}:{}},children:g})]})}const XA="#12A594";function qA({isActive:t,onClick:r}){const[n,o]=A.useState(!1),[i,a]=A.useState(0),s=A.useRef(!1),l=A.useRef(null),[c,u]=A.useState(0),f=A.useRef(!1),[d]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!t&&d;A.useEffect(()=>{g&&!f.current&&(f.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(f.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!t&&!s.current){s.current=!0;const A=performance.now(),e=t=>{const r=t-A,n=Math.min(r/400,1);a(n),n<1&&(l.current=requestAnimationFrame(e))};l.current=requestAnimationFrame(e)}return n||(l.current&&(cancelAnimationFrame(l.current),l.current=null),s.current=!1,a(0)),()=>{l.current&&cancelAnimationFrame(l.current)}},[n,t]);const h=A=>{if(t)return;if(!g)return;const e=11*i;return A>=e-2&&Ad&&o(!0),onMouseLeave:()=>d&&o(!1),onPointerEnter:()=>d&&o(!0),onPointerLeave:()=>d&&o(!1),className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors",style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-teal)":"var(--map-ui-bg, var(--bg-surface))"},title:t?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[e.jsx(y,{className:"w-3.5 h-3.5 flex-shrink-0 "+(t?"text-sys-teal":"text-text-secondary"),fill:1===c?"#FFFFFF":3===c?XA:"none",stroke:1===c||2===c?"#FFFFFF":g?XA:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),e.jsx("span",{className:t?"text-sys-teal":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:t||g?700:500,letterSpacing:"-0.01em",lineHeight:1},children:"LiveTrace".split("").map((A,t)=>e.jsx("span",{style:{color:h(t)||void 0},children:A},t))})]})}const $A="#fe8019";function Ae({isActive:t,onClick:r,brightness:n=.7,onBrightnessChange:o}){const[i,a]=A.useState(!1),[s,l]=A.useState(!1),[c]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)});A.useEffect(()=>{wA()},[]),A.useEffect(()=>{if(!i||t)return;const A=requestAnimationFrame(()=>l(!0)),e=setTimeout(()=>l(!1),80);return()=>{cancelAnimationFrame(A),clearTimeout(e)}},[i,t]);const u=Math.max(.01,Math.min(1,n)),g=u<.999,h=u>.011,m=i&&!t&&c;return e.jsxs("button",{onClick:r,onMouseEnter:()=>c&&a(!0),onMouseLeave:()=>c&&a(!1),onPointerEnter:()=>c&&a(!0),onPointerLeave:()=>c&&a(!1),className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors",style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-amber)":"var(--map-ui-bg, var(--bg-surface))"},title:t?"Configure wardriving coverage":"Show wardriving coverage",children:[e.jsx(k,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(t?"text-amber-400":"text-text-secondary"),style:m?{color:$A}:void 0}),e.jsx("span",{className:t?"text-amber-400":"text-text-secondary",style:{fontFamily:t||m?"'Jacquard 12', serif":"ui-monospace, SFMono-Regular, monospace",fontSize:t||m?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:t?"scale(1.45)":m?`scale(${s?1.595:1.45})`:void 0,transformOrigin:"left center",...m?{color:$A}:{}},children:"Wardrive"}),t&&o&&e.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[e.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.max(.01,u-.2);null==o||o(e)},disabled:!h,className:"p-0.5 rounded transition-colors "+(h?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:e.jsx(d,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.min(1,u+.2);null==o||o(e)},disabled:!g,className:"p-0.5 rounded transition-colors "+(g?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:e.jsx(f,{className:"w-3.5 h-3.5"})})]})]})}function ee(A){let e=!0,t=-90,r=90,n=-180,o=180;for(const i of A.toLowerCase()){const A="0123456789bcdefghjkmnpqrstuvwxyz".indexOf(i);if(-1!==A)for(let i=4;i>=0;i--){const a=A>>i&1;if(e){const A=(n+o)/2;a?n=A:o=A}else{const A=(t+r)/2;a?t=A:r=A}e=!e}}return{lat:(t+r)/2,lon:(n+o)/2}}function te(A){return Math.exp(-A*Math.LN2/7)}const re="pymc-wardriving-url",ne="pymc-wardriving-enabled",oe="pymc-wardriving-brightness";function ie(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(re,A):localStorage.removeItem(re))}function ae(A){"undefined"!=typeof localStorage&&localStorage.setItem(ne,String(A))}function se(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(oe);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function le(A,e=null){if(null!==A){const t=(Math.max(-12,Math.min(12,A))+12)/24;return null!==e?.8*t+(Math.max(-120,Math.min(-50,e))+120)/70*.2:t}return null!==e?(Math.max(-120,Math.min(-50,e))+120)/70:.5}const ce=C((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(ne),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(re)||"",brightness:se(),isModalOpen:!1,openModal:()=>A({isModalOpen:!0}),closeModal:()=>A({isModalOpen:!1}),setUrl:e=>A({url:e}),setBrightness:e=>{const t=Math.max(.01,Math.min(1,e));!function(A){if("undefined"==typeof localStorage)return;const e=Math.max(.01,Math.min(1,A));localStorage.setItem(oe,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;ae(t),A({isVisible:t})},setVisible:e=>{ae(e),A({isVisible:e})},loadCoverage:async e=>{if(!e.trim())return A({error:"Please enter a URL",status:"error"}),!1;try{new URL(e.trim())}catch{return A({error:"Invalid URL format",status:"error"}),!1}A({error:null,status:"connecting"});try{A({status:"loading"});const t=await async function(A){const e=`${A.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,t=await async function(A,e={},t=8e3){const r=new AbortController,n=setTimeout(()=>r.abort(),t);try{return await fetch(A,{...e,signal:r.signal})}catch(o){if(o instanceof Error&&"AbortError"===o.name)throw new Error(`Connection timed out after ${t/1e3}s`);throw o}finally{clearTimeout(n)}}(e,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to fetch precise samples: ${t.status}`);return t.json()}(e.trim());if(!t||"object"!=typeof t)throw new Error("Invalid response from server");if(!Array.isArray(t.keys))throw new Error("No sample data found in response");A({status:"processing"});const r=function(A){var e;const t=[];for(const r of A.keys){if(!r.observed)continue;const{lat:A,lon:n}=ee(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=te(i),s=le(r.snr,r.rssi)*(.3+.7*a);t.push({lat:A,lon:n,successRate:r.observed?1:0,weight:s,totalSamples:1,ageDays:i,geohash:r.hash,repeaters:(null==(e=r.path)?void 0:e.map(A=>A.toLowerCase()))||[]})}return t}(t);if(0===r.length)throw new Error("No valid coverage points found");return A({coveragePoints:r,repeaters:[],stats:{coverageCount:r.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:e.trim()}),ie(e.trim()),ae(!0),!0}catch(t){const e=t instanceof Error?t.message:"Failed to load coverage data";let r=e;return e.includes("timed out")?r="Connection timed out. Server may be unreachable or slow.":e.includes("Failed to fetch")||e.includes("NetworkError")?r="Could not connect to server. Check the URL and try again.":e.includes("CORS")?r="Server does not allow cross-origin requests.":e.includes("404")?r="Coverage endpoint not found. Check the URL.":(e.includes("ERR_NAME_NOT_RESOLVED")||e.includes("DNS"))&&(r="Server not found. Check the URL for typos."),A({error:r,status:"error"}),!1}},clearCoverage:()=>{A({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),ie(""),ae(!1)}})),ue={type:"spring",damping:25,stiffness:300},fe={type:"spring",damping:20,stiffness:300};function de({status:A}){if("connecting"!==A&&"loading"!==A&&"processing"!==A)return null;const t={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[A];if(!t)return null;const r="connecting"===A?30:"loading"===A?60:90;return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[e.jsx("div",{className:"relative",children:e.jsx(w,{className:"w-5 h-5 text-amber-400 animate-spin"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-amber-400 font-medium",children:t}),e.jsx("div",{className:"mt-2 h-1.5 bg-amber-500/20 rounded-full overflow-hidden",children:e.jsx(a.div,{className:"h-full bg-amber-400 rounded-full",initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:"easeOut"}})})]})]})})}function ge({icon:A,title:t,description:r,variant:n}){const o={success:"bg-accent-success/10 border-accent-success/30 text-accent-success",error:"bg-accent-danger/10 border-accent-danger/30 text-accent-danger",warning:"bg-accent-secondary/10 border-accent-secondary/30 text-accent-secondary"}[n];return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsxs("div",{className:`flex items-start gap-3 p-4 border rounded-xl ${o}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:A}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),r&&e.jsx("p",{className:"text-xs opacity-80 mt-0.5",children:r})]})]})})}function he({icon:A,label:t,value:r,min:n,max:o,formatValue:i,onChange:s}){const l=i?i(r):`${Math.round(r)}%`;return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsx("div",{className:"p-4 bg-bg-surface border border-border-subtle rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-text-muted",children:A}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:t}),e.jsx("span",{className:"text-xs text-text-muted font-mono tabular-nums",children:l})]}),e.jsx("input",{type:"range",min:n,max:o,value:r,onChange:A=>s(Number(A.target.value)),className:"w-full h-1.5 bg-bg-elevated rounded-full appearance-none cursor-pointer\n [&::-webkit-slider-thumb]:appearance-none\n [&::-webkit-slider-thumb]:w-3.5\n [&::-webkit-slider-thumb]:h-3.5\n [&::-webkit-slider-thumb]:rounded-full\n [&::-webkit-slider-thumb]:bg-accent-secondary\n [&::-webkit-slider-thumb]:cursor-pointer\n [&::-webkit-slider-thumb]:transition-transform\n [&::-webkit-slider-thumb]:hover:scale-110\n [&::-webkit-slider-thumb]:shadow-md"})]})]})})})}function me(){const{isModalOpen:t,closeModal:r,status:n,isVisible:o,stats:s,error:c,url:u,brightness:d,loadCoverage:g,clearCoverage:h,toggleVisibility:m,setUrl:b,setBrightness:p}=ce(),v="connecting"===n||"loading"===n||"processing"===n,[x,y]=A.useState(u),k=A.useCallback(async()=>{await g(x)},[x,g]),C=A.useCallback(()=>{y(""),h()},[h]),F=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||v||(A.preventDefault(),k())},[k,v]),P=A.useCallback(A=>{const e=A.target.value;y(e),b(e)},[b]),T=s.coverageCount>0,L=x.trim().length>0&&!v;return e.jsx(l,{children:t&&e.jsxs("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center",children:[e.jsx(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:v?void 0:r}),e.jsx(a.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:ue,className:"relative w-full max-w-md mx-4",children:e.jsxs("div",{className:"map-control-glass rounded-2xl overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-accent-secondary/20",children:e.jsx(B,{className:"w-5 h-5 text-accent-secondary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),e.jsx($,{plain:!0,color:"muted",onClick:r,disabled:v,className:"!p-2 !rounded-lg","aria-label":"Close modal",children:e.jsx(M,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),e.jsx("input",{type:"url",value:x,onChange:P,onKeyDown:F,placeholder:"https://coverage.wcmesh.com",className:"w-full px-4 py-3 bg-bg-surface border border-border-subtle rounded-xl \n text-text-primary placeholder:text-text-muted \n focus:outline-none focus:ring-2 focus:ring-accent-secondary/50 focus:border-accent-secondary/50 \n transition-all disabled:opacity-50",disabled:v}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:"Enter the base URL of a wardriving coverage server (e.g., coverage.wcmesh.com)"})]}),e.jsxs(l,{mode:"wait",children:[v&&e.jsx(de,{status:n},"loading"),"error"===n&&c&&e.jsx(ge,{icon:e.jsx(D,{className:"w-5 h-5"}),title:"Connection Failed",description:c,variant:"error"},"error"),"success"===n&&T&&e.jsx(ge,{icon:e.jsx(E,{className:"w-5 h-5"}),title:"Data Loaded Successfully",description:`${s.coverageCount.toLocaleString()} coverage points • ${s.repeaterCount.toLocaleString()} repeaters`,variant:"success"},"success"),T&&!v&&"success"!==n&&e.jsx(ge,{icon:e.jsx(Q,{className:"w-5 h-5"}),title:"Coverage Data Loaded",description:`${s.coverageCount.toLocaleString()} points${s.lastUpdated?` • Last updated ${s.lastUpdated.toLocaleTimeString()}`:""}`,variant:"warning"},"info")]}),e.jsx(l,{children:T&&!v&&e.jsx(he,{icon:e.jsx(f,{className:"w-4 h-4 "+(d>.5?"text-accent-secondary":"text-text-muted")}),label:"Brightness",value:100*d,min:1,max:100,formatValue:A=>`${Math.round(A)}%`,onChange:A=>p(A/100)},"brightness")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-t border-border-subtle",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(l,{children:T&&e.jsxs(a.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},className:"flex items-center gap-1",children:[e.jsx($,{plain:!0,color:"muted",onClick:m,disabled:v,title:o?"Hide heatmap":"Show heatmap",children:o?e.jsxs(e.Fragment,{children:[e.jsx(j,{"data-slot":"icon"})," Hide"]}):e.jsxs(e.Fragment,{children:[e.jsx(i,{"data-slot":"icon"})," Show"]})}),e.jsxs($,{plain:!0,color:"danger",onClick:C,disabled:v,title:"Clear coverage data",children:[e.jsx(N,{"data-slot":"icon"})," Clear"]})]})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{plain:!0,color:"muted",onClick:r,disabled:v,children:T?"Done":"Cancel"}),e.jsx($,{color:"warning",onClick:k,disabled:!L,children:v?e.jsxs(e.Fragment,{children:[e.jsx(w,{"data-slot":"icon",className:"animate-spin"}),"Loading..."]}):T?e.jsxs(e.Fragment,{children:[e.jsx(S,{"data-slot":"icon"}),"Refresh"]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{"data-slot":"icon"}),"Connect"]})})]})]})]})})]})})}const be={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function pe({label:A,value:t,min:r,max:n,step:o,unit:i,formatValue:a,onChange:s}){const l=a?a(t):t.toFixed(2);return e.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[e.jsx("span",{className:"text-[11px] sm:text-[11px] text-text-secondary w-14 sm:w-16 flex-shrink-0",children:A}),e.jsx("input",{type:"range",min:r,max:n,step:o,value:t,onChange:A=>s(parseFloat(A.target.value)),className:"flex-1 h-1.5 sm:h-1 bg-bg-elevated rounded-full appearance-none cursor-pointer\n [&::-webkit-slider-thumb]:appearance-none\n [&::-webkit-slider-thumb]:w-4\n [&::-webkit-slider-thumb]:h-4\n [&::-webkit-slider-thumb]:sm:w-2.5\n [&::-webkit-slider-thumb]:sm:h-2.5\n [&::-webkit-slider-thumb]:rounded-full\n [&::-webkit-slider-thumb]:bg-accent-primary\n [&::-webkit-slider-thumb]:cursor-pointer\n [&::-webkit-slider-thumb]:shadow-md"}),e.jsxs("span",{className:"text-[11px] sm:text-[11px] text-text-primary font-mono tabular-nums w-12 sm:w-14 text-right flex-shrink-0",children:[l,i&&e.jsx("span",{className:"text-text-muted ml-0.5 hidden sm:inline",children:i})]})]})}function ve({icon:A,label:t,value:r,subtext:n}){return e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[e.jsx("div",{className:"text-text-muted",children:A}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"text-[10px] sm:text-[11px] text-text-secondary truncate",children:t})}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[11px] sm:text-xs font-mono text-text-primary",children:r}),n&&e.jsx("div",{className:"text-[8px] sm:text-[9px] text-text-muted leading-tight",children:n})]})]})}function we({visible:t,onClose:r,settings:n,onSettingsChange:o,partition:i,totalNodes:s}){const c=F(),f=A.useRef(null),d=A.useMemo(()=>{if(!i)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const A=Array.from(i.communities.values()).map(A=>A.length),e=A.reduce((A,e)=>A+e,0);return{numCommunities:i.numCommunities,avgCommunitySize:A.length>0?Math.round(e/A.length):0,minCommunitySize:A.length>0?Math.min(...A):0,maxCommunitySize:A.length>0?Math.max(...A):0,fiedlerValue:i.fiedlerValue,modularity:0,coveragePercent:s>0?Math.round(e/s*100):0}},[i,s]),g=(A,e)=>{o({...n,[A]:e})},h=(111*n.bandwidth).toFixed(1);return e.jsx("div",{ref:f,className:"absolute inset-0 z-[600] pointer-events-none",children:e.jsx(l,{children:t&&e.jsx(a.div,{drag:!0,dragControls:c,dragConstraints:f,dragElastic:.1,dragMomentum:!1,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{type:"spring",damping:25,stiffness:300},className:"\n absolute pointer-events-auto\n /* Mobile: bottom sheet style, full width with margins */\n bottom-2 left-2 right-2\n /* sm+: floating panel in bottom-right */\n sm:bottom-16 sm:left-auto sm:right-3 sm:w-64\n /* md+: slightly wider */\n md:w-72\n ",style:{touchAction:"none"},children:e.jsxs("div",{className:"\n map-control-glass rounded-lg overflow-hidden shadow-lg\n /* Mobile: limit height, allow scroll */\n max-h-[45vh] sm:max-h-[calc(100vh-180px)] overflow-y-auto\n /* iOS momentum scrolling */\n overscroll-contain\n ",children:[e.jsxs("div",{className:"\n flex items-center justify-between \n px-3 py-2 sm:px-2.5 sm:py-1.5 \n border-b border-border-subtle \n cursor-grab active:cursor-grabbing\n /* Larger touch target on mobile */\n min-h-[44px] sm:min-h-0\n ",onPointerDown:A=>c.start(A),children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx(P,{className:"w-4 h-4 sm:w-3 sm:h-3 text-text-muted"}),e.jsx(u,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-accent-primary"}),e.jsx("span",{className:"text-sm sm:text-xs font-medium text-text-primary",children:"Partition"})]}),e.jsx($,{plain:!0,color:"muted",onClick:r,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:e.jsx(M,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),e.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b border-border-subtle",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[e.jsx(ve,{icon:e.jsx(u,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:d.numCommunities}),e.jsx(ve,{icon:e.jsx(T,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:d.avgCommunitySize,subtext:`${d.minCommunitySize}–${d.maxCommunitySize}`}),e.jsx(ve,{icon:e.jsx(L,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:d.fiedlerValue.toFixed(3)}),e.jsx(ve,{icon:e.jsx(T,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${d.coveragePercent}%`,subtext:`of ${s}`})]})}),e.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:e.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[e.jsx(pe,{label:"Bandwidth",value:n.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>h,unit:"km",onChange:A=>g("bandwidth",A)}),e.jsx(pe,{label:"Threshold",value:n.threshold,min:.05,max:.5,step:.01,formatValue:A=>`${Math.round(100*(1-A))}%`,unit:"cov",onChange:A=>g("threshold",A)}),e.jsx(pe,{label:"Opacity",value:n.opacity,min:.1,max:1,step:.05,formatValue:A=>`${Math.round(100*A)}%`,onChange:A=>g("opacity",A)}),e.jsx(pe,{label:"Stroke",value:n.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:A=>A.toFixed(1),onChange:A=>g("strokeWidth",A)})]})})]})})})})}const xe={getItem:A=>{try{return localStorage.getItem(A)}catch{return null}},setItem:(A,e)=>{try{localStorage.setItem(A,e)}catch{}},removeItem:A=>{try{localStorage.removeItem(A)}catch{}}},ye=C()(xA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:yA(()=>xe)}));var ke=function(A){var e,t=void 0!==(A=A||{})?A:{},r={};for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);var n,o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",n=function(A,e,t){var r=new XMLHttpRequest;r.open("GET",A,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)e(r.response);else{var n=O(A);n?e(n.buffer):t()}},r.onerror=t,r.send(null)};var i=t.print||function(){}.bind(),a=t.printErr||function(){}.bind();for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);r=null,t.arguments&&t.arguments;var s=0,l=!1;function c(A){var e=t["_"+A];return e||tA("Assertion failed: "+("Cannot call unknown function "+A+", make sure it is exported")),e}var u,f,d,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function v(A,e){return A?function(A,e,t){for(var r=e+t,n=e;A[n]&&!(n>=r);)++n;if(n-e>16&&A.subarray&&p)return p.decode(A.subarray(e,n));for(var o="";e>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|a)}else o+=String.fromCharCode(i)}return o}(d,A,e):""}function w(A,e){return A%e>0&&(A+=e-A%e),A}function x(A){u=A,t.HEAP8=f=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=d=new Uint8Array(A),t.HEAPU16=new Uint16Array(A),t.HEAPU32=new Uint32Array(A),t.HEAPF32=m=new Float32Array(A),t.HEAPF64=b=new Float64Array(A)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var y=t.TOTAL_MEMORY||33554432;function k(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?t.dynCall_v(r):t.dynCall_vi(r,e.arg):r(void 0===e.arg?null:e.arg)}else e()}}y=(u=t.buffer?t.buffer:new ArrayBuffer(y)).byteLength,x(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function Q(A){D.unshift(A)}var j=Math.abs,N=Math.ceil,S=Math.floor,F=Math.min,P=0,T=null;t.preloadedImages={},t.preloadedAudios={};var L,I,R=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return f.length}R="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var G="function"==typeof atob?atob:function(A){var e,t,r,n,o,i,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="",l=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e=a.indexOf(A.charAt(l++))<<2|(n=a.indexOf(A.charAt(l++)))>>4,t=(15&n)<<4|(o=a.indexOf(A.charAt(l++)))>>2,r=(3&o)<<6|(i=a.indexOf(A.charAt(l++))),s+=String.fromCharCode(e),64!==o&&(s+=String.fromCharCode(t)),64!==i&&(s+=String.fromCharCode(r))}while(l=0){if((0|t)>13780509){if(0|(a=0|le(15,s)))break;s=0|n[(l=s)>>2],l=0|n[l+4>>2]}else c=0|qe(0|t,0|(a=((0|t)<0)<<31>>31),3,0),l=0|B(),a=0|Ve(0|t,0|a,1,0),a=0|Ve(0|(a=0|qe(0|c,0|l,0|a,0|B())),0|B(),1,0),l=0|B(),n[s>>2]=a,n[s+4>>2]=l,s=a;if(lt(0|r,0,s<<3),0|o){lt(0|o,0,s<<2),a=0|L(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|L(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return S=i,0|a}function T(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=S,S=S+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return S=a,2;if(n[(s=r)>>2]=A,n[s+4>>2]=e,(s=!!(0|o))&&(n[o>>2]=0),0|HA(A,e))return S=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|I(s,e,4,m,i)))break A;if(0|HA(s=0|n[(e=i)>>2],e=0|n[e+4>>2])){s=9;break A}}if(0|(s=0|I(s,e,0|n[26800+(g<<2)>>2],m,i)))break A;if(s=0|n[(e=i)>>2],e=0|n[e+4>>2],n[(A=r+(d<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(d<<2)>>2]=h,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|I(s,e,4,m,i)))break A;if(0|HA(s=0|n[(e=i)>>2],e=0|n[e+4>>2])){s=9;break A}}if(0|(s=0|I(s,e,0|n[26800+(g<<2)>>2],m,i)))break A;if(s=0|n[(e=i)>>2],e=0|n[e+4>>2],n[(A=r+(d<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else s=0}while(0);return S=a,0|s}function L(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0;if(u=S,S=S+16|0,l=u+8|0,c=u,f=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(f<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(d=(0|p)==(0|A)&(0|b)==(0|e))))do{f=0|$e(0|(f=0|Ve(0|f,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),d=(0|(b=0|n[(p=h=r+(f<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|d));if(f=o+(f<<2)|0,d&&(0|n[f>>2])<=(0|s))return S=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[f>>2]=s,(0|s)>=(0|t))return S=u,0;switch(d=s+1|0,n[l>>2]=0,0|(f=0|I(A,e,2,l,c))){case 9:m=9;break;case 0:(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(f=0|I(A,e,3,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,1,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,5,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,4,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,6,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}return S=u,0}}while(0);return S=u,0|f}function I(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if((t|=0)>>>0>6)return 1;if(f=(0|n[(r|=0)>>2])%6|0,n[r>>2]=f,(0|f)>0){s=0;do{t=0|vA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(f=0|tt(0|A,0|e,45),B(),(a=127&f)>>>0>121)return 5;i=0|OA(A,e),s=0|tt(0|A,0|e,52),B(),s&=15;A:do{if(s){for(;;){if(c=0|tt(0|A,0|e,0|(l=3*(15-s|0)|0)),B(),7==(0|(c&=7))){e=5;break}if(g=!(0|ZA(s)),s=s+-1|0,d=0|rt(7,0,0|l),e&=~B(),A=0|rt(0|n[(g?432:16)+(28*c|0)+(t<<2)>>2],0,0|l)|A&~d,e|=l=0|B(),!(t=0|n[(g?640:224)+(28*c|0)+(t<<2)>>2])){t=0;break A}if(!s){u=8;break A}}return 0|e}u=8}while(0);8==(0|u)&&(A|=0|rt(0|(g=0|n[848+(28*a|0)+(t<<2)>>2]),0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+(t<<2)>>2],127&~g||(g=0|rt(0|n[848+(28*a|0)+20>>2],0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+20>>2],A=0|YA(g|A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]))),c=0|tt(0|A,0|e,45),B(),c&=127;A:do{if(0|z(c)){e:do{if(1==(0|OA(A,e))){if((0|a)!=(0|c)){if(0|Y(c,0|n[7696+(28*a|0)>>2])){A=0|VA(A,e),l=1,e=0|B();break}M(27795,26864,533,26872)}switch(0|i){case 3:A=0|YA(A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]),l=0;break e;case 5:A=0|VA(A,e),e=0|B(),n[r>>2]=5+(0|n[r>>2]),l=0;break e;case 0:return 9;default:return 1}}else l=0}while(0);if((0|t)>0){s=0;do{A=0|UA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}if((0|a)!=(0|c)){if(!(0|G(c))){if(!!(0|l)|5!=(0|OA(A,e)))break;n[r>>2]=1+(0|n[r>>2]);break}switch(127&f){case 8:case 118:break A}3!=(0|OA(A,e))&&(n[r>>2]=1+(0|n[r>>2]))}}else if((0|t)>0){s=0;do{A=0|YA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}}while(0);return n[r>>2]=((0|n[r>>2])+t|0)%6|0,n[(g=o)>>2]=A,n[g+4>>2]=e,0}function R(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(i=S,S=S+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return S=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,S=i,0;n[h>>2]=0;A:do{if(0|HA(A,e))A=9;else{a=0,g=A;do{if(0|(A=0|I(g,e,4,h,o)))break A;if(a=a+1|0,0|HA(g=0|n[(e=o)>>2],e=0|n[e+4>>2])){A=9;break A}}while((0|a)<(0|t));n[(d=r)>>2]=g,n[d+4>>2]=e,d=t+-1|0,f=0,A=1;do{if(a=26800+(f<<2)|0,5==(0|f))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|I(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|d)){if(c=0|n[(u=o)>>2],u=0|n[u+4>>2],n[(A=r+(a<<3)|0)>>2]=c,n[A+4>>2]=u,0|HA(c,u)){A=9;break A}A=a+1|0}else A=a;if((0|(s=s+1|0))>=(0|t))break;a=A}else for(l=o,u=0|n[a>>2],c=0,a=A,s=0|n[l>>2],l=0|n[l+4>>2];;){if(0|(A=0|I(s,l,u,h,o)))break A;if(s=0|n[(l=o)>>2],l=0|n[l+4>>2],n[(A=r+(a<<3)|0)>>2]=s,n[A+4>>2]=l,A=a+1|0,0|HA(s,l)){A=9;break A}if((0|(c=c+1|0))>=(0|t))break;a=A}f=f+1|0}while(f>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return S=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=S,S=S+16|0,o=a,i=a+8|0,s=(s=!(0|HA(A|=0,e|=0)))?1:2;;){if(n[i>>2]=0,!(0|I(A,e,s,i,o))&((0|n[(l=o)>>2])==(0|t)?(0|n[l+4>>2])==(0|r):0)){A=4;break}if((s=s+1|0)>>>0>=7){s=7,A=4;break}}return 4==(0|A)?(S=a,0|s):0}function H(A,e,t,r,i,a,s){e|=0,t|=0,r|=0,i|=0,a|=0,s|=0;var l,c,u,f,d,g,h,m,b,p,v=0,w=0,x=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,j=0,N=0,F=0,P=0,T=0,L=0,I=0,R=0,_=0;if(p=S,S=S+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(w=0|n[(A|=0)>>2]))<=0)return S=p,0;for(u=A+4|0,f=h+8|0,d=m+8|0,g=l+8|0,v=0,F=0;;){N=(x=0|n[u>>2])+(F<<4)|0,n[h>>2]=n[N>>2],n[h+4>>2]=n[N+4>>2],n[h+8>>2]=n[N+8>>2],n[h+12>>2]=n[N+12>>2],(0|F)==(w+-1|0)?(n[m>>2]=n[x>>2],n[m+4>>2]=n[x+4>>2],n[m+8>>2]=n[x+8>>2],n[m+12>>2]=n[x+12>>2]):(N=x+(F+1<<4)|0,n[m>>2]=n[N>>2],n[m+4>>2]=n[N+4>>2],n[m+8>>2]=n[N+8>>2],n[m+12>>2]=n[N+12>>2]),w=0|tA(h,m,r,b);A:do{if(w)x=0,v=w;else if(x=0|n[(w=b)>>2],(0|(w=0|n[w+4>>2]))>0|!(0|w)&x>>>0>0){j=0,N=0;e:for(;;){if(I=1/(+(x>>>0)+4294967296*+(0|w)),_=+o[h>>3],R=+((w=0|Ze(0|x,0|w,0|j,0|N))>>>0)+4294967296*+(0|B()),L=+(j>>>0)+4294967296*+(0|N),o[l>>3]=I*(_*R)+I*(+o[m>>3]*L),o[g>>3]=I*(+o[f>>3]*R)+I*(+o[d>>3]*L),0|(w=0|KA(l,r,c))){v=w;break}C=0|At(0|(E=0|n[(Q=c)>>2]),0|(Q=0|n[Q+4>>2]),0|e,0|t),y=0|B(),x=0|n[(k=w=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|x)&!(0|k))P=w,T=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){v=1;break e}if((0|x)==(0|E)&(0|k)==(0|Q))break t;if(C=0|$e(0|(w=0|Ve(0|C,0|y,1,0)),0|B(),0|e,0|t),y=0|B(),D=0|Ve(0|D,0|M,1,0),M=0|B(),!(0|(x=0|n[(k=w=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){P=w,T=16;break}}}while(0);if(16!=(0|T)||(T=0,!(0|E)&!(0|Q))||(n[(D=P)>>2]=E,n[D+4>>2]=Q,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=Q,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(Q=i)>>2]=D,n[Q+4>>2]=E),j=0|Ve(0|j,0|N,1,0),N=0|B(),x=0|n[(w=b)>>2],!((0|(w=0|n[w+4>>2]))>(0|N)|(0|w)==(0|N)&x>>>0>j>>>0)){x=1;break A}}x=0}else x=1}while(0);if(F=F+1|0,!x){T=21;break}if((0|F)>=(0|(w=0|n[A>>2]))){v=0,T=21;break}}return 21==(0|T)?(S=p,0|v):0}function z(A){return(A|=0)>>>0>121?0|(A=0):0|(A=0|n[7696+(28*A|0)+16>>2])}function G(A){return 4==(0|(A|=0))|117==(0|A)|0}function O(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)>>2]}function U(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)+4>>2]}function Y(A,e){return e|=0,(0|n[7696+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|n[7696+(28*A|0)+24>>2])==(0|e))}function W(A,e){return 0|n[848+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function V(A,e){return e|=0,(0|n[848+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|n[848+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|n[848+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|n[848+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|n[848+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|n[848+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|n[848+(28*A|0)+24>>2])==(0|e)?6:7)}function Z(A){var e,t,r;return e=(r=+o[16+(A|=0)>>3])-(t=+o[A+24>>3]),+(r>3]<+o[A+24>>3]|0}function J(A){return+(+o[(A|=0)>>3]-+o[A+8>>3])}function X(A,e){A|=0;var t,r,n=0;return(n=+o[(e|=0)>>3])>=+o[A+8>>3]&&n<=+o[A>>3]?(t=+o[A+16>>3],n=+o[A+24>>3],e=(r=+o[e+8>>3])>=n,A=r<=t&1,t>3]<+o[e+8>>3]||+o[A+8>>3]>+o[e>>3]?0|(s=0):(n=(l=+o[A+16>>3])<(u=+o[(t=A+24|0)>>3]),c=(a=+o[(s=e+16|0)>>3])<(i=+o[(r=e+24|0)>>3]),e=u-a>3],e)||(u=+ie(+o[t>>3],A))>+ie(+o[s>>3],e)?0|(c=0):0|(c=1))}function $(A,e){e|=0;var t,r,n,i,a,s=0,l=0,c=0,u=0;return+o[(A|=0)>>3]<+o[e>>3]||+o[A+8>>3]>+o[e+8>>3]?0|(s=0):(n=(i=+o[(s=A+16|0)>>3])<(l=+o[A+24>>3]),c=(u=+o[(t=e+16|0)>>3])<(a=+o[(r=e+24|0)>>3]),e=l-u>3],e)?0|(c=(u=+ie(+o[s>>3],A))>=+ie(+o[t>>3],e)):0|(c=0))}function AA(A,e){A|=0,e|=0;var t,r,i,a,s,l=0;i=S,S=S+176|0,n[(r=i)>>2]=4,l=+o[e>>3],o[r+8>>3]=l,a=+o[e+16>>3],o[r+16>>3]=a,o[r+24>>3]=l,l=+o[e+24>>3],o[r+32>>3]=l,s=+o[e+8>>3],o[r+40>>3]=s,o[r+48>>3]=l,o[r+56>>3]=s,o[r+64>>3]=a,t=96+(e=r+72|0)|0;do{n[e>>2]=0,e=e+4|0}while((0|e)<(0|t));st(0|A,0|r,168),S=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,f,d,g,h=0,m=0,b=0,p=0,w=0,y=0,k=0;d=S,S=S+288|0,f=d+264|0,p=d+96|0,m=(h=b=d)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(S=d,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],f),$A(b,m,p),u=+ae(f,p+8|0),o[f>>3]=+o[A>>3],o[(m=f+8|0)>>3]=+o[A+16>>3],o[p>>3]=+o[A+8>>3],o[(b=p+8|0)>>3]=+o[A+24>>3],a=+ae(f,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[f>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+v(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,w=~~k>>>0,y=+l(k)>=1?k>0?~~+x(+s(k/4294967296),4294967295)>>>0:~~+v((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|w)&!(0|y),n[(e=t)>>2]=p?1:w,n[e+4>>2]=p?0:y,e=0):e=1,S=d,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,f,d=0,g=0,h=0;f=S,S=S+288|0,c=f+264|0,u=f+96|0,a=(d=g=f)+96|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(t=0|Ae(t,g))?(S=f,0|(r=t)):(qA(d=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(d,t,u),h=+ae(c,u+8|0),h=+v(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,d=+l(h)>=1?h>0?~~+x(+s(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|d),n[r>>2]=g?1:t,n[r+4>>2]=g?0:d,S=f,0|(r=0)):(S=f,0|(r=1)))}function rA(A,e,t,r){e|=0,t|=0,r|=0,n[(A|=0)>>2]=e,n[A+4>>2]=t,n[A+8>>2]=r}function nA(A){var e,t=0,r=0,o=0,i=0,a=0;t=0|n[(A|=0)>>2],r=0|n[(e=A+4|0)>>2],(0|t)<0&&(r=r-t|0,n[e>>2]=r,n[(a=A+8|0)>>2]=(0|n[a>>2])-t,n[A>>2]=0,t=0),(0|r)<0?(t=t-r|0,n[A>>2]=t,i=(0|n[(a=A+8|0)>>2])-r|0,n[a>>2]=i,n[e>>2]=0,r=0):(a=i=A+8|0,i=0|n[i>>2]),(0|i)<0&&(t=t-i|0,n[A>>2]=t,r=r-i|0,n[e>>2]=r,n[a>>2]=0,i=0),(0|(o=(0|i)<(0|(o=(0|r)<(0|t)?r:t))?i:o))<=0||(n[A>>2]=t-o,n[e>>2]=r-o,n[a>>2]=i-o)}function oA(A,e){var t,r;e|=0,r=0|n[8+(A|=0)>>2],t=+((0|n[A+4>>2])-r|0),o[e>>3]=+((0|n[A>>2])-r|0)-.5*t,o[e+8>>3]=.8660254037844386*t}function iA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[e>>2])+(0|n[A>>2]),n[t+4>>2]=(0|n[e+4>>2])+(0|n[A+4>>2]),n[t+8>>2]=(0|n[e+8>>2])+(0|n[A+8>>2])}function aA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[A>>2])-(0|n[e>>2]),n[t+4>>2]=(0|n[A+4>>2])-(0|n[e+4>>2]),n[t+8>>2]=(0|n[A+8>>2])-(0|n[e+8>>2])}function sA(A,e){e|=0;var t,r=0;r=0|w(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|w(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|w(0|n[(A=A+8|0)>>2],e),n[A>>2]=e}function lA(A){var e,t,r=0,o=0,i=0,a=0,s=0;s=(0|(t=0|n[(A|=0)>>2]))<0,A=(A=(o=(0|(a=((e=(0|(i=(0|n[A+4>>2])-(s?t:0)|0))<0)?0-i|0:0)+((0|n[A+8>>2])-(s?t:0))|0))<0)?0:a)-((i=(0|(o=(0|A)<(0|(o=(0|(r=(e?0:i)-(o?a:0)|0))<(0|(a=(s?0:t)-(e?i:0)-(o?a:0)|0))?r:a))?A:o))>0)?o:0)|0,r=r-(i?o:0)|0;A:do{switch(a-(i?o:0)|0){case 0:switch(0|r){case 0:return 0|(0|A?1==(0|A)?1:7:0);case 1:return 0|(0|A?1==(0|A)?3:7:2);default:break A}case 1:switch(0|r){case 0:return 0|(0|A?1==(0|A)?5:7:4);case 1:if(A)break A;return 6;default:break A}}}while(0);return 7}function cA(A){var e,t,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(l=0|n[(t=8+(A|=0)|0)>>2],(e=(0|n[A>>2])-l|0)>>>0>715827881|(l=(0|n[(c=A+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-e|0,s=-2147483648-e|0,(i=(0|e)>0)?(0|a)<(0|e):(0|s)>(0|e))return 1;if(o=e<<1,i?(2147483647-o|0)<(0|e):(-2147483648-o|0)>(0|e))return 1;if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 1;if(r=3*e|0,o=l<<1,(i?(0|a)<(0|o):(0|s)>(0|o))||((0|e)>-1?(-2147483648|r)>=(0|l):(-2147483648^r)<(0|l)))return 1}else o=l<<1,r=3*e|0;return i=0|Oe(.14285714285714285*+(r-l|0)),n[A>>2]=i,a=0|Oe(.14285714285714285*+(o+e|0)),n[c>>2]=a,n[t>>2]=0,r=(o=(0|a)<(0|i))?i:a,(0|(o=o?a:i))<0&&((-2147483648==(0|o)||((0|r)>0?(2147483647-r|0)<(0|o):(-2147483648-r|0)>(0|o)))&&M(27795,26892,354,26903),((0|r)>-1?(-2147483648|r)>=(0|o):(-2147483648^r)<(0|o))&&M(27795,26892,354,26903)),r=a-i|0,(0|i)<0?(o=0-i|0,n[c>>2]=r,n[t>>2]=o,n[A>>2]=0,i=0):(r=a,o=0),(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[t>>2]=o,n[c>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[c>>2]=a,n[t>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[c>>2]=r-i,n[t>>2]=o-i),0}function uA(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(i=0|n[(e=8+(A|=0)|0)>>2],(a=(0|n[A>>2])-i|0)>>>0>715827881|(i=(0|n[(s=A+4|0)>>2])-i|0)>>>0>715827881){if((r=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 1;if(t=a<<1,(o=(0|i)>0)?(2147483647-i|0)<(0|i):(-2147483648-i|0)>(0|i))return 1;if(l=i<<1,o?(2147483647-l|0)<(0|i):(-2147483648-l|0)>(0|i))return 1;if(r?(2147483647-t|0)<(0|i):(-2147483648-t|0)>(0|i))return 1;if(r=3*i|0,(0|i)>-1?(-2147483648|r)>=(0|a):(-2147483648^r)<(0|a))return 1}else r=3*i|0,t=a<<1;return o=0|Oe(.14285714285714285*+(t+i|0)),n[A>>2]=o,i=0|Oe(.14285714285714285*+(r-a|0)),n[s>>2]=i,n[e>>2]=0,t=(r=(0|i)<(0|o))?o:i,(0|(r=r?i:o))<0&&((-2147483648==(0|r)||((0|t)>0?(2147483647-t|0)<(0|r):(-2147483648-t|0)>(0|r)))&&M(27795,26892,402,26917),((0|t)>-1?(-2147483648|t)>=(0|r):(-2147483648^t)<(0|r))&&M(27795,26892,402,26917)),t=i-o|0,(0|o)<0?(r=0-o|0,n[s>>2]=t,n[e>>2]=r,n[A>>2]=0,o=0):(t=i,r=0),(0|t)<0&&(o=o-t|0,n[A>>2]=o,r=r-t|0,n[e>>2]=r,n[s>>2]=0,t=0),a=o-r|0,i=t-r|0,(0|r)<0?(n[A>>2]=a,n[s>>2]=i,n[e>>2]=0,t=i,i=a,r=0):i=o,(0|(o=(0|r)<(0|(o=(0|t)<(0|i)?t:i))?r:o))<=0||(n[A>>2]=i-o,n[s>>2]=t-o,n[e>>2]=r-o),0}function fA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+((3*(r=(0|n[A>>2])-o|0)|0)-(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((o<<1)+r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function dA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+(((r=(0|n[A>>2])-o|0)<<1)+(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((3*o|0)-r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function gA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(3*o|0)|0,n[A>>2]=s,i=a+(3*i|0)|0,n[t>>2]=i,o=(3*a|0)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function hA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(3*(o=0|n[(t=A+4|0)>>2])|0)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(3*s|0)|0,n[A>>2]=s,n[t>>2]=a,o=(3*i|0)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function mA(A,e){A|=0;var t,r,o,i=0,a=0,s=0;((e|=0)-1|0)>>>0>=6||(s=(0|n[15440+(12*e|0)>>2])+(0|n[A>>2])|0,n[A>>2]=s,o=A+4|0,a=(0|n[15440+(12*e|0)+4>>2])+(0|n[o>>2])|0,n[o>>2]=a,r=A+8|0,e=(0|n[15440+(12*e|0)+8>>2])+(0|n[r>>2])|0,n[r>>2]=e,i=a-s|0,(0|s)<0?(e=e-s|0,n[o>>2]=i,n[r>>2]=e,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,e=e-i|0,n[r>>2]=e,n[o>>2]=0,i=0),t=a-e|0,s=i-e|0,(0|e)<0?(n[A>>2]=t,n[o>>2]=s,n[r>>2]=0,a=t,e=0):s=i,(0|(i=(0|e)<(0|(i=(0|s)<(0|a)?s:a))?e:i))<=0||(n[A>>2]=a-i,n[o>>2]=s-i,n[r>>2]=e-i))}function bA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(o=0|n[(t=A+4|0)>>2])+s|0,s=(i=0|n[(r=A+8|0)>>2])+s|0,n[A>>2]=s,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function pA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],a=0|n[(t=A+4|0)>>2],i=0|n[(r=A+8|0)>>2],s=a+o|0,n[A>>2]=s,a=i+a|0,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function vA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function wA(A){switch(0|(A|=0)){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}return 0|A}function xA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(o<<1)|0,n[A>>2]=s,i=a+(i<<1)|0,n[t>>2]=i,o=(a<<1)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function yA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=((o=0|n[(t=A+4|0)>>2])<<1)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(s<<1)|0,n[A>>2]=s,n[t>>2]=a,o=(i<<1)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function kA(A,e){e|=0;var t,r,o,i=0,a=0,s=0;return o=(0|(r=(0|n[(A|=0)>>2])-(0|n[e>>2])|0))<0,t=(0|(a=(0|n[A+4>>2])-(0|n[e+4>>2])-(o?r:0)|0))<0,e=(e=(A=(0|(s=(o?0-r|0:0)+(0|n[A+8>>2])-(0|n[e+8>>2])+(t?0-a|0:0)|0))<0)?0:s)-((a=(0|(A=(0|e)<(0|(A=(0|(i=(t?0:a)-(A?s:0)|0))<(0|(s=(o?0:r)-(t?a:0)-(A?s:0)|0))?i:s))?e:A))>0)?A:0)|0,i=i-(a?A:0)|0,0|((0|(A=(0|(A=s-(a?A:0)|0))>-1?A:0-A|0))>(0|(e=(0|(i=(0|i)>-1?i:0-i|0))>(0|(e=(0|e)>-1?e:0-e|0))?i:e))?A:e)}function CA(A){var e,t,r,o;t=(o=0|n[(e=8+(A|=0)|0)>>2])-(0|n[A>>2])|0,n[A>>2]=t,A=(0|n[(r=A+4|0)>>2])-o|0,n[r>>2]=A,n[e>>2]=0-(A+t)}function BA(A){var e,t,r=0,o=0,i=0,a=0,s=0;r=0-(o=0|n[(A|=0)>>2])|0,n[A>>2]=r,n[(e=A+8|0)>>2]=0,a=(i=0|n[(t=A+4|0)>>2])+o|0,(0|o)>0?(n[t>>2]=a,n[e>>2]=o,n[A>>2]=0,r=0,i=a):o=0,(0|i)<0?(s=r-i|0,n[A>>2]=s,o=o-i|0,n[e>>2]=o,n[t>>2]=0,a=s-o|0,r=0-o|0,(0|o)<0?(n[A>>2]=a,n[t>>2]=r,n[e>>2]=0,i=r,o=0):(i=0,a=s)):a=r,(0|(r=(0|o)<(0|(r=(0|i)<(0|a)?i:a))?o:r))<=0||(n[A>>2]=a-r,n[t>>2]=i-r,n[e>>2]=o-r)}function MA(A,e){var t=0;switch(t=0|tt(0|(A|=0),0|(e|=0),56),B(),7&t){case 0:case 7:return 0}return t=-2130706433&e|134217728,!0&268435456==(2013265920&e)?!0&16777216==(117440512&e)&!!(0|HA(A,t))?0|(t=0):0|(t=0|LA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=S,S=S+16|0,r=o,a=-2130706433&(e|=0)|134217728,!0&268435456==(2013265920&e)?(i=0|tt(0|(A|=0),0|e,56),B(),i=0|function(A,e,t){t|=0;var r,o=0,i=0;if(r=S,S=S+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return S=r,-1;if(1==(0|t)&(o=!!(0|o)))return S=r,-1;do{if(!(0|Fe(A,e,i))){if(o){o=(5+(0|n[26352+(t<<2)>>2])-(0|n[i>>2])|0)%5|0;break}o=(6+(0|n[26384+(t<<2)>>2])-(0|n[i>>2])|0)%6|0;break}o=-1}while(0);return S=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,S=o,0|(a=6)):(0|XA(A,a,r)&&M(27795,26932,282,26947),e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,a)?QA(r,e,i,2,t):FA(r,e,i,2,t),S=o,0|(a=0))):(S=o,0|(a=6))}function EA(A,e,t,r,i){e|=0,t|=0,r|=0,i|=0;var a,s=0,u=0;if(s=+function(A){var e,t;return t=+o[(A|=0)>>3],e=+o[A+8>>3],+ +c(+(t*t+e*e))}(A|=0),s<1e-16)return e=15600+(e<<4)|0,n[i>>2]=n[e>>2],n[i+4>>2]=n[e+4>>2],n[i+8>>2]=n[e+8>>2],void(n[i+12>>2]=n[e+12>>2]);if(u=+p(+ +o[A+8>>3],+ +o[A>>3]),(0|t)>0){A=0;do{s*=.37796447300922725,A=A+1|0}while((0|A)!=(0|t))}a=.3333333333333333*s,r?(t=!(0|ZA(t)),s=+b(.381966011250105*(t?a:.37796447300922725*a))):(s=+b(.381966011250105*s),0|ZA(t)&&(u=+ne(u+.3334731722518321))),function(A,e,t,r){A|=0,e=+e,r|=0;var i=0,a=0,s=0,c=0;if((t=+t)<1e-16)return n[r>>2]=n[A>>2],n[r+4>>2]=n[A+4>>2],n[r+8>>2]=n[A+8>>2],void(n[r+12>>2]=n[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(i=+l(+(a+-3.141592653589793))<1e-16,e=+o[A>>3],i){e-=t,o[r>>3]=e,i=r;break}if(s=+f(+t),t=+d(+t),e=s*+d(+e)+ +f(+a)*(t*+f(+e)),e=+m(+((e=e>1?1:e)<-1?-1:e)),o[r>>3]=e,+l(+(e+-1.5707963267948966))<1e-16)return o[r>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[r>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if(c=1/+f(+e),a=t*+d(+a)*c,t=+o[A>>3],e=c*((s-+d(+e)*+d(+t))/+f(+t)),s=a>1?1:a,e=e>1?1:e,(e=+o[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(o[r+8>>3]=e)}e=+o[A>>3]+t,o[r>>3]=e,i=r}while(0);if(+l(+(e+-1.5707963267948966))<1e-16)return o[i>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[i>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if((e=+o[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);o[r+8>>3]=e}(15600+(e<<4)|0,+ne(+o[15920+(24*e|0)>>3]-u),s,i)}function QA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,w,x,y,k,C,B,D,E,Q,j=0,N=0,F=0,P=0,T=0,L=0;if(Q=S,S=S+272|0,P=Q+240|0,B=Q,D=Q+224|0,E=Q+208|0,b=Q+176|0,p=Q+160|0,v=Q+192|0,w=Q+144|0,x=Q+128|0,y=Q+112|0,k=Q+96|0,C=Q+80|0,n[(j=Q+256|0)>>2]=e,n[P>>2]=n[A>>2],n[P+4>>2]=n[A+4>>2],n[P+8>>2]=n[A+8>>2],n[P+12>>2]=n[A+12>>2],jA(P,j,B),n[i>>2]=0,(0|(P=r+t+(5==(0|r)&1)|0))<=(0|t))S=Q;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[j>>2])<<2)|0,f=16960+(a<<2)|0,d=x+8|0,g=y+8|0,h=k+8|0,m=E+4|0,F=t;A:for(;;){N=B+((0|F)%5<<4)|0,n[E>>2]=n[N>>2],n[E+4>>2]=n[N+4>>2],n[E+8>>2]=n[N+8>>2],n[E+12>>2]=n[N+12>>2];do{}while(2==(0|NA(E,a,0,1)));if((0|F)>(0|t)&!!(0|ZA(e))){if(n[b>>2]=n[E>>2],n[b+4>>2]=n[E+4>>2],n[b+8>>2]=n[E+8>>2],n[b+12>>2]=n[E+12>>2],oA(s,p),r=0|n[b>>2],j=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*j|0)>>2],(0|(N=0|n[18640+(80*r|0)+(20*j|0)+16>>2]))>0){A=0;do{bA(l),A=A+1|0}while((0|A)<(0|N))}switch(N=18640+(80*r|0)+(20*j|0)+4|0,n[v>>2]=n[N>>2],n[v+4>>2]=n[N+4>>2],n[v+8>>2]=n[N+8>>2],sA(v,3*(0|n[u>>2])|0),iA(l,v,l),nA(l),oA(l,w),T=+(0|n[f>>2]),o[x>>3]=3*T,o[d>>3]=0,L=-1.5*T,o[y>>3]=L,o[g>>3]=2.598076211353316*T,o[k>>3]=L,o[h>>3]=-2.598076211353316*T,0|n[17040+(80*(0|n[b>>2])|0)+(n[E>>2]<<2)>>2]){case 1:A=y,r=x;break;case 3:A=k,r=y;break;case 2:A=x,r=k;break;default:A=12;break A}je(p,w,r,A,C),EA(C,0|n[b>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])}if((0|F)<(0|c)&&(oA(m,b),EA(b,0|n[E>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),n[D>>2]=n[E>>2],n[D+4>>2]=n[E+4>>2],n[D+8>>2]=n[E+8>>2],n[D+12>>2]=n[E+12>>2],(0|(F=F+1|0))>=(0|P)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):S=Q}}function jA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=S,S=S+128|0,i=r,s=20240,l=60+(a=o=r+64|0)|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));s=20304,l=(a=i)+60|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));o=(l=!(0|ZA(0|n[e>>2])))?o:i,xA(i=A+4|0),yA(i),0|ZA(0|n[e>>2])&&(hA(i),n[e>>2]=1+(0|n[e>>2])),n[t>>2]=n[A>>2],iA(i,o,e=t+4|0),nA(e),n[t+16>>2]=n[A>>2],iA(i,o+12|0,e=t+20|0),nA(e),n[t+32>>2]=n[A>>2],iA(i,o+24|0,e=t+36|0),nA(e),n[t+48>>2]=n[A>>2],iA(i,o+36|0,e=t+52|0),nA(e),n[t+64>>2]=n[A>>2],iA(i,o+48|0,t=t+68|0),nA(t),S=r}function NA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,f=0,d=0,g=0,h=0;if(c=S,S=S+32|0,l=c+12|0,i=c,h=4+(A|=0)|0,g=0|n[16960+((e|=0)<<2)>>2],g=(s=!!(0|r))?3*g|0:g,u=0|n[h>>2],o=0|n[(a=A+8|0)>>2],s){if((0|(u=o+u+(r=0|n[(f=A+12|0)>>2])|0))==(0|g))return S=c,1;d=f}else u=o+u+(r=0|n[(d=A+12|0)>>2])|0;if((0|u)<=(0|g))return S=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){f=18640+(80*r|0)+60|0,r=A;break}r=18640+(80*r|0)+40|0,t?(rA(l,g,0,0),aA(h,l,i),pA(i),iA(i,l,h),f=r,r=A):(f=r,r=A)}else f=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[f>>2],(0|n[(u=f+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=f+4|0,n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],e=0|n[16880+(e<<2)>>2],sA(l,s?3*e|0:e),iA(h,l,h),nA(h),r=s&&((0|n[a>>2])+(0|n[h>>2])+(0|n[d>>2])|0)==(0|g)?1:2,S=c,0|r}function SA(A,e){A|=0,e|=0;var t=0;do{t=0|NA(A,e,0,1)}while(2==(0|t));return 0|t}function FA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,w,x,y,k,C,B=0,D=0,E=0,Q=0,j=0;if(C=S,S=S+240|0,w=C+208|0,x=C,y=C+192|0,k=C+176|0,h=C+160|0,m=C+144|0,b=C+128|0,p=C+112|0,v=C+96|0,n[(B=C+224|0)>>2]=e,n[w>>2]=n[A>>2],n[w+4>>2]=n[A+4>>2],n[w+8>>2]=n[A+8>>2],n[w+12>>2]=n[A+12>>2],PA(w,B,x),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))S=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,f=p+8|0,d=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=x+((B=(0|E)%6|0)<<4)|0,n[y>>2]=n[A>>2],n[y+4>>2]=n[A+4>>2],n[y+8>>2]=n[A+8>>2],n[y+12>>2]=n[A+12>>2],A=D,D=0|NA(y,a,0,1),(0|E)>(0|t)&!!(0|ZA(e))&&1!=(0|A)&&(0|n[y>>2])!=(0|r)){switch(oA(x+((B+5|0)%6<<4)+4|0,k),oA(x+(B<<4)+4|0,h),Q=+(0|n[l>>2]),o[m>>3]=3*Q,o[c>>3]=0,j=-1.5*Q,o[b>>3]=j,o[u>>3]=2.598076211353316*Q,o[p>>3]=j,o[f>>3]=-2.598076211353316*Q,B=0|n[w>>2],0|n[17040+(80*B|0)+(((0|r)==(0|B)?n[y>>2]:r)<<2)>>2]){case 1:A=b,r=m;break;case 3:A=p,r=b;break;case 2:A=m,r=p;break;default:A=8;break A}je(k,h,r,A,v),0|Ne(k,v)||0|Ne(h,v)||(EA(v,0|n[w>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(d,k),EA(k,0|n[y>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),(0|(E=E+1|0))>=(0|g)){A=3;break}r=0|n[y>>2]}3!=(0|A)?8==(0|A)&&M(27054,27017,737,27099):S=C}}function PA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=S,S=S+160|0,i=r,s=20368,l=72+(a=o=r+80|0)|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));s=20448,l=(a=i)+72|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));o=(l=!(0|ZA(0|n[e>>2])))?o:i,xA(i=A+4|0),yA(i),0|ZA(0|n[e>>2])&&(hA(i),n[e>>2]=1+(0|n[e>>2])),n[t>>2]=n[A>>2],iA(i,o,e=t+4|0),nA(e),n[t+16>>2]=n[A>>2],iA(i,o+12|0,e=t+20|0),nA(e),n[t+32>>2]=n[A>>2],iA(i,o+24|0,e=t+36|0),nA(e),n[t+48>>2]=n[A>>2],iA(i,o+36|0,e=t+52|0),nA(e),n[t+64>>2]=n[A>>2],iA(i,o+48|0,e=t+68|0),nA(e),n[t+80>>2]=n[A>>2],iA(i,o+60|0,t=t+84|0),nA(t),S=r}function TA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function LA(A,e){A|=0;var t=0,n=0,o=0,i=0;return!0&134217728==(-16777216&(e|=0))?(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0>121?0|(A=0):!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())?0|r[20528+t|0]?!(0|A)&!(0|(e&=8191))?0|(i=1):(i=0|nt(0|A,0|e),B(),0|!!((63-i|0)%3|0)):0|(i=1):0|(i=0)):0|(A=0)}function IA(A,e,t,r){A|=0,t|=0,r|=0;var o=0,i=0,a=0,s=0;if(o=0|rt(0|(e|=0),0,52),i=0|B(),t=0|rt(0|t,0,45),t=0|i|B()|134225919,(0|e)<1)return i=-1,r=t,n[(e=A)>>2]=i,void(n[(A=A+4|0)>>2]=r);for(i=1,o=-1;s=0|rt(7,0,0|(a=3*(15-i|0)|0)),t&=~B(),o=o&~s|(a=0|rt(0|r,0,0|a)),t=0|t|B(),(0|i)!=(0|e);)i=i+1|0;n[(a=s=A)>>2]=o,n[(s=s+4|0)>>2]=t}function RA(A,e,t,r){t|=0,r|=0;var o=0,i=0;if(i=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return 4;if((0|(i&=15))<(0|t))return 12;if((0|i)==(0|t))return n[r>>2]=A,n[r+4>>2]=e,0;if(o=0|rt(0|t,0,52),o|=A,A=B()|-15728641&e,(0|i)>(0|t))do{e=0|rt(7,0,3*(14-t|0)|0),t=t+1|0,o|=e,A=0|B()|A}while((0|t)<(0|i));return n[r>>2]=o,n[r+4>>2]=A,0}function _A(A,e,t,r){t|=0,r|=0;var o=0,i=0,a=0;if(i=0|tt(0|(A|=0),0|(e|=0),52),B(),!((0|t)<16&(0|(i&=15))<=(0|t)))return 4;o=t-i|0,t=0|tt(0|A,0|e,45),B();A:do{if(0|z(127&t)){e:do{if(0|i){for(t=1;!((a=0|rt(7,0,3*(15-t|0)|0))&A)&!((0|B())&e);){if(!(t>>>0>>0))break e;t=t+1|0}t=0|pe(7,0,o,((0|o)<0)<<31>>31),o=0|B();break A}}while(0);t=0|Ve(0|(t=0|qe(0|(t=0|pe(7,0,o,((0|o)<0)<<31>>31)),0|B(),5,0)),0|B(),-5,-1),t=0|Ve(0|(t=0|Xe(0|t,0|B(),6,0)),0|B(),1,0),o=0|B()}else t=0|pe(7,0,o,((0|o)<0)<<31>>31),o=0|B()}while(0);return n[(a=r)>>2]=t,n[a+4>>2]=o,0}function HA(A,e){var t=0,r=0,n=0;if(n=0|tt(0|(A|=0),0|(e|=0),45),B(),!(0|z(127&n)))return 0;n=0|tt(0|A,0|e,52),B(),n&=15;A:do{if(n)for(r=1;;){if(t=0|tt(0|A,0|e,3*(15-r|0)|0),B(),0|(t&=7))break A;if(!(r>>>0>>0)){t=0;break}r=r+1|0}else t=0}while(0);return 1&!(0|t)}function zA(A,e,t,r){return A|=0,e|=0,(0|(r|=0))<(0|(t|=0))?(r=A,C(0|(t=e)),0|r):(t=0|rt(-1,-1,3+(3*(r-t|0)|0)|0),r=0|rt(0|~t,0|~B(),3*(15-r|0)|0),t=~B()&e,r=~r&A,C(0|t),0|r)}function GA(A,e,t,r){t|=0,r|=0;var o=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),(0|t)<16&(0|(o&=15))<=(0|t)?((0|o)<(0|t)&&(o=0|rt(-1,-1,3+(3*(t+-1-o|0)|0)|0),o=0|rt(0|~o,0|~B(),3*(15-t|0)|0),e=~B()&e,A&=~o),o=0|rt(0|t,0,52),t=-15728641&e|B(),n[r>>2]=A|o,n[r+4>>2]=t,0|(r=0)):0|(r=4)}function OA(A,e){var t=0,r=0,n=0;if(n=0|tt(0|(A|=0),0|(e|=0),52),B(),!(n&=15))return 0;for(r=1;;){if(t=0|tt(0|A,0|e,3*(15-r|0)|0),B(),0|(t&=7)){r=5;break}if(!(r>>>0>>0)){t=0,r=5;break}r=r+1|0}return 5==(0|r)?0|t:0}function UA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(n=0|tt(0|A,0|e,0|(i=3*(15-t|0)|0)),B(),o=0|rt(7,0,0|i),e&=~B(),A=A&~o|(i=0|rt(0|vA(7&n),0,0|i)),e=0|e|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function YA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;i=0|tt(0|A,0|e,0|(o=3*(15-t|0)|0)),B(),n=0|rt(7,0,0|o),e&=~B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~n,e=0|B()|e,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function WA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|wA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(o=0|rt(7,0,0|(n=3*(15-t|0)|0)),i=e&~B(),e=0|tt(0|A,0|e,0|n),B(),A=A&~o|(e=0|rt(0|wA(7&e),0,0|n)),e=0|i|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function VA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;o=0|rt(7,0,0|(i=3*(15-t|0)|0)),n=e&~B(),e=0|tt(0|A,0|e,0|i),B(),A=(e=0|rt(0|wA(7&e),0,0|i))|A&~o,e=0|B()|n,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function ZA(A){return(0|(A|=0))%2|0}function KA(A,e,t){t|=0;var r,i=0;return r=S,S=S+16|0,i=r,(e|=0)>>>0>15?(S=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=S,S=S+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=S,S=S+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=S,S=S+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+f(+n),n=+d(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+f(+n),o[e>>3]=r,n=t*+d(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Se(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Se(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Se(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Se(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Se(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Se(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Se(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Se(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Se(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Se(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Se(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Se(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Se(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Se(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Se(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Se(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Se(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Se(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Se(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Se(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,S=i):S=i}(A|=0,t|=0,c=i),(s=+h(+(1-.5*+o[c>>3])))<1e-16)return n[r>>2]=0,n[r+4>>2]=0,n[r+8>>2]=0,n[r+12>>2]=0,void(S=i);if(c=0|n[t>>2],a=+ne((a=+o[15920+(24*c|0)>>3])-+ne(+function(A,e){var t,r,n,i,a;return A|=0,i=+o[(e|=0)>>3],r=+f(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+d(+n),t=+o[A>>3],+ +p(+a,+(+d(+i)*+f(+t)-+f(+n)*(r*+d(+t))))}(15600+(c<<4)|0,A))),l=0|ZA(e)?+ne(a+-.3334731722518321):a,a=2.618033988749896*+g(+s),(0|e)>0){A=0;do{a*=2.6457513110645907,A=A+1|0}while((0|A)!=(0|e))}s=+f(+l)*a,o[r>>3]=s,l=+d(+l)*a,o[r+8>>3]=l,S=i}(A|=0,e|=0,t|=0,i=r),function(A,e){A|=0;var t,r,i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],f=+l(+r),i=+o[A+8>>3],f+=.5*(d=1.1547005383792515*+l(+i)),f-=+(0|(s=~~f)),d-=+(0|(A=~~d));do{if(f<.5){if(f<.3333333333333333){if(n[e>>2]=s,d<.5*(f+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(d<(h=1-f)))+A|0,n[e+4>>2]=A,h<=d&d<2*f){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(f<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,d<.5*f){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(d<1-f){if(n[e+4>>2]=A,2*f-1>2]=s;break}}else A=A+1|0,n[e+4>>2]=A;s=s+1|0,n[e>>2]=s}while(0);do{if(r<0){if(1&A){s=~~(+(0|s)-(2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(A+1|0)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))+1)),n[e>>2]=s;break}s=~~(+(0|s)-2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(0|A)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))),n[e>>2]=s;break}}while(0);g=e+4|0,i<0&&(s=s-((1|A<<1)/2|0)|0,n[e>>2]=s,A=0-A|0,n[g>>2]=A),c=A-s|0,(0|s)<0?(u=0-s|0,n[g>>2]=c,n[a>>2]=u,n[e>>2]=0,A=c,s=0):u=0,(0|A)<0&&(s=s-A|0,n[e>>2]=s,u=u-A|0,n[a>>2]=u,n[g>>2]=0,A=0),t=s-u|0,c=A-u|0,(0|u)<0&&(n[e>>2]=t,n[g>>2]=c,n[a>>2]=0,A=c,s=t,u=0),(0|(c=(0|u)<(0|(c=(0|A)<(0|s)?A:s))?u:c))<=0||(n[e>>2]=s-c,n[g>>2]=A-c,n[a>>2]=u-c)}(i,t+4|0),S=r}(A,e,i),e=0|function(A,e){A|=0;var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0;if(t=S,S=S+64|0,l=t+40|0,o=t+24|0,i=t+12|0,a=t,rt(0|(e|=0),0,52),r=134225919|B(),!e)return(0|n[A+4>>2])>2||(0|n[A+8>>2])>2||(0|n[A+12>>2])>2?(l=0,C(0|(s=0)),S=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),S=t,0|l);if(n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],n[l+12>>2]=n[A+12>>2],s=l+4|0,(0|e)>0)for(A=-1;n[o>>2]=n[s>>2],n[o+4>>2]=n[s+4>>2],n[o+8>>2]=n[s+8>>2],1&e?(fA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],gA(i)):(dA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],hA(i)),aA(o,i,a),nA(a),c=0|rt(7,0,0|(u=3*(15-e|0)|0)),r&=~B(),A=(u=0|rt(0|lA(a),0,0|u))|A&~c,r=0|B()|r,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|n[s>>2])<=2&&(0|n[l+8>>2])<=2&&(0|n[l+12>>2])<=2){if(e=0|rt(0|(o=0|O(l)),0,45),e|=A,A=B()|-1040385&r,a=0|U(l),!(0|z(o))){if((0|a)<=0)break;for(i=0;;){if(o=0|tt(0|e,0|A,52),B(),o&=15)for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0;if((0|(i=i+1|0))==(0|a))break A}}i=0|tt(0|e,0|A,52),B(),i&=15;e:do{if(i){r=1;t:for(;;){switch(u=0|tt(0|e,0|A,3*(15-r|0)|0),B(),7&u){case 1:break t;case 0:break;default:break e}if(!(r>>>0>>0))break e;r=r+1|0}if(0|Y(o,0|n[l>>2]))for(r=1;c=0|rt(7,0,0|(l=3*(15-r|0)|0)),u=A&~B(),A=0|tt(0|e,0|A,0|l),B(),e=e&~c|(A=0|rt(0|wA(7&A),0,0|l)),A=0|u|B(),r>>>0>>0;)r=r+1|0;else for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0}}while(0);if((0|a)>0){r=0;do{e=0|UA(e,A),A=0|B(),r=r+1|0}while((0|r)!=(0|a))}}else e=0,A=0}while(0);return u=e,C(0|(c=A)),S=t,0|u}(i,e),i=0|B(),n[t>>2]=e,n[t+4>>2]=i,!(0|e)&!(0|i)&&M(27795,27122,1050,27145),S=r,0|(i=0)):(S=r,0|(i=3))}function JA(A,e,t){var r,o=0,i=0,a=0;if(r=4+(t|=0)|0,i=0|tt(0|(A|=0),0|(e|=0),52),B(),i&=15,a=0|tt(0|A,0|e,45),B(),o=!(0|i),0|z(127&a)){if(o)return 1;o=1}else{if(o)return 0;o=0|n[r>>2]||0|n[t+8>>2]?1:1&!!(0|n[t+12>>2])}for(t=1;1&t?gA(r):hA(r),a=0|tt(0|A,0|e,3*(15-t|0)|0),B(),mA(r,7&a),t>>>0>>0;)t=t+1|0;return 0|o}function XA(A,e,t){t|=0;var r,o,i=0,a=0,s=0,l=0,c=0,u=0;if(o=S,S=S+16|0,r=o,u=0|tt(0|(A|=0),0|(e|=0),45),B(),(u&=127)>>>0>121)return n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,n[t+12>>2]=0,S=o,5;A:do{if(0|z(u)&&(s=0|tt(0|A,0|e,52),B(),0|(s&=15))){i=1;e:for(;;){switch(c=0|tt(0|A,0|e,3*(15-i|0)|0),B(),7&c){case 5:break e;case 0:break;default:i=e;break A}if(!(i>>>0>>0)){i=e;break A}i=i+1|0}for(a=1,i=e;l=0|rt(7,0,0|(e=3*(15-a|0)|0)),c=i&~B(),i=0|tt(0|A,0|i,0|e),B(),A=A&~l|(i=0|rt(0|wA(7&i),0,0|e)),i=0|c|B(),a>>>0>>0;)a=a+1|0}else i=e}while(0);if(c=7696+(28*u|0)|0,n[t>>2]=n[c>>2],n[t+4>>2]=n[c+4>>2],n[t+8>>2]=n[c+8>>2],n[t+12>>2]=n[c+12>>2],!(0|JA(A,i,t)))return S=o,0;if(l=t+4|0,n[r>>2]=n[l>>2],n[r+4>>2]=n[l+4>>2],n[r+8>>2]=n[l+8>>2],s=0|tt(0|A,0|i,52),B(),c=15&s,1&s?(hA(l),s=c+1|0):s=c,0|z(u)){A:do{if(c)for(e=1;;){if(a=0|tt(0|A,0|i,3*(15-e|0)|0),B(),0|(a&=7)){i=a;break A}if(!(e>>>0>>0)){i=0;break}e=e+1|0}else i=0}while(0);i=4==(0|i)&1}else i=0;if(0|NA(t,s,i,0)){if(0|z(u))do{}while(0|NA(t,s,0,0));(0|s)!=(0|c)&&dA(l)}else(0|s)!=(0|c)&&(n[l>>2]=n[r>>2],n[l+4>>2]=n[r+4>>2],n[l+8>>2]=n[r+8>>2]);return S=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=S,S=S+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(S=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=S,S=S+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),S=r}(r,15&i,t),S=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=S,S=S+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return S=r,0|n;n=0|tt(0|A,0|e,45),B(),n=!(0|z(127&n)),o=0|tt(0|A,0|e,52),B(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(!((0|rt(7,0,3*(15-n|0)|0))&A)&!((0|B())&e)))break A;if(!(n>>>0>>0))break;n=n+1|0}return QA(i,o,0,5,t),S=r,0}}while(0);return FA(i,o,0,6,t),S=r,0}function Ae(A,e){e|=0;var t=0,r=0,o=0,i=0,a=0,s=0,l=0;if((A|=0)>>>0>15)return 4;if(rt(0|A,0,52),s=134225919|B(),!A){t=0,r=0;do{0|z(r)&&(rt(0|r,0,45),a=0|s|B(),n[(A=e+(t<<3)|0)>>2]=-1,n[A+4>>2]=a,t=t+1|0),r=r+1|0}while(122!=(0|r));return 0}t=0,a=0;do{if(0|z(a)){for(rt(0|a,0,45),r=1,o=-1,i=0|s|B();o&=~(l=0|rt(7,0,3*(15-r|0)|0)),i&=~B(),(0|r)!=(0|A);)r=r+1|0;n[(l=e+(t<<3)|0)>>2]=o,n[l+4>>2]=i,t=t+1|0}a=a+1|0}while(122!=(0|a));return 0}function ee(A,e,t,r){A|=0,r|=0;var o=0,i=0,a=0;o=0|tt(0|(e|=0),0|(t|=0),52),B(),!(0|e)&!(0|t)|(0|r)>15|(0|(o&=15))>(0|r)?(i=-1,e=-1,t=0,o=0):(e=0|zA(e,t,o+1|0,r),a=-15728641&B(),t=0|rt(0|r,0,52),i=o,e=(e=!(0|HA(t|=e,a=0|a|B())))?-1:r,o=a),n[(a=A)>>2]=t,n[a+4>>2]=o,n[A+8>>2]=i,n[A+12>>2]=e}function te(A,e,t,r){t|=0,r|=0;var o=0,i=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,n[(i=r+8|0)>>2]=o,!(0|A)&!(0|e)|(0|t)>15|(0|o)>(0|t)?(n[(t=r)>>2]=0,n[t+4>>2]=0,n[i>>2]=-1,void(n[r+12>>2]=-1)):(A=0|zA(A,e,o+1|0,t),i=-15728641&B(),o=0|rt(0|t,0,52),o|=A,i=0|i|B(),n[(A=r)>>2]=o,n[A+4>>2]=i,A=r+12|0,0|HA(o,i)?void(n[A>>2]=t):void(n[A>>2]=-1))}function re(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(!(!(0|(t=0|n[(r=A|=0)>>2]))&!(0|(r=0|n[r+4>>2]))||(o=0|tt(0|t,0|r,52),B(),t=0|Ve(0|(l=0|rt(1,0,3*(15^(o&=15))|0)),0|B(),0|t,0|r),r=0|B(),n[(l=A)>>2]=t,n[l+4>>2]=r,(0|o)<(0|(s=0|n[(l=A+8|0)>>2]))))){for(e=A+12|0,a=o;;){if((0|a)==(0|s)){o=5;break}if(c=(0|a)==(0|n[e>>2]),o=0|tt(0|t,0|r,0|(i=3*(15-a|0)|0)),B(),c&1==(0|(o&=7))&!0){o=7;break}if(!(7==(0|o)&!0)){o=10;break}if(t=0|Ve(0|t,0|r,0|(c=0|rt(1,0,0|i)),0|B()),r=0|B(),n[(c=A)>>2]=t,n[c+4>>2]=r,!((0|a)>(0|s))){o=10;break}a=a+-1|0}if(5==(0|o))return n[(c=A)>>2]=0,n[c+4>>2]=0,n[l>>2]=-1,void(n[e>>2]=-1);if(7==(0|o))return s=0|Ve(0|t,0|r,0|(s=0|rt(1,0,0|i)),0|B()),l=0|B(),n[(c=A)>>2]=s,n[c+4>>2]=l,void(n[e>>2]=a+-1)}}function ne(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function oe(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<17453292519943298e-27?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<17453292519943298e-27):0|(e=0)}function ie(A,e){switch(A=+A,0|(e|=0)){case 1:A=A<0?A+6.283185307179586:A;break;case 2:A=A>0?A+-6.283185307179586:A}return+A}function ae(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475}function se(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20656+(A<<3)>>3],0|(e=0))}function le(A,e){e|=0;var t=0;return(A|=0)>>>0>15?0|(e=4):(t=0|qe(0|(t=0|pe(7,0,A,((0|A)<0)<<31>>31)),0|B(),120,0),A=0|B(),n[e>>2]=2|t,n[e+4>>2]=A,0|(e=0))}function ce(A,e,t){A|=0,t|=0;var r,n,i,a,s=0,l=0,u=0,h=0,m=0,v=0;return v=+o[(e|=0)>>3],i=+o[A>>3],m=+d(.5*(v-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+d(.5*(u-n)),r=+f(+i),a=+f(+v),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],v=+d(.5*(m-v)),s=+o[t+8>>3],u=+d(.5*(s-u)),l=+f(+m),u=2*+p(+ +c(+(u=v*v+u*(a*l*u))),+ +c(+(1-u))),m=+d(.5*(i-m)),s=+d(.5*(n-s)),s=2*+p(+ +c(+(s=m*m+s*(r*l*s))),+ +c(+(1-s))),4*+b(+ +c(+ +g(.5*(l=.5*(h+u+s)))*+g(.5*(l-h))*+g(.5*(l-u))*+g(.5*(l-s))))}function ue(A,e,t){t|=0;var r,i,a,s=0,l=0;if(a=S,S=S+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return S=a,0|l;if(0|$A(A,e,i)&&M(27795,27190,415,27199),(0|(e=0|n[i>>2]))>0){if(s=+ce(i+8|0,i+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{s+=+ce(i+8+((l=A)<<4)|0,i+8+((0|(A=A+1|0))%(0|e)<<4)|0,r)}while((0|A)<(0|e))}}else s=0;return o[t>>3]=s,S=a,0}function fe(A){A|=0;var e,t,r=0;return(e=0|We(1,12))||M(27280,27235,49,27293),0|(r=0|n[(t=A+4|0)>>2])?(n[(r=r+8|0)>>2]=e,n[t>>2]=e,0|e):(0|n[A>>2]&&M(27310,27235,61,27333),n[(r=A)>>2]=e,n[t>>2]=e,0|e)}function de(A,e){var t,r;return A|=0,e|=0,(r=0|Ue(24))||M(27347,27235,78,27361),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[r+16>>2]=0,0|(t=0|n[(e=A+4|0)>>2])?(n[t+16>>2]=r,n[e>>2]=r,0|r):(0|n[A>>2]&&M(27376,27235,82,27361),n[A>>2]=r,n[e>>2]=r,0|r)}function ge(A){var e=0,t=0,r=0,o=0;if(A|=0)for(r=1;;){if(0|(e=0|n[A>>2]))do{if(0|(t=0|n[e>>2]))do{o=t,t=0|n[t+16>>2],Ye(o)}while(0|t);o=e,e=0|n[e+8>>2],Ye(o)}while(0|e);if(e=A,A=0|n[A+8>>2],r||Ye(e),!A)break;r=0}}function he(A,e,t){A|=0;var r=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),r=+o[t>>3],i=e&(i=+o[t+8>>3])<0?i+6.283185307179586:i,!(A=0|n[A>>2]))return 0;if(e){e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(((c=(l=s<0?s+6.283185307179586:s)+(r-a)/(c-a)*((s=i<0?i+6.283185307179586:i)-l))<0?c+6.283185307179586:c)>(u=l==u|s==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}else{e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(s+(r-a)/(c-a)*(i-s)>(u=s==u|i==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}return 0}function me(A,e,t,o,i){t|=0,o|=0,i|=0;var a,s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(c=S,S=S+32|0,w=c+16|0,l=c,u=0|tt(0|(A|=0),0|(e|=0),52),B(),u&=15,b=0|tt(0|t,0|o,52),B(),(0|u)!=(15&b))return S=c,12;if(h=0|tt(0|A,0|e,45),B(),h&=127,m=0|tt(0|t,0|o,45),B(),h>>>0>121|(m&=127)>>>0>121)return S=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(d=0|V(h,m))))return S=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=d,f=g)}else p=0,f=0;a=0|z(h),s=0|z(m),n[w>>2]=0,n[w+4>>2]=0,n[w+8>>2]=0,n[w+12>>2]=0;do{if(p){if(d=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(d){h=0,g=t,d=o;do{g=0|WA(g,d),d=0|B(),1==(0|(f=0|wA(f)))&&(f=0|wA(1)),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;else if(d){h=0,g=t,d=o;do{g=0|VA(g,d),d=0|B(),f=0|wA(f),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;if(JA(h,g,w),b||M(27563,27538,191,27548),(d=!!(0|a))&(f=!!(0|s))&&M(27590,27538,192,27548),d){if(7==(0|(f=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*f|0)+p|0]){u=1;break}h=g=0|n[21168+(28*f|0)+(p<<2)>>2]}else if(f){if(7==(0|(f=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*f|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(f<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){d=w+4|0,f=0;do{pA(d),f=f+1|0}while((0|f)!=(0|g))}if(n[l>>2]=0,n[l+4>>2]=0,n[l+8>>2]=0,mA(l,p),0|u)for(;0|ZA(u)?gA(l):hA(l),(0|u)>1;)u=u+-1|0;if((0|h)>0){u=0;do{pA(l),u=u+1|0}while((0|u)!=(0|h))}iA(v=w+4|0,l,v),nA(v),v=51}}else if(JA(t,o,w),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(f=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*f|0)+u|0])u=1;else if((0|(f=0|n[21168+(28*f|0)+(u<<2)>>2]))>0){d=w+4|0,u=0;do{pA(d),u=u+1|0}while((0|u)!=(0|f));v=51}else v=51;else v=51}while(0);return 51==(0|v)&&(u=w+4|0,n[i>>2]=n[u>>2],n[i+4>>2]=n[u+4>>2],n[i+8>>2]=n[u+8>>2],u=0),S=c,0|u}function be(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(a=S,S=S+48|0,o=a+36|0,c=a+24|0,u=a+12|0,f=a,s=0|tt(0|(A|=0),0|(e|=0),52),B(),s&=15,g=0|tt(0|A,0|e,45),B(),(g&=127)>>>0>121)return S=a,5;if(i=0|z(g),rt(0|s,0,52),b=134225919|B(),n[(l=r)>>2]=-1,n[l+4>>2]=b,!s)return 7==(0|(s=0|lA(t)))||127==(0|(s=0|W(g,s)))?(S=a,0|(b=1)):(h=0|rt(0|s,0,45),m=0|B(),m=-1040385&n[(g=r)+4>>2]|m,n[(b=r)>>2]=n[g>>2]|h,n[b+4>>2]=m,S=a,0|(b=0));for(n[o>>2]=n[t>>2],n[o+4>>2]=n[t+4>>2],n[o+8>>2]=n[t+8>>2],t=s;;){if(l=t,t=t+-1|0,n[c>>2]=n[o>>2],n[c+4>>2]=n[o+4>>2],n[c+8>>2]=n[o+8>>2],0|ZA(l)){if(0|(s=0|cA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],gA(u)}else{if(0|(s=0|uA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],hA(u)}if(aA(c,u,f),nA(f),v=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(w=3*(15-l|0)|0)),s&=~B(),w=0|rt(0|lA(f),0,0|w),s=0|B()|s,n[(b=r)>>2]=w|v&~p,n[b+4>>2]=s,(0|l)<=1){t=14;break}}A:do{if(13!=(0|t)&&14==(0|t))if((0|n[o>>2])<=1&&(0|n[o+4>>2])<=1&&(0|n[o+8>>2])<=1){f=127==(0|(s=0|W(g,t=0|lA(o))))?0:0|z(s);e:do{if(t){if(i){if(7==(0|(s=0|OA(A,e)))){s=5;break A}if((0|(l=0|n[21376+(28*s|0)+(t<<2)>>2]))>0){s=t,t=0;do{s=0|vA(s),t=t+1|0}while((0|t)!=(0|l))}else s=t;if(1==(0|s)){s=9;break A}127==(0|(t=0|W(g,s)))&&M(27648,27538,411,27678),0|z(t)?M(27693,27538,412,27678):(m=t,h=l,d=s)}else m=s,h=0,d=t;if((0|(u=0|n[4272+(28*g|0)+(d<<2)>>2]))<=-1&&M(27724,27538,419,27678),!f){if((0|h)<0){s=5;break A}if(0|h){s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];do{t=0|YA(t,l),l=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=l,s=s+1|0}while((0|s)<(0|h))}if((0|u)<=0){s=m,t=58;break}for(s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];;)if(t=0|YA(t,l),l=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=l,(0|(s=s+1|0))==(0|u)){s=m,t=58;break e}}if(7==(0|(c=0|V(m,g)))&&M(27514,27538,428,27678),t=0|n[(s=r)>>2],s=0|n[s+4>>2],(0|u)>0){l=0;do{t=0|YA(t,s),s=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=s,l=l+1|0}while((0|l)!=(0|u))}if(7==(0|(s=0|OA(t,s)))&&M(27795,27538,440,27678),t=0|G(m),(0|(t=0|n[(t?21792:21584)+(28*c|0)+(s<<2)>>2]))<0&&M(27795,27538,454,27678),t){s=0,l=0|n[(c=r)>>2],c=0|n[c+4>>2];do{l=0|UA(l,c),c=0|B(),n[(w=r)>>2]=l,n[w+4>>2]=c,s=s+1|0}while((0|s)<(0|t));s=m,t=58}else s=m,t=58}else if(!!(0|i)&!!(0|f)){if(7==(0|(t=0|OA(A,e)))|7==(0|(l=0|OA(0|n[(l=r)>>2],0|n[l+4>>2])))){s=5;break A}if((0|(l=0|n[21376+(28*t|0)+(l<<2)>>2]))<0){s=5;break A}if(l){t=0,c=0|n[(u=r)>>2],u=0|n[u+4>>2];do{c=0|YA(c,u),u=0|B(),n[(w=r)>>2]=c,n[w+4>>2]=u,t=t+1|0}while((0|t)<(0|l));t=58}else t=59}else t=58}while(0);if(58==(0|t)&&f&&(t=59),59==(0|t)&&1==(0|OA(0|n[(w=r)>>2],0|n[w+4>>2]))){s=9;break}p=0|n[(w=r)>>2],w=-1040385&n[w+4>>2],v=0|rt(0|s,0,45),w=0|w|B(),n[(s=r)>>2]=p|v,n[s+4>>2]=w,s=0}else s=1}while(0);return S=a,0|s}function pe(A,e,t,r){A|=0,e|=0;var n=0,o=0,i=0;if(!(0|(t|=0))&!(0|(r|=0)))return o=1,C(0|(n=0)),0|o;o=A,n=e,A=1,e=0;do{A=0|qe(0|((i=!0&!(1&t))?1:o),0|(i?0:n),0|A,0|e),e=0|B(),t=0|et(0|t,0|r,1),r=0|B(),o=0|qe(0|o,0|n,0|o,0|n),n=0|B()}while(!(!(0|t)&!(0|r)));return C(0|e),0|A}function ve(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,d=0;i=S,S=S+16|0,s=i,l=0|tt(0|(A|=0),0|(e|=0),52),B(),l&=15;do{if(l){if(!(a=0|qA(A,e,s))){u=+o[s>>3],c=1/+f(+u),d=+o[25968+(l<<3)>>3],o[t>>3]=u+d,o[t+8>>3]=u-d,u=+o[s+8>>3],c*=d,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return S=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return S=i,5;s=22064+(a<<5)|0,n[t>>2]=n[s>>2],n[t+4>>2]=n[s+4>>2],n[t+8>>2]=n[s+8>>2],n[t+12>>2]=n[s+12>>2],n[t+16>>2]=n[s+16>>2],n[t+20>>2]=n[s+20>>2],n[t+24>>2]=n[s+24>>2],n[t+28>>2]=n[s+28>>2];break}while(0);return function(A,e){e=+e;var t,r,n,i,a,s,l,c=0,u=0;c=(i=+o[(n=16+(A|=0)|0)>>3])-(r=+o[(t=A+24|0)>>3]),c=i>3],c=.5*(c*e-c),u+=e=.5*((l=u-(s=+o[(a=A+8|0)>>3]))*e-l),o[A>>3]=u>1.5707963267948966?1.5707963267948966:u,e=s-e,o[a>>3]=e<-1.5707963267948966?-1.5707963267948966:e,e=(e=i+c)>3.141592653589793?e+-6.283185307179586:e,o[n>>3]=e<-3.141592653589793?e+6.283185307179586:e,e=(e=r-c)>3.141592653589793?e+-6.283185307179586:e,o[t>>3]=e<-3.141592653589793?e+6.283185307179586:e}(t,r?1.4:1.1),(0|n[(r=26096+(l<<3)|0)>>2])==(0|A)&&(0|n[r+4>>2])==(0|e)&&(o[t>>3]=1.5707963267948966),(0|n[(l=26224+(l<<3)|0)>>2])==(0|A)&&(0|n[l+4>>2])==(0|e)&&(o[t+8>>3]=-1.5707963267948966),1.5707963267948966!=+o[t>>3]&&-1.5707963267948966!=+o[t+8>>3]?(S=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,S=i,0|(l=0))}function we(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0;if(i=S,S=S+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))S=i;else{if(0|r[0|(a=A+28|0)]?(s=0|xe(s,l),l=0|B()):r[0|a]=1,!(0|n[n[(o=A+20|0)>>2]>>2]))return 0|(s=0|n[(a=A+24|0)>>2])&&Ye(s),n[(y=A)>>2]=0,n[y+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[A+16>>2]=0,n[a>>2]=0,void(S=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))x=A+24|0;else{v=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,f=3==(2|c),d=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){w=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){w=19;break e}}if(g&&(c=0|n[4+(0|n[o>>2])>>2],n[e>>2]=n[c>>2],n[e+4>>2]=n[c+4>>2],n[e+8>>2]=n[c+8>>2],n[e+12>>2]=n[c+12>>2],0|X(26832,e))){if(0|KA(0|n[4+(0|n[o>>2])>>2],u,t)){w=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){w=29;break}}if(h){if(0|(c=0|$A(s,l,e))){w=32;break}if(0|ve(s,l,t,0)){w=36;break}if(f&&0|De(0|n[o>>2],0|n[p>>2],e,t)){w=42;break}if(g&&0|Qe(0|n[o>>2],0|n[p>>2],e,t)){w=42;break}}if(b){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){w=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){w=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],d)){w=53;break}if(0|Qe(0|n[o>>2],0|n[p>>2],t,e)){w=53;break}}}}do{if((0|u)<(0|n[v>>2])){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){w=58;break e}if(!(0|q(c,e))){w=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){w=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){w=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else w=73}while(0);if(73==(0|w)&&(w=0,s=0|xe(s,l),l=0|B()),!(0|s)&!(0|l)){x=p;break A}}switch(0|w){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,w=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,w=20;break;case 25:M(27795,27761,470,27772);break;case 29:case 42:return n[A>>2]=s,n[A+4>>2]=l,void(S=i);case 32:return 0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(S=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,w=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,w=55;break;case 58:0|c&&Ye(c),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,w=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,w=71;break;case 67:return 0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(S=i)}if(20==(0|w))return void(S=i);if(55==(0|w))return void(S=i);if(71==(0|w))return void(S=i)}}while(0);0|(a=0|n[x>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[y>>2]=0,n[x>>2]=0,S=i}}function xe(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;t=S,S=S+16|0,f=t,o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,r=0|tt(0|A,0|e,45),B();do{if(o){for(;r=0|rt(o+4095|0,0,52),i=B()|-15728641&e,r=r|A|(s=0|rt(7,0,0|(a=3*(15-o|0)|0))),i|=l=0|B(),c=0|tt(0|A,0|e,0|a),B(),o=o+-1|0,!((c&=7)>>>0<6);){if(!o){u=4;break}e=i,A=r}if(4==(0|u)){r=0|tt(0|r,0|i,45),B();break}return f=0|rt(((f=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,f|=A&~s,C(0|u),S=t,0|f}}while(0);return(r&=127)>>>0>120?(f=0,C(0|(u=0)),S=t,0|f):(IA(f,0,r+1|0,0),u=0|n[f+4>>2],f=0|n[f>>2],C(0|u),S=t,0|f)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),i=+o[t>>3],a=e&(a=+o[t+8>>3])<0?a+6.283185307179586:a,(0|(g=0|n[A>>2]))<=0)return 0;if(r=0|n[A+4>>2],e){e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(((u=(c=l<0?l+6.283185307179586:l)+(i-s)/(u-s)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}else{e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(d=l==d|a==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}return 0}function ke(A,e){e|=0;var t,r,i,a,s,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0;if(!(r=0|n[(A|=0)>>2]))return n[e>>2]=0,n[e+4>>2]=0,n[e+8>>2]=0,n[e+12>>2]=0,n[e+16>>2]=0,n[e+20>>2]=0,n[e+24>>2]=0,void(n[e+28>>2]=0);if(o[(i=e+8|0)>>3]=17976931348623157e292,o[(a=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(s=e+16|0)>>3]=-17976931348623157e292,!((0|r)<=0)){for(t=0|n[A+4>>2],b=17976931348623157e292,p=-17976931348623157e292,v=0,A=-1,d=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,w=0;c=+o[t+(w<<4)>>3],h=+o[t+(w<<4)+8>>3],f=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,d=c),h>3]=h,g=h),c>m?o[e>>3]=c:c=m,h>u&&(o[s>>3]=h,u=h),b=h>0&hp?h:p,v|=+l(+(h-f))>3.141592653589793,(0|(A=w+1|0))!=(0|r);)x=w,m=c,w=A,A=x;v&&(o[s>>3]=p,o[a>>3]=b)}}function Ce(A){return 0|((A|=0)>>>0<4?0:15)}function Be(A,e){e|=0;var t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(v=e+8|0)>>3]=17976931348623157e292,o[(w=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(x=e+16|0)>>3]=-17976931348623157e292,(0|p)>0){for(a=0|n[A+4>>2],m=17976931348623157e292,b=-17976931348623157e292,i=0,r=-1,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292,y=0;s=+o[a+(y<<4)>>3],g=+o[a+(y<<4)+8>>3],u=+o[a+(((0|(B=r+2|0))==(0|p)?0:B)<<4)+8>>3],s>3]=s,f=s),g>3]=g,d=g),s>h?o[e>>3]=s:s=h,g>c&&(o[x>>3]=g,c=g),m=g>0&gb?g:b,i|=+l(+(g-u))>3.141592653589793,(0|(r=y+1|0))!=(0|p);)B=y,h=s,y=r,r=B;i&&(o[x>>3]=b,o[w>>3]=m)}}else n[e>>2]=0,n[e+4>>2]=0,n[e+8>>2]=0,n[e+12>>2]=0,n[e+16>>2]=0,n[e+20>>2]=0,n[e+24>>2]=0,n[e+28>>2]=0;if(!((0|(r=0|n[(B=A+8|0)>>2]))<=0)){t=A+12|0,C=0;do{if(a=0|n[t>>2],i=C,w=e+((C=C+1|0)<<5)|0,x=0|n[a+(i<<3)>>2]){if(o[(y=e+(C<<5)+8|0)>>3]=17976931348623157e292,o[(A=e+(C<<5)+24|0)>>3]=17976931348623157e292,o[w>>3]=-17976931348623157e292,o[(k=e+(C<<5)+16|0)>>3]=-17976931348623157e292,(0|x)>0){for(p=0|n[a+(i<<3)+4>>2],m=17976931348623157e292,b=-17976931348623157e292,a=0,i=-1,v=0,f=17976931348623157e292,d=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(v<<4)>>3],h=+o[p+(v<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|x)?0:i)<<4)+8>>3],s>3]=s,f=s),h>3]=h,d=h),s>g?o[w>>3]=s:s=g,h>c&&(o[k>>3]=h,c=h),m=h>0&hb?h:b,a|=+l(+(h-u))>3.141592653589793,(0|(i=v+1|0))!=(0|x);)M=v,v=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[w>>2]=0,n[w+4>>2]=0,n[w+8>>2]=0,n[w+12>>2]=0,n[w+16>>2]=0,n[w+20>>2]=0,n[w+24>>2]=0,n[w+28>>2]=0,r=0|n[B>>2]}while((0|C)<(0|r))}}function Me(A,e,t){var r=0,o=0,i=0;if(!(0|ye(A|=0,e|=0,t|=0)))return 0;if((0|n[(o=A+8|0)>>2])<=0)return 1;for(r=A+12|0,A=0;;){if(i=A,A=A+1|0,0|ye((0|n[r>>2])+(i<<3)|0,e+(A<<5)|0,t)){A=0,r=6;break}if((0|A)>=(0|n[o>>2])){A=1,r=6;break}}return 6==(0|r)?0|A:0}function De(A,e,t,r){r|=0;var o,i,a=0,s=0,l=0,c=0,u=0;if(i=S,S=S+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return S=i,0;c=A+8|0;A:do{if((0|n[c>>2])>0){for(s=A+12|0,a=0;;){if(u=a,a=a+1|0,0|ye((0|n[s>>2])+(u<<3)|0,e+(a<<5)|0,l)){a=0;break}if((0|a)>=(0|n[c>>2]))break A}return S=i,0|a}}while(0);if(0|Ee(A,e,t,r))return S=i,0;n[o>>2]=n[t>>2],n[o+4>>2]=l,a=0|n[c>>2];A:do{if((0|a)>0)for(A=A+12|0,l=0,s=a;;){if(a=0|n[A>>2],(0|n[a+(l<<3)>>2])>0){if(0|ye(o,r,0|n[a+(l<<3)+4>>2])){a=0;break A}if(a=l+1|0,0|Ee((0|n[A>>2])+(l<<3)|0,e+(a<<5)|0,t,r)){a=0;break A}s=0|n[c>>2]}else a=l+1|0;if(!((0|a)<(0|s))){a=1;break}l=a}else a=1}while(0);return S=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,M=0;if(u=S,S=S+176|0,l=u+172|0,f=u+168|0,c=u,!(0|q(e|=0,r|=0)))return S=u,0;if(function(A,e,t,r){var i,a,s,l,c;e|=0,t|=0,r|=0,A=(a=+o[16+(A|=0)>>3])<(c=+o[A+24>>3]),i=(l=+o[e+16>>3])<(s=+o[e+24>>3]),e=c-l>2]=A?i|e?1:2:0,n[r>>2]=i?A?1:e?2:1:0}(e,r,l,f),st(0|c,0|t,168),(0|n[t>>2])>0){e=0;do{y=+ie(+o[(B=c+8+(e<<4)+8|0)>>3],0|n[f>>2]),o[B>>3]=y,e=e+1|0}while((0|e)<(0|n[t>>2]))}a=+o[r>>3],s=+o[r+8>>3],y=+ie(+o[r+16>>3],0|n[f>>2]),i=+ie(+o[r+24>>3],0|n[f>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(f=0|n[c>>2]))<=0)for(e=0;;)if((0|(e=e+1|0))>=(0|n[A>>2])){e=0;break A}for(t=0;;){if(e=0|n[r>>2],w=+o[e+(t<<4)>>3],x=+ie(+o[e+(t<<4)+8>>3],0|n[l>>2]),e=0|n[r>>2],B=(0|(t=t+1|0))%(0|n[A>>2])|0,d=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(w>=a)|!(d>=a)&&!(w<=s)|!(d<=s)&&!(x<=i)|!(g<=i)&&!(x>=y)|!(g>=y)){v=d-w,b=g-x,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|f)?0:e,d=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-d,h=+o[c+8+(M<<4)>>3],!(0==(p=v*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=x-d,C=w-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(v*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|f))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return S=u,0|e}function Qe(A,e,t,r){var o=0,i=0,a=0;if(0|Ee(A|=0,e|=0,t|=0,r|=0))return 1;if((0|n[(i=A+8|0)>>2])<=0)return 0;for(o=A+12|0,A=0;;){if(a=A,A=A+1|0,0|Ee((0|n[o>>2])+(a<<3)|0,e+(A<<5)|0,t,r)){A=1,o=6;break}if((0|A)>=(0|n[i>>2])){A=0,o=6;break}}return 6==(0|o)?0|A:0}function je(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,f,d=0;l=+o[(A|=0)>>3],s=+o[e>>3]-l,a=+o[A+8>>3],i=+o[e+8>>3]-a,u=+o[t>>3],d=((d=+o[r>>3]-u)*(a-(f=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-f))/(s*c-i*d),o[n>>3]=l+s*d,o[n+8>>3]=a+i*d}function Ne(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<1.1920928955078125e-7?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<1.1920928955078125e-7):0|(e=0)}function Se(A,e){var t,r,n;return e|=0,+((n=+o[(A|=0)>>3]-+o[e>>3])*n+(r=+o[A+8>>3]-+o[e+8>>3])*r+(t=+o[A+16>>3]-+o[e+16>>3])*t)}function Fe(A,e,t){t|=0;var r,o,i,a,s=0,l=0,c=0,u=0;if(a=S,S=S+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return S=a,0|s;r=0|TA(A,e),i=0|OA(A,e),function(A,e){A=7696+(28*(A|=0)|0)|0,n[(e|=0)>>2]=n[A>>2],n[e+4>>2]=n[A+4>>2],n[e+8>>2]=n[A+8>>2],n[e+12>>2]=n[A+12>>2]}(r,u),s=0|function(A,e){A|=0;var t=0,r=0;if((e|=0)>>>0>20)return-1;do{if((0|n[11120+(216*e|0)>>2])!=(0|A))if((0|n[11120+(216*e|0)+8>>2])!=(0|A))if((0|n[11120+(216*e|0)+16>>2])!=(0|A))if((0|n[11120+(216*e|0)+24>>2])!=(0|A))if((0|n[11120+(216*e|0)+32>>2])!=(0|A))if((0|n[11120+(216*e|0)+40>>2])!=(0|A))if((0|n[11120+(216*e|0)+48>>2])!=(0|A))if((0|n[11120+(216*e|0)+56>>2])!=(0|A))if((0|n[11120+(216*e|0)+64>>2])!=(0|A))if((0|n[11120+(216*e|0)+72>>2])!=(0|A))if((0|n[11120+(216*e|0)+80>>2])!=(0|A))if((0|n[11120+(216*e|0)+88>>2])!=(0|A))if((0|n[11120+(216*e|0)+96>>2])!=(0|A))if((0|n[11120+(216*e|0)+104>>2])!=(0|A))if((0|n[11120+(216*e|0)+112>>2])!=(0|A))if((0|n[11120+(216*e|0)+120>>2])!=(0|A))if((0|n[11120+(216*e|0)+128>>2])!=(0|A)){if((0|n[11120+(216*e|0)+136>>2])!=(0|A)){if((0|n[11120+(216*e|0)+144>>2])==(0|A)){A=0,t=2,r=0;break}if((0|n[11120+(216*e|0)+152>>2])==(0|A)){A=0,t=2,r=1;break}if((0|n[11120+(216*e|0)+160>>2])==(0|A)){A=0,t=2,r=2;break}if((0|n[11120+(216*e|0)+168>>2])==(0|A)){A=1,t=2,r=0;break}if((0|n[11120+(216*e|0)+176>>2])==(0|A)){A=1,t=2,r=1;break}if((0|n[11120+(216*e|0)+184>>2])==(0|A)){A=1,t=2,r=2;break}if((0|n[11120+(216*e|0)+192>>2])==(0|A)){A=2,t=2,r=0;break}if((0|n[11120+(216*e|0)+200>>2])==(0|A)){A=2,t=2,r=1;break}if((0|n[11120+(216*e|0)+208>>2])==(0|A)){A=2,t=2,r=2;break}return-1}A=2,t=1,r=2}else A=2,t=1,r=1;else A=2,t=1,r=0;else A=1,t=1,r=2;else A=1,t=1,r=1;else A=1,t=1,r=0;else A=0,t=1,r=2;else A=0,t=1,r=1;else A=0,t=1,r=0;else A=2,t=0,r=2;else A=2,t=0,r=1;else A=2,t=0,r=0;else A=1,t=0,r=2;else A=1,t=0,r=1;else A=1,t=0,r=0;else A=0,t=0,r=2;else A=0,t=0,r=1;else A=0,t=0,r=0}while(0);return 0|n[11120+(216*e|0)+(72*t|0)+(24*A|0)+(r<<3)+4>>2]}(r,0|n[o>>2]);do{if(0|z(r)){switch(0|r){case 4:l=0;break;case 14:l=1;break;case 24:l=2;break;case 38:l=3;break;case 49:l=4;break;case 58:l=5;break;case 63:l=6;break;case 72:l=7;break;case 83:l=8;break;case 97:l=9;break;case 107:l=10;break;case 117:l=11;break;default:M(27795,27797,75,27806)}if(c=0|n[26416+(24*l|0)+8>>2],e=0|n[26416+(24*l|0)+16>>2],(0|(A=0|n[o>>2]))!=(0|n[u>>2])&&(u=0|G(r))|(0|(A=0|n[o>>2]))==(0|e)&&(s=(s+1|0)%6|0),3==(0|i)&(0|A)==(0|e)){s=(s+5|0)%6|0;break}5==(0|i)&(0|A)==(0|c)&&(s=(s+1|0)%6|0)}}while(0);return n[t>>2]=s,S=a,0}function Pe(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(l=S,S=S+32|0,w=l+24|0,s=l+20|0,a=l+8|0,i=l+16|0,o=l,g=(g=!(0|HA(A|=0,e|=0)))?6:5,m=0|tt(0|A,0|e,52),B(),g>>>0<=t>>>0)return S=l,2;!(b=!(0|(m&=15)))&&!((p=0|rt(7,0,3*(15^m)|0))&A)&!((0|B())&e)?c=t:u=4;A:do{if(4==(0|u)){if((0|((c=!!(0|HA(A,e)))?4:5))<(0|t))return S=l,1;if(0|Fe(A,e,w))return S=l,1;if(u=(0|n[w>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return S=l,1;n[s>>2]=0,c=0|I(A,e,p,s,a);do{if(!c){if(h=0|n[(d=a)>>2],u=(f=(d=0|n[d+4>>2])>>>0>>0|(0|d)==(0|e)&h>>>0>>0)?h:A,f=f?d:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(d&(0|B())))c=t;else{if(d=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|d)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|d)&&M(27795,27797,248,27822),0|Fe(A,e,w)&&M(27795,27797,248,27822),c=(0|n[w>>2])+d|0,7==(0|(d=0|n[(c=g?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&M(27795,27797,248,27822),n[i>>2]=0,0|(c=0|I(A,e,d,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|f)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,f=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,f=h;break}do{if(!(0|Fe(g,h,w))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[w>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[w>>2])|0)%6|0;break}c=-1}while(0);u=g,f=h}else c=t}while(0);h=0|n[(d=a)>>2],d=0|n[d+4>>2]}if((0|u)==(0|h)&(0|f)==(0|d)){if(A=(g=!!(0|HA(h,d)))?0|_(h,d,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,d),(A+-1|0)>>>0<=5&&!(1==(0|A)&(v=!!(0|c))))do{if(!(0|Fe(h,d,w))){if(v){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[w>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[w>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|g&5==(0|c)?0:c}e=f,A=u;break A}}while(0);return S=l,0|c}}while(0);return v=0|rt(0|c,0,56),w=B()|-2130706433&e|536870912,n[r>>2]=v|A,n[r+4>>2]=w,S=l,0}function Te(A,e){A|=0;var t,r,o=0,i=0;return r=S,S=S+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|LA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Pe(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,S=r,0|o):(S=r,0|(o=0))}function Le(A,e,t){A|=0,t|=0;var r=0;(0|(e|=0))>0?(r=0|We(e,4),n[A>>2]=r,r||M(27835,27858,40,27872)):n[A>>2]=0,n[A+4>>2]=e,n[A+8>>2]=0,n[A+12>>2]=t}function Ie(A){var e,t,r,i=0,a=0,s=0,c=0;e=4+(A|=0)|0,t=A+12|0,r=A+8|0;A:for(;;){for(a=0|n[e>>2],i=0;;){if((0|i)>=(0|a))break A;if(s=0|n[A>>2],c=0|n[s+(i<<2)>>2])break;i=i+1|0}i=s+(~~(+l(+ +u(10,+ +(15-(0|n[t>>2])|0))*(+o[c>>3]+ +o[c+8>>3]))%+(0|a))>>>0<<2)|0,a=0|n[i>>2];e:do{if(0|a){if(s=c+32|0,(0|a)==(0|c))n[i>>2]=n[s>>2];else{if(!(i=0|n[(a=a+32|0)>>2]))break;for(;(0|i)!=(0|c);)if(!(i=0|n[(a=i+32|0)>>2]))break e;n[a>>2]=n[s>>2]}Ye(c),n[r>>2]=(0|n[r>>2])-1}}while(0)}Ye(0|n[A>>2])}function Re(A){var e,t=0,r=0;for(e=0|n[4+(A|=0)>>2],r=0;;){if((0|r)>=(0|e)){t=0,r=4;break}if(t=0|n[(0|n[A>>2])+(r<<2)>>2]){r=4;break}r=r+1|0}return 4==(0|r)?0|t:0}function _e(A,e){e|=0;var t=0,r=0,i=0,a=0;if(t=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,t=(0|n[A>>2])+(t<<2)|0,!(r=0|n[t>>2]))return 1;a=e+32|0;do{if((0|r)!=(0|e)){if(!(t=0|n[r+32>>2]))return 1;for(i=t;;){if((0|i)==(0|e)){i=8;break}if(!(t=0|n[i+32>>2])){t=1,i=10;break}r=i,i=t}if(8==(0|i)){n[r+32>>2]=n[a>>2];break}if(10==(0|i))return 0|t}else n[t>>2]=n[a>>2]}while(0);return Ye(e),n[(a=A+8|0)>>2]=(0|n[a>>2])-1,0}function He(A,e,t){A|=0,e|=0,t|=0;var r,i=0,a=0,s=0;(r=0|Ue(40))||M(27888,27858,98,27901),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[(a=r+16|0)>>2]=n[t>>2],n[a+4>>2]=n[t+4>>2],n[a+8>>2]=n[t+8>>2],n[a+12>>2]=n[t+12>>2],n[r+32>>2]=0,a=~~(+l(+ +u(10,+ +(15-(0|n[A+12>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,a=(0|n[A>>2])+(a<<2)|0,i=0|n[a>>2];do{if(i){for(;!(0|oe(i,e)&&0|oe(i+16|0,t));)if(a=0|n[i+32>>2],!(0|n[(i=0|a?a:i)+32>>2])){s=10;break}if(10==(0|s)){n[i+32>>2]=r;break}return Ye(r),0|i}n[a>>2]=r}while(0);return n[(s=A+8|0)>>2]=1+(0|n[s>>2]),0|r}function ze(A,e,t){e|=0,t|=0;var r=0,i=0;if(i=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,!(i=0|n[(0|n[A>>2])+(i<<2)>>2]))return 0;if(!t){for(A=i;;){if(0|oe(A,e)){r=10;break}if(!(A=0|n[A+32>>2])){A=0,r=10;break}}if(10==(0|r))return 0|A}for(A=i;;){if(0|oe(A,e)&&0|oe(A+16|0,t)){r=10;break}if(!(A=0|n[A+32>>2])){A=0,r=10;break}}return 10==(0|r)?0|A:0}function Ge(A,e){e|=0;var t=0;if(t=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,!(A=0|n[(0|n[A>>2])+(t<<2)>>2]))return 0;for(;;){if(0|oe(A,e)){e=5;break}if(!(A=0|n[A+32>>2])){A=0,e=5;break}}return 5==(0|e)?0|A:0}function Oe(A){return 0|+ct(+(A=+A))}function Ue(A){A|=0;var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0;e=S,S=S+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(d=0|n[6981])>>>A))return o=0|n[(r=8+(A=27964+((t=(1&r^1)+A|0)<<1<<2)|0)|0)>>2],(0|(a=0|n[(i=o+8|0)>>2]))==(0|A)?n[6981]=d&~(1<>2]=A,n[r>>2]=a),y=t<<3,n[o+4>>2]=3|y,n[(y=o+y+4|0)>>2]=1|n[y>>2],S=e,0|i;if(u>>>0>(f=0|n[6983])>>>0){if(0|r)return t=((t=r<>>=l=t>>>12&16)>>>5&8)|l|(a=(t>>>=r)>>>2&4)|(A=(t>>>=a)>>>1&2)|(o=(t>>>=A)>>>1&1))+(t>>>o)|0)<<1<<2)|0)|0)>>2],(0|(r=0|n[(l=a+8|0)>>2]))==(0|t)?(A=d&~(1<>2]=t,n[A>>2]=r,A=d),s=(y=o<<3)-u|0,n[a+4>>2]=3|u,n[4+(i=a+u|0)>>2]=1|s,n[a+y>>2]=s,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,A&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=s,n[6986]=i,S=e,0|l;if(a=0|n[6982]){for(r=(a&0-a)-1|0,r=c=0|n[28228+(((o=(r>>>=i=r>>>12&16)>>>5&8)|i|(s=(r>>>=o)>>>2&4)|(l=(r>>>=s)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&n[c+4>>2])-u|0;(A=0|n[r+16>>2])||(A=0|n[r+20>>2]);)r=A,l=(i=(s=(-8&n[A+4>>2])-u|0)>>>0>>0)?A:l,c=i?s:c;if((s=l+u|0)>>>0>l>>>0){i=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){r=0;break}for(;;)if(r=0|n[(o=t+20|0)>>2])t=r,A=o;else{if(!(r=0|n[(o=t+16|0)>>2]))break;t=r,A=o}n[A>>2]=0,r=t}else r=0|n[l+8>>2],n[r+12>>2]=t,n[t+8>>2]=r,r=t}while(0);do{if(0|i){if(t=0|n[l+28>>2],(0|l)==(0|n[(A=28228+(t<<2)|0)>>2])){if(n[A>>2]=r,!r){n[6982]=a&~(1<>2])==(0|l)?y:i+20)>>2]=r,!r)break;n[r+24>>2]=i,0|(t=0|n[l+16>>2])&&(n[r+16>>2]=t,n[t+24>>2]=r),0|(t=0|n[l+20>>2])&&(n[r+20>>2]=t,n[t+24>>2]=r)}}while(0);return c>>>0<16?(y=c+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2]):(n[l+4>>2]=3|u,n[s+4>>2]=1|c,n[s+c>>2]=c,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|d,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=c,n[6986]=s),S=e,0|l+8}d=u}else d=u}else d=u}else if(A>>>0<=4294967231)if(u=-8&(A=A+11|0),o=0|n[6982]){i=0-u|0,c=(A>>>=8)?u>>>0>16777215?31:u>>>(7+(c=14-((l=(520192+(b=A<<(d=(A+1048320|0)>>>16&8))|0)>>>16&4)|d|(c=(245760+(b<<=l)|0)>>>16&2))+(b<>>15)|0)|0)&1|c<<1:0,r=0|n[28228+(c<<2)>>2];A:do{if(r)for(A=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((s=(-8&n[r+4>>2])-u|0)>>>0>>0){if(!s){A=r,i=0,b=65;break A}A=r,i=s}if(a=!(0|(b=0|n[r+20>>2]))|(0|b)==(0|(r=0|n[r+16+(l>>>31<<2)>>2]))?a:b,!r){r=a,b=61;break}l<<=1}else r=0,A=0,b=61}while(0);if(61==(0|b)){if(!(0|r)&!(0|A)){if(!(A=((A=2<>>=s=d>>>12&16)>>>5&8)|s|(l=(d>>>=a)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(d=(-8&n[a+4>>2])-u|0)>>>0>>0)?d:i,A=r?a:A,(r=0|n[a+16>>2])||(r=0|n[a+20>>2]),!r){l=A,s=i;break}a=r}if(0|l&&s>>>0<((0|n[6983])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){a=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){t=0;break}for(;;)if(r=0|n[(i=t+20|0)>>2])t=r,A=i;else{if(!(r=0|n[(i=t+16|0)>>2]))break;t=r,A=i}n[A>>2]=0}else y=0|n[l+8>>2],n[y+12>>2]=t,n[t+8>>2]=y}while(0);do{if(a){if(A=0|n[l+28>>2],(0|l)==(0|n[(r=28228+(A<<2)|0)>>2])){if(n[r>>2]=t,!t){o&=~(1<>2])==(0|l)?y:a+20)>>2]=t,!t)break;n[t+24>>2]=a,0|(A=0|n[l+16>>2])&&(n[t+16>>2]=A,n[A+24>>2]=t),(A=0|n[l+20>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);A:do{if(s>>>0<16)y=s+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2];else{if(n[l+4>>2]=3|u,n[f+4>>2]=1|s,n[f+s>>2]=s,t=s>>>3,s>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=f,n[t+12>>2]=f,n[f+8>>2]=t,n[f+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(r=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[f+28>>2]=r,n[4+(A=f+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break}t=0|n[t>>2];e:do{if((-8&n[t+4>>2])!=(0|s)){for(o=s<<(31==(0|r)?0:25-(r>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|s)){t=A;break e}o<<=1,t=A}n[r>>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break A}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=f,n[x>>2]=f,n[f+8>>2]=y,n[f+12>>2]=t,n[f+24>>2]=0}}while(0);return S=e,0|l+8}d=u}else d=u;else d=-1}while(0);if((r=0|n[6983])>>>0>=d>>>0)return t=r-d|0,A=0|n[6986],t>>>0>15?(y=A+d|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|d):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),S=e,0|A+8;if((s=0|n[6984])>>>0>d>>>0)return w=s-d|0,n[6984]=w,x=(y=0|n[6987])+d|0,n[6987]=x,n[x+4>>2]=1|w,n[y+4>>2]=3|d,S=e,0|y+8;if(0|n[7099]?A=0|n[7101]:(n[7101]=4096,n[7100]=4096,n[7102]=-1,n[7103]=-1,n[7104]=0,n[7092]=0,n[7099]=-16&g^1431655768,A=4096),l=d+48|0,(u=(a=A+(c=d+47|0)|0)&(i=0-A|0))>>>0<=d>>>0)return S=e,0;if(0|(A=0|n[7091])&&(g=(f=0|n[7089])+u|0)>>>0<=f>>>0|g>>>0>A>>>0)return S=e,0;A:do{if(4&n[7092])t=0,b=143;else{r=0|n[6987];e:do{if(r){for(o=28372;!((g=0|n[o>>2])>>>0<=r>>>0&&(g+(0|n[o+4>>2])|0)>>>0>r>>>0);){if(!(A=0|n[o+8>>2])){b=128;break e}o=A}if((t=a-s&i)>>>0<2147483647)if((0|(A=0|ut(0|t)))==((0|n[o>>2])+(0|n[o+4>>2])|0)){if(-1!=(0|A)){s=t,a=A,b=145;break A}}else o=A,b=136;else t=0}else b=128}while(0);do{if(128==(0|b))if(-1!=(0|(r=0|ut(0)))&&(t=r,m=(t=((m=(h=0|n[7100])-1|0)&t?(m+t&0-h)-t|0:0)+u|0)+(h=0|n[7089])|0,t>>>0>d>>>0&t>>>0<2147483647)){if(0|(g=0|n[7091])&&m>>>0<=h>>>0|m>>>0>g>>>0){t=0;break}if((0|(A=0|ut(0|t)))==(0|r)){s=t,a=r,b=145;break A}o=A,b=136}else t=0}while(0);do{if(136==(0|b)){if(r=0-t|0,!(l>>>0>t>>>0&t>>>0<2147483647&-1!=(0|o))){if(-1==(0|o)){t=0;break}s=t,a=o,b=145;break A}if((A=c-t+(A=0|n[7101])&0-A)>>>0>=2147483647){s=t,a=o,b=145;break A}if(-1==(0|ut(0|A))){ut(0|r),t=0;break}s=A+t|0,a=o,b=145;break A}}while(0);n[7092]=4|n[7092],b=143}}while(0);if(143==(0|b)&&u>>>0<2147483647&&!(-1==(0|(w=0|ut(0|u)))|1^(v=(p=(m=0|ut(0))-w|0)>>>0>(d+40|0)>>>0)|w>>>0>>0&-1!=(0|w)&-1!=(0|m)^1)&&(s=v?p:t,a=w,b=145),145==(0|b)){t=(0|n[7089])+s|0,n[7089]=t,t>>>0>(0|n[7090])>>>0&&(n[7090]=t),c=0|n[6987];A:do{if(c){for(t=28372;;){if((0|a)==((A=0|n[t>>2])+(r=0|n[t+4>>2])|0)){b=154;break}if(!(o=0|n[t+8>>2]))break;t=o}if(!(154!=(0|b)||(x=t+4|0,8&n[t+12>>2]))&&a>>>0>c>>>0&A>>>0<=c>>>0){n[x>>2]=r+s,x=c+(w=7&(w=c+8|0)?0-w&7:0)|0,w=(y=(0|n[6984])+s|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[c+y+4>>2]=40,n[6988]=n[7103];break}for(a>>>0<(0|n[6985])>>>0&&(n[6985]=a),r=a+s|0,t=28372;;){if((0|n[t>>2])==(0|r)){b=162;break}if(!(A=0|n[t+8>>2]))break;t=A}if(162==(0|b)&&!(8&n[t+12>>2])){n[t>>2]=a,n[(f=t+4|0)>>2]=(0|n[f>>2])+s,u=(f=a+(7&(f=a+8|0)?0-f&7:0)|0)+d|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-f-d|0,n[f+4>>2]=3|d;e:do{if((0|c)==(0|t))y=(0|n[6984])+l|0,n[6984]=y,n[6987]=u,n[u+4>>2]=1|y;else{if((0|n[6986])==(0|t)){y=(0|n[6983])+l|0,n[6983]=y,n[6986]=u,n[u+4>>2]=1|y,n[u+y>>2]=y;break}if(1==(3&(A=0|n[t+4>>2]))){s=-8&A,o=A>>>3;t:do{if(A>>>0<256){if(A=0|n[t+8>>2],(0|(r=0|n[t+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=r,n[r+8>>2]=A;break}a=0|n[t+24>>2],A=0|n[t+12>>2];do{if((0|A)==(0|t)){if(A=0|n[(o=4+(r=t+16|0)|0)>>2])r=o;else if(!(A=0|n[r>>2])){A=0;break}for(;;)if(o=0|n[(i=A+20|0)>>2])A=o,r=i;else{if(!(o=0|n[(i=A+16|0)>>2]))break;A=o,r=i}n[r>>2]=0}else y=0|n[t+8>>2],n[y+12>>2]=A,n[A+8>>2]=y}while(0);if(!a)break;o=28228+((r=0|n[t+28>>2])<<2)|0;do{if((0|n[o>>2])==(0|t)){if(n[o>>2]=A,0|A)break;n[6982]=n[6982]&~(1<>2])==(0|t)?y:a+20)>>2]=A,!A)break t}while(0);if(n[A+24>>2]=a,0|(o=0|n[(r=t+16|0)>>2])&&(n[A+16>>2]=o,n[o+24>>2]=A),!(r=0|n[r+4>>2]))break;n[A+20>>2]=r,n[r+24>>2]=A}while(0);t=t+s|0,i=s+l|0}else i=l;if(n[(t=t+4|0)>>2]=-2&n[t>>2],n[u+4>>2]=1|i,n[u+i>>2]=i,t=i>>>3,i>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=u,n[t+12>>2]=u,n[u+8>>2]=t,n[u+12>>2]=r;break}t=i>>>8;do{if(t){if(i>>>0>16777215){o=31;break}o=i>>>(7+(o=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(o=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|o<<1}else o=0}while(0);if(t=28228+(o<<2)|0,n[u+28>>2]=o,n[4+(A=u+16|0)>>2]=0,n[A>>2]=0,!((A=0|n[6982])&(r=1<>2]=u,n[u+24>>2]=t,n[u+12>>2]=u,n[u+8>>2]=u;break}t=0|n[t>>2];t:do{if((-8&n[t+4>>2])!=(0|i)){for(o=i<<(31==(0|o)?0:25-(o>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|i)){t=A;break t}o<<=1,t=A}n[r>>2]=u,n[u+24>>2]=t,n[u+12>>2]=u,n[u+8>>2]=u;break e}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=u,n[x>>2]=u,n[u+8>>2]=y,n[u+12>>2]=t,n[u+24>>2]=0}}while(0);return S=e,0|f+8}for(t=28372;!((A=0|n[t>>2])>>>0<=c>>>0&&(y=A+(0|n[t+4>>2])|0)>>>0>c>>>0);)t=0|n[t+8>>2];t=(A=(A=(i=y+-47|0)+(7&(A=i+8|0)?0-A&7:0)|0)>>>0<(i=c+16|0)>>>0?c:A)+8|0,x=a+(w=7&(w=a+8|0)?0-w&7:0)|0,w=(r=s+-40|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[a+r+4>>2]=40,n[6988]=n[7103],n[(r=A+4|0)>>2]=27,n[t>>2]=n[7093],n[t+4>>2]=n[7094],n[t+8>>2]=n[7095],n[t+12>>2]=n[7096],n[7093]=a,n[7094]=s,n[7096]=0,n[7095]=t,t=A+24|0;do{x=t,n[(t=t+4|0)>>2]=7}while((x+8|0)>>>0>>0);if((0|A)!=(0|c)){if(a=A-c|0,n[r>>2]=-2&n[r>>2],n[c+4>>2]=1|a,n[A>>2]=a,t=a>>>3,a>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=c,n[t+12>>2]=c,n[c+8>>2]=t,n[c+12>>2]=r;break}if(r=28228+((o=(t=a>>>8)?a>>>0>16777215?31:a>>>(7+(o=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(o=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|o<<1:0)<<2)|0,n[c+28>>2]=o,n[c+20>>2]=0,n[i>>2]=0,!((t=0|n[6982])&(A=1<>2]=c,n[c+24>>2]=r,n[c+12>>2]=c,n[c+8>>2]=c;break}t=0|n[r>>2];e:do{if((-8&n[t+4>>2])!=(0|a)){for(o=a<<(31==(0|o)?0:25-(o>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|a)){t=A;break e}o<<=1,t=A}n[r>>2]=c,n[c+24>>2]=t,n[c+12>>2]=c,n[c+8>>2]=c;break A}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=c,n[x>>2]=c,n[c+8>>2]=y,n[c+12>>2]=t,n[c+24>>2]=0}}else!(0|(y=0|n[6985]))|a>>>0>>0&&(n[6985]=a),n[7093]=a,n[7094]=s,n[7096]=0,n[6990]=n[7099],n[6989]=-1,n[6994]=27964,n[6993]=27964,n[6996]=27972,n[6995]=27972,n[6998]=27980,n[6997]=27980,n[7e3]=27988,n[6999]=27988,n[7002]=27996,n[7001]=27996,n[7004]=28004,n[7003]=28004,n[7006]=28012,n[7005]=28012,n[7008]=28020,n[7007]=28020,n[7010]=28028,n[7009]=28028,n[7012]=28036,n[7011]=28036,n[7014]=28044,n[7013]=28044,n[7016]=28052,n[7015]=28052,n[7018]=28060,n[7017]=28060,n[7020]=28068,n[7019]=28068,n[7022]=28076,n[7021]=28076,n[7024]=28084,n[7023]=28084,n[7026]=28092,n[7025]=28092,n[7028]=28100,n[7027]=28100,n[7030]=28108,n[7029]=28108,n[7032]=28116,n[7031]=28116,n[7034]=28124,n[7033]=28124,n[7036]=28132,n[7035]=28132,n[7038]=28140,n[7037]=28140,n[7040]=28148,n[7039]=28148,n[7042]=28156,n[7041]=28156,n[7044]=28164,n[7043]=28164,n[7046]=28172,n[7045]=28172,n[7048]=28180,n[7047]=28180,n[7050]=28188,n[7049]=28188,n[7052]=28196,n[7051]=28196,n[7054]=28204,n[7053]=28204,n[7056]=28212,n[7055]=28212,x=a+(w=7&(w=a+8|0)?0-w&7:0)|0,w=(y=s+-40|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>d>>>0)return w=t-d|0,n[6984]=w,x=(y=0|n[6987])+d|0,n[6987]=x,n[x+4>>2]=1|w,n[y+4>>2]=3|d,S=e,0|y+8}return n[(y=27920)>>2]=12,S=e,0}function Ye(A){var e=0,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(A|=0){t=A+-8|0,o=0|n[6985],l=t+(e=-8&(A=0|n[A+-4>>2]))|0;do{if(1&A)s=t,a=t;else{if(r=0|n[t>>2],!(3&A))return;if(i=r+e|0,(a=t+(0-r)|0)>>>0>>0)return;if((0|n[6986])==(0|a)){if(3&~(e=0|n[(A=l+4|0)>>2])){s=a,e=i;break}return n[6983]=i,n[A>>2]=-2&e,n[a+4>>2]=1|i,void(n[a+i>>2]=i)}if(t=r>>>3,r>>>0<256){if(A=0|n[a+8>>2],(0|(e=0|n[a+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=e,n[e+8>>2]=A,s=a,e=i;break}o=0|n[a+24>>2],A=0|n[a+12>>2];do{if((0|A)==(0|a)){if(A=0|n[(t=4+(e=a+16|0)|0)>>2])e=t;else if(!(A=0|n[e>>2])){A=0;break}for(;;)if(t=0|n[(r=A+20|0)>>2])A=t,e=r;else{if(!(t=0|n[(r=A+16|0)>>2]))break;A=t,e=r}n[e>>2]=0}else s=0|n[a+8>>2],n[s+12>>2]=A,n[A+8>>2]=s}while(0);if(o){if(e=0|n[a+28>>2],(0|n[(t=28228+(e<<2)|0)>>2])==(0|a)){if(n[t>>2]=A,!A){n[6982]=n[6982]&~(1<>2])==(0|a)?s:o+20)>>2]=A,!A){s=a,e=i;break}n[A+24>>2]=o,0|(t=0|n[(e=a+16|0)>>2])&&(n[A+16>>2]=t,n[t+24>>2]=A),(e=0|n[e+4>>2])?(n[A+20>>2]=e,n[e+24>>2]=A,s=a,e=i):(s=a,e=i)}else s=a,e=i}}while(0);if(!(a>>>0>=l>>>0)&&1&(r=0|n[(A=l+4|0)>>2])){if(2&r)n[A>>2]=-2&r,n[s+4>>2]=1|e,n[a+e>>2]=e,o=e;else{if((0|n[6987])==(0|l)){if(l=(0|n[6984])+e|0,n[6984]=l,n[6987]=s,n[s+4>>2]=1|l,(0|s)!=(0|n[6986]))return;return n[6986]=0,void(n[6983]=0)}if((0|n[6986])==(0|l))return l=(0|n[6983])+e|0,n[6983]=l,n[6986]=a,n[s+4>>2]=1|l,void(n[a+l>>2]=l);o=(-8&r)+e|0,t=r>>>3;do{if(r>>>0<256){if(e=0|n[l+8>>2],(0|(A=0|n[l+12>>2]))==(0|e)){n[6981]=n[6981]&~(1<>2]=A,n[A+8>>2]=e;break}i=0|n[l+24>>2],A=0|n[l+12>>2];do{if((0|A)==(0|l)){if(A=0|n[(t=4+(e=l+16|0)|0)>>2])e=t;else if(!(A=0|n[e>>2])){t=0;break}for(;;)if(t=0|n[(r=A+20|0)>>2])A=t,e=r;else{if(!(t=0|n[(r=A+16|0)>>2]))break;A=t,e=r}n[e>>2]=0,t=A}else t=0|n[l+8>>2],n[t+12>>2]=A,n[A+8>>2]=t,t=A}while(0);if(0|i){if(A=0|n[l+28>>2],(0|n[(e=28228+(A<<2)|0)>>2])==(0|l)){if(n[e>>2]=t,!t){n[6982]=n[6982]&~(1<>2])==(0|l)?r:i+20)>>2]=t,!t)break;n[t+24>>2]=i,0|(e=0|n[(A=l+16|0)>>2])&&(n[t+16>>2]=e,n[e+24>>2]=t),0|(A=0|n[A+4>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);if(n[s+4>>2]=1|o,n[a+o>>2]=o,(0|s)==(0|n[6986]))return void(n[6983]=o)}if(A=o>>>3,o>>>0<256)return t=27964+(A<<1<<2)|0,(e=0|n[6981])&(A=1<>2]:(n[6981]=e|A,A=t,e=t+8|0),n[e>>2]=s,n[A+12>>2]=s,n[s+8>>2]=A,void(n[s+12>>2]=t);A=28228+((r=(A=o>>>8)?o>>>0>16777215?31:o>>>(7+(r=14-((i=(520192+(l=A<<(a=(A+1048320|0)>>>16&8))|0)>>>16&4)|a|(r=(245760+(l<<=i)|0)>>>16&2))+(l<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[s+28>>2]=r,n[s+20>>2]=0,n[s+16>>2]=0,e=0|n[6982],t=1<>2];e:do{if((-8&n[A+4>>2])!=(0|o)){for(r=o<<(31==(0|r)?0:25-(r>>>1)|0);e=0|n[(t=A+16+(r>>>31<<2)|0)>>2];){if((-8&n[e+4>>2])==(0|o)){A=e;break e}r<<=1,A=e}n[t>>2]=s,n[s+24>>2]=A,n[s+12>>2]=s,n[s+8>>2]=s;break A}}while(0);l=0|n[(a=A+8|0)>>2],n[l+12>>2]=s,n[a>>2]=s,n[s+8>>2]=l,n[s+12>>2]=A,n[s+24>>2]=0}else n[6982]=e|t,n[A>>2]=s,n[s+24>>2]=A,n[s+12>>2]=s,n[s+8>>2]=s}while(0);if(l=(0|n[6989])-1|0,n[6989]=l,!(0|l)){for(A=28380;A=0|n[A>>2];)A=A+8|0;n[6989]=-1}}}}function We(A,e){e|=0;var t=0;return(A|=0)?(t=0|w(e,A),(e|A)>>>0>65535&&(t=((t>>>0)/(A>>>0)|0)==(0|e)?t:-1)):t=0,(A=0|Ue(t))&&3&n[A+-4>>2]?(lt(0|A,0,0|t),0|A):0|A}function Ve(A,e,t,r){return 0|(C((e|=0)+(r|=0)+((t=(A|=0)+(t|=0)>>>0)>>>0>>0|0)>>>0|0),t)}function Ze(A,e,t,r){return 0|(C(0|(r=(e|=0)-(r|=0)-((t|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-t>>>0)}function Ke(A){return 0|((A|=0)?31-(0|k(A^A-1)):32)}function Je(A,e,t,r,o){o|=0;var i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(u=A|=0,a=t|=0,s=d=r|=0,!(c=l=e|=0))return i=!!(0|o),s?i?(n[o>>2]=0|A,n[o+4>>2]=0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(d=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=f=i+1|0,A=u>>>(f>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(f>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(f=32-s|0)-1>>31&c>>>((g=s-32|0)>>>0)|(c<>>(s>>>0))&(e=g>>31),e&=c>>>(s>>>0),i=u<<(h=64-s|0)&(l=f>>31),s=(c<>>(g>>>0))&l|u<>31;break}return 0|o&&(n[o>>2]=i&u,n[o+4>>2]=0),1==(0|a)?(h=0|A,0|(C(0|(g=l|0&e)),h)):(g=c>>>((h=0|Ke(0|a))>>>0)|0,h=c<<32-h|u>>>(h>>>0),0|(C(0|g),h))}if(i)return 0|o&&(n[o>>2]=(c>>>0)%(a>>>0),n[o+4>>2]=0),h=(c>>>0)/(a>>>0)>>>0,0|(C(0|(g=0)),h);if(!u)return 0|o&&(n[o>>2]=0,n[o+4>>2]=(c>>>0)%(s>>>0)),h=(c>>>0)/(s>>>0)>>>0,0|(C(0|(g=0)),h);if(!((i=s-1|0)&s))return 0|o&&(n[o>>2]=0|A,n[o+4>>2]=i&c|0&e),g=0,h=c>>>((0|Ke(0|s))>>>0),0|(C(0|g),h);if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=30){a=e=i+1|0,A=c<<(s=31-i|0)|u>>>(e>>>0),e=c>>>(e>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,h=0,0|(C(0|(g=0)),h)):(h=0,0|(C(0|(g=0)),h))}while(0);if(a){c=0|Ve(0|(f=0|t),0|(u=d|0&r),-1,-1),t=0|B(),l=s,s=0;do{r=l,l=i>>>31|l<<1,i=s|i<<1,Ze(0|c,0|t,0|(r=A<<1|r>>>31),0|(d=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|d,g&f|0,(((0|h)<0?-1:0)>>31|((0|h)<0?-1:0)<<1)&u),e=0|B(),a=a-1|0}while(0|a);c=l,l=0}else c=s,l=0,s=0;return a=0,0|o&&(n[o>>2]=A,n[o+4>>2]=e),h=i<<1&-2|s,0|(C(0|(g=(0|i)>>>31|(c|a)<<1|l)),h)}function Xe(A,e,t,r){var n,o,i,a,s;return t|=0,o=(r|=0)>>31|((0|r)<0?-1:0)<<1,n=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,i=0|Ze((s=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(a=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|s,0|a),A=o^s,e=n^a,0|Ze((0|Je(i,0|B(),0|Ze(o^t|0,n^r|0,0|o,0|n),0|B(),0))^A,(0|B())^e,0|A,0|e)}function qe(A,e,t,r){var n,o;return e|=0,r|=0,t=0|function(A,e){var t,r,n,o=0;return A=((t=0|w(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|w(o,r=A>>>16))|0,e=0|w(o=e>>>16,n),0|(C((A>>>16)+(0|w(o,r))+(((65535&A)+e|0)>>>16)|0),A+e<<16|65535&t)}(n=A|=0,o=t|=0),A=0|B(),0|(C((0|w(e,o))+(0|w(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=S,S=S+16|0,s=0|o,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,l=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,Je(A=0|Ze((a=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(i=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|a,0|i),e=0|B(),0|Ze(c^t|0,l^r|0,0|c,0|l),0|B(),s),r=0|Ze(n[s>>2]^a|0,n[s+4>>2]^i|0,0|a,0|i),t=0|B(),S=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=S,S=S+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),S=i,0|(C(0|n[o+4>>2]),n[o>>2])}function et(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>t|0),A>>>t|(e&(1<>t-32)}function tt(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>>t|0),A>>>t|(e&(1<>>t-32|0)}function rt(A,e,t){return A|=0,(0|(t|=0))<32?(C((e|=0)<>>32-t),A<=0?+s(A+.5):+v(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return Q(0|A,0|e,0|t),0|A;if(i=0|A,o=A+t|0,(3&A)==(3&e)){for(;3&A;){if(!t)return 0|i;r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0,t=t-1|0}for(a=(t=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],n[A+12>>2]=n[e+12>>2],n[A+16>>2]=n[e+16>>2],n[A+20>>2]=n[e+20>>2],n[A+24>>2]=n[e+24>>2],n[A+28>>2]=n[e+28>>2],n[A+32>>2]=n[e+32>>2],n[A+36>>2]=n[e+36>>2],n[A+40>>2]=n[e+40>>2],n[A+44>>2]=n[e+44>>2],n[A+48>>2]=n[e+48>>2],n[A+52>>2]=n[e+52>>2],n[A+56>>2]=n[e+56>>2],n[A+60>>2]=n[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|t);)n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}else for(t=o-4|0;(0|A)<(0|t);)r[0|A]=0|r[0|e],r[A+1|0]=0|r[e+1|0],r[A+2|0]=0|r[e+2|0],r[A+3|0]=0|r[e+3|0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|o);)r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0;return 0|i}function lt(A,e,t){e|=0;var o,i=0,a=0,s=0;if(o=(A|=0)+(t|=0)|0,e&=255,(0|t)>=67){for(;3&A;)r[0|A]=e,A=A+1|0;for(s=e|e<<8|e<<16|e<<24,a=(i=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=s,n[A+4>>2]=s,n[A+8>>2]=s,n[A+12>>2]=s,n[A+16>>2]=s,n[A+20>>2]=s,n[A+24>>2]=s,n[A+28>>2]=s,n[A+32>>2]=s,n[A+36>>2]=s,n[A+40>>2]=s,n[A+44>>2]=s,n[A+48>>2]=s,n[A+52>>2]=s,n[A+56>>2]=s,n[A+60>>2]=s,A=A+64|0;for(;(0|A)<(0|i);)n[A>>2]=s,A=A+4|0}for(;(0|A)<(0|o);)r[0|A]=e,A=A+1|0;return o-t|0}function ct(A){return(A=+A)>=0?+s(A+.5):+v(A-.5)}function ut(A){var e,t,r;return A|=0,r=0|E(),(0|A)>0&(0|(e=(t=0|n[a>>2])+A|0))<(0|t)|(0|e)<0?(N(0|e),D(12),-1):(0|e)>(0|r)&&!(0|j(0|e))?(D(12),-1):(n[a>>2]=e,0|t)}return{___divdi3:Xe,___muldi3:qe,___remdi3:$e,___uremdi3:At,_areNeighborCells:function(A,e,t,r,o){o|=0;var i,a,s,l=0,c=0,u=0,f=0;if(s=S,S=S+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return S=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,S=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,f=0|tt(0|t,0|r,52),B(),(0|c)!=(15&f))return S=s,12;if(l=c+-1|0,c>>>0>1){RA(A,e,l,a),RA(t,r,l,i),u=0|n[(f=a)>>2],f=0|n[f+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|f)==(0|n[i+4>>2])){l=0|tt(0|A,0|e,0|(c=3*(15^c)|0)),B(),l&=7,c=0|tt(0|t,0|r,0|c),B(),c&=7;do{if(!(0|l)|!(0|c))n[o>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|HA(u,f)){l=5;break}if((0|n[15536+(l<<2)>>2])!=(0|c)&&(0|n[15568+(l<<2)>>2])!=(0|c))break A;n[o>>2]=1,l=0}}while(0);return S=s,0|l}}while(0)}c=(l=a)+56|0;do{n[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return F(A,e,1,a),l=(0|n[(e=a)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+8|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+16|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+24|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+32|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+40|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)?1:1&((0|n[(l=a+48|0)>>2])==(0|t)?(0|n[l+4>>2])==(0|r):0),n[o>>2]=l,S=s,0},_bitshift64Ashr:et,_bitshift64Lshr:tt,_bitshift64Shl:rt,_calloc:We,_cellAreaKm2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475),0|A},_cellAreaM2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475*1e3*1e3),0|A},_cellAreaRads2:ue,_cellToBoundary:$A,_cellToCenterChild:GA,_cellToChildPos:function(A,e,t,r){t|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0;if(o=S,S=S+16|0,p=o,v=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return S=o,4;if((0|(v&=15))<(0|t))return S=o,12;if((0|v)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|v)>(0|t)){c=t;do{b=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,a|=b,l=0|B()|l}while((0|c)<(0|v));b=a}else b=a;else b=A,l=e;m=0|tt(0|b,0|l,45),B();A:do{if(0|z(127&m)){if(c=0|tt(0|b,0|l,52),B(),0|(c&=15))for(a=1;;){if(!(!((m=0|rt(7,0,3*(15-a|0)|0))&b)&!((0|B())&l))){u=33;break A}if(!(a>>>0>>0))break;a=a+1|0}if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(m=-15728641&e,h=v;;){if(g=h,(h=h+-1|0)>>>0>15|(0|v)<(0|h)){u=19;break}if((0|v)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|v)<(0|g))d=a;else{u=h;do{d=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,c=0|B()|c}while((0|u)<(0|v));d=a}else d=A,c=e;if(f=0|tt(0|d,0|c,45),B(),0|z(127&f)){f=0|tt(0|d,0|c,52),B(),f&=15;e:do{if(f)for(u=1;;){if(a=0|tt(0|d,0|c,3*(15-u|0)|0),B(),0|(a&=7))break e;if(!(u>>>0>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|tt(0|A,0|e,3*(15-g|0)|0),B(),7==(0|(c&=7))){i=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){i=5,u=42;break}if(0|(d=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=v-g|0,((0|u)<0)<<31>>31),f=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|f,5,0)),0|B(),-5,-1),a=0|Ve(0|(a=0|Xe(0|a,0|B(),6,0)),0|B(),1,0),c=0|B()):(a=u,c=f),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|f,0|(g=d+-1|0),((0|g)<0)<<31>>31)),0|B()),f=0|Ve(0|g,0|(d=0|B()),0|n[(f=r)>>2],0|n[f+4>>2]),d=0|B(),n[(g=r)>>2]=f,n[g+4>>2]=d),(0|h)<=(0|t)){u=37;break}}if(19==(0|u))M(27795,27122,1367,27158);else{if(37==(0|u)){i=0|n[(s=r)+4>>2],s=0|n[s>>2];break}if(42==(0|u))return S=o,0|i}}else i=0,s=0}else u=33}while(0);A:do{if(33==(0|u)){if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(a=v;;){if(i=0|tt(0|A,0|e,3*(15-a|0)|0),B(),7==(0|(i&=7))){i=5;break}if(i=0|qe(0|(s=0|pe(7,0,s=v-a|0,((0|s)<0)<<31>>31)),0|B(),0|i,0),s=0|B(),s=0|Ve(0|n[(m=r)>>2],0|n[m+4>>2],0|i,0|s),i=0|B(),n[(m=r)>>2]=s,n[m+4>>2]=i,(0|(a=a+-1|0))<=(0|t))break A}return S=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,v,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(v=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[v>>2])>>>0>s>>>0:0))?(S=o,0|(v=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=S,S=S+16|0,ee(o=i,A|=0,e|=0,t|=0),!(0|(A=0|n[(e=o)>>2]))&!(0|(e=0|n[e+4>>2])))return S=i,0;a=0,t=0;do{n[(s=r+(a<<3)|0)>>2]=A,n[s+4>>2]=e,a=0|Ve(0|a,0|t,1,0),t=0|B(),re(o),A=0|n[(s=o)>>2],e=0|n[s+4>>2]}while(!(!(0|A)&!(0|e)));return S=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=S,S=S+16|0,a=s,(o|=0)?A=15:(A=0|me(A,e|=0,t|=0,r|=0,a))||(function(A,e){var t;e|=0,t=0|n[8+(A|=0)>>2],n[e>>2]=(0|n[A>>2])-t,n[e+4>>2]=(0|n[A+4>>2])-t}(a,i),A=0),S=s,0|A},_cellToParent:RA,_cellToVertex:Pe,_cellToVertexes:function(A,e,t){t|=0;var r,o=0,i=0;return i=!(0|HA(A|=0,e|=0)),r=!(0|(o=0|Pe(A,e,0,t))),i?r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||(o=0|Pe(A,e,4,t+32|0))?0|(i=o):0|Pe(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||0|(o=0|Pe(A,e,4,t+32|0))?0|(i=o):(n[(i=t+40|0)>>2]=0,n[i+4>>2]=0,0|(i=0)):0|(i=o)},_cellsToDirectedEdge:function(A,e,t,r,o){return o|=0,7==(0|(t=0|_(A|=0,e|=0,t|=0,r|=0)))?0|(o=11):(r=0|rt(0|t,0,56),e=-2130706433&e|B()|268435456,n[o>>2]=A|r,n[o+4>>2]=e,0|(o=0))},_cellsToLinkedMultiPolygon:function(A,e,t){t|=0;var r,i,a,s=0;if(a=S,S=S+32|0,r=a,0|(A=0|function(A,e,t){A|=0,t|=0;var r,o,i=0,a=0,s=0,l=0,c=0,u=0;if(o=S,S=S+176|0,r=o,(0|(e|=0))<1)return Le(t,0,0),S=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Le(t,(0|e)>6?e:6,15&c),c=0;!(0|(i=0|$A(0|n[(i=A+(c<<3)|0)>>2],0|n[i+4>>2],r)));){if((0|(i=0|n[r>>2]))>0){l=0;do{s=r+8+(l<<4)|0,(a=0|ze(t,i=r+8+((0|(l=l+1|0))%(0|i)<<4)|0,s))?_e(t,a):He(t,s,i),i=0|n[r>>2]}while((0|l)<(0|i))}if((0|(c=c+1|0))>=(0|e)){i=0,u=13;break}}return 13==(0|u)?(S=o,0|i):(Ie(t),S=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return S=a,0|A;if(n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,0|(A=0|Re(i)))do{e=0|fe(t);do{de(e,A),s=A+16|0,n[r>>2]=n[s>>2],n[r+4>>2]=n[s+4>>2],n[r+8>>2]=n[s+8>>2],n[r+12>>2]=n[s+12>>2],_e(i,A),A=0|Ge(i,r)}while(0|A);A=0|Re(i)}while(0|A);return Ie(i),(A=0|function(A){var e,t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,D=0,E=0,Q=0,j=0,N=0,S=0,F=0,P=0,T=0,L=0;if(0|n[(s=(A|=0)+8|0)>>2])return 1;if(!(a=0|n[A>>2]))return 0;r=a,i=0;do{i=i+1|0,r=0|n[r+8>>2]}while(0|r);if(i>>>0<2)return 0;(t=0|Ue(i<<2))||M(27396,27235,317,27415),(e=0|Ue(i<<5))||M(27437,27235,321,27415),n[A>>2]=0,n[(E=A+4|0)>>2]=0,n[s>>2]=0,i=0,P=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(d=+o[u+8>>3],r=u,u=0|n[u+16>>2],f=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(d-f))>3.141592653589793){L=14;break}c+=(f-d)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|L)){L=0,c=0,r=h;do{B=+o[r+8>>3],S=0|n[(F=r+16|0)>>2],C=+o[(S=0|S?S:h)+8>>3],c+=(+o[r>>3]+ +o[S>>3])*((C<0?C+6.283185307179586:C)-(B<0?B+6.283185307179586:B)),r=0|n[(0|r?F:a)>>2]}while(0|r)}c>0?(n[t+(P<<2)>>2]=a,P=P+1|0,s=D,r=m):L=19}else L=19;if(19==(0|L)){L=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){L=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){L=21;break A}if(!(i=0|We(1,12))){L=23;break A}n[r>>2]=i,s=i+4|0,u=i,r=m}while(0);if(n[u>>2]=a,n[s>>2]=a,u=e+(D<<5)|0,g=0|n[a>>2]){for(o[(h=e+(D<<5)+8|0)>>3]=17976931348623157e292,o[(m=e+(D<<5)+24|0)>>3]=17976931348623157e292,o[u>>3]=-17976931348623157e292,o[(b=e+(D<<5)+16|0)>>3]=-17976931348623157e292,y=17976931348623157e292,k=-17976931348623157e292,s=0,p=g,d=17976931348623157e292,w=17976931348623157e292,x=-17976931348623157e292,f=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((v=!(0|p))?g:p)+8>>3],c>3]=c,d=c),B>3]=B,w=B),c>x?o[u>>3]=c:c=x,B>f&&(o[b>>3]=B,f=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!v;)x=c;s&&(o[b>>3]=k,o[m>>3]=y)}else n[u>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,n[u+12>>2]=0,n[u+16>>2]=0,n[u+20>>2]=0,n[u+24>>2]=0,n[u+28>>2]=0;s=D+1|0}if(a=0|n[(F=a+8|0)>>2],n[F>>2]=0,!a){L=45;break}D=s,m=r}if(21==(0|L))M(27213,27235,35,27247);else if(23==(0|L))M(27267,27235,37,27247);else if(27==(0|L))M(27310,27235,61,27333);else if(45==(0|L)){A:do{if((0|P)>0){for(F=!(0|s),N=s<<2,S=!(0|A),j=0,r=0;;){if(Q=0|n[t+(j<<2)>>2],F)L=73;else{if(!(D=0|Ue(N))){L=50;break}if(!(E=0|Ue(N))){L=52;break}e:do{if(S)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[Q>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,v=i+1|0):v=i,u=0|n[u+8>>2];)s=s+1|0,i=v;if((0|v)>0)if(a=0|n[D>>2],1==(0|v))i=a;else for(b=0,p=-1,i=a,m=a;;){for(g=0|n[m>>2],a=0,u=0;h=(0|(s=0|n[n[D+(u<<2)>>2]>>2]))==(0|g)?a:a+(1&he(s,0|n[E+(u<<2)>>2],0|n[g>>2]))|0,(0|(u=u+1|0))!=(0|v);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|v))break e;b=a,p=s?h:p,m=0|n[D+(a<<2)>>2]}else i=0}}while(0);if(Ye(D),Ye(E),i){if(a=0|n[(s=i+4|0)>>2])i=a+8|0;else if(0|n[i>>2]){L=70;break}n[i>>2]=Q,n[s>>2]=Q}else L=73}if(73==(0|L)){if(L=0,0|(r=0|n[Q>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(Q),r=1}if((0|(j=j+1|0))>=(0|P)){T=r;break A}}50==(0|L)?M(27452,27235,249,27471):52==(0|L)?M(27490,27235,252,27471):70==(0|L)&&M(27310,27235,61,27333)}else T=0}while(0);return Ye(t),Ye(e),0|T}return 0}(t))?(ge(t),S=a,0|(s=A)):(S=a,0|(s=0))},_childPosToCell:function(A,e,t,r,o,i){A|=0,e|=0,i|=0;var a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=S,S=S+16|0,s=a,(o|=0)>>>0>15)return S=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return S=a,12;if(0|_A(t,r,o,s)&&M(27795,27122,1327,27173),!(((0|e)>-1|-1==(0|e)&A>>>0>4294967295)&((0|(u=0|n[(f=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[f>>2])>>>0>A>>>0:0))))return S=a,2;f=o-l|0,o=0|rt(0|o,0,52),c=B()|-15728641&r,n[(u=i)>>2]=o|t,n[u+4>>2]=c,u=0|tt(0|t,0|r,45),B();A:do{if(0|z(127&u)){if(0|l)for(s=1;;){if(!(!((u=0|rt(7,0,3*(15-s|0)|0))&t)&!((0|B())&r)))break A;if(!(s>>>0>>0))break;s=s+1|0}if((0|f)<1)return S=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=f-c|0,((0|l)<0)<<31>>31),t=0|B();do{if(s){if(s=0|Xe(0|(s=0|Ve(0|(s=0|qe(0|l,0|t,5,0)),0|B(),-5,-1)),0|B(),6,0),(0|e)>(0|(o=0|B()))|(0|e)==(0|o)&A>>>0>s>>>0){e=0|Ze(0|(e=0|Ve(0|A,0|e,-1,-1)),0|B(),0|s,0|o),s=0|B(),h=0|n[(d=i)>>2],d=0|n[d+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),d&=~B(),m=0|rt(0|(o=0|Ve(0|(r=0|Xe(0|e,0|s,0|l,0|t)),0|(A=0|B()),2,0)),0|B(),0|m),d=0|B()|d,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=d,A=0|Ze(0|e,0|s,0|(A=0|qe(0|r,0|A,0|l,0|t)),0|B()),s=0,e=0|B();break}g=0|n[(m=i)>>2],m=0|n[m+4>>2],h=0|rt(7,0,3*(u+r|0)|0),m&=~B(),n[(s=i)>>2]=g&~h,n[s+4>>2]=m,s=1;break}o=0|n[(g=i)>>2],g=0|n[g+4>>2],d=0|rt(7,0,0|(r=3*(u+r|0)|0)),g&=~B(),r=0|rt(0|(m=0|Xe(0|A,0|e,0|l,0|t)),0|(s=0|B()),0|r),g=0|B()|g,n[(h=i)>>2]=r|o&~d,n[h+4>>2]=g,A=0|Ze(0|A,0|e,0|(s=0|qe(0|m,0|s,0|l,0|t)),0|B()),s=0,e=0|B()}while(0);if(!((0|f)>(0|c))){e=0;break}r=~c,c=c+1|0}return S=a,0|e}}while(0);if((0|f)<1)return S=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=f-s|0,((0|h)<0)<<31>>31),m=0|B(),t=0|n[(c=i)>>2],c=0|n[c+4>>2],r=0|rt(7,0,0|(l=3*(o-s|0)|0)),c&=~B(),l=0|rt(0|(d=0|Xe(0|A,0|e,0|h,0|m)),0|(g=0|B()),0|l),c=0|B()|c,n[(u=i)>>2]=l|t&~r,n[u+4>>2]=c,A=0|Ze(0|A,0|e,0|(m=0|qe(0|d,0|g,0|h,0|m)),0|B()),e=0|B(),(0|f)<=(0|s)){e=0;break}s=s+1|0}return S=a,0|e},_compactCells:function(A,e,t,r){e|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,D=0,E=0,Q=0,j=0,N=0,S=0;if(!(0|(t|=0))&!(0|(r|=0)))return 0;if(a=0|n[(i=A|=0)>>2],!0&!(15728640&(i=0|n[i+4>>2]))){if(!((0|r)>0|!(0|r)&t>>>0>0))return 0;if(n[(S=e)>>2]=a,n[S+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{N=0|n[4+(j=A+(i<<3)|0)>>2],n[(S=e+(i<<3)|0)>>2]=n[j>>2],n[S+4>>2]=N,i=0|Ve(0|i,0|a,1,0),a=0|B()}while((0|a)<(0|r)|(0|a)==(0|r)&i>>>0>>0);return 0}if(!(N=0|Ue(o=t<<3)))return 13;if(st(0|N,0|A,0|o),!(j=0|We(t,8)))return Ye(N),13;A:for(;;){E=0|tt(0|(u=0|n[(i=N)>>2]),0|(i=0|n[i+4>>2]),52),B(),Q=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(w=0|rt(0|Q,0,52),x=0|B(),Q>>>0>15){if(!(!(0|u)&!(0|i))){S=16;break A}for(a=0,A=0;;){if(a=0|Ve(0|a,0|A,1,0),!((0|(A=0|B()))<(0|r)|(0|A)==(0|r)&a>>>0>>0))break e;if(!(!(0|(k=0|n[(s=N+(a<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))){i=s,S=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){S=21;break A}if(f=0|tt(0|l,0|A,52),B(),(0|(f&=15))<(0|Q)){i=12,S=27;break A}if((0|f)!=(0|Q)&&(l|=w,A=-15728641&A|x,f>>>0>=E>>>0)){c=Q;do{k=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,l|=k,A=0|B()|A}while(c>>>0>>0)}if(g=0|At(0|l,0|A,0|t,0|r),h=0|B(),!(!(0|(d=0|n[(f=c=j+(g<<3)|0)>>2]))&!(0|(f=0|n[f+4>>2])))){p=0,v=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&v>>>0>t>>>0){S=31;break A}if((0|d)==(0|l)&(-117440513&f)==(0|A)){m=0|tt(0|d,0|f,56),B(),b=1+(m&=7)|0,k=0|tt(0|d,0|f,45),B();t:do{if(0|z(127&k)){if(d=0|tt(0|d,0|f,52),B(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((k=0|rt(7,0,3*(15-f|0)|0))&l)&!((0|B())&A))){f=7;break t}if(!(f>>>0>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){S=41;break A}k=0|rt(0|b,0,56),A=B()|-117440513&A,n[(y=c)>>2]=0,n[y+4>>2]=0,l|=k}else g=0|$e(0|(g=0|Ve(0|g,0|h,1,0)),0|B(),0|t,0|r),h=0|B();v=0|Ve(0|v,0|p,1,0),p=0|B(),d=0|n[(f=c=j+(g<<3)|0)>>2],f=0|n[f+4>>2]}while(!(!(0|d)&!(0|f)))}n[(k=c)>>2]=l,n[k+4>>2]=A}if(a=0|Ve(0|a,0|s,1,0),!((0|(s=0|B()))<(0|r)|(0|s)==(0|r)&a>>>0>>0))break e;l=0|n[(A=N+(a<<3)|0)>>2],A=0|n[A+4>>2]}}}while(0);if(k=0|Ve(0|t,0|r,5,0),(y=0|B())>>>0<0|!(0|y)&k>>>0<11){S=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){S=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=f=j+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{d=0|tt(0|a,0|s,56),B(),l=1+(d&=7)|0,g=-117440513&s,y=0|tt(0|a,0|s,45),B();e:do{if(0|z(127&y)){if(h=0|tt(0|a,0|s,52),B(),0|(h&=15))for(c=1;;){if(!(!(a&(y=0|rt(7,0,3*(15-c|0)|0)))&!(g&(0|B()))))break e;if(!(c>>>0>>0))break;c=c+1|0}a|=s=0|rt(0|l,0,56),s=0|B()|g,n[(l=f)>>2]=a,n[l+4>>2]=s,l=d+2|0}}while(0);7==(0|l)?(n[(y=k+(A<<3)|0)>>2]=a,n[y+4>>2]=-117440513&s,A=0|Ve(0|A,0|m,1,0),y=0|B()):y=m}if(b=0|Ve(0|b,0|p,1,0),!((0|(p=0|B()))<(0|r)|(0|p)==(0|r)&b>>>0>>0))break;m=y}if(C){if(v=Q>>>0>15,w=0|rt(0|Q,0,52),x=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(Q=e+(a<<3)|0)>>2]=u,n[Q+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()),l=0|Ve(0|l,0|s,1,0),(0|(s=0|B()))<(0|r)|(0|s)==(0|r)&l>>>0>>0;)u=0|n[(i=N+(l<<3)|0)>>2],i=0|n[i+4>>2];i=y;break}for(a=0,c=0,s=0,l=0;;){do{if(!(!(0|u)&!(0|i))){if(h=0|tt(0|u,0|i,52),B(),v|(0|(h&=15))<(0|Q)){S=80;break A}if((0|h)!=(0|Q)){if(f=u|w,d=-15728641&i|x,h>>>0>=E>>>0){g=Q;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,f|=D,d=0|B()|d}while(g>>>0>>0)}}else f=u,d=i;m=0|At(0|f,0|d,0|t,0|r),g=0,h=0,p=0|B();do{if((0|g)>(0|r)|(0|g)==(0|r)&h>>>0>t>>>0){S=81;break A}if((-117440513&(b=0|n[4+(D=j+(m<<3)|0)>>2]))==(0|d)&&(0|n[D>>2])==(0|f)){S=65;break}m=0|$e(0|(D=0|Ve(0|m,0|p,1,0)),0|B(),0|t,0|r),p=0|B(),h=0|Ve(0|h,0|g,1,0),g=0|B(),D=j+(m<<3)|0}while((0|n[D>>2])!=(0|f)||(0|n[D+4>>2])!=(0|d));if(65==(0|S)&&(S=0,!0&100663296==(117440512&b)))break;n[(D=e+(a<<3)|0)>>2]=u,n[D+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()}}while(0);if(s=0|Ve(0|s,0|l,1,0),!((0|(l=0|B()))<(0|r)|(0|l)==(0|r)&s>>>0>>0))break;u=0|n[(i=N+(s<<3)|0)>>2],i=0|n[i+4>>2]}i=y}else a=0,i=y}else a=0,A=0,i=0}while(0);if(lt(0|j,0,0|o),st(0|N,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){S=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|S))!0&!(117440512&i)?(i=4,S=27):S=21;else if(31==(0|S))M(27795,27122,620,27132);else{if(41==(0|S))return Ye(N),Ye(j),10;if(48==(0|S))return Ye(N),Ye(j),13;80==(0|S)?M(27795,27122,711,27132):81==(0|S)?M(27795,27122,723,27132):85==(0|S)&&(st(0|e,0|N,t<<3),S=89)}return 21==(0|S)?(Ye(N),Ye(j),0|(S=5)):27==(0|S)?(Ye(N),Ye(j),0|(S=i)):89==(0|S)?(Ye(N),Ye(j),0|(S=0)):0},_constructCell:function(A,e,t,o){t|=0,o|=0;var i=0,a=0,s=0,l=0,c=0,u=0;if((A|=0)>>>0>15)return 4;if((e|=0)>>>0>121)return 17;s=0|rt(0|A,0,52),i=0|B(),l=0|rt(0|e,0,45),i=0|i|B()|134225919;A:do{if((0|A)>=1){for(l=1,s=!!(0|r[20528+e|0]),a=-1;;){if((e=0|n[t+(l+-1<<2)>>2])>>>0>6){i=18,e=10;break}if(!(!(0|e)|1^s)){if(1==(0|e)){i=19,e=10;break}s=0}if(c=0|rt(7,0,0|(u=3*(15-l|0)|0)),i&=~B(),a=(e=0|rt(0|e,((0|e)<0)<<31>>31,0|u))|a&~c,i=0|B()|i,!((0|l)<(0|A)))break A;l=l+1|0}if(10==(0|e))return 0|i}else a=-1}while(0);return n[(u=o)>>2]=a,n[u+4>>2]=i,0},_destroyLinkedMultiPolygon:ge,_directedEdgeToBoundary:DA,_directedEdgeToCells:function(A,e,t){A|=0;var r,o,i,a=0;return r=S,S=S+16|0,a=r,!0&268435456==(2013265920&(e|=0))?(o=-2130706433&e|134217728,n[(i=t|=0)>>2]=A,n[i+4>>2]=o,n[a>>2]=0,e=0|tt(0|A,0|e,56),B(),a=0|I(A,o,7&e,a,t+8|0),S=r,0|a):(S=r,0|(a=6))},_edgeLengthKm:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return l=A,s=+o[t>>3],s*=6371.007180918475,o[t>>3]=s,S=r,0|l;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return l=0,s=0,s*=6371.007180918475,o[t>>3]=s,S=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,o[t>>3]=h,S=r,0|l},_edgeLengthM:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return l=A,s=+o[t>>3],s*=6371.007180918475,s*=1e3,o[t>>3]=s,S=r,0|l;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return l=0,s=0,s*=6371.007180918475,s*=1e3,o[t>>3]=s,S=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,h*=1e3,o[t>>3]=h,S=r,0|l},_edgeLengthRads:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return S=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return S=r,0;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+i)*+f(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,S=r,0},_emscripten_replace_memory:function(A){return r=new Int8Array(A),n=new Int32Array(A),o=new Float64Array(A),t=A,!0},_free:Ye,_getBaseCellNumber:TA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=S,S=S+16|0,n[(i=r)>>2]=0,!0&268435456==(2013265920&e)?(o=0|tt(0|A,0|e,56),B(),i=0|I(A,-2130706433&e|134217728,7&o,i,t),S=r,0|i):(S=r,0|(i=6))},_getDirectedEdgeOrigin:function(A,e,t){return A|=0,t|=0,!0&268435456==(2013265920&(e|=0))?(n[t>>2]=A,n[t+4>>2]=-2130706433&e|134217728,0|(t=0)):0|(t=6)},_getHexagonAreaAvgKm2:se,_getHexagonAreaAvgM2:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20784+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgKm:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20912+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgM:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[21040+(A<<3)>>3],0|(e=0))},_getIcosahedronFaces:function A(e,t,r){r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;o=S,S=S+128|0,f=o+112|0,s=o+96|0,d=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[f>>2]=c,l=0|tt(0|e,0|t,45),B(),l&=127;A:do{if(0|z(l)){if(0|c)for(i=1;;){if(!(!((u=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){a=0;break A}if(!(i>>>0>>0))break;i=i+1|0}if(!(1&a))return u=0|rt(c+1|0,0,52),d=B()|-15728641&t,d=0|A((u|e)&~(f=0|rt(7,0,3*(14-c|0)|0)),d&~B(),r),S=o,0|d;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(jA(s,f,d),u=5):(PA(s,f,d),u=6);A:do{if(0|z(l))if(c)for(i=1;;){if(!(!((l=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){e=2;break A}if(!(i>>>0>>0)){e=5;break}i=i+1|0}else e=5;else e=2}while(0);lt(0|r,-1,e<<2);A:do{if(a)for(s=0;;){if(SA(l=d+(s<<4)|0,0|n[f>>2]),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}else for(s=0;;){if(NA(l=d+(s<<4)|0,0|n[f>>2],0,1),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}}while(0)}return S=o,0|i},_getIndexDigit:function(A,e,t,r){return r|=0,((t|=0)-1|0)>>>0>14?0|(r=4):(t=0|tt(0|(A|=0),0|(e|=0),3*(15-t|0)|0),B(),n[r>>2]=7&t,0|(r=0))},_getNumCells:le,_getPentagons:Ae,_getRes0Cells:function(A){A|=0;var e=0,t=0,r=0;e=0;do{rt(0|e,0,45),r=134225919|B(),n[(t=A+(e<<3)|0)>>2]=-1,n[t+4>>2]=r,e=e+1|0}while(122!=(0|e));return 0},_getResolution:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),15&e},_greatCircleDistanceKm:ae,_greatCircleDistanceM:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:F,_gridDiskDistances:P,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=S,S=S+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(S=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(S=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,S=a,0|(l=0))},_gridPathCells:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,D=0,E=0;if(a=S,S=S+48|0,c=a+12|0,D=a,!(s=0|me(A|=0,e|=0,A,e,i=a+24|0))&&!(s=0|me(A,e,t,r,c))){C=((0|(k=0|kA(i,c)))<0)<<31>>31,n[i>>2]=0,n[i+4>>2]=0,n[i+8>>2]=0,n[c>>2]=0,n[c+4>>2]=0,n[c+8>>2]=0,0|me(A,e,A,e,i)&&M(27795,27538,692,27747),0|me(A,e,t,r,c)&&M(27795,27538,697,27747),CA(i),CA(c),g=0|k?1/+(0|k):0,t=0|n[i>>2],v=g*+((0|n[c>>2])-t|0),r=0|n[(w=i+4|0)>>2],x=g*+((0|n[c+4>>2])-r|0),s=0|n[(y=i+8|0)>>2],g*=+((0|n[c+8>>2])-s|0),n[D>>2]=t,n[(h=D+4|0)>>2]=r,n[(m=D+8|0)>>2]=s;A:do{if((0|k)<0)s=0;else for(b=0,p=0;;){E=v*(f=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=x*f+ +(0|r),f=g*f+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+f),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),f=+l(+(+(0|s)-f));do{if(!(E>u&E>f)){if(d=0-t|0,u>f){r=d-s|0;break}r=c,s=d-c|0;break}t=0-(c+s)|0,r=c}while(0);if(n[D>>2]=t,n[h>>2]=r,n[m>>2]=s,BA(D),0|(s=0|be(A,e,D,o+(p<<3)|0)))break A;if(!((0|b)<(0|C)|(0|b)==(0|C)&p>>>0>>0)){s=0;break A}t=0|Ve(0|p,0|b,1,0),b=r=0|B(),p=t,t=0|n[i>>2],r=0|n[w>>2],s=0|n[y>>2]}}while(0);return S=a,0|s}return S=a,0|s},_gridPathCellsSize:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a=0,s=0,l=0;return i=S,S=S+32|0,l=i,(a=0|me(A|=0,e|=0,A,e,s=i+12|0))||(a=0|me(A,e,t,r,l))?(S=i,0|(l=a)):(r=0|Ve(0|(r=0|kA(s,l)),((0|r)<0)<<31>>31,1,0),s=0|B(),n[(l=o)>>2]=r,n[l+4>>2]=s,S=i,0|(l=0))},_gridRing:function(A,e,t,r){return 0|R(A|=0,e|=0,t|=0,r|=0)?(lt(0|r,0,48*t|0),0|(r=0|function(A,e,t,r){A|=0,e|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;if(o=S,S=S+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,S=o,0;do{if((0|t)>=0){if((0|t)>13780509){if(0|(i=0|le(15,s)))break;i=0|n[(a=s)>>2],a=0|n[a+4>>2]}else f=0|qe(0|t,0|(i=((0|t)<0)<<31>>31),3,0),a=0|B(),i=0|Ve(0|t,0|i,1,0),i=0|Ve(0|(i=0|qe(0|f,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(f=s)>>2]=i,n[f+4>>2]=a;if(u=0|We(i,8)){if(!(f=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|L(A,e,t,u,f,i,a,0))){Ye(u),Ye(f);break}if(e=0|n[s>>2],(0|(s=0|n[s+4>>2]))>0|!(0|s)&e>>>0>0){i=0,l=0,c=0;do{!(0|(a=0|n[(A=u+(l<<3)|0)>>2]))&!(0|(A=0|n[A+4>>2]))||(0|n[f+(l<<2)>>2])!=(0|t)||(n[(d=r+(i<<3)|0)>>2]=a,n[d+4>>2]=A,i=i+1|0),l=0|Ve(0|l,0|c,1,0),c=0|B()}while((0|c)<(0|s)|(0|c)==(0|s)&l>>>0>>0)}Ye(u),Ye(f),i=0}else i=13}else i=2}while(0);return S=o,0|i}(A,e,t,r))):0|(r=0)},_gridRingUnsafe:R,_i64Add:Ve,_i64Subtract:Ze,_isPentagon:HA,_isResClassIII:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),1&e},_isValidCell:LA,_isValidDirectedEdge:MA,_isValidIndex:function(A,e){A|=0;var t=0,n=0,o=0,i=0;if(!0&134217728==(-16777216&(e|=0))&&(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0<=121)&&!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())){if(!(0|r[20528+t|0]))return 1;if(!(0|A)&!(0|(t=8191&e)))return 1;if(i=0|nt(0|A,0|t),B(),(63-i|0)%3|0)return 1}return 0|MA(A,e)?0|(i=1):0|(i=1&!!(0|Te(A,e)))},_isValidVertex:Te,_latLngToCell:KA,_llvm_ctlz_i64:nt,_llvm_maxnum_f64:ot,_llvm_minnum_f64:it,_llvm_round_f64:at,_localIjToCell:function(A,e,t,r,o){var i,a;return A|=0,e|=0,t|=0,o|=0,a=S,S=S+16|0,i=a,(r|=0)?t=15:(t=0|function(A,e){e|=0;var t,r,o,i=0,a=0,s=0;if(a=0|n[(A|=0)>>2],n[e>>2]=a,s=0|n[A+4>>2],n[(r=e+4|0)>>2]=s,n[(o=e+8|0)>>2]=0,A=(i=(0|s)<(0|a))?a:s,(0|(i=i?s:a))<0){if(-2147483648==(0|i)||((0|A)>0?(2147483647-A|0)<(0|i):(-2147483648-A|0)>(0|i)))return 1;if((0|A)>-1?(-2147483648|A)>=(0|i):(-2147483648^A)<(0|i))return 1}return A=s-a|0,(0|a)<0?(i=0-a|0,n[r>>2]=A,n[o>>2]=i,n[e>>2]=0,a=0):(A=s,i=0),(0|A)<0&&(a=a-A|0,n[e>>2]=a,i=i-A|0,n[o>>2]=i,n[r>>2]=0,A=0),t=a-i|0,s=A-i|0,(0|i)<0?(n[e>>2]=t,n[r>>2]=s,n[o>>2]=0,A=s,s=t,i=0):s=a,(0|(a=(0|i)<(0|(a=(0|A)<(0|s)?A:s))?i:a))<=0||(n[e>>2]=s-a,n[r>>2]=A-a,n[o>>2]=i-a),0}(t,i))||(t=0|be(A,e,i,o)),S=a,0|t},_malloc:Ue,_maxFaceCount:function(A,e,t){t|=0;var r=0,o=0;if(o=0|tt(0|(A|=0),0|(e|=0),45),B(),!(0|z(127&o)))return o=2,n[t>>2]=o,0;if(o=0|tt(0|A,0|e,52),B(),!(o&=15))return o=5,n[t>>2]=o,0;for(r=1;;){if(!(!((0|rt(7,0,3*(15-r|0)|0))&A)&!((0|B())&e))){r=2,A=6;break}if(!(r>>>0>>0)){r=5,A=6;break}r=r+1|0}return 6==(0|A)?(n[t>>2]=r,0):0},_maxGridDiskSize:function(A,e){e|=0;var t=0,r=0,o=0;return(0|(A|=0))<0?0|(e=2):(0|A)>13780509?0|(e=0|le(15,e)):(o=0|qe(0|A,0|(t=((0|A)<0)<<31>>31),3,0),r=0|B(),t=0|Ve(0|A,0|t,1,0),t=0|Ve(0|(t=0|qe(0|o,0|r,0|t,0|B())),0|B(),1,0),A=0|B(),n[e>>2]=t,n[e+4>>2]=A,0|(e=0))},_maxPolygonToCellsSize:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0;if(o=S,S=S+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return S=o,0|t;if(l=0|n[(c=A)+4>>2],n[(t=a)>>2]=n[c>>2],n[t+4>>2]=l,ke(a,i),!(t=0|eA(i,e,s))){if(e=0|n[a>>2],(0|(a=0|n[A+8>>2]))>0){i=0|n[A+12>>2],t=0;do{e=(0|n[i+(t<<3)>>2])+e|0,t=t+1|0}while((0|t)<(0|a))}i=0|n[(t=s)>>2],(0|(t=0|n[t+4>>2]))<(0|(a=((0|e)<0)<<31>>31))|(0|t)==(0|a)&i>>>0>>0?(n[(t=s)>>2]=e,n[t+4>>2]=a,t=a):e=i,l=0|Ve(0|e,0|t,12,0),c=0|B(),n[(t=s)>>2]=l,n[t+4>>2]=c,n[(t=r)>>2]=l,n[t+4>>2]=c,t=0}return S=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,d=0,g=0,h=0,m=0,b=0,p=0;if(s=S,S=S+48|0,h=s+32|0,g=s+40|0,a=s,!(0|n[(A|=0)>>2]))return n[(m=i)>>2]=0,n[m+4>>2]=0,S=s,0;IA(h,0,0,0),c=0|n[(d=h)>>2],d=0|n[d+4>>2];do{if(e>>>0>15)n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=4,m=9;else{if(0|(t=0|Ce(t))){n[(h=a)>>2]=0,n[h+4>>2]=0,n[a+8>>2]=t,n[a+12>>2]=-1,m=a+29|0,n[(h=a+16|0)>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,r[h+12|0]=0,r[0|m]=0|r[0|g],r[m+1|0]=0|r[g+1|0],r[m+2|0]=0|r[g+2|0],m=9;break}if(!(t=0|We(1+(0|n[A+8>>2])|0,32))){n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=13,m=9;break}Be(A,t),n[(p=a)>>2]=c,n[p+4>>2]=d,n[(d=a+8|0)>>2]=0,n[a+12>>2]=e,n[a+20>>2]=A,n[a+24>>2]=t,r[a+28|0]=0,r[0|(c=a+29|0)]=0|r[0|g],r[c+1|0]=0|r[g+1|0],r[c+2|0]=0|r[g+2|0],n[a+16>>2]=3,b=+J(t),b*=+Z(t),u=+l(+ +o[t>>3]),u=b/+f(+ +it(+u,+ +l(+ +o[t+8>>3])))*6371.007180918475*6371.007180918475,t=0|n[(c=a+12|0)>>2];A:do{if((0|t)>0)do{if(se(t+-1|0,h),!(u/+o[h>>3]>10))break A;t=(p=0|n[c>>2])-1|0,n[c>>2]=t}while((0|p)>1)}while(0);if(we(a),n[(c=i)>>2]=0,n[c+4>>2]=0,!(!(0|(t=0|n[(c=a)>>2]))&!(0|(c=0|n[c+4>>2]))))do{_A(t,c,e,h),g=h,g=0|Ve(0|n[(A=i)>>2],0|n[A+4>>2],0|n[g>>2],0|n[g+4>>2]),A=0|B(),n[(p=i)>>2]=g,n[p+4>>2]=A,we(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[d>>2]}}while(0);return S=s,0|t},_memcpy:st,_memset:lt,_originToDirectedEdges:function(A,e,t){t|=0;var r,o=0;return r=!(0|HA(A|=0,e|=0)),e&=-2130706433,n[(o=t)>>2]=r?A:0,n[o+4>>2]=r?285212672|e:0,n[(o=t+8|0)>>2]=A,n[o+4>>2]=301989888|e,n[(o=t+16|0)>>2]=A,n[o+4>>2]=318767104|e,n[(o=t+24|0)>>2]=A,n[o+4>>2]=335544320|e,n[(o=t+32|0)>>2]=A,n[o+4>>2]=352321536|e,n[(t=t+40|0)>>2]=A,n[t+4>>2]=369098752|e,0},_pentagonCount:function(){return 12},_polygonToCells:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i,a,s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,j=0,N=0,F=0,P=0,I=0,R=0,_=0;if(s=S,S=S+112|0,o=s+80|0,d=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return S=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return S=s,13;if(Be(A,_),!(l=0|Ce(t))){if(R=0|n[(I=A)+4>>2],n[(l=d)>>2]=n[I>>2],n[l+4>>2]=R,ke(d,o),l=0|eA(o,e,i))I=0,R=0;else{if(l=0|n[d>>2],(0|(c=0|n[g>>2]))>0){u=0|n[A+12>>2],t=0;do{l=(0|n[u+(t<<3)>>2])+l|0,t=t+1|0}while((0|t)!=(0|c));t=l}else t=l;c=0|n[(l=i)>>2],(0|(l=0|n[l+4>>2]))<(0|(u=((0|t)<0)<<31>>31))|(0|l)==(0|u)&c>>>0>>0?(n[(l=i)>>2]=t,n[l+4>>2]=u,l=u):t=c,I=0|Ve(0|t,0|l,12,0),R=0|B(),n[(l=i)>>2]=I,n[l+4>>2]=R,l=0}if(!l){if(!(t=0|We(I,8)))return Ye(_),S=s,13;if(!(f=0|We(I,8)))return Ye(_),Ye(t),S=s,13;n[(F=o)>>2]=0,n[F+4>>2]=0,P=0|n[(F=A)+4>>2],n[(l=d)>>2]=n[F>>2],n[l+4>>2]=P,l=0|H(d,I,R,e,o,t,f);A:do{if(l)Ye(t),Ye(f),Ye(_);else{e:do{if((0|n[g>>2])>0){for(u=A+12|0,c=0;l=0|H((0|n[u>>2])+(c<<3)|0,I,R,e,o,t,f),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(f),Ye(_);break A}}while(0);(0|R)>0|!(0|R)&I>>>0>0&<(0|f,0,I<<3),F=0|n[(P=o)+4>>2];e:do{if((0|F)>0|!(0|F)&(0|n[P>>2])>>>0>0){Q=t,j=f,N=t,F=f,P=t,l=t,M=t,D=f,E=f,t=f;t:for(;;){for(x=0,y=0,k=0,C=0,c=0,u=0;;){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|T(g=0|n[(e=Q+(x<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|We(7,4))&&(L(g,e,1,i,f,7,0,0),Ye(f))}for(w=0;;){p=0|n[(v=i+(w<<3)|0)>>2],v=0|n[v+4>>2];r:do{if(!(0|p)&!(0|v))f=c,d=u;else{if(h=0|At(0|p,0|v,0|I,0|R),g=0|B(),!(!(0|(d=0|n[(e=f=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|R)|(0|m)==(0|R)&b>>>0>I>>>0)break t;if((0|d)==(0|p)&(0|e)==(0|v)){f=c,d=u;break r}h=0|$e(0|(f=0|Ve(0|h,0|g,1,0)),0|B(),0|I,0|R),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),d=0|n[(e=f=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|d)&!(0|e)))}if(!(0|p)&!(0|v)){f=c,d=u;break}qA(p,v,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=f)>>2]=p,n[m+4>>2]=v,n[(c=j+(c<<3)|0)>>2]=p,n[c+4>>2]=v,c=b),f=c,d=u}}while(0);if((w=w+1|0)>>>0>=7)break;c=f,u=d}if(x=0|Ve(0|x,0|y,1,0),y=0|B(),k=0|Ve(0|k,0|C,1,0),C=0|B(),c=0|n[(u=o)>>2],!((0|C)<(0|(u=0|n[u+4>>2]))|(0|C)==(0|u)&k>>>0>>0))break;c=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=Q+(c<<3)|0)>>2]=0,n[C+4>>2]=0,c=0|Ve(0|c,0|u,1,0),u=0|B(),k=0|n[(C=o)+4>>2]}while((0|u)<(0|k)|((0|u)==(0|k)?c>>>0<(0|n[C>>2])>>>0:0))}if(n[(C=o)>>2]=f,n[C+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break e;w=t,x=E,y=P,k=D,C=j,t=M,E=l,D=N,M=w,l=x,P=F,F=y,N=k,j=Q,Q=C}Ye(N),Ye(F),Ye(_),l=1;break A}l=f}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return S=s,0|l}}return Ye(_),S=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0;c=S,S=S+160|0,f=c+64|0,h=c+112|0,p=c,function(A,e,t,o){A|=0,e|=0,t|=0,o|=0;var i,a,s,l=0,c=0,u=0,f=0;s=S,S=S+48|0,i=s+40|0,a=s,IA(c=s+32|0,0,0,0),u=0|n[c>>2],c=0|n[c+4>>2];do{if(t>>>0<=15){if(0|(l=0|Ce(o))){n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=l,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}if(l=0|We(1+(0|n[e+8>>2])|0,32)){Be(e,l),n[(f=a)>>2]=u,n[f+4>>2]=c,n[a+8>>2]=0,n[a+12>>2]=t,n[a+16>>2]=o,n[a+20>>2]=e,n[a+24>>2]=l,r[a+28|0]=0,r[0|(u=a+29|0)]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(u=a)>>2]=0,n[u+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,f=a+29|0,n[(u=a+16|0)>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,r[u+12|0]=0,r[0|f]=0|r[0|i],r[f+1|0]=0|r[i+1|0],r[f+2|0]=0|r[i+2|0]}while(0);we(a),n[A>>2]=n[a>>2],n[A+4>>2]=n[a+4>>2],n[A+8>>2]=n[a+8>>2],n[A+12>>2]=n[a+12>>2],n[A+16>>2]=n[a+16>>2],n[A+20>>2]=n[a+20>>2],n[A+24>>2]=n[a+24>>2],n[A+28>>2]=n[a+28>>2],S=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(f,0|n[(d=g)>>2],0|n[d+4>>2],e),s=0|n[(d=f)>>2],d=0|n[d+4>>2],u=0|n[g+8>>2],n[(m=h+4|0)>>2]=n[g>>2],n[m+4>>2]=n[g+4>>2],n[m+8>>2]=n[g+8>>2],n[m+12>>2]=n[g+12>>2],n[m+16>>2]=n[g+16>>2],n[m+20>>2]=n[g+20>>2],n[m+24>>2]=n[g+24>>2],n[m+28>>2]=n[g+28>>2],n[(m=p)>>2]=s,n[m+4>>2]=d,n[(m=p+8|0)>>2]=u,e=h,t=36+(A=p+12|0)|0;do{n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}while((0|A)<(0|t));if(n[(h=p+48|0)>>2]=n[f>>2],n[h+4>>2]=n[f+4>>2],n[h+8>>2]=n[f+8>>2],n[h+12>>2]=n[f+12>>2],!(0|s)&!(0|d))return S=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,f=0,e=s,A=d;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&f>>>0>>0)){b=4;break}if(d=f,f=0|Ve(0|f,0|u,1,0),u=0|B(),n[(d=a+(d<<3)|0)>>2]=e,n[d+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(we(t),!(0|(A=0|n[(e=t)>>2]))&!(0|(e=0|n[e+4>>2]))){b=10;break}te(A,e,0|n[g>>2],h),e=0|n[(A=h)>>2],A=0|n[A+4>>2]}n[(d=p)>>2]=e,n[d+4>>2]=A}while(!(!(0|e)&!(0|A)));return 4==(0|b)?(0|(e=0|n[(A=p+40|0)>>2])&&Ye(e),n[(b=p+16|0)>>2]=0,n[b+4>>2]=0,n[l>>2]=0,n[p+36>>2]=0,n[g>>2]=-1,n[p+32>>2]=0,n[A>>2]=0,te(0,0,0,h),n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=0,S=c,0|(p=14)):(10==(0|b)&&(n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=n[l>>2]),p=0|n[m>>2],S=c,0|p)},_readInt64AsDoubleFromPointer:function(A){return+(+((0|n[(A|=0)>>2])>>>0)+4294967296*+(0|n[A+4>>2]))},_res0CellCount:function(){return 122},_round:ct,_sbrk:ut,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(A,e,t,r,o,i,a){A|=0,r|=0,o|=0,i|=0;var s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(s=S,S=S+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return S=s,0;if((0|(a|=0))>=16)return S=s,12;g=0,h=0,d=0,l=0;A:for(;;){if(f=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&f)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(f=m)>>2]))&!(0|(f=0|n[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(d=r+(c<<3)|0)>>2]=u,n[d+4>>2]=f,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(d=m)>>2],f=0|n[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(g=0|Ve(0|g,0|h,1,0),!((0|(h=0|B()))<(0|t)|(0|h)==(0|t)&g>>>0>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(S=s,0|(m=14)):11==(0|c)?(S=s,0|l):0},_uncompactCellsSize:function(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0;a=S,S=S+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(f=0,l=0,s=0,d=0;;){if(!(!(0|(c=0|n[(u=A+(f<<3)|0)>>2]))&!(0|(u=0|n[u+4>>2]))||(u=!(0|_A(c,u,r,i)),l=0|Ve(0|n[(c=i)>>2],0|n[c+4>>2],0|l,0|s),s=0|B(),u))){s=12;break}if(f=0|Ve(0|f,0|d,1,0),!((0|(d=0|B()))<(0|t)|(0|d)==(0|t)&f>>>0>>0))break A}return S=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,S=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=S,S=S+192|0,o=a,i=a+168|0,s=0|tt(0|(A|=0),0|(e|=0),56),B(),s&=7,0|(r=0|XA(A,l=-2130706433&e|134217728,i))?(S=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?QA(i,e,s,1,o):FA(i,e,s,1,o),l=o+8|0,n[t>>2]=n[l>>2],n[t+4>>2]=n[l+4>>2],n[t+8>>2]=n[l+8>>2],n[t+12>>2]=n[l+12>>2],S=a,0|(l=0))},establishStackSpace:function(A,e){S=A|=0},stackAlloc:function(A){var e;return e=S,S=15+(S=S+(A|=0)|0)&-16,0|e},stackRestore:function(A){S=A|=0},stackSave:function(){return 0|S}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(A){s=A},c:function(){return s},d:function(A,e,t,r){tA("Assertion failed: "+v(A)+", at: "+[e?v(e):"unknown filename",t,r?v(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){d.set(d.subarray(e,e+t),A)},h:function(A){var e=z(),t=16777216,r=2130706432;if(A>r)return!1;for(var n=Math.max(e,16777216);n0))return 0;for(var n=t+r-1,o=0;o=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++o)),i<=127){if(t>=n)break;e[t++]=i}else if(i<=2047){if(t+1>=n)break;e[t++]=192|i>>6,e[t++]=128|63&i}else if(i<=65535){if(t+2>=n)break;e[t++]=224|i>>12,e[t++]=128|i>>6&63,e[t++]=128|63&i}else{if(t+3>=n)break;e[t++]=240|i>>18,e[t++]=128|i>>12&63,e[t++]=128|i>>6&63,e[t++]=128|63&i}}e[t]=0}(A,d,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,f.set(e,t),r}},o=c(A),i=[],a=0;if(r)for(var s=0;s>1]=e;break;case"i32":h[A>>2]=e;break;case"i64":I=[e>>>0,(L=e,+j(L)>=1?L>0?(0|F(+S(L/4294967296),4294967295))>>>0:~~+N((L-+(~~L>>>0))/4294967296)>>>0:0)],h[A>>2]=I[0],h[A+4>>2]=I[1];break;case"float":m[A>>2]=e;break;case"double":b[A>>3]=e;break;default:tA("invalid type for setValue: "+t)}},t.getValue=function(A,e,t){switch("*"===(e=e||"i8").charAt(e.length-1)&&(e="i32"),e){case"i1":case"i8":return f[0|A];case"i16":return g[A>>1];case"i32":case"i64":return h[A>>2];case"float":return m[A>>2];case"double":return b[A>>3];default:tA("invalid type for getValue: "+e)}return null},R){H(R)||(W=R,R=t.locateFile?t.locateFile(W,o):o+W),P++,t.monitorRunDependencies&&t.monitorRunDependencies(P);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),d.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(P--,t.monitorRunDependencies&&t.monitorRunDependencies(P),0==P&&T){var A=T;T=null,A()}}()},q=function(){n(R,X,function(){throw"could not load memory initializer "+R})},$=O(R);if($)X($.buffer);else if(t.memoryInitializerRequest){var AA=function(){var A=t.memoryInitializerRequest,e=A.response;if(200!==A.status&&0!==A.status){var r=O(t.memoryInitializerRequestURL);if(!r)return void q();e=r.buffer}X(e)};t.memoryInitializerRequest.response?setTimeout(AA,0):t.memoryInitializerRequest.addEventListener("load",AA)}else q()}function eA(A){function e(){V||(V=!0,l||(k(B),k(M),t.onRuntimeInitialized&&t.onRuntimeInitialized(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)Q(t.postRun.shift());k(D)}()))}P>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),P>0||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),e()},1)):e()))}function tA(A){throw t.onAbort&&t.onAbort(A),i(A+=""),a(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(T=function A(){V||eA(),V||(T=A)},t.run=eA,t.abort=tA,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return eA(),A}("object"==typeof ke?ke:{}),Ce="number",Be={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},Me={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function De(A,e,t){var r=t&&"value"in t,n=new Error((A[e]||"Unknown error")+" (code: "+e+(r?", value: "+t.value:"")+")");return n.code=e,n}function Ee(A){if(0!==A)throw function(A,e){return De(Be,A,2===arguments.length?{value:e}:{})}(A)}var Qe={};[["sizeOfH3Index",Ce],["sizeOfLatLng",Ce],["sizeOfCellBoundary",Ce],["sizeOfGeoLoop",Ce],["sizeOfGeoPolygon",Ce],["sizeOfLinkedGeoPolygon",Ce],["sizeOfCoordIJ",Ce],["readInt64AsDoubleFromPointer",Ce],["isValidCell",Ce,[Ce,Ce]],["isValidIndex",Ce,[Ce,Ce]],["latLngToCell",Ce,[Ce,Ce,Ce,Ce]],["cellToLatLng",Ce,[Ce,Ce,Ce]],["cellToBoundary",Ce,[Ce,Ce,Ce]],["maxGridDiskSize",Ce,[Ce,Ce]],["gridDisk",Ce,[Ce,Ce,Ce,Ce]],["gridDiskDistances",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridRing",Ce,[Ce,Ce,Ce,Ce]],["gridRingUnsafe",Ce,[Ce,Ce,Ce,Ce]],["maxPolygonToCellsSize",Ce,[Ce,Ce,Ce,Ce]],["polygonToCells",Ce,[Ce,Ce,Ce,Ce]],["maxPolygonToCellsSizeExperimental",Ce,[Ce,Ce,Ce,Ce]],["polygonToCellsExperimental",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["cellsToLinkedMultiPolygon",Ce,[Ce,Ce,Ce]],["destroyLinkedMultiPolygon",null,[Ce]],["compactCells",Ce,[Ce,Ce,Ce,Ce]],["uncompactCells",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["uncompactCellsSize",Ce,[Ce,Ce,Ce,Ce,Ce]],["isPentagon",Ce,[Ce,Ce]],["isResClassIII",Ce,[Ce,Ce]],["getBaseCellNumber",Ce,[Ce,Ce]],["getResolution",Ce,[Ce,Ce]],["getIndexDigit",Ce,[Ce,Ce,Ce]],["constructCell",Ce,[Ce,Ce,Ce,Ce]],["maxFaceCount",Ce,[Ce,Ce,Ce]],["getIcosahedronFaces",Ce,[Ce,Ce,Ce]],["cellToParent",Ce,[Ce,Ce,Ce,Ce]],["cellToChildren",Ce,[Ce,Ce,Ce,Ce]],["cellToCenterChild",Ce,[Ce,Ce,Ce,Ce]],["cellToChildrenSize",Ce,[Ce,Ce,Ce,Ce]],["cellToChildPos",Ce,[Ce,Ce,Ce,Ce]],["childPosToCell",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["areNeighborCells",Ce,[Ce,Ce,Ce,Ce,Ce]],["cellsToDirectedEdge",Ce,[Ce,Ce,Ce,Ce,Ce]],["getDirectedEdgeOrigin",Ce,[Ce,Ce,Ce]],["getDirectedEdgeDestination",Ce,[Ce,Ce,Ce]],["isValidDirectedEdge",Ce,[Ce,Ce]],["directedEdgeToCells",Ce,[Ce,Ce,Ce]],["originToDirectedEdges",Ce,[Ce,Ce,Ce]],["directedEdgeToBoundary",Ce,[Ce,Ce,Ce]],["gridDistance",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridPathCells",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridPathCellsSize",Ce,[Ce,Ce,Ce,Ce,Ce]],["cellToLocalIj",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["localIjToCell",Ce,[Ce,Ce,Ce,Ce,Ce]],["getHexagonAreaAvgM2",Ce,[Ce,Ce]],["getHexagonAreaAvgKm2",Ce,[Ce,Ce]],["getHexagonEdgeLengthAvgM",Ce,[Ce,Ce]],["getHexagonEdgeLengthAvgKm",Ce,[Ce,Ce]],["greatCircleDistanceM",Ce,[Ce,Ce]],["greatCircleDistanceKm",Ce,[Ce,Ce]],["greatCircleDistanceRads",Ce,[Ce,Ce]],["cellAreaM2",Ce,[Ce,Ce,Ce]],["cellAreaKm2",Ce,[Ce,Ce,Ce]],["cellAreaRads2",Ce,[Ce,Ce,Ce]],["edgeLengthM",Ce,[Ce,Ce,Ce]],["edgeLengthKm",Ce,[Ce,Ce,Ce]],["edgeLengthRads",Ce,[Ce,Ce,Ce]],["getNumCells",Ce,[Ce,Ce]],["getRes0Cells",Ce,[Ce]],["res0CellCount",Ce],["getPentagons",Ce,[Ce,Ce]],["pentagonCount",Ce],["cellToVertex",Ce,[Ce,Ce,Ce,Ce]],["cellToVertexes",Ce,[Ce,Ce,Ce]],["vertexToLatLng",Ce,[Ce,Ce,Ce]],["isValidVertex",Ce,[Ce,Ce]]].forEach(function(A){Qe[A[0]]=ke.cwrap.apply(ke,A)});var je=16,Ne=Qe.sizeOfH3Index(),Se=Qe.sizeOfLatLng(),Fe=Qe.sizeOfCellBoundary();Qe.sizeOfGeoPolygon(),Qe.sizeOfGeoLoop(),Qe.sizeOfLinkedGeoPolygon(),Qe.sizeOfCoordIJ();var Pe=/[^0-9a-fA-F]/;function Te(A){if(A>=0)return A.toString(je);var e=Le(8,(A&=2147483647).toString(je));return(parseInt(e[0],je)+8).toString(je)+e.substring(1)}function Le(A,e){for(var t=A-e.length,r="",n=0;n.85?.9+(i-.85)/.15*.1:.1+(i-.15)/.7*.8;var i;return We(r[Math.min(23,Math.floor(24*o))])}function Ze({coveragePoints:t,visible:r,terrainEnabled:n=!1,brightness:o=.7,basemapMode:i="dark"}){const{current:a}=I(),[s,l]=A.useState(null);A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==a?void 0:a.getMap)?void 0:A.call(a);e&&!s&&l(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[a,s]);const[c,u]=A.useState(null),[f,d]=A.useState(!1),g=A.useRef({aborted:!1}),h=A.useRef(0),m=A.useRef(i),b=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(t),p=A.useMemo(()=>function(A="dark"){var e;if("light"===A)return Ye;const t=vA();return 24===t.length&&0!==(null==(e=t[0])?void 0:e[0])?t:Ue}(i),[i]);A.useEffect(()=>{if(!b||!Array.isArray(b)||0===b.length)return void queueMicrotask(()=>{u(null),h.current=0});const A=m.current!==i;if(b.length===h.current&&c&&!A)return;h.current=b.length,m.current=i,g.current.aborted=!0,g.current={aborted:!1};const e=g.current;d(!0);const{cells:t,minQuality:r,maxQuality:n}=function(A){const e=new Map;for(const o of A){if("number"!=typeof o.lat||"number"!=typeof o.lon||isNaN(o.lat)||isNaN(o.lon))continue;const A=_e(o.lat,o.lon,8),t=e.get(A),r=o.weight;t?(t.count++,t.qualitySum+=r):e.set(A,{count:1,qualitySum:r})}const t=[];let r=1/0,n=-1/0;for(const[o,i]of e.entries()){const A=i.qualitySum/i.count;t.push({hexId:o,count:i.count,avgQuality:A}),r=Math.min(r,A),n=Math.max(n,A)}return{cells:t,minQuality:t.length>0?r:0,maxQuality:t.length>0?n:0}}(b);if(0===t.length)return u(null),void d(!1);if(t.length<500){const A=function(A,e,t,r){const n=[];for(const o of A){const A=He(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=Ve(o.avgQuality,e,t,r);n.push({type:"Feature",properties:{color:i,quality:o.avgQuality,count:o.count},geometry:{type:"Polygon",coordinates:[A]}})}return{type:"FeatureCollection",features:n}}(t,r,n,p);return void(e.aborted||(u(A),d(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=Ve(n.avgQuality,e,t,r);o.push({type:"Feature",properties:{color:s,quality:n.avgQuality,count:n.count},geometry:{type:"Polygon",coordinates:[a]}})}irequestAnimationFrame(A))}return{type:"FeatureCollection",features:o}}(t,r,n,p,e).then(A=>{!e.aborted&&A&&u(A)}).finally(()=>{e.aborted||d(!1)}),()=>{e.aborted=!0}},[b,p]),A.useEffect(()=>{if(!s)return;const A=()=>{var A,e;try{const t=s.getLayer(Oe),n=s.getSource(Ge);if(r&&c&&c.features.length>0){if(n?s.getSource(Ge).setData(c):s.addSource(Ge,{type:"geojson",data:c}),!t){const t=s.getLayer("topology-weak-edges-native"),r=null==(e=null==(A=s.getStyle())?void 0:A.layers)?void 0:e.find(A=>"symbol"===A.type),n=t?"topology-weak-edges-native":null==r?void 0:r.id;s.addLayer({id:Oe,type:"fill",source:Ge,paint:{"fill-color":["get","color"],"fill-opacity":o}},n)}}else t&&s.removeLayer(Oe),n&&s.removeSource(Ge)}catch(t){}};s.isStyleLoaded()?A():s.once("style.load",A)},[s,r,c,n]),A.useEffect(()=>{if(s&&r)try{s.getLayer(Oe)&&s.setPaintProperty(Oe,"fill-opacity",o)}catch{}},[s,o,r]),A.useEffect(()=>()=>{if(s)try{s.getLayer(Oe)&&s.removeLayer(Oe),s.getSource(Ge)&&s.removeSource(Ge)}catch{}},[s]);const v=(null==c?void 0:c.features.length)??0;return v>0&&r?e.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==t?void 0:t.length)||0,"data-cell-count":v,"data-terrain-enabled":n,"data-is-processing":f,style:{display:"none"}}):null}const Ke="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Je="terrarium",Xe="terrain-dem",qe="hillshade-dem",$e="terrain-hillshade";function At({enabled:e,exaggeration:t=4}){const{current:r}=I(),[n,o]=A.useState(null),i=A.useRef(null);return A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);e&&!n&&o(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[r,n]),A.useEffect(()=>{if(!n)return;let A=!0;const e=()=>{var e,t;if(A)try{if(n.getSource(qe)||n.addSource(qe,{type:"raster-dem",tiles:[Ke],encoding:Je,tileSize:256,maxzoom:14}),!n.getLayer($e)){const A=null==(t=null==(e=n.getStyle())?void 0:e.layers)?void 0:t.find(A=>"symbol"===A.type);n.addLayer({id:$e,type:"hillshade",source:qe,paint:{"hillshade-shadow-color":"rgba(10, 10, 10, 0.6)","hillshade-highlight-color":"rgba(245, 240, 230, 0.4)","hillshade-accent-color":"rgba(90, 75, 65, 0.3)","hillshade-illumination-direction":315,"hillshade-exaggeration":.35}},null==A?void 0:A.id)}n.getSource(Xe)||n.addSource(Xe,{type:"raster-dem",tiles:[Ke],encoding:Je,tileSize:256,maxzoom:14})}catch(r){}};return n.isStyleLoaded()?e():(n.once("style.load",e),n.once("load",()=>{A&&!n.getSource(qe)&&e()})),()=>{A=!1}},[n]),A.useEffect(()=>{if(!n)return;let A=!0,r=!1;const o=()=>{if(A&&n.getSource(Xe))try{e?(n.setCenterClampedToGround(!1),n.setTerrain({source:Xe,exaggeration:t}),n.setMaxPitch(70),!r&&n.getPitch()<30&&!n.isMoving()&&(r=!0,null!==i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,A&&!n.isMoving()&&n.getPitch()<30&&n.easeTo({pitch:45,duration:1e3})},200))):(n.setTerrain(null),n.setCenterClampedToGround(!0),n.getPitch()>0&&!n.isMoving()&&n.easeTo({pitch:0,duration:800}),n.setMaxPitch(60))}catch(o){}};if(n.isStyleLoaded()&&n.getSource(Xe))o();else{const A=()=>{n.getSource(Xe)&&o()};n.once("idle",A)}return()=>{A=!1,null!==i.current&&(clearTimeout(i.current),i.current=null)}},[n,e,t]),A.useEffect(()=>()=>{var A;try{(null==(A=null==n?void 0:n.getStyle)?void 0:A.call(n))&&n.isStyleLoaded()&&(n.setTerrain(null),n.getLayer($e)&&n.removeLayer($e),n.getSource(qe)&&n.removeSource(qe),n.getSource(Xe)&&n.removeSource(Xe))}catch{}},[n]),null}function et(A,e){let t=0;for(let r=0;r0)for(let t=0;t=A.length)return A;const t=[],r=A.length/e;for(let n=0;no.has(A.fromHash)&&o.has(A.toHash));if(0===i.length)return null;const a=function(A,e,t,r){const n=e.length,o=new Map(e.map((A,e)=>[A,e])),i=Array(n).fill(null).map(()=>Array(n).fill(0));for(const a of A){const A=o.get(a.fromHash),e=o.get(a.toHash);if(void 0!==A&&void 0!==e&&A!==e){const n=a.strength*a.certainCount;let o=1;if(t){const A=t.get(a.fromHash),e=t.get(a.toHash);A&&e&&(o=ot(FA(A[0],A[1],e[0],e[1])/1e3))}let s=1;if(r){const A=[a.fromHash,a.toHash].sort().join("-");s=1-.7*(r.get(A)??0)}const l=.3+.7*(a.symmetryRatio??0),c=Math.pow(n,.7)*Math.pow(o,.3)*s*l;i[A][e]=c,i[e][A]=c}}return i}(i,e,t,r),s=function(A){const e=A.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let r=0;rArray(e).fill(0));for(let a=0;a43758.5453*Math.sin(12.9898*e)%1-.5);rt(o,t),tt(o);let i=0;for(let a=0;a<100;a++){const A=nt(n,o);rt(A,t);const e=et(A,A)/et(o,A);if(tt(A),o=A,Math.abs(e-i)<1e-8)return{vector:o,eigenvalue:r-e};i=e}return{vector:o,eigenvalue:r-i}}(s);if(c<.001)return null;const u=[],f=[];for(let d=0;d0&&A.push([A[0][0],A[0][1]]),t=A}return t}function gt(A,e={}){const t=function(A,e={}){if(A.length<3)return{coordinates:[],valid:!1};const{bandwidth:t=ct,threshold:r=ut,cellSize:n=ft}=e,o=function(A,e){let t=1/0,r=-1/0,n=1/0,o=-1/0;for(const[i,a]of A)ir&&(r=i),ao&&(o=a);return t-=e,r+=e,n-=e,o+=e,{minX:t,minY:n,maxX:r,maxY:o,width:r-t,height:o-n}}(A,.02),i=Math.ceil(o.width/(t/2)),a=Math.ceil(o.height/(t/2)),s=Math.min(1,200/Math.max(i,a)),l=Math.max(10,Math.ceil(i*s)),c=Math.max(10,Math.ceil(a*s)),u=A=>A/l*o.width+o.minX,f=A=>A/c*o.height+o.minY,d=t/o.width*l;try{const e=kA().x(A=>(A[0]-o.minX)/o.width*l).y(A=>(A[1]-o.minY)/o.height*c).size([l,c]).bandwidth(Math.max(5,d)).cellSize(n)(A);if(0===e.length)return{coordinates:[],valid:!1};const t=Math.max(...e.map(A=>A.value))*r;let i=e[0],a=1/0;for(const A of e){const e=Math.abs(A.value-t);e0){const e=A[0],t=A[A.length-1];e[0]===t[0]&&e[1]===t[1]||A.push([e[0],e[1]])}if(A.length>=4){const t=dt(A);e.push(t)}}e.length>0&&s.push(e)}const g=[];for(const A of s)for(const e of A)g.push(e);return{coordinates:s,valid:s.length>0}}catch(g){return{coordinates:[],valid:!1}}}(A,e);return t.valid&&0!==t.coordinates.length?1===t.coordinates.length?{type:"Polygon",coordinates:t.coordinates[0]}:{type:"MultiPolygon",coordinates:t.coordinates}:null}function ht(A,e,t){return(e[0]-A[0])*(t[1]-A[1])-(e[1]-A[1])*(t[0]-A[0])}function mt(A,e,t,r,n){const o=n*n,i=o*n;return[.5*(2*e[0]+(-A[0]+t[0])*n+(2*A[0]-5*e[0]+4*t[0]-r[0])*o+(-A[0]+3*e[0]-3*t[0]+r[0])*i),.5*(2*e[1]+(-A[1]+t[1])*n+(2*A[1]-5*e[1]+4*t[1]-r[1])*o+(-A[1]+3*e[1]-3*t[1]+r[1])*i)]}function bt(A){let e=function(A){if(A.length<3)return A;const e=[...A].sort((A,e)=>A[0]-e[0]||A[1]-e[1]),t=[];for(const n of e){for(;t.length>=2&&ht(t[t.length-2],t[t.length-1],n)<=0;)t.pop();t.push(n)}const r=[];for(let n=e.length-1;n>=0;n--){const A=e[n];for(;r.length>=2&&ht(r[r.length-2],r[r.length-1],A)<=0;)r.pop();r.push(A)}return t.pop(),r.pop(),t.concat(r)}(A);if(e.length<3)return null;e=function(A){if(A.length<3)return A;let e=0,t=0;for(const[r,n]of A)e+=r,t+=n;return e/=A.length,t/=A.length,A.map(([A,r])=>{const n=A-e,o=r-t,i=Math.sqrt(n*n+o*o);if(i<1e-4)return[A,r];const a=(i+.008)/i;return[e+n*a,t+o*a]})}(e);const t=function(A){if(A.length<3)return A;const e=[],t=A.length;for(let r=0;rt?function(A,e,t,r){const n=[];for(const[o,i]of A.communities){const A=[];for(const t of i){const r=e.get(t);r&&A.push([r[1],r[0]])}if(A.length<3)continue;let a=gt(A,{bandwidth:t,threshold:r});a||(a=bt(A)),a&&n.push({type:"Feature",properties:{community:o,color:st(o),borderColor:lt(o),nodeCount:i.length},geometry:a})}return{type:"FeatureCollection",features:n}}(t,r,i,a):{type:"FeatureCollection",features:[]},[t,r,i,a]),c=n?o:0,u={"fill-color":["get","color"],"fill-opacity":c},f={"line-color":["get","borderColor"],"line-width":s,"line-opacity":c};return e.jsxs(R,{id:"mincut-partition",type:"geojson",data:l,children:[e.jsx(_,{id:"mincut-partition-fill",type:"fill",paint:u}),e.jsx(_,{id:"mincut-partition-stroke",type:"line",paint:f})]})}const vt={showTopology:!1,showNeighborLines:!0,show3DTerrain:!1,showMinCut:!1,nodeFilter:"all"},wt=C()(xA(A=>({viewState:null,setViewState:e=>A({viewState:e,lastSavedAt:Date.now()}),toggles:vt,setToggle:(e,t)=>A(A=>({toggles:{...A.toggles,[e]:t},lastSavedAt:Date.now()})),setToggles:e=>A(A=>({toggles:{...A.toggles,...e},lastSavedAt:Date.now()})),hasAnalyzed:!1,setHasAnalyzed:e=>A({hasAnalyzed:e,lastSavedAt:Date.now()}),lastSavedAt:null,reset:()=>A({viewState:null,toggles:vt,hasAnalyzed:!1,lastSavedAt:null})}),{name:"pymc-map-view",partialize:A=>({viewState:A.viewState,toggles:A.toggles,hasAnalyzed:A.hasAnalyzed,lastSavedAt:A.lastSavedAt})}));function xt(A,e=!1,t=!1,r=!1,n=.7,o){const i=bA(o);return r?n>=.75?i.restBright:i.rest:n>=.85?i.rest:i.restDim}function yt(A){return[A[1],A[0]]}function kt(A,e,t,r=12){const[n,o]=A,[i,a]=e,s=[];for(let l=0;l<=r;l++){const A=l/r,e=o+(a-o)*A,c=n+(i-n)*A,u=4*t*A*(1-A);s.push([e,c,u])}return s}function Ct(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Bt(A,e,t,r,n,o,i,a,s,l,c,u="dark"){const f=LA(),d=[];let g=1/0,h=-1/0;const m=[];for(const p of A){const A=.7*(p.edge.avgConfidence??(e?.7:.5))+p.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);m.push({polyline:p,brightnessScore:A}),g=Math.min(g,A),h=Math.max(h,A)}if(0===m.length)return{type:"FeatureCollection",features:[]};const b=h-g||1;m.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:p,brightnessScore:v}of m){const{from:A,to:i,edge:h}=p,m=t.get(h.key)??0;if(m<=0)continue;const w=a.has(h.key),x=s.has(h.key),y=h.avgConfidence??(e?.7:.5),k=l===h.key,C=c[h.fromHash],B=c[h.toHash],M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||h.fromHash.slice(0,8),D=(null==B?void 0:B.node_name)||(null==B?void 0:B.name)||h.toHash.slice(0,8),E=[A[0]+(i[0]-A[0])*m,A[1]+(i[1]-A[1])*m];let Q,j,N,S;if(e){const A=o.get(h.key)??PA(h.certainCount),e=n.get(h.key)??A;Q=e+(A-e)*r,k?Q=Math.max(1.6*Q,4.5):x&&(Q*=1.3)}else Q=1.5;if(j=k?f.edges.highlight:xt(0,h.isDirectPathEdge??!1,w,x,y,u),N=k?f.edges.highlight:h.isDirectPathEdge?f.edges.hoverDirect:w?f.edges.hoverLoop:f.edges.hoverStandard,e){const A=Math.min(1.5*m,1)*f.edgeOpacity;S=x?1.15*A:A}else S=(.3+.3*y)*m;k&&(S=.95);const F=(v-g)/b;d.push({type:"Feature",properties:{key:h.key,baseColor:j,hoverColor:N,baseWidth:Q,baseOpacity:S,brightnessScore:F,isLoopEdge:w,isBackbone:x,isDirectPath:h.isDirectPathEdge??!1,isHubConnection:h.isHubConnection??!1,isZeroHop:h.isZeroHop??!1,isValidated:e,certainCount:h.certainCount,confidence:y,symmetryRatio:h.symmetryRatio??1,dominantDirection:h.dominantDirection??"balanced",fromName:M,toName:D,fromHash:h.fromHash,toHash:h.toHash},geometry:{type:"LineString",coordinates:[yt(A),yt(E)]}})}return{type:"FeatureCollection",features:d}}function Mt(A,e){const t=LA(),r=[];let n=0;for(const o of A){const A=e.get(o.hash);A&&A.blendedScore>n&&(n=A.blendedScore)}for(const o of A){const{from:A,to:i,hash:a,neighbor:s,lastHopData:l}=o,c=`neighbor-${a}`,u=(null==l?void 0:l.avgRssi)??s.rssi??null,f=(null==l?void 0:l.avgSnr)??s.snr??null,d=(null==l?void 0:l.count)??0,g=(null==l?void 0:l.confidence)??1,h=e.get(a),m=(null==h?void 0:h.listenerScore)??0,b=(null==h?void 0:h.loudScore)??0,p=(null==h?void 0:h.blendedScore)??0,v=n>0?p/n:0,w=o.rxAdvertCount??0,x=o.txProxyCount??0,y=w+x,k=y>0?(x-w)/y:0,C=kt(A,i,150,8);r.push({type:"Feature",properties:{key:c,hash:a,name:s.node_name||s.name||a.slice(0,8),prefix:a.slice(2,4).toUpperCase(),color:t.neighborColor,width:2.5,opacity:.85,rssi:u,snr:f,packetCount:d,confidence:g,hasAvgRssi:void 0!==(null==l?void 0:l.avgRssi),hasAvgSnr:void 0!==(null==l?void 0:l.avgSnr),isNeighborEdge:!0,listenerScore:m,loudScore:b,blendedScore:p,trafficWeight:v,linkAsymmetry:k,rxAdvertCount:w,txProxyCount:x},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Dt(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Et(A,e){if(A<240)return.5;if(A<480)return 1;const t=(A-480)/(e-480);return Math.max(0,.33*(1-t))}function Qt(A,e,t){const r=t?nA(t):null,n=[];for(const o of A){if(r&&o.toUpperCase()===r){t&&n.push(t);continue}const A=e.get(o.toUpperCase());A&&n.push(A)}return n}const jt="edge-blink-source",Nt="edge-blink-layer",St=1e3,Ft=1e3,Pt="node-markers-layer";function Tt(A){return A<0||A>=St?0:1-A/St}function Lt(A){if(A<0)return 0;if(A>=Ft)return 0;const e=A/Ft;return Math.pow(1-e,3)}function It(A){return[A[1],A[0]]}function Rt(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function _t({txDelayRec:t,onRemove:r}){const[n,o]=A.useState(!1),i=t.floodFactor??t.txDelayFactor,a=t.directFactor??t.directTxDelayFactor;return e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[e.jsxs("button",{onClick:async()=>{const A=`set txdelay ${i.toFixed(1)}\nset direct.txdelay ${a.toFixed(1)}`;try{await navigator.clipboard.writeText(A),o(!0),setTimeout(()=>o(!1),1500)}catch(e){const t=document.createElement("textarea");t.value=A,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),o(!0),setTimeout(()=>o(!1),1500)}catch{}document.body.removeChild(t)}},className:"flex items-center gap-2 flex-1 py-1 px-1.5 bg-amber-400/5 hover:bg-amber-400/10 rounded transition-colors group",title:"Click to copy CLI commands",children:[e.jsx(U,{className:"w-3 h-3 text-amber-400 shrink-0"}),e.jsx("span",{className:"text-text-muted",children:"TxDelay"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-text-muted",children:"F"}),e.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",i.toFixed(1)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-text-muted",children:"D"}),e.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",a.toFixed(1)]})]})]}),n?e.jsx(E,{className:"w-3 h-3 text-green-400 ml-auto"}):e.jsx(H,{className:"w-3 h-3 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]}),r&&e.jsx("button",{onClick:r,className:"p-1 text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:e.jsx(N,{className:"w-3.5 h-3.5"})})]})}function Ht({hash:t,hashPrefix:r,name:n,isHub:o,isGateway:i,isBackbone:a,isZeroHop:s,isMobile:l,isRoomServer:c,isStale:u,lastSeenTimestamp:f,centrality:d,affinity:g,meanSnr:h,meanRssi:m,neighbor:b,onRemove:p,txDelayRec:v}){const[w,x]=A.useState(!1),y=s?"Direct":(null==g?void 0:g.typicalHopPosition)?`${g.typicalHopPosition}-hop`:null,k=v&&!v.insufficientData;return e.jsxs("div",{className:"w-[240px] pr-2",children:[e.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-tight truncate mb-1",children:n}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[e.jsx("code",{className:"font-mono text-[10px] text-text-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:r}),e.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),1500)}catch(A){const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy"),x(!0),setTimeout(()=>x(!1),1500)}catch{}document.body.removeChild(e)}},className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:w?e.jsx(E,{className:"w-3 h-3 text-sys-green"}):e.jsx(H,{className:"w-3 h-3 text-text-secondary"})}),e.jsx(DA,{hash:t,size:"sm"}),y&&e.jsx(iA,{color:s?QA.direct:QA.multihop,compact:!0,children:y}),b.is_repeater&&e.jsx(iA,{color:jA.repeater,compact:!0,children:"Rptr"}),o&&e.jsx(iA,{color:jA.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),i&&!o&&e.jsx(iA,{color:jA.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),a&&e.jsx(iA,{color:jA.backbone,compact:!0,title:"Backbone",children:"Bone"}),l&&e.jsx(iA,{color:jA.mobile,compact:!0,children:"Mobile"}),c&&e.jsx(iA,{color:jA.room,compact:!0,children:"Room"}),u&&f&&e.jsxs(iA,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Rt(f)]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-secondary mb-1.5",children:[e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(z,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsx("span",{className:"font-mono",children:aA(b.last_seen)})]}),(null==g?void 0:g.distanceMeters)&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(G,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(C=g.distanceMeters,null===C?"—":C<1e3?`${Math.round(C)}m`:`${(C/1e3).toFixed(1)}km`)})]}),b.latitude&&b.longitude&&0!==b.latitude&&0!==b.longitude&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(O,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsxs("span",{className:"font-mono text-text-muted",children:[b.latitude.toFixed(2),", ",b.longitude.toFixed(2)]})]})]}),e.jsx("div",{className:"mb-1.5",style:{width:224},children:e.jsx(EA,{nodeHash:t,width:224,height:26,showArea:!0,showTooltip:!0})}),e.jsxs("div",{className:"flex gap-3 text-[10px] mb-1.5",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Packets"}),e.jsx("span",{className:"data-box data-box-compact",children:(null==g?void 0:g.frequency)||0})]}),s&&void 0!==h&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"SNR"}),e.jsxs("span",{className:"data-box data-box-compact",children:[h.toFixed(1)," dB"]})]}),k&&v.networkRole&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Role"}),e.jsx(iA,{color:NA[v.networkRole],compact:!0,title:{hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"}[v.networkRole],children:v.networkRole})]})]}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Adverts"}),e.jsx("span",{className:"data-box data-box-compact",children:b.advert_count||0})]}),s&&void 0!==m&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"RSSI"}),e.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(m)," dBm"]})]}),k&&v.dataConfidence&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Data"}),e.jsx(iA,{color:SA[v.dataConfidence],compact:!0,title:{high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"}[v.dataConfidence],children:v.dataConfidence})]})]}),!k&&p&&e.jsx("button",{onClick:p,className:"p-1 self-start text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:e.jsx(N,{className:"w-3.5 h-3.5"})})]}),k&&e.jsx(_t,{txDelayRec:v,onRemove:p})]});var C}const zt="node-markers-native",Gt="node-markers-layer",Ot="node-markers-layer-local",Ut="marker-standard",Yt="marker-standard-neighbor",Wt="marker-hub",Vt="marker-hub-neighbor",Zt="marker-gateway",Kt="marker-gateway-neighbor",Jt="marker-mobile",Xt="marker-mobile-neighbor",qt="marker-room-server",$t="marker-room-server-neighbor",Ar="marker-local",er="marker-blink-black",tr="marker-blink-black-local",rr="marker-blink",nr="marker-blink-local";function or(A){var e;const t=null==(e=A.contact_type)?void 0:e.toLowerCase();return"room server"===t||"room_server"===t||"room"===t||"server"===t}function ir(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function ar({neighborsWithLocation:t,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:f,openPopupId:d,onOpenPopup:g,onClosePopup:h,onNodeClick:m,blinkingNodes:b}){const{current:p}=I(),v=A.useRef(!1),[w,x]=A.useState(!1);A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e)return;const t=()=>{try{!function(A){const e=mA(),t=(A,e,t=0,r=!1)=>{const n=document.createElement("canvas");n.width=32,n.height=32;const o=n.getContext("2d",r?{colorSpace:"display-p3"}:void 0),i=14-t/2;return o.beginPath(),o.arc(16,16,i,0,2*Math.PI),o.fillStyle=A,o.fill(),e&&t>0&&(o.strokeStyle=e,o.lineWidth=2*t,o.stroke()),o.shadowColor="rgba(0,0,0,0.3)",o.shadowBlur=4,o.shadowOffsetY=2,{data:o.getImageData(0,0,32,32),pixelRatio:2}},r=(A,e=!1)=>{const t=document.createElement("canvas");t.width=48,t.height=48;const r=t.getContext("2d",e?{colorSpace:"display-p3"}:void 0),n=24*.35*2;return r.strokeStyle=A,r.lineWidth=5,r.lineCap="round",r.lineJoin="round",r.beginPath(),r.moveTo(24-n,24),r.lineTo(24,24-n),r.lineTo(40.8,24),r.stroke(),r.beginPath(),r.moveTo(24-.7*n,24),r.lineTo(24-.7*n,35.76),r.lineTo(35.76,35.76),r.lineTo(35.76,24),r.stroke(),r.beginPath(),r.moveTo(20.64,35.76),r.lineTo(20.64,27.36),r.lineTo(27.36,27.36),r.lineTo(27.36,35.76),r.stroke(),{data:r.getImageData(0,0,48,48),pixelRatio:2}},n=(A,e)=>{const t=document.createElement("canvas");t.width=48,t.height=48;const r=t.getContext("2d"),n=24*.35*2;return r.strokeStyle=A,r.lineWidth=5,r.lineCap="round",r.lineJoin="round",e&&(r.fillStyle=e),r.beginPath(),r.roundRect(24-n,24-.6*n,1.6*n,1.2*n,6),e&&r.fill(),r.stroke(),r.beginPath(),r.moveTo(18.96,34.08),r.lineTo(24-.6*n,40.8),r.lineTo(24,34.08),r.stroke(),{data:r.getImageData(0,0,48,48),pixelRatio:2}},o="#00FF00",i={[Ut]:t(e.nodeFill),[Yt]:t(e.neighborColor),[Wt]:t(e.hubColor),[Vt]:t(e.neighborColor),[Zt]:t(e.gatewayColor),[Kt]:t(e.neighborColor),[Jt]:t("transparent",e.mobileColor,2.5),[Xt]:t(e.neighborColor),[qt]:n(e.roomColor),[$t]:n(e.neighborColor,"#1a1a1c"),[Ar]:r(e.localColor),[er]:t("#000000"),[tr]:r("#000000"),[rr]:t(o,void 0,0,!0),[nr]:r(o,!0)};for(const[a,s]of Object.entries(i))A.hasImage(a)&&A.removeImage(a),A.addImage(a,s.data,{pixelRatio:s.pixelRatio})}(e),v.current=!0,w||x(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{e.hasImage(Ut)||t()};e.on("styledata",r);const n=()=>{v.current=!1,t()},o=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(n,100);break}});o.observe(document.documentElement,{attributes:!0});const i=document.querySelector("[data-basemap]");let a=null;return i&&(a=new MutationObserver(A=>{for(const e of A)if("data-basemap"===e.attributeName){setTimeout(n,100);break}}),a.observe(i,{attributes:!0})),()=>{e.off("styledata",r),o.disconnect(),null==a||a.disconnect()}},[p,w]);const y=A.useMemo(()=>{var A;const e=[],r=[...t].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return or(e)?5e3:o.has(A)?3e3:a.hubNodes.includes(A)?2e3:(null==(t=a.gatewayNodes)?void 0:t.includes(A))?1e3:0};return n(A,e)-n(t,r)});for(const[t,s]of r){if(!s.latitude||!s.longitude)continue;if(n&&((n.startsWith("0x")?n.slice(2,4).toLowerCase():n.slice(0,2).toLowerCase())===(t.startsWith("0x")?t.slice(2,4).toLowerCase():t.slice(0,2).toLowerCase())||t===n))continue;const r=u(t),l=c(t,r);if(l<=.01)continue;const f=o.has(t),d=a.hubNodes.includes(t),g=(null==(A=a.gatewayNodes)?void 0:A.includes(t))??!1,h=a.mobileNodes.includes(t),m=or(s),b=a.centrality.get(t)||0,p=i.get(t),v="stale"===(null==p?void 0:p.status),w=v?Math.min(l,.5):l;let x="standard";m?x="roomServer":d?x="hub":g?x="gateway":h&&(x="mobile");const y=a.fullAffinity.get(t),k=a.txDelayRecommendations.get(t);e.push({type:"Feature",geometry:{type:"Point",coordinates:[s.longitude,s.latitude]},properties:{hash:t,name:s.node_name||s.name||"Unknown",hashPrefix:ir(t),iconType:x,isNeighbor:f,isHub:d,isGateway:g,isMobile:h,isRoomServer:m,isStale:v,isZeroHop:f,opacity:w,blinkIntensity:0,lastSeenTimestamp:null==p?void 0:p.lastSeen,centrality:b,neighborJson:JSON.stringify(s),affinityJson:y?JSON.stringify(y):void 0,txDelayRecJson:k?JSON.stringify(k):void 0,meanSnr:(null==p?void 0:p.avgSnr)??void 0,meanRssi:(null==p?void 0:p.avgRssi)??void 0}})}return{type:"FeatureCollection",features:e}},[t,n,o,i,a,c,u]),k=A.useMemo(()=>(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)?{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[r.longitude,r.latitude]},properties:{hash:"local",name:r.name,hashPrefix:n?ir(n):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]}:{type:"FeatureCollection",features:[]},[r,n]),C=A.useCallback(A=>{var e;if(!A.features||0===A.features.length)return;const t=null==(e=A.features[0].properties)?void 0:e.hash;t&&(g&&g(t),m&&"local"!==t&&m(t))},[g,m]),B=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;const r=null==(e=null==p?void 0:p.getMap)?void 0:e.call(p);r&&(r.getCanvas().style.cursor="pointer");const n=null==(t=A.features[0].properties)?void 0:t.hash;n&&l(n)},[p,l]),M=A.useCallback(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);e&&(e.getCanvas().style.cursor=""),l(null)},[p,l]);A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e||!w)return;const t=[Gt,Ot];for(const r of t)e.on("click",r,C),e.on("mouseenter",r,B),e.on("mouseleave",r,M);return()=>{for(const A of t)e.off("click",A,C),e.off("mouseenter",A,B),e.off("mouseleave",A,M)}},[p,w,C,B,M]);const D=A.useRef(y),E=A.useRef(k);A.useEffect(()=>{D.current=y,E.current=k},[y,k]),A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e||!w||!b||0===b.size)return;const t=e.getSource(zt),r=e.getSource(`${zt}-local`);if(t||r){if(t){const A=D.current;let e=!1;const r=A.features.map(A=>{const t=b.get(A.properties.hash)??0;return t!==A.properties.blinkIntensity?(e=!0,{...A,properties:{...A.properties,blinkIntensity:t}}):A});e&&t.setData({type:"FeatureCollection",features:r})}if(r&&n){const A=b.get(n)??0,e=E.current;e.features.length>0&&e.features[0].properties.blinkIntensity!==A&&r.setData({type:"FeatureCollection",features:[{...e.features[0],properties:{...e.features[0].properties,blinkIntensity:A}}]})}}},[p,w,b,n]);const Q=A.useMemo(()=>{if(!d)return null;if("local"===d&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=y.features.find(A=>A.properties.hash===d);if(!A)return null;const e=A.properties,t=e.txDelayRecJson?JSON.parse(e.txDelayRecJson):void 0;return{longitude:A.geometry.coordinates[0],latitude:A.geometry.coordinates[1],isLocal:!1,hash:e.hash,hashPrefix:e.hashPrefix,name:e.name,isHub:e.isHub,isGateway:e.isGateway,isBackbone:"backbone"===(null==t?void 0:t.networkRole),isZeroHop:e.isZeroHop,isMobile:e.isMobile,isRoomServer:e.isRoomServer,isStale:e.isStale,lastSeenTimestamp:e.lastSeenTimestamp,centrality:e.centrality,neighbor:e.neighborJson?JSON.parse(e.neighborJson):void 0,affinity:e.affinityJson?JSON.parse(e.affinityJson):void 0,txDelayRec:t,meanSnr:e.meanSnr,meanRssi:e.meanRssi}},[d,r,n,y]);if(!w)return null;const j=mA(),N=["case",[">",["get","blinkIntensity"],.66],rr,[">",["get","blinkIntensity"],.33],er,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],$t,qt],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],Vt,Wt],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],Kt,Zt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],Xt,Jt],["case",["get","isNeighbor"],Yt,Ut]],S=["interpolate",["linear"],["zoom"],6,.25,10,1];return e.jsxs(e.Fragment,{children:[e.jsx(R,{id:zt,type:"geojson",data:y,children:e.jsx(_,{id:Gt,type:"symbol",layout:{"icon-image":N,"icon-size":S,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),e.jsx(R,{id:`${zt}-local`,type:"geojson",data:k,children:e.jsx(_,{id:Ot,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],nr,[">",["get","blinkIntensity"],.33],tr,Ar],"icon-size":S,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),Q&&h&&e.jsx(Y,{longitude:Q.longitude,latitude:Q.latitude,offset:{center:[0,0],top:[0,12],"top-left":[6,12],"top-right":[-6,12],bottom:[0,-12],"bottom-left":[6,-12],"bottom-right":[-6,-12],left:[12,0],right:[-12,0]},maxWidth:"280px",closeOnClick:!0,onClose:h,className:"maplibre-popup",children:Q.isLocal?e.jsxs("div",{className:"text-sm",children:[e.jsx("strong",{className:"text-base",children:Q.name}),Q.hash&&e.jsx("span",{className:"ml-2 font-mono text-xs text-text-muted bg-surface-elevated px-1.5 py-0.5 rounded",children:ir(Q.hash)}),e.jsx("br",{}),e.jsx("span",{style:{color:j.localColor},className:"font-medium",children:"This Node (Local)"}),e.jsx("br",{}),r&&e.jsxs("span",{className:"text-xs text-text-muted",children:[r.latitude.toFixed(5),", ",r.longitude.toFixed(5)]})]}):Q.neighbor&&Q.hash?e.jsx(Ht,{hash:Q.hash,hashPrefix:Q.hashPrefix,name:Q.name,isHub:Q.isHub,isGateway:Q.isGateway,isBackbone:Q.isBackbone,isZeroHop:Q.isZeroHop,isMobile:Q.isMobile,isRoomServer:Q.isRoomServer,isStale:Q.isStale,lastSeenTimestamp:Q.lastSeenTimestamp,centrality:Q.centrality,affinity:Q.affinity,meanSnr:Q.meanSnr,meanRssi:Q.meanRssi,neighbor:Q.neighbor,txDelayRec:Q.txDelayRec,onRemove:f?()=>f(Q.hash,Q.name):void 0}):null})]})}const sr=[Gt,Ot];A.createContext(null);const lr="topology-validated-edges-native",cr="topology-weak-edges-native",ur="neighbor-edges-native",fr="topology-weak-edges-native",dr="topology-validated-edges-native",gr="neighbor-edges-native",hr={type:"FeatureCollection",features:[]},mr={"line-cap":"round","line-join":"round"},br={"line-color":"transparent","line-width":16,"line-opacity":0};function pr({showTopology:t,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,highlightedFocusEdges:i,onEdgeHover:a,onLoopHover:s,loops:l=[],neighborNames:c={},opacityBias:u=.5,widthMultiplier:f=1,trafficFilter:d=0,showNeighborLines:g=!0,disableHover:h=!1}){const{current:m}=I(),b=t||r,p=!0,v=g?"visible":"none",w=h||r,x=A.useRef(null),y=A.useRef(w),k=A.useRef(new Map),C=A.useRef(c),B=A.useRef(s);A.useLayoutEffect(()=>{y.current=w,C.current=c,B.current=s});const M=A.useMemo(()=>function(A){const e=new Map;for(const t of A)for(const A of t.edgeKeys){const r=e.get(A)??[];r.push(t),e.set(A,r)}return e}(l),[l]);A.useLayoutEffect(()=>{k.current=M},[M]);const D=A.useCallback(A=>{var e,t;if(y.current)return;if(!A.features||0===A.features.length)return;const r=A.features[0].properties;if(!(null==r?void 0:r.key))return;const n=r.key;if(n!==x.current){x.current=n;const o=!0===r.isNeighborEdge||"true"===r.isNeighborEdge,i=!0===r.isLoopEdge||"true"===r.isLoopEdge;if(o){const t={key:n,fromName:"Local",toName:r.name,certainCount:Number(r.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};a(n,[A.lngLat.lng,A.lngLat.lat],t),null==(e=B.current)||e.call(B,null)}else if(i&&B.current){const e=k.current.get(n)??[];if(e.length>0){const t=new Set;for(const A of e)for(const e of A.edgeKeys)t.add(e);const r={loops:e,highlightedEdgeKeys:t,hoveredEdgeKey:n,nodeNames:e[0].nodes.map(A=>C.current[A]||A.substring(0,4))};B.current(r,[A.lngLat.lng,A.lngLat.lat]),a(n)}else{const e={key:n,fromName:r.fromName,toName:r.toName,certainCount:Number(r.certainCount),confidence:Number(r.confidence),isBackbone:!0===r.isBackbone||"true"===r.isBackbone,isLoopEdge:!0,isDirectPath:!0===r.isDirectPath||"true"===r.isDirectPath,isZeroHop:!0===r.isZeroHop||"true"===r.isZeroHop,symmetryRatio:Number(r.symmetryRatio),dominantDirection:r.dominantDirection,isHubConnection:!0===r.isHubConnection||"true"===r.isHubConnection};a(n,[A.lngLat.lng,A.lngLat.lat],e)}}else{const e={key:n,fromName:r.fromName,toName:r.toName,certainCount:Number(r.certainCount),confidence:Number(r.confidence),isBackbone:!0===r.isBackbone||"true"===r.isBackbone,isLoopEdge:i,isDirectPath:!0===r.isDirectPath||"true"===r.isDirectPath,isZeroHop:!0===r.isZeroHop||"true"===r.isZeroHop,symmetryRatio:Number(r.symmetryRatio),dominantDirection:r.dominantDirection,isHubConnection:!0===r.isHubConnection||"true"===r.isHubConnection};a(n,[A.lngLat.lng,A.lngLat.lat],e),null==(t=B.current)||t.call(B,null)}}},[a]),E=A.useCallback(()=>{var A;null!==x.current&&(x.current=null,a(null),null==(A=B.current)||A.call(B,null))},[a]);A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e||!b)return;const t="topology-validated-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,D),e.on("mouseleave",t,E),!0);if(!n()){const A=()=>{n()&&e.off("styledata",A)};return e.on("styledata",A),()=>{try{e.off("styledata",A),r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}},[m,b,D,E]),A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e||!g)return;const t="neighbor-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,D),e.on("mouseleave",t,E),!0);if(!n()){const A=()=>{n()&&e.off("styledata",A)};return e.on("styledata",A),()=>{try{e.off("styledata",A),r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}},[m,p,g,D,E]),A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e)return;let t=null;const r=(A,t)=>{try{if(e.getLayer(A)&&e.getLayer(t))return e.moveLayer(A,t),!0}catch{}return!1},n=()=>{try{if(!e.getLayer("node-markers-layer"))return;r(gr,"node-markers-layer"),r("neighbor-edges-hitarea-native",gr),(r(dr,"neighbor-edges-hitarea-native")||r(dr,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",dr),r(fr,"topology-validated-edges-hitarea-native")}catch{}},o=()=>{t&&clearTimeout(t),t=setTimeout(n,50)},i=setTimeout(n,100);e.on("styledata",o);const a=A=>{(A.sourceId===lr||A.sourceId===cr||A.sourceId===ur)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[m,b,p,g]);const Q=w?null:n,j=function(A,e,t,r,n,o){const i=LA(),a=null!==A,s=n&&n.size>0,l=o&&o.size>0,c=s?Array.from(n):[],u=l?Array.from(o):[],f=e<=0?["get","baseColor"]:["case",[">=",["get","brightnessScore"],1-.5*e],"#FFFFFF",["get","baseColor"]],d=e<=0?1:["max",.1,["+",1,["*",e,3,["-",["get","brightnessScore"],.5]]]],g=s?["in",["get","key"],["literal",c]]:l?["in",["get","key"],["literal",u]]:!!a&&["==",["get","key"],A],h=a||s||l,m=i.edges.hoverLoop??"#A78BFA";return{"line-color":h?["case",g,s?m:l?"#FFD700":["get","hoverColor"],f]:f,"line-width":h?["case",g,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,h?["case",g,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],d,.35]]:["*",["get","baseOpacity"],d]]}}(Q,u,f,d,w?null:o,i??null),N=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=Z,i=["to-number",["get","listenerScore"],0],a=["to-number",["get","loudScore"],0],s=["/",i,["max",["+",i,a],1]],l=["*",["+",.2,["*",["to-number",["get","trafficWeight"],0],.8]],8];return{"line-color":["case",["all",["==",i,0],["==",a,0]],o,[">=",s,.97],r,["<=",s,.03],n,["interpolate",["linear"],s,.03,n,.5,t,.97,r]],"line-width":["interpolate",["linear"],["zoom"],6,e?["case",["==",["get","key"],A],["max",["*",l,.25],1.25],["*",l,.25]]:["*",l,.25],10,e?["case",["==",["get","key"],A],["max",l,5],l]:l],"line-opacity":e?["case",["==",["get","key"],A],1,.35]:.9}}(Q);return e.jsxs(e.Fragment,{children:[b&&e.jsx(R,{id:cr,type:"geojson",data:hr,children:e.jsx(_,{id:fr,type:"line",paint:j,layout:{...mr,visibility:v}})}),b&&e.jsxs(R,{id:lr,type:"geojson",data:hr,children:[e.jsx(_,{id:"topology-validated-edges-hitarea-native",type:"line",paint:br,layout:{...mr,visibility:v}}),e.jsx(_,{id:dr,type:"line",paint:j,layout:{...mr,visibility:v}})]}),e.jsxs(R,{id:ur,type:"geojson",data:hr,children:[e.jsx(_,{id:"neighbor-edges-hitarea-native",type:"line",paint:br,layout:{...mr,visibility:v}}),e.jsx(_,{id:gr,type:"line",paint:N,layout:{...mr,visibility:v}})]})]})}const vr=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function wr({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=I(),o=A.useRef(null);return A.useEffect(()=>{if(!n||!e||e===o.current)return;const A=t.get(e);if(!A)return;const i=n.getMap();i.isMoving()&&i.stop(),o.current=e;const[a,s]=A;n.flyTo({center:[s,a],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{null==r||r()},2600)},[e,t,n,r]),null}function xr({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=I(),i=A.useRef(null);return A.useEffect(()=>{if(!o||!e)return;if(e===i.current)return;i.current=e,n();const A=t.find(A=>A.edge.key===e)||r.find(A=>A.edge.key===e);if(!A)return;if(o.getMap().isMoving())return;const a=(A.from[0]+A.to[0])/2,s=(A.from[1]+A.to[1])/2,l=o.getZoom(),c=Math.max(l,11);o.easeTo({center:[s,a],zoom:c,duration:500})},[e,t,r,o,n]),null}function yr(A,e,t,r=64){const n=[],o=t/6371e3*(180/Math.PI),i=o/Math.cos(e*Math.PI/180);for(let a=0;a<=r;a++){const t=a/r*2*Math.PI,s=A+i*Math.cos(t),l=e+o*Math.sin(t);n.push([s,l])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}}}function kr({ghost:t,neighborCoordinates:r,onHighlightedNeighborsChange:n}){const{current:o}=I(),i=A.useRef(null),a=A.useRef(null),s=A.useMemo(()=>t?new Set(t.commonNeighbors):new Set,[t]);A.useEffect(()=>{null==n||n(s)},[s,n]);const l=A.useMemo(()=>{if(!(null==t?void 0:t.commonNeighbors)||t.commonNeighbors.length<2)return 8e3;let A=0;const e=[];for(const n of t.commonNeighbors){const A=r.get(n);A&&e.push(A)}t.estimatedLocation&&e.push([t.estimatedLocation.lat,t.estimatedLocation.lon]);for(let t=0;tA&&(A=n)}return Math.max(A,2e3)},[t,r]),c=A.useMemo(()=>{if(!(null==t?void 0:t.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:A,lon:e,uncertaintyM:r}=t.estimatedLocation,n=.5*l,o=r>0?r:2e3;return{type:"FeatureCollection",features:[yr(e,A,Math.max(500,Math.min(o,n)))]}},[t,l]);if(A.useEffect(()=>{if(!o)return;const A=o.getMap();if(t&&t.prefix!==a.current){if(a.current=t.prefix,!i.current&&A.getZoom()>3){const e=A.getCenter();i.current={center:[e.lng,e.lat],zoom:A.getZoom(),pitch:A.getPitch(),bearing:A.getBearing()}}const e=[];for(const A of t.commonNeighbors){const t=r.get(A);t&&e.push([t[1],t[0]])}if(t.estimatedLocation&&e.push([t.estimatedLocation.lon,t.estimatedLocation.lat]),e.length>0){const r=()=>{var n;if(A.isMoving())setTimeout(r,100);else if(1===e.length)o.flyTo({center:e[0],zoom:13,duration:1500});else{let A=1/0,r=-1/0,i=1/0,a=-1/0;for(const[t,n]of e)A=Math.min(A,t),r=Math.max(r,t),i=Math.min(i,n),a=Math.max(a,n);if(null==(n=t.estimatedLocation)?void 0:n.uncertaintyM){const e=t.estimatedLocation.uncertaintyM/111e3;A-=e,r+=e,i-=e,a+=e}o.fitBounds([[A,i],[r,a]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:1500})}};setTimeout(r,50)}}if(!t&&null!==a.current&&(a.current=null,i.current)){const e=i.current,t=()=>{A.isMoving()?setTimeout(t,100):(o.flyTo({center:e.center,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,duration:1e3}),i.current=null)};setTimeout(t,50)}},[t,o,r]),!(null==t?void 0:t.estimatedLocation))return null;return e.jsx(R,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:e.jsx(_,{id:"ghost-uncertainty-fill",type:"fill",paint:{"fill-color":"rgba(167, 139, 250, 0.15)","fill-opacity":.8}})})}!function(A){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(A);e&&(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16))}(TA.edges.neighborHover);const Cr={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},Br={longitude:0,latitude:0,zoom:2};function Mr({data:A}){const t=A.subtitle&&"loop"===A.type,r=A.subtitle&&"loop"!==A.type;return e.jsxs("div",{className:"w-[540px]",children:[e.jsxs("div",{className:"flex items-center justify-between h-5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[A.title.icon&&e.jsx("span",{className:`${A.title.color} text-base leading-none flex-shrink-0`,children:A.title.icon}),e.jsx("span",{className:`${A.title.color} font-semibold text-[13px] truncate`,children:A.title.text}),r&&e.jsx("span",{className:`${A.subtitle.color} text-[11px] flex-shrink-0`,children:A.subtitle.text})]}),A.badges.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:A.badges.map((A,t)=>e.jsx("span",{className:`${A.color} text-[11px] font-medium`,children:A.text},t))})]}),t&&e.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:e.jsx("span",{className:"font-mono text-[10px] text-text-muted truncate block",children:A.subtitle.text})}),e.jsx("div",{className:`flex items-center gap-4 h-4 ${t?"mt-1":"mt-1.5"} text-[11px]`,children:A.stats.map((A,t)=>e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx("span",{className:`font-mono tabular-nums font-semibold ${A.color??"text-text-primary"}`,children:A.value}),e.jsx("span",{className:"text-text-muted ml-1",children:A.label}),A.unit&&e.jsx("span",{className:"text-text-muted/50 ml-0.5",children:A.unit})]},t))})]})}function Dr({neighbors:t,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=sA(),f=lA(),d=cA(),g=uA(),h=fA(),[m,b]=A.useState(!1),p=wt(A=>A.viewState),v=wt(A=>A.toggles),w=wt(A=>A.hasAnalyzed),x=wt(A=>A.setViewState),y=wt(A=>A.setToggle),k=wt(A=>A.setHasAnalyzed),C=dA(A=>A.preloadFromNodes),B=dA(A=>A.isLoading),M=dA(A=>A.terrainGrid),D=n??h,E=A.useMemo(()=>{const A=[];for(const[,e]of Object.entries(t))e.latitude&&e.longitude&&A.push([e.latitude,e.longitude]);return A},[t]),Q=A.useMemo(()=>function(A,e){let t=[...A];if((null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&t.push([e.latitude,e.longitude]),0===t.length)return null;if(1===t.length){const[A,e]=t[0];return{longitude:e,latitude:A,zoom:14}}t=function(A,e){if(A.length<=2)return A;let t,r;if((null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude))t=e.latitude,r=e.longitude;else{let e=0,n=0;for(const[t,r]of A)e+=t,n+=r;t=e/A.length,r=n/A.length}const n=A.map(([A,e])=>{return{pos:[A,e],dist:(n=t,o=r,i=A,a=e,FA(n,o,i,a)/1e3)};var n,o,i,a});n.sort((A,e)=>A.dist-e.dist);const o=n[Math.floor(n.length/2)].dist,i=Math.max(3*o,50),a=n.filter(A=>A.dist<=i).map(A=>A.pos);return a.length<.5*A.length?A:a}(t,e);let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const[d,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,d),i=Math.max(i,d);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let f=16;return u>0&&(f=Math.floor(Math.log2(360/u*1.2)),f=Math.max(1,Math.min(14,f))),f=Math.min(f+1,12),{longitude:a,latitude:s,zoom:f}}(E,r),[E,r]),[j,N]=A.useState(()=>p??Q??Br),S=A.useCallback(A=>{N(A),x(A)},[x]),F=A.useRef(!!p);A.useEffect(()=>{F.current||!Q||p?p&&setTimeout(()=>b(!0),50):(N(Q),x(Q),F.current=!0,setTimeout(()=>b(!0),50))},[Q,p,x]);const[P,T]=A.useState(!1),[L,I]=A.useState(()=>!(v.showTopology&&!g.topologyLoadComplete)&&v.showTopology),[R,_]=A.useState(v.showNeighborLines),[H,z]=A.useState(!1),[G,O]=A.useState(v.showMinCut),[U,Y]=A.useState(be),[Z,J]=A.useState(v.show3DTerrain),[X,q]=A.useState(v.nodeFilter),$=A.useCallback(A=>{I(e=>{const t="function"==typeof A?A(e):A;return y("showTopology",t),t})},[y]),AA=A.useCallback(A=>{_(e=>{const t="function"==typeof A?A(e):A;return y("showNeighborLines",t),t})},[y]),iA=A.useCallback(A=>{O(e=>{const t="function"==typeof A?A(e):A;return y("showMinCut",t),t})},[y]),aA=A.useCallback(A=>{J(e=>{const t="function"==typeof A?A(e):A;return y("show3DTerrain",t),t})},[y]),mA=A.useCallback(A=>{q(A),y("nodeFilter",A)},[y]),[bA,pA]=A.useState(null),[vA,wA]=A.useState(null),[xA,yA]=A.useState(null),[kA]=A.useState(0),[DA]=A.useState(.5),[EA]=A.useState(0),[QA,jA]=A.useState(null),[NA,SA]=A.useState(""),[TA,LA]=A.useState(!1),[RA,_A]=A.useState("fetching"),[HA,zA]=A.useState(!1),[GA,OA]=A.useState(0),[UA,VA]=A.useState(()=>!(w&&!g.topologyLoadComplete)&&w);A.useEffect(()=>{g.topologyLoadComplete||(w&&!UA&&k(!1),v.showTopology&&!L&&y("showTopology",!1))},[w,v.showTopology,g.topologyLoadComplete,UA,L,k,y]);const ZA=A.useCallback(A=>{VA(A),k(A)},[k]),[KA,XA]=A.useState(null),$A=A.useCallback(A=>XA(A),[]),ee=A.useCallback(()=>XA(null),[]),[,te]=A.useState(new Set),re=ce(A=>A.coveragePoints),ne=ce(A=>A.isVisible),oe=ce(A=>A.brightness),ie=ce(A=>A.openModal),ae=ye(A=>A.isEnabled),se=ye(A=>A.toggle),le=CA(),ue=BA(),fe=A.useRef(!1);A.useEffect(()=>{re.length>0&&ne&&!fe.current&&(AA(!1),fe.current=!0)},[re.length,ne]);const de=A.useRef(null);A.useEffect(()=>{if(i&&i!==de.current){de.current=i;const A=setTimeout(()=>{XA(i)},1250);return()=>clearTimeout(A)}},[i]);const[ge,he]=A.useState(null),[pe,ve]=A.useState(null),xe=A.useCallback((A,e,t)=>{wA(A),A&&e&&t?he({longitude:e[0],latitude:e[1],type:"topology",properties:{key:t.key,fromName:t.fromName,toName:t.toName,certainCount:t.certainCount,confidence:t.confidence,isBackbone:t.isBackbone,isLoopEdge:t.isLoopEdge,isDirectPath:t.isDirectPath,isHubConnection:t.isHubConnection,symmetryRatio:t.symmetryRatio,dominantDirection:t.dominantDirection}}):A||he(null)},[]),ke=A.useCallback((A,e)=>{ve(A),A&&he(null)},[]),Ce=A.useMemo(()=>{var A;if(!L)return null;if(!bA)return null;if(vA)return null;const e=u.loops;if(0===e.length)return null;const r=function(A,e,t){const r=function(A,e){return e.filter(e=>e.nodes.includes(A)).sort((A,e)=>e.avgCertainCount-A.avgCertainCount)}(A,e),n=new Set,o=[];for(const i of r)for(const A of i.edgeKeys)if(!n.has(A)){n.add(A);const e=t.get(A);o.push({key:A,certainCount:(null==e?void 0:e.certainCount)??0})}return o.sort((A,e)=>e.certainCount-A.certainCount),{loops:r,highlightedEdgeKeys:n,sortedEdges:o}}(bA,e,u.edgeMap);if(0===r.loops.length)return null;const n=r.loops[0].nodes.map(A=>{var e,r;return A===D?"You":(null==(e=t[A])?void 0:e.node_name)||(null==(r=t[A])?void 0:r.name)||A.substring(0,4)});return{loops:r.loops,highlightedEdgeKeys:r.highlightedEdgeKeys,hoveredEdgeKey:(null==(A=r.sortedEdges[0])?void 0:A.key)||"",nodeNames:n}},[L,bA,vA,u.loops,u.edgeMap,t,D]);A.useEffect(()=>{vA||ve(Ce)},[Ce,vA]);const Be=A.useMemo(()=>{const A={};for(const[e,r]of Object.entries(t))A[e]=r.node_name||r.name||e.substring(0,4);return D&&(A[D]="You"),A},[t,D]),Me=A.useMemo(()=>Object.entries(t).filter(([,A])=>A.latitude&&A.longitude),[t]),De=A.useMemo(()=>{const A=new Map;D&&(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&A.set(D,[r.latitude,r.longitude]);for(const[e,t]of Me)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[D,r,Me]),Ee=A.useMemo(()=>{const A=new Map;for(const e of d)"expired"!==e.status&&A.set(e.hash,{hash:e.hash,prefix:e.prefix,count:e.count,avgRssi:e.avgRssi,avgSnr:e.avgSnr,lastSeen:e.lastSeen,confidence:1,status:e.status});return A},[d]),Qe=A.useMemo(()=>{var A,e;const r=new Set;for(const n of Ee.keys())(null==(A=t[n])?void 0:A.latitude)&&(null==(e=t[n])?void 0:e.longitude)&&r.add(n);return r},[Ee,t]),je=A.useMemo(()=>{if(0===Qe.size||!D)return new Map;const A=tA.getPackets();if(0===A.length)return new Map;const e=nA(D);return K(A,Qe,e).scores},[Qe,D,g.packetCount]),Ne=A.useCallback(A=>!!(D&&(A.fromHash===D&&Qe.has(A.toHash)||A.toHash===D&&Qe.has(A.fromHash))),[D,Qe]),Se=A.useMemo(()=>{var A,e;if(0===d.length||!D)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of d){if("expired"===n.status)continue;if(!(null==(A=t[n.hash])?void 0:A.latitude)||!(null==(e=t[n.hash])?void 0:e.longitude))continue;const o=[D,n.hash].sort(),i=`${o[0]}~${o[1]}`;r.push({fromHash:D,toHash:n.hash,key:i,packetCount:n.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:n.count,isLoopEdge:!1,forwardCount:n.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:n.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:n.avgRssi,avgSnr:n.avgSnr})}return r},[d,D,g.backgroundLoadComplete,t]),Fe=A.useMemo(()=>{const A=[];if(Se.length>0&&!g.backgroundLoadComplete){for(const e of Se){const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(Ne(e))continue;const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,De,Ne,Se,g.backgroundLoadComplete]),Pe=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(Ne(e))continue;const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,De,Ne]),Te=A.useMemo(()=>{if(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude))return[];const A=[],e=[r.latitude,r.longitude],n=new Map;for(const t of u.lastHopNeighbors)n.set(t.hash,t.count);const o=new Map;for(const t of d)o.set(t.hash,t.count);for(const r of Qe){const i=t[r];if(!(null==i?void 0:i.latitude)||!(null==i?void 0:i.longitude))continue;const a=o.get(r),s=n.get(r);A.push({from:e,to:[i.latitude,i.longitude],hash:r,neighbor:i,lastHopData:Ee.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,Qe,t,Ee,u.lastHopNeighbors,d]),Le=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),Ie=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),Re=A.useMemo(()=>{if(!xA)return null;const A=u.validatedEdges.filter(A=>A.fromHash===xA||A.toHash===xA);if(0===A.length)return null;const e=[...A].sort((A,e)=>e.certainCount-A.certainCount),t=Math.max(1,Math.ceil(.2*e.length)),r=e.slice(0,t);return new Set(r.map(A=>A.key))},[xA,u.validatedEdges]),_e=A.useMemo(()=>{let A=0;if(Se.length>0&&!g.backgroundLoadComplete){for(const e of Se)e.certainCount>A&&(A=e.certainCount);return A||1}for(const e of u.validatedEdges)e.certainCount>A&&(A=e.certainCount);return A||1},[u.validatedEdges,Se,g.backgroundLoadComplete]),He=A.useMemo(()=>{if(0===u.validatedEdges.length)return null;const A=new Set;for(const r of u.validatedEdges)A.add(r.fromHash),A.add(r.toHash);const e=Array.from(A).filter(A=>De.has(A)).sort();if(e.length<3)return null;const t=new Map;for(const r of e){const A=De.get(r);A&&t.set(r,A)}return function(A,e,t,r){const n=e.length;if(n<3)return{communities:new Map([[0,e]]),nodePartitions:e.map(A=>({hash:A,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:n<=1};const o=[];let i=1/0;const a=[[e,0]];for(;a.length>0;){const[e,n]=a.shift();if((t?it(e,t):0)>20&&n<4&&e.length>=10){const o=at(A,e,t,r);if(o){i=Math.min(i,o.fiedlerValue),a.push([o.group0,n+1]),a.push([o.group1,n+1]);continue}}o.push(e)}const s=new Map,l=[],c=new Map;for(let u=0;u{iA(A=>{const e=!A;if(e&&He&&c.current){const A=c.current.getMap();if(!A)return e;let t=1/0,r=-1/0,n=1/0,o=-1/0,i=!1;for(const[,e]of He.communities)for(const A of e){const e=De.get(A);if(e){const[A,a]=e;n=Math.min(n,A),o=Math.max(o,A),t=Math.min(t,a),r=Math.max(r,a),i=!0}}i&&A.fitBounds([[t,n],[r,o]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return e})},[He,De]),Ge=A.useRef(null);A.useLayoutEffect(()=>{var A,e;Ge.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const Oe=eA(),Ue=A.useMemo(()=>tA.getPackets(),[Oe]);!function({map:e,nodeCoordinates:t,packets:r,localHash:n,neighbors:o,meshTopology:i,enabled:a=!0}){const s=A.useRef(null),l=e&&"current"in e?e.current:e;A.useEffect(()=>{s.current=l},[l]);const c=A.useRef(!1),u=A.useRef(null),f=A.useRef([]),d=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),v=A.useRef(new Map),w=A.useRef(t);A.useEffect(()=>{w.current=t},[t]),A.useEffect(()=>{v.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=nA(r);t.has(A)||t.set(A,r)}if(e){const A=nA(e);t.set(A,e)}return t}(o,n)},[o,n]),A.useEffect(()=>{if(!a){b.current&&(clearTimeout(b.current),b.current=null),p.current=[],null!==u.current&&(cancelAnimationFrame(u.current),u.current=null),f.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(jt);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,d.current=0}},[a]),A.useEffect(()=>{const A=l;if(!A)return;let e=null,t=!1;const r=()=>{if(!t&&!c.current)try{A.getLayer(Nt)&&A.removeLayer(Nt),A.getSource(jt)&&A.removeSource(jt),A.addSource(jt,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Pt)?Pt:void 0;A.addLayer({id:Nt,type:"line",source:jt,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],"#8B7BAD","#12A594"],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],1.875,2.5],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},t),c.current=!0,m(!0),e&&(clearInterval(e),e=null)}catch{}};return A.isStyleLoaded()&&r(),A.once("style.load",()=>{r()}),c.current||(e=setInterval(()=>{c.current?e&&clearInterval(e):r()},100),setTimeout(()=>{e&&(clearInterval(e),e=null)},5e3)),()=>{t=!0,e&&clearInterval(e),null!==u.current&&(cancelAnimationFrame(u.current),u.current=null);const A=s.current;if(A&&c.current){try{A.getLayer(Nt)&&A.removeLayer(Nt),A.getSource(jt)&&A.removeSource(jt)}catch{}c.current=!1,m(!1)}}},[l]);const x=A.useRef(()=>{});A.useEffect(()=>{x.current=()=>{const A=s.current;if(!A)return;const e=A.getSource(jt);if(!e)return;const t=performance.now(),r=f.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ft:St)){o.push(i);const e=i.isSpeculative?Lt(A):Tt(A);e>0&&n.push({type:"Feature",properties:{intensity:e,opacityMult:i.isSpeculative?.5:1,isSpeculative:i.isSpeculative??!1},geometry:{type:"LineString",coordinates:[i.fromCoord,i.toCoord]}})}}e.setData({type:"FeatureCollection",features:n}),f.current=o,o.length>0?u.current=requestAnimationFrame(()=>x.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(Nt))return;const e=A.getLayer(Pt)?Pt:void 0;try{A.moveLayer(Nt,e)}catch{}}(A),null===u.current&&(u.current=requestAnimationFrame(()=>x.current()))},[]),k=A.useCallback(()=>{if(!s.current||!c.current)return;const A=p.current;if(p.current=[],b.current=null,0===A.length)return;const e=v.current,t=w.current;if(0===e.size)return;const r=performance.now();let o=0,a=!1;const l=new Set;for(const s of A){const A=rA(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,d=null;for(let n=0;n0){A.sort((A,e)=>e.confidence-A.confidence);const e=Math.max(1,Math.ceil(.25*A.length)),n=A.slice(0,e),i=o+150*u;for(const{edgeKey:A,otherHash:o}of n){const e=t.get(d),n=t.get(o);f.current.push({edgeKey:A,fromCoord:It(e),toCoord:It(n),startTime:r,delay:i,isSpeculative:!0}),l.add(A),a=!0}}}u>0&&(o+=150*u*.5)}a&&y()},[n,i,y]);A.useEffect(()=>{const A=s.current;if(!a)return;if(!A)return;if(!h)return;if(0===r.length)return;const e=Date.now(),t=d.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A);let n=0;for(const e of r){const A=e.timestamp??0;A>n&&(n=A)}if(d.current=n,t.length>0){t.sort((A,e)=>(A.timestamp??0)-(e.timestamp??0));const A=t.slice(-20);p.current.push(...A),k()}return}const n=r.filter(A=>(A.timestamp??0)>t);if(0===n.length)return;let o=0;for(const r of n){const A=r.timestamp??0;A>o&&(o=A)}d.current=o,p.current.push(...n),b.current&&clearTimeout(b.current),b.current=setTimeout(k,175)},[a,r,k,h]),A.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[])}({map:Ge,nodeCoordinates:De,packets:Ue,localHash:D,neighbors:t,meshTopology:u,enabled:ae});const{isExiting:Ye,isAnimating:We,resetAnimationState:Ve}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:f=[],showNeighborLines:d=!0,neighborSourceId:g,neighborLinkScores:h=new Map,basemapMode:m}){const b=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;b.current=A});const p=A.useRef(new Map),v=A.useRef(1),w=A.useRef(new Map),x=A.useRef(new Map),y=A.useRef(!1),k=A.useRef(null),C=A.useRef(t),B=A.useRef(new Set),M=A.useRef(""),D=A.useRef(new Map),E=A.useRef(""),Q=A.useRef(""),j=A.useRef(""),N=A.useRef(r),S=A.useRef(n),F=A.useRef(o),P=A.useRef(i),T=A.useRef(a),L=A.useRef(s),I=A.useRef(l),R=A.useRef(f),_=A.useRef(d),H=A.useRef(h),z=A.useRef(m);A.useEffect(()=>{N.current=r,S.current=n,F.current=o,P.current=i,T.current=a,L.current=s,I.current=l,R.current=f,_.current=d,H.current=h,z.current=m},[r,n,o,i,a,s,l,f,d,h,m]);const G=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,f;const d=b.current;if(!d)return;const h=d.getSource(c),m=d.getSource(u),y=d.getSource(g);if(h){const o=Bt(N.current,!0,p.current,v.current,w.current,x.current,F.current,P.current,T.current,L.current,I.current,z.current),i=`${o.features.length}:${(null==(t=null==(e=o.features[0])?void 0:e.properties)?void 0:t.key)??""}:${(null==(n=null==(r=o.features[o.features.length-1])?void 0:r.properties)?void 0:n.key)??""}:${Array.from(p.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==E.current)&&(h.setData(o),E.current=i)}if(m){const e=Bt(S.current,!1,p.current,v.current,w.current,x.current,F.current,P.current,T.current,L.current,I.current,z.current),t=`${e.features.length}:${(null==(i=null==(o=e.features[0])?void 0:o.properties)?void 0:i.key)??""}:${(null==(s=null==(a=e.features[e.features.length-1])?void 0:a.properties)?void 0:s.key)??""}`;(A||t!==Q.current)&&(m.setData(e),Q.current=t)}if(y&&R.current.length>0){const e=Mt(R.current,H.current),t=`${e.features.length}:${(null==(f=null==(l=e.features[0])?void 0:l.properties)?void 0:f.hash)??""}`;(A||t!==j.current)&&(y.setData(e),j.current=t)}},[c,u,g]),O=A.useCallback(()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null),p.current=new Map,v.current=1,w.current=new Map,x.current=new Map,y.current=!1,B.current=new Set,M.current="",D.current=new Map},[]);A.useEffect(()=>{const A=C.current,e=t;if(C.current=t,b.current){if(k.current&&(cancelAnimationFrame(k.current),k.current=null),A&&!e&&!y.current){y.current=!0;const A=new Map(p.current);let e=null;const t=r=>{e||(e=r);const n=r-e,o=Math.min(n/500,1),i=(a=o,1-Math.pow(1-a,3));var a;for(const[e,t]of A)p.current.set(e,t*(1-i));G(!0),o<1?k.current=requestAnimationFrame(t):(y.current=!1,p.current=new Map,B.current=new Set,M.current="",w.current=new Map,x.current=new Map,k.current=null,G(!0))};k.current=requestAnimationFrame(t)}!A&&e&&(p.current=new Map,B.current=new Set,M.current="")}},[t,G]),A.useEffect(()=>{const A=b.current;if(!t||y.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===B.current.size,a=""!==M.current&&M.current!==o;if(!i&&!a)return void G();const s=[],l=[];for(const{edge:t}of e)B.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(w.current=new Map(D.current),v.current=0),x.current=new Map;for(const{edge:t}of r){const A=PA(t.certainCount);x.current.set(t.key,A)}for(const t of s)p.current.set(t,0);for(const t of l)p.current.has(t)||p.current.set(t,1);if(s.length>0||a&&l.length>0){k.current&&(cancelAnimationFrame(k.current),k.current=null);let A=null;const e=Math.min(100,IA/Math.max(s.length,1)/2),t=r=>{A||(A=r);const n=r-A;for(let A=0;A0){const A=Math.min(n/IA,1);v.current=Ct(A)}G(!0);const o=IA+(s.length-1)*e;k.current=n{const A=b.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(f.length>0){const A=Mt(f,h);e.setData(A)}else e.setData({type:"FeatureCollection",features:[]});return!0};if(e())return;const t=r=>{r.sourceId===g&&e()&&A.off("sourcedata",t)};A.on("sourcedata",t);const r=()=>{e()&&(A.off("styledata",r),A.off("sourcedata",t))};return A.on("styledata",r),()=>{A.off("sourcedata",t),A.off("styledata",r)}},[g,f,h]);const U=A.useRef(m);return A.useEffect(()=>{m!==U.current&&(U.current=m,E.current="",Q.current="",j.current="",G(!0))},[m,G]),A.useEffect(()=>()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null)},[]),{isExiting:y.current,isAnimating:null!==k.current,resetAnimationState:O,weightAnimProgress:v.current,animStartWeights:w.current,animTargetWeights:x.current}}({map:Ge,showTopology:L,validatedPolylines:Fe,weakPolylines:Pe,maxCertainCount:_e,loopEdgeKeys:Le,backboneEdgeKeys:Ie,highlightedEdgeKey:s,neighbors:t,validatedSourceId:lr,weakSourceId:cr,neighborPolylines:Te,showNeighborLines:R,neighborSourceId:ur,neighborLinkScores:je,basemapMode:le}),Ke=A.useMemo(()=>{const A=new Set;for(const e of u.hubNodes){A.add(e);for(const t of u.validatedEdges)t.fromHash===e&&A.add(t.toHash),t.toHash===e&&A.add(t.fromHash)}return A},[u.hubNodes,u.validatedEdges]),Je=A.useMemo(()=>{const A=new Set;if(!n)return A;for(const e of u.validatedEdges)e.fromHash===n&&A.add(e.toHash),e.toHash===n&&A.add(e.fromHash);return A},[n,u.validatedEdges]),{getNodeOpacity:Xe}=function({soloDirect:e,soloHubs:t,neighborHashes:r,hubConnectedNodes:n,directNodeSet:o,localConnectedNodes:i,showTopology:a}){const[s,l]=A.useState(new Map),c=A.useRef(e),u=A.useRef(t),f=A.useRef(new Map),d=A.useRef(null),g=A.useRef(n),h=A.useRef(o),m=A.useRef(i),b=A.useRef(a);return A.useEffect(()=>{g.current=n,h.current=o,m.current=i,b.current=a},[n,o,i,a]),A.useEffect(()=>{const A=c.current,n=u.current,o=e,i=t;if(c.current=e,u.current=t,A===o&&n===i)return;d.current&&(cancelAnimationFrame(d.current),d.current=null);const a=g.current,s=h.current,p=m.current,v=b.current;for(const e of r)f.current.has(e)||f.current.set(e,Math.random());const w=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=v&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},x=[];for(const e of r){const t=w(e,A,n),r=w(e,o,i);t!==r&&x.push({hash:e,startOpacity:t?1:0,targetOpacity:r?1:0})}if(0===x.length)return;l(A=>{const e=new Map(A);for(const{hash:t,startOpacity:r}of x)e.set(t,r);return e});const y=x;let k=null;const C=A=>{k||(k=A);const e=A-k;let t=!0;l(()=>{const A=new Map;for(const{hash:r,startOpacity:n,targetOpacity:o}of y){const i=250*(f.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Dt(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?d.current=requestAnimationFrame(C):(d.current=null,l(new Map))};return d.current=requestAnimationFrame(C),()=>{d.current&&(cancelAnimationFrame(d.current),d.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===X,soloHubs:"hubs"===X,neighborHashes:Me.map(([A])=>A),hubConnectedNodes:Ke,directNodeSet:Qe,localConnectedNodes:Je,showTopology:L}),{blinkingNodes:qe,blinkColor:$e}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=eA(),a=A.useRef(tA.getPackets());A.useEffect(()=>{a.current=tA.getPackets()},[i]);const s=A.useRef(0),l=A.useRef(null),c=A.useRef(new Map),u=A.useRef(new Map);A.useEffect(()=>{u.current=function(A){const e=new Map;for(const t of Object.keys(A)){const A=nA(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const f=A.useRef(null);return A.useEffect(()=>{f.current=()=>{const A=performance.now(),e=c.current;if(0===e.size)return l.current=null,void o(new Map);const t=new Map,r=[];for(const[n,{startTime:o,staggerDelay:i}]of e){const e=A-o-i;if(e<0);else if(e>=750)r.push(n);else{const A=Et(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&f.current?l.current=requestAnimationFrame(f.current):l.current=null}},[]),A.useEffect(()=>{if(!r)return;const A=a.current;if(0===A.length)return;const e=s.current,n=A.filter(A=>(A.timestamp??0)>e);if(0===e){const e=A.reduce((A,e)=>Math.max(A,e.timestamp??0),0);return void(s.current=e)}if(0===n.length)return;const o=n.reduce((A,e)=>Math.max(A,e.timestamp??0),0);s.current=o;const i=performance.now();let d=0;for(const r of n){const A=rA(r,t);if(!A||0===A.original.length)continue;const e=Qt(A.original,u.current,t);if(0===e.length)continue;const n=375;for(let t=0;t()=>{null!==l.current&&(cancelAnimationFrame(l.current),l.current=null)},[]),{blinkingNodes:n,blinkColor:"#00FF00"}}({neighbors:t,localHash:n,enabled:ae}),et=A.useCallback(A=>{if("all"===X)return!0;if("direct"===X)return Qe.has(A);if("hubs"===X){if(u.hubNodes.includes(A))return!0;for(const e of u.validatedEdges){if(e.fromHash===A&&u.hubNodes.includes(e.toHash))return!0;if(e.toHash===A&&u.hubNodes.includes(e.fromHash))return!0}return!1}return!0},[X,Qe,u.hubNodes,u.validatedEdges]);A.useEffect(()=>{"fetching"===RA&&(g.loadProgress?OA(g.loadProgress.loaded):g.packetCount>0&&OA(g.packetCount))},[RA,g.loadProgress,g.packetCount]);const tt=A.useCallback(async()=>{zA(!0),LA(!0),_A("fetching"),OA(0),await f(),_A("analyzing"),await new Promise(A=>setTimeout(A,200)),_A("building");const A=Date.now(),e=Date.now()-A;e<1700&&await new Promise(A=>setTimeout(A,1700-e)),_A("complete"),await new Promise(A=>setTimeout(A,1e3)),LA(!1),zA(!1),Ve(),ZA(!0),setTimeout(()=>{$(!0)},150)},[f,Ve]),rt=A.useCallback(()=>{UA?$(A=>!A):tt()},[UA,tt]),nt=A.useCallback(A=>{S(A.viewState),(A.viewState.pitch??0)>10&&!Z&&aA(!0)},[Z]),ot=A.useCallback(()=>{T(A=>{var e,t,r,n,o,i,a;const s=!A,l=null==(r=null==(t=null==(e=c.current)?void 0:e.getContainer())?void 0:t.closest(".map-container-fullscreen, .map-container-16-9"))?void 0:r.parentElement;return s?l&&document.fullscreenEnabled?null==(n=l.requestFullscreen)||n.call(l).catch(()=>{}):l&&document.webkitFullscreenEnabled&&(null==(o=l.webkitRequestFullscreen)||o.call(l)):document.fullscreenElement?null==(i=document.exitFullscreen)||i.call(document).catch(()=>{}):document.webkitFullscreenElement&&(null==(a=document.webkitExitFullscreen)||a.call(document)),s})},[]),st=A.useCallback(A=>{mA(A)},[]),lt=A.useCallback(()=>{AA(A=>!A)},[]),ct=A.useCallback(()=>{z(A=>!A)},[]),ut=A.useCallback(()=>{aA(A=>{const e=!A;if(c.current){const A=c.current.getMap();A&&A.stop()}if(e&&c.current){const A=c.current.getMap();A&&A.easeTo({pitch:45,duration:1500,easing:A=>1-Math.pow(1-A,3)})}if(!e&&c.current){const A=c.current.getMap();A&&A.easeTo({pitch:0,bearing:0,duration:800,easing:A=>1-Math.pow(1-A,2)})}return e})},[]),ft=A.useCallback(()=>{L||$(!0)},[L]),dt=A.useCallback((A,e)=>{jA(A),SA(e)},[]),gt=A.useCallback(()=>{QA&&o&&o(QA),jA(null),SA("")},[QA,o]),ht=A.useMemo(()=>[...vr,...sr],[]),mt=A.useRef(!1);A.useEffect(()=>{mt.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const bt=A.useCallback(A=>{A.features&&0!==A.features.length||(mt.current&&ge&&(he(null),wA(null)),xA&&yA(null))},[ge,xA]),vt=A.useCallback(A=>{yA(e=>e===A?null:A)},[]),xt=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;if(A.features.some(A=>{var e,t;return null==(t=null==(e=A.layer)?void 0:e.id)?void 0:t.startsWith("node-markers-")}))return void(vA&&(wA(null),he(null)));const r=A.features.find(A=>{var e;const t=null==(e=A.layer)?void 0:e.id;return(null==t?void 0:t.startsWith("topology-"))||(null==t?void 0:t.startsWith("neighbor-"))});if(!r)return;const n=null==(e=r.layer)?void 0:e.id,o=r.properties;if(!(null==o?void 0:o.key))return;const i=null==n?void 0:n.startsWith("topology-"),a=null==n?void 0:n.startsWith("neighbor-");if(i||a){const e=o.key.replace(/-loop[12]$/,"");wA(e),A.lngLat&&he({longitude:A.lngLat.lng,latitude:A.lngLat.lat,type:i?"topology":"neighbor",properties:o})}try{(null==(t=c.current)?void 0:t.getCanvas())&&(c.current.getCanvas().style.cursor="pointer")}catch{}},[vA]),yt=A.useCallback(()=>{var A;wA(null),he(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),kt=P?"map-container-fullscreen":"map-container-16-9",Rt=E.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),_t=!m||!Rt,Ht=Rt;return e.jsxs("div",{className:`relative ${kt}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":le,children:[e.jsx("span",{id:"map-instructions",className:"sr-only",children:"Interactive map showing mesh network contacts. Use mouse or touch to pan and zoom. Press Tab to navigate map controls. Press Escape to exit fullscreen mode."}),_t&&e.jsx("div",{className:"absolute inset-0 z-50 glass-card flex items-center justify-center","aria-hidden":"true",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),Ht&&e.jsx("div",{className:`relative w-full h-full ${P?"":"rounded-[1.125rem] overflow-hidden"} ${_t?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:e.jsxs(W,{ref:c,...j,onMove:nt,mapStyle:Cr,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:ht,onMouseMove:xt,onMouseLeave:yt,onClick:bt,onError:A=>{},onIdle:()=>{if(!M&&!B&&c.current){const A=c.current.getMap();if(A){const e=Object.values(t).filter(A=>A.latitude&&A.longitude).map(A=>({latitude:A.latitude,longitude:A.longitude}));(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&e.push({latitude:r.latitude,longitude:r.longitude}),e.length>0&&C(e,A)}}},children:[e.jsx(V,{position:"bottom-right"}),e.jsx(MA,{mode:le}),e.jsx(At,{enabled:Z,exaggeration:4}),e.jsx(Ze,{coveragePoints:re,visible:re.length>0&&ne,terrainEnabled:Z,brightness:oe,basemapMode:le}),e.jsx(pt,{partition:He,nodeCoordinates:De,visible:G&&UA,opacity:U.opacity,bandwidth:U.bandwidth,threshold:U.threshold,strokeWidth:U.strokeWidth}),e.jsx(pr,{showTopology:L,isExiting:Ye,hoveredEdgeKey:vA,highlightedLoopEdges:null==pe?void 0:pe.highlightedEdgeKeys,highlightedFocusEdges:Re,onEdgeHover:xe,onLoopHover:ke,loops:u.loops,neighborNames:Be,opacityBias:kA,widthMultiplier:DA,trafficFilter:EA,showNeighborLines:R,disableHover:We||HA}),i&&e.jsx(wr,{targetHash:i,nodeCoordinates:De,onComplete:a}),s&&e.jsx(xr,{highlightedEdgeKey:s,validatedPolylines:Fe,weakPolylines:Pe,onEnsureTopology:ft}),e.jsx(kr,{ghost:l??null,neighborCoordinates:De,onHighlightedNeighborsChange:te}),e.jsx(ar,{neighborsWithLocation:Me,localNode:r,localHash:n,zeroHopNeighbors:Qe,lastHopNeighborMap:Ee,meshTopology:u,hoveredMarker:bA,onMarkerHover:pA,getNodeOpacity:Xe,shouldShowNode:et,onRequestRemove:o?dt:void 0,openPopupId:KA,onOpenPopup:$A,onClosePopup:ee,onNodeClick:vt,blinkingNodes:qe,blinkColor:$e})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"hops",value:A.size},{label:"seen",value:A.minCertainCount}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`+${t-1} overlapping`,color:"text-violet-400/70"}),{type:"loop",title:{icon:"⟳",text:"Redundant Path"+(t>1?"s":""),color:"text-violet-400"},subtitle:{text:`${e.nodeNames.join(" → ")} → ${e.nodeNames[0]}`,color:"text-text-secondary",mono:!0},stats:r,badges:n}}if("neighbor"===(null==A?void 0:A.type)){const e=A.properties,t=[];void 0!==e.rssi&&null!==e.rssi&&t.push({label:"RSSI",value:`${Math.round(e.rssi)} dBm`,unit:e.hasAvgRssi?"avg":void 0}),void 0!==e.snr&&null!==e.snr&&t.push({label:"SNR",value:`${Number(e.snr).toFixed(1)} dB`,unit:e.hasAvgSnr?"avg":void 0});const r=e.listenerScore??0,n=e.loudScore??0,o=r>0||n>0;return o&&(t.push({label:"listener",value:r,color:"text-accent-success"}),t.push({label:"loud",value:n,color:"text-accent-danger"})),void 0===e.packetCount||o||t.push({label:"packets",value:Number(e.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:e.prefix?`${e.name} (${e.prefix})`:e.name,color:"text-amber-400"},subtitle:{text:"Direct RF Neighbor",color:"text-amber-400/70"},stats:t,badges:[]}}if("topology"===(null==A?void 0:A.type)){const e=A.properties,r=t>0?Number(e.certainCount)/t:0,n=[{label:"validations",value:e.certainCount},{label:"of max traffic",value:`${Math.round(100*r)}%`},{label:"confidence",value:`${Math.round(100*Number(e.confidence))}%`}];if(void 0!==e.symmetryRatio&&e.symmetryRatio<1){const A="forward"===e.dominantDirection?"→":"reverse"===e.dominantDirection?"←":"↔";n.push({label:"symmetric",value:`${A} ${Math.round(100*e.symmetryRatio)}%`,color:"text-text-muted"})}const o=[];return e.isBackbone&&o.push({text:"Backbone",color:"text-gray-300"}),e.isLoopEdge&&o.push({text:"Redundant",color:"text-violet-400"}),e.isDirectPath&&o.push({text:"Direct Path",color:"text-teal-400"}),{type:"topology",title:{icon:"",text:`${e.fromName} ↔ ${e.toName}`,color:"text-text-primary"},stats:n,badges:o}}return null}(ge?{type:ge.type,properties:ge.properties}:null,pe,_e);return A&&e.jsx("div",{className:"map-edge-tooltip",children:e.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:e.jsx(Mr,{data:A})})})})(),e.jsx(WA,{mapRef:c,showNeighborLines:R,onToggleNeighborLines:lt,hasNeighborPolylines:Te.length>0,nodeFilter:X,onNodeFilterChange:st,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:Qe.size>0,showCoverage:H,onToggleCoverage:ct,showMinCut:G,onToggleMinCut:ze,hasMinCutData:UA&&null!==He&&He.numCommunities>1,show3DTerrain:Z,onToggle3DTerrain:ut,basemapMode:le,onToggleBasemap:ue,isFullscreen:P,onToggleFullscreen:ot}),e.jsxs("div",{className:"map-legend-stack",children:[e.jsx(JA,{isActive:L,hasAnalyzed:UA,isLoading:HA,onClick:rt}),e.jsx(qA,{isActive:ae,onClick:se}),e.jsx(Ae,{isActive:re.length>0&&ne,onClick:ie}),e.jsx(YA,{showTopology:L,validatedPolylineCount:Fe.length,filteredNeighborCount:Me.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:Qe,neighborsWithLocation:Me})]}),!P&&e.jsx("div",{className:"glass-card-frame absolute inset-0 pointer-events-none rounded-[1.125rem]",style:{zIndex:9999},"aria-hidden":"true"}),e.jsx(gA,{isOpen:null!==QA,onCancel:()=>jA(null),onConfirm:gt,title:"Remove Node?",message:`Remove "${NA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),e.jsx(hA,{isOpen:TA,currentStep:RA,packetCount:GA}),e.jsx(me,{}),e.jsx(we,{visible:G&&UA,onClose:()=>iA(!1),settings:U,onSettingsChange:Y,partition:He,totalNodes:Object.keys(t).length})]})}export{Dr as default}; +import{r as A,j as e,aT as t,ab as r,q as n,am as o,aK as i,m as a,C as s,A as l,W as c,bP as u,bQ as f,bR as d,bS as g,bq as h,br as m,aL as b,_ as p,bb as v,aq as w,aJ as x,a9 as y,bT as k,i as C,bN as B,X as M,bU as D,$ as E,bV as Q,bo as j,aZ as N,bW as S,bX as F,bY as P,ak as T,bZ as L,bO as I,bk as R,bl as _,a0 as H,D as z,aS as G,ar as O,b_ as U,bM as Y,bj as W,b$ as V}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as Z,c as K}from"./link-scoring-Cw0dJsWv.js";import{M as J,Y as X,T as q,y as $,Q as AA,m as eA,aN as tA,aO as rA,n as nA,aP as oA,B as iA,a6 as aA,al as sA,ak as lA,f as cA,r as uA,aQ as fA,aR as dA}from"./index-BJEgt3tp.js";import{C as gA}from"./ConfirmModal-CYXFGX_W.js";import{D as hA}from"./DeepAnalysisModal-D4eqwCNZ.js";import{i as mA,j as bA,k as pA,l as vA}from"./useThemeColors-AeHMyThq.js";import{l as wA}from"./font-loader-jlbdh9Fw.js";import{p as xA,a as yA}from"./vendor-core-WoOfkQwm.js";import{x as kA}from"./recharts-6XUQYgRA.js";import{u as CA,a as BA,B as MA}from"./BasemapLayer-S9Ush6Hh.js";import{P as DA,N as EA}from"./Contacts-CyyU4xmf.js";import{H as QA,C as jA,N as NA,b as SA}from"./SignalIndicator-BLrEkFNb.js";import"./deckgl-DTsmDcfs.js";import"./ping-DvLgBqTv.js";import"./PageLayout-CnF5SScd.js";import"./DataBox-CRX76VsB.js";import"./CollisionExplorerModal-DTnzK_xA.js";function FA(A,e,t,r){const n=(t-A)*Math.PI/180,o=(r-e)*Math.PI/180,i=Math.sin(n/2)*Math.sin(n/2)+Math.cos(A*Math.PI/180)*Math.cos(t*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2);return 2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i))*6371e3}function PA(A,e){const t=Math.max(5,Math.min(A,300)),r=Math.log(5),n=Math.log(300);return 1+(Math.log(t)-r)/(n-r)*5}const TA={nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",nodeColor:"#4338CA",localColor:"#FFB224",hubColor:"#8E4EC6",gatewayColor:"#5B5BD6",mobileColor:"#F76B15",roomServerColor:"#D6409F",neighborColor:"#FFB224",edges:{rest:"#4B4B4B",restBright:"#616161",restDim:"#3F3F3F",hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:"#8A8A8A",hoverNeighbor:"#FBBF24",neighborRest:"#6B7280",neighborHover:"#FBBF24",highlight:"#FFD700"},edgeOpacity:.82};function LA(){if("undefined"==typeof window)return TA;const A=mA(),e=bA();return{nodeFill:A.nodeFill,nodeStroke:A.nodeStroke,nodeColor:TA.nodeColor,localColor:A.localColor,hubColor:A.hubColor,gatewayColor:A.gatewayColor,mobileColor:A.mobileColor,roomServerColor:A.roomColor,neighborColor:A.neighborColor,edges:{rest:e.rest,restBright:e.restBright,restDim:e.restDim,hoverDirect:e.hoverDirect,hoverLoop:e.hoverLoop,hoverStandard:e.hoverStandard,hoverNeighbor:e.hoverNeighbor,neighborRest:TA.edges.neighborRest,neighborHover:TA.edges.neighborHover,highlight:e.highlight},edgeOpacity:TA.edgeOpacity}}const IA=2e3,RA={type:"spring",stiffness:500,damping:35};function _A({color:A,ring:t}){return e.jsx("span",{className:"shrink-0 rounded-full",style:{width:14,height:14,backgroundColor:t?"transparent":A,border:t?`4px solid ${A}`:void 0,boxSizing:"border-box"}})}function HA({color:A}){return e.jsx("span",{className:"shrink-0 rounded-sm",style:{width:16,height:3,backgroundColor:A}})}function zA({indicator:A,label:t,tooltip:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[A,e.jsx("span",{className:"text-text-secondary",children:t}),r&&e.jsx(q,{content:r,delay:200,children:e.jsx("span",{className:"text-text-muted cursor-help text-[10px] opacity-60 hover:opacity-100 transition-opacity",children:"ⓘ"})})]})}function GA({title:A,tooltip:t,isOpen:r,onToggle:n,showDivider:o,children:i}){return e.jsxs("div",{className:o?"mt-2 pt-2 border-t border-map-ui-border":"",children:[e.jsxs("button",{type:"button",onClick:n,className:"group w-full flex items-center justify-between py-1 text-text-secondary font-medium hover:text-text-primary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[A,e.jsx(q,{content:t,delay:200,children:e.jsx("span",{className:"text-text-muted cursor-help text-[10px] opacity-60 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),e.jsx(a.span,{animate:{rotate:r?0:-90},transition:{duration:.15},children:e.jsx(s,{className:"w-3 h-3 text-text-muted"})})]}),e.jsx(l,{initial:!1,children:r&&e.jsx(a.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:RA,className:"overflow-hidden",children:e.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:i})})})]})}function OA({label:A,value:t,color:r}){return e.jsxs("div",{className:"flex justify-between tabular-nums text-text-muted",children:[e.jsx("span",{children:A}),e.jsx("span",{className:"text-text-secondary",style:r?{color:r}:void 0,children:t})]})}function UA({icon:A,color:t,title:r,subtitle:n}){return e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-map-ui-border",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0",style:{color:t},children:A}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"font-medium truncate",style:{color:t},children:r}),e.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:n})]})]})})}function YA({showTopology:a,validatedPolylineCount:s,filteredNeighborCount:l,hasLocalNode:c,meshTopology:u,zeroHopNeighbors:f,neighborsWithLocation:d}){const g=pA(),h=J(),m=X(),b=h.filter(A=>A.isLikelyReal).length,p=function(A){let e=0;for(const t of A.txDelayRecommendations.values())"backbone"===t.networkRole&&e++;return e}(u),v=f.size>0,[w,x]=A.useState(!0),[y,k]=A.useState(!0),[C,B]=A.useState(!0);return e.jsxs("div",{className:"map-control-glass p-2.5 text-xs",children:[e.jsxs(GA,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:w,onToggle:()=>x(A=>!A),children:[e.jsx(zA,{indicator:e.jsx(_A,{color:g.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),e.jsx(zA,{indicator:e.jsx(_A,{color:g.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),(M=d,M.some(([,A])=>{var e;const t=null==(e=A.contact_type)?void 0:e.toLowerCase();return"room server"===t||"room_server"===t||"room"===t||"server"===t})&&e.jsx(zA,{indicator:e.jsx(t,{className:"w-3 h-3 shrink-0",style:{color:g.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."})),e.jsx(zA,{indicator:e.jsx(r,{className:"w-3 h-3 shrink-0",style:{color:g.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),v&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),u.gatewayNodes.length>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),p>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),u.mobileNodes.length>0&&e.jsx(zA,{indicator:e.jsx(_A,{color:g.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),b>0&&e.jsx(zA,{indicator:e.jsx(n,{className:"w-3 h-3 shrink-0",style:{color:g.ghostColor},strokeWidth:2.5}),label:`Ghost (${b})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),v&&e.jsxs(GA,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:y,onToggle:()=>k(A=>!A),showDivider:!0,children:[e.jsx(zA,{indicator:e.jsx(HA,{color:Z.YELLOW}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),e.jsx(zA,{indicator:e.jsx(HA,{color:Z.GREEN}),label:"Listener",tooltip:">67% listener. They hear us well."}),e.jsx(zA,{indicator:e.jsx(HA,{color:Z.RED}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),a&&s>0&&e.jsxs(GA,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:C,onToggle:()=>B(A=>!A),showDivider:!0,children:[e.jsx(OA,{label:"Nodes",value:l+(c?1:0)}),u.hubNodes.length>0&&e.jsx(OA,{label:"Hubs",value:u.hubNodes.length,color:TA.hubColor}),u.loops.length>0&&e.jsx(UA,{icon:e.jsx(o,{className:"w-3 h-3"}),color:TA.edges.hoverLoop,title:`${u.loops.length} ${1===u.loops.length?"Loop":"Loops"}`,subtitle:"Redundant paths"}),m.totalPaths>0&&e.jsx(UA,{icon:e.jsx(i,{className:"w-3 h-3"}),color:g.ghostColor,title:`${m.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]});var M}function WA({mapRef:A,showNeighborLines:t,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:w,showMinCut:x=!1,onToggleMinCut:y,hasMinCutData:k=!1,show3DTerrain:C,onToggle3DTerrain:B,basemapMode:M,onToggleBasemap:D,isFullscreen:E,onToggleFullscreen:Q}){const j="w-4 h-4";return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4",children:[e.jsxs("div",{className:"map-control-glass flex items-center gap-1 p-1",children:[n&&e.jsx($,{plain:!0,color:t?"warning":"muted",onClick:r,title:t?"Hide edge lines":"Show edge lines","aria-label":t?"Hide edge lines":"Show edge lines","aria-pressed":t,className:"!p-1.5 !rounded-md",children:e.jsx(c,{className:j})}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(AA,{color:"all"===o?"green":"zinc",onClick:()=>i("all"),title:"Show all nodes",children:"All"}),a&&e.jsx(AA,{color:"hubs"===o?"green":"zinc",onClick:()=>i("hubs"),title:"Show only hub nodes and their connections",children:"Hubs"}),s&&e.jsx(AA,{color:"direct"===o?"green":"zinc",onClick:()=>i("direct"),title:"Show only zero-hop (direct RF) neighbors",children:"Direct"})]}),k&&y&&e.jsx($,{plain:!0,color:x?"primary":"muted",onClick:y,title:x?"Hide community partition":"Show community partition","aria-label":x?"Hide community partition":"Show community partition","aria-pressed":x,className:"!p-1.5 !rounded-md",children:e.jsx(u,{className:j})}),e.jsx($,{plain:!0,color:"light"===M?"primary":"muted",onClick:D,title:"light"===M?"Switch to dark map":"Switch to light map","aria-label":"light"===M?"Switch to dark map":"Switch to light map","aria-pressed":"light"===M,className:"!p-1.5 !rounded-md",children:"light"===M?e.jsx(f,{className:j}):e.jsx(d,{className:j})}),e.jsx($,{plain:!0,color:C?"success":"muted",onClick:B,title:C?"Disable 3D terrain":"Enable 3D terrain","aria-label":C?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":C,className:"!p-1.5 !rounded-md",children:e.jsx(g,{className:j})}),e.jsx($,{plain:!0,color:"muted",onClick:Q,title:E?"Exit fullscreen":"Fullscreen","aria-label":E?"Exit fullscreen":"Enter fullscreen","aria-pressed":E,className:"!p-1.5 !rounded-md",children:E?e.jsx(h,{className:j}):e.jsx(m,{className:j})})]}),e.jsxs("div",{className:"map-control-glass flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomIn()},title:"Zoom in","aria-label":"Zoom in",className:"!p-1.5 !rounded-none",children:e.jsx(b,{className:j})}),e.jsx("div",{className:"h-px bg-border-subtle"}),e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomOut()},title:"Zoom out","aria-label":"Zoom out",className:"!p-1.5 !rounded-none",children:e.jsx(p,{className:j})}),e.jsx("div",{className:"h-px bg-border-subtle"}),e.jsx($,{plain:!0,color:"muted",onClick:()=>{var e;const t=null==(e=A.current)?void 0:e.getMap();t&&t.easeTo({bearing:0,pitch:0,duration:300})},title:"Reset bearing to north","aria-label":"Reset bearing to north",className:"!p-1.5 !rounded-none",children:e.jsx(v,{className:j})})]})]})})}const VA="#4ADE80",ZA="DeepAnalysis";function KA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function JA({isActive:t,hasAnalyzed:r,isLoading:n,onClick:o}){const[i,a]=A.useState(!1),[s,l]=A.useState(ZA),c=A.useRef(!1),u=A.useRef(null),[f]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),d=i&&!t&&!n&&f;A.useEffect(()=>{if(i&&!t&&!n&&!c.current){c.current=!0;const A=performance.now(),e=t=>{const r=t-A,n=Math.min(r/700,1),o=Math.floor(12*n);let i="";for(let A=0;A<12;A++)i+=A{u.current&&cancelAnimationFrame(u.current)}},[i,t,n]);const g=n?"Analyzing...":s;return e.jsxs("button",{onClick:o,onMouseEnter:()=>f&&a(!0),onMouseLeave:()=>f&&a(!1),onPointerEnter:()=>f&&a(!0),onPointerLeave:()=>f&&a(!1),disabled:n,className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors "+(n?"cursor-wait":""),style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-green)":"var(--map-ui-bg, var(--bg-surface))"},title:n?"Analyzing packet history...":r?t?"Hide topology edges":"Show topology edges":"Load full packet history and build topology",children:[n?e.jsx(w,{className:"w-3.5 h-3.5 flex-shrink-0 text-green-400 animate-spin"}):e.jsx(x,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(t?"text-green-400":"text-text-secondary"),style:d?{color:VA}:void 0}),e.jsx("span",{className:t?"text-green-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:t||d?700:500,letterSpacing:"-0.01em",lineHeight:1,...d?{color:VA}:{}},children:g})]})}const XA="#12A594";function qA({isActive:t,onClick:r}){const[n,o]=A.useState(!1),[i,a]=A.useState(0),s=A.useRef(!1),l=A.useRef(null),[c,u]=A.useState(0),f=A.useRef(!1),[d]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!t&&d;A.useEffect(()=>{g&&!f.current&&(f.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(f.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!t&&!s.current){s.current=!0;const A=performance.now(),e=t=>{const r=t-A,n=Math.min(r/400,1);a(n),n<1&&(l.current=requestAnimationFrame(e))};l.current=requestAnimationFrame(e)}return n||(l.current&&(cancelAnimationFrame(l.current),l.current=null),s.current=!1,a(0)),()=>{l.current&&cancelAnimationFrame(l.current)}},[n,t]);const h=A=>{if(t)return;if(!g)return;const e=11*i;return A>=e-2&&Ad&&o(!0),onMouseLeave:()=>d&&o(!1),onPointerEnter:()=>d&&o(!0),onPointerLeave:()=>d&&o(!1),className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors",style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-teal)":"var(--map-ui-bg, var(--bg-surface))"},title:t?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[e.jsx(y,{className:"w-3.5 h-3.5 flex-shrink-0 "+(t?"text-sys-teal":"text-text-secondary"),fill:1===c?"#FFFFFF":3===c?XA:"none",stroke:1===c||2===c?"#FFFFFF":g?XA:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),e.jsx("span",{className:t?"text-sys-teal":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:t||g?700:500,letterSpacing:"-0.01em",lineHeight:1},children:"LiveTrace".split("").map((A,t)=>e.jsx("span",{style:{color:h(t)||void 0},children:A},t))})]})}const $A="#fe8019";function Ae({isActive:t,onClick:r,brightness:n=.7,onBrightnessChange:o}){const[i,a]=A.useState(!1),[s,l]=A.useState(!1),[c]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)});A.useEffect(()=>{wA()},[]),A.useEffect(()=>{if(!i||t)return;const A=requestAnimationFrame(()=>l(!0)),e=setTimeout(()=>l(!1),80);return()=>{cancelAnimationFrame(A),clearTimeout(e)}},[i,t]);const u=Math.max(.01,Math.min(1,n)),g=u<.999,h=u>.011,m=i&&!t&&c;return e.jsxs("button",{onClick:r,onMouseEnter:()=>c&&a(!0),onMouseLeave:()=>c&&a(!1),onPointerEnter:()=>c&&a(!0),onPointerLeave:()=>c&&a(!1),className:"flex items-center gap-2 w-full text-left rounded-lg transition-colors",style:{padding:"0.5rem 0.625rem",backgroundColor:t?"var(--sidebar-action-active-amber)":"var(--map-ui-bg, var(--bg-surface))"},title:t?"Configure wardriving coverage":"Show wardriving coverage",children:[e.jsx(k,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(t?"text-amber-400":"text-text-secondary"),style:m?{color:$A}:void 0}),e.jsx("span",{className:t?"text-amber-400":"text-text-secondary",style:{fontFamily:t||m?"'Jacquard 12', serif":"ui-monospace, SFMono-Regular, monospace",fontSize:t||m?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:t?"scale(1.45)":m?`scale(${s?1.595:1.45})`:void 0,transformOrigin:"left center",...m?{color:$A}:{}},children:"Wardrive"}),t&&o&&e.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[e.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.max(.01,u-.2);null==o||o(e)},disabled:!h,className:"p-0.5 rounded transition-colors "+(h?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:e.jsx(d,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.min(1,u+.2);null==o||o(e)},disabled:!g,className:"p-0.5 rounded transition-colors "+(g?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:e.jsx(f,{className:"w-3.5 h-3.5"})})]})]})}function ee(A){let e=!0,t=-90,r=90,n=-180,o=180;for(const i of A.toLowerCase()){const A="0123456789bcdefghjkmnpqrstuvwxyz".indexOf(i);if(-1!==A)for(let i=4;i>=0;i--){const a=A>>i&1;if(e){const A=(n+o)/2;a?n=A:o=A}else{const A=(t+r)/2;a?t=A:r=A}e=!e}}return{lat:(t+r)/2,lon:(n+o)/2}}function te(A){return Math.exp(-A*Math.LN2/7)}const re="pymc-wardriving-url",ne="pymc-wardriving-enabled",oe="pymc-wardriving-brightness";function ie(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(re,A):localStorage.removeItem(re))}function ae(A){"undefined"!=typeof localStorage&&localStorage.setItem(ne,String(A))}function se(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(oe);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function le(A,e=null){if(null!==A){const t=(Math.max(-12,Math.min(12,A))+12)/24;return null!==e?.8*t+(Math.max(-120,Math.min(-50,e))+120)/70*.2:t}return null!==e?(Math.max(-120,Math.min(-50,e))+120)/70:.5}const ce=C((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(ne),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(re)||"",brightness:se(),isModalOpen:!1,openModal:()=>A({isModalOpen:!0}),closeModal:()=>A({isModalOpen:!1}),setUrl:e=>A({url:e}),setBrightness:e=>{const t=Math.max(.01,Math.min(1,e));!function(A){if("undefined"==typeof localStorage)return;const e=Math.max(.01,Math.min(1,A));localStorage.setItem(oe,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;ae(t),A({isVisible:t})},setVisible:e=>{ae(e),A({isVisible:e})},loadCoverage:async e=>{if(!e.trim())return A({error:"Please enter a URL",status:"error"}),!1;try{new URL(e.trim())}catch{return A({error:"Invalid URL format",status:"error"}),!1}A({error:null,status:"connecting"});try{A({status:"loading"});const t=await async function(A){const e=`${A.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,t=await async function(A,e={},t=8e3){const r=new AbortController,n=setTimeout(()=>r.abort(),t);try{return await fetch(A,{...e,signal:r.signal})}catch(o){if(o instanceof Error&&"AbortError"===o.name)throw new Error(`Connection timed out after ${t/1e3}s`);throw o}finally{clearTimeout(n)}}(e,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to fetch precise samples: ${t.status}`);return t.json()}(e.trim());if(!t||"object"!=typeof t)throw new Error("Invalid response from server");if(!Array.isArray(t.keys))throw new Error("No sample data found in response");A({status:"processing"});const r=function(A){var e;const t=[];for(const r of A.keys){if(!r.observed)continue;const{lat:A,lon:n}=ee(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=te(i),s=le(r.snr,r.rssi)*(.3+.7*a);t.push({lat:A,lon:n,successRate:r.observed?1:0,weight:s,totalSamples:1,ageDays:i,geohash:r.hash,repeaters:(null==(e=r.path)?void 0:e.map(A=>A.toLowerCase()))||[]})}return t}(t);if(0===r.length)throw new Error("No valid coverage points found");return A({coveragePoints:r,repeaters:[],stats:{coverageCount:r.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:e.trim()}),ie(e.trim()),ae(!0),!0}catch(t){const e=t instanceof Error?t.message:"Failed to load coverage data";let r=e;return e.includes("timed out")?r="Connection timed out. Server may be unreachable or slow.":e.includes("Failed to fetch")||e.includes("NetworkError")?r="Could not connect to server. Check the URL and try again.":e.includes("CORS")?r="Server does not allow cross-origin requests.":e.includes("404")?r="Coverage endpoint not found. Check the URL.":(e.includes("ERR_NAME_NOT_RESOLVED")||e.includes("DNS"))&&(r="Server not found. Check the URL for typos."),A({error:r,status:"error"}),!1}},clearCoverage:()=>{A({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),ie(""),ae(!1)}})),ue={type:"spring",damping:25,stiffness:300},fe={type:"spring",damping:20,stiffness:300};function de({status:A}){if("connecting"!==A&&"loading"!==A&&"processing"!==A)return null;const t={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[A];if(!t)return null;const r="connecting"===A?30:"loading"===A?60:90;return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[e.jsx("div",{className:"relative",children:e.jsx(w,{className:"w-5 h-5 text-amber-400 animate-spin"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-amber-400 font-medium",children:t}),e.jsx("div",{className:"mt-2 h-1.5 bg-amber-500/20 rounded-full overflow-hidden",children:e.jsx(a.div,{className:"h-full bg-amber-400 rounded-full",initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:"easeOut"}})})]})]})})}function ge({icon:A,title:t,description:r,variant:n}){const o={success:"bg-accent-success/10 border-accent-success/30 text-accent-success",error:"bg-accent-danger/10 border-accent-danger/30 text-accent-danger",warning:"bg-accent-secondary/10 border-accent-secondary/30 text-accent-secondary"}[n];return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsxs("div",{className:`flex items-start gap-3 p-4 border rounded-xl ${o}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:A}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t}),r&&e.jsx("p",{className:"text-xs opacity-80 mt-0.5",children:r})]})]})})}function he({icon:A,label:t,value:r,min:n,max:o,formatValue:i,onChange:s}){const l=i?i(r):`${Math.round(r)}%`;return e.jsx(a.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:16},exit:{opacity:0,height:0,marginTop:0},transition:fe,className:"overflow-hidden",children:e.jsx("div",{className:"p-4 bg-bg-surface border border-border-subtle rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"text-text-muted",children:A}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:t}),e.jsx("span",{className:"text-xs text-text-muted font-mono tabular-nums",children:l})]}),e.jsx("input",{type:"range",min:n,max:o,value:r,onChange:A=>s(Number(A.target.value)),className:"w-full h-1.5 bg-bg-elevated rounded-full appearance-none cursor-pointer\n [&::-webkit-slider-thumb]:appearance-none\n [&::-webkit-slider-thumb]:w-3.5\n [&::-webkit-slider-thumb]:h-3.5\n [&::-webkit-slider-thumb]:rounded-full\n [&::-webkit-slider-thumb]:bg-accent-secondary\n [&::-webkit-slider-thumb]:cursor-pointer\n [&::-webkit-slider-thumb]:transition-transform\n [&::-webkit-slider-thumb]:hover:scale-110\n [&::-webkit-slider-thumb]:shadow-md"})]})]})})})}function me(){const{isModalOpen:t,closeModal:r,status:n,isVisible:o,stats:s,error:c,url:u,brightness:d,loadCoverage:g,clearCoverage:h,toggleVisibility:m,setUrl:b,setBrightness:p}=ce(),v="connecting"===n||"loading"===n||"processing"===n,[x,y]=A.useState(u),k=A.useCallback(async()=>{await g(x)},[x,g]),C=A.useCallback(()=>{y(""),h()},[h]),F=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||v||(A.preventDefault(),k())},[k,v]),P=A.useCallback(A=>{const e=A.target.value;y(e),b(e)},[b]),T=s.coverageCount>0,L=x.trim().length>0&&!v;return e.jsx(l,{children:t&&e.jsxs("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center",children:[e.jsx(a.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:v?void 0:r}),e.jsx(a.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:ue,className:"relative w-full max-w-md mx-4",children:e.jsxs("div",{className:"map-control-glass rounded-2xl overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-accent-secondary/20",children:e.jsx(B,{className:"w-5 h-5 text-accent-secondary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),e.jsx($,{plain:!0,color:"muted",onClick:r,disabled:v,className:"!p-2 !rounded-lg","aria-label":"Close modal",children:e.jsx(M,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),e.jsx("input",{type:"url",value:x,onChange:P,onKeyDown:F,placeholder:"https://coverage.wcmesh.com",className:"w-full px-4 py-3 bg-bg-surface border border-border-subtle rounded-xl \n text-text-primary placeholder:text-text-muted \n focus:outline-none focus:ring-2 focus:ring-accent-secondary/50 focus:border-accent-secondary/50 \n transition-all disabled:opacity-50",disabled:v}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:"Enter the base URL of a wardriving coverage server (e.g., coverage.wcmesh.com)"})]}),e.jsxs(l,{mode:"wait",children:[v&&e.jsx(de,{status:n},"loading"),"error"===n&&c&&e.jsx(ge,{icon:e.jsx(D,{className:"w-5 h-5"}),title:"Connection Failed",description:c,variant:"error"},"error"),"success"===n&&T&&e.jsx(ge,{icon:e.jsx(E,{className:"w-5 h-5"}),title:"Data Loaded Successfully",description:`${s.coverageCount.toLocaleString()} coverage points • ${s.repeaterCount.toLocaleString()} repeaters`,variant:"success"},"success"),T&&!v&&"success"!==n&&e.jsx(ge,{icon:e.jsx(Q,{className:"w-5 h-5"}),title:"Coverage Data Loaded",description:`${s.coverageCount.toLocaleString()} points${s.lastUpdated?` • Last updated ${s.lastUpdated.toLocaleTimeString()}`:""}`,variant:"warning"},"info")]}),e.jsx(l,{children:T&&!v&&e.jsx(he,{icon:e.jsx(f,{className:"w-4 h-4 "+(d>.5?"text-accent-secondary":"text-text-muted")}),label:"Brightness",value:100*d,min:1,max:100,formatValue:A=>`${Math.round(A)}%`,onChange:A=>p(A/100)},"brightness")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-t border-border-subtle",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(l,{children:T&&e.jsxs(a.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},className:"flex items-center gap-1",children:[e.jsx($,{plain:!0,color:"muted",onClick:m,disabled:v,title:o?"Hide heatmap":"Show heatmap",children:o?e.jsxs(e.Fragment,{children:[e.jsx(j,{"data-slot":"icon"})," Hide"]}):e.jsxs(e.Fragment,{children:[e.jsx(i,{"data-slot":"icon"})," Show"]})}),e.jsxs($,{plain:!0,color:"danger",onClick:C,disabled:v,title:"Clear coverage data",children:[e.jsx(N,{"data-slot":"icon"})," Clear"]})]})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{plain:!0,color:"muted",onClick:r,disabled:v,children:T?"Done":"Cancel"}),e.jsx($,{color:"warning",onClick:k,disabled:!L,children:v?e.jsxs(e.Fragment,{children:[e.jsx(w,{"data-slot":"icon",className:"animate-spin"}),"Loading..."]}):T?e.jsxs(e.Fragment,{children:[e.jsx(S,{"data-slot":"icon"}),"Refresh"]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{"data-slot":"icon"}),"Connect"]})})]})]})]})})]})})}const be={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function pe({label:A,value:t,min:r,max:n,step:o,unit:i,formatValue:a,onChange:s}){const l=a?a(t):t.toFixed(2);return e.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[e.jsx("span",{className:"text-[11px] sm:text-[11px] text-text-secondary w-14 sm:w-16 flex-shrink-0",children:A}),e.jsx("input",{type:"range",min:r,max:n,step:o,value:t,onChange:A=>s(parseFloat(A.target.value)),className:"flex-1 h-1.5 sm:h-1 bg-bg-elevated rounded-full appearance-none cursor-pointer\n [&::-webkit-slider-thumb]:appearance-none\n [&::-webkit-slider-thumb]:w-4\n [&::-webkit-slider-thumb]:h-4\n [&::-webkit-slider-thumb]:sm:w-2.5\n [&::-webkit-slider-thumb]:sm:h-2.5\n [&::-webkit-slider-thumb]:rounded-full\n [&::-webkit-slider-thumb]:bg-accent-primary\n [&::-webkit-slider-thumb]:cursor-pointer\n [&::-webkit-slider-thumb]:shadow-md"}),e.jsxs("span",{className:"text-[11px] sm:text-[11px] text-text-primary font-mono tabular-nums w-12 sm:w-14 text-right flex-shrink-0",children:[l,i&&e.jsx("span",{className:"text-text-muted ml-0.5 hidden sm:inline",children:i})]})]})}function ve({icon:A,label:t,value:r,subtext:n}){return e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[e.jsx("div",{className:"text-text-muted",children:A}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"text-[10px] sm:text-[11px] text-text-secondary truncate",children:t})}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[11px] sm:text-xs font-mono text-text-primary",children:r}),n&&e.jsx("div",{className:"text-[8px] sm:text-[9px] text-text-muted leading-tight",children:n})]})]})}function we({visible:t,onClose:r,settings:n,onSettingsChange:o,partition:i,totalNodes:s}){const c=F(),f=A.useRef(null),d=A.useMemo(()=>{if(!i)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const A=Array.from(i.communities.values()).map(A=>A.length),e=A.reduce((A,e)=>A+e,0);return{numCommunities:i.numCommunities,avgCommunitySize:A.length>0?Math.round(e/A.length):0,minCommunitySize:A.length>0?Math.min(...A):0,maxCommunitySize:A.length>0?Math.max(...A):0,fiedlerValue:i.fiedlerValue,modularity:0,coveragePercent:s>0?Math.round(e/s*100):0}},[i,s]),g=(A,e)=>{o({...n,[A]:e})},h=(111*n.bandwidth).toFixed(1);return e.jsx("div",{ref:f,className:"absolute inset-0 z-[600] pointer-events-none",children:e.jsx(l,{children:t&&e.jsx(a.div,{drag:!0,dragControls:c,dragConstraints:f,dragElastic:.1,dragMomentum:!1,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{type:"spring",damping:25,stiffness:300},className:"\n absolute pointer-events-auto\n /* Mobile: bottom sheet style, full width with margins */\n bottom-2 left-2 right-2\n /* sm+: floating panel in bottom-right */\n sm:bottom-16 sm:left-auto sm:right-3 sm:w-64\n /* md+: slightly wider */\n md:w-72\n ",style:{touchAction:"none"},children:e.jsxs("div",{className:"\n map-control-glass rounded-lg overflow-hidden shadow-lg\n /* Mobile: limit height, allow scroll */\n max-h-[45vh] sm:max-h-[calc(100vh-180px)] overflow-y-auto\n /* iOS momentum scrolling */\n overscroll-contain\n ",children:[e.jsxs("div",{className:"\n flex items-center justify-between \n px-3 py-2 sm:px-2.5 sm:py-1.5 \n border-b border-border-subtle \n cursor-grab active:cursor-grabbing\n /* Larger touch target on mobile */\n min-h-[44px] sm:min-h-0\n ",onPointerDown:A=>c.start(A),children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx(P,{className:"w-4 h-4 sm:w-3 sm:h-3 text-text-muted"}),e.jsx(u,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-accent-primary"}),e.jsx("span",{className:"text-sm sm:text-xs font-medium text-text-primary",children:"Partition"})]}),e.jsx($,{plain:!0,color:"muted",onClick:r,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:e.jsx(M,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),e.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b border-border-subtle",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[e.jsx(ve,{icon:e.jsx(u,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:d.numCommunities}),e.jsx(ve,{icon:e.jsx(T,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:d.avgCommunitySize,subtext:`${d.minCommunitySize}–${d.maxCommunitySize}`}),e.jsx(ve,{icon:e.jsx(L,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:d.fiedlerValue.toFixed(3)}),e.jsx(ve,{icon:e.jsx(T,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${d.coveragePercent}%`,subtext:`of ${s}`})]})}),e.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:e.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[e.jsx(pe,{label:"Bandwidth",value:n.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>h,unit:"km",onChange:A=>g("bandwidth",A)}),e.jsx(pe,{label:"Threshold",value:n.threshold,min:.05,max:.5,step:.01,formatValue:A=>`${Math.round(100*(1-A))}%`,unit:"cov",onChange:A=>g("threshold",A)}),e.jsx(pe,{label:"Opacity",value:n.opacity,min:.1,max:1,step:.05,formatValue:A=>`${Math.round(100*A)}%`,onChange:A=>g("opacity",A)}),e.jsx(pe,{label:"Stroke",value:n.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:A=>A.toFixed(1),onChange:A=>g("strokeWidth",A)})]})})]})})})})}const xe={getItem:A=>{try{return localStorage.getItem(A)}catch{return null}},setItem:(A,e)=>{try{localStorage.setItem(A,e)}catch{}},removeItem:A=>{try{localStorage.removeItem(A)}catch{}}},ye=C()(xA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:yA(()=>xe)}));var ke=function(A){var e,t=void 0!==(A=A||{})?A:{},r={};for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);var n,o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",n=function(A,e,t){var r=new XMLHttpRequest;r.open("GET",A,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)e(r.response);else{var n=O(A);n?e(n.buffer):t()}},r.onerror=t,r.send(null)};var i=t.print||function(){}.bind(),a=t.printErr||function(){}.bind();for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);r=null,t.arguments&&t.arguments;var s=0,l=!1;function c(A){var e=t["_"+A];return e||tA("Assertion failed: "+("Cannot call unknown function "+A+", make sure it is exported")),e}var u,f,d,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function v(A,e){return A?function(A,e,t){for(var r=e+t,n=e;A[n]&&!(n>=r);)++n;if(n-e>16&&A.subarray&&p)return p.decode(A.subarray(e,n));for(var o="";e>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|a)}else o+=String.fromCharCode(i)}return o}(d,A,e):""}function w(A,e){return A%e>0&&(A+=e-A%e),A}function x(A){u=A,t.HEAP8=f=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=d=new Uint8Array(A),t.HEAPU16=new Uint16Array(A),t.HEAPU32=new Uint32Array(A),t.HEAPF32=m=new Float32Array(A),t.HEAPF64=b=new Float64Array(A)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var y=t.TOTAL_MEMORY||33554432;function k(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?t.dynCall_v(r):t.dynCall_vi(r,e.arg):r(void 0===e.arg?null:e.arg)}else e()}}y=(u=t.buffer?t.buffer:new ArrayBuffer(y)).byteLength,x(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function Q(A){D.unshift(A)}var j=Math.abs,N=Math.ceil,S=Math.floor,F=Math.min,P=0,T=null;t.preloadedImages={},t.preloadedAudios={};var L,I,R=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return f.length}R="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var G="function"==typeof atob?atob:function(A){var e,t,r,n,o,i,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="",l=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e=a.indexOf(A.charAt(l++))<<2|(n=a.indexOf(A.charAt(l++)))>>4,t=(15&n)<<4|(o=a.indexOf(A.charAt(l++)))>>2,r=(3&o)<<6|(i=a.indexOf(A.charAt(l++))),s+=String.fromCharCode(e),64!==o&&(s+=String.fromCharCode(t)),64!==i&&(s+=String.fromCharCode(r))}while(l=0){if((0|t)>13780509){if(0|(a=0|le(15,s)))break;s=0|n[(l=s)>>2],l=0|n[l+4>>2]}else c=0|qe(0|t,0|(a=((0|t)<0)<<31>>31),3,0),l=0|B(),a=0|Ve(0|t,0|a,1,0),a=0|Ve(0|(a=0|qe(0|c,0|l,0|a,0|B())),0|B(),1,0),l=0|B(),n[s>>2]=a,n[s+4>>2]=l,s=a;if(lt(0|r,0,s<<3),0|o){lt(0|o,0,s<<2),a=0|L(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|L(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return S=i,0|a}function T(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=S,S=S+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return S=a,2;if(n[(s=r)>>2]=A,n[s+4>>2]=e,(s=!!(0|o))&&(n[o>>2]=0),0|HA(A,e))return S=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|I(s,e,4,m,i)))break A;if(0|HA(s=0|n[(e=i)>>2],e=0|n[e+4>>2])){s=9;break A}}if(0|(s=0|I(s,e,0|n[26800+(g<<2)>>2],m,i)))break A;if(s=0|n[(e=i)>>2],e=0|n[e+4>>2],n[(A=r+(d<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(d<<2)>>2]=h,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|I(s,e,4,m,i)))break A;if(0|HA(s=0|n[(e=i)>>2],e=0|n[e+4>>2])){s=9;break A}}if(0|(s=0|I(s,e,0|n[26800+(g<<2)>>2],m,i)))break A;if(s=0|n[(e=i)>>2],e=0|n[e+4>>2],n[(A=r+(d<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else s=0}while(0);return S=a,0|s}function L(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0;if(u=S,S=S+16|0,l=u+8|0,c=u,f=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(f<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(d=(0|p)==(0|A)&(0|b)==(0|e))))do{f=0|$e(0|(f=0|Ve(0|f,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),d=(0|(b=0|n[(p=h=r+(f<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|d));if(f=o+(f<<2)|0,d&&(0|n[f>>2])<=(0|s))return S=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[f>>2]=s,(0|s)>=(0|t))return S=u,0;switch(d=s+1|0,n[l>>2]=0,0|(f=0|I(A,e,2,l,c))){case 9:m=9;break;case 0:(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(f=0|I(A,e,3,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,1,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,5,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,4,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|I(A,e,6,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}return S=u,0}}while(0);return S=u,0|f}function I(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if((t|=0)>>>0>6)return 1;if(f=(0|n[(r|=0)>>2])%6|0,n[r>>2]=f,(0|f)>0){s=0;do{t=0|vA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(f=0|tt(0|A,0|e,45),B(),(a=127&f)>>>0>121)return 5;i=0|OA(A,e),s=0|tt(0|A,0|e,52),B(),s&=15;A:do{if(s){for(;;){if(c=0|tt(0|A,0|e,0|(l=3*(15-s|0)|0)),B(),7==(0|(c&=7))){e=5;break}if(g=!(0|ZA(s)),s=s+-1|0,d=0|rt(7,0,0|l),e&=~B(),A=0|rt(0|n[(g?432:16)+(28*c|0)+(t<<2)>>2],0,0|l)|A&~d,e|=l=0|B(),!(t=0|n[(g?640:224)+(28*c|0)+(t<<2)>>2])){t=0;break A}if(!s){u=8;break A}}return 0|e}u=8}while(0);8==(0|u)&&(A|=0|rt(0|(g=0|n[848+(28*a|0)+(t<<2)>>2]),0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+(t<<2)>>2],127&~g||(g=0|rt(0|n[848+(28*a|0)+20>>2],0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+20>>2],A=0|YA(g|A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]))),c=0|tt(0|A,0|e,45),B(),c&=127;A:do{if(0|z(c)){e:do{if(1==(0|OA(A,e))){if((0|a)!=(0|c)){if(0|Y(c,0|n[7696+(28*a|0)>>2])){A=0|VA(A,e),l=1,e=0|B();break}M(27795,26864,533,26872)}switch(0|i){case 3:A=0|YA(A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]),l=0;break e;case 5:A=0|VA(A,e),e=0|B(),n[r>>2]=5+(0|n[r>>2]),l=0;break e;case 0:return 9;default:return 1}}else l=0}while(0);if((0|t)>0){s=0;do{A=0|UA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}if((0|a)!=(0|c)){if(!(0|G(c))){if(!!(0|l)|5!=(0|OA(A,e)))break;n[r>>2]=1+(0|n[r>>2]);break}switch(127&f){case 8:case 118:break A}3!=(0|OA(A,e))&&(n[r>>2]=1+(0|n[r>>2]))}}else if((0|t)>0){s=0;do{A=0|YA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}}while(0);return n[r>>2]=((0|n[r>>2])+t|0)%6|0,n[(g=o)>>2]=A,n[g+4>>2]=e,0}function R(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(i=S,S=S+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return S=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,S=i,0;n[h>>2]=0;A:do{if(0|HA(A,e))A=9;else{a=0,g=A;do{if(0|(A=0|I(g,e,4,h,o)))break A;if(a=a+1|0,0|HA(g=0|n[(e=o)>>2],e=0|n[e+4>>2])){A=9;break A}}while((0|a)<(0|t));n[(d=r)>>2]=g,n[d+4>>2]=e,d=t+-1|0,f=0,A=1;do{if(a=26800+(f<<2)|0,5==(0|f))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|I(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|d)){if(c=0|n[(u=o)>>2],u=0|n[u+4>>2],n[(A=r+(a<<3)|0)>>2]=c,n[A+4>>2]=u,0|HA(c,u)){A=9;break A}A=a+1|0}else A=a;if((0|(s=s+1|0))>=(0|t))break;a=A}else for(l=o,u=0|n[a>>2],c=0,a=A,s=0|n[l>>2],l=0|n[l+4>>2];;){if(0|(A=0|I(s,l,u,h,o)))break A;if(s=0|n[(l=o)>>2],l=0|n[l+4>>2],n[(A=r+(a<<3)|0)>>2]=s,n[A+4>>2]=l,A=a+1|0,0|HA(s,l)){A=9;break A}if((0|(c=c+1|0))>=(0|t))break;a=A}f=f+1|0}while(f>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return S=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=S,S=S+16|0,o=a,i=a+8|0,s=(s=!(0|HA(A|=0,e|=0)))?1:2;;){if(n[i>>2]=0,!(0|I(A,e,s,i,o))&((0|n[(l=o)>>2])==(0|t)?(0|n[l+4>>2])==(0|r):0)){A=4;break}if((s=s+1|0)>>>0>=7){s=7,A=4;break}}return 4==(0|A)?(S=a,0|s):0}function H(A,e,t,r,i,a,s){e|=0,t|=0,r|=0,i|=0,a|=0,s|=0;var l,c,u,f,d,g,h,m,b,p,v=0,w=0,x=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,j=0,N=0,F=0,P=0,T=0,L=0,I=0,R=0,_=0;if(p=S,S=S+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(w=0|n[(A|=0)>>2]))<=0)return S=p,0;for(u=A+4|0,f=h+8|0,d=m+8|0,g=l+8|0,v=0,F=0;;){N=(x=0|n[u>>2])+(F<<4)|0,n[h>>2]=n[N>>2],n[h+4>>2]=n[N+4>>2],n[h+8>>2]=n[N+8>>2],n[h+12>>2]=n[N+12>>2],(0|F)==(w+-1|0)?(n[m>>2]=n[x>>2],n[m+4>>2]=n[x+4>>2],n[m+8>>2]=n[x+8>>2],n[m+12>>2]=n[x+12>>2]):(N=x+(F+1<<4)|0,n[m>>2]=n[N>>2],n[m+4>>2]=n[N+4>>2],n[m+8>>2]=n[N+8>>2],n[m+12>>2]=n[N+12>>2]),w=0|tA(h,m,r,b);A:do{if(w)x=0,v=w;else if(x=0|n[(w=b)>>2],(0|(w=0|n[w+4>>2]))>0|!(0|w)&x>>>0>0){j=0,N=0;e:for(;;){if(I=1/(+(x>>>0)+4294967296*+(0|w)),_=+o[h>>3],R=+((w=0|Ze(0|x,0|w,0|j,0|N))>>>0)+4294967296*+(0|B()),L=+(j>>>0)+4294967296*+(0|N),o[l>>3]=I*(_*R)+I*(+o[m>>3]*L),o[g>>3]=I*(+o[f>>3]*R)+I*(+o[d>>3]*L),0|(w=0|KA(l,r,c))){v=w;break}C=0|At(0|(E=0|n[(Q=c)>>2]),0|(Q=0|n[Q+4>>2]),0|e,0|t),y=0|B(),x=0|n[(k=w=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|x)&!(0|k))P=w,T=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){v=1;break e}if((0|x)==(0|E)&(0|k)==(0|Q))break t;if(C=0|$e(0|(w=0|Ve(0|C,0|y,1,0)),0|B(),0|e,0|t),y=0|B(),D=0|Ve(0|D,0|M,1,0),M=0|B(),!(0|(x=0|n[(k=w=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){P=w,T=16;break}}}while(0);if(16!=(0|T)||(T=0,!(0|E)&!(0|Q))||(n[(D=P)>>2]=E,n[D+4>>2]=Q,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=Q,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(Q=i)>>2]=D,n[Q+4>>2]=E),j=0|Ve(0|j,0|N,1,0),N=0|B(),x=0|n[(w=b)>>2],!((0|(w=0|n[w+4>>2]))>(0|N)|(0|w)==(0|N)&x>>>0>j>>>0)){x=1;break A}}x=0}else x=1}while(0);if(F=F+1|0,!x){T=21;break}if((0|F)>=(0|(w=0|n[A>>2]))){v=0,T=21;break}}return 21==(0|T)?(S=p,0|v):0}function z(A){return(A|=0)>>>0>121?0|(A=0):0|(A=0|n[7696+(28*A|0)+16>>2])}function G(A){return 4==(0|(A|=0))|117==(0|A)|0}function O(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)>>2]}function U(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)+4>>2]}function Y(A,e){return e|=0,(0|n[7696+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|n[7696+(28*A|0)+24>>2])==(0|e))}function W(A,e){return 0|n[848+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function V(A,e){return e|=0,(0|n[848+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|n[848+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|n[848+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|n[848+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|n[848+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|n[848+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|n[848+(28*A|0)+24>>2])==(0|e)?6:7)}function Z(A){var e,t,r;return e=(r=+o[16+(A|=0)>>3])-(t=+o[A+24>>3]),+(r>3]<+o[A+24>>3]|0}function J(A){return+(+o[(A|=0)>>3]-+o[A+8>>3])}function X(A,e){A|=0;var t,r,n=0;return(n=+o[(e|=0)>>3])>=+o[A+8>>3]&&n<=+o[A>>3]?(t=+o[A+16>>3],n=+o[A+24>>3],e=(r=+o[e+8>>3])>=n,A=r<=t&1,t>3]<+o[e+8>>3]||+o[A+8>>3]>+o[e>>3]?0|(s=0):(n=(l=+o[A+16>>3])<(u=+o[(t=A+24|0)>>3]),c=(a=+o[(s=e+16|0)>>3])<(i=+o[(r=e+24|0)>>3]),e=u-a>3],e)||(u=+ie(+o[t>>3],A))>+ie(+o[s>>3],e)?0|(c=0):0|(c=1))}function $(A,e){e|=0;var t,r,n,i,a,s=0,l=0,c=0,u=0;return+o[(A|=0)>>3]<+o[e>>3]||+o[A+8>>3]>+o[e+8>>3]?0|(s=0):(n=(i=+o[(s=A+16|0)>>3])<(l=+o[A+24>>3]),c=(u=+o[(t=e+16|0)>>3])<(a=+o[(r=e+24|0)>>3]),e=l-u>3],e)?0|(c=(u=+ie(+o[s>>3],A))>=+ie(+o[t>>3],e)):0|(c=0))}function AA(A,e){A|=0,e|=0;var t,r,i,a,s,l=0;i=S,S=S+176|0,n[(r=i)>>2]=4,l=+o[e>>3],o[r+8>>3]=l,a=+o[e+16>>3],o[r+16>>3]=a,o[r+24>>3]=l,l=+o[e+24>>3],o[r+32>>3]=l,s=+o[e+8>>3],o[r+40>>3]=s,o[r+48>>3]=l,o[r+56>>3]=s,o[r+64>>3]=a,t=96+(e=r+72|0)|0;do{n[e>>2]=0,e=e+4|0}while((0|e)<(0|t));st(0|A,0|r,168),S=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,f,d,g,h=0,m=0,b=0,p=0,w=0,y=0,k=0;d=S,S=S+288|0,f=d+264|0,p=d+96|0,m=(h=b=d)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(S=d,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],f),$A(b,m,p),u=+ae(f,p+8|0),o[f>>3]=+o[A>>3],o[(m=f+8|0)>>3]=+o[A+16>>3],o[p>>3]=+o[A+8>>3],o[(b=p+8|0)>>3]=+o[A+24>>3],a=+ae(f,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[f>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+v(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,w=~~k>>>0,y=+l(k)>=1?k>0?~~+x(+s(k/4294967296),4294967295)>>>0:~~+v((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|w)&!(0|y),n[(e=t)>>2]=p?1:w,n[e+4>>2]=p?0:y,e=0):e=1,S=d,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,f,d=0,g=0,h=0;f=S,S=S+288|0,c=f+264|0,u=f+96|0,a=(d=g=f)+96|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(t=0|Ae(t,g))?(S=f,0|(r=t)):(qA(d=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(d,t,u),h=+ae(c,u+8|0),h=+v(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,d=+l(h)>=1?h>0?~~+x(+s(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|d),n[r>>2]=g?1:t,n[r+4>>2]=g?0:d,S=f,0|(r=0)):(S=f,0|(r=1)))}function rA(A,e,t,r){e|=0,t|=0,r|=0,n[(A|=0)>>2]=e,n[A+4>>2]=t,n[A+8>>2]=r}function nA(A){var e,t=0,r=0,o=0,i=0,a=0;t=0|n[(A|=0)>>2],r=0|n[(e=A+4|0)>>2],(0|t)<0&&(r=r-t|0,n[e>>2]=r,n[(a=A+8|0)>>2]=(0|n[a>>2])-t,n[A>>2]=0,t=0),(0|r)<0?(t=t-r|0,n[A>>2]=t,i=(0|n[(a=A+8|0)>>2])-r|0,n[a>>2]=i,n[e>>2]=0,r=0):(a=i=A+8|0,i=0|n[i>>2]),(0|i)<0&&(t=t-i|0,n[A>>2]=t,r=r-i|0,n[e>>2]=r,n[a>>2]=0,i=0),(0|(o=(0|i)<(0|(o=(0|r)<(0|t)?r:t))?i:o))<=0||(n[A>>2]=t-o,n[e>>2]=r-o,n[a>>2]=i-o)}function oA(A,e){var t,r;e|=0,r=0|n[8+(A|=0)>>2],t=+((0|n[A+4>>2])-r|0),o[e>>3]=+((0|n[A>>2])-r|0)-.5*t,o[e+8>>3]=.8660254037844386*t}function iA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[e>>2])+(0|n[A>>2]),n[t+4>>2]=(0|n[e+4>>2])+(0|n[A+4>>2]),n[t+8>>2]=(0|n[e+8>>2])+(0|n[A+8>>2])}function aA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[A>>2])-(0|n[e>>2]),n[t+4>>2]=(0|n[A+4>>2])-(0|n[e+4>>2]),n[t+8>>2]=(0|n[A+8>>2])-(0|n[e+8>>2])}function sA(A,e){e|=0;var t,r=0;r=0|w(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|w(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|w(0|n[(A=A+8|0)>>2],e),n[A>>2]=e}function lA(A){var e,t,r=0,o=0,i=0,a=0,s=0;s=(0|(t=0|n[(A|=0)>>2]))<0,A=(A=(o=(0|(a=((e=(0|(i=(0|n[A+4>>2])-(s?t:0)|0))<0)?0-i|0:0)+((0|n[A+8>>2])-(s?t:0))|0))<0)?0:a)-((i=(0|(o=(0|A)<(0|(o=(0|(r=(e?0:i)-(o?a:0)|0))<(0|(a=(s?0:t)-(e?i:0)-(o?a:0)|0))?r:a))?A:o))>0)?o:0)|0,r=r-(i?o:0)|0;A:do{switch(a-(i?o:0)|0){case 0:switch(0|r){case 0:return 0|(0|A?1==(0|A)?1:7:0);case 1:return 0|(0|A?1==(0|A)?3:7:2);default:break A}case 1:switch(0|r){case 0:return 0|(0|A?1==(0|A)?5:7:4);case 1:if(A)break A;return 6;default:break A}}}while(0);return 7}function cA(A){var e,t,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(l=0|n[(t=8+(A|=0)|0)>>2],(e=(0|n[A>>2])-l|0)>>>0>715827881|(l=(0|n[(c=A+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-e|0,s=-2147483648-e|0,(i=(0|e)>0)?(0|a)<(0|e):(0|s)>(0|e))return 1;if(o=e<<1,i?(2147483647-o|0)<(0|e):(-2147483648-o|0)>(0|e))return 1;if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 1;if(r=3*e|0,o=l<<1,(i?(0|a)<(0|o):(0|s)>(0|o))||((0|e)>-1?(-2147483648|r)>=(0|l):(-2147483648^r)<(0|l)))return 1}else o=l<<1,r=3*e|0;return i=0|Oe(.14285714285714285*+(r-l|0)),n[A>>2]=i,a=0|Oe(.14285714285714285*+(o+e|0)),n[c>>2]=a,n[t>>2]=0,r=(o=(0|a)<(0|i))?i:a,(0|(o=o?a:i))<0&&((-2147483648==(0|o)||((0|r)>0?(2147483647-r|0)<(0|o):(-2147483648-r|0)>(0|o)))&&M(27795,26892,354,26903),((0|r)>-1?(-2147483648|r)>=(0|o):(-2147483648^r)<(0|o))&&M(27795,26892,354,26903)),r=a-i|0,(0|i)<0?(o=0-i|0,n[c>>2]=r,n[t>>2]=o,n[A>>2]=0,i=0):(r=a,o=0),(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[t>>2]=o,n[c>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[c>>2]=a,n[t>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[c>>2]=r-i,n[t>>2]=o-i),0}function uA(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(i=0|n[(e=8+(A|=0)|0)>>2],(a=(0|n[A>>2])-i|0)>>>0>715827881|(i=(0|n[(s=A+4|0)>>2])-i|0)>>>0>715827881){if((r=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 1;if(t=a<<1,(o=(0|i)>0)?(2147483647-i|0)<(0|i):(-2147483648-i|0)>(0|i))return 1;if(l=i<<1,o?(2147483647-l|0)<(0|i):(-2147483648-l|0)>(0|i))return 1;if(r?(2147483647-t|0)<(0|i):(-2147483648-t|0)>(0|i))return 1;if(r=3*i|0,(0|i)>-1?(-2147483648|r)>=(0|a):(-2147483648^r)<(0|a))return 1}else r=3*i|0,t=a<<1;return o=0|Oe(.14285714285714285*+(t+i|0)),n[A>>2]=o,i=0|Oe(.14285714285714285*+(r-a|0)),n[s>>2]=i,n[e>>2]=0,t=(r=(0|i)<(0|o))?o:i,(0|(r=r?i:o))<0&&((-2147483648==(0|r)||((0|t)>0?(2147483647-t|0)<(0|r):(-2147483648-t|0)>(0|r)))&&M(27795,26892,402,26917),((0|t)>-1?(-2147483648|t)>=(0|r):(-2147483648^t)<(0|r))&&M(27795,26892,402,26917)),t=i-o|0,(0|o)<0?(r=0-o|0,n[s>>2]=t,n[e>>2]=r,n[A>>2]=0,o=0):(t=i,r=0),(0|t)<0&&(o=o-t|0,n[A>>2]=o,r=r-t|0,n[e>>2]=r,n[s>>2]=0,t=0),a=o-r|0,i=t-r|0,(0|r)<0?(n[A>>2]=a,n[s>>2]=i,n[e>>2]=0,t=i,i=a,r=0):i=o,(0|(o=(0|r)<(0|(o=(0|t)<(0|i)?t:i))?r:o))<=0||(n[A>>2]=i-o,n[s>>2]=t-o,n[e>>2]=r-o),0}function fA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+((3*(r=(0|n[A>>2])-o|0)|0)-(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((o<<1)+r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function dA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+(((r=(0|n[A>>2])-o|0)<<1)+(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((3*o|0)-r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function gA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(3*o|0)|0,n[A>>2]=s,i=a+(3*i|0)|0,n[t>>2]=i,o=(3*a|0)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function hA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(3*(o=0|n[(t=A+4|0)>>2])|0)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(3*s|0)|0,n[A>>2]=s,n[t>>2]=a,o=(3*i|0)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function mA(A,e){A|=0;var t,r,o,i=0,a=0,s=0;((e|=0)-1|0)>>>0>=6||(s=(0|n[15440+(12*e|0)>>2])+(0|n[A>>2])|0,n[A>>2]=s,o=A+4|0,a=(0|n[15440+(12*e|0)+4>>2])+(0|n[o>>2])|0,n[o>>2]=a,r=A+8|0,e=(0|n[15440+(12*e|0)+8>>2])+(0|n[r>>2])|0,n[r>>2]=e,i=a-s|0,(0|s)<0?(e=e-s|0,n[o>>2]=i,n[r>>2]=e,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,e=e-i|0,n[r>>2]=e,n[o>>2]=0,i=0),t=a-e|0,s=i-e|0,(0|e)<0?(n[A>>2]=t,n[o>>2]=s,n[r>>2]=0,a=t,e=0):s=i,(0|(i=(0|e)<(0|(i=(0|s)<(0|a)?s:a))?e:i))<=0||(n[A>>2]=a-i,n[o>>2]=s-i,n[r>>2]=e-i))}function bA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(o=0|n[(t=A+4|0)>>2])+s|0,s=(i=0|n[(r=A+8|0)>>2])+s|0,n[A>>2]=s,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function pA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],a=0|n[(t=A+4|0)>>2],i=0|n[(r=A+8|0)>>2],s=a+o|0,n[A>>2]=s,a=i+a|0,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function vA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function wA(A){switch(0|(A|=0)){case 1:A=3;break;case 3:A=2;break;case 2:A=6;break;case 6:A=4;break;case 4:A=5;break;case 5:A=1}return 0|A}function xA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(o<<1)|0,n[A>>2]=s,i=a+(i<<1)|0,n[t>>2]=i,o=(a<<1)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function yA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=((o=0|n[(t=A+4|0)>>2])<<1)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(s<<1)|0,n[A>>2]=s,n[t>>2]=a,o=(i<<1)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function kA(A,e){e|=0;var t,r,o,i=0,a=0,s=0;return o=(0|(r=(0|n[(A|=0)>>2])-(0|n[e>>2])|0))<0,t=(0|(a=(0|n[A+4>>2])-(0|n[e+4>>2])-(o?r:0)|0))<0,e=(e=(A=(0|(s=(o?0-r|0:0)+(0|n[A+8>>2])-(0|n[e+8>>2])+(t?0-a|0:0)|0))<0)?0:s)-((a=(0|(A=(0|e)<(0|(A=(0|(i=(t?0:a)-(A?s:0)|0))<(0|(s=(o?0:r)-(t?a:0)-(A?s:0)|0))?i:s))?e:A))>0)?A:0)|0,i=i-(a?A:0)|0,0|((0|(A=(0|(A=s-(a?A:0)|0))>-1?A:0-A|0))>(0|(e=(0|(i=(0|i)>-1?i:0-i|0))>(0|(e=(0|e)>-1?e:0-e|0))?i:e))?A:e)}function CA(A){var e,t,r,o;t=(o=0|n[(e=8+(A|=0)|0)>>2])-(0|n[A>>2])|0,n[A>>2]=t,A=(0|n[(r=A+4|0)>>2])-o|0,n[r>>2]=A,n[e>>2]=0-(A+t)}function BA(A){var e,t,r=0,o=0,i=0,a=0,s=0;r=0-(o=0|n[(A|=0)>>2])|0,n[A>>2]=r,n[(e=A+8|0)>>2]=0,a=(i=0|n[(t=A+4|0)>>2])+o|0,(0|o)>0?(n[t>>2]=a,n[e>>2]=o,n[A>>2]=0,r=0,i=a):o=0,(0|i)<0?(s=r-i|0,n[A>>2]=s,o=o-i|0,n[e>>2]=o,n[t>>2]=0,a=s-o|0,r=0-o|0,(0|o)<0?(n[A>>2]=a,n[t>>2]=r,n[e>>2]=0,i=r,o=0):(i=0,a=s)):a=r,(0|(r=(0|o)<(0|(r=(0|i)<(0|a)?i:a))?o:r))<=0||(n[A>>2]=a-r,n[t>>2]=i-r,n[e>>2]=o-r)}function MA(A,e){var t=0;switch(t=0|tt(0|(A|=0),0|(e|=0),56),B(),7&t){case 0:case 7:return 0}return t=-2130706433&e|134217728,!0&268435456==(2013265920&e)?!0&16777216==(117440512&e)&!!(0|HA(A,t))?0|(t=0):0|(t=0|LA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=S,S=S+16|0,r=o,a=-2130706433&(e|=0)|134217728,!0&268435456==(2013265920&e)?(i=0|tt(0|(A|=0),0|e,56),B(),i=0|function(A,e,t){t|=0;var r,o=0,i=0;if(r=S,S=S+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return S=r,-1;if(1==(0|t)&(o=!!(0|o)))return S=r,-1;do{if(!(0|Fe(A,e,i))){if(o){o=(5+(0|n[26352+(t<<2)>>2])-(0|n[i>>2])|0)%5|0;break}o=(6+(0|n[26384+(t<<2)>>2])-(0|n[i>>2])|0)%6|0;break}o=-1}while(0);return S=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,S=o,0|(a=6)):(0|XA(A,a,r)&&M(27795,26932,282,26947),e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,a)?QA(r,e,i,2,t):FA(r,e,i,2,t),S=o,0|(a=0))):(S=o,0|(a=6))}function EA(A,e,t,r,i){e|=0,t|=0,r|=0,i|=0;var a,s=0,u=0;if(s=+function(A){var e,t;return t=+o[(A|=0)>>3],e=+o[A+8>>3],+ +c(+(t*t+e*e))}(A|=0),s<1e-16)return e=15600+(e<<4)|0,n[i>>2]=n[e>>2],n[i+4>>2]=n[e+4>>2],n[i+8>>2]=n[e+8>>2],void(n[i+12>>2]=n[e+12>>2]);if(u=+p(+ +o[A+8>>3],+ +o[A>>3]),(0|t)>0){A=0;do{s*=.37796447300922725,A=A+1|0}while((0|A)!=(0|t))}a=.3333333333333333*s,r?(t=!(0|ZA(t)),s=+b(.381966011250105*(t?a:.37796447300922725*a))):(s=+b(.381966011250105*s),0|ZA(t)&&(u=+ne(u+.3334731722518321))),function(A,e,t,r){A|=0,e=+e,r|=0;var i=0,a=0,s=0,c=0;if((t=+t)<1e-16)return n[r>>2]=n[A>>2],n[r+4>>2]=n[A+4>>2],n[r+8>>2]=n[A+8>>2],void(n[r+12>>2]=n[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(i=+l(+(a+-3.141592653589793))<1e-16,e=+o[A>>3],i){e-=t,o[r>>3]=e,i=r;break}if(s=+f(+t),t=+d(+t),e=s*+d(+e)+ +f(+a)*(t*+f(+e)),e=+m(+((e=e>1?1:e)<-1?-1:e)),o[r>>3]=e,+l(+(e+-1.5707963267948966))<1e-16)return o[r>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[r>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if(c=1/+f(+e),a=t*+d(+a)*c,t=+o[A>>3],e=c*((s-+d(+e)*+d(+t))/+f(+t)),s=a>1?1:a,e=e>1?1:e,(e=+o[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(o[r+8>>3]=e)}e=+o[A>>3]+t,o[r>>3]=e,i=r}while(0);if(+l(+(e+-1.5707963267948966))<1e-16)return o[i>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[i>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if((e=+o[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);o[r+8>>3]=e}(15600+(e<<4)|0,+ne(+o[15920+(24*e|0)>>3]-u),s,i)}function QA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,w,x,y,k,C,B,D,E,Q,j=0,N=0,F=0,P=0,T=0,L=0;if(Q=S,S=S+272|0,P=Q+240|0,B=Q,D=Q+224|0,E=Q+208|0,b=Q+176|0,p=Q+160|0,v=Q+192|0,w=Q+144|0,x=Q+128|0,y=Q+112|0,k=Q+96|0,C=Q+80|0,n[(j=Q+256|0)>>2]=e,n[P>>2]=n[A>>2],n[P+4>>2]=n[A+4>>2],n[P+8>>2]=n[A+8>>2],n[P+12>>2]=n[A+12>>2],jA(P,j,B),n[i>>2]=0,(0|(P=r+t+(5==(0|r)&1)|0))<=(0|t))S=Q;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[j>>2])<<2)|0,f=16960+(a<<2)|0,d=x+8|0,g=y+8|0,h=k+8|0,m=E+4|0,F=t;A:for(;;){N=B+((0|F)%5<<4)|0,n[E>>2]=n[N>>2],n[E+4>>2]=n[N+4>>2],n[E+8>>2]=n[N+8>>2],n[E+12>>2]=n[N+12>>2];do{}while(2==(0|NA(E,a,0,1)));if((0|F)>(0|t)&!!(0|ZA(e))){if(n[b>>2]=n[E>>2],n[b+4>>2]=n[E+4>>2],n[b+8>>2]=n[E+8>>2],n[b+12>>2]=n[E+12>>2],oA(s,p),r=0|n[b>>2],j=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*j|0)>>2],(0|(N=0|n[18640+(80*r|0)+(20*j|0)+16>>2]))>0){A=0;do{bA(l),A=A+1|0}while((0|A)<(0|N))}switch(N=18640+(80*r|0)+(20*j|0)+4|0,n[v>>2]=n[N>>2],n[v+4>>2]=n[N+4>>2],n[v+8>>2]=n[N+8>>2],sA(v,3*(0|n[u>>2])|0),iA(l,v,l),nA(l),oA(l,w),T=+(0|n[f>>2]),o[x>>3]=3*T,o[d>>3]=0,L=-1.5*T,o[y>>3]=L,o[g>>3]=2.598076211353316*T,o[k>>3]=L,o[h>>3]=-2.598076211353316*T,0|n[17040+(80*(0|n[b>>2])|0)+(n[E>>2]<<2)>>2]){case 1:A=y,r=x;break;case 3:A=k,r=y;break;case 2:A=x,r=k;break;default:A=12;break A}je(p,w,r,A,C),EA(C,0|n[b>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])}if((0|F)<(0|c)&&(oA(m,b),EA(b,0|n[E>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),n[D>>2]=n[E>>2],n[D+4>>2]=n[E+4>>2],n[D+8>>2]=n[E+8>>2],n[D+12>>2]=n[E+12>>2],(0|(F=F+1|0))>=(0|P)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):S=Q}}function jA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=S,S=S+128|0,i=r,s=20240,l=60+(a=o=r+64|0)|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));s=20304,l=(a=i)+60|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));o=(l=!(0|ZA(0|n[e>>2])))?o:i,xA(i=A+4|0),yA(i),0|ZA(0|n[e>>2])&&(hA(i),n[e>>2]=1+(0|n[e>>2])),n[t>>2]=n[A>>2],iA(i,o,e=t+4|0),nA(e),n[t+16>>2]=n[A>>2],iA(i,o+12|0,e=t+20|0),nA(e),n[t+32>>2]=n[A>>2],iA(i,o+24|0,e=t+36|0),nA(e),n[t+48>>2]=n[A>>2],iA(i,o+36|0,e=t+52|0),nA(e),n[t+64>>2]=n[A>>2],iA(i,o+48|0,t=t+68|0),nA(t),S=r}function NA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,f=0,d=0,g=0,h=0;if(c=S,S=S+32|0,l=c+12|0,i=c,h=4+(A|=0)|0,g=0|n[16960+((e|=0)<<2)>>2],g=(s=!!(0|r))?3*g|0:g,u=0|n[h>>2],o=0|n[(a=A+8|0)>>2],s){if((0|(u=o+u+(r=0|n[(f=A+12|0)>>2])|0))==(0|g))return S=c,1;d=f}else u=o+u+(r=0|n[(d=A+12|0)>>2])|0;if((0|u)<=(0|g))return S=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){f=18640+(80*r|0)+60|0,r=A;break}r=18640+(80*r|0)+40|0,t?(rA(l,g,0,0),aA(h,l,i),pA(i),iA(i,l,h),f=r,r=A):(f=r,r=A)}else f=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[f>>2],(0|n[(u=f+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=f+4|0,n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],e=0|n[16880+(e<<2)>>2],sA(l,s?3*e|0:e),iA(h,l,h),nA(h),r=s&&((0|n[a>>2])+(0|n[h>>2])+(0|n[d>>2])|0)==(0|g)?1:2,S=c,0|r}function SA(A,e){A|=0,e|=0;var t=0;do{t=0|NA(A,e,0,1)}while(2==(0|t));return 0|t}function FA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,w,x,y,k,C,B=0,D=0,E=0,Q=0,j=0;if(C=S,S=S+240|0,w=C+208|0,x=C,y=C+192|0,k=C+176|0,h=C+160|0,m=C+144|0,b=C+128|0,p=C+112|0,v=C+96|0,n[(B=C+224|0)>>2]=e,n[w>>2]=n[A>>2],n[w+4>>2]=n[A+4>>2],n[w+8>>2]=n[A+8>>2],n[w+12>>2]=n[A+12>>2],PA(w,B,x),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))S=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,f=p+8|0,d=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=x+((B=(0|E)%6|0)<<4)|0,n[y>>2]=n[A>>2],n[y+4>>2]=n[A+4>>2],n[y+8>>2]=n[A+8>>2],n[y+12>>2]=n[A+12>>2],A=D,D=0|NA(y,a,0,1),(0|E)>(0|t)&!!(0|ZA(e))&&1!=(0|A)&&(0|n[y>>2])!=(0|r)){switch(oA(x+((B+5|0)%6<<4)+4|0,k),oA(x+(B<<4)+4|0,h),Q=+(0|n[l>>2]),o[m>>3]=3*Q,o[c>>3]=0,j=-1.5*Q,o[b>>3]=j,o[u>>3]=2.598076211353316*Q,o[p>>3]=j,o[f>>3]=-2.598076211353316*Q,B=0|n[w>>2],0|n[17040+(80*B|0)+(((0|r)==(0|B)?n[y>>2]:r)<<2)>>2]){case 1:A=b,r=m;break;case 3:A=p,r=b;break;case 2:A=m,r=p;break;default:A=8;break A}je(k,h,r,A,v),0|Ne(k,v)||0|Ne(h,v)||(EA(v,0|n[w>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(d,k),EA(k,0|n[y>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),(0|(E=E+1|0))>=(0|g)){A=3;break}r=0|n[y>>2]}3!=(0|A)?8==(0|A)&&M(27054,27017,737,27099):S=C}}function PA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=S,S=S+160|0,i=r,s=20368,l=72+(a=o=r+80|0)|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));s=20448,l=(a=i)+72|0;do{n[a>>2]=n[s>>2],a=a+4|0,s=s+4|0}while((0|a)<(0|l));o=(l=!(0|ZA(0|n[e>>2])))?o:i,xA(i=A+4|0),yA(i),0|ZA(0|n[e>>2])&&(hA(i),n[e>>2]=1+(0|n[e>>2])),n[t>>2]=n[A>>2],iA(i,o,e=t+4|0),nA(e),n[t+16>>2]=n[A>>2],iA(i,o+12|0,e=t+20|0),nA(e),n[t+32>>2]=n[A>>2],iA(i,o+24|0,e=t+36|0),nA(e),n[t+48>>2]=n[A>>2],iA(i,o+36|0,e=t+52|0),nA(e),n[t+64>>2]=n[A>>2],iA(i,o+48|0,e=t+68|0),nA(e),n[t+80>>2]=n[A>>2],iA(i,o+60|0,t=t+84|0),nA(t),S=r}function TA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function LA(A,e){A|=0;var t=0,n=0,o=0,i=0;return!0&134217728==(-16777216&(e|=0))?(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0>121?0|(A=0):!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())?0|r[20528+t|0]?!(0|A)&!(0|(e&=8191))?0|(i=1):(i=0|nt(0|A,0|e),B(),0|!!((63-i|0)%3|0)):0|(i=1):0|(i=0)):0|(A=0)}function IA(A,e,t,r){A|=0,t|=0,r|=0;var o=0,i=0,a=0,s=0;if(o=0|rt(0|(e|=0),0,52),i=0|B(),t=0|rt(0|t,0,45),t=0|i|B()|134225919,(0|e)<1)return i=-1,r=t,n[(e=A)>>2]=i,void(n[(A=A+4|0)>>2]=r);for(i=1,o=-1;s=0|rt(7,0,0|(a=3*(15-i|0)|0)),t&=~B(),o=o&~s|(a=0|rt(0|r,0,0|a)),t=0|t|B(),(0|i)!=(0|e);)i=i+1|0;n[(a=s=A)>>2]=o,n[(s=s+4|0)>>2]=t}function RA(A,e,t,r){t|=0,r|=0;var o=0,i=0;if(i=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return 4;if((0|(i&=15))<(0|t))return 12;if((0|i)==(0|t))return n[r>>2]=A,n[r+4>>2]=e,0;if(o=0|rt(0|t,0,52),o|=A,A=B()|-15728641&e,(0|i)>(0|t))do{e=0|rt(7,0,3*(14-t|0)|0),t=t+1|0,o|=e,A=0|B()|A}while((0|t)<(0|i));return n[r>>2]=o,n[r+4>>2]=A,0}function _A(A,e,t,r){t|=0,r|=0;var o=0,i=0,a=0;if(i=0|tt(0|(A|=0),0|(e|=0),52),B(),!((0|t)<16&(0|(i&=15))<=(0|t)))return 4;o=t-i|0,t=0|tt(0|A,0|e,45),B();A:do{if(0|z(127&t)){e:do{if(0|i){for(t=1;!((a=0|rt(7,0,3*(15-t|0)|0))&A)&!((0|B())&e);){if(!(t>>>0>>0))break e;t=t+1|0}t=0|pe(7,0,o,((0|o)<0)<<31>>31),o=0|B();break A}}while(0);t=0|Ve(0|(t=0|qe(0|(t=0|pe(7,0,o,((0|o)<0)<<31>>31)),0|B(),5,0)),0|B(),-5,-1),t=0|Ve(0|(t=0|Xe(0|t,0|B(),6,0)),0|B(),1,0),o=0|B()}else t=0|pe(7,0,o,((0|o)<0)<<31>>31),o=0|B()}while(0);return n[(a=r)>>2]=t,n[a+4>>2]=o,0}function HA(A,e){var t=0,r=0,n=0;if(n=0|tt(0|(A|=0),0|(e|=0),45),B(),!(0|z(127&n)))return 0;n=0|tt(0|A,0|e,52),B(),n&=15;A:do{if(n)for(r=1;;){if(t=0|tt(0|A,0|e,3*(15-r|0)|0),B(),0|(t&=7))break A;if(!(r>>>0>>0)){t=0;break}r=r+1|0}else t=0}while(0);return 1&!(0|t)}function zA(A,e,t,r){return A|=0,e|=0,(0|(r|=0))<(0|(t|=0))?(r=A,C(0|(t=e)),0|r):(t=0|rt(-1,-1,3+(3*(r-t|0)|0)|0),r=0|rt(0|~t,0|~B(),3*(15-r|0)|0),t=~B()&e,r=~r&A,C(0|t),0|r)}function GA(A,e,t,r){t|=0,r|=0;var o=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),(0|t)<16&(0|(o&=15))<=(0|t)?((0|o)<(0|t)&&(o=0|rt(-1,-1,3+(3*(t+-1-o|0)|0)|0),o=0|rt(0|~o,0|~B(),3*(15-t|0)|0),e=~B()&e,A&=~o),o=0|rt(0|t,0,52),t=-15728641&e|B(),n[r>>2]=A|o,n[r+4>>2]=t,0|(r=0)):0|(r=4)}function OA(A,e){var t=0,r=0,n=0;if(n=0|tt(0|(A|=0),0|(e|=0),52),B(),!(n&=15))return 0;for(r=1;;){if(t=0|tt(0|A,0|e,3*(15-r|0)|0),B(),0|(t&=7)){r=5;break}if(!(r>>>0>>0)){t=0,r=5;break}r=r+1|0}return 5==(0|r)?0|t:0}function UA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(n=0|tt(0|A,0|e,0|(i=3*(15-t|0)|0)),B(),o=0|rt(7,0,0|i),e&=~B(),A=A&~o|(i=0|rt(0|vA(7&n),0,0|i)),e=0|e|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function YA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;i=0|tt(0|A,0|e,0|(o=3*(15-t|0)|0)),B(),n=0|rt(7,0,0|o),e&=~B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~n,e=0|B()|e,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function WA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|wA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(o=0|rt(7,0,0|(n=3*(15-t|0)|0)),i=e&~B(),e=0|tt(0|A,0|e,0|n),B(),A=A&~o|(e=0|rt(0|wA(7&e),0,0|n)),e=0|i|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function VA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;o=0|rt(7,0,0|(i=3*(15-t|0)|0)),n=e&~B(),e=0|tt(0|A,0|e,0|i),B(),A=(e=0|rt(0|wA(7&e),0,0|i))|A&~o,e=0|B()|n,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function ZA(A){return(0|(A|=0))%2|0}function KA(A,e,t){t|=0;var r,i=0;return r=S,S=S+16|0,i=r,(e|=0)>>>0>15?(S=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=S,S=S+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=S,S=S+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=S,S=S+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+f(+n),n=+d(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+f(+n),o[e>>3]=r,n=t*+d(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Se(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Se(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Se(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Se(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Se(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Se(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Se(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Se(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Se(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Se(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Se(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Se(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Se(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Se(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Se(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Se(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Se(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Se(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Se(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Se(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,S=i):S=i}(A|=0,t|=0,c=i),(s=+h(+(1-.5*+o[c>>3])))<1e-16)return n[r>>2]=0,n[r+4>>2]=0,n[r+8>>2]=0,n[r+12>>2]=0,void(S=i);if(c=0|n[t>>2],a=+ne((a=+o[15920+(24*c|0)>>3])-+ne(+function(A,e){var t,r,n,i,a;return A|=0,i=+o[(e|=0)>>3],r=+f(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+d(+n),t=+o[A>>3],+ +p(+a,+(+d(+i)*+f(+t)-+f(+n)*(r*+d(+t))))}(15600+(c<<4)|0,A))),l=0|ZA(e)?+ne(a+-.3334731722518321):a,a=2.618033988749896*+g(+s),(0|e)>0){A=0;do{a*=2.6457513110645907,A=A+1|0}while((0|A)!=(0|e))}s=+f(+l)*a,o[r>>3]=s,l=+d(+l)*a,o[r+8>>3]=l,S=i}(A|=0,e|=0,t|=0,i=r),function(A,e){A|=0;var t,r,i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],f=+l(+r),i=+o[A+8>>3],f+=.5*(d=1.1547005383792515*+l(+i)),f-=+(0|(s=~~f)),d-=+(0|(A=~~d));do{if(f<.5){if(f<.3333333333333333){if(n[e>>2]=s,d<.5*(f+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(d<(h=1-f)))+A|0,n[e+4>>2]=A,h<=d&d<2*f){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(f<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,d<.5*f){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(d<1-f){if(n[e+4>>2]=A,2*f-1>2]=s;break}}else A=A+1|0,n[e+4>>2]=A;s=s+1|0,n[e>>2]=s}while(0);do{if(r<0){if(1&A){s=~~(+(0|s)-(2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(A+1|0)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))+1)),n[e>>2]=s;break}s=~~(+(0|s)-2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(0|A)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))),n[e>>2]=s;break}}while(0);g=e+4|0,i<0&&(s=s-((1|A<<1)/2|0)|0,n[e>>2]=s,A=0-A|0,n[g>>2]=A),c=A-s|0,(0|s)<0?(u=0-s|0,n[g>>2]=c,n[a>>2]=u,n[e>>2]=0,A=c,s=0):u=0,(0|A)<0&&(s=s-A|0,n[e>>2]=s,u=u-A|0,n[a>>2]=u,n[g>>2]=0,A=0),t=s-u|0,c=A-u|0,(0|u)<0&&(n[e>>2]=t,n[g>>2]=c,n[a>>2]=0,A=c,s=t,u=0),(0|(c=(0|u)<(0|(c=(0|A)<(0|s)?A:s))?u:c))<=0||(n[e>>2]=s-c,n[g>>2]=A-c,n[a>>2]=u-c)}(i,t+4|0),S=r}(A,e,i),e=0|function(A,e){A|=0;var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0;if(t=S,S=S+64|0,l=t+40|0,o=t+24|0,i=t+12|0,a=t,rt(0|(e|=0),0,52),r=134225919|B(),!e)return(0|n[A+4>>2])>2||(0|n[A+8>>2])>2||(0|n[A+12>>2])>2?(l=0,C(0|(s=0)),S=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),S=t,0|l);if(n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],n[l+12>>2]=n[A+12>>2],s=l+4|0,(0|e)>0)for(A=-1;n[o>>2]=n[s>>2],n[o+4>>2]=n[s+4>>2],n[o+8>>2]=n[s+8>>2],1&e?(fA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],gA(i)):(dA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],hA(i)),aA(o,i,a),nA(a),c=0|rt(7,0,0|(u=3*(15-e|0)|0)),r&=~B(),A=(u=0|rt(0|lA(a),0,0|u))|A&~c,r=0|B()|r,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|n[s>>2])<=2&&(0|n[l+8>>2])<=2&&(0|n[l+12>>2])<=2){if(e=0|rt(0|(o=0|O(l)),0,45),e|=A,A=B()|-1040385&r,a=0|U(l),!(0|z(o))){if((0|a)<=0)break;for(i=0;;){if(o=0|tt(0|e,0|A,52),B(),o&=15)for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0;if((0|(i=i+1|0))==(0|a))break A}}i=0|tt(0|e,0|A,52),B(),i&=15;e:do{if(i){r=1;t:for(;;){switch(u=0|tt(0|e,0|A,3*(15-r|0)|0),B(),7&u){case 1:break t;case 0:break;default:break e}if(!(r>>>0>>0))break e;r=r+1|0}if(0|Y(o,0|n[l>>2]))for(r=1;c=0|rt(7,0,0|(l=3*(15-r|0)|0)),u=A&~B(),A=0|tt(0|e,0|A,0|l),B(),e=e&~c|(A=0|rt(0|wA(7&A),0,0|l)),A=0|u|B(),r>>>0>>0;)r=r+1|0;else for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0}}while(0);if((0|a)>0){r=0;do{e=0|UA(e,A),A=0|B(),r=r+1|0}while((0|r)!=(0|a))}}else e=0,A=0}while(0);return u=e,C(0|(c=A)),S=t,0|u}(i,e),i=0|B(),n[t>>2]=e,n[t+4>>2]=i,!(0|e)&!(0|i)&&M(27795,27122,1050,27145),S=r,0|(i=0)):(S=r,0|(i=3))}function JA(A,e,t){var r,o=0,i=0,a=0;if(r=4+(t|=0)|0,i=0|tt(0|(A|=0),0|(e|=0),52),B(),i&=15,a=0|tt(0|A,0|e,45),B(),o=!(0|i),0|z(127&a)){if(o)return 1;o=1}else{if(o)return 0;o=0|n[r>>2]||0|n[t+8>>2]?1:1&!!(0|n[t+12>>2])}for(t=1;1&t?gA(r):hA(r),a=0|tt(0|A,0|e,3*(15-t|0)|0),B(),mA(r,7&a),t>>>0>>0;)t=t+1|0;return 0|o}function XA(A,e,t){t|=0;var r,o,i=0,a=0,s=0,l=0,c=0,u=0;if(o=S,S=S+16|0,r=o,u=0|tt(0|(A|=0),0|(e|=0),45),B(),(u&=127)>>>0>121)return n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,n[t+12>>2]=0,S=o,5;A:do{if(0|z(u)&&(s=0|tt(0|A,0|e,52),B(),0|(s&=15))){i=1;e:for(;;){switch(c=0|tt(0|A,0|e,3*(15-i|0)|0),B(),7&c){case 5:break e;case 0:break;default:i=e;break A}if(!(i>>>0>>0)){i=e;break A}i=i+1|0}for(a=1,i=e;l=0|rt(7,0,0|(e=3*(15-a|0)|0)),c=i&~B(),i=0|tt(0|A,0|i,0|e),B(),A=A&~l|(i=0|rt(0|wA(7&i),0,0|e)),i=0|c|B(),a>>>0>>0;)a=a+1|0}else i=e}while(0);if(c=7696+(28*u|0)|0,n[t>>2]=n[c>>2],n[t+4>>2]=n[c+4>>2],n[t+8>>2]=n[c+8>>2],n[t+12>>2]=n[c+12>>2],!(0|JA(A,i,t)))return S=o,0;if(l=t+4|0,n[r>>2]=n[l>>2],n[r+4>>2]=n[l+4>>2],n[r+8>>2]=n[l+8>>2],s=0|tt(0|A,0|i,52),B(),c=15&s,1&s?(hA(l),s=c+1|0):s=c,0|z(u)){A:do{if(c)for(e=1;;){if(a=0|tt(0|A,0|i,3*(15-e|0)|0),B(),0|(a&=7)){i=a;break A}if(!(e>>>0>>0)){i=0;break}e=e+1|0}else i=0}while(0);i=4==(0|i)&1}else i=0;if(0|NA(t,s,i,0)){if(0|z(u))do{}while(0|NA(t,s,0,0));(0|s)!=(0|c)&&dA(l)}else(0|s)!=(0|c)&&(n[l>>2]=n[r>>2],n[l+4>>2]=n[r+4>>2],n[l+8>>2]=n[r+8>>2]);return S=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=S,S=S+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(S=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=S,S=S+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),S=r}(r,15&i,t),S=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=S,S=S+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return S=r,0|n;n=0|tt(0|A,0|e,45),B(),n=!(0|z(127&n)),o=0|tt(0|A,0|e,52),B(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(!((0|rt(7,0,3*(15-n|0)|0))&A)&!((0|B())&e)))break A;if(!(n>>>0>>0))break;n=n+1|0}return QA(i,o,0,5,t),S=r,0}}while(0);return FA(i,o,0,6,t),S=r,0}function Ae(A,e){e|=0;var t=0,r=0,o=0,i=0,a=0,s=0,l=0;if((A|=0)>>>0>15)return 4;if(rt(0|A,0,52),s=134225919|B(),!A){t=0,r=0;do{0|z(r)&&(rt(0|r,0,45),a=0|s|B(),n[(A=e+(t<<3)|0)>>2]=-1,n[A+4>>2]=a,t=t+1|0),r=r+1|0}while(122!=(0|r));return 0}t=0,a=0;do{if(0|z(a)){for(rt(0|a,0,45),r=1,o=-1,i=0|s|B();o&=~(l=0|rt(7,0,3*(15-r|0)|0)),i&=~B(),(0|r)!=(0|A);)r=r+1|0;n[(l=e+(t<<3)|0)>>2]=o,n[l+4>>2]=i,t=t+1|0}a=a+1|0}while(122!=(0|a));return 0}function ee(A,e,t,r){A|=0,r|=0;var o=0,i=0,a=0;o=0|tt(0|(e|=0),0|(t|=0),52),B(),!(0|e)&!(0|t)|(0|r)>15|(0|(o&=15))>(0|r)?(i=-1,e=-1,t=0,o=0):(e=0|zA(e,t,o+1|0,r),a=-15728641&B(),t=0|rt(0|r,0,52),i=o,e=(e=!(0|HA(t|=e,a=0|a|B())))?-1:r,o=a),n[(a=A)>>2]=t,n[a+4>>2]=o,n[A+8>>2]=i,n[A+12>>2]=e}function te(A,e,t,r){t|=0,r|=0;var o=0,i=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,n[(i=r+8|0)>>2]=o,!(0|A)&!(0|e)|(0|t)>15|(0|o)>(0|t)?(n[(t=r)>>2]=0,n[t+4>>2]=0,n[i>>2]=-1,void(n[r+12>>2]=-1)):(A=0|zA(A,e,o+1|0,t),i=-15728641&B(),o=0|rt(0|t,0,52),o|=A,i=0|i|B(),n[(A=r)>>2]=o,n[A+4>>2]=i,A=r+12|0,0|HA(o,i)?void(n[A>>2]=t):void(n[A>>2]=-1))}function re(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(!(!(0|(t=0|n[(r=A|=0)>>2]))&!(0|(r=0|n[r+4>>2]))||(o=0|tt(0|t,0|r,52),B(),t=0|Ve(0|(l=0|rt(1,0,3*(15^(o&=15))|0)),0|B(),0|t,0|r),r=0|B(),n[(l=A)>>2]=t,n[l+4>>2]=r,(0|o)<(0|(s=0|n[(l=A+8|0)>>2]))))){for(e=A+12|0,a=o;;){if((0|a)==(0|s)){o=5;break}if(c=(0|a)==(0|n[e>>2]),o=0|tt(0|t,0|r,0|(i=3*(15-a|0)|0)),B(),c&1==(0|(o&=7))&!0){o=7;break}if(!(7==(0|o)&!0)){o=10;break}if(t=0|Ve(0|t,0|r,0|(c=0|rt(1,0,0|i)),0|B()),r=0|B(),n[(c=A)>>2]=t,n[c+4>>2]=r,!((0|a)>(0|s))){o=10;break}a=a+-1|0}if(5==(0|o))return n[(c=A)>>2]=0,n[c+4>>2]=0,n[l>>2]=-1,void(n[e>>2]=-1);if(7==(0|o))return s=0|Ve(0|t,0|r,0|(s=0|rt(1,0,0|i)),0|B()),l=0|B(),n[(c=A)>>2]=s,n[c+4>>2]=l,void(n[e>>2]=a+-1)}}function ne(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function oe(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<17453292519943298e-27?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<17453292519943298e-27):0|(e=0)}function ie(A,e){switch(A=+A,0|(e|=0)){case 1:A=A<0?A+6.283185307179586:A;break;case 2:A=A>0?A+-6.283185307179586:A}return+A}function ae(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475}function se(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20656+(A<<3)>>3],0|(e=0))}function le(A,e){e|=0;var t=0;return(A|=0)>>>0>15?0|(e=4):(t=0|qe(0|(t=0|pe(7,0,A,((0|A)<0)<<31>>31)),0|B(),120,0),A=0|B(),n[e>>2]=2|t,n[e+4>>2]=A,0|(e=0))}function ce(A,e,t){A|=0,t|=0;var r,n,i,a,s=0,l=0,u=0,h=0,m=0,v=0;return v=+o[(e|=0)>>3],i=+o[A>>3],m=+d(.5*(v-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+d(.5*(u-n)),r=+f(+i),a=+f(+v),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],v=+d(.5*(m-v)),s=+o[t+8>>3],u=+d(.5*(s-u)),l=+f(+m),u=2*+p(+ +c(+(u=v*v+u*(a*l*u))),+ +c(+(1-u))),m=+d(.5*(i-m)),s=+d(.5*(n-s)),s=2*+p(+ +c(+(s=m*m+s*(r*l*s))),+ +c(+(1-s))),4*+b(+ +c(+ +g(.5*(l=.5*(h+u+s)))*+g(.5*(l-h))*+g(.5*(l-u))*+g(.5*(l-s))))}function ue(A,e,t){t|=0;var r,i,a,s=0,l=0;if(a=S,S=S+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return S=a,0|l;if(0|$A(A,e,i)&&M(27795,27190,415,27199),(0|(e=0|n[i>>2]))>0){if(s=+ce(i+8|0,i+8+((1!=(0|e)&1)<<4)|0,r)+0,1!=(0|e)){A=1;do{s+=+ce(i+8+((l=A)<<4)|0,i+8+((0|(A=A+1|0))%(0|e)<<4)|0,r)}while((0|A)<(0|e))}}else s=0;return o[t>>3]=s,S=a,0}function fe(A){A|=0;var e,t,r=0;return(e=0|We(1,12))||M(27280,27235,49,27293),0|(r=0|n[(t=A+4|0)>>2])?(n[(r=r+8|0)>>2]=e,n[t>>2]=e,0|e):(0|n[A>>2]&&M(27310,27235,61,27333),n[(r=A)>>2]=e,n[t>>2]=e,0|e)}function de(A,e){var t,r;return A|=0,e|=0,(r=0|Ue(24))||M(27347,27235,78,27361),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[r+16>>2]=0,0|(t=0|n[(e=A+4|0)>>2])?(n[t+16>>2]=r,n[e>>2]=r,0|r):(0|n[A>>2]&&M(27376,27235,82,27361),n[A>>2]=r,n[e>>2]=r,0|r)}function ge(A){var e=0,t=0,r=0,o=0;if(A|=0)for(r=1;;){if(0|(e=0|n[A>>2]))do{if(0|(t=0|n[e>>2]))do{o=t,t=0|n[t+16>>2],Ye(o)}while(0|t);o=e,e=0|n[e+8>>2],Ye(o)}while(0|e);if(e=A,A=0|n[A+8>>2],r||Ye(e),!A)break;r=0}}function he(A,e,t){A|=0;var r=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),r=+o[t>>3],i=e&(i=+o[t+8>>3])<0?i+6.283185307179586:i,!(A=0|n[A>>2]))return 0;if(e){e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(((c=(l=s<0?s+6.283185307179586:s)+(r-a)/(c-a)*((s=i<0?i+6.283185307179586:i)-l))<0?c+6.283185307179586:c)>(u=l==u|s==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}else{e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(s+(r-a)/(c-a)*(i-s)>(u=s==u|i==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}return 0}function me(A,e,t,o,i){t|=0,o|=0,i|=0;var a,s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(c=S,S=S+32|0,w=c+16|0,l=c,u=0|tt(0|(A|=0),0|(e|=0),52),B(),u&=15,b=0|tt(0|t,0|o,52),B(),(0|u)!=(15&b))return S=c,12;if(h=0|tt(0|A,0|e,45),B(),h&=127,m=0|tt(0|t,0|o,45),B(),h>>>0>121|(m&=127)>>>0>121)return S=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(d=0|V(h,m))))return S=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=d,f=g)}else p=0,f=0;a=0|z(h),s=0|z(m),n[w>>2]=0,n[w+4>>2]=0,n[w+8>>2]=0,n[w+12>>2]=0;do{if(p){if(d=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(d){h=0,g=t,d=o;do{g=0|WA(g,d),d=0|B(),1==(0|(f=0|wA(f)))&&(f=0|wA(1)),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;else if(d){h=0,g=t,d=o;do{g=0|VA(g,d),d=0|B(),f=0|wA(f),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;if(JA(h,g,w),b||M(27563,27538,191,27548),(d=!!(0|a))&(f=!!(0|s))&&M(27590,27538,192,27548),d){if(7==(0|(f=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*f|0)+p|0]){u=1;break}h=g=0|n[21168+(28*f|0)+(p<<2)>>2]}else if(f){if(7==(0|(f=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*f|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(f<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){d=w+4|0,f=0;do{pA(d),f=f+1|0}while((0|f)!=(0|g))}if(n[l>>2]=0,n[l+4>>2]=0,n[l+8>>2]=0,mA(l,p),0|u)for(;0|ZA(u)?gA(l):hA(l),(0|u)>1;)u=u+-1|0;if((0|h)>0){u=0;do{pA(l),u=u+1|0}while((0|u)!=(0|h))}iA(v=w+4|0,l,v),nA(v),v=51}}else if(JA(t,o,w),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(f=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*f|0)+u|0])u=1;else if((0|(f=0|n[21168+(28*f|0)+(u<<2)>>2]))>0){d=w+4|0,u=0;do{pA(d),u=u+1|0}while((0|u)!=(0|f));v=51}else v=51;else v=51}while(0);return 51==(0|v)&&(u=w+4|0,n[i>>2]=n[u>>2],n[i+4>>2]=n[u+4>>2],n[i+8>>2]=n[u+8>>2],u=0),S=c,0|u}function be(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(a=S,S=S+48|0,o=a+36|0,c=a+24|0,u=a+12|0,f=a,s=0|tt(0|(A|=0),0|(e|=0),52),B(),s&=15,g=0|tt(0|A,0|e,45),B(),(g&=127)>>>0>121)return S=a,5;if(i=0|z(g),rt(0|s,0,52),b=134225919|B(),n[(l=r)>>2]=-1,n[l+4>>2]=b,!s)return 7==(0|(s=0|lA(t)))||127==(0|(s=0|W(g,s)))?(S=a,0|(b=1)):(h=0|rt(0|s,0,45),m=0|B(),m=-1040385&n[(g=r)+4>>2]|m,n[(b=r)>>2]=n[g>>2]|h,n[b+4>>2]=m,S=a,0|(b=0));for(n[o>>2]=n[t>>2],n[o+4>>2]=n[t+4>>2],n[o+8>>2]=n[t+8>>2],t=s;;){if(l=t,t=t+-1|0,n[c>>2]=n[o>>2],n[c+4>>2]=n[o+4>>2],n[c+8>>2]=n[o+8>>2],0|ZA(l)){if(0|(s=0|cA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],gA(u)}else{if(0|(s=0|uA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],hA(u)}if(aA(c,u,f),nA(f),v=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(w=3*(15-l|0)|0)),s&=~B(),w=0|rt(0|lA(f),0,0|w),s=0|B()|s,n[(b=r)>>2]=w|v&~p,n[b+4>>2]=s,(0|l)<=1){t=14;break}}A:do{if(13!=(0|t)&&14==(0|t))if((0|n[o>>2])<=1&&(0|n[o+4>>2])<=1&&(0|n[o+8>>2])<=1){f=127==(0|(s=0|W(g,t=0|lA(o))))?0:0|z(s);e:do{if(t){if(i){if(7==(0|(s=0|OA(A,e)))){s=5;break A}if((0|(l=0|n[21376+(28*s|0)+(t<<2)>>2]))>0){s=t,t=0;do{s=0|vA(s),t=t+1|0}while((0|t)!=(0|l))}else s=t;if(1==(0|s)){s=9;break A}127==(0|(t=0|W(g,s)))&&M(27648,27538,411,27678),0|z(t)?M(27693,27538,412,27678):(m=t,h=l,d=s)}else m=s,h=0,d=t;if((0|(u=0|n[4272+(28*g|0)+(d<<2)>>2]))<=-1&&M(27724,27538,419,27678),!f){if((0|h)<0){s=5;break A}if(0|h){s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];do{t=0|YA(t,l),l=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=l,s=s+1|0}while((0|s)<(0|h))}if((0|u)<=0){s=m,t=58;break}for(s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];;)if(t=0|YA(t,l),l=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=l,(0|(s=s+1|0))==(0|u)){s=m,t=58;break e}}if(7==(0|(c=0|V(m,g)))&&M(27514,27538,428,27678),t=0|n[(s=r)>>2],s=0|n[s+4>>2],(0|u)>0){l=0;do{t=0|YA(t,s),s=0|B(),n[(w=r)>>2]=t,n[w+4>>2]=s,l=l+1|0}while((0|l)!=(0|u))}if(7==(0|(s=0|OA(t,s)))&&M(27795,27538,440,27678),t=0|G(m),(0|(t=0|n[(t?21792:21584)+(28*c|0)+(s<<2)>>2]))<0&&M(27795,27538,454,27678),t){s=0,l=0|n[(c=r)>>2],c=0|n[c+4>>2];do{l=0|UA(l,c),c=0|B(),n[(w=r)>>2]=l,n[w+4>>2]=c,s=s+1|0}while((0|s)<(0|t));s=m,t=58}else s=m,t=58}else if(!!(0|i)&!!(0|f)){if(7==(0|(t=0|OA(A,e)))|7==(0|(l=0|OA(0|n[(l=r)>>2],0|n[l+4>>2])))){s=5;break A}if((0|(l=0|n[21376+(28*t|0)+(l<<2)>>2]))<0){s=5;break A}if(l){t=0,c=0|n[(u=r)>>2],u=0|n[u+4>>2];do{c=0|YA(c,u),u=0|B(),n[(w=r)>>2]=c,n[w+4>>2]=u,t=t+1|0}while((0|t)<(0|l));t=58}else t=59}else t=58}while(0);if(58==(0|t)&&f&&(t=59),59==(0|t)&&1==(0|OA(0|n[(w=r)>>2],0|n[w+4>>2]))){s=9;break}p=0|n[(w=r)>>2],w=-1040385&n[w+4>>2],v=0|rt(0|s,0,45),w=0|w|B(),n[(s=r)>>2]=p|v,n[s+4>>2]=w,s=0}else s=1}while(0);return S=a,0|s}function pe(A,e,t,r){A|=0,e|=0;var n=0,o=0,i=0;if(!(0|(t|=0))&!(0|(r|=0)))return o=1,C(0|(n=0)),0|o;o=A,n=e,A=1,e=0;do{A=0|qe(0|((i=!0&!(1&t))?1:o),0|(i?0:n),0|A,0|e),e=0|B(),t=0|et(0|t,0|r,1),r=0|B(),o=0|qe(0|o,0|n,0|o,0|n),n=0|B()}while(!(!(0|t)&!(0|r)));return C(0|e),0|A}function ve(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,d=0;i=S,S=S+16|0,s=i,l=0|tt(0|(A|=0),0|(e|=0),52),B(),l&=15;do{if(l){if(!(a=0|qA(A,e,s))){u=+o[s>>3],c=1/+f(+u),d=+o[25968+(l<<3)>>3],o[t>>3]=u+d,o[t+8>>3]=u-d,u=+o[s+8>>3],c*=d,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return S=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return S=i,5;s=22064+(a<<5)|0,n[t>>2]=n[s>>2],n[t+4>>2]=n[s+4>>2],n[t+8>>2]=n[s+8>>2],n[t+12>>2]=n[s+12>>2],n[t+16>>2]=n[s+16>>2],n[t+20>>2]=n[s+20>>2],n[t+24>>2]=n[s+24>>2],n[t+28>>2]=n[s+28>>2];break}while(0);return function(A,e){e=+e;var t,r,n,i,a,s,l,c=0,u=0;c=(i=+o[(n=16+(A|=0)|0)>>3])-(r=+o[(t=A+24|0)>>3]),c=i>3],c=.5*(c*e-c),u+=e=.5*((l=u-(s=+o[(a=A+8|0)>>3]))*e-l),o[A>>3]=u>1.5707963267948966?1.5707963267948966:u,e=s-e,o[a>>3]=e<-1.5707963267948966?-1.5707963267948966:e,e=(e=i+c)>3.141592653589793?e+-6.283185307179586:e,o[n>>3]=e<-3.141592653589793?e+6.283185307179586:e,e=(e=r-c)>3.141592653589793?e+-6.283185307179586:e,o[t>>3]=e<-3.141592653589793?e+6.283185307179586:e}(t,r?1.4:1.1),(0|n[(r=26096+(l<<3)|0)>>2])==(0|A)&&(0|n[r+4>>2])==(0|e)&&(o[t>>3]=1.5707963267948966),(0|n[(l=26224+(l<<3)|0)>>2])==(0|A)&&(0|n[l+4>>2])==(0|e)&&(o[t+8>>3]=-1.5707963267948966),1.5707963267948966!=+o[t>>3]&&-1.5707963267948966!=+o[t+8>>3]?(S=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,S=i,0|(l=0))}function we(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0;if(i=S,S=S+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))S=i;else{if(0|r[0|(a=A+28|0)]?(s=0|xe(s,l),l=0|B()):r[0|a]=1,!(0|n[n[(o=A+20|0)>>2]>>2]))return 0|(s=0|n[(a=A+24|0)>>2])&&Ye(s),n[(y=A)>>2]=0,n[y+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[A+16>>2]=0,n[a>>2]=0,void(S=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))x=A+24|0;else{v=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,f=3==(2|c),d=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){w=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){w=19;break e}}if(g&&(c=0|n[4+(0|n[o>>2])>>2],n[e>>2]=n[c>>2],n[e+4>>2]=n[c+4>>2],n[e+8>>2]=n[c+8>>2],n[e+12>>2]=n[c+12>>2],0|X(26832,e))){if(0|KA(0|n[4+(0|n[o>>2])>>2],u,t)){w=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){w=29;break}}if(h){if(0|(c=0|$A(s,l,e))){w=32;break}if(0|ve(s,l,t,0)){w=36;break}if(f&&0|De(0|n[o>>2],0|n[p>>2],e,t)){w=42;break}if(g&&0|Qe(0|n[o>>2],0|n[p>>2],e,t)){w=42;break}}if(b){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){w=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){w=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],d)){w=53;break}if(0|Qe(0|n[o>>2],0|n[p>>2],t,e)){w=53;break}}}}do{if((0|u)<(0|n[v>>2])){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){w=58;break e}if(!(0|q(c,e))){w=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){w=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){w=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else w=73}while(0);if(73==(0|w)&&(w=0,s=0|xe(s,l),l=0|B()),!(0|s)&!(0|l)){x=p;break A}}switch(0|w){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,w=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,w=20;break;case 25:M(27795,27761,470,27772);break;case 29:case 42:return n[A>>2]=s,n[A+4>>2]=l,void(S=i);case 32:return 0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(S=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,w=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,w=55;break;case 58:0|c&&Ye(c),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,w=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,w=71;break;case 67:return 0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(S=i)}if(20==(0|w))return void(S=i);if(55==(0|w))return void(S=i);if(71==(0|w))return void(S=i)}}while(0);0|(a=0|n[x>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[y>>2]=0,n[x>>2]=0,S=i}}function xe(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;t=S,S=S+16|0,f=t,o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,r=0|tt(0|A,0|e,45),B();do{if(o){for(;r=0|rt(o+4095|0,0,52),i=B()|-15728641&e,r=r|A|(s=0|rt(7,0,0|(a=3*(15-o|0)|0))),i|=l=0|B(),c=0|tt(0|A,0|e,0|a),B(),o=o+-1|0,!((c&=7)>>>0<6);){if(!o){u=4;break}e=i,A=r}if(4==(0|u)){r=0|tt(0|r,0|i,45),B();break}return f=0|rt(((f=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,f|=A&~s,C(0|u),S=t,0|f}}while(0);return(r&=127)>>>0>120?(f=0,C(0|(u=0)),S=t,0|f):(IA(f,0,r+1|0,0),u=0|n[f+4>>2],f=0|n[f>>2],C(0|u),S=t,0|f)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),i=+o[t>>3],a=e&(a=+o[t+8>>3])<0?a+6.283185307179586:a,(0|(g=0|n[A>>2]))<=0)return 0;if(r=0|n[A+4>>2],e){e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(((u=(c=l<0?l+6.283185307179586:l)+(i-s)/(u-s)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}else{e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(d=l==d|a==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}return 0}function ke(A,e){e|=0;var t,r,i,a,s,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0;if(!(r=0|n[(A|=0)>>2]))return n[e>>2]=0,n[e+4>>2]=0,n[e+8>>2]=0,n[e+12>>2]=0,n[e+16>>2]=0,n[e+20>>2]=0,n[e+24>>2]=0,void(n[e+28>>2]=0);if(o[(i=e+8|0)>>3]=17976931348623157e292,o[(a=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(s=e+16|0)>>3]=-17976931348623157e292,!((0|r)<=0)){for(t=0|n[A+4>>2],b=17976931348623157e292,p=-17976931348623157e292,v=0,A=-1,d=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,w=0;c=+o[t+(w<<4)>>3],h=+o[t+(w<<4)+8>>3],f=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,d=c),h>3]=h,g=h),c>m?o[e>>3]=c:c=m,h>u&&(o[s>>3]=h,u=h),b=h>0&hp?h:p,v|=+l(+(h-f))>3.141592653589793,(0|(A=w+1|0))!=(0|r);)x=w,m=c,w=A,A=x;v&&(o[s>>3]=p,o[a>>3]=b)}}function Ce(A){return 0|((A|=0)>>>0<4?0:15)}function Be(A,e){e|=0;var t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(v=e+8|0)>>3]=17976931348623157e292,o[(w=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(x=e+16|0)>>3]=-17976931348623157e292,(0|p)>0){for(a=0|n[A+4>>2],m=17976931348623157e292,b=-17976931348623157e292,i=0,r=-1,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292,y=0;s=+o[a+(y<<4)>>3],g=+o[a+(y<<4)+8>>3],u=+o[a+(((0|(B=r+2|0))==(0|p)?0:B)<<4)+8>>3],s>3]=s,f=s),g>3]=g,d=g),s>h?o[e>>3]=s:s=h,g>c&&(o[x>>3]=g,c=g),m=g>0&gb?g:b,i|=+l(+(g-u))>3.141592653589793,(0|(r=y+1|0))!=(0|p);)B=y,h=s,y=r,r=B;i&&(o[x>>3]=b,o[w>>3]=m)}}else n[e>>2]=0,n[e+4>>2]=0,n[e+8>>2]=0,n[e+12>>2]=0,n[e+16>>2]=0,n[e+20>>2]=0,n[e+24>>2]=0,n[e+28>>2]=0;if(!((0|(r=0|n[(B=A+8|0)>>2]))<=0)){t=A+12|0,C=0;do{if(a=0|n[t>>2],i=C,w=e+((C=C+1|0)<<5)|0,x=0|n[a+(i<<3)>>2]){if(o[(y=e+(C<<5)+8|0)>>3]=17976931348623157e292,o[(A=e+(C<<5)+24|0)>>3]=17976931348623157e292,o[w>>3]=-17976931348623157e292,o[(k=e+(C<<5)+16|0)>>3]=-17976931348623157e292,(0|x)>0){for(p=0|n[a+(i<<3)+4>>2],m=17976931348623157e292,b=-17976931348623157e292,a=0,i=-1,v=0,f=17976931348623157e292,d=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(v<<4)>>3],h=+o[p+(v<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|x)?0:i)<<4)+8>>3],s>3]=s,f=s),h>3]=h,d=h),s>g?o[w>>3]=s:s=g,h>c&&(o[k>>3]=h,c=h),m=h>0&hb?h:b,a|=+l(+(h-u))>3.141592653589793,(0|(i=v+1|0))!=(0|x);)M=v,v=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[w>>2]=0,n[w+4>>2]=0,n[w+8>>2]=0,n[w+12>>2]=0,n[w+16>>2]=0,n[w+20>>2]=0,n[w+24>>2]=0,n[w+28>>2]=0,r=0|n[B>>2]}while((0|C)<(0|r))}}function Me(A,e,t){var r=0,o=0,i=0;if(!(0|ye(A|=0,e|=0,t|=0)))return 0;if((0|n[(o=A+8|0)>>2])<=0)return 1;for(r=A+12|0,A=0;;){if(i=A,A=A+1|0,0|ye((0|n[r>>2])+(i<<3)|0,e+(A<<5)|0,t)){A=0,r=6;break}if((0|A)>=(0|n[o>>2])){A=1,r=6;break}}return 6==(0|r)?0|A:0}function De(A,e,t,r){r|=0;var o,i,a=0,s=0,l=0,c=0,u=0;if(i=S,S=S+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return S=i,0;c=A+8|0;A:do{if((0|n[c>>2])>0){for(s=A+12|0,a=0;;){if(u=a,a=a+1|0,0|ye((0|n[s>>2])+(u<<3)|0,e+(a<<5)|0,l)){a=0;break}if((0|a)>=(0|n[c>>2]))break A}return S=i,0|a}}while(0);if(0|Ee(A,e,t,r))return S=i,0;n[o>>2]=n[t>>2],n[o+4>>2]=l,a=0|n[c>>2];A:do{if((0|a)>0)for(A=A+12|0,l=0,s=a;;){if(a=0|n[A>>2],(0|n[a+(l<<3)>>2])>0){if(0|ye(o,r,0|n[a+(l<<3)+4>>2])){a=0;break A}if(a=l+1|0,0|Ee((0|n[A>>2])+(l<<3)|0,e+(a<<5)|0,t,r)){a=0;break A}s=0|n[c>>2]}else a=l+1|0;if(!((0|a)<(0|s))){a=1;break}l=a}else a=1}while(0);return S=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,M=0;if(u=S,S=S+176|0,l=u+172|0,f=u+168|0,c=u,!(0|q(e|=0,r|=0)))return S=u,0;if(function(A,e,t,r){var i,a,s,l,c;e|=0,t|=0,r|=0,A=(a=+o[16+(A|=0)>>3])<(c=+o[A+24>>3]),i=(l=+o[e+16>>3])<(s=+o[e+24>>3]),e=c-l>2]=A?i|e?1:2:0,n[r>>2]=i?A?1:e?2:1:0}(e,r,l,f),st(0|c,0|t,168),(0|n[t>>2])>0){e=0;do{y=+ie(+o[(B=c+8+(e<<4)+8|0)>>3],0|n[f>>2]),o[B>>3]=y,e=e+1|0}while((0|e)<(0|n[t>>2]))}a=+o[r>>3],s=+o[r+8>>3],y=+ie(+o[r+16>>3],0|n[f>>2]),i=+ie(+o[r+24>>3],0|n[f>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(f=0|n[c>>2]))<=0)for(e=0;;)if((0|(e=e+1|0))>=(0|n[A>>2])){e=0;break A}for(t=0;;){if(e=0|n[r>>2],w=+o[e+(t<<4)>>3],x=+ie(+o[e+(t<<4)+8>>3],0|n[l>>2]),e=0|n[r>>2],B=(0|(t=t+1|0))%(0|n[A>>2])|0,d=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(w>=a)|!(d>=a)&&!(w<=s)|!(d<=s)&&!(x<=i)|!(g<=i)&&!(x>=y)|!(g>=y)){v=d-w,b=g-x,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|f)?0:e,d=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-d,h=+o[c+8+(M<<4)>>3],!(0==(p=v*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=x-d,C=w-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(v*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|f))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return S=u,0|e}function Qe(A,e,t,r){var o=0,i=0,a=0;if(0|Ee(A|=0,e|=0,t|=0,r|=0))return 1;if((0|n[(i=A+8|0)>>2])<=0)return 0;for(o=A+12|0,A=0;;){if(a=A,A=A+1|0,0|Ee((0|n[o>>2])+(a<<3)|0,e+(A<<5)|0,t,r)){A=1,o=6;break}if((0|A)>=(0|n[i>>2])){A=0,o=6;break}}return 6==(0|o)?0|A:0}function je(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,f,d=0;l=+o[(A|=0)>>3],s=+o[e>>3]-l,a=+o[A+8>>3],i=+o[e+8>>3]-a,u=+o[t>>3],d=((d=+o[r>>3]-u)*(a-(f=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-f))/(s*c-i*d),o[n>>3]=l+s*d,o[n+8>>3]=a+i*d}function Ne(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<1.1920928955078125e-7?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<1.1920928955078125e-7):0|(e=0)}function Se(A,e){var t,r,n;return e|=0,+((n=+o[(A|=0)>>3]-+o[e>>3])*n+(r=+o[A+8>>3]-+o[e+8>>3])*r+(t=+o[A+16>>3]-+o[e+16>>3])*t)}function Fe(A,e,t){t|=0;var r,o,i,a,s=0,l=0,c=0,u=0;if(a=S,S=S+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return S=a,0|s;r=0|TA(A,e),i=0|OA(A,e),function(A,e){A=7696+(28*(A|=0)|0)|0,n[(e|=0)>>2]=n[A>>2],n[e+4>>2]=n[A+4>>2],n[e+8>>2]=n[A+8>>2],n[e+12>>2]=n[A+12>>2]}(r,u),s=0|function(A,e){A|=0;var t=0,r=0;if((e|=0)>>>0>20)return-1;do{if((0|n[11120+(216*e|0)>>2])!=(0|A))if((0|n[11120+(216*e|0)+8>>2])!=(0|A))if((0|n[11120+(216*e|0)+16>>2])!=(0|A))if((0|n[11120+(216*e|0)+24>>2])!=(0|A))if((0|n[11120+(216*e|0)+32>>2])!=(0|A))if((0|n[11120+(216*e|0)+40>>2])!=(0|A))if((0|n[11120+(216*e|0)+48>>2])!=(0|A))if((0|n[11120+(216*e|0)+56>>2])!=(0|A))if((0|n[11120+(216*e|0)+64>>2])!=(0|A))if((0|n[11120+(216*e|0)+72>>2])!=(0|A))if((0|n[11120+(216*e|0)+80>>2])!=(0|A))if((0|n[11120+(216*e|0)+88>>2])!=(0|A))if((0|n[11120+(216*e|0)+96>>2])!=(0|A))if((0|n[11120+(216*e|0)+104>>2])!=(0|A))if((0|n[11120+(216*e|0)+112>>2])!=(0|A))if((0|n[11120+(216*e|0)+120>>2])!=(0|A))if((0|n[11120+(216*e|0)+128>>2])!=(0|A)){if((0|n[11120+(216*e|0)+136>>2])!=(0|A)){if((0|n[11120+(216*e|0)+144>>2])==(0|A)){A=0,t=2,r=0;break}if((0|n[11120+(216*e|0)+152>>2])==(0|A)){A=0,t=2,r=1;break}if((0|n[11120+(216*e|0)+160>>2])==(0|A)){A=0,t=2,r=2;break}if((0|n[11120+(216*e|0)+168>>2])==(0|A)){A=1,t=2,r=0;break}if((0|n[11120+(216*e|0)+176>>2])==(0|A)){A=1,t=2,r=1;break}if((0|n[11120+(216*e|0)+184>>2])==(0|A)){A=1,t=2,r=2;break}if((0|n[11120+(216*e|0)+192>>2])==(0|A)){A=2,t=2,r=0;break}if((0|n[11120+(216*e|0)+200>>2])==(0|A)){A=2,t=2,r=1;break}if((0|n[11120+(216*e|0)+208>>2])==(0|A)){A=2,t=2,r=2;break}return-1}A=2,t=1,r=2}else A=2,t=1,r=1;else A=2,t=1,r=0;else A=1,t=1,r=2;else A=1,t=1,r=1;else A=1,t=1,r=0;else A=0,t=1,r=2;else A=0,t=1,r=1;else A=0,t=1,r=0;else A=2,t=0,r=2;else A=2,t=0,r=1;else A=2,t=0,r=0;else A=1,t=0,r=2;else A=1,t=0,r=1;else A=1,t=0,r=0;else A=0,t=0,r=2;else A=0,t=0,r=1;else A=0,t=0,r=0}while(0);return 0|n[11120+(216*e|0)+(72*t|0)+(24*A|0)+(r<<3)+4>>2]}(r,0|n[o>>2]);do{if(0|z(r)){switch(0|r){case 4:l=0;break;case 14:l=1;break;case 24:l=2;break;case 38:l=3;break;case 49:l=4;break;case 58:l=5;break;case 63:l=6;break;case 72:l=7;break;case 83:l=8;break;case 97:l=9;break;case 107:l=10;break;case 117:l=11;break;default:M(27795,27797,75,27806)}if(c=0|n[26416+(24*l|0)+8>>2],e=0|n[26416+(24*l|0)+16>>2],(0|(A=0|n[o>>2]))!=(0|n[u>>2])&&(u=0|G(r))|(0|(A=0|n[o>>2]))==(0|e)&&(s=(s+1|0)%6|0),3==(0|i)&(0|A)==(0|e)){s=(s+5|0)%6|0;break}5==(0|i)&(0|A)==(0|c)&&(s=(s+1|0)%6|0)}}while(0);return n[t>>2]=s,S=a,0}function Pe(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0;if(l=S,S=S+32|0,w=l+24|0,s=l+20|0,a=l+8|0,i=l+16|0,o=l,g=(g=!(0|HA(A|=0,e|=0)))?6:5,m=0|tt(0|A,0|e,52),B(),g>>>0<=t>>>0)return S=l,2;!(b=!(0|(m&=15)))&&!((p=0|rt(7,0,3*(15^m)|0))&A)&!((0|B())&e)?c=t:u=4;A:do{if(4==(0|u)){if((0|((c=!!(0|HA(A,e)))?4:5))<(0|t))return S=l,1;if(0|Fe(A,e,w))return S=l,1;if(u=(0|n[w>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return S=l,1;n[s>>2]=0,c=0|I(A,e,p,s,a);do{if(!c){if(h=0|n[(d=a)>>2],u=(f=(d=0|n[d+4>>2])>>>0>>0|(0|d)==(0|e)&h>>>0>>0)?h:A,f=f?d:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(d&(0|B())))c=t;else{if(d=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|d)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|d)&&M(27795,27797,248,27822),0|Fe(A,e,w)&&M(27795,27797,248,27822),c=(0|n[w>>2])+d|0,7==(0|(d=0|n[(c=g?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&M(27795,27797,248,27822),n[i>>2]=0,0|(c=0|I(A,e,d,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|f)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,f=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,f=h;break}do{if(!(0|Fe(g,h,w))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[w>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[w>>2])|0)%6|0;break}c=-1}while(0);u=g,f=h}else c=t}while(0);h=0|n[(d=a)>>2],d=0|n[d+4>>2]}if((0|u)==(0|h)&(0|f)==(0|d)){if(A=(g=!!(0|HA(h,d)))?0|_(h,d,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,d),(A+-1|0)>>>0<=5&&!(1==(0|A)&(v=!!(0|c))))do{if(!(0|Fe(h,d,w))){if(v){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[w>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[w>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|g&5==(0|c)?0:c}e=f,A=u;break A}}while(0);return S=l,0|c}}while(0);return v=0|rt(0|c,0,56),w=B()|-2130706433&e|536870912,n[r>>2]=v|A,n[r+4>>2]=w,S=l,0}function Te(A,e){A|=0;var t,r,o=0,i=0;return r=S,S=S+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|LA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Pe(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,S=r,0|o):(S=r,0|(o=0))}function Le(A,e,t){A|=0,t|=0;var r=0;(0|(e|=0))>0?(r=0|We(e,4),n[A>>2]=r,r||M(27835,27858,40,27872)):n[A>>2]=0,n[A+4>>2]=e,n[A+8>>2]=0,n[A+12>>2]=t}function Ie(A){var e,t,r,i=0,a=0,s=0,c=0;e=4+(A|=0)|0,t=A+12|0,r=A+8|0;A:for(;;){for(a=0|n[e>>2],i=0;;){if((0|i)>=(0|a))break A;if(s=0|n[A>>2],c=0|n[s+(i<<2)>>2])break;i=i+1|0}i=s+(~~(+l(+ +u(10,+ +(15-(0|n[t>>2])|0))*(+o[c>>3]+ +o[c+8>>3]))%+(0|a))>>>0<<2)|0,a=0|n[i>>2];e:do{if(0|a){if(s=c+32|0,(0|a)==(0|c))n[i>>2]=n[s>>2];else{if(!(i=0|n[(a=a+32|0)>>2]))break;for(;(0|i)!=(0|c);)if(!(i=0|n[(a=i+32|0)>>2]))break e;n[a>>2]=n[s>>2]}Ye(c),n[r>>2]=(0|n[r>>2])-1}}while(0)}Ye(0|n[A>>2])}function Re(A){var e,t=0,r=0;for(e=0|n[4+(A|=0)>>2],r=0;;){if((0|r)>=(0|e)){t=0,r=4;break}if(t=0|n[(0|n[A>>2])+(r<<2)>>2]){r=4;break}r=r+1|0}return 4==(0|r)?0|t:0}function _e(A,e){e|=0;var t=0,r=0,i=0,a=0;if(t=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,t=(0|n[A>>2])+(t<<2)|0,!(r=0|n[t>>2]))return 1;a=e+32|0;do{if((0|r)!=(0|e)){if(!(t=0|n[r+32>>2]))return 1;for(i=t;;){if((0|i)==(0|e)){i=8;break}if(!(t=0|n[i+32>>2])){t=1,i=10;break}r=i,i=t}if(8==(0|i)){n[r+32>>2]=n[a>>2];break}if(10==(0|i))return 0|t}else n[t>>2]=n[a>>2]}while(0);return Ye(e),n[(a=A+8|0)>>2]=(0|n[a>>2])-1,0}function He(A,e,t){A|=0,e|=0,t|=0;var r,i=0,a=0,s=0;(r=0|Ue(40))||M(27888,27858,98,27901),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[(a=r+16|0)>>2]=n[t>>2],n[a+4>>2]=n[t+4>>2],n[a+8>>2]=n[t+8>>2],n[a+12>>2]=n[t+12>>2],n[r+32>>2]=0,a=~~(+l(+ +u(10,+ +(15-(0|n[A+12>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,a=(0|n[A>>2])+(a<<2)|0,i=0|n[a>>2];do{if(i){for(;!(0|oe(i,e)&&0|oe(i+16|0,t));)if(a=0|n[i+32>>2],!(0|n[(i=0|a?a:i)+32>>2])){s=10;break}if(10==(0|s)){n[i+32>>2]=r;break}return Ye(r),0|i}n[a>>2]=r}while(0);return n[(s=A+8|0)>>2]=1+(0|n[s>>2]),0|r}function ze(A,e,t){e|=0,t|=0;var r=0,i=0;if(i=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,!(i=0|n[(0|n[A>>2])+(i<<2)>>2]))return 0;if(!t){for(A=i;;){if(0|oe(A,e)){r=10;break}if(!(A=0|n[A+32>>2])){A=0,r=10;break}}if(10==(0|r))return 0|A}for(A=i;;){if(0|oe(A,e)&&0|oe(A+16|0,t)){r=10;break}if(!(A=0|n[A+32>>2])){A=0,r=10;break}}return 10==(0|r)?0|A:0}function Ge(A,e){e|=0;var t=0;if(t=~~(+l(+ +u(10,+ +(15-(0|n[12+(A|=0)>>2])|0))*(+o[e>>3]+ +o[e+8>>3]))%+(0|n[A+4>>2]))>>>0,!(A=0|n[(0|n[A>>2])+(t<<2)>>2]))return 0;for(;;){if(0|oe(A,e)){e=5;break}if(!(A=0|n[A+32>>2])){A=0,e=5;break}}return 5==(0|e)?0|A:0}function Oe(A){return 0|+ct(+(A=+A))}function Ue(A){A|=0;var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0;e=S,S=S+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(d=0|n[6981])>>>A))return o=0|n[(r=8+(A=27964+((t=(1&r^1)+A|0)<<1<<2)|0)|0)>>2],(0|(a=0|n[(i=o+8|0)>>2]))==(0|A)?n[6981]=d&~(1<>2]=A,n[r>>2]=a),y=t<<3,n[o+4>>2]=3|y,n[(y=o+y+4|0)>>2]=1|n[y>>2],S=e,0|i;if(u>>>0>(f=0|n[6983])>>>0){if(0|r)return t=((t=r<>>=l=t>>>12&16)>>>5&8)|l|(a=(t>>>=r)>>>2&4)|(A=(t>>>=a)>>>1&2)|(o=(t>>>=A)>>>1&1))+(t>>>o)|0)<<1<<2)|0)|0)>>2],(0|(r=0|n[(l=a+8|0)>>2]))==(0|t)?(A=d&~(1<>2]=t,n[A>>2]=r,A=d),s=(y=o<<3)-u|0,n[a+4>>2]=3|u,n[4+(i=a+u|0)>>2]=1|s,n[a+y>>2]=s,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,A&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=s,n[6986]=i,S=e,0|l;if(a=0|n[6982]){for(r=(a&0-a)-1|0,r=c=0|n[28228+(((o=(r>>>=i=r>>>12&16)>>>5&8)|i|(s=(r>>>=o)>>>2&4)|(l=(r>>>=s)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&n[c+4>>2])-u|0;(A=0|n[r+16>>2])||(A=0|n[r+20>>2]);)r=A,l=(i=(s=(-8&n[A+4>>2])-u|0)>>>0>>0)?A:l,c=i?s:c;if((s=l+u|0)>>>0>l>>>0){i=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){r=0;break}for(;;)if(r=0|n[(o=t+20|0)>>2])t=r,A=o;else{if(!(r=0|n[(o=t+16|0)>>2]))break;t=r,A=o}n[A>>2]=0,r=t}else r=0|n[l+8>>2],n[r+12>>2]=t,n[t+8>>2]=r,r=t}while(0);do{if(0|i){if(t=0|n[l+28>>2],(0|l)==(0|n[(A=28228+(t<<2)|0)>>2])){if(n[A>>2]=r,!r){n[6982]=a&~(1<>2])==(0|l)?y:i+20)>>2]=r,!r)break;n[r+24>>2]=i,0|(t=0|n[l+16>>2])&&(n[r+16>>2]=t,n[t+24>>2]=r),0|(t=0|n[l+20>>2])&&(n[r+20>>2]=t,n[t+24>>2]=r)}}while(0);return c>>>0<16?(y=c+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2]):(n[l+4>>2]=3|u,n[s+4>>2]=1|c,n[s+c>>2]=c,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|d,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=c,n[6986]=s),S=e,0|l+8}d=u}else d=u}else d=u}else if(A>>>0<=4294967231)if(u=-8&(A=A+11|0),o=0|n[6982]){i=0-u|0,c=(A>>>=8)?u>>>0>16777215?31:u>>>(7+(c=14-((l=(520192+(b=A<<(d=(A+1048320|0)>>>16&8))|0)>>>16&4)|d|(c=(245760+(b<<=l)|0)>>>16&2))+(b<>>15)|0)|0)&1|c<<1:0,r=0|n[28228+(c<<2)>>2];A:do{if(r)for(A=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((s=(-8&n[r+4>>2])-u|0)>>>0>>0){if(!s){A=r,i=0,b=65;break A}A=r,i=s}if(a=!(0|(b=0|n[r+20>>2]))|(0|b)==(0|(r=0|n[r+16+(l>>>31<<2)>>2]))?a:b,!r){r=a,b=61;break}l<<=1}else r=0,A=0,b=61}while(0);if(61==(0|b)){if(!(0|r)&!(0|A)){if(!(A=((A=2<>>=s=d>>>12&16)>>>5&8)|s|(l=(d>>>=a)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(d=(-8&n[a+4>>2])-u|0)>>>0>>0)?d:i,A=r?a:A,(r=0|n[a+16>>2])||(r=0|n[a+20>>2]),!r){l=A,s=i;break}a=r}if(0|l&&s>>>0<((0|n[6983])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){a=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){t=0;break}for(;;)if(r=0|n[(i=t+20|0)>>2])t=r,A=i;else{if(!(r=0|n[(i=t+16|0)>>2]))break;t=r,A=i}n[A>>2]=0}else y=0|n[l+8>>2],n[y+12>>2]=t,n[t+8>>2]=y}while(0);do{if(a){if(A=0|n[l+28>>2],(0|l)==(0|n[(r=28228+(A<<2)|0)>>2])){if(n[r>>2]=t,!t){o&=~(1<>2])==(0|l)?y:a+20)>>2]=t,!t)break;n[t+24>>2]=a,0|(A=0|n[l+16>>2])&&(n[t+16>>2]=A,n[A+24>>2]=t),(A=0|n[l+20>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);A:do{if(s>>>0<16)y=s+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2];else{if(n[l+4>>2]=3|u,n[f+4>>2]=1|s,n[f+s>>2]=s,t=s>>>3,s>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=f,n[t+12>>2]=f,n[f+8>>2]=t,n[f+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(r=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[f+28>>2]=r,n[4+(A=f+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break}t=0|n[t>>2];e:do{if((-8&n[t+4>>2])!=(0|s)){for(o=s<<(31==(0|r)?0:25-(r>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|s)){t=A;break e}o<<=1,t=A}n[r>>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break A}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=f,n[x>>2]=f,n[f+8>>2]=y,n[f+12>>2]=t,n[f+24>>2]=0}}while(0);return S=e,0|l+8}d=u}else d=u;else d=-1}while(0);if((r=0|n[6983])>>>0>=d>>>0)return t=r-d|0,A=0|n[6986],t>>>0>15?(y=A+d|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|d):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),S=e,0|A+8;if((s=0|n[6984])>>>0>d>>>0)return w=s-d|0,n[6984]=w,x=(y=0|n[6987])+d|0,n[6987]=x,n[x+4>>2]=1|w,n[y+4>>2]=3|d,S=e,0|y+8;if(0|n[7099]?A=0|n[7101]:(n[7101]=4096,n[7100]=4096,n[7102]=-1,n[7103]=-1,n[7104]=0,n[7092]=0,n[7099]=-16&g^1431655768,A=4096),l=d+48|0,(u=(a=A+(c=d+47|0)|0)&(i=0-A|0))>>>0<=d>>>0)return S=e,0;if(0|(A=0|n[7091])&&(g=(f=0|n[7089])+u|0)>>>0<=f>>>0|g>>>0>A>>>0)return S=e,0;A:do{if(4&n[7092])t=0,b=143;else{r=0|n[6987];e:do{if(r){for(o=28372;!((g=0|n[o>>2])>>>0<=r>>>0&&(g+(0|n[o+4>>2])|0)>>>0>r>>>0);){if(!(A=0|n[o+8>>2])){b=128;break e}o=A}if((t=a-s&i)>>>0<2147483647)if((0|(A=0|ut(0|t)))==((0|n[o>>2])+(0|n[o+4>>2])|0)){if(-1!=(0|A)){s=t,a=A,b=145;break A}}else o=A,b=136;else t=0}else b=128}while(0);do{if(128==(0|b))if(-1!=(0|(r=0|ut(0)))&&(t=r,m=(t=((m=(h=0|n[7100])-1|0)&t?(m+t&0-h)-t|0:0)+u|0)+(h=0|n[7089])|0,t>>>0>d>>>0&t>>>0<2147483647)){if(0|(g=0|n[7091])&&m>>>0<=h>>>0|m>>>0>g>>>0){t=0;break}if((0|(A=0|ut(0|t)))==(0|r)){s=t,a=r,b=145;break A}o=A,b=136}else t=0}while(0);do{if(136==(0|b)){if(r=0-t|0,!(l>>>0>t>>>0&t>>>0<2147483647&-1!=(0|o))){if(-1==(0|o)){t=0;break}s=t,a=o,b=145;break A}if((A=c-t+(A=0|n[7101])&0-A)>>>0>=2147483647){s=t,a=o,b=145;break A}if(-1==(0|ut(0|A))){ut(0|r),t=0;break}s=A+t|0,a=o,b=145;break A}}while(0);n[7092]=4|n[7092],b=143}}while(0);if(143==(0|b)&&u>>>0<2147483647&&!(-1==(0|(w=0|ut(0|u)))|1^(v=(p=(m=0|ut(0))-w|0)>>>0>(d+40|0)>>>0)|w>>>0>>0&-1!=(0|w)&-1!=(0|m)^1)&&(s=v?p:t,a=w,b=145),145==(0|b)){t=(0|n[7089])+s|0,n[7089]=t,t>>>0>(0|n[7090])>>>0&&(n[7090]=t),c=0|n[6987];A:do{if(c){for(t=28372;;){if((0|a)==((A=0|n[t>>2])+(r=0|n[t+4>>2])|0)){b=154;break}if(!(o=0|n[t+8>>2]))break;t=o}if(!(154!=(0|b)||(x=t+4|0,8&n[t+12>>2]))&&a>>>0>c>>>0&A>>>0<=c>>>0){n[x>>2]=r+s,x=c+(w=7&(w=c+8|0)?0-w&7:0)|0,w=(y=(0|n[6984])+s|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[c+y+4>>2]=40,n[6988]=n[7103];break}for(a>>>0<(0|n[6985])>>>0&&(n[6985]=a),r=a+s|0,t=28372;;){if((0|n[t>>2])==(0|r)){b=162;break}if(!(A=0|n[t+8>>2]))break;t=A}if(162==(0|b)&&!(8&n[t+12>>2])){n[t>>2]=a,n[(f=t+4|0)>>2]=(0|n[f>>2])+s,u=(f=a+(7&(f=a+8|0)?0-f&7:0)|0)+d|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-f-d|0,n[f+4>>2]=3|d;e:do{if((0|c)==(0|t))y=(0|n[6984])+l|0,n[6984]=y,n[6987]=u,n[u+4>>2]=1|y;else{if((0|n[6986])==(0|t)){y=(0|n[6983])+l|0,n[6983]=y,n[6986]=u,n[u+4>>2]=1|y,n[u+y>>2]=y;break}if(1==(3&(A=0|n[t+4>>2]))){s=-8&A,o=A>>>3;t:do{if(A>>>0<256){if(A=0|n[t+8>>2],(0|(r=0|n[t+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=r,n[r+8>>2]=A;break}a=0|n[t+24>>2],A=0|n[t+12>>2];do{if((0|A)==(0|t)){if(A=0|n[(o=4+(r=t+16|0)|0)>>2])r=o;else if(!(A=0|n[r>>2])){A=0;break}for(;;)if(o=0|n[(i=A+20|0)>>2])A=o,r=i;else{if(!(o=0|n[(i=A+16|0)>>2]))break;A=o,r=i}n[r>>2]=0}else y=0|n[t+8>>2],n[y+12>>2]=A,n[A+8>>2]=y}while(0);if(!a)break;o=28228+((r=0|n[t+28>>2])<<2)|0;do{if((0|n[o>>2])==(0|t)){if(n[o>>2]=A,0|A)break;n[6982]=n[6982]&~(1<>2])==(0|t)?y:a+20)>>2]=A,!A)break t}while(0);if(n[A+24>>2]=a,0|(o=0|n[(r=t+16|0)>>2])&&(n[A+16>>2]=o,n[o+24>>2]=A),!(r=0|n[r+4>>2]))break;n[A+20>>2]=r,n[r+24>>2]=A}while(0);t=t+s|0,i=s+l|0}else i=l;if(n[(t=t+4|0)>>2]=-2&n[t>>2],n[u+4>>2]=1|i,n[u+i>>2]=i,t=i>>>3,i>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=u,n[t+12>>2]=u,n[u+8>>2]=t,n[u+12>>2]=r;break}t=i>>>8;do{if(t){if(i>>>0>16777215){o=31;break}o=i>>>(7+(o=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(o=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|o<<1}else o=0}while(0);if(t=28228+(o<<2)|0,n[u+28>>2]=o,n[4+(A=u+16|0)>>2]=0,n[A>>2]=0,!((A=0|n[6982])&(r=1<>2]=u,n[u+24>>2]=t,n[u+12>>2]=u,n[u+8>>2]=u;break}t=0|n[t>>2];t:do{if((-8&n[t+4>>2])!=(0|i)){for(o=i<<(31==(0|o)?0:25-(o>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|i)){t=A;break t}o<<=1,t=A}n[r>>2]=u,n[u+24>>2]=t,n[u+12>>2]=u,n[u+8>>2]=u;break e}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=u,n[x>>2]=u,n[u+8>>2]=y,n[u+12>>2]=t,n[u+24>>2]=0}}while(0);return S=e,0|f+8}for(t=28372;!((A=0|n[t>>2])>>>0<=c>>>0&&(y=A+(0|n[t+4>>2])|0)>>>0>c>>>0);)t=0|n[t+8>>2];t=(A=(A=(i=y+-47|0)+(7&(A=i+8|0)?0-A&7:0)|0)>>>0<(i=c+16|0)>>>0?c:A)+8|0,x=a+(w=7&(w=a+8|0)?0-w&7:0)|0,w=(r=s+-40|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[a+r+4>>2]=40,n[6988]=n[7103],n[(r=A+4|0)>>2]=27,n[t>>2]=n[7093],n[t+4>>2]=n[7094],n[t+8>>2]=n[7095],n[t+12>>2]=n[7096],n[7093]=a,n[7094]=s,n[7096]=0,n[7095]=t,t=A+24|0;do{x=t,n[(t=t+4|0)>>2]=7}while((x+8|0)>>>0>>0);if((0|A)!=(0|c)){if(a=A-c|0,n[r>>2]=-2&n[r>>2],n[c+4>>2]=1|a,n[A>>2]=a,t=a>>>3,a>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=c,n[t+12>>2]=c,n[c+8>>2]=t,n[c+12>>2]=r;break}if(r=28228+((o=(t=a>>>8)?a>>>0>16777215?31:a>>>(7+(o=14-((w=(520192+(y=t<<(x=(t+1048320|0)>>>16&8))|0)>>>16&4)|x|(o=(245760+(y<<=w)|0)>>>16&2))+(y<>>15)|0)|0)&1|o<<1:0)<<2)|0,n[c+28>>2]=o,n[c+20>>2]=0,n[i>>2]=0,!((t=0|n[6982])&(A=1<>2]=c,n[c+24>>2]=r,n[c+12>>2]=c,n[c+8>>2]=c;break}t=0|n[r>>2];e:do{if((-8&n[t+4>>2])!=(0|a)){for(o=a<<(31==(0|o)?0:25-(o>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|a)){t=A;break e}o<<=1,t=A}n[r>>2]=c,n[c+24>>2]=t,n[c+12>>2]=c,n[c+8>>2]=c;break A}}while(0);y=0|n[(x=t+8|0)>>2],n[y+12>>2]=c,n[x>>2]=c,n[c+8>>2]=y,n[c+12>>2]=t,n[c+24>>2]=0}}else!(0|(y=0|n[6985]))|a>>>0>>0&&(n[6985]=a),n[7093]=a,n[7094]=s,n[7096]=0,n[6990]=n[7099],n[6989]=-1,n[6994]=27964,n[6993]=27964,n[6996]=27972,n[6995]=27972,n[6998]=27980,n[6997]=27980,n[7e3]=27988,n[6999]=27988,n[7002]=27996,n[7001]=27996,n[7004]=28004,n[7003]=28004,n[7006]=28012,n[7005]=28012,n[7008]=28020,n[7007]=28020,n[7010]=28028,n[7009]=28028,n[7012]=28036,n[7011]=28036,n[7014]=28044,n[7013]=28044,n[7016]=28052,n[7015]=28052,n[7018]=28060,n[7017]=28060,n[7020]=28068,n[7019]=28068,n[7022]=28076,n[7021]=28076,n[7024]=28084,n[7023]=28084,n[7026]=28092,n[7025]=28092,n[7028]=28100,n[7027]=28100,n[7030]=28108,n[7029]=28108,n[7032]=28116,n[7031]=28116,n[7034]=28124,n[7033]=28124,n[7036]=28132,n[7035]=28132,n[7038]=28140,n[7037]=28140,n[7040]=28148,n[7039]=28148,n[7042]=28156,n[7041]=28156,n[7044]=28164,n[7043]=28164,n[7046]=28172,n[7045]=28172,n[7048]=28180,n[7047]=28180,n[7050]=28188,n[7049]=28188,n[7052]=28196,n[7051]=28196,n[7054]=28204,n[7053]=28204,n[7056]=28212,n[7055]=28212,x=a+(w=7&(w=a+8|0)?0-w&7:0)|0,w=(y=s+-40|0)-w|0,n[6987]=x,n[6984]=w,n[x+4>>2]=1|w,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>d>>>0)return w=t-d|0,n[6984]=w,x=(y=0|n[6987])+d|0,n[6987]=x,n[x+4>>2]=1|w,n[y+4>>2]=3|d,S=e,0|y+8}return n[(y=27920)>>2]=12,S=e,0}function Ye(A){var e=0,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(A|=0){t=A+-8|0,o=0|n[6985],l=t+(e=-8&(A=0|n[A+-4>>2]))|0;do{if(1&A)s=t,a=t;else{if(r=0|n[t>>2],!(3&A))return;if(i=r+e|0,(a=t+(0-r)|0)>>>0>>0)return;if((0|n[6986])==(0|a)){if(3&~(e=0|n[(A=l+4|0)>>2])){s=a,e=i;break}return n[6983]=i,n[A>>2]=-2&e,n[a+4>>2]=1|i,void(n[a+i>>2]=i)}if(t=r>>>3,r>>>0<256){if(A=0|n[a+8>>2],(0|(e=0|n[a+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=e,n[e+8>>2]=A,s=a,e=i;break}o=0|n[a+24>>2],A=0|n[a+12>>2];do{if((0|A)==(0|a)){if(A=0|n[(t=4+(e=a+16|0)|0)>>2])e=t;else if(!(A=0|n[e>>2])){A=0;break}for(;;)if(t=0|n[(r=A+20|0)>>2])A=t,e=r;else{if(!(t=0|n[(r=A+16|0)>>2]))break;A=t,e=r}n[e>>2]=0}else s=0|n[a+8>>2],n[s+12>>2]=A,n[A+8>>2]=s}while(0);if(o){if(e=0|n[a+28>>2],(0|n[(t=28228+(e<<2)|0)>>2])==(0|a)){if(n[t>>2]=A,!A){n[6982]=n[6982]&~(1<>2])==(0|a)?s:o+20)>>2]=A,!A){s=a,e=i;break}n[A+24>>2]=o,0|(t=0|n[(e=a+16|0)>>2])&&(n[A+16>>2]=t,n[t+24>>2]=A),(e=0|n[e+4>>2])?(n[A+20>>2]=e,n[e+24>>2]=A,s=a,e=i):(s=a,e=i)}else s=a,e=i}}while(0);if(!(a>>>0>=l>>>0)&&1&(r=0|n[(A=l+4|0)>>2])){if(2&r)n[A>>2]=-2&r,n[s+4>>2]=1|e,n[a+e>>2]=e,o=e;else{if((0|n[6987])==(0|l)){if(l=(0|n[6984])+e|0,n[6984]=l,n[6987]=s,n[s+4>>2]=1|l,(0|s)!=(0|n[6986]))return;return n[6986]=0,void(n[6983]=0)}if((0|n[6986])==(0|l))return l=(0|n[6983])+e|0,n[6983]=l,n[6986]=a,n[s+4>>2]=1|l,void(n[a+l>>2]=l);o=(-8&r)+e|0,t=r>>>3;do{if(r>>>0<256){if(e=0|n[l+8>>2],(0|(A=0|n[l+12>>2]))==(0|e)){n[6981]=n[6981]&~(1<>2]=A,n[A+8>>2]=e;break}i=0|n[l+24>>2],A=0|n[l+12>>2];do{if((0|A)==(0|l)){if(A=0|n[(t=4+(e=l+16|0)|0)>>2])e=t;else if(!(A=0|n[e>>2])){t=0;break}for(;;)if(t=0|n[(r=A+20|0)>>2])A=t,e=r;else{if(!(t=0|n[(r=A+16|0)>>2]))break;A=t,e=r}n[e>>2]=0,t=A}else t=0|n[l+8>>2],n[t+12>>2]=A,n[A+8>>2]=t,t=A}while(0);if(0|i){if(A=0|n[l+28>>2],(0|n[(e=28228+(A<<2)|0)>>2])==(0|l)){if(n[e>>2]=t,!t){n[6982]=n[6982]&~(1<>2])==(0|l)?r:i+20)>>2]=t,!t)break;n[t+24>>2]=i,0|(e=0|n[(A=l+16|0)>>2])&&(n[t+16>>2]=e,n[e+24>>2]=t),0|(A=0|n[A+4>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);if(n[s+4>>2]=1|o,n[a+o>>2]=o,(0|s)==(0|n[6986]))return void(n[6983]=o)}if(A=o>>>3,o>>>0<256)return t=27964+(A<<1<<2)|0,(e=0|n[6981])&(A=1<>2]:(n[6981]=e|A,A=t,e=t+8|0),n[e>>2]=s,n[A+12>>2]=s,n[s+8>>2]=A,void(n[s+12>>2]=t);A=28228+((r=(A=o>>>8)?o>>>0>16777215?31:o>>>(7+(r=14-((i=(520192+(l=A<<(a=(A+1048320|0)>>>16&8))|0)>>>16&4)|a|(r=(245760+(l<<=i)|0)>>>16&2))+(l<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[s+28>>2]=r,n[s+20>>2]=0,n[s+16>>2]=0,e=0|n[6982],t=1<>2];e:do{if((-8&n[A+4>>2])!=(0|o)){for(r=o<<(31==(0|r)?0:25-(r>>>1)|0);e=0|n[(t=A+16+(r>>>31<<2)|0)>>2];){if((-8&n[e+4>>2])==(0|o)){A=e;break e}r<<=1,A=e}n[t>>2]=s,n[s+24>>2]=A,n[s+12>>2]=s,n[s+8>>2]=s;break A}}while(0);l=0|n[(a=A+8|0)>>2],n[l+12>>2]=s,n[a>>2]=s,n[s+8>>2]=l,n[s+12>>2]=A,n[s+24>>2]=0}else n[6982]=e|t,n[A>>2]=s,n[s+24>>2]=A,n[s+12>>2]=s,n[s+8>>2]=s}while(0);if(l=(0|n[6989])-1|0,n[6989]=l,!(0|l)){for(A=28380;A=0|n[A>>2];)A=A+8|0;n[6989]=-1}}}}function We(A,e){e|=0;var t=0;return(A|=0)?(t=0|w(e,A),(e|A)>>>0>65535&&(t=((t>>>0)/(A>>>0)|0)==(0|e)?t:-1)):t=0,(A=0|Ue(t))&&3&n[A+-4>>2]?(lt(0|A,0,0|t),0|A):0|A}function Ve(A,e,t,r){return 0|(C((e|=0)+(r|=0)+((t=(A|=0)+(t|=0)>>>0)>>>0>>0|0)>>>0|0),t)}function Ze(A,e,t,r){return 0|(C(0|(r=(e|=0)-(r|=0)-((t|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-t>>>0)}function Ke(A){return 0|((A|=0)?31-(0|k(A^A-1)):32)}function Je(A,e,t,r,o){o|=0;var i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(u=A|=0,a=t|=0,s=d=r|=0,!(c=l=e|=0))return i=!!(0|o),s?i?(n[o>>2]=0|A,n[o+4>>2]=0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(d=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=f=i+1|0,A=u>>>(f>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(f>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(f=32-s|0)-1>>31&c>>>((g=s-32|0)>>>0)|(c<>>(s>>>0))&(e=g>>31),e&=c>>>(s>>>0),i=u<<(h=64-s|0)&(l=f>>31),s=(c<>>(g>>>0))&l|u<>31;break}return 0|o&&(n[o>>2]=i&u,n[o+4>>2]=0),1==(0|a)?(h=0|A,0|(C(0|(g=l|0&e)),h)):(g=c>>>((h=0|Ke(0|a))>>>0)|0,h=c<<32-h|u>>>(h>>>0),0|(C(0|g),h))}if(i)return 0|o&&(n[o>>2]=(c>>>0)%(a>>>0),n[o+4>>2]=0),h=(c>>>0)/(a>>>0)>>>0,0|(C(0|(g=0)),h);if(!u)return 0|o&&(n[o>>2]=0,n[o+4>>2]=(c>>>0)%(s>>>0)),h=(c>>>0)/(s>>>0)>>>0,0|(C(0|(g=0)),h);if(!((i=s-1|0)&s))return 0|o&&(n[o>>2]=0|A,n[o+4>>2]=i&c|0&e),g=0,h=c>>>((0|Ke(0|s))>>>0),0|(C(0|g),h);if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=30){a=e=i+1|0,A=c<<(s=31-i|0)|u>>>(e>>>0),e=c>>>(e>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,h=0,0|(C(0|(g=0)),h)):(h=0,0|(C(0|(g=0)),h))}while(0);if(a){c=0|Ve(0|(f=0|t),0|(u=d|0&r),-1,-1),t=0|B(),l=s,s=0;do{r=l,l=i>>>31|l<<1,i=s|i<<1,Ze(0|c,0|t,0|(r=A<<1|r>>>31),0|(d=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|d,g&f|0,(((0|h)<0?-1:0)>>31|((0|h)<0?-1:0)<<1)&u),e=0|B(),a=a-1|0}while(0|a);c=l,l=0}else c=s,l=0,s=0;return a=0,0|o&&(n[o>>2]=A,n[o+4>>2]=e),h=i<<1&-2|s,0|(C(0|(g=(0|i)>>>31|(c|a)<<1|l)),h)}function Xe(A,e,t,r){var n,o,i,a,s;return t|=0,o=(r|=0)>>31|((0|r)<0?-1:0)<<1,n=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,i=0|Ze((s=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(a=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|s,0|a),A=o^s,e=n^a,0|Ze((0|Je(i,0|B(),0|Ze(o^t|0,n^r|0,0|o,0|n),0|B(),0))^A,(0|B())^e,0|A,0|e)}function qe(A,e,t,r){var n,o;return e|=0,r|=0,t=0|function(A,e){var t,r,n,o=0;return A=((t=0|w(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|w(o,r=A>>>16))|0,e=0|w(o=e>>>16,n),0|(C((A>>>16)+(0|w(o,r))+(((65535&A)+e|0)>>>16)|0),A+e<<16|65535&t)}(n=A|=0,o=t|=0),A=0|B(),0|(C((0|w(e,o))+(0|w(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=S,S=S+16|0,s=0|o,c=(r|=0)>>31|((0|r)<0?-1:0)<<1,l=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,Je(A=0|Ze((a=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(i=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|a,0|i),e=0|B(),0|Ze(c^t|0,l^r|0,0|c,0|l),0|B(),s),r=0|Ze(n[s>>2]^a|0,n[s+4>>2]^i|0,0|a,0|i),t=0|B(),S=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=S,S=S+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),S=i,0|(C(0|n[o+4>>2]),n[o>>2])}function et(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>t|0),A>>>t|(e&(1<>t-32)}function tt(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>>t|0),A>>>t|(e&(1<>>t-32|0)}function rt(A,e,t){return A|=0,(0|(t|=0))<32?(C((e|=0)<>>32-t),A<=0?+s(A+.5):+v(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return Q(0|A,0|e,0|t),0|A;if(i=0|A,o=A+t|0,(3&A)==(3&e)){for(;3&A;){if(!t)return 0|i;r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0,t=t-1|0}for(a=(t=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],n[A+12>>2]=n[e+12>>2],n[A+16>>2]=n[e+16>>2],n[A+20>>2]=n[e+20>>2],n[A+24>>2]=n[e+24>>2],n[A+28>>2]=n[e+28>>2],n[A+32>>2]=n[e+32>>2],n[A+36>>2]=n[e+36>>2],n[A+40>>2]=n[e+40>>2],n[A+44>>2]=n[e+44>>2],n[A+48>>2]=n[e+48>>2],n[A+52>>2]=n[e+52>>2],n[A+56>>2]=n[e+56>>2],n[A+60>>2]=n[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|t);)n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}else for(t=o-4|0;(0|A)<(0|t);)r[0|A]=0|r[0|e],r[A+1|0]=0|r[e+1|0],r[A+2|0]=0|r[e+2|0],r[A+3|0]=0|r[e+3|0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|o);)r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0;return 0|i}function lt(A,e,t){e|=0;var o,i=0,a=0,s=0;if(o=(A|=0)+(t|=0)|0,e&=255,(0|t)>=67){for(;3&A;)r[0|A]=e,A=A+1|0;for(s=e|e<<8|e<<16|e<<24,a=(i=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=s,n[A+4>>2]=s,n[A+8>>2]=s,n[A+12>>2]=s,n[A+16>>2]=s,n[A+20>>2]=s,n[A+24>>2]=s,n[A+28>>2]=s,n[A+32>>2]=s,n[A+36>>2]=s,n[A+40>>2]=s,n[A+44>>2]=s,n[A+48>>2]=s,n[A+52>>2]=s,n[A+56>>2]=s,n[A+60>>2]=s,A=A+64|0;for(;(0|A)<(0|i);)n[A>>2]=s,A=A+4|0}for(;(0|A)<(0|o);)r[0|A]=e,A=A+1|0;return o-t|0}function ct(A){return(A=+A)>=0?+s(A+.5):+v(A-.5)}function ut(A){var e,t,r;return A|=0,r=0|E(),(0|A)>0&(0|(e=(t=0|n[a>>2])+A|0))<(0|t)|(0|e)<0?(N(0|e),D(12),-1):(0|e)>(0|r)&&!(0|j(0|e))?(D(12),-1):(n[a>>2]=e,0|t)}return{___divdi3:Xe,___muldi3:qe,___remdi3:$e,___uremdi3:At,_areNeighborCells:function(A,e,t,r,o){o|=0;var i,a,s,l=0,c=0,u=0,f=0;if(s=S,S=S+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return S=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,S=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,f=0|tt(0|t,0|r,52),B(),(0|c)!=(15&f))return S=s,12;if(l=c+-1|0,c>>>0>1){RA(A,e,l,a),RA(t,r,l,i),u=0|n[(f=a)>>2],f=0|n[f+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|f)==(0|n[i+4>>2])){l=0|tt(0|A,0|e,0|(c=3*(15^c)|0)),B(),l&=7,c=0|tt(0|t,0|r,0|c),B(),c&=7;do{if(!(0|l)|!(0|c))n[o>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|HA(u,f)){l=5;break}if((0|n[15536+(l<<2)>>2])!=(0|c)&&(0|n[15568+(l<<2)>>2])!=(0|c))break A;n[o>>2]=1,l=0}}while(0);return S=s,0|l}}while(0)}c=(l=a)+56|0;do{n[l>>2]=0,l=l+4|0}while((0|l)<(0|c));return F(A,e,1,a),l=(0|n[(e=a)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+8|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+16|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+24|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+32|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)||(0|n[(e=a+40|0)>>2])==(0|t)&&(0|n[e+4>>2])==(0|r)?1:1&((0|n[(l=a+48|0)>>2])==(0|t)?(0|n[l+4>>2])==(0|r):0),n[o>>2]=l,S=s,0},_bitshift64Ashr:et,_bitshift64Lshr:tt,_bitshift64Shl:rt,_calloc:We,_cellAreaKm2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475),0|A},_cellAreaM2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475*1e3*1e3),0|A},_cellAreaRads2:ue,_cellToBoundary:$A,_cellToCenterChild:GA,_cellToChildPos:function(A,e,t,r){t|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0;if(o=S,S=S+16|0,p=o,v=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return S=o,4;if((0|(v&=15))<(0|t))return S=o,12;if((0|v)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|v)>(0|t)){c=t;do{b=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,a|=b,l=0|B()|l}while((0|c)<(0|v));b=a}else b=a;else b=A,l=e;m=0|tt(0|b,0|l,45),B();A:do{if(0|z(127&m)){if(c=0|tt(0|b,0|l,52),B(),0|(c&=15))for(a=1;;){if(!(!((m=0|rt(7,0,3*(15-a|0)|0))&b)&!((0|B())&l))){u=33;break A}if(!(a>>>0>>0))break;a=a+1|0}if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(m=-15728641&e,h=v;;){if(g=h,(h=h+-1|0)>>>0>15|(0|v)<(0|h)){u=19;break}if((0|v)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|v)<(0|g))d=a;else{u=h;do{d=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,c=0|B()|c}while((0|u)<(0|v));d=a}else d=A,c=e;if(f=0|tt(0|d,0|c,45),B(),0|z(127&f)){f=0|tt(0|d,0|c,52),B(),f&=15;e:do{if(f)for(u=1;;){if(a=0|tt(0|d,0|c,3*(15-u|0)|0),B(),0|(a&=7))break e;if(!(u>>>0>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|tt(0|A,0|e,3*(15-g|0)|0),B(),7==(0|(c&=7))){i=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){i=5,u=42;break}if(0|(d=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=v-g|0,((0|u)<0)<<31>>31),f=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|f,5,0)),0|B(),-5,-1),a=0|Ve(0|(a=0|Xe(0|a,0|B(),6,0)),0|B(),1,0),c=0|B()):(a=u,c=f),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|f,0|(g=d+-1|0),((0|g)<0)<<31>>31)),0|B()),f=0|Ve(0|g,0|(d=0|B()),0|n[(f=r)>>2],0|n[f+4>>2]),d=0|B(),n[(g=r)>>2]=f,n[g+4>>2]=d),(0|h)<=(0|t)){u=37;break}}if(19==(0|u))M(27795,27122,1367,27158);else{if(37==(0|u)){i=0|n[(s=r)+4>>2],s=0|n[s>>2];break}if(42==(0|u))return S=o,0|i}}else i=0,s=0}else u=33}while(0);A:do{if(33==(0|u)){if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(a=v;;){if(i=0|tt(0|A,0|e,3*(15-a|0)|0),B(),7==(0|(i&=7))){i=5;break}if(i=0|qe(0|(s=0|pe(7,0,s=v-a|0,((0|s)<0)<<31>>31)),0|B(),0|i,0),s=0|B(),s=0|Ve(0|n[(m=r)>>2],0|n[m+4>>2],0|i,0|s),i=0|B(),n[(m=r)>>2]=s,n[m+4>>2]=i,(0|(a=a+-1|0))<=(0|t))break A}return S=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,v,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(v=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[v>>2])>>>0>s>>>0:0))?(S=o,0|(v=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=S,S=S+16|0,ee(o=i,A|=0,e|=0,t|=0),!(0|(A=0|n[(e=o)>>2]))&!(0|(e=0|n[e+4>>2])))return S=i,0;a=0,t=0;do{n[(s=r+(a<<3)|0)>>2]=A,n[s+4>>2]=e,a=0|Ve(0|a,0|t,1,0),t=0|B(),re(o),A=0|n[(s=o)>>2],e=0|n[s+4>>2]}while(!(!(0|A)&!(0|e)));return S=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=S,S=S+16|0,a=s,(o|=0)?A=15:(A=0|me(A,e|=0,t|=0,r|=0,a))||(function(A,e){var t;e|=0,t=0|n[8+(A|=0)>>2],n[e>>2]=(0|n[A>>2])-t,n[e+4>>2]=(0|n[A+4>>2])-t}(a,i),A=0),S=s,0|A},_cellToParent:RA,_cellToVertex:Pe,_cellToVertexes:function(A,e,t){t|=0;var r,o=0,i=0;return i=!(0|HA(A|=0,e|=0)),r=!(0|(o=0|Pe(A,e,0,t))),i?r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||(o=0|Pe(A,e,4,t+32|0))?0|(i=o):0|Pe(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||0|(o=0|Pe(A,e,4,t+32|0))?0|(i=o):(n[(i=t+40|0)>>2]=0,n[i+4>>2]=0,0|(i=0)):0|(i=o)},_cellsToDirectedEdge:function(A,e,t,r,o){return o|=0,7==(0|(t=0|_(A|=0,e|=0,t|=0,r|=0)))?0|(o=11):(r=0|rt(0|t,0,56),e=-2130706433&e|B()|268435456,n[o>>2]=A|r,n[o+4>>2]=e,0|(o=0))},_cellsToLinkedMultiPolygon:function(A,e,t){t|=0;var r,i,a,s=0;if(a=S,S=S+32|0,r=a,0|(A=0|function(A,e,t){A|=0,t|=0;var r,o,i=0,a=0,s=0,l=0,c=0,u=0;if(o=S,S=S+176|0,r=o,(0|(e|=0))<1)return Le(t,0,0),S=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Le(t,(0|e)>6?e:6,15&c),c=0;!(0|(i=0|$A(0|n[(i=A+(c<<3)|0)>>2],0|n[i+4>>2],r)));){if((0|(i=0|n[r>>2]))>0){l=0;do{s=r+8+(l<<4)|0,(a=0|ze(t,i=r+8+((0|(l=l+1|0))%(0|i)<<4)|0,s))?_e(t,a):He(t,s,i),i=0|n[r>>2]}while((0|l)<(0|i))}if((0|(c=c+1|0))>=(0|e)){i=0,u=13;break}}return 13==(0|u)?(S=o,0|i):(Ie(t),S=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return S=a,0|A;if(n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,0|(A=0|Re(i)))do{e=0|fe(t);do{de(e,A),s=A+16|0,n[r>>2]=n[s>>2],n[r+4>>2]=n[s+4>>2],n[r+8>>2]=n[s+8>>2],n[r+12>>2]=n[s+12>>2],_e(i,A),A=0|Ge(i,r)}while(0|A);A=0|Re(i)}while(0|A);return Ie(i),(A=0|function(A){var e,t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,B=0,D=0,E=0,Q=0,j=0,N=0,S=0,F=0,P=0,T=0,L=0;if(0|n[(s=(A|=0)+8|0)>>2])return 1;if(!(a=0|n[A>>2]))return 0;r=a,i=0;do{i=i+1|0,r=0|n[r+8>>2]}while(0|r);if(i>>>0<2)return 0;(t=0|Ue(i<<2))||M(27396,27235,317,27415),(e=0|Ue(i<<5))||M(27437,27235,321,27415),n[A>>2]=0,n[(E=A+4|0)>>2]=0,n[s>>2]=0,i=0,P=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(d=+o[u+8>>3],r=u,u=0|n[u+16>>2],f=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(d-f))>3.141592653589793){L=14;break}c+=(f-d)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|L)){L=0,c=0,r=h;do{B=+o[r+8>>3],S=0|n[(F=r+16|0)>>2],C=+o[(S=0|S?S:h)+8>>3],c+=(+o[r>>3]+ +o[S>>3])*((C<0?C+6.283185307179586:C)-(B<0?B+6.283185307179586:B)),r=0|n[(0|r?F:a)>>2]}while(0|r)}c>0?(n[t+(P<<2)>>2]=a,P=P+1|0,s=D,r=m):L=19}else L=19;if(19==(0|L)){L=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){L=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){L=21;break A}if(!(i=0|We(1,12))){L=23;break A}n[r>>2]=i,s=i+4|0,u=i,r=m}while(0);if(n[u>>2]=a,n[s>>2]=a,u=e+(D<<5)|0,g=0|n[a>>2]){for(o[(h=e+(D<<5)+8|0)>>3]=17976931348623157e292,o[(m=e+(D<<5)+24|0)>>3]=17976931348623157e292,o[u>>3]=-17976931348623157e292,o[(b=e+(D<<5)+16|0)>>3]=-17976931348623157e292,y=17976931348623157e292,k=-17976931348623157e292,s=0,p=g,d=17976931348623157e292,w=17976931348623157e292,x=-17976931348623157e292,f=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((v=!(0|p))?g:p)+8>>3],c>3]=c,d=c),B>3]=B,w=B),c>x?o[u>>3]=c:c=x,B>f&&(o[b>>3]=B,f=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!v;)x=c;s&&(o[b>>3]=k,o[m>>3]=y)}else n[u>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,n[u+12>>2]=0,n[u+16>>2]=0,n[u+20>>2]=0,n[u+24>>2]=0,n[u+28>>2]=0;s=D+1|0}if(a=0|n[(F=a+8|0)>>2],n[F>>2]=0,!a){L=45;break}D=s,m=r}if(21==(0|L))M(27213,27235,35,27247);else if(23==(0|L))M(27267,27235,37,27247);else if(27==(0|L))M(27310,27235,61,27333);else if(45==(0|L)){A:do{if((0|P)>0){for(F=!(0|s),N=s<<2,S=!(0|A),j=0,r=0;;){if(Q=0|n[t+(j<<2)>>2],F)L=73;else{if(!(D=0|Ue(N))){L=50;break}if(!(E=0|Ue(N))){L=52;break}e:do{if(S)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[Q>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,v=i+1|0):v=i,u=0|n[u+8>>2];)s=s+1|0,i=v;if((0|v)>0)if(a=0|n[D>>2],1==(0|v))i=a;else for(b=0,p=-1,i=a,m=a;;){for(g=0|n[m>>2],a=0,u=0;h=(0|(s=0|n[n[D+(u<<2)>>2]>>2]))==(0|g)?a:a+(1&he(s,0|n[E+(u<<2)>>2],0|n[g>>2]))|0,(0|(u=u+1|0))!=(0|v);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|v))break e;b=a,p=s?h:p,m=0|n[D+(a<<2)>>2]}else i=0}}while(0);if(Ye(D),Ye(E),i){if(a=0|n[(s=i+4|0)>>2])i=a+8|0;else if(0|n[i>>2]){L=70;break}n[i>>2]=Q,n[s>>2]=Q}else L=73}if(73==(0|L)){if(L=0,0|(r=0|n[Q>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(Q),r=1}if((0|(j=j+1|0))>=(0|P)){T=r;break A}}50==(0|L)?M(27452,27235,249,27471):52==(0|L)?M(27490,27235,252,27471):70==(0|L)&&M(27310,27235,61,27333)}else T=0}while(0);return Ye(t),Ye(e),0|T}return 0}(t))?(ge(t),S=a,0|(s=A)):(S=a,0|(s=0))},_childPosToCell:function(A,e,t,r,o,i){A|=0,e|=0,i|=0;var a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=S,S=S+16|0,s=a,(o|=0)>>>0>15)return S=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return S=a,12;if(0|_A(t,r,o,s)&&M(27795,27122,1327,27173),!(((0|e)>-1|-1==(0|e)&A>>>0>4294967295)&((0|(u=0|n[(f=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[f>>2])>>>0>A>>>0:0))))return S=a,2;f=o-l|0,o=0|rt(0|o,0,52),c=B()|-15728641&r,n[(u=i)>>2]=o|t,n[u+4>>2]=c,u=0|tt(0|t,0|r,45),B();A:do{if(0|z(127&u)){if(0|l)for(s=1;;){if(!(!((u=0|rt(7,0,3*(15-s|0)|0))&t)&!((0|B())&r)))break A;if(!(s>>>0>>0))break;s=s+1|0}if((0|f)<1)return S=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=f-c|0,((0|l)<0)<<31>>31),t=0|B();do{if(s){if(s=0|Xe(0|(s=0|Ve(0|(s=0|qe(0|l,0|t,5,0)),0|B(),-5,-1)),0|B(),6,0),(0|e)>(0|(o=0|B()))|(0|e)==(0|o)&A>>>0>s>>>0){e=0|Ze(0|(e=0|Ve(0|A,0|e,-1,-1)),0|B(),0|s,0|o),s=0|B(),h=0|n[(d=i)>>2],d=0|n[d+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),d&=~B(),m=0|rt(0|(o=0|Ve(0|(r=0|Xe(0|e,0|s,0|l,0|t)),0|(A=0|B()),2,0)),0|B(),0|m),d=0|B()|d,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=d,A=0|Ze(0|e,0|s,0|(A=0|qe(0|r,0|A,0|l,0|t)),0|B()),s=0,e=0|B();break}g=0|n[(m=i)>>2],m=0|n[m+4>>2],h=0|rt(7,0,3*(u+r|0)|0),m&=~B(),n[(s=i)>>2]=g&~h,n[s+4>>2]=m,s=1;break}o=0|n[(g=i)>>2],g=0|n[g+4>>2],d=0|rt(7,0,0|(r=3*(u+r|0)|0)),g&=~B(),r=0|rt(0|(m=0|Xe(0|A,0|e,0|l,0|t)),0|(s=0|B()),0|r),g=0|B()|g,n[(h=i)>>2]=r|o&~d,n[h+4>>2]=g,A=0|Ze(0|A,0|e,0|(s=0|qe(0|m,0|s,0|l,0|t)),0|B()),s=0,e=0|B()}while(0);if(!((0|f)>(0|c))){e=0;break}r=~c,c=c+1|0}return S=a,0|e}}while(0);if((0|f)<1)return S=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=f-s|0,((0|h)<0)<<31>>31),m=0|B(),t=0|n[(c=i)>>2],c=0|n[c+4>>2],r=0|rt(7,0,0|(l=3*(o-s|0)|0)),c&=~B(),l=0|rt(0|(d=0|Xe(0|A,0|e,0|h,0|m)),0|(g=0|B()),0|l),c=0|B()|c,n[(u=i)>>2]=l|t&~r,n[u+4>>2]=c,A=0|Ze(0|A,0|e,0|(m=0|qe(0|d,0|g,0|h,0|m)),0|B()),e=0|B(),(0|f)<=(0|s)){e=0;break}s=s+1|0}return S=a,0|e},_compactCells:function(A,e,t,r){e|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,D=0,E=0,Q=0,j=0,N=0,S=0;if(!(0|(t|=0))&!(0|(r|=0)))return 0;if(a=0|n[(i=A|=0)>>2],!0&!(15728640&(i=0|n[i+4>>2]))){if(!((0|r)>0|!(0|r)&t>>>0>0))return 0;if(n[(S=e)>>2]=a,n[S+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{N=0|n[4+(j=A+(i<<3)|0)>>2],n[(S=e+(i<<3)|0)>>2]=n[j>>2],n[S+4>>2]=N,i=0|Ve(0|i,0|a,1,0),a=0|B()}while((0|a)<(0|r)|(0|a)==(0|r)&i>>>0>>0);return 0}if(!(N=0|Ue(o=t<<3)))return 13;if(st(0|N,0|A,0|o),!(j=0|We(t,8)))return Ye(N),13;A:for(;;){E=0|tt(0|(u=0|n[(i=N)>>2]),0|(i=0|n[i+4>>2]),52),B(),Q=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(w=0|rt(0|Q,0,52),x=0|B(),Q>>>0>15){if(!(!(0|u)&!(0|i))){S=16;break A}for(a=0,A=0;;){if(a=0|Ve(0|a,0|A,1,0),!((0|(A=0|B()))<(0|r)|(0|A)==(0|r)&a>>>0>>0))break e;if(!(!(0|(k=0|n[(s=N+(a<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))){i=s,S=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){S=21;break A}if(f=0|tt(0|l,0|A,52),B(),(0|(f&=15))<(0|Q)){i=12,S=27;break A}if((0|f)!=(0|Q)&&(l|=w,A=-15728641&A|x,f>>>0>=E>>>0)){c=Q;do{k=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,l|=k,A=0|B()|A}while(c>>>0>>0)}if(g=0|At(0|l,0|A,0|t,0|r),h=0|B(),!(!(0|(d=0|n[(f=c=j+(g<<3)|0)>>2]))&!(0|(f=0|n[f+4>>2])))){p=0,v=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&v>>>0>t>>>0){S=31;break A}if((0|d)==(0|l)&(-117440513&f)==(0|A)){m=0|tt(0|d,0|f,56),B(),b=1+(m&=7)|0,k=0|tt(0|d,0|f,45),B();t:do{if(0|z(127&k)){if(d=0|tt(0|d,0|f,52),B(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((k=0|rt(7,0,3*(15-f|0)|0))&l)&!((0|B())&A))){f=7;break t}if(!(f>>>0>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){S=41;break A}k=0|rt(0|b,0,56),A=B()|-117440513&A,n[(y=c)>>2]=0,n[y+4>>2]=0,l|=k}else g=0|$e(0|(g=0|Ve(0|g,0|h,1,0)),0|B(),0|t,0|r),h=0|B();v=0|Ve(0|v,0|p,1,0),p=0|B(),d=0|n[(f=c=j+(g<<3)|0)>>2],f=0|n[f+4>>2]}while(!(!(0|d)&!(0|f)))}n[(k=c)>>2]=l,n[k+4>>2]=A}if(a=0|Ve(0|a,0|s,1,0),!((0|(s=0|B()))<(0|r)|(0|s)==(0|r)&a>>>0>>0))break e;l=0|n[(A=N+(a<<3)|0)>>2],A=0|n[A+4>>2]}}}while(0);if(k=0|Ve(0|t,0|r,5,0),(y=0|B())>>>0<0|!(0|y)&k>>>0<11){S=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){S=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=f=j+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{d=0|tt(0|a,0|s,56),B(),l=1+(d&=7)|0,g=-117440513&s,y=0|tt(0|a,0|s,45),B();e:do{if(0|z(127&y)){if(h=0|tt(0|a,0|s,52),B(),0|(h&=15))for(c=1;;){if(!(!(a&(y=0|rt(7,0,3*(15-c|0)|0)))&!(g&(0|B()))))break e;if(!(c>>>0>>0))break;c=c+1|0}a|=s=0|rt(0|l,0,56),s=0|B()|g,n[(l=f)>>2]=a,n[l+4>>2]=s,l=d+2|0}}while(0);7==(0|l)?(n[(y=k+(A<<3)|0)>>2]=a,n[y+4>>2]=-117440513&s,A=0|Ve(0|A,0|m,1,0),y=0|B()):y=m}if(b=0|Ve(0|b,0|p,1,0),!((0|(p=0|B()))<(0|r)|(0|p)==(0|r)&b>>>0>>0))break;m=y}if(C){if(v=Q>>>0>15,w=0|rt(0|Q,0,52),x=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(Q=e+(a<<3)|0)>>2]=u,n[Q+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()),l=0|Ve(0|l,0|s,1,0),(0|(s=0|B()))<(0|r)|(0|s)==(0|r)&l>>>0>>0;)u=0|n[(i=N+(l<<3)|0)>>2],i=0|n[i+4>>2];i=y;break}for(a=0,c=0,s=0,l=0;;){do{if(!(!(0|u)&!(0|i))){if(h=0|tt(0|u,0|i,52),B(),v|(0|(h&=15))<(0|Q)){S=80;break A}if((0|h)!=(0|Q)){if(f=u|w,d=-15728641&i|x,h>>>0>=E>>>0){g=Q;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,f|=D,d=0|B()|d}while(g>>>0>>0)}}else f=u,d=i;m=0|At(0|f,0|d,0|t,0|r),g=0,h=0,p=0|B();do{if((0|g)>(0|r)|(0|g)==(0|r)&h>>>0>t>>>0){S=81;break A}if((-117440513&(b=0|n[4+(D=j+(m<<3)|0)>>2]))==(0|d)&&(0|n[D>>2])==(0|f)){S=65;break}m=0|$e(0|(D=0|Ve(0|m,0|p,1,0)),0|B(),0|t,0|r),p=0|B(),h=0|Ve(0|h,0|g,1,0),g=0|B(),D=j+(m<<3)|0}while((0|n[D>>2])!=(0|f)||(0|n[D+4>>2])!=(0|d));if(65==(0|S)&&(S=0,!0&100663296==(117440512&b)))break;n[(D=e+(a<<3)|0)>>2]=u,n[D+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()}}while(0);if(s=0|Ve(0|s,0|l,1,0),!((0|(l=0|B()))<(0|r)|(0|l)==(0|r)&s>>>0>>0))break;u=0|n[(i=N+(s<<3)|0)>>2],i=0|n[i+4>>2]}i=y}else a=0,i=y}else a=0,A=0,i=0}while(0);if(lt(0|j,0,0|o),st(0|N,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){S=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|S))!0&!(117440512&i)?(i=4,S=27):S=21;else if(31==(0|S))M(27795,27122,620,27132);else{if(41==(0|S))return Ye(N),Ye(j),10;if(48==(0|S))return Ye(N),Ye(j),13;80==(0|S)?M(27795,27122,711,27132):81==(0|S)?M(27795,27122,723,27132):85==(0|S)&&(st(0|e,0|N,t<<3),S=89)}return 21==(0|S)?(Ye(N),Ye(j),0|(S=5)):27==(0|S)?(Ye(N),Ye(j),0|(S=i)):89==(0|S)?(Ye(N),Ye(j),0|(S=0)):0},_constructCell:function(A,e,t,o){t|=0,o|=0;var i=0,a=0,s=0,l=0,c=0,u=0;if((A|=0)>>>0>15)return 4;if((e|=0)>>>0>121)return 17;s=0|rt(0|A,0,52),i=0|B(),l=0|rt(0|e,0,45),i=0|i|B()|134225919;A:do{if((0|A)>=1){for(l=1,s=!!(0|r[20528+e|0]),a=-1;;){if((e=0|n[t+(l+-1<<2)>>2])>>>0>6){i=18,e=10;break}if(!(!(0|e)|1^s)){if(1==(0|e)){i=19,e=10;break}s=0}if(c=0|rt(7,0,0|(u=3*(15-l|0)|0)),i&=~B(),a=(e=0|rt(0|e,((0|e)<0)<<31>>31,0|u))|a&~c,i=0|B()|i,!((0|l)<(0|A)))break A;l=l+1|0}if(10==(0|e))return 0|i}else a=-1}while(0);return n[(u=o)>>2]=a,n[u+4>>2]=i,0},_destroyLinkedMultiPolygon:ge,_directedEdgeToBoundary:DA,_directedEdgeToCells:function(A,e,t){A|=0;var r,o,i,a=0;return r=S,S=S+16|0,a=r,!0&268435456==(2013265920&(e|=0))?(o=-2130706433&e|134217728,n[(i=t|=0)>>2]=A,n[i+4>>2]=o,n[a>>2]=0,e=0|tt(0|A,0|e,56),B(),a=0|I(A,o,7&e,a,t+8|0),S=r,0|a):(S=r,0|(a=6))},_edgeLengthKm:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return l=A,s=+o[t>>3],s*=6371.007180918475,o[t>>3]=s,S=r,0|l;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return l=0,s=0,s*=6371.007180918475,o[t>>3]=s,S=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,o[t>>3]=h,S=r,0|l},_edgeLengthM:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return l=A,s=+o[t>>3],s*=6371.007180918475,s*=1e3,o[t>>3]=s,S=r,0|l;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return l=0,s=0,s*=6371.007180918475,s*=1e3,o[t>>3]=s,S=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,h*=1e3,o[t>>3]=h,S=r,0|l},_edgeLengthRads:function(A,e,t){t|=0;var r,i=0,a=0,s=0,l=0,u=0,g=0,h=0;if(r=S,S=S+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return S=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return S=r,0;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+i)*+f(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,S=r,0},_emscripten_replace_memory:function(A){return r=new Int8Array(A),n=new Int32Array(A),o=new Float64Array(A),t=A,!0},_free:Ye,_getBaseCellNumber:TA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=S,S=S+16|0,n[(i=r)>>2]=0,!0&268435456==(2013265920&e)?(o=0|tt(0|A,0|e,56),B(),i=0|I(A,-2130706433&e|134217728,7&o,i,t),S=r,0|i):(S=r,0|(i=6))},_getDirectedEdgeOrigin:function(A,e,t){return A|=0,t|=0,!0&268435456==(2013265920&(e|=0))?(n[t>>2]=A,n[t+4>>2]=-2130706433&e|134217728,0|(t=0)):0|(t=6)},_getHexagonAreaAvgKm2:se,_getHexagonAreaAvgM2:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20784+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgKm:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20912+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgM:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[21040+(A<<3)>>3],0|(e=0))},_getIcosahedronFaces:function A(e,t,r){r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;o=S,S=S+128|0,f=o+112|0,s=o+96|0,d=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[f>>2]=c,l=0|tt(0|e,0|t,45),B(),l&=127;A:do{if(0|z(l)){if(0|c)for(i=1;;){if(!(!((u=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){a=0;break A}if(!(i>>>0>>0))break;i=i+1|0}if(!(1&a))return u=0|rt(c+1|0,0,52),d=B()|-15728641&t,d=0|A((u|e)&~(f=0|rt(7,0,3*(14-c|0)|0)),d&~B(),r),S=o,0|d;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(jA(s,f,d),u=5):(PA(s,f,d),u=6);A:do{if(0|z(l))if(c)for(i=1;;){if(!(!((l=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){e=2;break A}if(!(i>>>0>>0)){e=5;break}i=i+1|0}else e=5;else e=2}while(0);lt(0|r,-1,e<<2);A:do{if(a)for(s=0;;){if(SA(l=d+(s<<4)|0,0|n[f>>2]),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}else for(s=0;;){if(NA(l=d+(s<<4)|0,0|n[f>>2],0,1),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}}while(0)}return S=o,0|i},_getIndexDigit:function(A,e,t,r){return r|=0,((t|=0)-1|0)>>>0>14?0|(r=4):(t=0|tt(0|(A|=0),0|(e|=0),3*(15-t|0)|0),B(),n[r>>2]=7&t,0|(r=0))},_getNumCells:le,_getPentagons:Ae,_getRes0Cells:function(A){A|=0;var e=0,t=0,r=0;e=0;do{rt(0|e,0,45),r=134225919|B(),n[(t=A+(e<<3)|0)>>2]=-1,n[t+4>>2]=r,e=e+1|0}while(122!=(0|e));return 0},_getResolution:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),15&e},_greatCircleDistanceKm:ae,_greatCircleDistanceM:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:F,_gridDiskDistances:P,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=S,S=S+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(S=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(S=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,S=a,0|(l=0))},_gridPathCells:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,D=0,E=0;if(a=S,S=S+48|0,c=a+12|0,D=a,!(s=0|me(A|=0,e|=0,A,e,i=a+24|0))&&!(s=0|me(A,e,t,r,c))){C=((0|(k=0|kA(i,c)))<0)<<31>>31,n[i>>2]=0,n[i+4>>2]=0,n[i+8>>2]=0,n[c>>2]=0,n[c+4>>2]=0,n[c+8>>2]=0,0|me(A,e,A,e,i)&&M(27795,27538,692,27747),0|me(A,e,t,r,c)&&M(27795,27538,697,27747),CA(i),CA(c),g=0|k?1/+(0|k):0,t=0|n[i>>2],v=g*+((0|n[c>>2])-t|0),r=0|n[(w=i+4|0)>>2],x=g*+((0|n[c+4>>2])-r|0),s=0|n[(y=i+8|0)>>2],g*=+((0|n[c+8>>2])-s|0),n[D>>2]=t,n[(h=D+4|0)>>2]=r,n[(m=D+8|0)>>2]=s;A:do{if((0|k)<0)s=0;else for(b=0,p=0;;){E=v*(f=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=x*f+ +(0|r),f=g*f+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+f),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),f=+l(+(+(0|s)-f));do{if(!(E>u&E>f)){if(d=0-t|0,u>f){r=d-s|0;break}r=c,s=d-c|0;break}t=0-(c+s)|0,r=c}while(0);if(n[D>>2]=t,n[h>>2]=r,n[m>>2]=s,BA(D),0|(s=0|be(A,e,D,o+(p<<3)|0)))break A;if(!((0|b)<(0|C)|(0|b)==(0|C)&p>>>0>>0)){s=0;break A}t=0|Ve(0|p,0|b,1,0),b=r=0|B(),p=t,t=0|n[i>>2],r=0|n[w>>2],s=0|n[y>>2]}}while(0);return S=a,0|s}return S=a,0|s},_gridPathCellsSize:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a=0,s=0,l=0;return i=S,S=S+32|0,l=i,(a=0|me(A|=0,e|=0,A,e,s=i+12|0))||(a=0|me(A,e,t,r,l))?(S=i,0|(l=a)):(r=0|Ve(0|(r=0|kA(s,l)),((0|r)<0)<<31>>31,1,0),s=0|B(),n[(l=o)>>2]=r,n[l+4>>2]=s,S=i,0|(l=0))},_gridRing:function(A,e,t,r){return 0|R(A|=0,e|=0,t|=0,r|=0)?(lt(0|r,0,48*t|0),0|(r=0|function(A,e,t,r){A|=0,e|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;if(o=S,S=S+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,S=o,0;do{if((0|t)>=0){if((0|t)>13780509){if(0|(i=0|le(15,s)))break;i=0|n[(a=s)>>2],a=0|n[a+4>>2]}else f=0|qe(0|t,0|(i=((0|t)<0)<<31>>31),3,0),a=0|B(),i=0|Ve(0|t,0|i,1,0),i=0|Ve(0|(i=0|qe(0|f,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(f=s)>>2]=i,n[f+4>>2]=a;if(u=0|We(i,8)){if(!(f=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|L(A,e,t,u,f,i,a,0))){Ye(u),Ye(f);break}if(e=0|n[s>>2],(0|(s=0|n[s+4>>2]))>0|!(0|s)&e>>>0>0){i=0,l=0,c=0;do{!(0|(a=0|n[(A=u+(l<<3)|0)>>2]))&!(0|(A=0|n[A+4>>2]))||(0|n[f+(l<<2)>>2])!=(0|t)||(n[(d=r+(i<<3)|0)>>2]=a,n[d+4>>2]=A,i=i+1|0),l=0|Ve(0|l,0|c,1,0),c=0|B()}while((0|c)<(0|s)|(0|c)==(0|s)&l>>>0>>0)}Ye(u),Ye(f),i=0}else i=13}else i=2}while(0);return S=o,0|i}(A,e,t,r))):0|(r=0)},_gridRingUnsafe:R,_i64Add:Ve,_i64Subtract:Ze,_isPentagon:HA,_isResClassIII:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),1&e},_isValidCell:LA,_isValidDirectedEdge:MA,_isValidIndex:function(A,e){A|=0;var t=0,n=0,o=0,i=0;if(!0&134217728==(-16777216&(e|=0))&&(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0<=121)&&!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())){if(!(0|r[20528+t|0]))return 1;if(!(0|A)&!(0|(t=8191&e)))return 1;if(i=0|nt(0|A,0|t),B(),(63-i|0)%3|0)return 1}return 0|MA(A,e)?0|(i=1):0|(i=1&!!(0|Te(A,e)))},_isValidVertex:Te,_latLngToCell:KA,_llvm_ctlz_i64:nt,_llvm_maxnum_f64:ot,_llvm_minnum_f64:it,_llvm_round_f64:at,_localIjToCell:function(A,e,t,r,o){var i,a;return A|=0,e|=0,t|=0,o|=0,a=S,S=S+16|0,i=a,(r|=0)?t=15:(t=0|function(A,e){e|=0;var t,r,o,i=0,a=0,s=0;if(a=0|n[(A|=0)>>2],n[e>>2]=a,s=0|n[A+4>>2],n[(r=e+4|0)>>2]=s,n[(o=e+8|0)>>2]=0,A=(i=(0|s)<(0|a))?a:s,(0|(i=i?s:a))<0){if(-2147483648==(0|i)||((0|A)>0?(2147483647-A|0)<(0|i):(-2147483648-A|0)>(0|i)))return 1;if((0|A)>-1?(-2147483648|A)>=(0|i):(-2147483648^A)<(0|i))return 1}return A=s-a|0,(0|a)<0?(i=0-a|0,n[r>>2]=A,n[o>>2]=i,n[e>>2]=0,a=0):(A=s,i=0),(0|A)<0&&(a=a-A|0,n[e>>2]=a,i=i-A|0,n[o>>2]=i,n[r>>2]=0,A=0),t=a-i|0,s=A-i|0,(0|i)<0?(n[e>>2]=t,n[r>>2]=s,n[o>>2]=0,A=s,s=t,i=0):s=a,(0|(a=(0|i)<(0|(a=(0|A)<(0|s)?A:s))?i:a))<=0||(n[e>>2]=s-a,n[r>>2]=A-a,n[o>>2]=i-a),0}(t,i))||(t=0|be(A,e,i,o)),S=a,0|t},_malloc:Ue,_maxFaceCount:function(A,e,t){t|=0;var r=0,o=0;if(o=0|tt(0|(A|=0),0|(e|=0),45),B(),!(0|z(127&o)))return o=2,n[t>>2]=o,0;if(o=0|tt(0|A,0|e,52),B(),!(o&=15))return o=5,n[t>>2]=o,0;for(r=1;;){if(!(!((0|rt(7,0,3*(15-r|0)|0))&A)&!((0|B())&e))){r=2,A=6;break}if(!(r>>>0>>0)){r=5,A=6;break}r=r+1|0}return 6==(0|A)?(n[t>>2]=r,0):0},_maxGridDiskSize:function(A,e){e|=0;var t=0,r=0,o=0;return(0|(A|=0))<0?0|(e=2):(0|A)>13780509?0|(e=0|le(15,e)):(o=0|qe(0|A,0|(t=((0|A)<0)<<31>>31),3,0),r=0|B(),t=0|Ve(0|A,0|t,1,0),t=0|Ve(0|(t=0|qe(0|o,0|r,0|t,0|B())),0|B(),1,0),A=0|B(),n[e>>2]=t,n[e+4>>2]=A,0|(e=0))},_maxPolygonToCellsSize:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0;if(o=S,S=S+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return S=o,0|t;if(l=0|n[(c=A)+4>>2],n[(t=a)>>2]=n[c>>2],n[t+4>>2]=l,ke(a,i),!(t=0|eA(i,e,s))){if(e=0|n[a>>2],(0|(a=0|n[A+8>>2]))>0){i=0|n[A+12>>2],t=0;do{e=(0|n[i+(t<<3)>>2])+e|0,t=t+1|0}while((0|t)<(0|a))}i=0|n[(t=s)>>2],(0|(t=0|n[t+4>>2]))<(0|(a=((0|e)<0)<<31>>31))|(0|t)==(0|a)&i>>>0>>0?(n[(t=s)>>2]=e,n[t+4>>2]=a,t=a):e=i,l=0|Ve(0|e,0|t,12,0),c=0|B(),n[(t=s)>>2]=l,n[t+4>>2]=c,n[(t=r)>>2]=l,n[t+4>>2]=c,t=0}return S=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,d=0,g=0,h=0,m=0,b=0,p=0;if(s=S,S=S+48|0,h=s+32|0,g=s+40|0,a=s,!(0|n[(A|=0)>>2]))return n[(m=i)>>2]=0,n[m+4>>2]=0,S=s,0;IA(h,0,0,0),c=0|n[(d=h)>>2],d=0|n[d+4>>2];do{if(e>>>0>15)n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=4,m=9;else{if(0|(t=0|Ce(t))){n[(h=a)>>2]=0,n[h+4>>2]=0,n[a+8>>2]=t,n[a+12>>2]=-1,m=a+29|0,n[(h=a+16|0)>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,r[h+12|0]=0,r[0|m]=0|r[0|g],r[m+1|0]=0|r[g+1|0],r[m+2|0]=0|r[g+2|0],m=9;break}if(!(t=0|We(1+(0|n[A+8>>2])|0,32))){n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=13,m=9;break}Be(A,t),n[(p=a)>>2]=c,n[p+4>>2]=d,n[(d=a+8|0)>>2]=0,n[a+12>>2]=e,n[a+20>>2]=A,n[a+24>>2]=t,r[a+28|0]=0,r[0|(c=a+29|0)]=0|r[0|g],r[c+1|0]=0|r[g+1|0],r[c+2|0]=0|r[g+2|0],n[a+16>>2]=3,b=+J(t),b*=+Z(t),u=+l(+ +o[t>>3]),u=b/+f(+ +it(+u,+ +l(+ +o[t+8>>3])))*6371.007180918475*6371.007180918475,t=0|n[(c=a+12|0)>>2];A:do{if((0|t)>0)do{if(se(t+-1|0,h),!(u/+o[h>>3]>10))break A;t=(p=0|n[c>>2])-1|0,n[c>>2]=t}while((0|p)>1)}while(0);if(we(a),n[(c=i)>>2]=0,n[c+4>>2]=0,!(!(0|(t=0|n[(c=a)>>2]))&!(0|(c=0|n[c+4>>2]))))do{_A(t,c,e,h),g=h,g=0|Ve(0|n[(A=i)>>2],0|n[A+4>>2],0|n[g>>2],0|n[g+4>>2]),A=0|B(),n[(p=i)>>2]=g,n[p+4>>2]=A,we(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[d>>2]}}while(0);return S=s,0|t},_memcpy:st,_memset:lt,_originToDirectedEdges:function(A,e,t){t|=0;var r,o=0;return r=!(0|HA(A|=0,e|=0)),e&=-2130706433,n[(o=t)>>2]=r?A:0,n[o+4>>2]=r?285212672|e:0,n[(o=t+8|0)>>2]=A,n[o+4>>2]=301989888|e,n[(o=t+16|0)>>2]=A,n[o+4>>2]=318767104|e,n[(o=t+24|0)>>2]=A,n[o+4>>2]=335544320|e,n[(o=t+32|0)>>2]=A,n[o+4>>2]=352321536|e,n[(t=t+40|0)>>2]=A,n[t+4>>2]=369098752|e,0},_pentagonCount:function(){return 12},_polygonToCells:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i,a,s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,w=0,x=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,j=0,N=0,F=0,P=0,I=0,R=0,_=0;if(s=S,S=S+112|0,o=s+80|0,d=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return S=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return S=s,13;if(Be(A,_),!(l=0|Ce(t))){if(R=0|n[(I=A)+4>>2],n[(l=d)>>2]=n[I>>2],n[l+4>>2]=R,ke(d,o),l=0|eA(o,e,i))I=0,R=0;else{if(l=0|n[d>>2],(0|(c=0|n[g>>2]))>0){u=0|n[A+12>>2],t=0;do{l=(0|n[u+(t<<3)>>2])+l|0,t=t+1|0}while((0|t)!=(0|c));t=l}else t=l;c=0|n[(l=i)>>2],(0|(l=0|n[l+4>>2]))<(0|(u=((0|t)<0)<<31>>31))|(0|l)==(0|u)&c>>>0>>0?(n[(l=i)>>2]=t,n[l+4>>2]=u,l=u):t=c,I=0|Ve(0|t,0|l,12,0),R=0|B(),n[(l=i)>>2]=I,n[l+4>>2]=R,l=0}if(!l){if(!(t=0|We(I,8)))return Ye(_),S=s,13;if(!(f=0|We(I,8)))return Ye(_),Ye(t),S=s,13;n[(F=o)>>2]=0,n[F+4>>2]=0,P=0|n[(F=A)+4>>2],n[(l=d)>>2]=n[F>>2],n[l+4>>2]=P,l=0|H(d,I,R,e,o,t,f);A:do{if(l)Ye(t),Ye(f),Ye(_);else{e:do{if((0|n[g>>2])>0){for(u=A+12|0,c=0;l=0|H((0|n[u>>2])+(c<<3)|0,I,R,e,o,t,f),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(f),Ye(_);break A}}while(0);(0|R)>0|!(0|R)&I>>>0>0&<(0|f,0,I<<3),F=0|n[(P=o)+4>>2];e:do{if((0|F)>0|!(0|F)&(0|n[P>>2])>>>0>0){Q=t,j=f,N=t,F=f,P=t,l=t,M=t,D=f,E=f,t=f;t:for(;;){for(x=0,y=0,k=0,C=0,c=0,u=0;;){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|T(g=0|n[(e=Q+(x<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|We(7,4))&&(L(g,e,1,i,f,7,0,0),Ye(f))}for(w=0;;){p=0|n[(v=i+(w<<3)|0)>>2],v=0|n[v+4>>2];r:do{if(!(0|p)&!(0|v))f=c,d=u;else{if(h=0|At(0|p,0|v,0|I,0|R),g=0|B(),!(!(0|(d=0|n[(e=f=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|R)|(0|m)==(0|R)&b>>>0>I>>>0)break t;if((0|d)==(0|p)&(0|e)==(0|v)){f=c,d=u;break r}h=0|$e(0|(f=0|Ve(0|h,0|g,1,0)),0|B(),0|I,0|R),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),d=0|n[(e=f=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|d)&!(0|e)))}if(!(0|p)&!(0|v)){f=c,d=u;break}qA(p,v,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=f)>>2]=p,n[m+4>>2]=v,n[(c=j+(c<<3)|0)>>2]=p,n[c+4>>2]=v,c=b),f=c,d=u}}while(0);if((w=w+1|0)>>>0>=7)break;c=f,u=d}if(x=0|Ve(0|x,0|y,1,0),y=0|B(),k=0|Ve(0|k,0|C,1,0),C=0|B(),c=0|n[(u=o)>>2],!((0|C)<(0|(u=0|n[u+4>>2]))|(0|C)==(0|u)&k>>>0>>0))break;c=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=Q+(c<<3)|0)>>2]=0,n[C+4>>2]=0,c=0|Ve(0|c,0|u,1,0),u=0|B(),k=0|n[(C=o)+4>>2]}while((0|u)<(0|k)|((0|u)==(0|k)?c>>>0<(0|n[C>>2])>>>0:0))}if(n[(C=o)>>2]=f,n[C+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break e;w=t,x=E,y=P,k=D,C=j,t=M,E=l,D=N,M=w,l=x,P=F,F=y,N=k,j=Q,Q=C}Ye(N),Ye(F),Ye(_),l=1;break A}l=f}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return S=s,0|l}}return Ye(_),S=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0;c=S,S=S+160|0,f=c+64|0,h=c+112|0,p=c,function(A,e,t,o){A|=0,e|=0,t|=0,o|=0;var i,a,s,l=0,c=0,u=0,f=0;s=S,S=S+48|0,i=s+40|0,a=s,IA(c=s+32|0,0,0,0),u=0|n[c>>2],c=0|n[c+4>>2];do{if(t>>>0<=15){if(0|(l=0|Ce(o))){n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=l,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}if(l=0|We(1+(0|n[e+8>>2])|0,32)){Be(e,l),n[(f=a)>>2]=u,n[f+4>>2]=c,n[a+8>>2]=0,n[a+12>>2]=t,n[a+16>>2]=o,n[a+20>>2]=e,n[a+24>>2]=l,r[a+28|0]=0,r[0|(u=a+29|0)]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(u=a)>>2]=0,n[u+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,f=a+29|0,n[(u=a+16|0)>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,r[u+12|0]=0,r[0|f]=0|r[0|i],r[f+1|0]=0|r[i+1|0],r[f+2|0]=0|r[i+2|0]}while(0);we(a),n[A>>2]=n[a>>2],n[A+4>>2]=n[a+4>>2],n[A+8>>2]=n[a+8>>2],n[A+12>>2]=n[a+12>>2],n[A+16>>2]=n[a+16>>2],n[A+20>>2]=n[a+20>>2],n[A+24>>2]=n[a+24>>2],n[A+28>>2]=n[a+28>>2],S=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(f,0|n[(d=g)>>2],0|n[d+4>>2],e),s=0|n[(d=f)>>2],d=0|n[d+4>>2],u=0|n[g+8>>2],n[(m=h+4|0)>>2]=n[g>>2],n[m+4>>2]=n[g+4>>2],n[m+8>>2]=n[g+8>>2],n[m+12>>2]=n[g+12>>2],n[m+16>>2]=n[g+16>>2],n[m+20>>2]=n[g+20>>2],n[m+24>>2]=n[g+24>>2],n[m+28>>2]=n[g+28>>2],n[(m=p)>>2]=s,n[m+4>>2]=d,n[(m=p+8|0)>>2]=u,e=h,t=36+(A=p+12|0)|0;do{n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}while((0|A)<(0|t));if(n[(h=p+48|0)>>2]=n[f>>2],n[h+4>>2]=n[f+4>>2],n[h+8>>2]=n[f+8>>2],n[h+12>>2]=n[f+12>>2],!(0|s)&!(0|d))return S=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,f=0,e=s,A=d;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&f>>>0>>0)){b=4;break}if(d=f,f=0|Ve(0|f,0|u,1,0),u=0|B(),n[(d=a+(d<<3)|0)>>2]=e,n[d+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(we(t),!(0|(A=0|n[(e=t)>>2]))&!(0|(e=0|n[e+4>>2]))){b=10;break}te(A,e,0|n[g>>2],h),e=0|n[(A=h)>>2],A=0|n[A+4>>2]}n[(d=p)>>2]=e,n[d+4>>2]=A}while(!(!(0|e)&!(0|A)));return 4==(0|b)?(0|(e=0|n[(A=p+40|0)>>2])&&Ye(e),n[(b=p+16|0)>>2]=0,n[b+4>>2]=0,n[l>>2]=0,n[p+36>>2]=0,n[g>>2]=-1,n[p+32>>2]=0,n[A>>2]=0,te(0,0,0,h),n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=0,S=c,0|(p=14)):(10==(0|b)&&(n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=n[l>>2]),p=0|n[m>>2],S=c,0|p)},_readInt64AsDoubleFromPointer:function(A){return+(+((0|n[(A|=0)>>2])>>>0)+4294967296*+(0|n[A+4>>2]))},_res0CellCount:function(){return 122},_round:ct,_sbrk:ut,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(A,e,t,r,o,i,a){A|=0,r|=0,o|=0,i|=0;var s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(s=S,S=S+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return S=s,0;if((0|(a|=0))>=16)return S=s,12;g=0,h=0,d=0,l=0;A:for(;;){if(f=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&f)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(f=m)>>2]))&!(0|(f=0|n[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(d=r+(c<<3)|0)>>2]=u,n[d+4>>2]=f,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(d=m)>>2],f=0|n[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(g=0|Ve(0|g,0|h,1,0),!((0|(h=0|B()))<(0|t)|(0|h)==(0|t)&g>>>0>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(S=s,0|(m=14)):11==(0|c)?(S=s,0|l):0},_uncompactCellsSize:function(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0;a=S,S=S+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(f=0,l=0,s=0,d=0;;){if(!(!(0|(c=0|n[(u=A+(f<<3)|0)>>2]))&!(0|(u=0|n[u+4>>2]))||(u=!(0|_A(c,u,r,i)),l=0|Ve(0|n[(c=i)>>2],0|n[c+4>>2],0|l,0|s),s=0|B(),u))){s=12;break}if(f=0|Ve(0|f,0|d,1,0),!((0|(d=0|B()))<(0|t)|(0|d)==(0|t)&f>>>0>>0))break A}return S=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,S=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=S,S=S+192|0,o=a,i=a+168|0,s=0|tt(0|(A|=0),0|(e|=0),56),B(),s&=7,0|(r=0|XA(A,l=-2130706433&e|134217728,i))?(S=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?QA(i,e,s,1,o):FA(i,e,s,1,o),l=o+8|0,n[t>>2]=n[l>>2],n[t+4>>2]=n[l+4>>2],n[t+8>>2]=n[l+8>>2],n[t+12>>2]=n[l+12>>2],S=a,0|(l=0))},establishStackSpace:function(A,e){S=A|=0},stackAlloc:function(A){var e;return e=S,S=15+(S=S+(A|=0)|0)&-16,0|e},stackRestore:function(A){S=A|=0},stackSave:function(){return 0|S}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(A){s=A},c:function(){return s},d:function(A,e,t,r){tA("Assertion failed: "+v(A)+", at: "+[e?v(e):"unknown filename",t,r?v(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){d.set(d.subarray(e,e+t),A)},h:function(A){var e=z(),t=16777216,r=2130706432;if(A>r)return!1;for(var n=Math.max(e,16777216);n0))return 0;for(var n=t+r-1,o=0;o=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++o)),i<=127){if(t>=n)break;e[t++]=i}else if(i<=2047){if(t+1>=n)break;e[t++]=192|i>>6,e[t++]=128|63&i}else if(i<=65535){if(t+2>=n)break;e[t++]=224|i>>12,e[t++]=128|i>>6&63,e[t++]=128|63&i}else{if(t+3>=n)break;e[t++]=240|i>>18,e[t++]=128|i>>12&63,e[t++]=128|i>>6&63,e[t++]=128|63&i}}e[t]=0}(A,d,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,f.set(e,t),r}},o=c(A),i=[],a=0;if(r)for(var s=0;s>1]=e;break;case"i32":h[A>>2]=e;break;case"i64":I=[e>>>0,(L=e,+j(L)>=1?L>0?(0|F(+S(L/4294967296),4294967295))>>>0:~~+N((L-+(~~L>>>0))/4294967296)>>>0:0)],h[A>>2]=I[0],h[A+4>>2]=I[1];break;case"float":m[A>>2]=e;break;case"double":b[A>>3]=e;break;default:tA("invalid type for setValue: "+t)}},t.getValue=function(A,e,t){switch("*"===(e=e||"i8").charAt(e.length-1)&&(e="i32"),e){case"i1":case"i8":return f[0|A];case"i16":return g[A>>1];case"i32":case"i64":return h[A>>2];case"float":return m[A>>2];case"double":return b[A>>3];default:tA("invalid type for getValue: "+e)}return null},R){H(R)||(W=R,R=t.locateFile?t.locateFile(W,o):o+W),P++,t.monitorRunDependencies&&t.monitorRunDependencies(P);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),d.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(P--,t.monitorRunDependencies&&t.monitorRunDependencies(P),0==P&&T){var A=T;T=null,A()}}()},q=function(){n(R,X,function(){throw"could not load memory initializer "+R})},$=O(R);if($)X($.buffer);else if(t.memoryInitializerRequest){var AA=function(){var A=t.memoryInitializerRequest,e=A.response;if(200!==A.status&&0!==A.status){var r=O(t.memoryInitializerRequestURL);if(!r)return void q();e=r.buffer}X(e)};t.memoryInitializerRequest.response?setTimeout(AA,0):t.memoryInitializerRequest.addEventListener("load",AA)}else q()}function eA(A){function e(){V||(V=!0,l||(k(B),k(M),t.onRuntimeInitialized&&t.onRuntimeInitialized(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)Q(t.postRun.shift());k(D)}()))}P>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),P>0||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),e()},1)):e()))}function tA(A){throw t.onAbort&&t.onAbort(A),i(A+=""),a(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(T=function A(){V||eA(),V||(T=A)},t.run=eA,t.abort=tA,t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return eA(),A}("object"==typeof ke?ke:{}),Ce="number",Be={0:"Success",1:"The operation failed but a more specific error is not available",2:"Argument was outside of acceptable range",3:"Latitude or longitude arguments were outside of acceptable range",4:"Resolution argument was outside of acceptable range",5:"Cell argument was not valid",6:"Directed edge argument was not valid",7:"Undirected edge argument was not valid",8:"Vertex argument was not valid",9:"Pentagon distortion was encountered",10:"Duplicate input",11:"Cell arguments were not neighbors",12:"Cell arguments had incompatible resolutions",13:"Memory allocation failed",14:"Bounds of provided memory were insufficient",15:"Mode or flags argument was not valid",16:"Index argument was not valid",17:"Base cell number was outside of acceptable range",18:"Child indexing digits invalid",19:"Child indexing digits refer to a deleted subsequence"},Me={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function De(A,e,t){var r=t&&"value"in t,n=new Error((A[e]||"Unknown error")+" (code: "+e+(r?", value: "+t.value:"")+")");return n.code=e,n}function Ee(A){if(0!==A)throw function(A,e){return De(Be,A,2===arguments.length?{value:e}:{})}(A)}var Qe={};[["sizeOfH3Index",Ce],["sizeOfLatLng",Ce],["sizeOfCellBoundary",Ce],["sizeOfGeoLoop",Ce],["sizeOfGeoPolygon",Ce],["sizeOfLinkedGeoPolygon",Ce],["sizeOfCoordIJ",Ce],["readInt64AsDoubleFromPointer",Ce],["isValidCell",Ce,[Ce,Ce]],["isValidIndex",Ce,[Ce,Ce]],["latLngToCell",Ce,[Ce,Ce,Ce,Ce]],["cellToLatLng",Ce,[Ce,Ce,Ce]],["cellToBoundary",Ce,[Ce,Ce,Ce]],["maxGridDiskSize",Ce,[Ce,Ce]],["gridDisk",Ce,[Ce,Ce,Ce,Ce]],["gridDiskDistances",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridRing",Ce,[Ce,Ce,Ce,Ce]],["gridRingUnsafe",Ce,[Ce,Ce,Ce,Ce]],["maxPolygonToCellsSize",Ce,[Ce,Ce,Ce,Ce]],["polygonToCells",Ce,[Ce,Ce,Ce,Ce]],["maxPolygonToCellsSizeExperimental",Ce,[Ce,Ce,Ce,Ce]],["polygonToCellsExperimental",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["cellsToLinkedMultiPolygon",Ce,[Ce,Ce,Ce]],["destroyLinkedMultiPolygon",null,[Ce]],["compactCells",Ce,[Ce,Ce,Ce,Ce]],["uncompactCells",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["uncompactCellsSize",Ce,[Ce,Ce,Ce,Ce,Ce]],["isPentagon",Ce,[Ce,Ce]],["isResClassIII",Ce,[Ce,Ce]],["getBaseCellNumber",Ce,[Ce,Ce]],["getResolution",Ce,[Ce,Ce]],["getIndexDigit",Ce,[Ce,Ce,Ce]],["constructCell",Ce,[Ce,Ce,Ce,Ce]],["maxFaceCount",Ce,[Ce,Ce,Ce]],["getIcosahedronFaces",Ce,[Ce,Ce,Ce]],["cellToParent",Ce,[Ce,Ce,Ce,Ce]],["cellToChildren",Ce,[Ce,Ce,Ce,Ce]],["cellToCenterChild",Ce,[Ce,Ce,Ce,Ce]],["cellToChildrenSize",Ce,[Ce,Ce,Ce,Ce]],["cellToChildPos",Ce,[Ce,Ce,Ce,Ce]],["childPosToCell",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["areNeighborCells",Ce,[Ce,Ce,Ce,Ce,Ce]],["cellsToDirectedEdge",Ce,[Ce,Ce,Ce,Ce,Ce]],["getDirectedEdgeOrigin",Ce,[Ce,Ce,Ce]],["getDirectedEdgeDestination",Ce,[Ce,Ce,Ce]],["isValidDirectedEdge",Ce,[Ce,Ce]],["directedEdgeToCells",Ce,[Ce,Ce,Ce]],["originToDirectedEdges",Ce,[Ce,Ce,Ce]],["directedEdgeToBoundary",Ce,[Ce,Ce,Ce]],["gridDistance",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridPathCells",Ce,[Ce,Ce,Ce,Ce,Ce]],["gridPathCellsSize",Ce,[Ce,Ce,Ce,Ce,Ce]],["cellToLocalIj",Ce,[Ce,Ce,Ce,Ce,Ce,Ce]],["localIjToCell",Ce,[Ce,Ce,Ce,Ce,Ce]],["getHexagonAreaAvgM2",Ce,[Ce,Ce]],["getHexagonAreaAvgKm2",Ce,[Ce,Ce]],["getHexagonEdgeLengthAvgM",Ce,[Ce,Ce]],["getHexagonEdgeLengthAvgKm",Ce,[Ce,Ce]],["greatCircleDistanceM",Ce,[Ce,Ce]],["greatCircleDistanceKm",Ce,[Ce,Ce]],["greatCircleDistanceRads",Ce,[Ce,Ce]],["cellAreaM2",Ce,[Ce,Ce,Ce]],["cellAreaKm2",Ce,[Ce,Ce,Ce]],["cellAreaRads2",Ce,[Ce,Ce,Ce]],["edgeLengthM",Ce,[Ce,Ce,Ce]],["edgeLengthKm",Ce,[Ce,Ce,Ce]],["edgeLengthRads",Ce,[Ce,Ce,Ce]],["getNumCells",Ce,[Ce,Ce]],["getRes0Cells",Ce,[Ce]],["res0CellCount",Ce],["getPentagons",Ce,[Ce,Ce]],["pentagonCount",Ce],["cellToVertex",Ce,[Ce,Ce,Ce,Ce]],["cellToVertexes",Ce,[Ce,Ce,Ce]],["vertexToLatLng",Ce,[Ce,Ce,Ce]],["isValidVertex",Ce,[Ce,Ce]]].forEach(function(A){Qe[A[0]]=ke.cwrap.apply(ke,A)});var je=16,Ne=Qe.sizeOfH3Index(),Se=Qe.sizeOfLatLng(),Fe=Qe.sizeOfCellBoundary();Qe.sizeOfGeoPolygon(),Qe.sizeOfGeoLoop(),Qe.sizeOfLinkedGeoPolygon(),Qe.sizeOfCoordIJ();var Pe=/[^0-9a-fA-F]/;function Te(A){if(A>=0)return A.toString(je);var e=Le(8,(A&=2147483647).toString(je));return(parseInt(e[0],je)+8).toString(je)+e.substring(1)}function Le(A,e){for(var t=A-e.length,r="",n=0;n.85?.9+(i-.85)/.15*.1:.1+(i-.15)/.7*.8;var i;return We(r[Math.min(23,Math.floor(24*o))])}function Ze({coveragePoints:t,visible:r,terrainEnabled:n=!1,brightness:o=.7,basemapMode:i="dark"}){const{current:a}=I(),[s,l]=A.useState(null);A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==a?void 0:a.getMap)?void 0:A.call(a);e&&!s&&l(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[a,s]);const[c,u]=A.useState(null),[f,d]=A.useState(!1),g=A.useRef({aborted:!1}),h=A.useRef(0),m=A.useRef(i),b=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(t),p=A.useMemo(()=>function(A="dark"){var e;if("light"===A)return Ye;const t=vA();return 24===t.length&&0!==(null==(e=t[0])?void 0:e[0])?t:Ue}(i),[i]);A.useEffect(()=>{if(!b||!Array.isArray(b)||0===b.length)return void queueMicrotask(()=>{u(null),h.current=0});const A=m.current!==i;if(b.length===h.current&&c&&!A)return;h.current=b.length,m.current=i,g.current.aborted=!0,g.current={aborted:!1};const e=g.current;d(!0);const{cells:t,minQuality:r,maxQuality:n}=function(A){const e=new Map;for(const o of A){if("number"!=typeof o.lat||"number"!=typeof o.lon||isNaN(o.lat)||isNaN(o.lon))continue;const A=_e(o.lat,o.lon,8),t=e.get(A),r=o.weight;t?(t.count++,t.qualitySum+=r):e.set(A,{count:1,qualitySum:r})}const t=[];let r=1/0,n=-1/0;for(const[o,i]of e.entries()){const A=i.qualitySum/i.count;t.push({hexId:o,count:i.count,avgQuality:A}),r=Math.min(r,A),n=Math.max(n,A)}return{cells:t,minQuality:t.length>0?r:0,maxQuality:t.length>0?n:0}}(b);if(0===t.length)return u(null),void d(!1);if(t.length<500){const A=function(A,e,t,r){const n=[];for(const o of A){const A=He(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=Ve(o.avgQuality,e,t,r);n.push({type:"Feature",properties:{color:i,quality:o.avgQuality,count:o.count},geometry:{type:"Polygon",coordinates:[A]}})}return{type:"FeatureCollection",features:n}}(t,r,n,p);return void(e.aborted||(u(A),d(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=Ve(n.avgQuality,e,t,r);o.push({type:"Feature",properties:{color:s,quality:n.avgQuality,count:n.count},geometry:{type:"Polygon",coordinates:[a]}})}irequestAnimationFrame(A))}return{type:"FeatureCollection",features:o}}(t,r,n,p,e).then(A=>{!e.aborted&&A&&u(A)}).finally(()=>{e.aborted||d(!1)}),()=>{e.aborted=!0}},[b,p]),A.useEffect(()=>{if(!s)return;const A=()=>{var A,e;try{const t=s.getLayer(Oe),n=s.getSource(Ge);if(r&&c&&c.features.length>0){if(n?s.getSource(Ge).setData(c):s.addSource(Ge,{type:"geojson",data:c}),!t){const t=s.getLayer("topology-weak-edges-native"),r=null==(e=null==(A=s.getStyle())?void 0:A.layers)?void 0:e.find(A=>"symbol"===A.type),n=t?"topology-weak-edges-native":null==r?void 0:r.id;s.addLayer({id:Oe,type:"fill",source:Ge,paint:{"fill-color":["get","color"],"fill-opacity":o}},n)}}else t&&s.removeLayer(Oe),n&&s.removeSource(Ge)}catch(t){}};s.isStyleLoaded()?A():s.once("style.load",A)},[s,r,c,n]),A.useEffect(()=>{if(s&&r)try{s.getLayer(Oe)&&s.setPaintProperty(Oe,"fill-opacity",o)}catch{}},[s,o,r]),A.useEffect(()=>()=>{if(s)try{s.getLayer(Oe)&&s.removeLayer(Oe),s.getSource(Ge)&&s.removeSource(Ge)}catch{}},[s]);const v=(null==c?void 0:c.features.length)??0;return v>0&&r?e.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==t?void 0:t.length)||0,"data-cell-count":v,"data-terrain-enabled":n,"data-is-processing":f,style:{display:"none"}}):null}const Ke="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Je="terrarium",Xe="terrain-dem",qe="hillshade-dem",$e="terrain-hillshade";function At({enabled:e,exaggeration:t=4}){const{current:r}=I(),[n,o]=A.useState(null),i=A.useRef(null);return A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);e&&!n&&o(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[r,n]),A.useEffect(()=>{if(!n)return;let A=!0;const e=()=>{var e,t;if(A)try{if(n.getSource(qe)||n.addSource(qe,{type:"raster-dem",tiles:[Ke],encoding:Je,tileSize:256,maxzoom:14}),!n.getLayer($e)){const A=null==(t=null==(e=n.getStyle())?void 0:e.layers)?void 0:t.find(A=>"symbol"===A.type);n.addLayer({id:$e,type:"hillshade",source:qe,paint:{"hillshade-shadow-color":"rgba(10, 10, 10, 0.6)","hillshade-highlight-color":"rgba(245, 240, 230, 0.4)","hillshade-accent-color":"rgba(90, 75, 65, 0.3)","hillshade-illumination-direction":315,"hillshade-exaggeration":.35}},null==A?void 0:A.id)}n.getSource(Xe)||n.addSource(Xe,{type:"raster-dem",tiles:[Ke],encoding:Je,tileSize:256,maxzoom:14})}catch(r){}};return n.isStyleLoaded()?e():(n.once("style.load",e),n.once("load",()=>{A&&!n.getSource(qe)&&e()})),()=>{A=!1}},[n]),A.useEffect(()=>{if(!n)return;let A=!0,r=!1;const o=()=>{if(A&&n.getSource(Xe))try{e?(n.setCenterClampedToGround(!1),n.setTerrain({source:Xe,exaggeration:t}),n.setMaxPitch(70),!r&&n.getPitch()<30&&!n.isMoving()&&(r=!0,null!==i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,A&&!n.isMoving()&&n.getPitch()<30&&n.easeTo({pitch:45,duration:1e3})},200))):(n.setTerrain(null),n.setCenterClampedToGround(!0),n.getPitch()>0&&!n.isMoving()&&n.easeTo({pitch:0,duration:800}),n.setMaxPitch(60))}catch(o){}};if(n.isStyleLoaded()&&n.getSource(Xe))o();else{const A=()=>{n.getSource(Xe)&&o()};n.once("idle",A)}return()=>{A=!1,null!==i.current&&(clearTimeout(i.current),i.current=null)}},[n,e,t]),A.useEffect(()=>()=>{var A;try{(null==(A=null==n?void 0:n.getStyle)?void 0:A.call(n))&&n.isStyleLoaded()&&(n.setTerrain(null),n.getLayer($e)&&n.removeLayer($e),n.getSource(qe)&&n.removeSource(qe),n.getSource(Xe)&&n.removeSource(Xe))}catch{}},[n]),null}function et(A,e){let t=0;for(let r=0;r0)for(let t=0;t=A.length)return A;const t=[],r=A.length/e;for(let n=0;no.has(A.fromHash)&&o.has(A.toHash));if(0===i.length)return null;const a=function(A,e,t,r){const n=e.length,o=new Map(e.map((A,e)=>[A,e])),i=Array(n).fill(null).map(()=>Array(n).fill(0));for(const a of A){const A=o.get(a.fromHash),e=o.get(a.toHash);if(void 0!==A&&void 0!==e&&A!==e){const n=a.strength*a.certainCount;let o=1;if(t){const A=t.get(a.fromHash),e=t.get(a.toHash);A&&e&&(o=ot(FA(A[0],A[1],e[0],e[1])/1e3))}let s=1;if(r){const A=[a.fromHash,a.toHash].sort().join("-");s=1-.7*(r.get(A)??0)}const l=.3+.7*(a.symmetryRatio??0),c=Math.pow(n,.7)*Math.pow(o,.3)*s*l;i[A][e]=c,i[e][A]=c}}return i}(i,e,t,r),s=function(A){const e=A.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let r=0;rArray(e).fill(0));for(let a=0;a43758.5453*Math.sin(12.9898*e)%1-.5);rt(o,t),tt(o);let i=0;for(let a=0;a<100;a++){const A=nt(n,o);rt(A,t);const e=et(A,A)/et(o,A);if(tt(A),o=A,Math.abs(e-i)<1e-8)return{vector:o,eigenvalue:r-e};i=e}return{vector:o,eigenvalue:r-i}}(s);if(c<.001)return null;const u=[],f=[];for(let d=0;d0&&A.push([A[0][0],A[0][1]]),t=A}return t}function gt(A,e={}){const t=function(A,e={}){if(A.length<3)return{coordinates:[],valid:!1};const{bandwidth:t=ct,threshold:r=ut,cellSize:n=ft}=e,o=function(A,e){let t=1/0,r=-1/0,n=1/0,o=-1/0;for(const[i,a]of A)ir&&(r=i),ao&&(o=a);return t-=e,r+=e,n-=e,o+=e,{minX:t,minY:n,maxX:r,maxY:o,width:r-t,height:o-n}}(A,.02),i=Math.ceil(o.width/(t/2)),a=Math.ceil(o.height/(t/2)),s=Math.min(1,200/Math.max(i,a)),l=Math.max(10,Math.ceil(i*s)),c=Math.max(10,Math.ceil(a*s)),u=A=>A/l*o.width+o.minX,f=A=>A/c*o.height+o.minY,d=t/o.width*l;try{const e=kA().x(A=>(A[0]-o.minX)/o.width*l).y(A=>(A[1]-o.minY)/o.height*c).size([l,c]).bandwidth(Math.max(5,d)).cellSize(n)(A);if(0===e.length)return{coordinates:[],valid:!1};const t=Math.max(...e.map(A=>A.value))*r;let i=e[0],a=1/0;for(const A of e){const e=Math.abs(A.value-t);e0){const e=A[0],t=A[A.length-1];e[0]===t[0]&&e[1]===t[1]||A.push([e[0],e[1]])}if(A.length>=4){const t=dt(A);e.push(t)}}e.length>0&&s.push(e)}const g=[];for(const A of s)for(const e of A)g.push(e);return{coordinates:s,valid:s.length>0}}catch(g){return{coordinates:[],valid:!1}}}(A,e);return t.valid&&0!==t.coordinates.length?1===t.coordinates.length?{type:"Polygon",coordinates:t.coordinates[0]}:{type:"MultiPolygon",coordinates:t.coordinates}:null}function ht(A,e,t){return(e[0]-A[0])*(t[1]-A[1])-(e[1]-A[1])*(t[0]-A[0])}function mt(A,e,t,r,n){const o=n*n,i=o*n;return[.5*(2*e[0]+(-A[0]+t[0])*n+(2*A[0]-5*e[0]+4*t[0]-r[0])*o+(-A[0]+3*e[0]-3*t[0]+r[0])*i),.5*(2*e[1]+(-A[1]+t[1])*n+(2*A[1]-5*e[1]+4*t[1]-r[1])*o+(-A[1]+3*e[1]-3*t[1]+r[1])*i)]}function bt(A){let e=function(A){if(A.length<3)return A;const e=[...A].sort((A,e)=>A[0]-e[0]||A[1]-e[1]),t=[];for(const n of e){for(;t.length>=2&&ht(t[t.length-2],t[t.length-1],n)<=0;)t.pop();t.push(n)}const r=[];for(let n=e.length-1;n>=0;n--){const A=e[n];for(;r.length>=2&&ht(r[r.length-2],r[r.length-1],A)<=0;)r.pop();r.push(A)}return t.pop(),r.pop(),t.concat(r)}(A);if(e.length<3)return null;e=function(A){if(A.length<3)return A;let e=0,t=0;for(const[r,n]of A)e+=r,t+=n;return e/=A.length,t/=A.length,A.map(([A,r])=>{const n=A-e,o=r-t,i=Math.sqrt(n*n+o*o);if(i<1e-4)return[A,r];const a=(i+.008)/i;return[e+n*a,t+o*a]})}(e);const t=function(A){if(A.length<3)return A;const e=[],t=A.length;for(let r=0;rt?function(A,e,t,r){const n=[];for(const[o,i]of A.communities){const A=[];for(const t of i){const r=e.get(t);r&&A.push([r[1],r[0]])}if(A.length<3)continue;let a=gt(A,{bandwidth:t,threshold:r});a||(a=bt(A)),a&&n.push({type:"Feature",properties:{community:o,color:st(o),borderColor:lt(o),nodeCount:i.length},geometry:a})}return{type:"FeatureCollection",features:n}}(t,r,i,a):{type:"FeatureCollection",features:[]},[t,r,i,a]),c=n?o:0,u={"fill-color":["get","color"],"fill-opacity":c},f={"line-color":["get","borderColor"],"line-width":s,"line-opacity":c};return e.jsxs(R,{id:"mincut-partition",type:"geojson",data:l,children:[e.jsx(_,{id:"mincut-partition-fill",type:"fill",paint:u}),e.jsx(_,{id:"mincut-partition-stroke",type:"line",paint:f})]})}const vt={showTopology:!1,showNeighborLines:!0,show3DTerrain:!1,showMinCut:!1,nodeFilter:"all"},wt=C()(xA(A=>({viewState:null,setViewState:e=>A({viewState:e,lastSavedAt:Date.now()}),toggles:vt,setToggle:(e,t)=>A(A=>({toggles:{...A.toggles,[e]:t},lastSavedAt:Date.now()})),setToggles:e=>A(A=>({toggles:{...A.toggles,...e},lastSavedAt:Date.now()})),hasAnalyzed:!1,setHasAnalyzed:e=>A({hasAnalyzed:e,lastSavedAt:Date.now()}),lastSavedAt:null,reset:()=>A({viewState:null,toggles:vt,hasAnalyzed:!1,lastSavedAt:null})}),{name:"pymc-map-view",partialize:A=>({viewState:A.viewState,toggles:A.toggles,hasAnalyzed:A.hasAnalyzed,lastSavedAt:A.lastSavedAt})}));function xt(A,e=!1,t=!1,r=!1,n=.7,o){const i=bA(o);return r?n>=.75?i.restBright:i.rest:n>=.85?i.rest:i.restDim}function yt(A){return[A[1],A[0]]}function kt(A,e,t,r=12){const[n,o]=A,[i,a]=e,s=[];for(let l=0;l<=r;l++){const A=l/r,e=o+(a-o)*A,c=n+(i-n)*A,u=4*t*A*(1-A);s.push([e,c,u])}return s}function Ct(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Bt(A,e,t,r,n,o,i,a,s,l,c,u="dark"){const f=LA(),d=[];let g=1/0,h=-1/0;const m=[];for(const p of A){const A=.7*(p.edge.avgConfidence??(e?.7:.5))+p.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);m.push({polyline:p,brightnessScore:A}),g=Math.min(g,A),h=Math.max(h,A)}if(0===m.length)return{type:"FeatureCollection",features:[]};const b=h-g||1;m.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:p,brightnessScore:v}of m){const{from:A,to:i,edge:h}=p,m=t.get(h.key)??0;if(m<=0)continue;const w=a.has(h.key),x=s.has(h.key),y=h.avgConfidence??(e?.7:.5),k=l===h.key,C=c[h.fromHash],B=c[h.toHash],M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||h.fromHash.slice(0,8),D=(null==B?void 0:B.node_name)||(null==B?void 0:B.name)||h.toHash.slice(0,8),E=[A[0]+(i[0]-A[0])*m,A[1]+(i[1]-A[1])*m];let Q,j,N,S;if(e){const A=o.get(h.key)??PA(h.certainCount),e=n.get(h.key)??A;Q=e+(A-e)*r,k?Q=Math.max(1.6*Q,4.5):x&&(Q*=1.3)}else Q=1.5;if(j=k?f.edges.highlight:xt(0,h.isDirectPathEdge??!1,w,x,y,u),N=k?f.edges.highlight:h.isDirectPathEdge?f.edges.hoverDirect:w?f.edges.hoverLoop:f.edges.hoverStandard,e){const A=Math.min(1.5*m,1)*f.edgeOpacity;S=x?1.15*A:A}else S=(.3+.3*y)*m;k&&(S=.95);const F=(v-g)/b;d.push({type:"Feature",properties:{key:h.key,baseColor:j,hoverColor:N,baseWidth:Q,baseOpacity:S,brightnessScore:F,isLoopEdge:w,isBackbone:x,isDirectPath:h.isDirectPathEdge??!1,isHubConnection:h.isHubConnection??!1,isZeroHop:h.isZeroHop??!1,isValidated:e,certainCount:h.certainCount,confidence:y,symmetryRatio:h.symmetryRatio??1,dominantDirection:h.dominantDirection??"balanced",fromName:M,toName:D,fromHash:h.fromHash,toHash:h.toHash},geometry:{type:"LineString",coordinates:[yt(A),yt(E)]}})}return{type:"FeatureCollection",features:d}}function Mt(A,e){const t=LA(),r=[];let n=0;for(const o of A){const A=e.get(o.hash);A&&A.blendedScore>n&&(n=A.blendedScore)}for(const o of A){const{from:A,to:i,hash:a,neighbor:s,lastHopData:l}=o,c=`neighbor-${a}`,u=(null==l?void 0:l.avgRssi)??s.rssi??null,f=(null==l?void 0:l.avgSnr)??s.snr??null,d=(null==l?void 0:l.count)??0,g=(null==l?void 0:l.confidence)??1,h=e.get(a),m=(null==h?void 0:h.listenerScore)??0,b=(null==h?void 0:h.loudScore)??0,p=(null==h?void 0:h.blendedScore)??0,v=n>0?p/n:0,w=o.rxAdvertCount??0,x=o.txProxyCount??0,y=w+x,k=y>0?(x-w)/y:0,C=kt(A,i,150,8);r.push({type:"Feature",properties:{key:c,hash:a,name:s.node_name||s.name||a.slice(0,8),prefix:a.slice(2,4).toUpperCase(),color:t.neighborColor,width:2.5,opacity:.85,rssi:u,snr:f,packetCount:d,confidence:g,hasAvgRssi:void 0!==(null==l?void 0:l.avgRssi),hasAvgSnr:void 0!==(null==l?void 0:l.avgSnr),isNeighborEdge:!0,listenerScore:m,loudScore:b,blendedScore:p,trafficWeight:v,linkAsymmetry:k,rxAdvertCount:w,txProxyCount:x},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Dt(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Et(A,e){if(A<240)return.5;if(A<480)return 1;const t=(A-480)/(e-480);return Math.max(0,.33*(1-t))}function Qt(A,e,t){const r=t?nA(t):null,n=[];for(const o of A){if(r&&o.toUpperCase()===r){t&&n.push(t);continue}const A=e.get(o.toUpperCase());A&&n.push(A)}return n}const jt="edge-blink-source",Nt="edge-blink-layer",St=1e3,Ft=1e3,Pt="node-markers-layer";function Tt(A){return A<0||A>=St?0:1-A/St}function Lt(A){if(A<0)return 0;if(A>=Ft)return 0;const e=A/Ft;return Math.pow(1-e,3)}function It(A){return[A[1],A[0]]}function Rt(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function _t({txDelayRec:t,onRemove:r}){const[n,o]=A.useState(!1),i=t.floodFactor??t.txDelayFactor,a=t.directFactor??t.directTxDelayFactor;return e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[e.jsxs("button",{onClick:async()=>{const A=`set txdelay ${i.toFixed(1)}\nset direct.txdelay ${a.toFixed(1)}`;try{await navigator.clipboard.writeText(A),o(!0),setTimeout(()=>o(!1),1500)}catch(e){const t=document.createElement("textarea");t.value=A,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),o(!0),setTimeout(()=>o(!1),1500)}catch{}document.body.removeChild(t)}},className:"flex items-center gap-2 flex-1 py-1 px-1.5 bg-amber-400/5 hover:bg-amber-400/10 rounded transition-colors group",title:"Click to copy CLI commands",children:[e.jsx(U,{className:"w-3 h-3 text-amber-400 shrink-0"}),e.jsx("span",{className:"text-text-muted",children:"TxDelay"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-text-muted",children:"F"}),e.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",i.toFixed(1)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-text-muted",children:"D"}),e.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",a.toFixed(1)]})]})]}),n?e.jsx(E,{className:"w-3 h-3 text-green-400 ml-auto"}):e.jsx(H,{className:"w-3 h-3 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]}),r&&e.jsx("button",{onClick:r,className:"p-1 text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:e.jsx(N,{className:"w-3.5 h-3.5"})})]})}function Ht({hash:t,hashPrefix:r,name:n,isHub:o,isGateway:i,isBackbone:a,isZeroHop:s,isMobile:l,isRoomServer:c,isStale:u,lastSeenTimestamp:f,centrality:d,affinity:g,meanSnr:h,meanRssi:m,neighbor:b,onRemove:p,txDelayRec:v}){const[w,x]=A.useState(!1),y=s?"Direct":(null==g?void 0:g.typicalHopPosition)?`${g.typicalHopPosition}-hop`:null,k=v&&!v.insufficientData;return e.jsxs("div",{className:"w-[240px] pr-2",children:[e.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-tight truncate mb-1",children:n}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[e.jsx("code",{className:"font-mono text-[10px] text-text-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:r}),e.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),1500)}catch(A){const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy"),x(!0),setTimeout(()=>x(!1),1500)}catch{}document.body.removeChild(e)}},className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:w?e.jsx(E,{className:"w-3 h-3 text-sys-green"}):e.jsx(H,{className:"w-3 h-3 text-text-secondary"})}),e.jsx(DA,{hash:t,size:"sm"}),y&&e.jsx(iA,{color:s?QA.direct:QA.multihop,compact:!0,children:y}),b.is_repeater&&e.jsx(iA,{color:jA.repeater,compact:!0,children:"Rptr"}),o&&e.jsx(iA,{color:jA.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),i&&!o&&e.jsx(iA,{color:jA.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),a&&e.jsx(iA,{color:jA.backbone,compact:!0,title:"Backbone",children:"Bone"}),l&&e.jsx(iA,{color:jA.mobile,compact:!0,children:"Mobile"}),c&&e.jsx(iA,{color:jA.room,compact:!0,children:"Room"}),u&&f&&e.jsxs(iA,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",Rt(f)]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-secondary mb-1.5",children:[e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(z,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsx("span",{className:"font-mono",children:aA(b.last_seen)})]}),(null==g?void 0:g.distanceMeters)&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(G,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(C=g.distanceMeters,null===C?"—":C<1e3?`${Math.round(C)}m`:`${(C/1e3).toFixed(1)}km`)})]}),b.latitude&&b.longitude&&0!==b.latitude&&0!==b.longitude&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(O,{className:"w-3 h-3 text-text-muted shrink-0"}),e.jsxs("span",{className:"font-mono text-text-muted",children:[b.latitude.toFixed(2),", ",b.longitude.toFixed(2)]})]})]}),e.jsx("div",{className:"mb-1.5",style:{width:224},children:e.jsx(EA,{nodeHash:t,width:224,height:26,showArea:!0,showTooltip:!0})}),e.jsxs("div",{className:"flex gap-3 text-[10px] mb-1.5",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Packets"}),e.jsx("span",{className:"data-box data-box-compact",children:(null==g?void 0:g.frequency)||0})]}),s&&void 0!==h&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"SNR"}),e.jsxs("span",{className:"data-box data-box-compact",children:[h.toFixed(1)," dB"]})]}),k&&v.networkRole&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Role"}),e.jsx(iA,{color:NA[v.networkRole],compact:!0,title:{hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"}[v.networkRole],children:v.networkRole})]})]}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Adverts"}),e.jsx("span",{className:"data-box data-box-compact",children:b.advert_count||0})]}),s&&void 0!==m&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"RSSI"}),e.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(m)," dBm"]})]}),k&&v.dataConfidence&&e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsx("span",{className:"text-text-muted",children:"Data"}),e.jsx(iA,{color:SA[v.dataConfidence],compact:!0,title:{high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"}[v.dataConfidence],children:v.dataConfidence})]})]}),!k&&p&&e.jsx("button",{onClick:p,className:"p-1 self-start text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:e.jsx(N,{className:"w-3.5 h-3.5"})})]}),k&&e.jsx(_t,{txDelayRec:v,onRemove:p})]});var C}const zt="node-markers-native",Gt="node-markers-layer",Ot="node-markers-layer-local",Ut="marker-standard",Yt="marker-standard-neighbor",Wt="marker-hub",Vt="marker-hub-neighbor",Zt="marker-gateway",Kt="marker-gateway-neighbor",Jt="marker-mobile",Xt="marker-mobile-neighbor",qt="marker-room-server",$t="marker-room-server-neighbor",Ar="marker-local",er="marker-blink-black",tr="marker-blink-black-local",rr="marker-blink",nr="marker-blink-local";function or(A){var e;const t=null==(e=A.contact_type)?void 0:e.toLowerCase();return"room server"===t||"room_server"===t||"room"===t||"server"===t}function ir(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function ar({neighborsWithLocation:t,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:f,openPopupId:d,onOpenPopup:g,onClosePopup:h,onNodeClick:m,blinkingNodes:b}){const{current:p}=I(),v=A.useRef(!1),[w,x]=A.useState(!1);A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e)return;const t=()=>{try{!function(A){const e=mA(),t=(A,e,t=0,r=!1)=>{const n=document.createElement("canvas");n.width=32,n.height=32;const o=n.getContext("2d",r?{colorSpace:"display-p3"}:void 0),i=14-t/2;return o.beginPath(),o.arc(16,16,i,0,2*Math.PI),o.fillStyle=A,o.fill(),e&&t>0&&(o.strokeStyle=e,o.lineWidth=2*t,o.stroke()),o.shadowColor="rgba(0,0,0,0.3)",o.shadowBlur=4,o.shadowOffsetY=2,{data:o.getImageData(0,0,32,32),pixelRatio:2}},r=(A,e=!1)=>{const t=document.createElement("canvas");t.width=48,t.height=48;const r=t.getContext("2d",e?{colorSpace:"display-p3"}:void 0),n=24*.35*2;return r.strokeStyle=A,r.lineWidth=5,r.lineCap="round",r.lineJoin="round",r.beginPath(),r.moveTo(24-n,24),r.lineTo(24,24-n),r.lineTo(40.8,24),r.stroke(),r.beginPath(),r.moveTo(24-.7*n,24),r.lineTo(24-.7*n,35.76),r.lineTo(35.76,35.76),r.lineTo(35.76,24),r.stroke(),r.beginPath(),r.moveTo(20.64,35.76),r.lineTo(20.64,27.36),r.lineTo(27.36,27.36),r.lineTo(27.36,35.76),r.stroke(),{data:r.getImageData(0,0,48,48),pixelRatio:2}},n=(A,e)=>{const t=document.createElement("canvas");t.width=48,t.height=48;const r=t.getContext("2d"),n=24*.35*2;return r.strokeStyle=A,r.lineWidth=5,r.lineCap="round",r.lineJoin="round",e&&(r.fillStyle=e),r.beginPath(),r.roundRect(24-n,24-.6*n,1.6*n,1.2*n,6),e&&r.fill(),r.stroke(),r.beginPath(),r.moveTo(18.96,34.08),r.lineTo(24-.6*n,40.8),r.lineTo(24,34.08),r.stroke(),{data:r.getImageData(0,0,48,48),pixelRatio:2}},o="#00FF00",i={[Ut]:t(e.nodeFill),[Yt]:t(e.neighborColor),[Wt]:t(e.hubColor),[Vt]:t(e.neighborColor),[Zt]:t(e.gatewayColor),[Kt]:t(e.neighborColor),[Jt]:t("transparent",e.mobileColor,2.5),[Xt]:t(e.neighborColor),[qt]:n(e.roomColor),[$t]:n(e.neighborColor,"#1a1a1c"),[Ar]:r(e.localColor),[er]:t("#000000"),[tr]:r("#000000"),[rr]:t(o,void 0,0,!0),[nr]:r(o,!0)};for(const[a,s]of Object.entries(i))A.hasImage(a)&&A.removeImage(a),A.addImage(a,s.data,{pixelRatio:s.pixelRatio})}(e),v.current=!0,w||x(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{e.hasImage(Ut)||t()};e.on("styledata",r);const n=()=>{v.current=!1,t()},o=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(n,100);break}});o.observe(document.documentElement,{attributes:!0});const i=document.querySelector("[data-basemap]");let a=null;return i&&(a=new MutationObserver(A=>{for(const e of A)if("data-basemap"===e.attributeName){setTimeout(n,100);break}}),a.observe(i,{attributes:!0})),()=>{e.off("styledata",r),o.disconnect(),null==a||a.disconnect()}},[p,w]);const y=A.useMemo(()=>{var A;const e=[],r=[...t].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return or(e)?5e3:o.has(A)?3e3:a.hubNodes.includes(A)?2e3:(null==(t=a.gatewayNodes)?void 0:t.includes(A))?1e3:0};return n(A,e)-n(t,r)});for(const[t,s]of r){if(!s.latitude||!s.longitude)continue;if(n&&((n.startsWith("0x")?n.slice(2,4).toLowerCase():n.slice(0,2).toLowerCase())===(t.startsWith("0x")?t.slice(2,4).toLowerCase():t.slice(0,2).toLowerCase())||t===n))continue;const r=u(t),l=c(t,r);if(l<=.01)continue;const f=o.has(t),d=a.hubNodes.includes(t),g=(null==(A=a.gatewayNodes)?void 0:A.includes(t))??!1,h=a.mobileNodes.includes(t),m=or(s),b=a.centrality.get(t)||0,p=i.get(t),v="stale"===(null==p?void 0:p.status),w=v?Math.min(l,.5):l;let x="standard";m?x="roomServer":d?x="hub":g?x="gateway":h&&(x="mobile");const y=a.fullAffinity.get(t),k=a.txDelayRecommendations.get(t);e.push({type:"Feature",geometry:{type:"Point",coordinates:[s.longitude,s.latitude]},properties:{hash:t,name:s.node_name||s.name||"Unknown",hashPrefix:ir(t),iconType:x,isNeighbor:f,isHub:d,isGateway:g,isMobile:h,isRoomServer:m,isStale:v,isZeroHop:f,opacity:w,blinkIntensity:0,lastSeenTimestamp:null==p?void 0:p.lastSeen,centrality:b,neighborJson:JSON.stringify(s),affinityJson:y?JSON.stringify(y):void 0,txDelayRecJson:k?JSON.stringify(k):void 0,meanSnr:(null==p?void 0:p.avgSnr)??void 0,meanRssi:(null==p?void 0:p.avgRssi)??void 0}})}return{type:"FeatureCollection",features:e}},[t,n,o,i,a,c,u]),k=A.useMemo(()=>(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)?{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[r.longitude,r.latitude]},properties:{hash:"local",name:r.name,hashPrefix:n?ir(n):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]}:{type:"FeatureCollection",features:[]},[r,n]),C=A.useCallback(A=>{var e;if(!A.features||0===A.features.length)return;const t=null==(e=A.features[0].properties)?void 0:e.hash;t&&(g&&g(t),m&&"local"!==t&&m(t))},[g,m]),B=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;const r=null==(e=null==p?void 0:p.getMap)?void 0:e.call(p);r&&(r.getCanvas().style.cursor="pointer");const n=null==(t=A.features[0].properties)?void 0:t.hash;n&&l(n)},[p,l]),M=A.useCallback(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);e&&(e.getCanvas().style.cursor=""),l(null)},[p,l]);A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e||!w)return;const t=[Gt,Ot];for(const r of t)e.on("click",r,C),e.on("mouseenter",r,B),e.on("mouseleave",r,M);return()=>{for(const A of t)e.off("click",A,C),e.off("mouseenter",A,B),e.off("mouseleave",A,M)}},[p,w,C,B,M]);const D=A.useRef(y),E=A.useRef(k);A.useEffect(()=>{D.current=y,E.current=k},[y,k]),A.useEffect(()=>{var A;const e=null==(A=null==p?void 0:p.getMap)?void 0:A.call(p);if(!e||!w||!b||0===b.size)return;const t=e.getSource(zt),r=e.getSource(`${zt}-local`);if(t||r){if(t){const A=D.current;let e=!1;const r=A.features.map(A=>{const t=b.get(A.properties.hash)??0;return t!==A.properties.blinkIntensity?(e=!0,{...A,properties:{...A.properties,blinkIntensity:t}}):A});e&&t.setData({type:"FeatureCollection",features:r})}if(r&&n){const A=b.get(n)??0,e=E.current;e.features.length>0&&e.features[0].properties.blinkIntensity!==A&&r.setData({type:"FeatureCollection",features:[{...e.features[0],properties:{...e.features[0].properties,blinkIntensity:A}}]})}}},[p,w,b,n]);const Q=A.useMemo(()=>{if(!d)return null;if("local"===d&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=y.features.find(A=>A.properties.hash===d);if(!A)return null;const e=A.properties,t=e.txDelayRecJson?JSON.parse(e.txDelayRecJson):void 0;return{longitude:A.geometry.coordinates[0],latitude:A.geometry.coordinates[1],isLocal:!1,hash:e.hash,hashPrefix:e.hashPrefix,name:e.name,isHub:e.isHub,isGateway:e.isGateway,isBackbone:"backbone"===(null==t?void 0:t.networkRole),isZeroHop:e.isZeroHop,isMobile:e.isMobile,isRoomServer:e.isRoomServer,isStale:e.isStale,lastSeenTimestamp:e.lastSeenTimestamp,centrality:e.centrality,neighbor:e.neighborJson?JSON.parse(e.neighborJson):void 0,affinity:e.affinityJson?JSON.parse(e.affinityJson):void 0,txDelayRec:t,meanSnr:e.meanSnr,meanRssi:e.meanRssi}},[d,r,n,y]);if(!w)return null;const j=mA(),N=["case",[">",["get","blinkIntensity"],.66],rr,[">",["get","blinkIntensity"],.33],er,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],$t,qt],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],Vt,Wt],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],Kt,Zt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],Xt,Jt],["case",["get","isNeighbor"],Yt,Ut]],S=["interpolate",["linear"],["zoom"],6,.25,10,1];return e.jsxs(e.Fragment,{children:[e.jsx(R,{id:zt,type:"geojson",data:y,children:e.jsx(_,{id:Gt,type:"symbol",layout:{"icon-image":N,"icon-size":S,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),e.jsx(R,{id:`${zt}-local`,type:"geojson",data:k,children:e.jsx(_,{id:Ot,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],nr,[">",["get","blinkIntensity"],.33],tr,Ar],"icon-size":S,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),Q&&h&&e.jsx(Y,{longitude:Q.longitude,latitude:Q.latitude,offset:{center:[0,0],top:[0,12],"top-left":[6,12],"top-right":[-6,12],bottom:[0,-12],"bottom-left":[6,-12],"bottom-right":[-6,-12],left:[12,0],right:[-12,0]},maxWidth:"280px",closeOnClick:!0,onClose:h,className:"maplibre-popup",children:Q.isLocal?e.jsxs("div",{className:"text-sm",children:[e.jsx("strong",{className:"text-base",children:Q.name}),Q.hash&&e.jsx("span",{className:"ml-2 font-mono text-xs text-text-muted bg-surface-elevated px-1.5 py-0.5 rounded",children:ir(Q.hash)}),e.jsx("br",{}),e.jsx("span",{style:{color:j.localColor},className:"font-medium",children:"This Node (Local)"}),e.jsx("br",{}),r&&e.jsxs("span",{className:"text-xs text-text-muted",children:[r.latitude.toFixed(5),", ",r.longitude.toFixed(5)]})]}):Q.neighbor&&Q.hash?e.jsx(Ht,{hash:Q.hash,hashPrefix:Q.hashPrefix,name:Q.name,isHub:Q.isHub,isGateway:Q.isGateway,isBackbone:Q.isBackbone,isZeroHop:Q.isZeroHop,isMobile:Q.isMobile,isRoomServer:Q.isRoomServer,isStale:Q.isStale,lastSeenTimestamp:Q.lastSeenTimestamp,centrality:Q.centrality,affinity:Q.affinity,meanSnr:Q.meanSnr,meanRssi:Q.meanRssi,neighbor:Q.neighbor,txDelayRec:Q.txDelayRec,onRemove:f?()=>f(Q.hash,Q.name):void 0}):null})]})}const sr=[Gt,Ot];A.createContext(null);const lr="topology-validated-edges-native",cr="topology-weak-edges-native",ur="neighbor-edges-native",fr="topology-weak-edges-native",dr="topology-validated-edges-native",gr="neighbor-edges-native",hr={type:"FeatureCollection",features:[]},mr={"line-cap":"round","line-join":"round"},br={"line-color":"transparent","line-width":16,"line-opacity":0};function pr({showTopology:t,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,highlightedFocusEdges:i,onEdgeHover:a,onLoopHover:s,loops:l=[],neighborNames:c={},opacityBias:u=.5,widthMultiplier:f=1,trafficFilter:d=0,showNeighborLines:g=!0,disableHover:h=!1}){const{current:m}=I(),b=t||r,p=!0,v=g?"visible":"none",w=h||r,x=A.useRef(null),y=A.useRef(w),k=A.useRef(new Map),C=A.useRef(c),B=A.useRef(s);A.useLayoutEffect(()=>{y.current=w,C.current=c,B.current=s});const M=A.useMemo(()=>function(A){const e=new Map;for(const t of A)for(const A of t.edgeKeys){const r=e.get(A)??[];r.push(t),e.set(A,r)}return e}(l),[l]);A.useLayoutEffect(()=>{k.current=M},[M]);const D=A.useCallback(A=>{var e,t;if(y.current)return;if(!A.features||0===A.features.length)return;const r=A.features[0].properties;if(!(null==r?void 0:r.key))return;const n=r.key;if(n!==x.current){x.current=n;const o=!0===r.isNeighborEdge||"true"===r.isNeighborEdge,i=!0===r.isLoopEdge||"true"===r.isLoopEdge;if(o){const t={key:n,fromName:"Local",toName:r.name,certainCount:Number(r.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};a(n,[A.lngLat.lng,A.lngLat.lat],t),null==(e=B.current)||e.call(B,null)}else if(i&&B.current){const e=k.current.get(n)??[];if(e.length>0){const t=new Set;for(const A of e)for(const e of A.edgeKeys)t.add(e);const r={loops:e,highlightedEdgeKeys:t,hoveredEdgeKey:n,nodeNames:e[0].nodes.map(A=>C.current[A]||A.substring(0,4))};B.current(r,[A.lngLat.lng,A.lngLat.lat]),a(n)}else{const e={key:n,fromName:r.fromName,toName:r.toName,certainCount:Number(r.certainCount),confidence:Number(r.confidence),isBackbone:!0===r.isBackbone||"true"===r.isBackbone,isLoopEdge:!0,isDirectPath:!0===r.isDirectPath||"true"===r.isDirectPath,isZeroHop:!0===r.isZeroHop||"true"===r.isZeroHop,symmetryRatio:Number(r.symmetryRatio),dominantDirection:r.dominantDirection,isHubConnection:!0===r.isHubConnection||"true"===r.isHubConnection};a(n,[A.lngLat.lng,A.lngLat.lat],e)}}else{const e={key:n,fromName:r.fromName,toName:r.toName,certainCount:Number(r.certainCount),confidence:Number(r.confidence),isBackbone:!0===r.isBackbone||"true"===r.isBackbone,isLoopEdge:i,isDirectPath:!0===r.isDirectPath||"true"===r.isDirectPath,isZeroHop:!0===r.isZeroHop||"true"===r.isZeroHop,symmetryRatio:Number(r.symmetryRatio),dominantDirection:r.dominantDirection,isHubConnection:!0===r.isHubConnection||"true"===r.isHubConnection};a(n,[A.lngLat.lng,A.lngLat.lat],e),null==(t=B.current)||t.call(B,null)}}},[a]),E=A.useCallback(()=>{var A;null!==x.current&&(x.current=null,a(null),null==(A=B.current)||A.call(B,null))},[a]);A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e||!b)return;const t="topology-validated-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,D),e.on("mouseleave",t,E),!0);if(!n()){const A=()=>{n()&&e.off("styledata",A)};return e.on("styledata",A),()=>{try{e.off("styledata",A),r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}},[m,b,D,E]),A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e||!g)return;const t="neighbor-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,D),e.on("mouseleave",t,E),!0);if(!n()){const A=()=>{n()&&e.off("styledata",A)};return e.on("styledata",A),()=>{try{e.off("styledata",A),r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,D),e.off("mouseleave",t,E))}catch{}}},[m,p,g,D,E]),A.useEffect(()=>{var A;const e=null==(A=null==m?void 0:m.getMap)?void 0:A.call(m);if(!e)return;let t=null;const r=(A,t)=>{try{if(e.getLayer(A)&&e.getLayer(t))return e.moveLayer(A,t),!0}catch{}return!1},n=()=>{try{if(!e.getLayer("node-markers-layer"))return;r(gr,"node-markers-layer"),r("neighbor-edges-hitarea-native",gr),(r(dr,"neighbor-edges-hitarea-native")||r(dr,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",dr),r(fr,"topology-validated-edges-hitarea-native")}catch{}},o=()=>{t&&clearTimeout(t),t=setTimeout(n,50)},i=setTimeout(n,100);e.on("styledata",o);const a=A=>{(A.sourceId===lr||A.sourceId===cr||A.sourceId===ur)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[m,b,p,g]);const Q=w?null:n,j=function(A,e,t,r,n,o){const i=LA(),a=null!==A,s=n&&n.size>0,l=o&&o.size>0,c=s?Array.from(n):[],u=l?Array.from(o):[],f=e<=0?["get","baseColor"]:["case",[">=",["get","brightnessScore"],1-.5*e],"#FFFFFF",["get","baseColor"]],d=e<=0?1:["max",.1,["+",1,["*",e,3,["-",["get","brightnessScore"],.5]]]],g=s?["in",["get","key"],["literal",c]]:l?["in",["get","key"],["literal",u]]:!!a&&["==",["get","key"],A],h=a||s||l,m=i.edges.hoverLoop??"#A78BFA";return{"line-color":h?["case",g,s?m:l?"#FFD700":["get","hoverColor"],f]:f,"line-width":h?["case",g,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,h?["case",g,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],d,.35]]:["*",["get","baseOpacity"],d]]}}(Q,u,f,d,w?null:o,i??null),N=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=Z,i=["to-number",["get","listenerScore"],0],a=["to-number",["get","loudScore"],0],s=["/",i,["max",["+",i,a],1]],l=["*",["+",.2,["*",["to-number",["get","trafficWeight"],0],.8]],8];return{"line-color":["case",["all",["==",i,0],["==",a,0]],o,[">=",s,.97],r,["<=",s,.03],n,["interpolate",["linear"],s,.03,n,.5,t,.97,r]],"line-width":["interpolate",["linear"],["zoom"],6,e?["case",["==",["get","key"],A],["max",["*",l,.25],1.25],["*",l,.25]]:["*",l,.25],10,e?["case",["==",["get","key"],A],["max",l,5],l]:l],"line-opacity":e?["case",["==",["get","key"],A],1,.35]:.9}}(Q);return e.jsxs(e.Fragment,{children:[b&&e.jsx(R,{id:cr,type:"geojson",data:hr,children:e.jsx(_,{id:fr,type:"line",paint:j,layout:{...mr,visibility:v}})}),b&&e.jsxs(R,{id:lr,type:"geojson",data:hr,children:[e.jsx(_,{id:"topology-validated-edges-hitarea-native",type:"line",paint:br,layout:{...mr,visibility:v}}),e.jsx(_,{id:dr,type:"line",paint:j,layout:{...mr,visibility:v}})]}),e.jsxs(R,{id:ur,type:"geojson",data:hr,children:[e.jsx(_,{id:"neighbor-edges-hitarea-native",type:"line",paint:br,layout:{...mr,visibility:v}}),e.jsx(_,{id:gr,type:"line",paint:N,layout:{...mr,visibility:v}})]})]})}const vr=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function wr({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=I(),o=A.useRef(null);return A.useEffect(()=>{if(!n||!e||e===o.current)return;const A=t.get(e);if(!A)return;const i=n.getMap();i.isMoving()&&i.stop(),o.current=e;const[a,s]=A;n.flyTo({center:[s,a],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{null==r||r()},2600)},[e,t,n,r]),null}function xr({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=I(),i=A.useRef(null);return A.useEffect(()=>{if(!o||!e)return;if(e===i.current)return;i.current=e,n();const A=t.find(A=>A.edge.key===e)||r.find(A=>A.edge.key===e);if(!A)return;if(o.getMap().isMoving())return;const a=(A.from[0]+A.to[0])/2,s=(A.from[1]+A.to[1])/2,l=o.getZoom(),c=Math.max(l,11);o.easeTo({center:[s,a],zoom:c,duration:500})},[e,t,r,o,n]),null}function yr(A,e,t,r=64){const n=[],o=t/6371e3*(180/Math.PI),i=o/Math.cos(e*Math.PI/180);for(let a=0;a<=r;a++){const t=a/r*2*Math.PI,s=A+i*Math.cos(t),l=e+o*Math.sin(t);n.push([s,l])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[n]}}}function kr({ghost:t,neighborCoordinates:r,onHighlightedNeighborsChange:n}){const{current:o}=I(),i=A.useRef(null),a=A.useRef(null),s=A.useMemo(()=>t?new Set(t.commonNeighbors):new Set,[t]);A.useEffect(()=>{null==n||n(s)},[s,n]);const l=A.useMemo(()=>{if(!(null==t?void 0:t.commonNeighbors)||t.commonNeighbors.length<2)return 8e3;let A=0;const e=[];for(const n of t.commonNeighbors){const A=r.get(n);A&&e.push(A)}t.estimatedLocation&&e.push([t.estimatedLocation.lat,t.estimatedLocation.lon]);for(let t=0;tA&&(A=n)}return Math.max(A,2e3)},[t,r]),c=A.useMemo(()=>{if(!(null==t?void 0:t.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:A,lon:e,uncertaintyM:r}=t.estimatedLocation,n=.5*l,o=r>0?r:2e3;return{type:"FeatureCollection",features:[yr(e,A,Math.max(500,Math.min(o,n)))]}},[t,l]);if(A.useEffect(()=>{if(!o)return;const A=o.getMap();if(t&&t.prefix!==a.current){if(a.current=t.prefix,!i.current&&A.getZoom()>3){const e=A.getCenter();i.current={center:[e.lng,e.lat],zoom:A.getZoom(),pitch:A.getPitch(),bearing:A.getBearing()}}const e=[];for(const A of t.commonNeighbors){const t=r.get(A);t&&e.push([t[1],t[0]])}if(t.estimatedLocation&&e.push([t.estimatedLocation.lon,t.estimatedLocation.lat]),e.length>0){const r=()=>{var n;if(A.isMoving())setTimeout(r,100);else if(1===e.length)o.flyTo({center:e[0],zoom:13,duration:1500});else{let A=1/0,r=-1/0,i=1/0,a=-1/0;for(const[t,n]of e)A=Math.min(A,t),r=Math.max(r,t),i=Math.min(i,n),a=Math.max(a,n);if(null==(n=t.estimatedLocation)?void 0:n.uncertaintyM){const e=t.estimatedLocation.uncertaintyM/111e3;A-=e,r+=e,i-=e,a+=e}o.fitBounds([[A,i],[r,a]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:1500})}};setTimeout(r,50)}}if(!t&&null!==a.current&&(a.current=null,i.current)){const e=i.current,t=()=>{A.isMoving()?setTimeout(t,100):(o.flyTo({center:e.center,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,duration:1e3}),i.current=null)};setTimeout(t,50)}},[t,o,r]),!(null==t?void 0:t.estimatedLocation))return null;return e.jsx(R,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:e.jsx(_,{id:"ghost-uncertainty-fill",type:"fill",paint:{"fill-color":"rgba(167, 139, 250, 0.15)","fill-opacity":.8}})})}!function(A){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(A);e&&(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16))}(TA.edges.neighborHover);const Cr={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},Br={longitude:0,latitude:0,zoom:2};function Mr({data:A}){const t=A.subtitle&&"loop"===A.type,r=A.subtitle&&"loop"!==A.type;return e.jsxs("div",{className:"w-[540px]",children:[e.jsxs("div",{className:"flex items-center justify-between h-5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[A.title.icon&&e.jsx("span",{className:`${A.title.color} text-base leading-none flex-shrink-0`,children:A.title.icon}),e.jsx("span",{className:`${A.title.color} font-semibold text-[13px] truncate`,children:A.title.text}),r&&e.jsx("span",{className:`${A.subtitle.color} text-[11px] flex-shrink-0`,children:A.subtitle.text})]}),A.badges.length>0&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:A.badges.map((A,t)=>e.jsx("span",{className:`${A.color} text-[11px] font-medium`,children:A.text},t))})]}),t&&e.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:e.jsx("span",{className:"font-mono text-[10px] text-text-muted truncate block",children:A.subtitle.text})}),e.jsx("div",{className:`flex items-center gap-4 h-4 ${t?"mt-1":"mt-1.5"} text-[11px]`,children:A.stats.map((A,t)=>e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx("span",{className:`font-mono tabular-nums font-semibold ${A.color??"text-text-primary"}`,children:A.value}),e.jsx("span",{className:"text-text-muted ml-1",children:A.label}),A.unit&&e.jsx("span",{className:"text-text-muted/50 ml-0.5",children:A.unit})]},t))})]})}function Dr({neighbors:t,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=sA(),f=lA(),d=cA(),g=uA(),h=fA(),[m,b]=A.useState(!1),p=wt(A=>A.viewState),v=wt(A=>A.toggles),w=wt(A=>A.hasAnalyzed),x=wt(A=>A.setViewState),y=wt(A=>A.setToggle),k=wt(A=>A.setHasAnalyzed),C=dA(A=>A.preloadFromNodes),B=dA(A=>A.isLoading),M=dA(A=>A.terrainGrid),D=n??h,E=A.useMemo(()=>{const A=[];for(const[,e]of Object.entries(t))e.latitude&&e.longitude&&A.push([e.latitude,e.longitude]);return A},[t]),Q=A.useMemo(()=>function(A,e){let t=[...A];if((null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&t.push([e.latitude,e.longitude]),0===t.length)return null;if(1===t.length){const[A,e]=t[0];return{longitude:e,latitude:A,zoom:14}}t=function(A,e){if(A.length<=2)return A;let t,r;if((null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude))t=e.latitude,r=e.longitude;else{let e=0,n=0;for(const[t,r]of A)e+=t,n+=r;t=e/A.length,r=n/A.length}const n=A.map(([A,e])=>{return{pos:[A,e],dist:(n=t,o=r,i=A,a=e,FA(n,o,i,a)/1e3)};var n,o,i,a});n.sort((A,e)=>A.dist-e.dist);const o=n[Math.floor(n.length/2)].dist,i=Math.max(3*o,50),a=n.filter(A=>A.dist<=i).map(A=>A.pos);return a.length<.5*A.length?A:a}(t,e);let r=1/0,n=-1/0,o=1/0,i=-1/0;for(const[d,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,d),i=Math.max(i,d);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let f=16;return u>0&&(f=Math.floor(Math.log2(360/u*1.2)),f=Math.max(1,Math.min(14,f))),f=Math.min(f+1,12),{longitude:a,latitude:s,zoom:f}}(E,r),[E,r]),[j,N]=A.useState(()=>p??Q??Br),S=A.useCallback(A=>{N(A),x(A)},[x]),F=A.useRef(!!p);A.useEffect(()=>{F.current||!Q||p?p&&setTimeout(()=>b(!0),50):(N(Q),x(Q),F.current=!0,setTimeout(()=>b(!0),50))},[Q,p,x]);const[P,T]=A.useState(!1),[L,I]=A.useState(()=>!(v.showTopology&&!g.topologyLoadComplete)&&v.showTopology),[R,_]=A.useState(v.showNeighborLines),[H,z]=A.useState(!1),[G,O]=A.useState(v.showMinCut),[U,Y]=A.useState(be),[Z,J]=A.useState(v.show3DTerrain),[X,q]=A.useState(v.nodeFilter),$=A.useCallback(A=>{I(e=>{const t="function"==typeof A?A(e):A;return y("showTopology",t),t})},[y]),AA=A.useCallback(A=>{_(e=>{const t="function"==typeof A?A(e):A;return y("showNeighborLines",t),t})},[y]),iA=A.useCallback(A=>{O(e=>{const t="function"==typeof A?A(e):A;return y("showMinCut",t),t})},[y]),aA=A.useCallback(A=>{J(e=>{const t="function"==typeof A?A(e):A;return y("show3DTerrain",t),t})},[y]),mA=A.useCallback(A=>{q(A),y("nodeFilter",A)},[y]),[bA,pA]=A.useState(null),[vA,wA]=A.useState(null),[xA,yA]=A.useState(null),[kA]=A.useState(0),[DA]=A.useState(.5),[EA]=A.useState(0),[QA,jA]=A.useState(null),[NA,SA]=A.useState(""),[TA,LA]=A.useState(!1),[RA,_A]=A.useState("fetching"),[HA,zA]=A.useState(!1),[GA,OA]=A.useState(0),[UA,VA]=A.useState(()=>!(w&&!g.topologyLoadComplete)&&w);A.useEffect(()=>{g.topologyLoadComplete||(w&&!UA&&k(!1),v.showTopology&&!L&&y("showTopology",!1))},[w,v.showTopology,g.topologyLoadComplete,UA,L,k,y]);const ZA=A.useCallback(A=>{VA(A),k(A)},[k]),[KA,XA]=A.useState(null),$A=A.useCallback(A=>XA(A),[]),ee=A.useCallback(()=>XA(null),[]),[,te]=A.useState(new Set),re=ce(A=>A.coveragePoints),ne=ce(A=>A.isVisible),oe=ce(A=>A.brightness),ie=ce(A=>A.openModal),ae=ye(A=>A.isEnabled),se=ye(A=>A.toggle),le=CA(),ue=BA(),fe=A.useRef(!1);A.useEffect(()=>{re.length>0&&ne&&!fe.current&&(AA(!1),fe.current=!0)},[re.length,ne]);const de=A.useRef(null);A.useEffect(()=>{if(i&&i!==de.current){de.current=i;const A=setTimeout(()=>{XA(i)},1250);return()=>clearTimeout(A)}},[i]);const[ge,he]=A.useState(null),[pe,ve]=A.useState(null),xe=A.useCallback((A,e,t)=>{wA(A),A&&e&&t?he({longitude:e[0],latitude:e[1],type:"topology",properties:{key:t.key,fromName:t.fromName,toName:t.toName,certainCount:t.certainCount,confidence:t.confidence,isBackbone:t.isBackbone,isLoopEdge:t.isLoopEdge,isDirectPath:t.isDirectPath,isHubConnection:t.isHubConnection,symmetryRatio:t.symmetryRatio,dominantDirection:t.dominantDirection}}):A||he(null)},[]),ke=A.useCallback((A,e)=>{ve(A),A&&he(null)},[]),Ce=A.useMemo(()=>{var A;if(!L)return null;if(!bA)return null;if(vA)return null;const e=u.loops;if(0===e.length)return null;const r=function(A,e,t){const r=function(A,e){return e.filter(e=>e.nodes.includes(A)).sort((A,e)=>e.avgCertainCount-A.avgCertainCount)}(A,e),n=new Set,o=[];for(const i of r)for(const A of i.edgeKeys)if(!n.has(A)){n.add(A);const e=t.get(A);o.push({key:A,certainCount:(null==e?void 0:e.certainCount)??0})}return o.sort((A,e)=>e.certainCount-A.certainCount),{loops:r,highlightedEdgeKeys:n,sortedEdges:o}}(bA,e,u.edgeMap);if(0===r.loops.length)return null;const n=r.loops[0].nodes.map(A=>{var e,r;return A===D?"You":(null==(e=t[A])?void 0:e.node_name)||(null==(r=t[A])?void 0:r.name)||A.substring(0,4)});return{loops:r.loops,highlightedEdgeKeys:r.highlightedEdgeKeys,hoveredEdgeKey:(null==(A=r.sortedEdges[0])?void 0:A.key)||"",nodeNames:n}},[L,bA,vA,u.loops,u.edgeMap,t,D]);A.useEffect(()=>{vA||ve(Ce)},[Ce,vA]);const Be=A.useMemo(()=>{const A={};for(const[e,r]of Object.entries(t))A[e]=r.node_name||r.name||e.substring(0,4);return D&&(A[D]="You"),A},[t,D]),Me=A.useMemo(()=>Object.entries(t).filter(([,A])=>A.latitude&&A.longitude),[t]),De=A.useMemo(()=>{const A=new Map;D&&(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&A.set(D,[r.latitude,r.longitude]);for(const[e,t]of Me)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[D,r,Me]),Ee=A.useMemo(()=>{const A=new Map;for(const e of d)"expired"!==e.status&&A.set(e.hash,{hash:e.hash,prefix:e.prefix,count:e.count,avgRssi:e.avgRssi,avgSnr:e.avgSnr,lastSeen:e.lastSeen,confidence:1,status:e.status});return A},[d]),Qe=A.useMemo(()=>{var A,e;const r=new Set;for(const n of Ee.keys())(null==(A=t[n])?void 0:A.latitude)&&(null==(e=t[n])?void 0:e.longitude)&&r.add(n);return r},[Ee,t]),je=A.useMemo(()=>{if(0===Qe.size||!D)return new Map;const A=tA.getPackets();if(0===A.length)return new Map;const e=nA(D);return K(A,Qe,e).scores},[Qe,D,g.packetCount]),Ne=A.useCallback(A=>!!(D&&(A.fromHash===D&&Qe.has(A.toHash)||A.toHash===D&&Qe.has(A.fromHash))),[D,Qe]),Se=A.useMemo(()=>{var A,e;if(0===d.length||!D)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of d){if("expired"===n.status)continue;if(!(null==(A=t[n.hash])?void 0:A.latitude)||!(null==(e=t[n.hash])?void 0:e.longitude))continue;const o=[D,n.hash].sort(),i=`${o[0]}~${o[1]}`;r.push({fromHash:D,toHash:n.hash,key:i,packetCount:n.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:n.count,isLoopEdge:!1,forwardCount:n.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:n.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:n.avgRssi,avgSnr:n.avgSnr})}return r},[d,D,g.backgroundLoadComplete,t]),Fe=A.useMemo(()=>{const A=[];if(Se.length>0&&!g.backgroundLoadComplete){for(const e of Se){const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(Ne(e))continue;const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,De,Ne,Se,g.backgroundLoadComplete]),Pe=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(Ne(e))continue;const t=De.get(e.fromHash),r=De.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,De,Ne]),Te=A.useMemo(()=>{if(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude))return[];const A=[],e=[r.latitude,r.longitude],n=new Map;for(const t of u.lastHopNeighbors)n.set(t.hash,t.count);const o=new Map;for(const t of d)o.set(t.hash,t.count);for(const r of Qe){const i=t[r];if(!(null==i?void 0:i.latitude)||!(null==i?void 0:i.longitude))continue;const a=o.get(r),s=n.get(r);A.push({from:e,to:[i.latitude,i.longitude],hash:r,neighbor:i,lastHopData:Ee.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,Qe,t,Ee,u.lastHopNeighbors,d]),Le=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),Ie=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),Re=A.useMemo(()=>{if(!xA)return null;const A=u.validatedEdges.filter(A=>A.fromHash===xA||A.toHash===xA);if(0===A.length)return null;const e=[...A].sort((A,e)=>e.certainCount-A.certainCount),t=Math.max(1,Math.ceil(.2*e.length)),r=e.slice(0,t);return new Set(r.map(A=>A.key))},[xA,u.validatedEdges]),_e=A.useMemo(()=>{let A=0;if(Se.length>0&&!g.backgroundLoadComplete){for(const e of Se)e.certainCount>A&&(A=e.certainCount);return A||1}for(const e of u.validatedEdges)e.certainCount>A&&(A=e.certainCount);return A||1},[u.validatedEdges,Se,g.backgroundLoadComplete]),He=A.useMemo(()=>{if(0===u.validatedEdges.length)return null;const A=new Set;for(const r of u.validatedEdges)A.add(r.fromHash),A.add(r.toHash);const e=Array.from(A).filter(A=>De.has(A)).sort();if(e.length<3)return null;const t=new Map;for(const r of e){const A=De.get(r);A&&t.set(r,A)}return function(A,e,t,r){const n=e.length;if(n<3)return{communities:new Map([[0,e]]),nodePartitions:e.map(A=>({hash:A,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:n<=1};const o=[];let i=1/0;const a=[[e,0]];for(;a.length>0;){const[e,n]=a.shift();if((t?it(e,t):0)>20&&n<4&&e.length>=10){const o=at(A,e,t,r);if(o){i=Math.min(i,o.fiedlerValue),a.push([o.group0,n+1]),a.push([o.group1,n+1]);continue}}o.push(e)}const s=new Map,l=[],c=new Map;for(let u=0;u{iA(A=>{const e=!A;if(e&&He&&c.current){const A=c.current.getMap();if(!A)return e;let t=1/0,r=-1/0,n=1/0,o=-1/0,i=!1;for(const[,e]of He.communities)for(const A of e){const e=De.get(A);if(e){const[A,a]=e;n=Math.min(n,A),o=Math.max(o,A),t=Math.min(t,a),r=Math.max(r,a),i=!0}}i&&A.fitBounds([[t,n],[r,o]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return e})},[He,De]),Ge=A.useRef(null);A.useLayoutEffect(()=>{var A,e;Ge.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const Oe=eA(),Ue=A.useMemo(()=>tA.getPackets(),[Oe]);!function({map:e,nodeCoordinates:t,packets:r,localHash:n,neighbors:o,meshTopology:i,enabled:a=!0}){const s=A.useRef(null),l=e&&"current"in e?e.current:e;A.useEffect(()=>{s.current=l},[l]);const c=A.useRef(!1),u=A.useRef(null),f=A.useRef([]),d=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),v=A.useRef(new Map),w=A.useRef(t);A.useEffect(()=>{w.current=t},[t]),A.useEffect(()=>{v.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=nA(r);t.has(A)||t.set(A,r)}if(e){const A=nA(e);t.set(A,e)}return t}(o,n)},[o,n]),A.useEffect(()=>{if(!a){b.current&&(clearTimeout(b.current),b.current=null),p.current=[],null!==u.current&&(cancelAnimationFrame(u.current),u.current=null),f.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(jt);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,d.current=0}},[a]),A.useEffect(()=>{const A=l;if(!A)return;let e=null,t=!1;const r=()=>{if(!t&&!c.current)try{A.getLayer(Nt)&&A.removeLayer(Nt),A.getSource(jt)&&A.removeSource(jt),A.addSource(jt,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Pt)?Pt:void 0;A.addLayer({id:Nt,type:"line",source:jt,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],"#8B7BAD","#12A594"],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],1.875,2.5],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},t),c.current=!0,m(!0),e&&(clearInterval(e),e=null)}catch{}};return A.isStyleLoaded()&&r(),A.once("style.load",()=>{r()}),c.current||(e=setInterval(()=>{c.current?e&&clearInterval(e):r()},100),setTimeout(()=>{e&&(clearInterval(e),e=null)},5e3)),()=>{t=!0,e&&clearInterval(e),null!==u.current&&(cancelAnimationFrame(u.current),u.current=null);const A=s.current;if(A&&c.current){try{A.getLayer(Nt)&&A.removeLayer(Nt),A.getSource(jt)&&A.removeSource(jt)}catch{}c.current=!1,m(!1)}}},[l]);const x=A.useRef(()=>{});A.useEffect(()=>{x.current=()=>{const A=s.current;if(!A)return;const e=A.getSource(jt);if(!e)return;const t=performance.now(),r=f.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ft:St)){o.push(i);const e=i.isSpeculative?Lt(A):Tt(A);e>0&&n.push({type:"Feature",properties:{intensity:e,opacityMult:i.isSpeculative?.5:1,isSpeculative:i.isSpeculative??!1},geometry:{type:"LineString",coordinates:[i.fromCoord,i.toCoord]}})}}e.setData({type:"FeatureCollection",features:n}),f.current=o,o.length>0?u.current=requestAnimationFrame(()=>x.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(Nt))return;const e=A.getLayer(Pt)?Pt:void 0;try{A.moveLayer(Nt,e)}catch{}}(A),null===u.current&&(u.current=requestAnimationFrame(()=>x.current()))},[]),k=A.useCallback(()=>{if(!s.current||!c.current)return;const A=p.current;if(p.current=[],b.current=null,0===A.length)return;const e=v.current,t=w.current;if(0===e.size)return;const r=performance.now();let o=0,a=!1;const l=new Set;for(const s of A){const A=rA(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,d=null;for(let n=0;n0){A.sort((A,e)=>e.confidence-A.confidence);const e=Math.max(1,Math.ceil(.25*A.length)),n=A.slice(0,e),i=o+150*u;for(const{edgeKey:A,otherHash:o}of n){const e=t.get(d),n=t.get(o);f.current.push({edgeKey:A,fromCoord:It(e),toCoord:It(n),startTime:r,delay:i,isSpeculative:!0}),l.add(A),a=!0}}}u>0&&(o+=150*u*.5)}a&&y()},[n,i,y]);A.useEffect(()=>{const A=s.current;if(!a)return;if(!A)return;if(!h)return;if(0===r.length)return;const e=Date.now(),t=d.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A);let n=0;for(const e of r){const A=e.timestamp??0;A>n&&(n=A)}if(d.current=n,t.length>0){t.sort((A,e)=>(A.timestamp??0)-(e.timestamp??0));const A=t.slice(-20);p.current.push(...A),k()}return}const n=r.filter(A=>(A.timestamp??0)>t);if(0===n.length)return;let o=0;for(const r of n){const A=r.timestamp??0;A>o&&(o=A)}d.current=o,p.current.push(...n),b.current&&clearTimeout(b.current),b.current=setTimeout(k,175)},[a,r,k,h]),A.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[])}({map:Ge,nodeCoordinates:De,packets:Ue,localHash:D,neighbors:t,meshTopology:u,enabled:ae});const{isExiting:Ye,isAnimating:We,resetAnimationState:Ve}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:f=[],showNeighborLines:d=!0,neighborSourceId:g,neighborLinkScores:h=new Map,basemapMode:m}){const b=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;b.current=A});const p=A.useRef(new Map),v=A.useRef(1),w=A.useRef(new Map),x=A.useRef(new Map),y=A.useRef(!1),k=A.useRef(null),C=A.useRef(t),B=A.useRef(new Set),M=A.useRef(""),D=A.useRef(new Map),E=A.useRef(""),Q=A.useRef(""),j=A.useRef(""),N=A.useRef(r),S=A.useRef(n),F=A.useRef(o),P=A.useRef(i),T=A.useRef(a),L=A.useRef(s),I=A.useRef(l),R=A.useRef(f),_=A.useRef(d),H=A.useRef(h),z=A.useRef(m);A.useEffect(()=>{N.current=r,S.current=n,F.current=o,P.current=i,T.current=a,L.current=s,I.current=l,R.current=f,_.current=d,H.current=h,z.current=m},[r,n,o,i,a,s,l,f,d,h,m]);const G=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,f;const d=b.current;if(!d)return;const h=d.getSource(c),m=d.getSource(u),y=d.getSource(g);if(h){const o=Bt(N.current,!0,p.current,v.current,w.current,x.current,F.current,P.current,T.current,L.current,I.current,z.current),i=`${o.features.length}:${(null==(t=null==(e=o.features[0])?void 0:e.properties)?void 0:t.key)??""}:${(null==(n=null==(r=o.features[o.features.length-1])?void 0:r.properties)?void 0:n.key)??""}:${Array.from(p.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==E.current)&&(h.setData(o),E.current=i)}if(m){const e=Bt(S.current,!1,p.current,v.current,w.current,x.current,F.current,P.current,T.current,L.current,I.current,z.current),t=`${e.features.length}:${(null==(i=null==(o=e.features[0])?void 0:o.properties)?void 0:i.key)??""}:${(null==(s=null==(a=e.features[e.features.length-1])?void 0:a.properties)?void 0:s.key)??""}`;(A||t!==Q.current)&&(m.setData(e),Q.current=t)}if(y&&R.current.length>0){const e=Mt(R.current,H.current),t=`${e.features.length}:${(null==(f=null==(l=e.features[0])?void 0:l.properties)?void 0:f.hash)??""}`;(A||t!==j.current)&&(y.setData(e),j.current=t)}},[c,u,g]),O=A.useCallback(()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null),p.current=new Map,v.current=1,w.current=new Map,x.current=new Map,y.current=!1,B.current=new Set,M.current="",D.current=new Map},[]);A.useEffect(()=>{const A=C.current,e=t;if(C.current=t,b.current){if(k.current&&(cancelAnimationFrame(k.current),k.current=null),A&&!e&&!y.current){y.current=!0;const A=new Map(p.current);let e=null;const t=r=>{e||(e=r);const n=r-e,o=Math.min(n/500,1),i=(a=o,1-Math.pow(1-a,3));var a;for(const[e,t]of A)p.current.set(e,t*(1-i));G(!0),o<1?k.current=requestAnimationFrame(t):(y.current=!1,p.current=new Map,B.current=new Set,M.current="",w.current=new Map,x.current=new Map,k.current=null,G(!0))};k.current=requestAnimationFrame(t)}!A&&e&&(p.current=new Map,B.current=new Set,M.current="")}},[t,G]),A.useEffect(()=>{const A=b.current;if(!t||y.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===B.current.size,a=""!==M.current&&M.current!==o;if(!i&&!a)return void G();const s=[],l=[];for(const{edge:t}of e)B.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(w.current=new Map(D.current),v.current=0),x.current=new Map;for(const{edge:t}of r){const A=PA(t.certainCount);x.current.set(t.key,A)}for(const t of s)p.current.set(t,0);for(const t of l)p.current.has(t)||p.current.set(t,1);if(s.length>0||a&&l.length>0){k.current&&(cancelAnimationFrame(k.current),k.current=null);let A=null;const e=Math.min(100,IA/Math.max(s.length,1)/2),t=r=>{A||(A=r);const n=r-A;for(let A=0;A0){const A=Math.min(n/IA,1);v.current=Ct(A)}G(!0);const o=IA+(s.length-1)*e;k.current=n{const A=b.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(f.length>0){const A=Mt(f,h);e.setData(A)}else e.setData({type:"FeatureCollection",features:[]});return!0};if(e())return;const t=r=>{r.sourceId===g&&e()&&A.off("sourcedata",t)};A.on("sourcedata",t);const r=()=>{e()&&(A.off("styledata",r),A.off("sourcedata",t))};return A.on("styledata",r),()=>{A.off("sourcedata",t),A.off("styledata",r)}},[g,f,h]);const U=A.useRef(m);return A.useEffect(()=>{m!==U.current&&(U.current=m,E.current="",Q.current="",j.current="",G(!0))},[m,G]),A.useEffect(()=>()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null)},[]),{isExiting:y.current,isAnimating:null!==k.current,resetAnimationState:O,weightAnimProgress:v.current,animStartWeights:w.current,animTargetWeights:x.current}}({map:Ge,showTopology:L,validatedPolylines:Fe,weakPolylines:Pe,maxCertainCount:_e,loopEdgeKeys:Le,backboneEdgeKeys:Ie,highlightedEdgeKey:s,neighbors:t,validatedSourceId:lr,weakSourceId:cr,neighborPolylines:Te,showNeighborLines:R,neighborSourceId:ur,neighborLinkScores:je,basemapMode:le}),Ke=A.useMemo(()=>{const A=new Set;for(const e of u.hubNodes){A.add(e);for(const t of u.validatedEdges)t.fromHash===e&&A.add(t.toHash),t.toHash===e&&A.add(t.fromHash)}return A},[u.hubNodes,u.validatedEdges]),Je=A.useMemo(()=>{const A=new Set;if(!n)return A;for(const e of u.validatedEdges)e.fromHash===n&&A.add(e.toHash),e.toHash===n&&A.add(e.fromHash);return A},[n,u.validatedEdges]),{getNodeOpacity:Xe}=function({soloDirect:e,soloHubs:t,neighborHashes:r,hubConnectedNodes:n,directNodeSet:o,localConnectedNodes:i,showTopology:a}){const[s,l]=A.useState(new Map),c=A.useRef(e),u=A.useRef(t),f=A.useRef(new Map),d=A.useRef(null),g=A.useRef(n),h=A.useRef(o),m=A.useRef(i),b=A.useRef(a);return A.useEffect(()=>{g.current=n,h.current=o,m.current=i,b.current=a},[n,o,i,a]),A.useEffect(()=>{const A=c.current,n=u.current,o=e,i=t;if(c.current=e,u.current=t,A===o&&n===i)return;d.current&&(cancelAnimationFrame(d.current),d.current=null);const a=g.current,s=h.current,p=m.current,v=b.current;for(const e of r)f.current.has(e)||f.current.set(e,Math.random());const w=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=v&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},x=[];for(const e of r){const t=w(e,A,n),r=w(e,o,i);t!==r&&x.push({hash:e,startOpacity:t?1:0,targetOpacity:r?1:0})}if(0===x.length)return;l(A=>{const e=new Map(A);for(const{hash:t,startOpacity:r}of x)e.set(t,r);return e});const y=x;let k=null;const C=A=>{k||(k=A);const e=A-k;let t=!0;l(()=>{const A=new Map;for(const{hash:r,startOpacity:n,targetOpacity:o}of y){const i=250*(f.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Dt(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?d.current=requestAnimationFrame(C):(d.current=null,l(new Map))};return d.current=requestAnimationFrame(C),()=>{d.current&&(cancelAnimationFrame(d.current),d.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===X,soloHubs:"hubs"===X,neighborHashes:Me.map(([A])=>A),hubConnectedNodes:Ke,directNodeSet:Qe,localConnectedNodes:Je,showTopology:L}),{blinkingNodes:qe,blinkColor:$e}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=eA(),a=A.useRef(tA.getPackets());A.useEffect(()=>{a.current=tA.getPackets()},[i]);const s=A.useRef(0),l=A.useRef(null),c=A.useRef(new Map),u=A.useRef(new Map);A.useEffect(()=>{u.current=function(A){const e=new Map;for(const t of Object.keys(A)){const A=nA(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const f=A.useRef(null);return A.useEffect(()=>{f.current=()=>{const A=performance.now(),e=c.current;if(0===e.size)return l.current=null,void o(new Map);const t=new Map,r=[];for(const[n,{startTime:o,staggerDelay:i}]of e){const e=A-o-i;if(e<0);else if(e>=750)r.push(n);else{const A=Et(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&f.current?l.current=requestAnimationFrame(f.current):l.current=null}},[]),A.useEffect(()=>{if(!r)return;const A=a.current;if(0===A.length)return;const e=s.current,n=A.filter(A=>(A.timestamp??0)>e);if(0===e){const e=A.reduce((A,e)=>Math.max(A,e.timestamp??0),0);return void(s.current=e)}if(0===n.length)return;const o=n.reduce((A,e)=>Math.max(A,e.timestamp??0),0);s.current=o;const i=performance.now();let d=0;for(const r of n){const A=rA(r,t);if(!A||0===A.original.length)continue;const e=Qt(A.original,u.current,t);if(0===e.length)continue;const n=375;for(let t=0;t()=>{null!==l.current&&(cancelAnimationFrame(l.current),l.current=null)},[]),{blinkingNodes:n,blinkColor:"#00FF00"}}({neighbors:t,localHash:n,enabled:ae}),et=A.useCallback(A=>{if("all"===X)return!0;if("direct"===X)return Qe.has(A);if("hubs"===X){if(u.hubNodes.includes(A))return!0;for(const e of u.validatedEdges){if(e.fromHash===A&&u.hubNodes.includes(e.toHash))return!0;if(e.toHash===A&&u.hubNodes.includes(e.fromHash))return!0}return!1}return!0},[X,Qe,u.hubNodes,u.validatedEdges]);A.useEffect(()=>{"fetching"===RA&&(g.loadProgress?OA(g.loadProgress.loaded):g.packetCount>0&&OA(g.packetCount))},[RA,g.loadProgress,g.packetCount]);const tt=A.useCallback(async()=>{zA(!0),LA(!0),_A("fetching"),OA(0),await f(),_A("analyzing"),await new Promise(A=>setTimeout(A,200)),_A("building");const A=Date.now(),e=Date.now()-A;e<1700&&await new Promise(A=>setTimeout(A,1700-e)),_A("complete"),await new Promise(A=>setTimeout(A,1e3)),LA(!1),zA(!1),Ve(),ZA(!0),setTimeout(()=>{$(!0)},150)},[f,Ve]),rt=A.useCallback(()=>{UA?$(A=>!A):tt()},[UA,tt]),nt=A.useCallback(A=>{S(A.viewState),(A.viewState.pitch??0)>10&&!Z&&aA(!0)},[Z]),ot=A.useCallback(()=>{T(A=>{var e,t,r,n,o,i,a;const s=!A,l=null==(r=null==(t=null==(e=c.current)?void 0:e.getContainer())?void 0:t.closest(".map-container-fullscreen, .map-container-16-9"))?void 0:r.parentElement;return s?l&&document.fullscreenEnabled?null==(n=l.requestFullscreen)||n.call(l).catch(()=>{}):l&&document.webkitFullscreenEnabled&&(null==(o=l.webkitRequestFullscreen)||o.call(l)):document.fullscreenElement?null==(i=document.exitFullscreen)||i.call(document).catch(()=>{}):document.webkitFullscreenElement&&(null==(a=document.webkitExitFullscreen)||a.call(document)),s})},[]),st=A.useCallback(A=>{mA(A)},[]),lt=A.useCallback(()=>{AA(A=>!A)},[]),ct=A.useCallback(()=>{z(A=>!A)},[]),ut=A.useCallback(()=>{aA(A=>{const e=!A;if(c.current){const A=c.current.getMap();A&&A.stop()}if(e&&c.current){const A=c.current.getMap();A&&A.easeTo({pitch:45,duration:1500,easing:A=>1-Math.pow(1-A,3)})}if(!e&&c.current){const A=c.current.getMap();A&&A.easeTo({pitch:0,bearing:0,duration:800,easing:A=>1-Math.pow(1-A,2)})}return e})},[]),ft=A.useCallback(()=>{L||$(!0)},[L]),dt=A.useCallback((A,e)=>{jA(A),SA(e)},[]),gt=A.useCallback(()=>{QA&&o&&o(QA),jA(null),SA("")},[QA,o]),ht=A.useMemo(()=>[...vr,...sr],[]),mt=A.useRef(!1);A.useEffect(()=>{mt.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const bt=A.useCallback(A=>{A.features&&0!==A.features.length||(mt.current&&ge&&(he(null),wA(null)),xA&&yA(null))},[ge,xA]),vt=A.useCallback(A=>{yA(e=>e===A?null:A)},[]),xt=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;if(A.features.some(A=>{var e,t;return null==(t=null==(e=A.layer)?void 0:e.id)?void 0:t.startsWith("node-markers-")}))return void(vA&&(wA(null),he(null)));const r=A.features.find(A=>{var e;const t=null==(e=A.layer)?void 0:e.id;return(null==t?void 0:t.startsWith("topology-"))||(null==t?void 0:t.startsWith("neighbor-"))});if(!r)return;const n=null==(e=r.layer)?void 0:e.id,o=r.properties;if(!(null==o?void 0:o.key))return;const i=null==n?void 0:n.startsWith("topology-"),a=null==n?void 0:n.startsWith("neighbor-");if(i||a){const e=o.key.replace(/-loop[12]$/,"");wA(e),A.lngLat&&he({longitude:A.lngLat.lng,latitude:A.lngLat.lat,type:i?"topology":"neighbor",properties:o})}try{(null==(t=c.current)?void 0:t.getCanvas())&&(c.current.getCanvas().style.cursor="pointer")}catch{}},[vA]),yt=A.useCallback(()=>{var A;wA(null),he(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),kt=P?"map-container-fullscreen":"map-container-16-9",Rt=E.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),_t=!m||!Rt,Ht=Rt;return e.jsxs("div",{className:`relative ${kt}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":le,children:[e.jsx("span",{id:"map-instructions",className:"sr-only",children:"Interactive map showing mesh network contacts. Use mouse or touch to pan and zoom. Press Tab to navigate map controls. Press Escape to exit fullscreen mode."}),_t&&e.jsx("div",{className:"absolute inset-0 z-50 glass-card flex items-center justify-center","aria-hidden":"true",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),Ht&&e.jsx("div",{className:`relative w-full h-full ${P?"":"rounded-[1.125rem] overflow-hidden"} ${_t?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:e.jsxs(W,{ref:c,...j,onMove:nt,mapStyle:Cr,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:ht,onMouseMove:xt,onMouseLeave:yt,onClick:bt,onError:A=>{},onIdle:()=>{if(!M&&!B&&c.current){const A=c.current.getMap();if(A){const e=Object.values(t).filter(A=>A.latitude&&A.longitude).map(A=>({latitude:A.latitude,longitude:A.longitude}));(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&e.push({latitude:r.latitude,longitude:r.longitude}),e.length>0&&C(e,A)}}},children:[e.jsx(V,{position:"bottom-right"}),e.jsx(MA,{mode:le}),e.jsx(At,{enabled:Z,exaggeration:4}),e.jsx(Ze,{coveragePoints:re,visible:re.length>0&&ne,terrainEnabled:Z,brightness:oe,basemapMode:le}),e.jsx(pt,{partition:He,nodeCoordinates:De,visible:G&&UA,opacity:U.opacity,bandwidth:U.bandwidth,threshold:U.threshold,strokeWidth:U.strokeWidth}),e.jsx(pr,{showTopology:L,isExiting:Ye,hoveredEdgeKey:vA,highlightedLoopEdges:null==pe?void 0:pe.highlightedEdgeKeys,highlightedFocusEdges:Re,onEdgeHover:xe,onLoopHover:ke,loops:u.loops,neighborNames:Be,opacityBias:kA,widthMultiplier:DA,trafficFilter:EA,showNeighborLines:R,disableHover:We||HA}),i&&e.jsx(wr,{targetHash:i,nodeCoordinates:De,onComplete:a}),s&&e.jsx(xr,{highlightedEdgeKey:s,validatedPolylines:Fe,weakPolylines:Pe,onEnsureTopology:ft}),e.jsx(kr,{ghost:l??null,neighborCoordinates:De,onHighlightedNeighborsChange:te}),e.jsx(ar,{neighborsWithLocation:Me,localNode:r,localHash:n,zeroHopNeighbors:Qe,lastHopNeighborMap:Ee,meshTopology:u,hoveredMarker:bA,onMarkerHover:pA,getNodeOpacity:Xe,shouldShowNode:et,onRequestRemove:o?dt:void 0,openPopupId:KA,onOpenPopup:$A,onClosePopup:ee,onNodeClick:vt,blinkingNodes:qe,blinkColor:$e})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"hops",value:A.size},{label:"seen",value:A.minCertainCount}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`+${t-1} overlapping`,color:"text-violet-400/70"}),{type:"loop",title:{icon:"⟳",text:"Redundant Path"+(t>1?"s":""),color:"text-violet-400"},subtitle:{text:`${e.nodeNames.join(" → ")} → ${e.nodeNames[0]}`,color:"text-text-secondary",mono:!0},stats:r,badges:n}}if("neighbor"===(null==A?void 0:A.type)){const e=A.properties,t=[];void 0!==e.rssi&&null!==e.rssi&&t.push({label:"RSSI",value:`${Math.round(e.rssi)} dBm`,unit:e.hasAvgRssi?"avg":void 0}),void 0!==e.snr&&null!==e.snr&&t.push({label:"SNR",value:`${Number(e.snr).toFixed(1)} dB`,unit:e.hasAvgSnr?"avg":void 0});const r=e.listenerScore??0,n=e.loudScore??0,o=r>0||n>0;return o&&(t.push({label:"listener",value:r,color:"text-accent-success"}),t.push({label:"loud",value:n,color:"text-accent-danger"})),void 0===e.packetCount||o||t.push({label:"packets",value:Number(e.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:e.prefix?`${e.name} (${e.prefix})`:e.name,color:"text-amber-400"},subtitle:{text:"Direct RF Neighbor",color:"text-amber-400/70"},stats:t,badges:[]}}if("topology"===(null==A?void 0:A.type)){const e=A.properties,r=t>0?Number(e.certainCount)/t:0,n=[{label:"validations",value:e.certainCount},{label:"of max traffic",value:`${Math.round(100*r)}%`},{label:"confidence",value:`${Math.round(100*Number(e.confidence))}%`}];if(void 0!==e.symmetryRatio&&e.symmetryRatio<1){const A="forward"===e.dominantDirection?"→":"reverse"===e.dominantDirection?"←":"↔";n.push({label:"symmetric",value:`${A} ${Math.round(100*e.symmetryRatio)}%`,color:"text-text-muted"})}const o=[];return e.isBackbone&&o.push({text:"Backbone",color:"text-gray-300"}),e.isLoopEdge&&o.push({text:"Redundant",color:"text-violet-400"}),e.isDirectPath&&o.push({text:"Direct Path",color:"text-teal-400"}),{type:"topology",title:{icon:"",text:`${e.fromName} ↔ ${e.toName}`,color:"text-text-primary"},stats:n,badges:o}}return null}(ge?{type:ge.type,properties:ge.properties}:null,pe,_e);return A&&e.jsx("div",{className:"map-edge-tooltip",children:e.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:e.jsx(Mr,{data:A})})})})(),e.jsx(WA,{mapRef:c,showNeighborLines:R,onToggleNeighborLines:lt,hasNeighborPolylines:Te.length>0,nodeFilter:X,onNodeFilterChange:st,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:Qe.size>0,showCoverage:H,onToggleCoverage:ct,showMinCut:G,onToggleMinCut:ze,hasMinCutData:UA&&null!==He&&He.numCommunities>1,show3DTerrain:Z,onToggle3DTerrain:ut,basemapMode:le,onToggleBasemap:ue,isFullscreen:P,onToggleFullscreen:ot}),e.jsxs("div",{className:"map-legend-stack",children:[e.jsx(JA,{isActive:L,hasAnalyzed:UA,isLoading:HA,onClick:rt}),e.jsx(qA,{isActive:ae,onClick:se}),e.jsx(Ae,{isActive:re.length>0&&ne,onClick:ie}),e.jsx(YA,{showTopology:L,validatedPolylineCount:Fe.length,filteredNeighborCount:Me.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:Qe,neighborsWithLocation:Me})]}),!P&&e.jsx("div",{className:"glass-card-frame absolute inset-0 pointer-events-none rounded-[1.125rem]",style:{zIndex:9999},"aria-hidden":"true"}),e.jsx(gA,{isOpen:null!==QA,onCancel:()=>jA(null),onConfirm:gt,title:"Remove Node?",message:`Remove "${NA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),e.jsx(hA,{isOpen:TA,currentStep:RA,packetCount:GA}),e.jsx(me,{}),e.jsx(we,{visible:G&&UA,onClose:()=>iA(!1),settings:U,onSettingsChange:Y,partition:He,totalNodes:Object.keys(t).length})]})}export{Dr as default}; diff --git a/frontend/dist/assets/Dashboard-BIMfl_CK.js b/frontend/dist/assets/Dashboard-DiETwG01.js similarity index 99% rename from frontend/dist/assets/Dashboard-BIMfl_CK.js rename to frontend/dist/assets/Dashboard-DiETwG01.js index a3debffc..c50a92ca 100644 --- a/frontend/dist/assets/Dashboard-BIMfl_CK.js +++ b/frontend/dist/assets/Dashboard-DiETwG01.js @@ -1 +1 @@ -import{r as e,j as t,V as s,Y as a,Z as n,_ as l,$ as i,a0 as r,E as o,L as c,a1 as d,U as u,a2 as m,a3 as h,a4 as x,a5 as f,a6 as p,a7 as v,a8 as g,a9 as j,aa as b,ab as N,ac as y,ad as k}from"./vendor-react-C341c8YC.js";import{B as w,S as M,u as L,c as _,d as S,e as C,w as F,L as B,f as R,h as D,j as T,D as A,k as $,m as P,n as I,T as H,o as E,p as W,q,r as z,t as O,F as K}from"./index-CPdqYR4z.js";import{u as G,a as V}from"./useThemeColors-AeHMyThq.js";import{C as U,S as J,a as Q,P as X,b as Y}from"./PageLayout-CcoYWyzO.js";import{P as Z}from"./PacketList-CnSxB7Jy.js";import{T as ee}from"./TimeRangeSelector-DGCfekAv.js";import{s as te}from"./SignalIndicator-BLrEkFNb.js";import{R as se,L as ae,Y as ne,u as le,A as ie,C as re,X as oe,T as ce,v as de}from"./recharts-6XUQYgRA.js";import{c as ue}from"./link-scoring-BNnTohl3.js";import{N as me}from"./NodeInformationCard-D-IeNCCX.js";import{R as he,C as xe}from"./Grid-BOO-7ObJ.js";import{C as fe}from"./Card-BeZKc0xw.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./channel-keys-DJWRrSwE.js";import"./DataBox-CRX76VsB.js";const pe={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},ve=/([,\.:\/])/g,ge=e.memo(function({children:s,className:a="",as:n="span"}){const l=e.useMemo(()=>{let e;return e="number"==typeof s?s.toLocaleString():Array.isArray(s)?s.join(""):String(s??""),ve.test(e)?(ve.lastIndex=0,e.split(ve).map((e,s)=>{const a=pe[e];return a?t.jsx("span",{className:a,children:e},s):e})):e},[s]);return t.jsx(n,{className:`data-tight ${a}`.trim(),children:l})}),je={received:{barBase:"var(--metric-received)"},forwarded:{barBase:"var(--metric-forwarded)"},transmitted:{barBase:"var(--metric-transmitted)"},dropped:{barBase:"var(--metric-dropped)"},neutral:{barBase:"var(--metric-neutral)"}},be={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function Ne({buckets:s,colorType:a}){const n=je[a].barBase,l=e.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=M.statsCard,t=s.length/e,a=t<=1?s:Array.from({length:e},(e,a)=>{var n,l;const i=s.slice(Math.floor(a*t),Math.floor((a+1)*t)),r=i.reduce((e,t)=>e+t.count,0),o=i.length?i.reduce((e,t)=>e+t.avg_snr,0)/i.length:0;return{bucket:a,start:(null==(n=i[0])?void 0:n.start)??0,end:(null==(l=i.at(-1))?void 0:l.end)??0,count:r,airtime_ms:i.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),l=a.map(e=>e.count).filter(e=>e>0);if(0===l.length)return a.map(()=>({height:0,bottom:0,color:"transparent",count:0,snr:0}));const i=Math.max(...l),r=Math.min(...l),o=i-r;return 0===o?a.map(e=>({height:e.count>0?40:0,bottom:e.count>0?30:0,color:e.count>0?n:"transparent",count:e.count,snr:e.avg_snr})):a.map(e=>{if(0===e.count)return{height:0,bottom:0,color:"transparent",count:0,snr:e.avg_snr};const t=(e.count-r)/o,s=15*t;return{height:Math.max(30,30+50*t),bottom:s,color:n,count:e.count,snr:e.avg_snr}})},[s,n]);return(null==s?void 0:s.length)?t.jsx("div",{className:"w-full h-full flex items-end pt-1",children:l.map((e,s)=>{var a;return t.jsx("div",{className:"flex-1 relative min-w-0",style:{height:"100%"},children:t.jsx("div",{className:"absolute inset-x-0",style:{height:`${e.height}%`,bottom:`${e.bottom}%`,backgroundColor:e.color,opacity:e.count>0?.8:.1},title:e.count>0?`${e.count} packets, SNR: ${null==(a=e.snr)?void 0:a.toFixed(1)}dB`:"No packets"})},s)})}):t.jsx("div",{className:"w-full h-full flex items-end justify-center gap-[2px] opacity-20",children:t.jsx("span",{className:"type-data-xs text-text-secondary",children:"No data"})})}function ye({title:s,value:a,color:n="neutral",subtitle:l,buckets:i,receivedCount:r,timeRangeLabel:o,icon:c,size:d="md",isLoaded:u=!0}){const m="string"==typeof a?a:a.toLocaleString(),h=e.useMemo(()=>function(e){if(!(null==e?void 0:e.length))return null;const t=e.reduce((e,t)=>e+t.count,0),s=e[0].start,a=e[e.length-1].end,n=Math.max((a-s)/3600,1),l=Math.round(t/n);let i=0,r=0;for(let d=0;dr&&(r=e[d].count,i=d);const o=new Date(1e3*e[i].start).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),c=e.filter(e=>e.count>0&&0!==e.avg_snr);return{total:t,ratePerHour:l,peakCount:r,peakHour:o,avgSnr:c.length>0?c.reduce((e,t)=>e+t.avg_snr,0)/c.length:null}}(i),[i]),x="number"==typeof a?a:(null==h?void 0:h.total)??0,f=r&&r>0?(x/r*100).toFixed(1):null;return u?t.jsxs("div",{className:`data-card flex flex-col relative ${be[d]}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[c&&t.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),t.jsx("span",{className:"type-micro",children:s}),o&&t.jsx(w,{color:"teal",className:"hidden sm:inline-flex",children:o})]}),t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:m})}),t.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:i?t.jsx(Ne,{buckets:i,colorType:n}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx("div",{className:"w-full h-0.5 rounded-full bg-text-muted/15"})})}),t.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:t.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Rate"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[(null==h?void 0:h.ratePerHour)??l??"—","/hr"]})]}),null!==f?t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"dropped"===n?"Drop %":"Ratio"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[f,"%"]})]}):(null==h?void 0:h.peakHour)?t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Peak"}),t.jsx("div",{className:"data-box data-box-fill data-box-left",children:h.peakHour})]}):null]})})]}):t.jsx("div",{className:`data-card flex flex-col relative ${be[d]}`,children:t.jsx(U,{})})}const ke=.2;function we(e,t=1){return Math.floor(5*t*e)}function Me(e){const t=Math.round(e/ke)*ke;return Math.max(0,Math.min(5,t))}function Le({stats:o,receivedBuckets:c,droppedBuckets:d,forwardedBuckets:u,bucketDurationSeconds:m,timeRangeLabel:h,isLoaded:x=!0}){var f,p,v,g;const[j,b]=e.useState(!1);if(!x)return t.jsx("div",{className:"data-card flex flex-col relative",children:t.jsx(U,{})});const N=function(e,t,s,a,n){var l,i;const r=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=r(t),c=r(s),d=r(a),u=o||(null==e?void 0:e.rx_count)||1,m=c||(null==e?void 0:e.dropped_count)||0,h=u>0?m/(u+m)*100:0;let x=0;if((null==a?void 0:a.length)&&n)x=100*d/(a.length*n*1e3)*100;else if(e){const t=1e3*(e.uptime_seconds||1);x=(e.total_airtime_ms||e.airtime_used_ms||0)/t*100}const f=(null==e?void 0:e.neighbors)??{},p=Object.values(f).filter(e=>e.zero_hop).length;let v=1;h<3?v-=ke:h>15?v+=.4:h>10&&(v+=ke),x>5&&(v+=ke),p>10&&(v+=ke);const g=Me(v),j=Me(.28*g),b=we(g),N=we(j),y=we((null==(i=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:i.tx_delay_factor)??1);return{floodFactor:g,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b{const e=`set txdelay ${N.floodFactor.toFixed(1)}\nset direct.txdelay ${N.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(e),b(!0),setTimeout(()=>b(!1),1500)}catch(t){const s=document.createElement("textarea");s.value=e,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy"),b(!0),setTimeout(()=>b(!1),1500)}catch{}document.body.removeChild(s)}},className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-white/[0.02] rounded-lg transition-colors p-1 -m-1 group",title:"Click to copy CLI commands",children:[t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-hero text-text-primary",children:t.jsxs(ge,{children:["×",N.floodFactor.toFixed(1)]})}),t.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide mt-0.5 sm:mt-1",children:"Flood"})]}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-hero text-accent-tertiary",children:t.jsxs(ge,{children:["×",N.directFactor.toFixed(1)]})}),t.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide mt-0.5 sm:mt-1",children:"Direct"})]}),t.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:j?t.jsx(i,{className:"w-4 h-4 text-green-400"}):t.jsx(r,{className:"w-4 h-4 text-text-muted"})})]}),t.jsx("div",{className:"flex-1 py-2",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Dupe"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left "+(N.duplicateRate>10?"text-accent-warning":""),children:[N.duplicateRate.toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"TX Util"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[N.txUtilization.toFixed(2),"%"]})]})]})}),t.jsxs("div",{className:"pt-2 mt-2",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:null!==y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"data-box",children:["×",y.toFixed(2)]}),t.jsxs("div",{className:"data-box",style:{color:"var(--accent-tertiary)"},children:["×",(null==k?void 0:k.toFixed(2))??"—"]})]}):t.jsx("span",{className:"text-sm text-text-muted",children:"No config"})})]})]})}function _e(){const s=L(),a=_(),n=S(),l=C(),[i,r]=e.useState([]);e.useEffect(()=>{const e=F.subscribe(e=>{r(e)});return r(F.getPendingPackets()),e},[]);const u=e.useMemo(()=>{const e=s.length<=100?s:s.slice(-100),t=new Set(e.map(e=>e.packet_hash));return[...i.filter(e=>!t.has(e.packet.packet_hash)).map(e=>({...e.packet,isPending:!0})),...e].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,i]),m=null==l?void 0:l.local_hash,h=null==l?void 0:l.neighbors;return t.jsxs("div",{className:"chart-container h-full flex flex-col !overflow-visible",children:[t.jsxs("div",{className:"chart-header",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(o,{className:"chart-title-icon"}),"Recent Packets"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx(B,{showLabel:!0}),t.jsxs(c,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(d,{className:"w-3 h-3"})]})]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:t.jsx(Z,{packets:u,allPackets:s,localHash:m,neighbors:h,loading:a,maxPackets:50,showPagination:!1,flashNewest:!0,emptyMessage:"No packets received",footerAction:t.jsxs(c,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(d,{className:"w-3 h-3"})]})})})]})}const Se=e.memo(function({active:e,payload:s,label:a,formatValue:n,labelKey:l}){var i;if(!e||!(null==s?void 0:s.length))return null;const r=l&&(null==(i=s[0])?void 0:i.payload)?s[0].payload[l]:a;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[r&&t.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:r}),t.jsx("div",{className:"space-y-1.5",children:s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:e.name}),t.jsx("span",{className:"type-data-sm text-white tabular-nums",children:n?n(e.value,e.name):e.value.toLocaleString()})]},s))})]})});e.memo(function({active:e,payload:s,color:a,labelKey:n,unit:l=""}){var i,r;if(!e||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(i=null==o?void 0:o.payload)?void 0:i[n];return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[t.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a}}),t.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(r=null==o?void 0:o.value)?void 0:r.toLocaleString(),l]})]})]})}),e.memo(function({payload:e}){return(null==e?void 0:e.length)?t.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:e.value})]},s))}):null});const Ce={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Fe({trend:e}){return t.jsx("span",{className:`mini-widget-trend ${e}`,children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Ce[e]})})})}function Be(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Re({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function De({title:e,icon:s,value:a,unit:n,valueSize:l="md",status:i,subtitle:r,trend:o,children:c,isLoading:d=!1,error:u,className:m="",onClick:h}){const x=["mini-widget-value","lg"===l&&"mini-widget-value-lg","sm"===l&&"mini-widget-value-sm"].filter(Boolean).join(" "),f=["mini-widget",h&&"cursor-pointer",m].filter(Boolean).join(" ");return t.jsxs("div",{className:f,onClick:h,role:h?"button":void 0,children:[t.jsxs("div",{className:"mini-widget-header",children:[s,t.jsx("span",{className:"mini-widget-title",children:e}),i&&"unknown"!==i&&t.jsx("div",{className:`mini-widget-status-dot ${i}`}),o&&t.jsx(Fe,{trend:o})]}),d?t.jsx(Be,{}):u?t.jsx(Re,{message:u}):t.jsxs(t.Fragment,{children:[void 0!==a&&t.jsxs("div",{className:x,children:[t.jsx(ge,{children:a}),n&&t.jsx("span",{className:"mini-widget-unit",children:n})]}),r&&t.jsx("div",{className:"mini-widget-subtitle",children:r}),c]})]})}const Te={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Ae={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function $e(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),a=t/100*(s.length-1),n=Math.floor(a),l=Math.ceil(a);return n===l?s[n]:s[n]+(s[l]-s[n])*(a-n)}function Pe(e){return $e(e,50)}function Ie(e){if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(Number).filter(e=>!isNaN(e))}catch{}return[]}function He(e){return null!=e&&0!==e&&!Object.is(e,-0)&&!(e>-50||e<-130)}function Ee(e,t,s=2,a=!1){if(null===t)return"stable";const n=e-t;return(0!==t?100*Math.abs(n/t):Math.abs(n))0?"up":"down":n>0?"down":"up"}const We={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:Ae,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},qe=e.createContext(We);function ze({children:s}){var a;const n=C(),l=L(),i=R(),r=D(),o=T(),c=A[o],d=Math.max(1,c.minutes/60),u=null===n,m=e.useMemo(()=>function(e,t){const s=3600*t,a=Math.floor(Date.now()/1e3)-s,n=e.filter(e=>e.timestamp>=a&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),l=n.length,i=n.filter(e=>(e.lbt_attempts??0)>1).length,r=l>0?i/l*100:0,o=n.filter(e=>(e.lbt_attempts??0)>1),c=o.length>0?o.reduce((e,t)=>e+(t.lbt_attempts??0),0)/o.length:0,d=n.filter(e=>(e.lbt_attempts??0)>=5).length,u=l>0?d/l*100:0,m=[];for(const b of n){const e=Ie(b.lbt_backoff_delays_ms);m.push(...e)}const h=m.reduce((e,t)=>e+t,0),x=m.length>0?h/m.length:0,f=m.length>0?Math.min(...m):0,p=m.length>0?Math.max(...m):0,v=s/24,g=[],j=[];for(let b=0;b<24;b++){const e=a+b*v,t=e+v,s=n.filter(s=>s.timestamp>=e&&s.timestamp(e.lbt_attempts??0)>1).length,i=s.length>0?l/s.length*100:0,r=[];for(const a of s){const e=Ie(a.lbt_backoff_delays_ms);r.push(...e)}const o=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;if(g.push(o),0===s.length)j.push(0);else{const e=s.filter(e=>(e.lbt_attempts??0)>=5).length,t=r.length>0?Math.max(...r):0,a=Math.min(s.length/5,1),n=.15,l=Math.log(1+i*n)/Math.log(1+100*n)*40,c=e/s.length*100,d=Math.min(.5*c,25);let u=0;o>100&&(u=Math.min(8*Math.log10(o/100),15));let m=0;t>500&&o>0&&t>2*o&&(m=Math.min((t-500)/200,5));const h=l+d+u+m;j.push(Math.min(h*a,85))}}return{totalPacketsWithLBT:l,packetsWithRetries:i,retryRate:r,avgRetries:c,channelBusyCount:d,channelBusyRate:u,avgBackoffMs:x,minBackoffMs:f,maxBackoffMs:p,totalBackoffMs:h,sparklineBackoff:g,sparklineCollisionRisk:j,windowHours:t,packetCount:e.length}}(l,d),[l,d]),h=(null==n?void 0:n.noise_floor_dbm)??null,x=e.useMemo(()=>He(h)?h:null,[h]),f=e.useMemo(()=>{var e;const t=null==(e=null==n?void 0:n.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(a=null==n?void 0:n.config)?void 0:a.radio]),[p,v]=e.useState([]),g=e.useRef({time:0,hours:0});e.useEffect(()=>{const e=async()=>{var e;const t=Date.now(),s=Math.ceil(d);if(0===g.current.time||g.current.hours!==s||t-g.current.time>=6e4){g.current={time:t,hours:s};try{const t=await $(Math.max(s,24));t.success&&(null==(e=t.data)?void 0:e.history)&&v(t.data.history)}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[d]);const j=e.useMemo(()=>function(e,t){if(0===e.length)return[];const s=e.reduce((e,t)=>Math.max(e,t.timestamp),0);if(0===s)return[];const a=3600*t,n=s-a,l=a/24,i=[];for(let r=0;r<24;r++){const t=n+r*l,s=t+l,a=e.filter(e=>e.timestamp>=t&&e.timestamp0){const e=a.reduce((e,t)=>e+t.noise_floor_dbm,0)/a.length;i.push(e)}else i.push(i.length>0?i[i.length-1]:-100)}return i}(p,d),[p,d]),b=null==n?void 0:n.neighbors,N=e.useMemo(()=>{const e=b??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)))},[b,r]),y=e.useMemo(()=>i.filter(e=>!r.has(e.hash)),[i,r]),k=e.useMemo(()=>function(e){if(0===e.length)return{...Ae,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),a=e.length>0?[e[e.length-1]]:[],n=e.slice(-4).filter(e=>Number.isFinite(e)),l=Pe(s),i=$e(s,10),r=$e(s,90),o=Pe(a),c=null!==o&&null!==i?o-i:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,a=0,n=0,l=0;const i=e[0].timestamp;for(const o of e){const e=(o.timestamp-i)/3600,t=o.value;s+=e,a+=t,n+=e*t,l+=e*e}const r=t*l-s*s;return Math.abs(r)<1e-4?0:(t*n-s*a)/r}(n.map((e,s)=>({timestamp:t-3600*(n.length-1-s),value:e}))),u=function(e){if(e.length<2)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length,s=e.map(e=>Math.pow(e-t,2)).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(s)}(n),m=s.length>=12,[h,x]=m?function(e,t,s){const a=Te;return e>=a.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=a.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:i,baselineP90:r,currentMedian:o,currentSampleCount:a.length,delta:c,slope:d,jitter:u,penalty:h,penaltyReason:x,computedAt:t,isReliable:m}}(j),[j]),w=e.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const a=e.map(e=>{const a=function(e,t,s){const a=te(e,t,s,0);if(a)switch(a.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const n=void 0===e?50:e>=10?100:e>=5?80:e>=0?60:e>=-5?40:20,l=void 0===t?50:t>=-70?100:t>=-80?80:t>=-90?60:t>=-100?40:20;return Math.round(.6*n+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),n=t[e.hash];return{name:(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:a,advertCount:e.count}});a.sort((e,t)=>t.score-e.score);const n=a.length>0?a.reduce((e,t)=>e+t.score,0)/a.length:0;return{neighbors:a,networkScore:Math.round(n),neighborCount:a.length,bestLink:a.length>0?{name:a[0].name,score:a[0].score}:null,worstLink:a.length>0?{name:a[a.length-1].name,score:a[a.length-1].score}:null}}(y,N,f),[y,N,f]),M=e.useMemo(()=>function(e,t,s){const a=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let n=50;null!==t&&(n=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,i=Math.round(.35*a+.25*n+.4*l);let r;return r=i>=85?"excellent":i>=70?"good":i>=50?"fair":i>=30?"congested":"critical",{score:i,status:r,components:{lbtHealth:Math.round(a),noiseHealth:Math.round(n),linkHealth:Math.round(l)}}}(m,x,w),[m,x,w]),[_,S]=e.useState({noiseFloor:null,networkScore:null,channelHealth:null}),F=e.useRef(0);e.useEffect(()=>{const e=()=>{const e=Date.now();e-F.current>3e4&&(F.current=e,S({noiseFloor:x,networkScore:(null==w?void 0:w.networkScore)??null,channelHealth:(null==M?void 0:M.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[x,null==w?void 0:w.networkScore,null==M?void 0:M.score]);const B=e.useMemo(()=>({noiseFloor:{current:x,previous:_.noiseFloor,trend:null!==x?Ee(x,_.noiseFloor,2,!0):"stable"},networkScore:{current:(null==w?void 0:w.networkScore)??0,previous:_.networkScore,trend:Ee((null==w?void 0:w.networkScore)??0,_.networkScore,3,!1)},channelHealth:{current:(null==M?void 0:M.score)??0,previous:_.channelHealth,trend:Ee((null==M?void 0:M.score)??0,_.channelHealth,3,!1)}}),[x,null==w?void 0:w.networkScore,null==M?void 0:M.score,_]),P={lbtStats:m,noiseFloor:x,sparklineNoiseFloor:j,linkQuality:w,channelHealth:M,nfTrend:k,radioConfig:f,trends:B,stats:n,recentPackets:l,quickNeighbors:i,isLoading:u,error:null,refresh:async()=>{}};return t.jsx(qe.Provider,{value:P,children:s})}function Oe(){const t=e.useContext(qe);if(void 0===t)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function Ke(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function Ge(){const{lbtStats:s,isLoading:a,error:n}=Oe(),l=u(),i=(null==s?void 0:s.avgBackoffMs)??0,r=(null==s?void 0:s.retryRate)??0,o=s?(c=i)<100?"excellent":c<250?"good":c<500?"fair":c<1e3?"congested":"critical":"unknown";var c;const d=null==s?void 0:s.sparklineBackoff,{chartData:h,yDomain:x}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,100]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,100]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,.1*a,10);return{chartData:e,yDomain:[Math.max(0,s-l),a+l]}},[d]);return t.jsx(De,{title:"LBT Backoff",icon:t.jsx(m,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:o,subtitle:s?Ke(i,r):void 0,isLoading:a,error:n,onClick:()=>l("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline",children:h.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:h,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:x,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ve(e){return 0===e?"—":e<1?"<1":Math.round(e).toString()}function Ue(){const{lbtStats:e,isLoading:s,error:a}=Oe(),n=u(),l=(null==e?void 0:e.channelBusyCount)??0,i=(null==e?void 0:e.totalPacketsWithLBT)??0,r=(null==e?void 0:e.channelBusyRate)??0,o=(null==e?void 0:e.retryRate)??0,c=(null==e?void 0:e.avgBackoffMs)??0,d=(null==e?void 0:e.minBackoffMs)??0,m=(null==e?void 0:e.maxBackoffMs)??0,x=o>0?Math.max(0,(o-r)/o*100):100;return t.jsx(De,{title:"Ch. Busy",icon:t.jsx(h,{className:"mini-widget-icon"}),isLoading:s,error:a,onClick:()=>n("/packets"),children:t.jsx("div",{className:"flex-1 flex items-end",children:t.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-2 w-full items-baseline",children:[t.jsx("span",{className:"data-box-label mb-0",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[t.jsx(ge,{children:l}),t.jsx("span",{className:"text-text-muted punc-slash",children:"/"}),t.jsx(ge,{children:i})]}),t.jsx("span",{className:"data-box-label mb-0",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),t.jsx("div",{className:"data-box justify-self-start",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:t.jsxs(ge,{children:[x.toFixed(0),"%"]})}),t.jsx("span",{className:"data-box-label mb-0",title:`Average LBT backoff delay: ${c.toFixed(0)}ms.`,children:"Mean:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Average LBT backoff delay: ${c.toFixed(0)}ms.`,children:[t.jsx(ge,{children:Ve(c)}),t.jsx("span",{className:"text-text-muted text-xs",children:"ms"})]}),t.jsx("span",{className:"data-box-label mb-0",title:`Backoff range: ${d.toFixed(0)}ms min, ${m.toFixed(0)}ms max.`,children:"Range:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Backoff range: ${d.toFixed(0)}ms min, ${m.toFixed(0)}ms max.`,children:[t.jsx(ge,{children:Ve(d)}),t.jsx("span",{className:"text-text-muted punc-slash",children:"/"}),t.jsx(ge,{children:Ve(m)})]})]})})})}function Je(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}function Qe(){const{noiseFloor:s,sparklineNoiseFloor:a,trends:n,isLoading:l,error:i}=Oe(),r=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==n?void 0:n.noiseFloor.trend,{chartData:d,yDomain:u}=e.useMemo(()=>{if(!a||a.length<2)return{chartData:[],yDomain:[-120,-90]};const e=a.map(e=>({value:e})),t=a.filter(e=>-100!==e&&e<-50);if(0===t.length)return{chartData:e,yDomain:[-120,-90]};const s=Math.min(...t),n=Math.max(...t),l=n-s,i=Math.max(.2*l,3);return{chartData:e,yDomain:[s-i,n+i]}},[a]);return t.jsx(De,{title:"Noise Floor",icon:t.jsx(x,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:r,trend:c,subtitle:Je(s),isLoading:l,error:i,children:t.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:u,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Xe(){const s=u(),a=R(),n=L(),l=C(),i=T(),r=60*A[i].minutes,o=P(),c=e.useMemo(()=>{if(0===o)return n;const e=o-r;return n.filter(t=>t.timestamp>=e)},[n,r,o]),d=null===l,m=(null==l?void 0:l.local_hash)?I(l.local_hash):"",h=(null==l?void 0:l.neighbors)??{},{neighborHashes:x,neighborNames:j}=e.useMemo(()=>{const e=new Set,t=new Map;for(const s of a){e.add(s.hash);const a=h[s.hash],n=(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||s.prefix;t.set(s.hash,n)}return{neighborHashes:e,neighborNames:t}},[a,h]),b=e.useMemo(()=>{if(0===x.size||0===c.length||!m)return{champion:null,listener:null,loudest:null};const{scores:e}=ue(c,x,m),t=[];for(const[l,i]of e)0!==i.blendedScore&&t.push({...i,name:j.get(l)??I(l)});let s=null,a=null,n=null;for(const l of t)(!s||l.blendedScore>s.blendedScore)&&(s=l),(!a||l.listenerScore>a.listenerScore)&&(a=l),(!n||l.loudScore>n.loudScore)&&(n=l);return{champion:s,listener:a,loudest:n}},[c,x,m,j]),{champion:N,listener:y,loudest:k}=b,w=N||y||k?t.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[N&&t.jsx(H,{content:(M=N,t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",M.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",M.blendedScore,t.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",M.listenerScore,"/100 (",M.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",M.loudScore,"/100 (",M.loudCount," packets relayed)"]})]})]})),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(f,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),t.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:N.name}),t.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:N.blendedScore})]})}),y&&t.jsx(H,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.listenerCount," packets where they heard your transmissions"]})})]}))(y),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:y.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:y.listenerScore})]})}),k&&t.jsx(H,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.loudCount," packets they relayed directly to you"]})})]}))(k),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(v,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:k.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:k.loudScore})]})})]}):0===a.length?t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var M;return t.jsx(De,{title:"Link Leaders",icon:t.jsx(g,{className:"mini-widget-icon"}),isLoading:d,onClick:()=>s("/contacts"),children:w})}function Ye(){const{lbtStats:s,isLoading:a,error:n}=Oe(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:a,avgBackoffMs:n,maxBackoffMs:l}=e;if(0===a)return 0;const i=Math.min(a/10,1),r=Math.log(1+.15*t)/Math.log(16)*40,o=s/a*100,c=Math.min(.5*o,25);let d=0;n>100&&(d=Math.min(8*Math.log10(n/100),15));let u=0;l>500&&n>0&&l>2*n&&(u=Math.min((l-500)/200,5));const m=(r+c+d+u)*i;return Math.min(m,85)}(s):0,i=s?(r=l)<15?"excellent":r<30?"good":r<45?"fair":r<60?"congested":"critical":"unknown";var r;const o=(null==s?void 0:s.maxBackoffMs)??0,c=s?o>200?`Max backoff: ${Math.round(o)}ms`:function(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}(l):void 0,d=null==s?void 0:s.sparklineCollisionRisk,{chartData:u,yDomain:m}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,85]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,85]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,5);return{chartData:e,yDomain:[Math.max(0,s-l),Math.min(85,a+l)]}},[d]);return t.jsx(De,{title:"Collision Risk",icon:t.jsx(j,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:i,subtitle:c,isLoading:a,error:n,children:t.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:m,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ze(){const[s,a]=e.useState(!1),[n]=e.useState(0),{stats:l,lbtStats:i,isLoading:r}=Oe(),c=e.useMemo(()=>{if(!l)return null;const e=l.airtime_used_ms??0,t=l.max_airtime_ms??1;return{usedMs:e,maxMs:t,remainingMs:l.airtime_remaining_ms??0,utilizationPercent:l.utilization_percent??(t>0?e/t*100:0)}},[l]),d=e.useMemo(()=>i&&0!==i.totalPacketsWithLBT?(i.totalPacketsWithLBT-i.packetsWithRetries)/i.totalPacketsWithLBT*100:100,[i]),u=(null==c?void 0:c.utilizationPercent)??0,m=(h=u)<30?"excellent":h<50?"good":h<70?"fair":h<90?"congested":"critical";var h;const x=(null==c?void 0:c.remainingMs)??0,f=d<95?`${d.toFixed(0)}% clean TX`:((p=x)<1e3?`${Math.round(p)}ms`:p<6e4?`${(p/1e3).toFixed(1)}s`:`${(p/6e4).toFixed(1)}m`)+" remaining";var p;const v=c?t.jsx("div",{className:"mini-widget-progress mt-auto",children:t.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return t.jsx(De,{title:"Duty Cycle",icon:t.jsx(o,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:f,isLoading:r,children:v})}function et(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(J,{className:"w-4 h-4"}),t.jsx(J,{className:"h-3 w-16"})]}),t.jsx(J,{className:"h-7 w-12 mt-2"}),t.jsx(J,{className:"h-3 w-20 mt-2"})]})}function tt(){return t.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((e,s)=>t.jsx(et,{},s))})}function st({className:e="",isLoaded:s=!0}){return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(b,{className:"w-4 h-4 text-accent-primary"}),t.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?t.jsx(ze,{children:t.jsxs("div",{className:"widget-row",children:[t.jsx(Ge,{}),t.jsx(Ye,{}),t.jsx(Qe,{}),t.jsx(Ze,{}),t.jsx(Ue,{}),t.jsx(Xe,{})]})}):t.jsx(tt,{})]})}function at(){var s,n;const l=C(),i=E(),r=L(),o=W(),c=T(),d=q(),u=z(),m=A[c],h=5===c&&!u.threeDayLoadComplete,x=6===c&&!u.sevenDayLoadComplete,f=7===c&&!u.fourteenDayLoadComplete,p=u.isBackgroundLoading&&(h||x||f),v=G(),g=V(),j=null==(s=null==l?void 0:l.config)?void 0:s.radio,b=e.useMemo(()=>j?{sf:j.spreading_factor??10,bw:j.bandwidth??25e4,cr:j.coding_rate??5,preamble:j.preamble_length??8}:null,[j]),M=r.length,_=e.useMemo(()=>M?O(m.minutes,m.buckets,r,l):null,[M,m.minutes,m.buckets,b]),S=e.useMemo(()=>function(e,t,s){if(!(null==e?void 0:e.length))return[];const a=s<=1440?{hour:"2-digit",minute:"2-digit",hour12:!1}:s<=4320?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{weekday:"short",hour:"numeric",hour12:!1};return e.map((e,n)=>{var l;let i=new Date(1e3*e.start).toLocaleString([],a);return s>4320&&(i=i.replace(/(\d+)$/,"$1h")),{time:i,received:e.count,unique:(null==(l=null==t?void 0:t[n])?void 0:l.count)??0}})}(null==_?void 0:_.received,null==_?void 0:_.unique_received,m.minutes),[null==_?void 0:_.received,null==_?void 0:_.unique_received,m.minutes]),F=e.useMemo(()=>function(e){if(!e.length)return[0,"auto"];let t=0;for(const s of e)s.received>t&&(t=s.received),s.unique>t&&(t=s.unique);return[0,t||1]}(S),[S]),B=e.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==_?void 0:_.received),s=e(null==_?void 0:_.unique_received),a=e(null==_?void 0:_.forwarded),n=e(null==_?void 0:_.dropped),l=e(null==_?void 0:_.transmitted),i=((null==_?void 0:_.time_range_minutes)??m.minutes)/60;return{received:t,uniqueReceived:s,forwarded:a,dropped:n,transmitted:l,rxPerHour:i>0?Math.round(t/i):0,fwdPerHour:i>0?Math.round(a/i):0}},[_,m.minutes]),R=(null==l?void 0:l.node_name)??(null==(n=null==l?void 0:l.config)?void 0:n.node_name)??"Unknown Node";return i?t.jsxs(Q,{className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-white/50",children:i}),t.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(X,{children:[t.jsx(Y,{title:R,icon:t.jsx(N,{}),controls:t.jsx(ee,{ranges:A,selectedIndex:c,onSelect:d,isPending:p})}),t.jsx(he,{template:"hero",children:t.jsx(Q,{isLoaded:o,skeletonType:"chart",compact:!0,children:o&&t.jsxs(t.Fragment,{children:[t.jsx(fe,{icon:t.jsx(a,{}),title:"RECEIVED",badge:m.label,actions:t.jsxs("div",{className:"data-box",children:[B.rxPerHour,"/hr"]})}),t.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:B.received})}),t.jsx(w,{color:"green",className:"mb-0.5 sm:mb-1",children:"Total RF"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:B.uniqueReceived})}),t.jsx(w,{color:"blue",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),t.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-8 dashboard-chart-height",children:S.length>0?t.jsx(se,{width:"100%",height:"100%",children:t.jsxs(ie,{data:S,margin:{left:0,right:8,top:0,bottom:0},children:[t.jsx(re,{strokeDasharray:"3 3",stroke:g.grid,vertical:!1}),t.jsx(oe,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:g.axisTick,fontSize:10,fontFamily:K},dy:8,interval:"preserveStartEnd",minTickGap:60}),t.jsx(ne,{domain:F,axisLine:!1,tickLine:!1,tick:{fill:g.axisTick,fontSize:10,fontFamily:K},dx:-4,width:28}),t.jsx(ce,{content:t.jsx(Se,{labelKey:"time"}),cursor:{stroke:g.cursor,strokeWidth:1}}),t.jsx(de,{type:"stepAfter",dataKey:"received",name:"Total RF",stroke:"none",fill:v.received,fillOpacity:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:v.received},isAnimationActive:!1}),t.jsx(de,{type:"stepAfter",dataKey:"unique",name:"Unique",stroke:"none",fill:v.forwarded,fillOpacity:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:v.forwarded},isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),t.jsxs(he,{template:"compact",children:[t.jsx(xe,{span:6,lg:4,children:t.jsx(ye,{title:"FORWARDED",value:B.forwarded,color:"forwarded",buckets:null==_?void 0:_.forwarded,receivedCount:B.received,timeRangeLabel:m.label,icon:t.jsx(y,{className:"w-4 h-4"}),isLoaded:o})}),t.jsx(xe,{span:6,lg:4,children:t.jsx(ye,{title:"DROPPED",value:B.dropped,color:"dropped",buckets:null==_?void 0:_.dropped,receivedCount:B.received,timeRangeLabel:m.label,icon:t.jsx(k,{className:"w-4 h-4"}),isLoaded:o})}),t.jsx(xe,{span:12,lg:4,children:t.jsx(Le,{stats:l,receivedBuckets:null==_?void 0:_.received,droppedBuckets:null==_?void 0:_.dropped,forwardedBuckets:null==_?void 0:_.forwarded,bucketDurationSeconds:null==_?void 0:_.bucket_duration_seconds,timeRangeLabel:m.label,isLoaded:o})})]}),t.jsx(st,{isLoaded:o}),t.jsx(_e,{}),l&&t.jsx(he,{template:"auto",children:t.jsx(me,{nodeName:R,repeaterVersion:l.version,coreVersion:l.core_version,localHash:l.local_hash,publicKey:l.public_key})})]})}export{at as default}; +import{r as e,j as t,V as s,Y as a,Z as n,_ as l,$ as i,a0 as r,E as o,L as c,a1 as d,U as u,a2 as m,a3 as h,a4 as x,a5 as f,a6 as p,a7 as v,a8 as g,a9 as j,aa as b,ab as N,ac as y,ad as k}from"./vendor-react-C341c8YC.js";import{B as w,S as M,u as L,c as _,d as S,e as C,w as F,L as B,f as R,h as D,j as T,D as A,k as $,m as P,n as I,T as H,o as E,p as W,q,r as z,t as O,F as K}from"./index-BJEgt3tp.js";import{u as G,a as V}from"./useThemeColors-AeHMyThq.js";import{C as U,S as J,a as Q,P as X,b as Y}from"./PageLayout-CnF5SScd.js";import{P as Z}from"./PacketList-BPeOqxkB.js";import{T as ee}from"./TimeRangeSelector-DGCfekAv.js";import{s as te}from"./SignalIndicator-BLrEkFNb.js";import{R as se,L as ae,Y as ne,u as le,A as ie,C as re,X as oe,T as ce,v as de}from"./recharts-6XUQYgRA.js";import{c as ue}from"./link-scoring-Cw0dJsWv.js";import{N as me}from"./NodeInformationCard-CEW2bogB.js";import{R as he,C as xe}from"./Grid-BOO-7ObJ.js";import{C as fe}from"./Card-2pQSGkKC.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./channel-keys-DJWRrSwE.js";import"./DataBox-CRX76VsB.js";const pe={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},ve=/([,\.:\/])/g,ge=e.memo(function({children:s,className:a="",as:n="span"}){const l=e.useMemo(()=>{let e;return e="number"==typeof s?s.toLocaleString():Array.isArray(s)?s.join(""):String(s??""),ve.test(e)?(ve.lastIndex=0,e.split(ve).map((e,s)=>{const a=pe[e];return a?t.jsx("span",{className:a,children:e},s):e})):e},[s]);return t.jsx(n,{className:`data-tight ${a}`.trim(),children:l})}),je={received:{barBase:"var(--metric-received)"},forwarded:{barBase:"var(--metric-forwarded)"},transmitted:{barBase:"var(--metric-transmitted)"},dropped:{barBase:"var(--metric-dropped)"},neutral:{barBase:"var(--metric-neutral)"}},be={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function Ne({buckets:s,colorType:a}){const n=je[a].barBase,l=e.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=M.statsCard,t=s.length/e,a=t<=1?s:Array.from({length:e},(e,a)=>{var n,l;const i=s.slice(Math.floor(a*t),Math.floor((a+1)*t)),r=i.reduce((e,t)=>e+t.count,0),o=i.length?i.reduce((e,t)=>e+t.avg_snr,0)/i.length:0;return{bucket:a,start:(null==(n=i[0])?void 0:n.start)??0,end:(null==(l=i.at(-1))?void 0:l.end)??0,count:r,airtime_ms:i.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),l=a.map(e=>e.count).filter(e=>e>0);if(0===l.length)return a.map(()=>({height:0,bottom:0,color:"transparent",count:0,snr:0}));const i=Math.max(...l),r=Math.min(...l),o=i-r;return 0===o?a.map(e=>({height:e.count>0?40:0,bottom:e.count>0?30:0,color:e.count>0?n:"transparent",count:e.count,snr:e.avg_snr})):a.map(e=>{if(0===e.count)return{height:0,bottom:0,color:"transparent",count:0,snr:e.avg_snr};const t=(e.count-r)/o,s=15*t;return{height:Math.max(30,30+50*t),bottom:s,color:n,count:e.count,snr:e.avg_snr}})},[s,n]);return(null==s?void 0:s.length)?t.jsx("div",{className:"w-full h-full flex items-end pt-1",children:l.map((e,s)=>{var a;return t.jsx("div",{className:"flex-1 relative min-w-0",style:{height:"100%"},children:t.jsx("div",{className:"absolute inset-x-0",style:{height:`${e.height}%`,bottom:`${e.bottom}%`,backgroundColor:e.color,opacity:e.count>0?.8:.1},title:e.count>0?`${e.count} packets, SNR: ${null==(a=e.snr)?void 0:a.toFixed(1)}dB`:"No packets"})},s)})}):t.jsx("div",{className:"w-full h-full flex items-end justify-center gap-[2px] opacity-20",children:t.jsx("span",{className:"type-data-xs text-text-secondary",children:"No data"})})}function ye({title:s,value:a,color:n="neutral",subtitle:l,buckets:i,receivedCount:r,timeRangeLabel:o,icon:c,size:d="md",isLoaded:u=!0}){const m="string"==typeof a?a:a.toLocaleString(),h=e.useMemo(()=>function(e){if(!(null==e?void 0:e.length))return null;const t=e.reduce((e,t)=>e+t.count,0),s=e[0].start,a=e[e.length-1].end,n=Math.max((a-s)/3600,1),l=Math.round(t/n);let i=0,r=0;for(let d=0;dr&&(r=e[d].count,i=d);const o=new Date(1e3*e[i].start).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),c=e.filter(e=>e.count>0&&0!==e.avg_snr);return{total:t,ratePerHour:l,peakCount:r,peakHour:o,avgSnr:c.length>0?c.reduce((e,t)=>e+t.avg_snr,0)/c.length:null}}(i),[i]),x="number"==typeof a?a:(null==h?void 0:h.total)??0,f=r&&r>0?(x/r*100).toFixed(1):null;return u?t.jsxs("div",{className:`data-card flex flex-col relative ${be[d]}`,children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[c&&t.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),t.jsx("span",{className:"type-micro",children:s}),o&&t.jsx(w,{color:"teal",className:"hidden sm:inline-flex",children:o})]}),t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:m})}),t.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:i?t.jsx(Ne,{buckets:i,colorType:n}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx("div",{className:"w-full h-0.5 rounded-full bg-text-muted/15"})})}),t.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:t.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Rate"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[(null==h?void 0:h.ratePerHour)??l??"—","/hr"]})]}),null!==f?t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"dropped"===n?"Drop %":"Ratio"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[f,"%"]})]}):(null==h?void 0:h.peakHour)?t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"data-box-label",children:"Peak"}),t.jsx("div",{className:"data-box data-box-fill data-box-left",children:h.peakHour})]}):null]})})]}):t.jsx("div",{className:`data-card flex flex-col relative ${be[d]}`,children:t.jsx(U,{})})}const ke=.2;function we(e,t=1){return Math.floor(5*t*e)}function Me(e){const t=Math.round(e/ke)*ke;return Math.max(0,Math.min(5,t))}function Le({stats:o,receivedBuckets:c,droppedBuckets:d,forwardedBuckets:u,bucketDurationSeconds:m,timeRangeLabel:h,isLoaded:x=!0}){var f,p,v,g;const[j,b]=e.useState(!1);if(!x)return t.jsx("div",{className:"data-card flex flex-col relative",children:t.jsx(U,{})});const N=function(e,t,s,a,n){var l,i;const r=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=r(t),c=r(s),d=r(a),u=o||(null==e?void 0:e.rx_count)||1,m=c||(null==e?void 0:e.dropped_count)||0,h=u>0?m/(u+m)*100:0;let x=0;if((null==a?void 0:a.length)&&n)x=100*d/(a.length*n*1e3)*100;else if(e){const t=1e3*(e.uptime_seconds||1);x=(e.total_airtime_ms||e.airtime_used_ms||0)/t*100}const f=(null==e?void 0:e.neighbors)??{},p=Object.values(f).filter(e=>e.zero_hop).length;let v=1;h<3?v-=ke:h>15?v+=.4:h>10&&(v+=ke),x>5&&(v+=ke),p>10&&(v+=ke);const g=Me(v),j=Me(.28*g),b=we(g),N=we(j),y=we((null==(i=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:i.tx_delay_factor)??1);return{floodFactor:g,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b{const e=`set txdelay ${N.floodFactor.toFixed(1)}\nset direct.txdelay ${N.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(e),b(!0),setTimeout(()=>b(!1),1500)}catch(t){const s=document.createElement("textarea");s.value=e,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy"),b(!0),setTimeout(()=>b(!1),1500)}catch{}document.body.removeChild(s)}},className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-white/[0.02] rounded-lg transition-colors p-1 -m-1 group",title:"Click to copy CLI commands",children:[t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-hero text-text-primary",children:t.jsxs(ge,{children:["×",N.floodFactor.toFixed(1)]})}),t.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide mt-0.5 sm:mt-1",children:"Flood"})]}),t.jsxs("div",{className:"flex-1 flex flex-col",children:[t.jsx("span",{className:"type-data-hero text-accent-tertiary",children:t.jsxs(ge,{children:["×",N.directFactor.toFixed(1)]})}),t.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide mt-0.5 sm:mt-1",children:"Direct"})]}),t.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:j?t.jsx(i,{className:"w-4 h-4 text-green-400"}):t.jsx(r,{className:"w-4 h-4 text-text-muted"})})]}),t.jsx("div",{className:"flex-1 py-2",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Dupe"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left "+(N.duplicateRate>10?"text-accent-warning":""),children:[N.duplicateRate.toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"TX Util"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[N.txUtilization.toFixed(2),"%"]})]})]})}),t.jsxs("div",{className:"pt-2 mt-2",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:null!==y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"data-box",children:["×",y.toFixed(2)]}),t.jsxs("div",{className:"data-box",style:{color:"var(--accent-tertiary)"},children:["×",(null==k?void 0:k.toFixed(2))??"—"]})]}):t.jsx("span",{className:"text-sm text-text-muted",children:"No config"})})]})]})}function _e(){const s=L(),a=_(),n=S(),l=C(),[i,r]=e.useState([]);e.useEffect(()=>{const e=F.subscribe(e=>{r(e)});return r(F.getPendingPackets()),e},[]);const u=e.useMemo(()=>{const e=s.length<=100?s:s.slice(-100),t=new Set(e.map(e=>e.packet_hash));return[...i.filter(e=>!t.has(e.packet.packet_hash)).map(e=>({...e.packet,isPending:!0})),...e].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,i]),m=null==l?void 0:l.local_hash,h=null==l?void 0:l.neighbors;return t.jsxs("div",{className:"chart-container h-full flex flex-col !overflow-visible",children:[t.jsxs("div",{className:"chart-header",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(o,{className:"chart-title-icon"}),"Recent Packets"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx(B,{showLabel:!0}),t.jsxs(c,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(d,{className:"w-3 h-3"})]})]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:t.jsx(Z,{packets:u,allPackets:s,localHash:m,neighbors:h,loading:a,maxPackets:50,showPagination:!1,flashNewest:!0,emptyMessage:"No packets received",footerAction:t.jsxs(c,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(d,{className:"w-3 h-3"})]})})})]})}const Se=e.memo(function({active:e,payload:s,label:a,formatValue:n,labelKey:l}){var i;if(!e||!(null==s?void 0:s.length))return null;const r=l&&(null==(i=s[0])?void 0:i.payload)?s[0].payload[l]:a;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[r&&t.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:r}),t.jsx("div",{className:"space-y-1.5",children:s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:e.name}),t.jsx("span",{className:"type-data-sm text-white tabular-nums",children:n?n(e.value,e.name):e.value.toLocaleString()})]},s))})]})});e.memo(function({active:e,payload:s,color:a,labelKey:n,unit:l=""}){var i,r;if(!e||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(i=null==o?void 0:o.payload)?void 0:i[n];return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[t.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a}}),t.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(r=null==o?void 0:o.value)?void 0:r.toLocaleString(),l]})]})]})}),e.memo(function({payload:e}){return(null==e?void 0:e.length)?t.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:e.value})]},s))}):null});const Ce={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Fe({trend:e}){return t.jsx("span",{className:`mini-widget-trend ${e}`,children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Ce[e]})})})}function Be(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Re({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function De({title:e,icon:s,value:a,unit:n,valueSize:l="md",status:i,subtitle:r,trend:o,children:c,isLoading:d=!1,error:u,className:m="",onClick:h}){const x=["mini-widget-value","lg"===l&&"mini-widget-value-lg","sm"===l&&"mini-widget-value-sm"].filter(Boolean).join(" "),f=["mini-widget",h&&"cursor-pointer",m].filter(Boolean).join(" ");return t.jsxs("div",{className:f,onClick:h,role:h?"button":void 0,children:[t.jsxs("div",{className:"mini-widget-header",children:[s,t.jsx("span",{className:"mini-widget-title",children:e}),i&&"unknown"!==i&&t.jsx("div",{className:`mini-widget-status-dot ${i}`}),o&&t.jsx(Fe,{trend:o})]}),d?t.jsx(Be,{}):u?t.jsx(Re,{message:u}):t.jsxs(t.Fragment,{children:[void 0!==a&&t.jsxs("div",{className:x,children:[t.jsx(ge,{children:a}),n&&t.jsx("span",{className:"mini-widget-unit",children:n})]}),r&&t.jsx("div",{className:"mini-widget-subtitle",children:r}),c]})]})}const Te={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Ae={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function $e(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),a=t/100*(s.length-1),n=Math.floor(a),l=Math.ceil(a);return n===l?s[n]:s[n]+(s[l]-s[n])*(a-n)}function Pe(e){return $e(e,50)}function Ie(e){if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(Number).filter(e=>!isNaN(e))}catch{}return[]}function He(e){return null!=e&&0!==e&&!Object.is(e,-0)&&!(e>-50||e<-130)}function Ee(e,t,s=2,a=!1){if(null===t)return"stable";const n=e-t;return(0!==t?100*Math.abs(n/t):Math.abs(n))0?"up":"down":n>0?"down":"up"}const We={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:Ae,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},qe=e.createContext(We);function ze({children:s}){var a;const n=C(),l=L(),i=R(),r=D(),o=T(),c=A[o],d=Math.max(1,c.minutes/60),u=null===n,m=e.useMemo(()=>function(e,t){const s=3600*t,a=Math.floor(Date.now()/1e3)-s,n=e.filter(e=>e.timestamp>=a&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),l=n.length,i=n.filter(e=>(e.lbt_attempts??0)>1).length,r=l>0?i/l*100:0,o=n.filter(e=>(e.lbt_attempts??0)>1),c=o.length>0?o.reduce((e,t)=>e+(t.lbt_attempts??0),0)/o.length:0,d=n.filter(e=>(e.lbt_attempts??0)>=5).length,u=l>0?d/l*100:0,m=[];for(const b of n){const e=Ie(b.lbt_backoff_delays_ms);m.push(...e)}const h=m.reduce((e,t)=>e+t,0),x=m.length>0?h/m.length:0,f=m.length>0?Math.min(...m):0,p=m.length>0?Math.max(...m):0,v=s/24,g=[],j=[];for(let b=0;b<24;b++){const e=a+b*v,t=e+v,s=n.filter(s=>s.timestamp>=e&&s.timestamp(e.lbt_attempts??0)>1).length,i=s.length>0?l/s.length*100:0,r=[];for(const a of s){const e=Ie(a.lbt_backoff_delays_ms);r.push(...e)}const o=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;if(g.push(o),0===s.length)j.push(0);else{const e=s.filter(e=>(e.lbt_attempts??0)>=5).length,t=r.length>0?Math.max(...r):0,a=Math.min(s.length/5,1),n=.15,l=Math.log(1+i*n)/Math.log(1+100*n)*40,c=e/s.length*100,d=Math.min(.5*c,25);let u=0;o>100&&(u=Math.min(8*Math.log10(o/100),15));let m=0;t>500&&o>0&&t>2*o&&(m=Math.min((t-500)/200,5));const h=l+d+u+m;j.push(Math.min(h*a,85))}}return{totalPacketsWithLBT:l,packetsWithRetries:i,retryRate:r,avgRetries:c,channelBusyCount:d,channelBusyRate:u,avgBackoffMs:x,minBackoffMs:f,maxBackoffMs:p,totalBackoffMs:h,sparklineBackoff:g,sparklineCollisionRisk:j,windowHours:t,packetCount:e.length}}(l,d),[l,d]),h=(null==n?void 0:n.noise_floor_dbm)??null,x=e.useMemo(()=>He(h)?h:null,[h]),f=e.useMemo(()=>{var e;const t=null==(e=null==n?void 0:n.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(a=null==n?void 0:n.config)?void 0:a.radio]),[p,v]=e.useState([]),g=e.useRef({time:0,hours:0});e.useEffect(()=>{const e=async()=>{var e;const t=Date.now(),s=Math.ceil(d);if(0===g.current.time||g.current.hours!==s||t-g.current.time>=6e4){g.current={time:t,hours:s};try{const t=await $(Math.max(s,24));t.success&&(null==(e=t.data)?void 0:e.history)&&v(t.data.history)}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[d]);const j=e.useMemo(()=>function(e,t){if(0===e.length)return[];const s=e.reduce((e,t)=>Math.max(e,t.timestamp),0);if(0===s)return[];const a=3600*t,n=s-a,l=a/24,i=[];for(let r=0;r<24;r++){const t=n+r*l,s=t+l,a=e.filter(e=>e.timestamp>=t&&e.timestamp0){const e=a.reduce((e,t)=>e+t.noise_floor_dbm,0)/a.length;i.push(e)}else i.push(i.length>0?i[i.length-1]:-100)}return i}(p,d),[p,d]),b=null==n?void 0:n.neighbors,N=e.useMemo(()=>{const e=b??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)))},[b,r]),y=e.useMemo(()=>i.filter(e=>!r.has(e.hash)),[i,r]),k=e.useMemo(()=>function(e){if(0===e.length)return{...Ae,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),a=e.length>0?[e[e.length-1]]:[],n=e.slice(-4).filter(e=>Number.isFinite(e)),l=Pe(s),i=$e(s,10),r=$e(s,90),o=Pe(a),c=null!==o&&null!==i?o-i:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,a=0,n=0,l=0;const i=e[0].timestamp;for(const o of e){const e=(o.timestamp-i)/3600,t=o.value;s+=e,a+=t,n+=e*t,l+=e*e}const r=t*l-s*s;return Math.abs(r)<1e-4?0:(t*n-s*a)/r}(n.map((e,s)=>({timestamp:t-3600*(n.length-1-s),value:e}))),u=function(e){if(e.length<2)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length,s=e.map(e=>Math.pow(e-t,2)).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(s)}(n),m=s.length>=12,[h,x]=m?function(e,t,s){const a=Te;return e>=a.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=a.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:i,baselineP90:r,currentMedian:o,currentSampleCount:a.length,delta:c,slope:d,jitter:u,penalty:h,penaltyReason:x,computedAt:t,isReliable:m}}(j),[j]),w=e.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const a=e.map(e=>{const a=function(e,t,s){const a=te(e,t,s,0);if(a)switch(a.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const n=void 0===e?50:e>=10?100:e>=5?80:e>=0?60:e>=-5?40:20,l=void 0===t?50:t>=-70?100:t>=-80?80:t>=-90?60:t>=-100?40:20;return Math.round(.6*n+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),n=t[e.hash];return{name:(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:a,advertCount:e.count}});a.sort((e,t)=>t.score-e.score);const n=a.length>0?a.reduce((e,t)=>e+t.score,0)/a.length:0;return{neighbors:a,networkScore:Math.round(n),neighborCount:a.length,bestLink:a.length>0?{name:a[0].name,score:a[0].score}:null,worstLink:a.length>0?{name:a[a.length-1].name,score:a[a.length-1].score}:null}}(y,N,f),[y,N,f]),M=e.useMemo(()=>function(e,t,s){const a=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let n=50;null!==t&&(n=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,i=Math.round(.35*a+.25*n+.4*l);let r;return r=i>=85?"excellent":i>=70?"good":i>=50?"fair":i>=30?"congested":"critical",{score:i,status:r,components:{lbtHealth:Math.round(a),noiseHealth:Math.round(n),linkHealth:Math.round(l)}}}(m,x,w),[m,x,w]),[_,S]=e.useState({noiseFloor:null,networkScore:null,channelHealth:null}),F=e.useRef(0);e.useEffect(()=>{const e=()=>{const e=Date.now();e-F.current>3e4&&(F.current=e,S({noiseFloor:x,networkScore:(null==w?void 0:w.networkScore)??null,channelHealth:(null==M?void 0:M.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[x,null==w?void 0:w.networkScore,null==M?void 0:M.score]);const B=e.useMemo(()=>({noiseFloor:{current:x,previous:_.noiseFloor,trend:null!==x?Ee(x,_.noiseFloor,2,!0):"stable"},networkScore:{current:(null==w?void 0:w.networkScore)??0,previous:_.networkScore,trend:Ee((null==w?void 0:w.networkScore)??0,_.networkScore,3,!1)},channelHealth:{current:(null==M?void 0:M.score)??0,previous:_.channelHealth,trend:Ee((null==M?void 0:M.score)??0,_.channelHealth,3,!1)}}),[x,null==w?void 0:w.networkScore,null==M?void 0:M.score,_]),P={lbtStats:m,noiseFloor:x,sparklineNoiseFloor:j,linkQuality:w,channelHealth:M,nfTrend:k,radioConfig:f,trends:B,stats:n,recentPackets:l,quickNeighbors:i,isLoading:u,error:null,refresh:async()=>{}};return t.jsx(qe.Provider,{value:P,children:s})}function Oe(){const t=e.useContext(qe);if(void 0===t)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function Ke(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function Ge(){const{lbtStats:s,isLoading:a,error:n}=Oe(),l=u(),i=(null==s?void 0:s.avgBackoffMs)??0,r=(null==s?void 0:s.retryRate)??0,o=s?(c=i)<100?"excellent":c<250?"good":c<500?"fair":c<1e3?"congested":"critical":"unknown";var c;const d=null==s?void 0:s.sparklineBackoff,{chartData:h,yDomain:x}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,100]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,100]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,.1*a,10);return{chartData:e,yDomain:[Math.max(0,s-l),a+l]}},[d]);return t.jsx(De,{title:"LBT Backoff",icon:t.jsx(m,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:o,subtitle:s?Ke(i,r):void 0,isLoading:a,error:n,onClick:()=>l("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline",children:h.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:h,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:x,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ve(e){return 0===e?"—":e<1?"<1":Math.round(e).toString()}function Ue(){const{lbtStats:e,isLoading:s,error:a}=Oe(),n=u(),l=(null==e?void 0:e.channelBusyCount)??0,i=(null==e?void 0:e.totalPacketsWithLBT)??0,r=(null==e?void 0:e.channelBusyRate)??0,o=(null==e?void 0:e.retryRate)??0,c=(null==e?void 0:e.avgBackoffMs)??0,d=(null==e?void 0:e.minBackoffMs)??0,m=(null==e?void 0:e.maxBackoffMs)??0,x=o>0?Math.max(0,(o-r)/o*100):100;return t.jsx(De,{title:"Ch. Busy",icon:t.jsx(h,{className:"mini-widget-icon"}),isLoading:s,error:a,onClick:()=>n("/packets"),children:t.jsx("div",{className:"flex-1 flex items-end",children:t.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-2 w-full items-baseline",children:[t.jsx("span",{className:"data-box-label mb-0",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[t.jsx(ge,{children:l}),t.jsx("span",{className:"text-text-muted punc-slash",children:"/"}),t.jsx(ge,{children:i})]}),t.jsx("span",{className:"data-box-label mb-0",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),t.jsx("div",{className:"data-box justify-self-start",title:`${x.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:t.jsxs(ge,{children:[x.toFixed(0),"%"]})}),t.jsx("span",{className:"data-box-label mb-0",title:`Average LBT backoff delay: ${c.toFixed(0)}ms.`,children:"Mean:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Average LBT backoff delay: ${c.toFixed(0)}ms.`,children:[t.jsx(ge,{children:Ve(c)}),t.jsx("span",{className:"text-text-muted text-xs",children:"ms"})]}),t.jsx("span",{className:"data-box-label mb-0",title:`Backoff range: ${d.toFixed(0)}ms min, ${m.toFixed(0)}ms max.`,children:"Range:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Backoff range: ${d.toFixed(0)}ms min, ${m.toFixed(0)}ms max.`,children:[t.jsx(ge,{children:Ve(d)}),t.jsx("span",{className:"text-text-muted punc-slash",children:"/"}),t.jsx(ge,{children:Ve(m)})]})]})})})}function Je(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}function Qe(){const{noiseFloor:s,sparklineNoiseFloor:a,trends:n,isLoading:l,error:i}=Oe(),r=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==n?void 0:n.noiseFloor.trend,{chartData:d,yDomain:u}=e.useMemo(()=>{if(!a||a.length<2)return{chartData:[],yDomain:[-120,-90]};const e=a.map(e=>({value:e})),t=a.filter(e=>-100!==e&&e<-50);if(0===t.length)return{chartData:e,yDomain:[-120,-90]};const s=Math.min(...t),n=Math.max(...t),l=n-s,i=Math.max(.2*l,3);return{chartData:e,yDomain:[s-i,n+i]}},[a]);return t.jsx(De,{title:"Noise Floor",icon:t.jsx(x,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:r,trend:c,subtitle:Je(s),isLoading:l,error:i,children:t.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:u,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Xe(){const s=u(),a=R(),n=L(),l=C(),i=T(),r=60*A[i].minutes,o=P(),c=e.useMemo(()=>{if(0===o)return n;const e=o-r;return n.filter(t=>t.timestamp>=e)},[n,r,o]),d=null===l,m=(null==l?void 0:l.local_hash)?I(l.local_hash):"",h=(null==l?void 0:l.neighbors)??{},{neighborHashes:x,neighborNames:j}=e.useMemo(()=>{const e=new Set,t=new Map;for(const s of a){e.add(s.hash);const a=h[s.hash],n=(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||s.prefix;t.set(s.hash,n)}return{neighborHashes:e,neighborNames:t}},[a,h]),b=e.useMemo(()=>{if(0===x.size||0===c.length||!m)return{champion:null,listener:null,loudest:null};const{scores:e}=ue(c,x,m),t=[];for(const[l,i]of e)0!==i.blendedScore&&t.push({...i,name:j.get(l)??I(l)});let s=null,a=null,n=null;for(const l of t)(!s||l.blendedScore>s.blendedScore)&&(s=l),(!a||l.listenerScore>a.listenerScore)&&(a=l),(!n||l.loudScore>n.loudScore)&&(n=l);return{champion:s,listener:a,loudest:n}},[c,x,m,j]),{champion:N,listener:y,loudest:k}=b,w=N||y||k?t.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[N&&t.jsx(H,{content:(M=N,t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",M.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",M.blendedScore,t.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",M.listenerScore,"/100 (",M.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",M.loudScore,"/100 (",M.loudCount," packets relayed)"]})]})]})),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(f,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),t.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:N.name}),t.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:N.blendedScore})]})}),y&&t.jsx(H,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.listenerCount," packets where they heard your transmissions"]})})]}))(y),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:y.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:y.listenerScore})]})}),k&&t.jsx(H,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.loudCount," packets they relayed directly to you"]})})]}))(k),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(v,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:k.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:k.loudScore})]})})]}):0===a.length?t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var M;return t.jsx(De,{title:"Link Leaders",icon:t.jsx(g,{className:"mini-widget-icon"}),isLoading:d,onClick:()=>s("/contacts"),children:w})}function Ye(){const{lbtStats:s,isLoading:a,error:n}=Oe(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:a,avgBackoffMs:n,maxBackoffMs:l}=e;if(0===a)return 0;const i=Math.min(a/10,1),r=Math.log(1+.15*t)/Math.log(16)*40,o=s/a*100,c=Math.min(.5*o,25);let d=0;n>100&&(d=Math.min(8*Math.log10(n/100),15));let u=0;l>500&&n>0&&l>2*n&&(u=Math.min((l-500)/200,5));const m=(r+c+d+u)*i;return Math.min(m,85)}(s):0,i=s?(r=l)<15?"excellent":r<30?"good":r<45?"fair":r<60?"congested":"critical":"unknown";var r;const o=(null==s?void 0:s.maxBackoffMs)??0,c=s?o>200?`Max backoff: ${Math.round(o)}ms`:function(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}(l):void 0,d=null==s?void 0:s.sparklineCollisionRisk,{chartData:u,yDomain:m}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,85]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,85]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,5);return{chartData:e,yDomain:[Math.max(0,s-l),Math.min(85,a+l)]}},[d]);return t.jsx(De,{title:"Collision Risk",icon:t.jsx(j,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:i,subtitle:c,isLoading:a,error:n,children:t.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?t.jsx(se,{width:"100%",height:24,children:t.jsxs(ae,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(ne,{domain:m,hide:!0}),t.jsx(le,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ze(){const[s,a]=e.useState(!1),[n]=e.useState(0),{stats:l,lbtStats:i,isLoading:r}=Oe(),c=e.useMemo(()=>{if(!l)return null;const e=l.airtime_used_ms??0,t=l.max_airtime_ms??1;return{usedMs:e,maxMs:t,remainingMs:l.airtime_remaining_ms??0,utilizationPercent:l.utilization_percent??(t>0?e/t*100:0)}},[l]),d=e.useMemo(()=>i&&0!==i.totalPacketsWithLBT?(i.totalPacketsWithLBT-i.packetsWithRetries)/i.totalPacketsWithLBT*100:100,[i]),u=(null==c?void 0:c.utilizationPercent)??0,m=(h=u)<30?"excellent":h<50?"good":h<70?"fair":h<90?"congested":"critical";var h;const x=(null==c?void 0:c.remainingMs)??0,f=d<95?`${d.toFixed(0)}% clean TX`:((p=x)<1e3?`${Math.round(p)}ms`:p<6e4?`${(p/1e3).toFixed(1)}s`:`${(p/6e4).toFixed(1)}m`)+" remaining";var p;const v=c?t.jsx("div",{className:"mini-widget-progress mt-auto",children:t.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return t.jsx(De,{title:"Duty Cycle",icon:t.jsx(o,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:f,isLoading:r,children:v})}function et(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(J,{className:"w-4 h-4"}),t.jsx(J,{className:"h-3 w-16"})]}),t.jsx(J,{className:"h-7 w-12 mt-2"}),t.jsx(J,{className:"h-3 w-20 mt-2"})]})}function tt(){return t.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((e,s)=>t.jsx(et,{},s))})}function st({className:e="",isLoaded:s=!0}){return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(b,{className:"w-4 h-4 text-accent-primary"}),t.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?t.jsx(ze,{children:t.jsxs("div",{className:"widget-row",children:[t.jsx(Ge,{}),t.jsx(Ye,{}),t.jsx(Qe,{}),t.jsx(Ze,{}),t.jsx(Ue,{}),t.jsx(Xe,{})]})}):t.jsx(tt,{})]})}function at(){var s,n;const l=C(),i=E(),r=L(),o=W(),c=T(),d=q(),u=z(),m=A[c],h=5===c&&!u.threeDayLoadComplete,x=6===c&&!u.sevenDayLoadComplete,f=7===c&&!u.fourteenDayLoadComplete,p=u.isBackgroundLoading&&(h||x||f),v=G(),g=V(),j=null==(s=null==l?void 0:l.config)?void 0:s.radio,b=e.useMemo(()=>j?{sf:j.spreading_factor??10,bw:j.bandwidth??25e4,cr:j.coding_rate??5,preamble:j.preamble_length??8}:null,[j]),M=r.length,_=e.useMemo(()=>M?O(m.minutes,m.buckets,r,l):null,[M,m.minutes,m.buckets,b]),S=e.useMemo(()=>function(e,t,s){if(!(null==e?void 0:e.length))return[];const a=s<=1440?{hour:"2-digit",minute:"2-digit",hour12:!1}:s<=4320?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{weekday:"short",hour:"numeric",hour12:!1};return e.map((e,n)=>{var l;let i=new Date(1e3*e.start).toLocaleString([],a);return s>4320&&(i=i.replace(/(\d+)$/,"$1h")),{time:i,received:e.count,unique:(null==(l=null==t?void 0:t[n])?void 0:l.count)??0}})}(null==_?void 0:_.received,null==_?void 0:_.unique_received,m.minutes),[null==_?void 0:_.received,null==_?void 0:_.unique_received,m.minutes]),F=e.useMemo(()=>function(e){if(!e.length)return[0,"auto"];let t=0;for(const s of e)s.received>t&&(t=s.received),s.unique>t&&(t=s.unique);return[0,t||1]}(S),[S]),B=e.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==_?void 0:_.received),s=e(null==_?void 0:_.unique_received),a=e(null==_?void 0:_.forwarded),n=e(null==_?void 0:_.dropped),l=e(null==_?void 0:_.transmitted),i=((null==_?void 0:_.time_range_minutes)??m.minutes)/60;return{received:t,uniqueReceived:s,forwarded:a,dropped:n,transmitted:l,rxPerHour:i>0?Math.round(t/i):0,fwdPerHour:i>0?Math.round(a/i):0}},[_,m.minutes]),R=(null==l?void 0:l.node_name)??(null==(n=null==l?void 0:l.config)?void 0:n.node_name)??"Unknown Node";return i?t.jsxs(Q,{className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-white/50",children:i}),t.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(X,{children:[t.jsx(Y,{title:R,icon:t.jsx(N,{}),controls:t.jsx(ee,{ranges:A,selectedIndex:c,onSelect:d,isPending:p})}),t.jsx(he,{template:"hero",children:t.jsx(Q,{isLoaded:o,skeletonType:"chart",compact:!0,children:o&&t.jsxs(t.Fragment,{children:[t.jsx(fe,{icon:t.jsx(a,{}),title:"RECEIVED",badge:m.label,actions:t.jsxs("div",{className:"data-box",children:[B.rxPerHour,"/hr"]})}),t.jsxs("div",{className:"flex flex-wrap gap-4 sm:gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:B.received})}),t.jsx(w,{color:"green",className:"mb-0.5 sm:mb-1",children:"Total RF"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"type-data-hero text-text-primary",children:t.jsx(ge,{children:B.uniqueReceived})}),t.jsx(w,{color:"blue",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),t.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-8 dashboard-chart-height",children:S.length>0?t.jsx(se,{width:"100%",height:"100%",children:t.jsxs(ie,{data:S,margin:{left:0,right:8,top:0,bottom:0},children:[t.jsx(re,{strokeDasharray:"3 3",stroke:g.grid,vertical:!1}),t.jsx(oe,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:g.axisTick,fontSize:10,fontFamily:K},dy:8,interval:"preserveStartEnd",minTickGap:60}),t.jsx(ne,{domain:F,axisLine:!1,tickLine:!1,tick:{fill:g.axisTick,fontSize:10,fontFamily:K},dx:-4,width:28}),t.jsx(ce,{content:t.jsx(Se,{labelKey:"time"}),cursor:{stroke:g.cursor,strokeWidth:1}}),t.jsx(de,{type:"stepAfter",dataKey:"received",name:"Total RF",stroke:"none",fill:v.received,fillOpacity:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:v.received},isAnimationActive:!1}),t.jsx(de,{type:"stepAfter",dataKey:"unique",name:"Unique",stroke:"none",fill:v.forwarded,fillOpacity:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:v.forwarded},isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),t.jsxs(he,{template:"compact",children:[t.jsx(xe,{span:6,lg:4,children:t.jsx(ye,{title:"FORWARDED",value:B.forwarded,color:"forwarded",buckets:null==_?void 0:_.forwarded,receivedCount:B.received,timeRangeLabel:m.label,icon:t.jsx(y,{className:"w-4 h-4"}),isLoaded:o})}),t.jsx(xe,{span:6,lg:4,children:t.jsx(ye,{title:"DROPPED",value:B.dropped,color:"dropped",buckets:null==_?void 0:_.dropped,receivedCount:B.received,timeRangeLabel:m.label,icon:t.jsx(k,{className:"w-4 h-4"}),isLoaded:o})}),t.jsx(xe,{span:12,lg:4,children:t.jsx(Le,{stats:l,receivedBuckets:null==_?void 0:_.received,droppedBuckets:null==_?void 0:_.dropped,forwardedBuckets:null==_?void 0:_.forwarded,bucketDurationSeconds:null==_?void 0:_.bucket_duration_seconds,timeRangeLabel:m.label,isLoaded:o})})]}),t.jsx(st,{isLoaded:o}),t.jsx(_e,{}),l&&t.jsx(he,{template:"auto",children:t.jsx(me,{nodeName:R,repeaterVersion:l.version,coreVersion:l.core_version,localHash:l.local_hash,publicKey:l.public_key})})]})}export{at as default}; diff --git a/frontend/dist/assets/DeepAnalysisModal-DysenxvY.js b/frontend/dist/assets/DeepAnalysisModal-D4eqwCNZ.js similarity index 98% rename from frontend/dist/assets/DeepAnalysisModal-DysenxvY.js rename to frontend/dist/assets/DeepAnalysisModal-D4eqwCNZ.js index c227ea04..a8e74c78 100644 --- a/frontend/dist/assets/DeepAnalysisModal-DysenxvY.js +++ b/frontend/dist/assets/DeepAnalysisModal-D4eqwCNZ.js @@ -1 +1 @@ -import{r as e,j as t,m as s,$ as a,aJ as i,bW as n,aA as c,q as l,aq as r}from"./vendor-react-C341c8YC.js";import{n as m}from"./recharts-6XUQYgRA.js";import{N as d,aS as x,O as o,aT as p}from"./index-CPdqYR4z.js";function h({label:e,icon:s,status:i,detail:n}){return t.jsxs("div",{className:m("flex items-center gap-3 py-3 px-4 rounded-xl transition-all duration-300","active"===i&&"bg-accent-primary/10","complete"===i&&"bg-accent-primary/10 ring-2 ring-inset ring-accent-primary","pending"===i&&"opacity-40"),children:[t.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===i&&"bg-accent-primary/20","complete"===i&&"bg-accent-primary/20","pending"===i&&"bg-subtle-fill"),children:"complete"===i?t.jsx(a,{className:"w-4 h-4 text-accent-primary"}):"active"===i?t.jsx(r,{className:"w-4 h-4 animate-spin text-accent-primary"}):t.jsx("span",{className:"text-text-muted",children:s})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:m("text-sm font-medium transition-colors","active"===i&&"text-accent-primary","complete"===i&&"text-accent-primary","pending"===i&&"text-text-muted"),children:e}),n&&"pending"!==i&&t.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:n})]})]})}const g=e.memo(function({isOpen:e,currentStep:r,packetCount:m,onClose:g}){const j="complete"===r,u=e=>{const t=["fetching","analyzing","building","discovering","complete"],s=t.indexOf(r),a=t.indexOf(e);return a{});return t.jsx(d,{open:e,onClose:y,size:"sm",bottomSheet:!1,children:t.jsx(x,{isLoading:!j,borderRadius:16,children:t.jsx(o,{className:"p-6",children:j?t.jsxs("div",{className:"flex flex-col items-center py-6",children:[t.jsx(s.div,{variants:p,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-accent-primary/20",children:t.jsx(a,{className:"w-8 h-8 text-accent-primary"})}),t.jsx("h3",{className:"text-lg font-semibold text-accent-primary",children:"Ready!"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center bg-accent-primary/15",children:t.jsx(i,{className:"w-5 h-5 text-accent-primary"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Deep Analysis"}),t.jsx("p",{className:"text-xs text-text-muted",children:"Building mesh topology"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(h,{label:"Fetching Packets",icon:t.jsx(n,{className:"w-4 h-4"}),status:u("fetching"),detail:m>0?`${m.toLocaleString()} packets`:"Loading database..."}),t.jsx(h,{label:"Analyzing Database",icon:t.jsx(c,{className:"w-4 h-4"}),status:u("analyzing"),detail:"Processing packet paths"}),t.jsx(h,{label:"Building Topology",icon:t.jsx(i,{className:"w-4 h-4"}),status:u("building"),detail:"Computing mesh edges"}),t.jsx(h,{label:"Discovering Nodes",icon:t.jsx(l,{className:"w-4 h-4"}),status:u("discovering"),detail:"Viterbi HMM ghost detection"})]}),t.jsx("p",{className:"text-xs text-text-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})});export{g as D}; +import{r as e,j as t,m as s,$ as a,aJ as i,bW as n,aA as c,q as l,aq as r}from"./vendor-react-C341c8YC.js";import{n as m}from"./recharts-6XUQYgRA.js";import{N as d,aS as x,O as o,aT as p}from"./index-BJEgt3tp.js";function h({label:e,icon:s,status:i,detail:n}){return t.jsxs("div",{className:m("flex items-center gap-3 py-3 px-4 rounded-xl transition-all duration-300","active"===i&&"bg-accent-primary/10","complete"===i&&"bg-accent-primary/10 ring-2 ring-inset ring-accent-primary","pending"===i&&"opacity-40"),children:[t.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===i&&"bg-accent-primary/20","complete"===i&&"bg-accent-primary/20","pending"===i&&"bg-subtle-fill"),children:"complete"===i?t.jsx(a,{className:"w-4 h-4 text-accent-primary"}):"active"===i?t.jsx(r,{className:"w-4 h-4 animate-spin text-accent-primary"}):t.jsx("span",{className:"text-text-muted",children:s})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:m("text-sm font-medium transition-colors","active"===i&&"text-accent-primary","complete"===i&&"text-accent-primary","pending"===i&&"text-text-muted"),children:e}),n&&"pending"!==i&&t.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:n})]})]})}const g=e.memo(function({isOpen:e,currentStep:r,packetCount:m,onClose:g}){const j="complete"===r,u=e=>{const t=["fetching","analyzing","building","discovering","complete"],s=t.indexOf(r),a=t.indexOf(e);return a{});return t.jsx(d,{open:e,onClose:y,size:"sm",bottomSheet:!1,children:t.jsx(x,{isLoading:!j,borderRadius:16,children:t.jsx(o,{className:"p-6",children:j?t.jsxs("div",{className:"flex flex-col items-center py-6",children:[t.jsx(s.div,{variants:p,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-accent-primary/20",children:t.jsx(a,{className:"w-8 h-8 text-accent-primary"})}),t.jsx("h3",{className:"text-lg font-semibold text-accent-primary",children:"Ready!"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center bg-accent-primary/15",children:t.jsx(i,{className:"w-5 h-5 text-accent-primary"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Deep Analysis"}),t.jsx("p",{className:"text-xs text-text-muted",children:"Building mesh topology"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(h,{label:"Fetching Packets",icon:t.jsx(n,{className:"w-4 h-4"}),status:u("fetching"),detail:m>0?`${m.toLocaleString()} packets`:"Loading database..."}),t.jsx(h,{label:"Analyzing Database",icon:t.jsx(c,{className:"w-4 h-4"}),status:u("analyzing"),detail:"Processing packet paths"}),t.jsx(h,{label:"Building Topology",icon:t.jsx(i,{className:"w-4 h-4"}),status:u("building"),detail:"Computing mesh edges"}),t.jsx(h,{label:"Discovering Nodes",icon:t.jsx(l,{className:"w-4 h-4"}),status:u("discovering"),detail:"Viterbi HMM ghost detection"})]}),t.jsx("p",{className:"text-xs text-text-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})});export{g as D}; diff --git a/frontend/dist/assets/Login-zWarN3Ve.js b/frontend/dist/assets/Login-CkRuF4n8.js similarity index 99% rename from frontend/dist/assets/Login-zWarN3Ve.js rename to frontend/dist/assets/Login-CkRuF4n8.js index 1cad3c77..09b19ebc 100644 --- a/frontend/dist/assets/Login-zWarN3Ve.js +++ b/frontend/dist/assets/Login-CkRuF4n8.js @@ -1 +1 @@ -import{r as e,j as t,U as s,m as a,A as i}from"./vendor-react-C341c8YC.js";import{n as r}from"./recharts-6XUQYgRA.js";import{g as n,i as o,s as l,l as c,a as d,b as m,P as h}from"./index-CPdqYR4z.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const x=e.memo(function({width:e,height:s,className:a="",fill:i="currentColor"}){return t.jsxs("svg",{viewBox:"0 0 134 15",width:e,height:s,className:a,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[t.jsx("path",{fill:i,d:"M3.277,0.053C2.829,0.053 2.401,0.41 2.321,0.851L0.013,13.623C-0.067,14.064 0.232,14.421 0.681,14.421L3.13,14.421C3.578,14.421 4.006,14.064 4.086,13.623L5.004,8.54L6.684,13.957C6.766,14.239 7.02,14.421 7.337,14.421L10.58,14.421C10.897,14.421 11.217,14.239 11.401,13.957L15.043,8.513L14.119,13.623C14.038,14.064 14.338,14.421 14.787,14.421L17.236,14.421C17.684,14.421 18.112,14.064 18.192,13.623L20.5,0.851C20.582,0.41 20.283,0.053 19.834,0.053L16.69,0.053C16.373,0.053 16.053,0.235 15.87,0.517L9.897,9.473C9.803,9.616 9.578,9.578 9.528,9.41L7.074,0.517C6.992,0.235 6.738,0.053 6.421,0.053L3.277,0.053Z"}),t.jsx("path",{fill:i,d:"M21.146,14.421C21.146,14.421 33.257,14.421 33.257,14.421C33.526,14.421 33.784,14.205 33.831,13.942L34.337,11.128C34.385,10.863 34.206,10.649 33.936,10.649L25.519,10.649C25.429,10.649 25.37,10.576 25.385,10.488L25.635,9.105C25.65,9.017 25.736,8.944 25.826,8.944L32.596,8.944C32.865,8.944 33.123,8.728 33.171,8.465L33.621,5.974C33.669,5.709 33.49,5.495 33.221,5.495L26.45,5.495C26.361,5.495 26.301,5.423 26.317,5.335L26.584,3.852C26.599,3.764 26.685,3.691 26.775,3.691L35.192,3.691C35.462,3.691 35.719,3.476 35.767,3.21L36.258,0.498C36.306,0.235 36.126,0.019 35.857,0.019L23.746,0.019C23.297,0.019 22.867,0.378 22.788,0.819L20.474,13.621C20.396,14.062 20.695,14.421 21.146,14.421Z"}),t.jsx("path",{fill:i,d:"M45.926,14.419L45.926,14.421L46.346,14.421C48.453,14.421 50.465,12.742 50.839,10.67L51.081,9.327C51.456,7.256 50.05,5.576 47.943,5.576L41.455,5.576C41.186,5.576 41.007,5.363 41.054,5.097L41.218,4.192C41.266,3.927 41.524,3.713 41.793,3.713L50.569,3.713C51.018,3.713 51.446,3.356 51.526,2.915L51.9,0.85C51.98,0.407 51.68,0.05 51.232,0.05L41.638,0.05C39.531,0.05 37.519,1.73 37.145,3.801L36.88,5.267C36.505,7.339 37.91,9.018 40.018,9.018L46.506,9.018C46.775,9.018 46.954,9.231 46.907,9.497L46.785,10.176C46.737,10.441 46.479,10.655 46.21,10.655L37.189,10.655C36.741,10.655 36.313,11.012 36.233,11.453L35.841,13.621C35.761,14.062 36.061,14.419 36.51,14.419L45.926,14.419Z"}),t.jsx("path",{fill:i,d:"M68.008,0.046C68.008,0.046 65.296,0.046 65.296,0.046C64.847,0.046 64.42,0.403 64.34,0.844L63.532,5.31C63.517,5.398 63.431,5.469 63.341,5.469L58.085,5.469C57.995,5.469 57.936,5.398 57.951,5.31L58.758,0.844C58.837,0.403 58.539,0.046 58.09,0.046L55.378,0.046C54.93,0.046 54.502,0.403 54.422,0.844L52.112,13.623C52.032,14.064 52.331,14.421 52.78,14.421L55.492,14.421C55.941,14.421 56.369,14.064 56.449,13.623L57.272,9.074C57.287,8.986 57.373,8.914 57.462,8.914L62.719,8.914C62.809,8.914 62.868,8.985 62.853,9.074L62.032,13.623C61.952,14.064 62.252,14.421 62.7,14.421L65.413,14.421C65.861,14.421 66.289,14.064 66.369,13.623L68.678,0.844C68.755,0.403 68.457,0.046 68.008,0.046Z"}),t.jsx("path",{fill:i,d:"M72.099,14.421C72.099,14.421 80.066,14.421 80.066,14.421C80.515,14.421 80.943,14.064 81.022,13.623L81.414,11.453C81.494,11.012 81.194,10.655 80.746,10.655L73.828,10.655C73.559,10.655 73.38,10.441 73.427,10.176L74.51,4.215C74.558,3.951 74.815,3.736 75.082,3.736L82,3.736C82.448,3.736 82.876,3.379 82.956,2.938L83.34,0.817C83.42,0.376 83.12,0.019 82.672,0.019L74.724,0.019C72.622,0.019 70.614,1.691 70.236,3.757L68.965,10.665C68.587,12.738 69.99,14.421 72.099,14.421Z"}),t.jsx("path",{fill:i,d:"M97.176,-0C97.176,0 88.882,0 88.882,0C86.775,0 84.763,1.68 84.389,3.751L83.139,10.67C82.765,12.741 84.169,14.421 86.277,14.421L94.571,14.421C96.678,14.421 98.69,12.741 99.064,10.67L100.314,3.751C100.689,1.68 99.284,-0 97.176,-0ZM94.798,10.178C94.75,10.443 94.492,10.657 94.223,10.657L87.978,10.657C87.709,10.657 87.529,10.443 87.577,10.178L88.659,4.192C88.707,3.927 88.964,3.713 89.234,3.713L95.477,3.713C95.747,3.713 95.926,3.927 95.878,4.192L94.798,10.178Z"}),t.jsx("path",{fill:i,d:"M101.284,14.421L103.995,14.421C104.443,14.421 104.871,14.065 104.951,13.624L105.43,10.97C105.446,10.882 105.531,10.81 105.621,10.81L108.902,10.806C109.064,10.806 109.2,10.886 109.267,11.018L110.813,14.035C110.992,14.392 111.319,14.434 112.303,14.419C112.88,14.426 113.756,14.382 115.169,14.382C115.623,14.382 115.902,13.907 115.678,13.51L113.989,10.569C113.945,10.491 113.993,10.386 114.086,10.34C115.39,9.707 116.423,8.477 116.681,7.055L117.27,3.785C117.646,1.713 116.242,0.033 114.134,0.033L103.884,0.033C103.436,0.033 103.008,0.39 102.928,0.831L100.616,13.623C100.536,14.064 100.836,14.421 101.284,14.421L101.284,14.421ZM106.73,3.791C106.745,3.703 106.831,3.631 106.921,3.631L112.225,3.631C112.626,3.631 112.891,3.949 112.821,4.343L112.431,6.494C112.359,6.885 111.979,7.204 111.58,7.204L106.276,7.204C106.186,7.204 106.127,7.133 106.142,7.043L106.73,3.791Z"}),t.jsx("path",{fill:i,d:"M118.277,14.421C118.277,14.421 130.388,14.421 130.388,14.421C130.657,14.421 130.915,14.205 130.963,13.942L131.468,11.128C131.516,10.863 131.337,10.649 131.068,10.649L122.65,10.649C122.56,10.649 122.501,10.576 122.516,10.488L122.766,9.105C122.781,9.017 122.867,8.944 122.957,8.944L129.728,8.944C129.997,8.944 130.254,8.728 130.302,8.465L130.753,5.974C130.801,5.709 130.621,5.495 130.352,5.495L123.581,5.495C123.492,5.495 123.432,5.423 123.448,5.335L123.715,3.852C123.73,3.764 123.816,3.691 123.906,3.691L132.324,3.691C132.593,3.691 132.851,3.476 132.898,3.21L133.389,0.498C133.437,0.235 133.257,0.019 132.988,0.019L120.877,0.019C120.428,0.019 119.999,0.378 119.919,0.819L117.605,13.621C117.527,14.062 117.827,14.421 118.277,14.421Z"})]})}),u="#9cf15b",p={container:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:d.normal,delayChildren:.1}}},item:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:m.smooth}},footer:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{...m.gentle,delay:.4}}},error:{hidden:{opacity:0,height:0,marginTop:0},visible:{opacity:1,height:"auto",marginTop:24,transition:m.snappy},exit:{opacity:0,height:0,marginTop:0,transition:{duration:.15}}}},C=r("block font-mono text-xs font-medium uppercase tracking-wider text-text-secondary"),L=r("block w-full rounded-md bg-white/5 px-3 py-2","font-mono text-sm font-semibold text-text-primary","border border-transparent","outline-none ring-1 ring-inset ring-white/10","placeholder:text-text-muted/60 placeholder:font-normal","focus:ring-2 focus:ring-inset focus:ring-accent-primary","transition-shadow duration-150"),f=r("flex w-full justify-center rounded-md px-3 py-2","font-mono text-sm font-semibold uppercase tracking-wide text-black shadow-sm","focus-visible:outline-2 focus-visible:outline-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),j=e.memo(function({className:e}){return t.jsxs("svg",{className:r("animate-spin",e),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),g=e.memo(function({id:s,value:a,onChange:i,autoComplete:n="current-password",required:o=!1}){const[l,c]=e.useState(!1),d="×".repeat(a.length);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{id:s,name:s,type:l?"text":"password",value:a,onChange:i,autoComplete:n,required:o,className:r(L,"pr-10",!l&&"password-mask"),style:l?void 0:{fontFamily:"var(--font-data)",color:"transparent",caretColor:"var(--text-primary)"}}),!l&&a.length>0&&t.jsx("div",{className:r("pointer-events-none absolute inset-0 flex items-center","px-3 font-mono text-sm font-semibold text-text-primary"),"aria-hidden":"true",children:d}),t.jsx("button",{type:"button",onClick:()=>c(e=>!e),className:r("absolute inset-y-0 right-0 flex items-center pr-3","text-text-muted hover:text-text-secondary transition-colors"),"aria-label":l?"Hide password":"Show password",children:l?t.jsx("svg",{className:"size-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):t.jsxs("svg",{className:"size-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})}),v=e.memo(function({id:e,checked:s,onChange:a,label:i}){return t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsxs("div",{className:"group grid size-4 grid-cols-1",children:[t.jsx("input",{id:e,name:e,type:"checkbox",checked:s,onChange:e=>a(e.target.checked),className:r("col-start-1 row-start-1 appearance-none rounded-sm","border border-white/10 bg-white/5","checked:border-accent-primary checked:bg-accent-primary","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-primary","forced-colors:appearance-auto")}),t.jsx("svg",{fill:"none",viewBox:"0 0 14 14","aria-hidden":"true",className:r("pointer-events-none col-start-1 row-start-1","size-3.5 self-center justify-self-center stroke-white","group-has-[:disabled]:stroke-gray-950/25"),children:t.jsx("path",{d:"M3 8L6 11L11 3.5",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:r("transition-opacity",s?"opacity-100":"opacity-0")})})]})}),t.jsx("label",{htmlFor:e,className:"block font-mono text-xs uppercase tracking-wider text-text-secondary cursor-pointer select-none",children:i})]})}),b=e.memo(function({href:e,children:s}){return t.jsx(a.a,{href:e,target:"_blank",rel:"noopener noreferrer",whileHover:{scale:1.05},whileTap:{scale:.98},className:"inline-flex items-center gap-1.5 opacity-60 hover:opacity-100 transition-opacity",children:s})}),y=()=>t.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),w=e.memo(function(){return t.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:"#09090b"},"aria-hidden":"true"})}),k=e.memo(function(){return t.jsxs(a.footer,{variants:p.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[t.jsx("p",{className:"text-center font-mono text-[10px] uppercase tracking-widest text-white/40 mb-3",children:"Powered By"}),t.jsx("div",{className:"mx-auto max-w-xs",children:t.jsxs("div",{className:"flex items-center justify-center gap-4",children:[t.jsx(b,{href:"https://github.com/rightup/pyMC_Repeater",children:t.jsxs("span",{className:"font-mono text-sm font-semibold tracking-tight",children:[t.jsx("span",{style:{color:u},children:"py"}),t.jsx("span",{className:"text-white",children:"MC"})]})}),t.jsx(y,{}),t.jsx(b,{href:"https://meshcore.co.uk",children:t.jsx(x,{height:12,className:"text-white"})}),t.jsx(y,{}),t.jsxs(b,{href:"https://wcmesh.com",children:[t.jsx("div",{className:"size-6 overflow-hidden rounded border border-white/10",children:t.jsx("img",{src:"/assets/WCM_Waves-RN-_ocPH.gif",alt:"",className:"size-full object-cover"})}),t.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})});function N(){const r=s(),[d,m]=e.useState("admin"),[x,b]=e.useState(""),[y,N]=e.useState(n),[M,z]=e.useState(!1),[S,Z]=e.useState(null),T=d.length>0&&x.length>0&&!M;e.useEffect(()=>{o()&&r("/",{replace:!0})},[r]);const W=e.useCallback(()=>Z(null),[]),B=e.useCallback(e=>{m(e.target.value),S&&W()},[S,W]),F=e.useCallback(e=>{b(e.target.value),S&&W()},[S,W]),R=e.useCallback(e=>{N(e),l(e)},[]),A=e.useCallback(async e=>{if(e.preventDefault(),!T)return;z(!0),Z(null);const t=await c(d,x,y);z(!1),t.success?window.location.href="/":Z(t.error??"Login failed")},[T,d,x,y]);return t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-12 sm:px-6 lg:px-8",children:t.jsxs(a.div,{variants:p.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[t.jsx(a.div,{variants:p.item,className:"flex justify-center",children:t.jsx(h,{height:32})}),t.jsxs(a.form,{variants:p.item,onSubmit:A,className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"username",className:C,children:"Username"}),t.jsx("div",{className:"mt-2",children:t.jsx("input",{id:"username",name:"username",type:"text",value:d,onChange:B,required:!0,autoComplete:"username",autoFocus:!0,className:L})})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:C,children:"Password"}),t.jsx("div",{className:"mt-2",children:t.jsx(g,{id:"password",value:x,onChange:F,required:!0})})]}),t.jsx(v,{id:"remember-me",checked:y,onChange:R,label:"Remember me"}),t.jsx(i,{mode:"wait",children:S&&t.jsx(a.div,{variants:p.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-accent-danger/10 p-3 overflow-hidden",children:t.jsx("p",{className:"text-sm text-accent-danger text-center",children:S})},"error")}),t.jsx(a.div,{whileTap:T?{scale:.98}:void 0,children:t.jsx("button",{type:"submit",disabled:!T,className:f,style:{backgroundColor:u,"--tw-ring-color":u},onMouseEnter:e=>e.currentTarget.style.backgroundColor="#8de04a",onMouseLeave:e=>e.currentTarget.style.backgroundColor=u,children:M?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(j,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),t.jsxs(a.p,{variants:p.item,className:"text-center text-sm/6 text-text-muted",children:["A ",t.jsx("span",{style:{color:u},children:"@RightUp"})," X"," ",t.jsx("span",{style:{color:u},children:"@Treehouse⚡"})," Collab"]})]})}),t.jsx(k,{})]})}export{N as default}; +import{r as e,j as t,U as s,m as a,A as i}from"./vendor-react-C341c8YC.js";import{n as r}from"./recharts-6XUQYgRA.js";import{g as n,i as o,s as l,l as c,a as d,b as m,P as h}from"./index-BJEgt3tp.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const x=e.memo(function({width:e,height:s,className:a="",fill:i="currentColor"}){return t.jsxs("svg",{viewBox:"0 0 134 15",width:e,height:s,className:a,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[t.jsx("path",{fill:i,d:"M3.277,0.053C2.829,0.053 2.401,0.41 2.321,0.851L0.013,13.623C-0.067,14.064 0.232,14.421 0.681,14.421L3.13,14.421C3.578,14.421 4.006,14.064 4.086,13.623L5.004,8.54L6.684,13.957C6.766,14.239 7.02,14.421 7.337,14.421L10.58,14.421C10.897,14.421 11.217,14.239 11.401,13.957L15.043,8.513L14.119,13.623C14.038,14.064 14.338,14.421 14.787,14.421L17.236,14.421C17.684,14.421 18.112,14.064 18.192,13.623L20.5,0.851C20.582,0.41 20.283,0.053 19.834,0.053L16.69,0.053C16.373,0.053 16.053,0.235 15.87,0.517L9.897,9.473C9.803,9.616 9.578,9.578 9.528,9.41L7.074,0.517C6.992,0.235 6.738,0.053 6.421,0.053L3.277,0.053Z"}),t.jsx("path",{fill:i,d:"M21.146,14.421C21.146,14.421 33.257,14.421 33.257,14.421C33.526,14.421 33.784,14.205 33.831,13.942L34.337,11.128C34.385,10.863 34.206,10.649 33.936,10.649L25.519,10.649C25.429,10.649 25.37,10.576 25.385,10.488L25.635,9.105C25.65,9.017 25.736,8.944 25.826,8.944L32.596,8.944C32.865,8.944 33.123,8.728 33.171,8.465L33.621,5.974C33.669,5.709 33.49,5.495 33.221,5.495L26.45,5.495C26.361,5.495 26.301,5.423 26.317,5.335L26.584,3.852C26.599,3.764 26.685,3.691 26.775,3.691L35.192,3.691C35.462,3.691 35.719,3.476 35.767,3.21L36.258,0.498C36.306,0.235 36.126,0.019 35.857,0.019L23.746,0.019C23.297,0.019 22.867,0.378 22.788,0.819L20.474,13.621C20.396,14.062 20.695,14.421 21.146,14.421Z"}),t.jsx("path",{fill:i,d:"M45.926,14.419L45.926,14.421L46.346,14.421C48.453,14.421 50.465,12.742 50.839,10.67L51.081,9.327C51.456,7.256 50.05,5.576 47.943,5.576L41.455,5.576C41.186,5.576 41.007,5.363 41.054,5.097L41.218,4.192C41.266,3.927 41.524,3.713 41.793,3.713L50.569,3.713C51.018,3.713 51.446,3.356 51.526,2.915L51.9,0.85C51.98,0.407 51.68,0.05 51.232,0.05L41.638,0.05C39.531,0.05 37.519,1.73 37.145,3.801L36.88,5.267C36.505,7.339 37.91,9.018 40.018,9.018L46.506,9.018C46.775,9.018 46.954,9.231 46.907,9.497L46.785,10.176C46.737,10.441 46.479,10.655 46.21,10.655L37.189,10.655C36.741,10.655 36.313,11.012 36.233,11.453L35.841,13.621C35.761,14.062 36.061,14.419 36.51,14.419L45.926,14.419Z"}),t.jsx("path",{fill:i,d:"M68.008,0.046C68.008,0.046 65.296,0.046 65.296,0.046C64.847,0.046 64.42,0.403 64.34,0.844L63.532,5.31C63.517,5.398 63.431,5.469 63.341,5.469L58.085,5.469C57.995,5.469 57.936,5.398 57.951,5.31L58.758,0.844C58.837,0.403 58.539,0.046 58.09,0.046L55.378,0.046C54.93,0.046 54.502,0.403 54.422,0.844L52.112,13.623C52.032,14.064 52.331,14.421 52.78,14.421L55.492,14.421C55.941,14.421 56.369,14.064 56.449,13.623L57.272,9.074C57.287,8.986 57.373,8.914 57.462,8.914L62.719,8.914C62.809,8.914 62.868,8.985 62.853,9.074L62.032,13.623C61.952,14.064 62.252,14.421 62.7,14.421L65.413,14.421C65.861,14.421 66.289,14.064 66.369,13.623L68.678,0.844C68.755,0.403 68.457,0.046 68.008,0.046Z"}),t.jsx("path",{fill:i,d:"M72.099,14.421C72.099,14.421 80.066,14.421 80.066,14.421C80.515,14.421 80.943,14.064 81.022,13.623L81.414,11.453C81.494,11.012 81.194,10.655 80.746,10.655L73.828,10.655C73.559,10.655 73.38,10.441 73.427,10.176L74.51,4.215C74.558,3.951 74.815,3.736 75.082,3.736L82,3.736C82.448,3.736 82.876,3.379 82.956,2.938L83.34,0.817C83.42,0.376 83.12,0.019 82.672,0.019L74.724,0.019C72.622,0.019 70.614,1.691 70.236,3.757L68.965,10.665C68.587,12.738 69.99,14.421 72.099,14.421Z"}),t.jsx("path",{fill:i,d:"M97.176,-0C97.176,0 88.882,0 88.882,0C86.775,0 84.763,1.68 84.389,3.751L83.139,10.67C82.765,12.741 84.169,14.421 86.277,14.421L94.571,14.421C96.678,14.421 98.69,12.741 99.064,10.67L100.314,3.751C100.689,1.68 99.284,-0 97.176,-0ZM94.798,10.178C94.75,10.443 94.492,10.657 94.223,10.657L87.978,10.657C87.709,10.657 87.529,10.443 87.577,10.178L88.659,4.192C88.707,3.927 88.964,3.713 89.234,3.713L95.477,3.713C95.747,3.713 95.926,3.927 95.878,4.192L94.798,10.178Z"}),t.jsx("path",{fill:i,d:"M101.284,14.421L103.995,14.421C104.443,14.421 104.871,14.065 104.951,13.624L105.43,10.97C105.446,10.882 105.531,10.81 105.621,10.81L108.902,10.806C109.064,10.806 109.2,10.886 109.267,11.018L110.813,14.035C110.992,14.392 111.319,14.434 112.303,14.419C112.88,14.426 113.756,14.382 115.169,14.382C115.623,14.382 115.902,13.907 115.678,13.51L113.989,10.569C113.945,10.491 113.993,10.386 114.086,10.34C115.39,9.707 116.423,8.477 116.681,7.055L117.27,3.785C117.646,1.713 116.242,0.033 114.134,0.033L103.884,0.033C103.436,0.033 103.008,0.39 102.928,0.831L100.616,13.623C100.536,14.064 100.836,14.421 101.284,14.421L101.284,14.421ZM106.73,3.791C106.745,3.703 106.831,3.631 106.921,3.631L112.225,3.631C112.626,3.631 112.891,3.949 112.821,4.343L112.431,6.494C112.359,6.885 111.979,7.204 111.58,7.204L106.276,7.204C106.186,7.204 106.127,7.133 106.142,7.043L106.73,3.791Z"}),t.jsx("path",{fill:i,d:"M118.277,14.421C118.277,14.421 130.388,14.421 130.388,14.421C130.657,14.421 130.915,14.205 130.963,13.942L131.468,11.128C131.516,10.863 131.337,10.649 131.068,10.649L122.65,10.649C122.56,10.649 122.501,10.576 122.516,10.488L122.766,9.105C122.781,9.017 122.867,8.944 122.957,8.944L129.728,8.944C129.997,8.944 130.254,8.728 130.302,8.465L130.753,5.974C130.801,5.709 130.621,5.495 130.352,5.495L123.581,5.495C123.492,5.495 123.432,5.423 123.448,5.335L123.715,3.852C123.73,3.764 123.816,3.691 123.906,3.691L132.324,3.691C132.593,3.691 132.851,3.476 132.898,3.21L133.389,0.498C133.437,0.235 133.257,0.019 132.988,0.019L120.877,0.019C120.428,0.019 119.999,0.378 119.919,0.819L117.605,13.621C117.527,14.062 117.827,14.421 118.277,14.421Z"})]})}),u="#9cf15b",p={container:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:d.normal,delayChildren:.1}}},item:{hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:m.smooth}},footer:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{...m.gentle,delay:.4}}},error:{hidden:{opacity:0,height:0,marginTop:0},visible:{opacity:1,height:"auto",marginTop:24,transition:m.snappy},exit:{opacity:0,height:0,marginTop:0,transition:{duration:.15}}}},C=r("block font-mono text-xs font-medium uppercase tracking-wider text-text-secondary"),L=r("block w-full rounded-md bg-white/5 px-3 py-2","font-mono text-sm font-semibold text-text-primary","border border-transparent","outline-none ring-1 ring-inset ring-white/10","placeholder:text-text-muted/60 placeholder:font-normal","focus:ring-2 focus:ring-inset focus:ring-accent-primary","transition-shadow duration-150"),f=r("flex w-full justify-center rounded-md px-3 py-2","font-mono text-sm font-semibold uppercase tracking-wide text-black shadow-sm","focus-visible:outline-2 focus-visible:outline-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),j=e.memo(function({className:e}){return t.jsxs("svg",{className:r("animate-spin",e),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),g=e.memo(function({id:s,value:a,onChange:i,autoComplete:n="current-password",required:o=!1}){const[l,c]=e.useState(!1),d="×".repeat(a.length);return t.jsxs("div",{className:"relative",children:[t.jsx("input",{id:s,name:s,type:l?"text":"password",value:a,onChange:i,autoComplete:n,required:o,className:r(L,"pr-10",!l&&"password-mask"),style:l?void 0:{fontFamily:"var(--font-data)",color:"transparent",caretColor:"var(--text-primary)"}}),!l&&a.length>0&&t.jsx("div",{className:r("pointer-events-none absolute inset-0 flex items-center","px-3 font-mono text-sm font-semibold text-text-primary"),"aria-hidden":"true",children:d}),t.jsx("button",{type:"button",onClick:()=>c(e=>!e),className:r("absolute inset-y-0 right-0 flex items-center pr-3","text-text-muted hover:text-text-secondary transition-colors"),"aria-label":l?"Hide password":"Show password",children:l?t.jsx("svg",{className:"size-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):t.jsxs("svg",{className:"size-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]})}),v=e.memo(function({id:e,checked:s,onChange:a,label:i}){return t.jsxs("div",{className:"flex gap-3",children:[t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:t.jsxs("div",{className:"group grid size-4 grid-cols-1",children:[t.jsx("input",{id:e,name:e,type:"checkbox",checked:s,onChange:e=>a(e.target.checked),className:r("col-start-1 row-start-1 appearance-none rounded-sm","border border-white/10 bg-white/5","checked:border-accent-primary checked:bg-accent-primary","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-primary","forced-colors:appearance-auto")}),t.jsx("svg",{fill:"none",viewBox:"0 0 14 14","aria-hidden":"true",className:r("pointer-events-none col-start-1 row-start-1","size-3.5 self-center justify-self-center stroke-white","group-has-[:disabled]:stroke-gray-950/25"),children:t.jsx("path",{d:"M3 8L6 11L11 3.5",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:r("transition-opacity",s?"opacity-100":"opacity-0")})})]})}),t.jsx("label",{htmlFor:e,className:"block font-mono text-xs uppercase tracking-wider text-text-secondary cursor-pointer select-none",children:i})]})}),b=e.memo(function({href:e,children:s}){return t.jsx(a.a,{href:e,target:"_blank",rel:"noopener noreferrer",whileHover:{scale:1.05},whileTap:{scale:.98},className:"inline-flex items-center gap-1.5 opacity-60 hover:opacity-100 transition-opacity",children:s})}),y=()=>t.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),w=e.memo(function(){return t.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:"#09090b"},"aria-hidden":"true"})}),k=e.memo(function(){return t.jsxs(a.footer,{variants:p.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[t.jsx("p",{className:"text-center font-mono text-[10px] uppercase tracking-widest text-white/40 mb-3",children:"Powered By"}),t.jsx("div",{className:"mx-auto max-w-xs",children:t.jsxs("div",{className:"flex items-center justify-center gap-4",children:[t.jsx(b,{href:"https://github.com/rightup/pyMC_Repeater",children:t.jsxs("span",{className:"font-mono text-sm font-semibold tracking-tight",children:[t.jsx("span",{style:{color:u},children:"py"}),t.jsx("span",{className:"text-white",children:"MC"})]})}),t.jsx(y,{}),t.jsx(b,{href:"https://meshcore.co.uk",children:t.jsx(x,{height:12,className:"text-white"})}),t.jsx(y,{}),t.jsxs(b,{href:"https://wcmesh.com",children:[t.jsx("div",{className:"size-6 overflow-hidden rounded border border-white/10",children:t.jsx("img",{src:"/assets/WCM_Waves-RN-_ocPH.gif",alt:"",className:"size-full object-cover"})}),t.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})});function N(){const r=s(),[d,m]=e.useState("admin"),[x,b]=e.useState(""),[y,N]=e.useState(n),[M,z]=e.useState(!1),[S,Z]=e.useState(null),T=d.length>0&&x.length>0&&!M;e.useEffect(()=>{o()&&r("/",{replace:!0})},[r]);const W=e.useCallback(()=>Z(null),[]),B=e.useCallback(e=>{m(e.target.value),S&&W()},[S,W]),F=e.useCallback(e=>{b(e.target.value),S&&W()},[S,W]),R=e.useCallback(e=>{N(e),l(e)},[]),A=e.useCallback(async e=>{if(e.preventDefault(),!T)return;z(!0),Z(null);const t=await c(d,x,y);z(!1),t.success?window.location.href="/":Z(t.error??"Login failed")},[T,d,x,y]);return t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-12 sm:px-6 lg:px-8",children:t.jsxs(a.div,{variants:p.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[t.jsx(a.div,{variants:p.item,className:"flex justify-center",children:t.jsx(h,{height:32})}),t.jsxs(a.form,{variants:p.item,onSubmit:A,className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"username",className:C,children:"Username"}),t.jsx("div",{className:"mt-2",children:t.jsx("input",{id:"username",name:"username",type:"text",value:d,onChange:B,required:!0,autoComplete:"username",autoFocus:!0,className:L})})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"password",className:C,children:"Password"}),t.jsx("div",{className:"mt-2",children:t.jsx(g,{id:"password",value:x,onChange:F,required:!0})})]}),t.jsx(v,{id:"remember-me",checked:y,onChange:R,label:"Remember me"}),t.jsx(i,{mode:"wait",children:S&&t.jsx(a.div,{variants:p.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-accent-danger/10 p-3 overflow-hidden",children:t.jsx("p",{className:"text-sm text-accent-danger text-center",children:S})},"error")}),t.jsx(a.div,{whileTap:T?{scale:.98}:void 0,children:t.jsx("button",{type:"submit",disabled:!T,className:f,style:{backgroundColor:u,"--tw-ring-color":u},onMouseEnter:e=>e.currentTarget.style.backgroundColor="#8de04a",onMouseLeave:e=>e.currentTarget.style.backgroundColor=u,children:M?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(j,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),t.jsxs(a.p,{variants:p.item,className:"text-center text-sm/6 text-text-muted",children:["A ",t.jsx("span",{style:{color:u},children:"@RightUp"})," X"," ",t.jsx("span",{style:{color:u},children:"@Treehouse⚡"})," Collab"]})]})}),t.jsx(k,{})]})}export{N as default}; diff --git a/frontend/dist/assets/Logs-EKbeyhLl.js b/frontend/dist/assets/Logs-Cb5GXQFD.js similarity index 92% rename from frontend/dist/assets/Logs-EKbeyhLl.js rename to frontend/dist/assets/Logs-Cb5GXQFD.js index c94e198e..962153e6 100644 --- a/frontend/dist/assets/Logs-EKbeyhLl.js +++ b/frontend/dist/assets/Logs-Cb5GXQFD.js @@ -1 +1 @@ -import{r as s,j as e,F as a,bA as t,bB as l}from"./vendor-react-C341c8YC.js";import{n as r}from"./recharts-6XUQYgRA.js";import{au as i,av as n,d as o,aw as c,v as m,as as x,ax as d}from"./index-CPdqYR4z.js";import{u as p}from"./usePolling-CtRLadGa.js";import{P as h,b as j,a as u,L as g}from"./PageLayout-CcoYWyzO.js";import{C as f}from"./Card-BeZKc0xw.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const v=s.memo(function({log:s}){return e.jsx("div",{className:"p-3 rounded-2xl bg-subtle-fill hover:bg-subtle-fill-strong transition-colors",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:r("type-data-sm w-14 shrink-0",d(s.level)),children:s.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-text-primary break-words whitespace-pre-wrap",children:s.message}),e.jsx("p",{className:"type-data-xs text-text-muted mt-1",children:new Date(s.timestamp).toLocaleString()})]})]})})});function b({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:r("type-data-sm",s?"text-accent-tertiary":"text-accent-primary"),children:s?"DEBUG":"INFO"}),e.jsx("button",{onClick:a,className:r("relative w-10 h-5 rounded-full transition-colors duration-200",s?"bg-accent-tertiary":"bg-accent-primary"),role:"switch","aria-checked":s,children:e.jsx("span",{className:r("absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow-sm transition-transform duration-200",s?"translate-x-5":"translate-x-0")})})]})}function N(){const d=i(),N=n(),w=o(),y=c(),k=m(),[C,D]=s.useState(!1),L=s.useCallback(()=>{D(s=>!s)},[]),P=C?d:d.filter(s=>"DEBUG"!==s.level);return p(y,x.logs,w),e.jsxs(h,{children:[e.jsx(j,{title:"System Logs",icon:e.jsx(a,{}),controls:e.jsx(b,{showDebug:C,onToggle:L})}),e.jsxs(u,{noPadding:!0,children:[e.jsx(f,{listHeader:!0,icon:e.jsx(a,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx("button",{onClick:()=>k(!w),className:r("transition-colors",w?"text-signal-critical hover:text-signal-critical/80":"text-accent-primary hover:text-accent-primary/80 animate-pulse-slow"),title:w?"Pause":"Resume",children:w?e.jsx(t,{className:"w-5 h-5"}):e.jsx(l,{className:"w-5 h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:N&&0===d.length?e.jsx(g,{count:10}):0===P.length?e.jsx("div",{className:"text-center py-12 text-text-muted",children:0===d.length?"No logs available":"No logs match selected filters"}):P.map((s,a)=>e.jsx(v,{log:s},`${s.timestamp}-${a}`))})]})]})}export{N as default}; +import{r as s,j as e,F as a,bA as t,bB as l}from"./vendor-react-C341c8YC.js";import{n as r}from"./recharts-6XUQYgRA.js";import{au as i,av as n,d as o,aw as c,v as m,as as x,ax as d}from"./index-BJEgt3tp.js";import{u as p}from"./usePolling-CtRLadGa.js";import{P as h,b as j,a as u,L as g}from"./PageLayout-CnF5SScd.js";import{C as f}from"./Card-2pQSGkKC.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const v=s.memo(function({log:s}){return e.jsx("div",{className:"p-3 rounded-2xl bg-subtle-fill hover:bg-subtle-fill-strong transition-colors",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:r("type-data-sm w-14 shrink-0",d(s.level)),children:s.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-text-primary break-words whitespace-pre-wrap",children:s.message}),e.jsx("p",{className:"type-data-xs text-text-muted mt-1",children:new Date(s.timestamp).toLocaleString()})]})]})})});function b({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:r("type-data-sm",s?"text-accent-tertiary":"text-accent-primary"),children:s?"DEBUG":"INFO"}),e.jsx("button",{onClick:a,className:r("relative w-10 h-5 rounded-full transition-colors duration-200",s?"bg-accent-tertiary":"bg-accent-primary"),role:"switch","aria-checked":s,children:e.jsx("span",{className:r("absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow-sm transition-transform duration-200",s?"translate-x-5":"translate-x-0")})})]})}function N(){const d=i(),N=n(),w=o(),y=c(),k=m(),[C,D]=s.useState(!1),L=s.useCallback(()=>{D(s=>!s)},[]),P=C?d:d.filter(s=>"DEBUG"!==s.level);return p(y,x.logs,w),e.jsxs(h,{children:[e.jsx(j,{title:"System Logs",icon:e.jsx(a,{}),controls:e.jsx(b,{showDebug:C,onToggle:L})}),e.jsxs(u,{noPadding:!0,children:[e.jsx(f,{listHeader:!0,icon:e.jsx(a,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx("button",{onClick:()=>k(!w),className:r("transition-colors",w?"text-signal-critical hover:text-signal-critical/80":"text-accent-primary hover:text-accent-primary/80 animate-pulse-slow"),title:w?"Pause":"Resume",children:w?e.jsx(t,{className:"w-5 h-5"}):e.jsx(l,{className:"w-5 h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:N&&0===d.length?e.jsx(g,{count:10}):0===P.length?e.jsx("div",{className:"text-center py-12 text-text-muted",children:0===d.length?"No logs available":"No logs match selected filters"}):P.map((s,a)=>e.jsx(v,{log:s},`${s.timestamp}-${a}`))})]})]})}export{N as default}; diff --git a/frontend/dist/assets/MeshGraph-CdoFbL_m.js b/frontend/dist/assets/MeshGraph-DfCwG9Nt.js similarity index 99% rename from frontend/dist/assets/MeshGraph-CdoFbL_m.js rename to frontend/dist/assets/MeshGraph-DfCwG9Nt.js index 5cccdfc5..520a1f1f 100644 --- a/frontend/dist/assets/MeshGraph-CdoFbL_m.js +++ b/frontend/dist/assets/MeshGraph-DfCwG9Nt.js @@ -1 +1 @@ -import{r as e,j as t,aq as s,W as a,aQ as n,al as l,aK as i,bo as r,aJ as o,w as c,v as d,bp as x,bq as u,br as m,bs as p,A as h,m as b,X as g,bt as f,as as j,bu as y,E as v,a9 as N,ab as w,aY as C,bv as k,aX as S,C as L,bw as E,a1 as B}from"./vendor-react-C341c8YC.js";import"./recharts-6XUQYgRA.js";import{p as M,ak as H,r as R,al as P,am as D,e as F,a5 as I,an as G,T}from"./index-CPdqYR4z.js";import{D as Z}from"./DeepAnalysisModal-DysenxvY.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const z={type:"spring",stiffness:500,damping:35},$=Math.PI/180;function A(e,t){if(e<=0)return 0;const s=t-e;if(s>1209600)return 0;if(s<0)return 1;const a=s/3600;return Math.exp(-a/12)}function O(e,t){const s=Math.max(.2,Math.min(1,t)),a=e.replace("#",""),n=parseInt(a.substring(0,2),16),l=parseInt(a.substring(2,4),16),i=parseInt(a.substring(4,6),16),r=e=>Math.round(e*s+128*(1-s));return`#${r(n).toString(16).padStart(2,"0")}${r(l).toString(16).padStart(2,"0")}${r(i).toString(16).padStart(2,"0")}`}const W={simulationRepulsion:1.5,simulationLinkDistance:100,simulationGravity:.003,simulationCenter:.015,simulationFriction:.85},K={local:"#FBBF24",hub:"#6366F1",gateway:"#8B5CF6",backbone:"#10B981",neighbor:"#F59E0B",mobile:"#F97316",ghost:"#6B7280",standard:"#64748B"},V={local:"Local Node",hub:"Hub (≥10% traffic)",gateway:"Gateway (7-10%)",backbone:"Backbone",neighbor:"Direct RF Neighbor",mobile:"Mobile/Volatile",ghost:"Discovered (unconfirmed)",standard:"Standard Node"},_={local:w,hub:N,gateway:o,backbone:o,neighbor:v,mobile:y,ghost:j,standard:f},q="#FBBF24",Q="#8B5CF6",X="#10B981",Y="#F59E0B",J=["#440154","#482878","#3E4A89","#31688E","#26828E","#1F9E89","#35B779","#6DCD59","#B4DE2C","#FDE725"];function U(e,t,s,a,n={x:0,y:0}){const l=e*$,i=s*$,r=(t-a)*$,o=(e-s)*$,c=637100;return n.x=r*Math.cos(.5*(l+i))*c,n.y=o*c,n}function ee(e,t){if(t<=0||e<=0)return J[0];const s=Math.log10(e+1),a=Math.log10(t+1),n=Math.min(1,s/a),l=Math.min(J.length-1,Math.floor(n*J.length));return J[l]}const te=["local","hub","gateway","backbone","neighbor","mobile","ghost","standard"];function se({nodeCount:s,edgeCount:a,nodeClassCounts:n,hasZeroHopEdges:l,hasLoopEdges:i,hasDirectPathEdges:r}){const[c,d]=e.useState(!0),[x,u]=e.useState(!0);return t.jsxs("div",{className:"absolute bottom-4 left-4 z-10 bg-bg-elevated/95 backdrop-blur-sm rounded-lg border border-border-subtle shadow-lg min-w-[200px] max-w-[240px] type-data-xs",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-subtle",children:[t.jsx("span",{className:"font-medium text-text-primary",children:"Mesh Topology"}),t.jsxs("span",{className:"text-text-muted tabular-nums",children:[s,"n / ",a,"e"]})]}),t.jsxs("div",{className:"border-b border-border-subtle",children:[t.jsxs("button",{type:"button",onClick:()=>d(!c),className:"w-full flex items-center justify-between px-3 py-1.5 hover:bg-subtle-fill/50 transition-colors",children:[t.jsx("span",{className:"text-text-secondary",children:"Node Types"}),t.jsx(b.span,{animate:{rotate:c?0:-90},transition:{duration:.15},children:t.jsx(L,{className:"w-3 h-3 text-text-muted"})})]}),t.jsx(h,{initial:!1,children:c&&t.jsx(b.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:z,className:"overflow-hidden",children:t.jsx("div",{className:"px-3 pb-2 space-y-1",children:te.map(e=>{const s=n[e];if(0===s)return null;const a=_[e];return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 rounded-full",style:{width:8,height:8,backgroundColor:K[e]}}),t.jsx(a,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"text-text-secondary flex-1 truncate",children:V[e]}),t.jsx("span",{className:"text-text-muted tabular-nums",children:s})]},e)})})})})]}),t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>u(!x),className:"w-full flex items-center justify-between px-3 py-1.5 hover:bg-subtle-fill/50 transition-colors",children:[t.jsx("span",{className:"text-text-secondary",children:"Edge Types"}),t.jsx(b.span,{animate:{rotate:x?0:-90},transition:{duration:.15},children:t.jsx(L,{className:"w-3 h-3 text-text-muted"})})]}),t.jsx(h,{initial:!1,children:x&&t.jsx(b.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:z,className:"overflow-hidden",children:t.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[l&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:q}}),t.jsx(v,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Direct RF (zero-hop)"})]}),i&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:Q}}),t.jsx(E,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Loop (redundant path)"})]}),r&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:X}}),t.jsx(B,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Confirmed unicast"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:"#64748B"}}),t.jsx(o,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Standard edge"})]}),t.jsxs("div",{className:"pt-1 mt-1 border-t border-border-subtle/50",children:[t.jsx("div",{className:"text-text-muted text-[10px] mb-1",children:"Edge thickness = certainty"}),t.jsx("div",{className:"h-2 rounded-sm",style:{background:`linear-gradient(to right, ${J.slice(0,5).join(", ")}, ${Y})`}}),t.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted",children:[t.jsx("span",{children:"Low"}),t.jsx("span",{children:"High"})]})]})]})})})]})]})}function ae({node:e,onClose:s,onZoomTo:a}){const n=_[e.nodeClass],l={active:{label:"Active",color:"text-accent-success"},recent:{label:"Recent",color:"text-accent-secondary"},stale:{label:"Stale",color:"text-signal-poor"},inactive:{label:"Inactive",color:"text-text-muted"}}[e.activityLevel]??{label:e.activityLevel,color:"text-text-muted"};return t.jsxs(b.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},className:"absolute top-4 right-4 z-20 bg-bg-elevated/95 backdrop-blur-sm rounded-xl border border-border-subtle shadow-2xl w-72",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 rounded-full ring-2 ring-offset-1 ring-offset-bg-elevated",style:{width:10,height:10,backgroundColor:K[e.nodeClass],boxShadow:`0 0 8px ${K[e.nodeClass]}40`}}),t.jsx(n,{className:"w-3.5 h-3.5 text-text-muted"}),t.jsx("span",{className:"font-medium text-text-primary type-data-sm",children:e.prefix})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[e.isLocal&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-300",children:"LOCAL"}),a&&t.jsx(T,{content:"Zoom to node",children:t.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-subtle-fill transition-colors",children:t.jsx(C,{className:"w-3.5 h-3.5 text-text-muted"})})}),t.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-subtle-fill transition-colors",children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted"})})]})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs",children:[e.name&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Name"}),t.jsx("span",{className:"text-text-primary font-medium truncate ml-2",children:e.name})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:"text-text-secondary capitalize",children:V[e.nodeClass]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Activity"}),t.jsx("span",{className:l.color,children:l.label})]})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs border-t border-border-subtle",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"text-text-secondary tabular-nums",children:e.packetCount.toLocaleString()})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Connections"}),t.jsx("span",{className:"text-text-secondary tabular-nums",children:e.degree})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Betweenness"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[(100*e.betweenness).toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Community"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:["#",e.communityId]})]})]}),e.isZeroHop&&(null!==e.avgRssi||null!==e.avgSnr)&&t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs border-t border-border-subtle",children:[t.jsx("div",{className:"text-text-muted text-[10px] uppercase tracking-wide",children:"Signal Quality"}),null!==e.avgRssi&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[e.avgRssi.toFixed(0)," dBm"]})]}),null!==e.avgSnr&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),(e.isHub||e.isGateway||e.isBackbone||e.isMobile||e.isInLoop)&&t.jsx("div",{className:"px-3 py-2 border-t border-border-subtle",children:t.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.isHub&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-indigo-500/20 text-indigo-300",children:"Hub"}),e.isGateway&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/20 text-violet-300",children:"Gateway"}),e.isBackbone&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:"Backbone"}),e.isMobile&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-orange-500/20 text-orange-300",children:"Mobile"}),e.isInLoop&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-300",children:"In Loop"})]})}),e.hasCollision&&t.jsx("div",{className:"px-3 py-2 border-t border-border-subtle",children:t.jsxs("div",{className:"flex justify-between type-data-xs",children:[t.jsx("span",{className:"text-signal-poor",children:"Prefix collision"}),t.jsxs("span",{className:"text-text-muted tabular-nums",children:[(100*e.prefixConfidence).toFixed(0),"% conf"]})]})}),t.jsxs("div",{className:"px-3 py-2 border-t border-border-subtle space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between type-data-xs",children:[t.jsx("span",{className:"text-text-muted",children:"Position"}),t.jsx("span",{className:e.hasGeo?"text-accent-success":"text-text-muted",children:e.hasGeo?"GPS":"Simulated"})]}),t.jsx("div",{children:t.jsx("span",{className:"text-text-muted break-all text-[10px] leading-relaxed font-mono",children:e.hash})})]})]})}function ne(){return t.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 text-center px-8",children:[t.jsx("div",{className:"p-4 rounded-full bg-subtle-fill",children:t.jsx(S,{className:"w-8 h-8 text-text-muted"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h2",{className:"text-lg font-medium text-text-primary",children:"No Topology Data"}),t.jsx("p",{className:"text-sm text-text-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed. This typically takes a few minutes after starting."})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted mt-2",children:[t.jsx(v,{className:"w-4 h-4 animate-pulse"}),t.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}function le(){var f;const j=M(),[y,v]=e.useState(!1),N=H(),w=R(),[S,L]=e.useState(!1),[E,B]=e.useState("fetching"),[z,$]=e.useState(0),V=e.useRef(!1);e.useEffect(()=>{j&&!V.current&&(V.current=!0,(async()=>{L(!0),B("fetching"),$(0),await N(),B("analyzing"),await new Promise(e=>setTimeout(e,200)),B("building");const e=Date.now(),t=Date.now()-e;t<600&&await new Promise(e=>setTimeout(e,600-t)),B("discovering"),await new Promise(e=>setTimeout(e,400)),B("complete"),await new Promise(e=>setTimeout(e,800)),L(!1),v(!0)})())},[j,N]),e.useEffect(()=>{"fetching"===E&&(w.loadProgress?$(w.loadProgress.loaded):w.packetCount>0&&$(w.packetCount))},[E,w.loadProgress,w.packetCount]);const J=P(),te=D(),le=F(),ie=I(),[re,oe]=e.useState(!0),[ce,de]=e.useState(null),[xe,ue]=e.useState("all"),[me,pe]=e.useState(!0),[he,be]=e.useState(!0),[ge,fe]=e.useState(""),[je,ye]=e.useState(!1),ve=e.useRef(null),[Ne,we]=e.useState(null),[Ce,ke]=e.useState({x:0,y:0}),Se=e.useRef(null),[Le,Ee]=e.useState(!1),Be=G();e.useEffect(()=>{const e=e=>{var t;if(!(e.target instanceof HTMLInputElement))switch(e.key.toLowerCase()){case"f":e.metaKey||e.ctrlKey||(e.preventDefault(),null==(t=qe.current)||t.fitView(300));break;case"escape":je?(ye(!1),fe("")):ce&&de(null);break;case"/":je||(e.preventDefault(),ye(!0),setTimeout(()=>{var e;return null==(e=ve.current)?void 0:e.focus()},50));break;case" ":e.preventDefault();{const e=qe.current;e&&(re?e.pause():e.start(),oe(e=>!e))}break;case"l":pe(e=>!e);break;case"e":be(e=>!e)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[je,ce,re]);const Me=(null==ie?void 0:ie.latitude)??0,He=(null==ie?void 0:ie.longitude)??0,Re=null!==ie,Pe=e.useMemo(()=>Math.floor(Date.now()/1e3),[]),De=e.useMemo(()=>{var e;if(!te||0===te.size||!y)return[];const t=[],s=(null==le?void 0:le.node_name)??(null==(e=null==le?void 0:le.config)?void 0:e.node_name)??null,a={x:0,y:0};for(const n of te.values()){const e=n.isLocal?1:A(n.lastSeen,Pe);if(0===e&&!n.isLocal)continue;const l=K[n.nodeClass],i=n.isLocal?l:O(l,e),r=6+22*n.betweenness,o=n.isLocal?r:r*(.5+.5*e),c=n.isLocal?s??n.name:n.name;let d,x,u=!1;Re&&(n.isLocal?(d=0,x=0,u=!0):n.latitude&&n.longitude&&(U(n.latitude,n.longitude,Me,He,a),d=a.x,x=a.y,u=!0)),t.push({id:n.hash,label:c?`${n.prefix} ${c}`:n.prefix,color:i,size:o,x:d,y:x,recencyWeight:e,nodeClass:n.nodeClass,name:c,prefix:n.prefix,packetCount:n.packetCount,betweenness:n.betweenness,communityId:n.communityId,isLocal:n.isLocal,isHub:n.isHub,isGateway:n.isGateway,isBackbone:n.isBackbone,isMobile:n.isMobile,isGhost:n.isGhost,isInLoop:n.isInLoop,isZeroHop:n.isZeroHop,hasGeo:u,avgRssi:n.avgRssi,avgSnr:n.avgSnr,degree:n.degree,activityLevel:n.activityLevel,prefixConfidence:n.prefixConfidence,hasCollision:n.hasCollision,lastSeen:n.lastSeen})}return t},[te,y,Re,Me,He,null==le?void 0:le.node_name,null==(f=null==le?void 0:le.config)?void 0:f.node_name,Pe]),Fe=e.useMemo(()=>{const e=new Set;for(const t of De)e.add(t.id);return e},[De]),{rawLinks:Ie,hasZeroHopEdges:Ge,hasLoopEdges:Te,hasDirectPathEdges:Ze}=e.useMemo(()=>{const e=null==J?void 0:J.validatedEdges;if(!e||0===e.length||!y)return{rawLinks:[],maxCertainCount:0,hasZeroHopEdges:!1,hasLoopEdges:!1,hasDirectPathEdges:!1};let t=0,s=!1,a=!1,n=!1;for(const o of e)o.avgRecency<.02||Fe.has(o.fromHash)&&Fe.has(o.toHash)&&(o.certainCount>t&&(t=o.certainCount),s=s||!0===o.isZeroHop,a=a||!0===o.isLoopEdge,n=n||!0===o.isDirectPathEdge);const l=t>0?Math.log10(t+1):1,i=.8*t,r=[];for(const o of e){const e=o.avgRecency;if(e<.02)continue;if(!Fe.has(o.fromHash)||!Fe.has(o.toHash))continue;let s=.5;if(t>0&&o.certainCount>0){const e=Math.log10(o.certainCount+1);s=.5+7.5*Math.min(1,e/l)}const a=s*(.3+.7*e);let n;n=o.isZeroHop?q:o.isLoopEdge?Q:o.isDirectPathEdge?X:o.certainCount>i?Y:ee(o.certainCount,t);const c=O(n,e);r.push({source:o.fromHash,target:o.toHash,color:c,width:a,strength:.3+.7*o.strength,recencyWeight:e,packetCount:o.packetCount,certainCount:o.certainCount,isZeroHop:o.isZeroHop??!1,isLoopEdge:o.isLoopEdge??!1,isDirectPath:o.isDirectPathEdge,avgConfidence:o.avgConfidence})}return{rawLinks:r,maxCertainCount:t,hasZeroHopEdges:s,hasLoopEdges:a,hasDirectPathEdges:n}},[null==J?void 0:J.validatedEdges,y,Fe]),ze=e.useMemo(()=>{const e=new Map;for(const t of Ie)e.set(t.source,(e.get(t.source)??0)+1),e.set(t.target,(e.get(t.target)??0)+1);return e},[Ie]),$e=e.useMemo(()=>{const e=new Map;for(const t of De)e.set(t.id,t);return e},[De]),[Ae,Oe]=e.useState(null),[We,Ke]=e.useState(null),[Ve,_e]=e.useState({}),qe=e.useRef(null),Qe=e.useRef(!1),Xe=e.useRef(null);e.useEffect(()=>{var e,t;if(0===De.length||0===Ie.length)return Oe(null),Ke(null),void(Xe.current=null);const s=`${De.length}:${Ie.length}:${null==(e=De[0])?void 0:e.id}:${null==(t=De[De.length-1])?void 0:t.id}`;if(s===Xe.current||Qe.current)return;let a=!1;return Qe.current=!0,(async()=>{try{const e=De.map(e=>({id:e.id,label:e.label,color:e.color})),t=Ie.map(e=>({source:e.source,target:e.target,color:e.color,width:e.width})),n=new Set(t.map(e=>e.width)),l={points:{pointIdBy:"id",pointColorBy:"color",pointLabelBy:"label",pointDefaultColor:"#64748B",pointGreyoutOpacity:.3,pointDefaultSize:12,pointSizeScale:1},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",...t.length>=2&&n.size>=2?{linkWidthBy:"width",linkWidthRange:[.5,8]}:{},linkDefaultWidth:1,linkDefaultColor:"#4B5563",linkGreyoutOpacity:.2,linkWidthScale:1}},i=await k(l,e,t);if(a||!i)return;const{points:r,links:o,cosmographConfig:c}=i;Oe(r??null),Ke(o??null),_e({...c,...W}),Xe.current=s}finally{Qe.current=!1}})(),()=>{a=!0}},[De,Ie]);const Ye=e.useCallback(e=>{qe.current=e},[]),Je=e.useCallback(()=>{var e;null==(e=qe.current)||e.fitView(300)},[]),Ue=e.useCallback(()=>{const e=qe.current;e&&(re?e.pause():e.start(),oe(!re))},[re]),et=e.useCallback(async e=>{const t=qe.current;if(t)try{const s=await t.getPointIndicesByIds([e]);s&&s.length>0&&void 0!==s[0]&&t.zoomToPoint(s[0],400,2.5)}catch{}},[]),tt=e.useMemo(()=>{if(!ge.trim())return[];const e=ge.toLowerCase();return De.filter(t=>{var s;return t.prefix.toLowerCase().includes(e)||(null==(s=t.name)?void 0:s.toLowerCase().includes(e))||t.id.toLowerCase().includes(e)}).slice(0,8)},[De,ge]),st=e.useCallback(e=>{et(e.id),ye(!1),fe(""),de({hash:e.id,name:e.name,prefix:e.prefix,nodeClass:e.nodeClass,packetCount:e.packetCount,edgeCount:ze.get(e.id)??0,betweenness:e.betweenness,communityId:e.communityId,degree:e.degree,hasGeo:e.hasGeo,isLocal:e.isLocal,isHub:e.isHub,isGateway:e.isGateway,isBackbone:e.isBackbone,isMobile:e.isMobile,isInLoop:e.isInLoop,isZeroHop:e.isZeroHop,avgRssi:e.avgRssi,avgSnr:e.avgSnr,activityLevel:e.activityLevel,prefixConfidence:e.prefixConfidence,hasCollision:e.hasCollision})},[et,ze]),at=e.useRef(void 0),nt=e.useRef(0),lt=e.useCallback(async(e,t,s)=>{const a=Date.now();if(s&&a-nt.current>=16&&(nt.current=a,ke({x:s.clientX,y:s.clientY})),e===at.current)return;at.current=e,Se.current&&(clearTimeout(Se.current),Se.current=null);const n=qe.current;if(n)if(void 0!==e)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=$e.get(s);if(!a)return;we(a),n.selectPoint(e,!1,!0)}catch{we(null)}else Se.current=setTimeout(()=>{we(null),ce||n.unselectAllPoints()},100)},[$e,ce]),it=e.useCallback(()=>{Ee(e=>!e)},[]),rt=e.useCallback(()=>{ue(e=>{const t=["all","hubs","neighbors","active"],s=t.indexOf(e);return t[(s+1)%t.length]})},[]),ot={all:"All nodes",hubs:"Hubs & gateways only",neighbors:"Direct RF neighbors",active:"Recently active"},ct=e.useCallback(async(e,t,s)=>{var a;if(we(null),at.current=void 0,void 0===e)return de(null),void(null==(a=qe.current)||a.unselectAllPoints());const n=qe.current;if(n)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=$e.get(s);if(!a)return;n.selectPoint(e,!1),de({hash:s,name:a.name,prefix:a.prefix,nodeClass:a.nodeClass,packetCount:a.packetCount,edgeCount:ze.get(s)??0,betweenness:a.betweenness,communityId:a.communityId,degree:a.degree,hasGeo:a.hasGeo,isLocal:a.isLocal,isHub:a.isHub,isGateway:a.isGateway,isBackbone:a.isBackbone,isMobile:a.isMobile,isInLoop:a.isInLoop,isZeroHop:a.isZeroHop,avgRssi:a.avgRssi,avgSnr:a.avgSnr,activityLevel:a.activityLevel,prefixConfidence:a.prefixConfidence,hasCollision:a.hasCollision})}catch{}},[$e,ze]);if(!y)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex items-center justify-center bg-black",children:[t.jsx(Z,{isOpen:S,currentStep:E,packetCount:z}),!S&&t.jsx(s,{className:"w-8 h-8 text-accent-primary animate-spin"})]});if(0===De.length)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex flex-col bg-black overflow-hidden",children:[t.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle bg-bg-elevated/50",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(a,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]})]})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(ne,{})})]});if(!Ae)return t.jsx("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex items-center justify-center bg-black",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(s,{className:"w-8 h-8 text-accent-primary animate-spin"}),t.jsx("span",{className:"text-sm text-text-muted",children:"Preparing graph..."})]})});const dt=Le?"fixed inset-0 z-50 bg-black":"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] bg-black";return t.jsxs("div",{className:`${dt} flex flex-col overflow-hidden`,children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle/50 bg-black/80 backdrop-blur-sm z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(a,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]}),t.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[De.length," nodes • ",Ie.length," edges"]}),"all"!==xe&&t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-accent-primary/20 text-accent-primary",children:ot[xe]})]}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx(T,{content:"Search nodes (/)",children:t.jsx("button",{onClick:()=>{ye(!0),setTimeout(()=>{var e;return null==(e=ve.current)?void 0:e.focus()},50)},className:"p-2 rounded-lg transition-colors "+(je?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:t.jsx(n,{className:"w-4 h-4"})})}),t.jsx(T,{content:`Filter: ${ot[xe]}`,children:t.jsx("button",{onClick:rt,className:"p-2 rounded-lg transition-colors "+("all"!==xe?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:t.jsx(l,{className:"w-4 h-4"})})}),t.jsx("div",{className:"w-px h-4 bg-border-subtle mx-1"}),t.jsx(T,{content:(me?"Hide":"Show")+" labels (L)",children:t.jsx("button",{onClick:()=>pe(e=>!e),className:"p-2 rounded-lg transition-colors "+(me?"text-text-muted hover:bg-subtle-fill":"text-text-muted/50 hover:bg-subtle-fill"),children:me?t.jsx(i,{className:"w-4 h-4"}):t.jsx(r,{className:"w-4 h-4"})})}),t.jsx(T,{content:(he?"Hide":"Show")+" edges (E)",children:t.jsx("button",{onClick:()=>be(e=>!e),className:"p-2 rounded-lg transition-colors "+(he?"text-text-muted hover:bg-subtle-fill":"text-text-muted/50 hover:bg-subtle-fill"),children:t.jsx(o,{className:"w-4 h-4"})})}),t.jsx("div",{className:"w-px h-4 bg-border-subtle mx-1"}),t.jsx(T,{content:(re?"Pause":"Resume")+" simulation (Space)",children:t.jsx("button",{onClick:Ue,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:re?t.jsx(c,{className:"w-4 h-4 text-accent-success"}):t.jsx(d,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(T,{content:"Fit view (F)",children:t.jsx("button",{onClick:Je,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:t.jsx(x,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(T,{content:Le?"Exit fullscreen":"Fullscreen",children:t.jsx("button",{onClick:it,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:Le?t.jsx(u,{className:"w-4 h-4 text-text-muted"}):t.jsx(m,{className:"w-4 h-4 text-text-muted"})})})]})]}),t.jsxs("div",{className:"flex-1 relative min-h-0",children:[t.jsx(p,{className:"absolute inset-0",points:Ae,links:he?We:void 0,...Ve,backgroundColor:"#000000",fitViewOnInit:!0,showLabels:me,showDynamicLabels:me,showTopLabels:me,showTopLabelsLimit:30,showHoveredPointLabel:!1,pointLabelColor:"#E2E8F0",pointLabelFontSize:11,onClick:ct,onMouseMove:lt,onMount:Ye,renderHoveredPointRing:!0,hoveredPointRingColor:"#FBBF24",hoveredPointCursor:"pointer",pointGreyoutOpacity:.15,linkGreyoutOpacity:.1}),t.jsx(h,{children:Ne&&t.jsx(b.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.1},className:"fixed z-50 pointer-events-none",style:{left:Ce.x+16,top:Ce.y-8},children:t.jsxs("div",{className:"bg-bg-elevated/95 backdrop-blur-md rounded-lg border border-border-subtle shadow-2xl px-3 py-2 max-w-xs",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0 ring-1 ring-white/20",style:{backgroundColor:K[Ne.nodeClass],boxShadow:`0 0 6px ${K[Ne.nodeClass]}60`}}),t.jsx("span",{className:"font-medium text-text-primary text-sm truncate",children:Ne.name||Ne.prefix}),Ne.isLocal&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-yellow-500/20 text-yellow-300 shrink-0",children:"LOCAL"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[t.jsx("span",{className:"capitalize",children:Ne.nodeClass}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:[Ne.packetCount.toLocaleString()," pkts"]}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:[Ne.degree," conn"]})]}),Ne.isZeroHop&&(null!==Ne.avgSnr||null!==Ne.avgRssi)&&t.jsxs("div",{className:"flex items-center gap-2 mt-1 pt-1 border-t border-border-subtle/50 text-[10px]",children:[null!==Ne.avgSnr&&t.jsxs("span",{className:"text-accent-success",children:["SNR: ",Ne.avgSnr.toFixed(1)," dB"]}),null!==Ne.avgRssi&&t.jsxs("span",{className:"text-text-muted",children:["RSSI: ",Ne.avgRssi.toFixed(0)," dBm"]})]}),(Ne.isHub||Ne.isGateway||Ne.isBackbone||Ne.isMobile)&&t.jsxs("div",{className:"flex items-center gap-1 mt-1 pt-1 border-t border-border-subtle/50",children:[Ne.isHub&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-indigo-500/20 text-indigo-300",children:"Hub"}),Ne.isGateway&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-violet-500/20 text-violet-300",children:"Gateway"}),Ne.isBackbone&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:"Backbone"}),Ne.isMobile&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-orange-500/20 text-orange-300",children:"Mobile"})]}),t.jsx("div",{className:"text-[9px] text-text-muted/60 mt-1",children:"Click for details"})]})})}),t.jsx(h,{children:je&&t.jsx(b.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:t.jsxs("div",{className:"bg-bg-elevated/95 backdrop-blur-sm rounded-xl border border-border-subtle shadow-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle",children:[t.jsx(n,{className:"w-4 h-4 text-text-muted shrink-0"}),t.jsx("input",{ref:ve,type:"text",value:ge,onChange:e=>fe(e.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none",onKeyDown:e=>{"Escape"===e.key?(ye(!1),fe("")):"Enter"===e.key&&tt.length>0&&st(tt[0])}}),ge&&t.jsx("button",{onClick:()=>fe(""),className:"p-0.5 rounded hover:bg-subtle-fill",children:t.jsx(g,{className:"w-3 h-3 text-text-muted"})})]}),tt.length>0&&t.jsx("div",{className:"max-h-64 overflow-y-auto",children:tt.map((e,s)=>{const a=_[e.nodeClass];return t.jsxs("button",{onClick:()=>st(e),className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-subtle-fill transition-colors "+(0===s?"bg-subtle-fill/50":""),children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:K[e.nodeClass]}}),t.jsx(a,{className:"w-3.5 h-3.5 text-text-muted shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-text-primary truncate",children:e.name||e.prefix}),e.name&&t.jsx("div",{className:"text-[10px] text-text-muted",children:e.prefix})]}),t.jsx(C,{className:"w-3 h-3 text-text-muted shrink-0"})]},e.id)})}),ge&&0===tt.length&&t.jsx("div",{className:"px-3 py-4 text-center text-sm text-text-muted",children:"No nodes found"}),!ge&&t.jsx("div",{className:"px-3 py-2 text-[10px] text-text-muted",children:"Type to search • Enter to select • Esc to close"})]})})}),t.jsx(se,{nodeCount:De.length,edgeCount:Ie.length,nodeClassCounts:Be,hasZeroHopEdges:Ge,hasLoopEdges:Te,hasDirectPathEdges:Ze}),t.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 text-[10px] text-text-muted/60",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),t.jsx(h,{children:ce&&t.jsx(ae,{node:ce,onClose:()=>de(null),onZoomTo:()=>et(ce.hash)})})]})]})}export{le as default}; +import{r as e,j as t,aq as s,W as a,aQ as n,al as l,aK as i,bo as r,aJ as o,w as c,v as d,bp as x,bq as u,br as m,bs as p,A as h,m as b,X as g,bt as f,as as j,bu as y,E as v,a9 as N,ab as w,aY as C,bv as k,aX as S,C as L,bw as E,a1 as B}from"./vendor-react-C341c8YC.js";import"./recharts-6XUQYgRA.js";import{p as M,ak as H,r as R,al as P,am as D,e as F,a5 as I,an as G,T}from"./index-BJEgt3tp.js";import{D as Z}from"./DeepAnalysisModal-D4eqwCNZ.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const z={type:"spring",stiffness:500,damping:35},$=Math.PI/180;function A(e,t){if(e<=0)return 0;const s=t-e;if(s>1209600)return 0;if(s<0)return 1;const a=s/3600;return Math.exp(-a/12)}function O(e,t){const s=Math.max(.2,Math.min(1,t)),a=e.replace("#",""),n=parseInt(a.substring(0,2),16),l=parseInt(a.substring(2,4),16),i=parseInt(a.substring(4,6),16),r=e=>Math.round(e*s+128*(1-s));return`#${r(n).toString(16).padStart(2,"0")}${r(l).toString(16).padStart(2,"0")}${r(i).toString(16).padStart(2,"0")}`}const W={simulationRepulsion:1.5,simulationLinkDistance:100,simulationGravity:.003,simulationCenter:.015,simulationFriction:.85},K={local:"#FBBF24",hub:"#6366F1",gateway:"#8B5CF6",backbone:"#10B981",neighbor:"#F59E0B",mobile:"#F97316",ghost:"#6B7280",standard:"#64748B"},V={local:"Local Node",hub:"Hub (≥10% traffic)",gateway:"Gateway (7-10%)",backbone:"Backbone",neighbor:"Direct RF Neighbor",mobile:"Mobile/Volatile",ghost:"Discovered (unconfirmed)",standard:"Standard Node"},_={local:w,hub:N,gateway:o,backbone:o,neighbor:v,mobile:y,ghost:j,standard:f},q="#FBBF24",Q="#8B5CF6",X="#10B981",Y="#F59E0B",J=["#440154","#482878","#3E4A89","#31688E","#26828E","#1F9E89","#35B779","#6DCD59","#B4DE2C","#FDE725"];function U(e,t,s,a,n={x:0,y:0}){const l=e*$,i=s*$,r=(t-a)*$,o=(e-s)*$,c=637100;return n.x=r*Math.cos(.5*(l+i))*c,n.y=o*c,n}function ee(e,t){if(t<=0||e<=0)return J[0];const s=Math.log10(e+1),a=Math.log10(t+1),n=Math.min(1,s/a),l=Math.min(J.length-1,Math.floor(n*J.length));return J[l]}const te=["local","hub","gateway","backbone","neighbor","mobile","ghost","standard"];function se({nodeCount:s,edgeCount:a,nodeClassCounts:n,hasZeroHopEdges:l,hasLoopEdges:i,hasDirectPathEdges:r}){const[c,d]=e.useState(!0),[x,u]=e.useState(!0);return t.jsxs("div",{className:"absolute bottom-4 left-4 z-10 bg-bg-elevated/95 backdrop-blur-sm rounded-lg border border-border-subtle shadow-lg min-w-[200px] max-w-[240px] type-data-xs",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-subtle",children:[t.jsx("span",{className:"font-medium text-text-primary",children:"Mesh Topology"}),t.jsxs("span",{className:"text-text-muted tabular-nums",children:[s,"n / ",a,"e"]})]}),t.jsxs("div",{className:"border-b border-border-subtle",children:[t.jsxs("button",{type:"button",onClick:()=>d(!c),className:"w-full flex items-center justify-between px-3 py-1.5 hover:bg-subtle-fill/50 transition-colors",children:[t.jsx("span",{className:"text-text-secondary",children:"Node Types"}),t.jsx(b.span,{animate:{rotate:c?0:-90},transition:{duration:.15},children:t.jsx(L,{className:"w-3 h-3 text-text-muted"})})]}),t.jsx(h,{initial:!1,children:c&&t.jsx(b.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:z,className:"overflow-hidden",children:t.jsx("div",{className:"px-3 pb-2 space-y-1",children:te.map(e=>{const s=n[e];if(0===s)return null;const a=_[e];return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 rounded-full",style:{width:8,height:8,backgroundColor:K[e]}}),t.jsx(a,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"text-text-secondary flex-1 truncate",children:V[e]}),t.jsx("span",{className:"text-text-muted tabular-nums",children:s})]},e)})})})})]}),t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>u(!x),className:"w-full flex items-center justify-between px-3 py-1.5 hover:bg-subtle-fill/50 transition-colors",children:[t.jsx("span",{className:"text-text-secondary",children:"Edge Types"}),t.jsx(b.span,{animate:{rotate:x?0:-90},transition:{duration:.15},children:t.jsx(L,{className:"w-3 h-3 text-text-muted"})})]}),t.jsx(h,{initial:!1,children:x&&t.jsx(b.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:z,className:"overflow-hidden",children:t.jsxs("div",{className:"px-3 pb-2 space-y-1",children:[l&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:q}}),t.jsx(v,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Direct RF (zero-hop)"})]}),i&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:Q}}),t.jsx(E,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Loop (redundant path)"})]}),r&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:X}}),t.jsx(B,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Confirmed unicast"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-4 h-0.5 rounded-full",style:{backgroundColor:"#64748B"}}),t.jsx(o,{className:"w-3 h-3 text-text-muted"}),t.jsx("span",{className:"text-text-secondary",children:"Standard edge"})]}),t.jsxs("div",{className:"pt-1 mt-1 border-t border-border-subtle/50",children:[t.jsx("div",{className:"text-text-muted text-[10px] mb-1",children:"Edge thickness = certainty"}),t.jsx("div",{className:"h-2 rounded-sm",style:{background:`linear-gradient(to right, ${J.slice(0,5).join(", ")}, ${Y})`}}),t.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted",children:[t.jsx("span",{children:"Low"}),t.jsx("span",{children:"High"})]})]})]})})})]})]})}function ae({node:e,onClose:s,onZoomTo:a}){const n=_[e.nodeClass],l={active:{label:"Active",color:"text-accent-success"},recent:{label:"Recent",color:"text-accent-secondary"},stale:{label:"Stale",color:"text-signal-poor"},inactive:{label:"Inactive",color:"text-text-muted"}}[e.activityLevel]??{label:e.activityLevel,color:"text-text-muted"};return t.jsxs(b.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.15},className:"absolute top-4 right-4 z-20 bg-bg-elevated/95 backdrop-blur-sm rounded-xl border border-border-subtle shadow-2xl w-72",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 rounded-full ring-2 ring-offset-1 ring-offset-bg-elevated",style:{width:10,height:10,backgroundColor:K[e.nodeClass],boxShadow:`0 0 8px ${K[e.nodeClass]}40`}}),t.jsx(n,{className:"w-3.5 h-3.5 text-text-muted"}),t.jsx("span",{className:"font-medium text-text-primary type-data-sm",children:e.prefix})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[e.isLocal&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 text-yellow-300",children:"LOCAL"}),a&&t.jsx(T,{content:"Zoom to node",children:t.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-subtle-fill transition-colors",children:t.jsx(C,{className:"w-3.5 h-3.5 text-text-muted"})})}),t.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-subtle-fill transition-colors",children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted"})})]})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs",children:[e.name&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Name"}),t.jsx("span",{className:"text-text-primary font-medium truncate ml-2",children:e.name})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:"text-text-secondary capitalize",children:V[e.nodeClass]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Activity"}),t.jsx("span",{className:l.color,children:l.label})]})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs border-t border-border-subtle",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"text-text-secondary tabular-nums",children:e.packetCount.toLocaleString()})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Connections"}),t.jsx("span",{className:"text-text-secondary tabular-nums",children:e.degree})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Betweenness"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[(100*e.betweenness).toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Community"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:["#",e.communityId]})]})]}),e.isZeroHop&&(null!==e.avgRssi||null!==e.avgSnr)&&t.jsxs("div",{className:"px-3 py-2 space-y-1.5 type-data-xs border-t border-border-subtle",children:[t.jsx("div",{className:"text-text-muted text-[10px] uppercase tracking-wide",children:"Signal Quality"}),null!==e.avgRssi&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[e.avgRssi.toFixed(0)," dBm"]})]}),null!==e.avgSnr&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"text-text-secondary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),(e.isHub||e.isGateway||e.isBackbone||e.isMobile||e.isInLoop)&&t.jsx("div",{className:"px-3 py-2 border-t border-border-subtle",children:t.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.isHub&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-indigo-500/20 text-indigo-300",children:"Hub"}),e.isGateway&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-violet-500/20 text-violet-300",children:"Gateway"}),e.isBackbone&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:"Backbone"}),e.isMobile&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-orange-500/20 text-orange-300",children:"Mobile"}),e.isInLoop&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-300",children:"In Loop"})]})}),e.hasCollision&&t.jsx("div",{className:"px-3 py-2 border-t border-border-subtle",children:t.jsxs("div",{className:"flex justify-between type-data-xs",children:[t.jsx("span",{className:"text-signal-poor",children:"Prefix collision"}),t.jsxs("span",{className:"text-text-muted tabular-nums",children:[(100*e.prefixConfidence).toFixed(0),"% conf"]})]})}),t.jsxs("div",{className:"px-3 py-2 border-t border-border-subtle space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between type-data-xs",children:[t.jsx("span",{className:"text-text-muted",children:"Position"}),t.jsx("span",{className:e.hasGeo?"text-accent-success":"text-text-muted",children:e.hasGeo?"GPS":"Simulated"})]}),t.jsx("div",{children:t.jsx("span",{className:"text-text-muted break-all text-[10px] leading-relaxed font-mono",children:e.hash})})]})]})}function ne(){return t.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 text-center px-8",children:[t.jsx("div",{className:"p-4 rounded-full bg-subtle-fill",children:t.jsx(S,{className:"w-8 h-8 text-text-muted"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h2",{className:"text-lg font-medium text-text-primary",children:"No Topology Data"}),t.jsx("p",{className:"text-sm text-text-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed. This typically takes a few minutes after starting."})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted mt-2",children:[t.jsx(v,{className:"w-4 h-4 animate-pulse"}),t.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}function le(){var f;const j=M(),[y,v]=e.useState(!1),N=H(),w=R(),[S,L]=e.useState(!1),[E,B]=e.useState("fetching"),[z,$]=e.useState(0),V=e.useRef(!1);e.useEffect(()=>{j&&!V.current&&(V.current=!0,(async()=>{L(!0),B("fetching"),$(0),await N(),B("analyzing"),await new Promise(e=>setTimeout(e,200)),B("building");const e=Date.now(),t=Date.now()-e;t<600&&await new Promise(e=>setTimeout(e,600-t)),B("discovering"),await new Promise(e=>setTimeout(e,400)),B("complete"),await new Promise(e=>setTimeout(e,800)),L(!1),v(!0)})())},[j,N]),e.useEffect(()=>{"fetching"===E&&(w.loadProgress?$(w.loadProgress.loaded):w.packetCount>0&&$(w.packetCount))},[E,w.loadProgress,w.packetCount]);const J=P(),te=D(),le=F(),ie=I(),[re,oe]=e.useState(!0),[ce,de]=e.useState(null),[xe,ue]=e.useState("all"),[me,pe]=e.useState(!0),[he,be]=e.useState(!0),[ge,fe]=e.useState(""),[je,ye]=e.useState(!1),ve=e.useRef(null),[Ne,we]=e.useState(null),[Ce,ke]=e.useState({x:0,y:0}),Se=e.useRef(null),[Le,Ee]=e.useState(!1),Be=G();e.useEffect(()=>{const e=e=>{var t;if(!(e.target instanceof HTMLInputElement))switch(e.key.toLowerCase()){case"f":e.metaKey||e.ctrlKey||(e.preventDefault(),null==(t=qe.current)||t.fitView(300));break;case"escape":je?(ye(!1),fe("")):ce&&de(null);break;case"/":je||(e.preventDefault(),ye(!0),setTimeout(()=>{var e;return null==(e=ve.current)?void 0:e.focus()},50));break;case" ":e.preventDefault();{const e=qe.current;e&&(re?e.pause():e.start(),oe(e=>!e))}break;case"l":pe(e=>!e);break;case"e":be(e=>!e)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[je,ce,re]);const Me=(null==ie?void 0:ie.latitude)??0,He=(null==ie?void 0:ie.longitude)??0,Re=null!==ie,Pe=e.useMemo(()=>Math.floor(Date.now()/1e3),[]),De=e.useMemo(()=>{var e;if(!te||0===te.size||!y)return[];const t=[],s=(null==le?void 0:le.node_name)??(null==(e=null==le?void 0:le.config)?void 0:e.node_name)??null,a={x:0,y:0};for(const n of te.values()){const e=n.isLocal?1:A(n.lastSeen,Pe);if(0===e&&!n.isLocal)continue;const l=K[n.nodeClass],i=n.isLocal?l:O(l,e),r=6+22*n.betweenness,o=n.isLocal?r:r*(.5+.5*e),c=n.isLocal?s??n.name:n.name;let d,x,u=!1;Re&&(n.isLocal?(d=0,x=0,u=!0):n.latitude&&n.longitude&&(U(n.latitude,n.longitude,Me,He,a),d=a.x,x=a.y,u=!0)),t.push({id:n.hash,label:c?`${n.prefix} ${c}`:n.prefix,color:i,size:o,x:d,y:x,recencyWeight:e,nodeClass:n.nodeClass,name:c,prefix:n.prefix,packetCount:n.packetCount,betweenness:n.betweenness,communityId:n.communityId,isLocal:n.isLocal,isHub:n.isHub,isGateway:n.isGateway,isBackbone:n.isBackbone,isMobile:n.isMobile,isGhost:n.isGhost,isInLoop:n.isInLoop,isZeroHop:n.isZeroHop,hasGeo:u,avgRssi:n.avgRssi,avgSnr:n.avgSnr,degree:n.degree,activityLevel:n.activityLevel,prefixConfidence:n.prefixConfidence,hasCollision:n.hasCollision,lastSeen:n.lastSeen})}return t},[te,y,Re,Me,He,null==le?void 0:le.node_name,null==(f=null==le?void 0:le.config)?void 0:f.node_name,Pe]),Fe=e.useMemo(()=>{const e=new Set;for(const t of De)e.add(t.id);return e},[De]),{rawLinks:Ie,hasZeroHopEdges:Ge,hasLoopEdges:Te,hasDirectPathEdges:Ze}=e.useMemo(()=>{const e=null==J?void 0:J.validatedEdges;if(!e||0===e.length||!y)return{rawLinks:[],maxCertainCount:0,hasZeroHopEdges:!1,hasLoopEdges:!1,hasDirectPathEdges:!1};let t=0,s=!1,a=!1,n=!1;for(const o of e)o.avgRecency<.02||Fe.has(o.fromHash)&&Fe.has(o.toHash)&&(o.certainCount>t&&(t=o.certainCount),s=s||!0===o.isZeroHop,a=a||!0===o.isLoopEdge,n=n||!0===o.isDirectPathEdge);const l=t>0?Math.log10(t+1):1,i=.8*t,r=[];for(const o of e){const e=o.avgRecency;if(e<.02)continue;if(!Fe.has(o.fromHash)||!Fe.has(o.toHash))continue;let s=.5;if(t>0&&o.certainCount>0){const e=Math.log10(o.certainCount+1);s=.5+7.5*Math.min(1,e/l)}const a=s*(.3+.7*e);let n;n=o.isZeroHop?q:o.isLoopEdge?Q:o.isDirectPathEdge?X:o.certainCount>i?Y:ee(o.certainCount,t);const c=O(n,e);r.push({source:o.fromHash,target:o.toHash,color:c,width:a,strength:.3+.7*o.strength,recencyWeight:e,packetCount:o.packetCount,certainCount:o.certainCount,isZeroHop:o.isZeroHop??!1,isLoopEdge:o.isLoopEdge??!1,isDirectPath:o.isDirectPathEdge,avgConfidence:o.avgConfidence})}return{rawLinks:r,maxCertainCount:t,hasZeroHopEdges:s,hasLoopEdges:a,hasDirectPathEdges:n}},[null==J?void 0:J.validatedEdges,y,Fe]),ze=e.useMemo(()=>{const e=new Map;for(const t of Ie)e.set(t.source,(e.get(t.source)??0)+1),e.set(t.target,(e.get(t.target)??0)+1);return e},[Ie]),$e=e.useMemo(()=>{const e=new Map;for(const t of De)e.set(t.id,t);return e},[De]),[Ae,Oe]=e.useState(null),[We,Ke]=e.useState(null),[Ve,_e]=e.useState({}),qe=e.useRef(null),Qe=e.useRef(!1),Xe=e.useRef(null);e.useEffect(()=>{var e,t;if(0===De.length||0===Ie.length)return Oe(null),Ke(null),void(Xe.current=null);const s=`${De.length}:${Ie.length}:${null==(e=De[0])?void 0:e.id}:${null==(t=De[De.length-1])?void 0:t.id}`;if(s===Xe.current||Qe.current)return;let a=!1;return Qe.current=!0,(async()=>{try{const e=De.map(e=>({id:e.id,label:e.label,color:e.color})),t=Ie.map(e=>({source:e.source,target:e.target,color:e.color,width:e.width})),n=new Set(t.map(e=>e.width)),l={points:{pointIdBy:"id",pointColorBy:"color",pointLabelBy:"label",pointDefaultColor:"#64748B",pointGreyoutOpacity:.3,pointDefaultSize:12,pointSizeScale:1},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",...t.length>=2&&n.size>=2?{linkWidthBy:"width",linkWidthRange:[.5,8]}:{},linkDefaultWidth:1,linkDefaultColor:"#4B5563",linkGreyoutOpacity:.2,linkWidthScale:1}},i=await k(l,e,t);if(a||!i)return;const{points:r,links:o,cosmographConfig:c}=i;Oe(r??null),Ke(o??null),_e({...c,...W}),Xe.current=s}finally{Qe.current=!1}})(),()=>{a=!0}},[De,Ie]);const Ye=e.useCallback(e=>{qe.current=e},[]),Je=e.useCallback(()=>{var e;null==(e=qe.current)||e.fitView(300)},[]),Ue=e.useCallback(()=>{const e=qe.current;e&&(re?e.pause():e.start(),oe(!re))},[re]),et=e.useCallback(async e=>{const t=qe.current;if(t)try{const s=await t.getPointIndicesByIds([e]);s&&s.length>0&&void 0!==s[0]&&t.zoomToPoint(s[0],400,2.5)}catch{}},[]),tt=e.useMemo(()=>{if(!ge.trim())return[];const e=ge.toLowerCase();return De.filter(t=>{var s;return t.prefix.toLowerCase().includes(e)||(null==(s=t.name)?void 0:s.toLowerCase().includes(e))||t.id.toLowerCase().includes(e)}).slice(0,8)},[De,ge]),st=e.useCallback(e=>{et(e.id),ye(!1),fe(""),de({hash:e.id,name:e.name,prefix:e.prefix,nodeClass:e.nodeClass,packetCount:e.packetCount,edgeCount:ze.get(e.id)??0,betweenness:e.betweenness,communityId:e.communityId,degree:e.degree,hasGeo:e.hasGeo,isLocal:e.isLocal,isHub:e.isHub,isGateway:e.isGateway,isBackbone:e.isBackbone,isMobile:e.isMobile,isInLoop:e.isInLoop,isZeroHop:e.isZeroHop,avgRssi:e.avgRssi,avgSnr:e.avgSnr,activityLevel:e.activityLevel,prefixConfidence:e.prefixConfidence,hasCollision:e.hasCollision})},[et,ze]),at=e.useRef(void 0),nt=e.useRef(0),lt=e.useCallback(async(e,t,s)=>{const a=Date.now();if(s&&a-nt.current>=16&&(nt.current=a,ke({x:s.clientX,y:s.clientY})),e===at.current)return;at.current=e,Se.current&&(clearTimeout(Se.current),Se.current=null);const n=qe.current;if(n)if(void 0!==e)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=$e.get(s);if(!a)return;we(a),n.selectPoint(e,!1,!0)}catch{we(null)}else Se.current=setTimeout(()=>{we(null),ce||n.unselectAllPoints()},100)},[$e,ce]),it=e.useCallback(()=>{Ee(e=>!e)},[]),rt=e.useCallback(()=>{ue(e=>{const t=["all","hubs","neighbors","active"],s=t.indexOf(e);return t[(s+1)%t.length]})},[]),ot={all:"All nodes",hubs:"Hubs & gateways only",neighbors:"Direct RF neighbors",active:"Recently active"},ct=e.useCallback(async(e,t,s)=>{var a;if(we(null),at.current=void 0,void 0===e)return de(null),void(null==(a=qe.current)||a.unselectAllPoints());const n=qe.current;if(n)try{const t=await n.getPointIdsByIndices([e]);if(!t||0===t.length)return;const s=t[0],a=$e.get(s);if(!a)return;n.selectPoint(e,!1),de({hash:s,name:a.name,prefix:a.prefix,nodeClass:a.nodeClass,packetCount:a.packetCount,edgeCount:ze.get(s)??0,betweenness:a.betweenness,communityId:a.communityId,degree:a.degree,hasGeo:a.hasGeo,isLocal:a.isLocal,isHub:a.isHub,isGateway:a.isGateway,isBackbone:a.isBackbone,isMobile:a.isMobile,isInLoop:a.isInLoop,isZeroHop:a.isZeroHop,avgRssi:a.avgRssi,avgSnr:a.avgSnr,activityLevel:a.activityLevel,prefixConfidence:a.prefixConfidence,hasCollision:a.hasCollision})}catch{}},[$e,ze]);if(!y)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex items-center justify-center bg-black",children:[t.jsx(Z,{isOpen:S,currentStep:E,packetCount:z}),!S&&t.jsx(s,{className:"w-8 h-8 text-accent-primary animate-spin"})]});if(0===De.length)return t.jsxs("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex flex-col bg-black overflow-hidden",children:[t.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle bg-bg-elevated/50",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(a,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]})]})}),t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(ne,{})})]});if(!Ae)return t.jsx("div",{className:"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] flex items-center justify-center bg-black",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx(s,{className:"w-8 h-8 text-accent-primary animate-spin"}),t.jsx("span",{className:"text-sm text-text-muted",children:"Preparing graph..."})]})});const dt=Le?"fixed inset-0 z-50 bg-black":"-mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 h-[calc(100vh-64px)] bg-black";return t.jsxs("div",{className:`${dt} flex flex-col overflow-hidden`,children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle/50 bg-black/80 backdrop-blur-sm z-10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(a,{className:"w-5 h-5 text-accent-primary"}),t.jsxs("h1",{className:"type-data-sm font-semibold text-text-primary flex items-center gap-2",children:["MeshGraph",t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-accent-primary/20 text-accent-primary rounded",children:"Beta"})]}),t.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[De.length," nodes • ",Ie.length," edges"]}),"all"!==xe&&t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-accent-primary/20 text-accent-primary",children:ot[xe]})]}),t.jsxs("div",{className:"flex items-center gap-0.5",children:[t.jsx(T,{content:"Search nodes (/)",children:t.jsx("button",{onClick:()=>{ye(!0),setTimeout(()=>{var e;return null==(e=ve.current)?void 0:e.focus()},50)},className:"p-2 rounded-lg transition-colors "+(je?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:t.jsx(n,{className:"w-4 h-4"})})}),t.jsx(T,{content:`Filter: ${ot[xe]}`,children:t.jsx("button",{onClick:rt,className:"p-2 rounded-lg transition-colors "+("all"!==xe?"bg-accent-primary/20 text-accent-primary":"hover:bg-subtle-fill text-text-muted"),children:t.jsx(l,{className:"w-4 h-4"})})}),t.jsx("div",{className:"w-px h-4 bg-border-subtle mx-1"}),t.jsx(T,{content:(me?"Hide":"Show")+" labels (L)",children:t.jsx("button",{onClick:()=>pe(e=>!e),className:"p-2 rounded-lg transition-colors "+(me?"text-text-muted hover:bg-subtle-fill":"text-text-muted/50 hover:bg-subtle-fill"),children:me?t.jsx(i,{className:"w-4 h-4"}):t.jsx(r,{className:"w-4 h-4"})})}),t.jsx(T,{content:(he?"Hide":"Show")+" edges (E)",children:t.jsx("button",{onClick:()=>be(e=>!e),className:"p-2 rounded-lg transition-colors "+(he?"text-text-muted hover:bg-subtle-fill":"text-text-muted/50 hover:bg-subtle-fill"),children:t.jsx(o,{className:"w-4 h-4"})})}),t.jsx("div",{className:"w-px h-4 bg-border-subtle mx-1"}),t.jsx(T,{content:(re?"Pause":"Resume")+" simulation (Space)",children:t.jsx("button",{onClick:Ue,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:re?t.jsx(c,{className:"w-4 h-4 text-accent-success"}):t.jsx(d,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(T,{content:"Fit view (F)",children:t.jsx("button",{onClick:Je,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:t.jsx(x,{className:"w-4 h-4 text-text-muted"})})}),t.jsx(T,{content:Le?"Exit fullscreen":"Fullscreen",children:t.jsx("button",{onClick:it,className:"p-2 rounded-lg hover:bg-subtle-fill transition-colors",children:Le?t.jsx(u,{className:"w-4 h-4 text-text-muted"}):t.jsx(m,{className:"w-4 h-4 text-text-muted"})})})]})]}),t.jsxs("div",{className:"flex-1 relative min-h-0",children:[t.jsx(p,{className:"absolute inset-0",points:Ae,links:he?We:void 0,...Ve,backgroundColor:"#000000",fitViewOnInit:!0,showLabels:me,showDynamicLabels:me,showTopLabels:me,showTopLabelsLimit:30,showHoveredPointLabel:!1,pointLabelColor:"#E2E8F0",pointLabelFontSize:11,onClick:ct,onMouseMove:lt,onMount:Ye,renderHoveredPointRing:!0,hoveredPointRingColor:"#FBBF24",hoveredPointCursor:"pointer",pointGreyoutOpacity:.15,linkGreyoutOpacity:.1}),t.jsx(h,{children:Ne&&t.jsx(b.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.1},className:"fixed z-50 pointer-events-none",style:{left:Ce.x+16,top:Ce.y-8},children:t.jsxs("div",{className:"bg-bg-elevated/95 backdrop-blur-md rounded-lg border border-border-subtle shadow-2xl px-3 py-2 max-w-xs",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0 ring-1 ring-white/20",style:{backgroundColor:K[Ne.nodeClass],boxShadow:`0 0 6px ${K[Ne.nodeClass]}60`}}),t.jsx("span",{className:"font-medium text-text-primary text-sm truncate",children:Ne.name||Ne.prefix}),Ne.isLocal&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-yellow-500/20 text-yellow-300 shrink-0",children:"LOCAL"})]}),t.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[t.jsx("span",{className:"capitalize",children:Ne.nodeClass}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:[Ne.packetCount.toLocaleString()," pkts"]}),t.jsx("span",{children:"•"}),t.jsxs("span",{children:[Ne.degree," conn"]})]}),Ne.isZeroHop&&(null!==Ne.avgSnr||null!==Ne.avgRssi)&&t.jsxs("div",{className:"flex items-center gap-2 mt-1 pt-1 border-t border-border-subtle/50 text-[10px]",children:[null!==Ne.avgSnr&&t.jsxs("span",{className:"text-accent-success",children:["SNR: ",Ne.avgSnr.toFixed(1)," dB"]}),null!==Ne.avgRssi&&t.jsxs("span",{className:"text-text-muted",children:["RSSI: ",Ne.avgRssi.toFixed(0)," dBm"]})]}),(Ne.isHub||Ne.isGateway||Ne.isBackbone||Ne.isMobile)&&t.jsxs("div",{className:"flex items-center gap-1 mt-1 pt-1 border-t border-border-subtle/50",children:[Ne.isHub&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-indigo-500/20 text-indigo-300",children:"Hub"}),Ne.isGateway&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-violet-500/20 text-violet-300",children:"Gateway"}),Ne.isBackbone&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-emerald-500/20 text-emerald-300",children:"Backbone"}),Ne.isMobile&&t.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-orange-500/20 text-orange-300",children:"Mobile"})]}),t.jsx("div",{className:"text-[9px] text-text-muted/60 mt-1",children:"Click for details"})]})})}),t.jsx(h,{children:je&&t.jsx(b.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:t.jsxs("div",{className:"bg-bg-elevated/95 backdrop-blur-sm rounded-xl border border-border-subtle shadow-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border-subtle",children:[t.jsx(n,{className:"w-4 h-4 text-text-muted shrink-0"}),t.jsx("input",{ref:ve,type:"text",value:ge,onChange:e=>fe(e.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none",onKeyDown:e=>{"Escape"===e.key?(ye(!1),fe("")):"Enter"===e.key&&tt.length>0&&st(tt[0])}}),ge&&t.jsx("button",{onClick:()=>fe(""),className:"p-0.5 rounded hover:bg-subtle-fill",children:t.jsx(g,{className:"w-3 h-3 text-text-muted"})})]}),tt.length>0&&t.jsx("div",{className:"max-h-64 overflow-y-auto",children:tt.map((e,s)=>{const a=_[e.nodeClass];return t.jsxs("button",{onClick:()=>st(e),className:"w-full flex items-center gap-3 px-3 py-2 text-left hover:bg-subtle-fill transition-colors "+(0===s?"bg-subtle-fill/50":""),children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:K[e.nodeClass]}}),t.jsx(a,{className:"w-3.5 h-3.5 text-text-muted shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-text-primary truncate",children:e.name||e.prefix}),e.name&&t.jsx("div",{className:"text-[10px] text-text-muted",children:e.prefix})]}),t.jsx(C,{className:"w-3 h-3 text-text-muted shrink-0"})]},e.id)})}),ge&&0===tt.length&&t.jsx("div",{className:"px-3 py-4 text-center text-sm text-text-muted",children:"No nodes found"}),!ge&&t.jsx("div",{className:"px-3 py-2 text-[10px] text-text-muted",children:"Type to search • Enter to select • Esc to close"})]})})}),t.jsx(se,{nodeCount:De.length,edgeCount:Ie.length,nodeClassCounts:Be,hasZeroHopEdges:Ge,hasLoopEdges:Te,hasDirectPathEdges:Ze}),t.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 text-[10px] text-text-muted/60",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1 py-0.5 rounded bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),t.jsx(h,{children:ce&&t.jsx(ae,{node:ce,onClose:()=>de(null),onZoomTo:()=>et(ce.hash)})})]})]})}export{le as default}; diff --git a/frontend/dist/assets/NodeInformationCard-D-IeNCCX.js b/frontend/dist/assets/NodeInformationCard-CEW2bogB.js similarity index 90% rename from frontend/dist/assets/NodeInformationCard-D-IeNCCX.js rename to frontend/dist/assets/NodeInformationCard-CEW2bogB.js index efc0500d..1da210ea 100644 --- a/frontend/dist/assets/NodeInformationCard-D-IeNCCX.js +++ b/frontend/dist/assets/NodeInformationCard-CEW2bogB.js @@ -1 +1 @@ -import{j as e,E as s}from"./vendor-react-C341c8YC.js";import{a as t}from"./PageLayout-CcoYWyzO.js";import{D as a}from"./DataBox-CRX76VsB.js";import{ay as r}from"./index-CPdqYR4z.js";import{C as l}from"./Card-BeZKc0xw.js";function c({nodeName:c,repeaterVersion:m,coreVersion:i,localHash:n,publicKey:d}){return e.jsxs(t,{children:[e.jsx(l,{icon:e.jsx(s,{}),title:"Node Information",largeTitle:!0}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Node Name"}),e.jsx("p",{className:"type-body text-text-primary mt-0.5 sm:mt-1 truncate",title:c,children:c})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Repeater"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${m}`,children:["v",m]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Core"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${i}`,children:["v",i]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Console"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${r}`,children:["v",r]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Local Hash"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:n?e.jsx(a,{copy:!0,size:"compact",children:n}):e.jsx("span",{className:"type-data-sm text-text-secondary",children:"N/A"})})]})]}),d&&e.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-border-subtle",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Public Key"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:e.jsx(a,{copy:!0,size:"responsive",children:d})})]})]})}export{c as N}; +import{j as e,E as s}from"./vendor-react-C341c8YC.js";import{a as t}from"./PageLayout-CnF5SScd.js";import{D as a}from"./DataBox-CRX76VsB.js";import{ay as r}from"./index-BJEgt3tp.js";import{C as l}from"./Card-2pQSGkKC.js";function c({nodeName:c,repeaterVersion:m,coreVersion:i,localHash:n,publicKey:d}){return e.jsxs(t,{children:[e.jsx(l,{icon:e.jsx(s,{}),title:"Node Information",largeTitle:!0}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Node Name"}),e.jsx("p",{className:"type-body text-text-primary mt-0.5 sm:mt-1 truncate",title:c,children:c})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Repeater"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${m}`,children:["v",m]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Core"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${i}`,children:["v",i]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Console"}),e.jsxs("p",{className:"type-data text-text-primary mt-0.5 sm:mt-1 truncate",title:`v${r}`,children:["v",r]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Local Hash"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:n?e.jsx(a,{copy:!0,size:"compact",children:n}):e.jsx("span",{className:"type-data-sm text-text-secondary",children:"N/A"})})]})]}),d&&e.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-border-subtle",children:[e.jsx("span",{className:"type-label text-text-secondary",children:"Public Key"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:e.jsx(a,{copy:!0,size:"responsive",children:d})})]})]})}export{c as N}; diff --git a/frontend/dist/assets/PacketList-CnSxB7Jy.js b/frontend/dist/assets/PacketList-BPeOqxkB.js similarity index 99% rename from frontend/dist/assets/PacketList-CnSxB7Jy.js rename to frontend/dist/assets/PacketList-BPeOqxkB.js index e5bbf65a..5fe9f766 100644 --- a/frontend/dist/assets/PacketList-CnSxB7Jy.js +++ b/frontend/dist/assets/PacketList-BPeOqxkB.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-Ouls8uhs.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/BasemapLayer-S9Ush6Hh.js","assets/useThemeColors-AeHMyThq.js","assets/index-CPdqYR4z.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-CIefRaAd.css"])))=>i.map(i=>d[i]); -import{j as e,r as t,an as s,ao as a,a0 as n,a1 as r,aj as l,ap as i,aq as c,ar as o,as as d,at as x,e as m,m as p,au as h,av as u,D as g,aw as f,ax as j,ay as y,az as b,aA as N,E as v,aB as w,aC as k,t as C,aD as S,ab as P,A as _,aE as T,aF as H,aG as B,aH as M,C as F,V as L,a9 as D,aI as z,a5 as A}from"./vendor-react-C341c8YC.js";import{n as E}from"./recharts-6XUQYgRA.js";import{y as R,B as U,z as I,A as $,C as V,E as Q,G as O,n as W,H as G,I as q,e as K,J as Y,K as J,M as X,N as Z,O as ee,Q as te,U as se,V as ae,W as ne}from"./index-CPdqYR4z.js";import{P as re,d as le,g as ie,a as ce,h as oe,b as de,c as xe,e as me,f as pe,i as he,j as ue}from"./channel-keys-DJWRrSwE.js";import{D as ge,S as fe,R as je,P as ye,g as be}from"./SignalIndicator-BLrEkFNb.js";import{_ as Ne}from"./deckgl-DTsmDcfs.js";import{D as ve}from"./DataBox-CRX76VsB.js";import{g as we,s as ke}from"./useThemeColors-AeHMyThq.js";function Ce({"aria-label":t="Page navigation",className:s,...a}){return e.jsx("nav",{"aria-label":t,...a,className:E("flex gap-x-2",s)})}function Se({onClick:t,disabled:s=!1,className:a,children:n="Previous"}){return e.jsx("span",{className:E("grow basis-0",a),children:e.jsxs(R,{plain:!0,onClick:t,disabled:s,"aria-label":"Previous page",className:E("gap-1",s&&"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 Pe({onClick:t,disabled:s=!1,className:a,children:n="Next"}){return e.jsx("span",{className:E("flex grow basis-0 justify-end",a),children:e.jsxs(R,{plain:!0,onClick:t,disabled:s,"aria-label":"Next page",className:E("gap-1",s&&"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 _e({className:t,...s}){return e.jsx("span",{...s,className:E("hidden items-baseline gap-x-2 sm:flex",t)})}function Te({page:t,current:s=!1,onClick:a,className:n,children:r}){return e.jsx(R,{plain:!s,outline:s,onClick:()=>null==a?void 0:a(t),"aria-label":`Page ${t}`,"aria-current":s?"page":void 0,className:E("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",s&&"before:bg-white/5",n),children:r??t})}function He({className:t,...s}){return e.jsx("span",{"aria-hidden":"true",...s,className:E("w-[2.25rem] select-none text-center text-sm text-text-muted",t),children:"…"})}function Be(e){if(!e||e.length<8)return null;const t=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16),n=parseInt(e.slice(6,8),16);return isNaN(t)||isNaN(s)||isNaN(a)||isNaN(n)?null:((t|s<<8|a<<16|n<<24)>>>0).toString(16).toUpperCase().padStart(8,"0")}function Me(e){return e>=10?"excellent":e>=5?"good":e>=0?"fair":e>=-5?"poor":"critical"}function Fe(e){if(!e.payload)return null;try{const t=oe(e.payload),s=function(e){const t=e.original_path||e.forwarded_path||[];if("string"==typeof t)try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(e=>parseInt(e,16))}catch{return[]}else if(Array.isArray(t))return t.map(e=>parseInt(e,16));return[]}(e),a=de(t,s);return a?{packet:e,decoded:a,timestamp:e.timestamp??0,hopCount:a.snrValues.length,rssi:e.rssi,snr:e.snr}:null}catch{return null}}const Le={rx:{icon:l,label:"Rx",badgeColor:ge.rx,avatarBg:"bg-emerald-500/15",avatarText:"text-emerald-400"},forward:{icon:r,label:"Fwd",badgeColor:ge.forward,avatarBg:"bg-sky-500/15",avatarText:"text-sky-400"},duplicate:{icon:n,label:"Dupe",badgeColor:ge.duplicate,avatarBg:"bg-zinc-500/15",avatarText:"text-zinc-400"},tx:{icon:a,label:"Tx",badgeColor:ge.tx,avatarBg:"bg-violet-500/15",avatarText:"text-violet-400"},dropped:{icon:s,label:"Drop",badgeColor:ge.dropped,avatarBg:"bg-amber-500/15",avatarText:"text-amber-400"}},De={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},ze={sm:"w-7 h-7",md:"w-8 h-8",lg:"w-9 h-9"};function Ae(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 Ee=t.memo(function({packet:t,showLabel:s=!0,variant:a="avatar",size:n="sm"}){const r=Ae(t),l=Le[r],i=l.icon;return"avatar"===a?e.jsx("div",{className:E("flex items-center justify-center rounded-full flex-shrink-0",l.avatarBg,ze[n]),children:e.jsx(i,{className:E(De[n],l.avatarText)})}):e.jsxs(U,{color:l.badgeColor,children:[e.jsx(i,{className:De[n]}),s&&l.label]})}),Re=t.memo(function({path:t,localHash:s,className:a}){if(!t||0===t.length)return e.jsx("span",{className:E("text-white/30 text-[10px]",a),children:"—"});const n=s?(s.startsWith("0x")?s.slice(2,4):s.slice(0,2)).toUpperCase():null;return e.jsx("span",{className:E("flex items-center gap-0.5 font-mono text-[10px] overflow-hidden",a),children:t.map((s,a)=>{const r=a===t.length-1,l=n&&s.toUpperCase()===n;return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[l?e.jsx("span",{className:"px-1 py-0.5 rounded bg-amber-500/20 text-amber-400 text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-white/[0.06] text-white/60",children:s.toUpperCase()}),!r&&e.jsx(i,{className:"w-2.5 h-2.5 text-white/20 mx-0.5 flex-shrink-0"})]},`${s}-${a}`)})})}),Ue=t.memo(function({count:t,className:s}){const a=t>=2;return e.jsxs("span",{className:E("font-mono text-xs tabular-nums",a?"text-white/70":"text-white/30",s),children:[t,e.jsx("span",{className:"text-white/20",children:"→"})]})});function Ie(e){const t=e.payload_type_name||V(e.payload_type??e.type),s=e.route_type_name||Q(e.route_type??e.route);return{payloadType:t,routeType:s,payloadColor:ye[t]??"zinc",routeColor:je[s]??"zinc"}}function $e(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Ve(e,t){if(!e||!t)return null;const s=e.startsWith("0x")?e.slice(2):e;for(const[a,n]of Object.entries(t))if((a.startsWith("0x")?a.slice(2):a).toLowerCase().startsWith(s.toLowerCase()))return n.name||n.node_name||null;return null}const Qe=t.memo(function({packet:s,onClick:a,localHash:n,neighbors:r,isFlashing:l=!1,isPending:i,isTraceHighlighted:o,onTraceHover:d,traceTag:x,onViewTraceReport:m,dupeGroupPosition:p,isDupeGroupHovered:h=!1,onDupeGroupHover:u}){const g=I(s.is_duplicate),f=void 0!==p,{payloadType:j,routeType:y,payloadColor:b,routeColor:N}=Ie(s),v="tx_local"===s.packet_origin,w=i??s.isPending,k="TRACE"===j,C=$e(s.original_path),S=$e(s.forwarded_path),P=S.length>0?S:C,_=P.length,T=s.src_hash?(s.src_hash.startsWith("0x")?s.src_hash.slice(2,6):s.src_hash.slice(0,4)).toUpperCase():null,H=Ve(s.src_hash,r),B=s.payload_length??s.length??0;s.lbt_attempts;const M=t.useCallback(()=>{k&&x&&m?m(x):a(s)},[k,x,m,a,s]),F=t.useCallback(()=>{k&&x&&d&&d(x),f&&u&&s.packet_hash&&u(s.packet_hash)},[k,x,d,f,u,s.packet_hash]),L=t.useCallback(()=>{d&&d(null),u&&u(null)},[d,u]),D={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)",brown:"rgb(168, 133, 107)"},z=D[b]||D.zinc,A=h;return e.jsxs("div",{onClick:M,onMouseEnter:F,onMouseLeave:L,className:E("group relative cursor-pointer","hover:bg-white/[0.02]",g&&!h&&"opacity-40",l&&"flash-row",w&&"opacity-70",v&&"bg-violet-500/5",o&&"bg-teal-500/10"),children:[e.jsx("div",{className:E("absolute pointer-events-none transition-opacity duration-75",f?A?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:(()=>{const e={pointerEvents:"none"};return"first"===p?{...e,borderTop:`2px solid ${z}`,borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:"middle"===p?{...e,borderTop:"none",borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:"last"===p?{...e,borderTop:"none",borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:`2px solid ${z}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...e,border:`2px solid ${z}`,borderRadius:"8px",inset:"-2px"}})()}),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.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ee,{packet:s,variant:"avatar",size:"sm"}),w&&e.jsx(c,{className:"absolute -right-1 -bottom-1 w-3 h-3 text-amber-400 animate-spin"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-[13px] text-white font-sans truncate",children:T||"—"}),H&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-white/40 truncate max-w-[70px]",children:H})]})]}),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:"text-[10px] min-[600px]:text-[11px] text-white/50 font-mono tabular-nums whitespace-nowrap flex-shrink-0",children:$(s.timestamp)}),e.jsx(U,{color:b,className:"flex-shrink-0",children:j}),e.jsx("span",{className:"min-[600px]:hidden text-[10px] font-mono text-white/40 flex-shrink-0",children:y.charAt(0)}),e.jsx(U,{color:N,className:"flex-shrink-0 hidden min-[600px]:inline-flex",children:y}),e.jsx("div",{className:"flex-shrink-0 flex items-center",children:e.jsx(Ue,{count:_})}),e.jsxs("span",{className:"hidden min-[520px]:inline text-[10px] text-white/40 font-mono flex-shrink-0",children:[B,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:e.jsx(Re,{path:P,localHash:n})})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(fe,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0})})]})]})}),Oe=t.memo(function({packet:t,onClick:s,localHash:a,neighbors:n,isFlashing:r=!1,isPending:l,isTraceHighlighted:i,traceTag:o,onViewTraceReport:d,dupeGroupPosition:x,isDupeGroupHovered:m=!1,onDupeGroupHover:p}){const{payloadType:h,routeType:u,payloadColor:g,routeColor:f}=Ie(t),j="tx_local"===t.packet_origin,y=l??t.isPending,b="TRACE"===h,N=I(t.is_duplicate),v=$e(t.original_path),w=$e(t.forwarded_path),k=w.length>0?w:v,C=k.length,S=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,P=Ve(t.src_hash,n),_=t.payload_length??t.length??0,T=t.lbt_attempts??0,H={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)"},B=H[g]||H.zinc;return e.jsxs("div",{onClick:()=>{b&&o&&d?d(o):s(t)},className:E("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-white/[0.04]",N&&"opacity-40",r&&"flash-row",y&&"opacity-70",j&&"bg-violet-500/5",i&&"bg-teal-500/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:(()=>{if(!x)return{opacity:0};const e=m?1:.4,t=m?"3px":"2px";return"first"===x?{backgroundColor:B,opacity:e,width:t,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:"middle"===x?{backgroundColor:B,opacity:e,width:t,top:0,bottom:0,borderRadius:0}:"last"===x?{backgroundColor:B,opacity:e,width:t,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:B,opacity:e,width:t,top:"6px",bottom:"6px",borderRadius:"9999px"}})()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"relative flex-shrink-0 mt-0.5",children:[e.jsx(Ee,{packet:t,variant:"avatar",size:"sm"}),y&&e.jsx(c,{className:"absolute -right-1 -bottom-1 w-2.5 h-2.5 text-amber-400 animate-spin"})]}),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:[e.jsx("span",{className:"font-semibold text-[14px] text-white tracking-tight",children:S||"—"}),P&&e.jsx("span",{className:"text-[12px] text-white/40 truncate max-w-[80px]",children:P}),e.jsx("div",{className:"flex-1"}),e.jsx(U,{color:g,className:"flex-shrink-0 !text-[9px] !px-1.5 !py-0",children:h}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-white/50 tabular-nums w-[28px] text-right",children:t.rssi}),e.jsx(fe,{rssi:t.rssi,compact:!0,showValues:!1})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-white/40 font-mono",children:[e.jsx("span",{className:"tabular-nums",children:$(t.timestamp)}),e.jsx(U,{color:f,className:"!text-[8px] !px-1 !py-0 !leading-none",children:u.charAt(0)}),C>0&&e.jsxs("span",{className:"text-white/30",children:[C,"h"]}),_>0&&e.jsxs("span",{className:"text-white/30",children:[_,"B"]}),T>0&&e.jsxs("span",{className:T>1?"text-amber-400/60":"text-white/30",children:["LBT:",T]}),null!=t.snr&&e.jsxs("span",{className:"text-white/30",children:[t.snr.toFixed(0),"dB"]})]}),C>0&&e.jsx("div",{className:"pt-0.5",children:e.jsx(Re,{path:k,localHash:a})})]})]})]})});function We(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 Ge=t.lazy(()=>Ne(()=>import("./PathMapMapLibre-Ouls8uhs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function qe(e){return`${(100*e).toFixed(0)}%`}function Ke(e,t){const s=document.documentElement,a=getComputedStyle(s),n={success:a.getPropertyValue("--accent-success").trim()||"#39D98A",secondary:a.getPropertyValue("--accent-secondary").trim()||"#F9D26F",poor:a.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:a.getPropertyValue("--accent-danger").trim()||"#FF5C7A",muted:a.getPropertyValue("--text-muted").trim()||"#767688"};let r;return r=0===t?n.muted:e>=1?n.success:e>=.5?n.secondary:e>=.25?n.poor:e>0?n.danger:n.muted,{color:r}}class Ye extends t.Component{constructor(e){super(e),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-text-muted",children:[e.jsx(x,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Je({path:s,neighbors:a,localNode:n,localHash:r,srcHash:l,dstHash:i,neighborAffinity:c,prefixLookup:x,hubNodes:m,traceSnr:p,advertiserSource:h}){const[u,g]=t.useState(null),f=t.useMemo(()=>{if(!h)return null;const e="wardrive"===h.nodeType;return{prefix:h.prefix||"??",candidates:[{hash:h.publicKey||h.prefix||"source",name:h.name,latitude:h.latitude,longitude:h.longitude,probability:1,isLocal:!1,isWardrive:e}],confidence:1,totalMatches:1,isSource:!0}},[h]),j=t.useMemo(()=>{if(h)return null;if(!l)return null;const e=W(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 s=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||l.slice(0,8);return{prefix:e,candidates:[{hash:l,name:s,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[h,l,a]),y=t.useMemo(()=>{const e=(null==i?void 0:i.startsWith("0x"))?i.slice(2):i;if((!e||"00"===e||"0000000000000000"===e)&&n&&r){const e=W(r),t=0!==n.latitude||0!==n.longitude;return{prefix:e,candidates:[{hash:r,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}}if(!i)return null;const t=W(i);if(r&&i===r&&n){const e=0!==n.latitude||0!==n.longitude;return{prefix:t,candidates:[{hash:i,name:n.name||"Local Node",latitude:e?n.latitude:0,longitude:e?n.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const s=a[i];if((null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&(0!==s.latitude||0!==s.longitude))return{prefix:t,candidates:[{hash:i,name:s.node_name||s.name||"Destination",latitude:s.latitude,longitude:s.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===s.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const l=(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||i.slice(0,8);return{prefix:t,candidates:[{hash:i,name:l,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,n,r]),b=t.useMemo(()=>function(e,t,s,a,n,r){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=e.length-1,i=e.map((i,c)=>{const o=c===l,d=e.length-c,{candidates:x,totalMatches:m}=function(e,t,s,a,n=!1,r,l,i){const c=function(e){const t={};for(const[s,a]of Object.entries(e))We(a)&&(t[s]=a);return t}(t);let o;if(l){const t=function(e,t,s){const a=t.toUpperCase(),n=e.get(a);if(!n||0===n.candidates.length)return{hash:null,confidence:0};if(null==s?void 0:s.isLastHop)return{hash:n.bestMatch,confidence:n.confidence};if(1===(null==s?void 0:s.position))return{hash:n.bestMatch,confidence:n.confidence};if((null==s?void 0:s.position)&&n.bestMatchForPosition.has(s.position)){const e=n.bestMatchForPosition.get(s.position),t=Math.max(e.confidence,n.confidence);return{hash:e.hash,confidence:t}}if((null==s?void 0:s.adjacentPrefixes)&&s.adjacentPrefixes.length>0){let e=n.bestMatch,t=0;for(const a of n.candidates){let n=0;for(const e of s.adjacentPrefixes)n+=a.adjacentPrefixCounts.get(e.toUpperCase())||0;const r=a.combinedScore+n/Math.max(1,a.totalAdjacentObservations)*.3;r>t&&(t=r,e=a.hash)}return{hash:e,confidence:n.confidence}}return{hash:n.bestMatch,confidence:n.confidence}}(l,e,{position:i,isLastHop:n});o=t.confidence}const{matches:d,probability:x}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),l=[],i=s&&O(r,s);i&&l.push(s);for(const p of Object.keys(t))O(r,p)&&l.push(p);if(n&&i&&s&&1===l.length)return{matches:l,probability:1,bestMatch:s};if(n&&i&&l.length>1){const e=l.filter(e=>e!==s);if(1===e.length)return{matches:l,probability:1,bestMatch:e[0]}}const c=l.length>0?1/l.length:0,o=[...l].sort();let d=null,x=-1;if(1===o.length)d=o[0];else if(o.length>1&&a){for(const e of o){const t=a.get(e),s=t?"number"==typeof t?t:t.combinedScore:0;s>x&&(x=s,d=e)}d||(d=o[0])}else o.length>0&&(d=o[0]);let m=c;if(l.length>1&&a&&x>0){let e=0;for(const t of l){const s=a.get(t);e+=s?"number"==typeof s?s:s.combinedScore:0}e>0&&(m=Math.min(.95,x/e))}return{matches:l,probability:m,bestMatch:d}}(e,c,a,r,n),m=d.length,p=[],h=e.toUpperCase(),u=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const f of d){if(a&&O(h,a)&&f===a&&u&&s){p.push({hash:f,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:x,isLocal:!0});continue}const e=c[f];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&p.push({hash:f,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:x,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const g=p.length;if(1===g)p[0].probability=o??1;else if(g>1)if(void 0!==o&&o>0){p[0].probability=o;const e=1-o,t=g-1;p.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=p.map(t=>{if(t.isLocal)return{candidate:t,score:1};const a=null==r?void 0:r.get(t.hash);let n=.5;var l;let i;return u&&s&&(n=(l=function(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,l=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}(s.latitude,s.longitude,t.latitude,t.longitude))<100?1:l<500?.9:l<1e3?.7:l<5e3?.5:l<1e4?.3:.1),a?i=.3*n+.3*a.hopConsistencyScore+.4*a.frequencyScore:(i=n,t.isDirectNeighbor&&(i=Math.max(i,.8))),e+=i,{candidate:t,score:i}});if(e>0)t.forEach(({candidate:t,score:s})=>{t.probability=Math.min(.95,s/e)});else{const e=1/g;p.forEach(t=>t.probability=e)}}return{candidates:p,totalMatches:m}}(i,t,s,a,o,n,r,d),p=x.length>0?Math.max(...x.map(e=>e.probability)):0;return{prefix:i,candidates:x,confidence:p,totalMatches:m}}),c=i.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),o=i.some(e=>e.candidates.length>0);return{hops:i,overallConfidence:c,hasValidPath:o}}(s,a,n,r,c,x),[s,a,n,r,c,x]),N=t.useMemo(()=>{const e=[];f?e.push(f):j&&e.push(j),e.push(...b.hops),y&&e.push(y);const t=e.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),s=e.some(e=>e.candidates.some(e=>0!==e.latitude||0!==e.longitude));return{hops:e,overallConfidence:t,hasValidPath:s}},[f,j,b,y]);return N.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-text-muted",children:"Path Confidence:"}),e.jsx("span",{className:(v=N.overallConfidence,v>=1?"text-accent-success":v>=.5?"text-accent-secondary":v>=.25?"text-signal-poor":v>0?"text-accent-danger":"text-text-muted"),children:qe(N.overallConfidence)}),e.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:e.jsx(d,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),e.jsx("span",{className:"text-text-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),e.jsx("span",{className:"text-text-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),e.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Ye,{children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:e.jsx(Ge,{resolvedPath:N,localNode:n,hubNodes:m,hoveredHopIndex:u,onHoverHop:g,traceSnr:p})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:N.hops.map((t,s)=>{var a,n,r;const l=!0===t.isSource,i=!0===t.isDestination,c=u===s;let o;return o=l?`Source: ${(null==(a=t.candidates[0])?void 0:a.name)||"Unknown"}`:i?`Destination: ${(null==(n=t.candidates[0])?void 0:n.name)||"Unknown"}`:0===t.totalMatches?"No matching nodes found":1===t.totalMatches?`Exact match: ${(null==(r=t.candidates[0])?void 0:r.name)||"Unknown"}`:`${t.totalMatches} possible matches (${(100*t.confidence).toFixed(0)}% confidence)`,e.jsxs("div",{className:E("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono cursor-pointer transition-all",c?"bg-accent-primary/20 ring-1 ring-accent-primary/50":"bg-bg-elevated hover:bg-bg-subtle",l&&"border border-accent-success/30",i&&"border border-accent-primary/30"),title:o,onMouseEnter:()=>g(s),onMouseLeave:()=>g(null),children:[l&&e.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),i&&e.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:Ke(t.confidence,t.totalMatches),children:t.prefix}),!l&&!i&&t.totalMatches>1&&e.jsxs("span",{className:"text-text-muted",children:["×",t.totalMatches]}),!l&&!i&&0===t.totalMatches&&e.jsx("span",{className:"text-text-muted",children:"?"})]},s)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[e.jsx(o,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var v}function Xe(e){return e.match(/.{1,2}/g)||[]}function Ze(e){return null!==e&&e.startsWith("payload:")}const et={red:"var(--sys-red)",orange:"var(--sys-orange)",amber:"var(--sys-amber)",yellow:"var(--sys-yellow)",lime:"var(--sys-green)",green:"var(--sys-green)",emerald:"var(--sys-green)",teal:"var(--sys-teal)",cyan:"var(--sys-cyan)",sky:"var(--sys-cyan)",blue:"var(--sys-blue)",indigo:"var(--sys-indigo)",violet:"var(--sys-indigo)",purple:"var(--sys-purple)",fuchsia:"var(--sys-pink)",pink:"var(--sys-pink)",rose:"var(--sys-red)",brown:"var(--sys-brown)",zinc:"var(--text-muted)"},tt=15,st="color-mix(in srgb, var(--bg-elevated) 60%, var(--bg-body))",at="\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n ",nt=2,rt={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function lt(e,t){return e?`inset 0 0 0 ${nt}px ${et[t]}`:at}function it(e,t){return e?t:`color-mix(in srgb, ${t} ${tt}%, transparent)`}function ct({segments:s,selectedSegment:a,onSegmentClick:n}){const[r,l]=t.useState(null),[i,c]=t.useState(null),o=s.some(e=>void 0!==e.id)&&n,d=[];for(const e of s){const t=Xe(e.hex);for(const s of t)d.push({byte:s.toUpperCase(),color:e.color,id:e.id})}const x=[];for(let e=0;e{const d=t.length<16;return e.jsx("div",{className:"flex rounded-md overflow-hidden",children:t.map(({byte:s,color:x,id:m},p)=>{const h=p===t.length-1,u=d&&h,g=et[x],f=m?r===m:i===x,j=Boolean(m&&a===m),y=f||j;return e.jsx("span",{className:"w-[1.75rem] text-xs text-center py-0.5 font-mono select-none "+(o?"cursor-pointer":""),style:{backgroundColor:it(y,g),color:y?"rgba(255,255,255,0.95)":g,transition:y?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...u?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{m?l(m):c(x)},onMouseLeave:()=>{l(null),c(null)},onClick:()=>m&&(null==n?void 0:n(m)),onTouchStart:()=>{m?l(m):c(x)},onTouchEnd:()=>{l(null),c(null)},children:s},p)})},s)})})}function ot({bits:t,field:s,value:a,binary:n}){return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-text-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-text-secondary",children:s}),e.jsx("td",{className:"py-1.5",children:(()=>{if("Payload Type"===s){const t=ye[a]||"zinc";return e.jsx(U,{color:t,children:a})}if("Route Type"===s){const t=je[a]||"zinc";return e.jsx(U,{color:t,children:a})}return e.jsx("span",{className:"text-sm text-text-primary",children:a})})()}),e.jsx("td",{className:"py-1.5 font-mono text-xs text-sys-cyan",children:n})]})}function dt({id:t,title:s,color:a,hexBytes:n,startByte:r,endByte:l,isSelected:i,children:c}){const o=n?Xe(n):[];return e.jsxs(p.div,{layout:"position",layoutId:t,transition:rt,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:st,boxShadow:lt(i,a)},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(U,{color:a,children:s}),o.length>0&&o.length<=16&&o.map((t,s)=>e.jsx(U,{color:a,className:"font-mono",children:t.toUpperCase()},s))]}),e.jsxs("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:["Bytes ",r,"-",l]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function xt({advert:t,timestamp:s}){const a=q(s||t.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-purple-500/10 dark:bg-purple-400/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-purple) 0%, var(--sys-blue) 100%)"},children:e.jsx(v,{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-text-primary font-sans truncate leading-tight",children:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[void 0!==t.latitude&&void 0!==t.longitude&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(o,{className:"w-4 h-4 text-purple-600 dark:text-purple-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-purple-600 dark:text-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]})]})]})})}function mt({decoded:t,timestamp:s}){const a=s?q(s):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-teal-500/10 dark:bg-teal-400/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(N,{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-text-primary font-sans truncate leading-tight",children:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(u,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-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(g,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]}),t.decrypted&&t.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(ve,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function pt({decoded:t,timestamp:s,isLoading:a=!1}){const n=s?q(s):"Unknown";return a?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(--bg-elevated) 60%, var(--bg-body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[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-white/[0.08] animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-white/[0.08] 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-white/[0.15] animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-white/[0.15] 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(--bg-elevated) 60%, var(--bg-body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-text-muted font-sans",children:["From ",e.jsx("span",{className:"text-text-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-text-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 dark:bg-zinc-400/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-zinc) 0%, color-mix(in srgb, var(--sys-zinc) 70%, black) 100%)"},children:e.jsx(f,{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-text-primary font-sans truncate leading-tight",children:"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-text-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-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-zinc-500 dark:text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:n})]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Private channel or unknown hash channel. Channel secret required for decryption."})]})]})})}function ht({decoded:t,timestamp:s}){const a=s?q(s):"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(b,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",t.crc]})," · ",a]})]})]})}function ut({decoded:t,timestamp:s}){const a=s?q(s):"Unknown",n=t.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-amber-500/10 dark:bg-amber-400/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(y,{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-text-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:[n," ",1===n?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]}),t.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.path.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsx(r,{className:"w-4 h-4 text-amber-500 dark:text-amber-400"}),e.jsx(U,{color:"amber",className:"font-mono",children:t})]},s))})})]})]})})}function gt({decoded:t,timestamp:s}){const a=s?q(s):"Unknown",n=t.pathHashes.length,l=t.snrValues.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-blue-500/10 dark:bg-blue-400/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(j,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-medium text-text-primary truncate leading-tight",children:["Trace ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-text-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary",children:a})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-text-muted",children:[e.jsxs("span",{children:[n," target ",1===n?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[l," SNR ",1===l?"sample":"samples"]}),0!==t.authCode&&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((s,a)=>{const n=t.snrValues[a],l=void 0!==n?(e=>e>=7?"green":e>=0?"yellow":e>=-5?"orange":"red")(n):"zinc",i=void 0!==n;return e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsx(r,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U,{color:i?"blue":"zinc",className:"font-mono",children:s}),i&&e.jsxs(U,{color:l,className:"font-mono",children:[n>=0?"+":"",Number.isInteger(n)?n:n.toFixed(1),"dB"]})]})]},a)})})]})]})})}function ft({decoded:t,timestamp:s}){const a=s?q(s):"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-purple) 0%, var(--sys-indigo) 100%)"},children:e.jsx(f,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:[t.srcHash," → ",t.destHash," · ",a]})]})]}):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-text-muted font-sans",children:[e.jsx("span",{className:"font-mono text-text-secondary",children:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-text-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-text-muted font-sans",children:["· ",a]})]}),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 jt({decoded:t,timestamp:s}){const a=s?q(s):"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-yellow-500/10 dark:bg-yellow-400/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(h,{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-text-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-black/10 dark:bg-white/10 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(u,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-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(g,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]})]})]})})}function yt({decoded:t,timestamp:s,payloadType:a}){const n=s?q(s):"Unknown",r=(()=>{switch(a){case xe.REQ:return{icon:C,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case xe.RESPONSE:return{icon:k,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case xe.ANON_REQ:return{icon:f,gradient:"var(--sys-purple), var(--sys-pink)",bg:"rgba(168, 85, 247, 0.15)",label:"Anonymous Request"};default:return{icon:w,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=r.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, ${r.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-text-primary font-sans",children:r.label}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:[t.length," bytes · ",n]})]})]})}function bt({pathHex:t}){if(!t)return null;const s=Xe(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:s.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsx(r,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{size:"compact",copy:!0,children:t.toUpperCase()}),e.jsx("span",{className:"text-[10px] text-text-muted font-sans tabular-nums w-4 text-left",children:s+1})]})]},s))})}function Nt({decoded:t,payloadType:s}){const a=he[s]||`TYPE_${s}`;switch(t.type){case"advert":{const s="chat"===t.nodeType?"companion":t.nodeType.replace("_"," "),a=void 0!==t.latitude&&void 0!==t.longitude&&!(0===t.latitude&&0===t.longitude);return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Role:"})," ",s]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Name:"})," ",t.name]}),a&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Time:"})," ",q(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Flags:"})," ",t.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-text-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"CRC:"})," 0x",t.crc]})});case"path":return e.jsx("div",{className:"text-xs text-text-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Path:"})," ",t.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-text-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Tag:"})," 0x",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"SNR:"})," ",t.snrValues.map(e=>`${e>=0?"+":""}${Number.isInteger(e)?e:e.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-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-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Src:"})," ",t.srcHash]}),t.encrypted?e.jsx("p",{className:"text-text-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Text:"})," ",t.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-accent-success",children:t.channelName}):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-text-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Text:"})," ",t.text]})]}):e.jsx("p",{className:"text-text-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-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-text-muted",children:"Data:"})," ",t.dataLength," bytes ",t.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Part:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Message ID:"})," ",t.messageId]})]});default:return e.jsxs("p",{className:"text-xs text-text-secondary",children:[a," (",t.length," bytes)"]})}}const vt=t.memo(function({packet:s}){var a;const n=s.raw_packet||"",l=n.length/2,i=G(),[c,o]=t.useState(null),[d,x]=t.useState(null),[h,u]=t.useState(!1),[g,f]=t.useState(null),j=t.useCallback(e=>{f(t=>t===e?null:e)},[]),y=t.useMemo(()=>function(e){if(!e||e.length<4)return null;const t=re.fromHex(e);if(!t.success||!t.packet)return null;const s=t.packet,a=function(e){const t=3&e,s=e>>2&15,a=e>>6&3;return[{bits:"0-1",field:"Route Type",value:ie(t),binary:(3&t).toString(2).padStart(2,"0")},{bits:"2-5",field:"Payload Type",value:ce(s),binary:(15&s).toString(2).padStart(4,"0")},{bits:"6-7",field:"Version",value:a.toString(),binary:(3&a).toString(2).padStart(2,"0")}]}(s.header),n=e.slice(0,2);let r=2,l="";s.hasTransportCodes()&&(l=e.slice(2,10),r=10);const i=e.slice(r,r+2),c=r+2,o=c+2*s.pathLen,d=e.slice(c,o),x=e.slice(o),m=le(s);return{packet:s,headerHex:n,headerFields:a,transportCodesHex:l,pathLengthHex:i,pathDataHex:d,payloadHex:x,payloadStartByte:Math.floor(o/2),decoded:m}}(n),[n]),b=(null==(a=null==y?void 0:y.packet)?void 0:a.payloadType)===xe.GRP_TXT&&(!i||h);if(t.useEffect(()=>{if(!(null==y?void 0:y.packet)||y.packet.payloadType!==xe.GRP_TXT)return o(null),void u(!1);if(!i)return void u(!0);u(!0);let e=!1;return me(y.packet.payload).then(t=>{e||(t&&o(t),u(!1))}),()=>{e=!0}},[null==y?void 0:y.packet,i]),t.useEffect(()=>{if(!(null==y?void 0:y.packet)||y.packet.payloadType!==xe.GRP_DATA)return void x(null);if(!i)return;let e=!1;return pe(y.packet.payload).then(t=>{!e&&t&&x(t)}),()=>{e=!0}},[null==y?void 0:y.packet,i]),!y||0===n.length)return e.jsx("div",{className:"p-4 text-center text-text-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:N}=y;let v=y.decoded;c&&"grp_txt"===y.decoded.type?v=c:d&&"grp_data"===y.decoded.type&&(v=d);const w=t.useMemo(()=>function(t,s){switch(t.type){case"advert":return function(t,s){const a=[];let n=0;const r=s.slice(0,64);a.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-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const l=s.slice(64,72);a.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:l,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:l.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.timestamp," (",q(t.timestamp),")"]})]})}),n+=4;const i=s.slice(72,200);a.push({id:"payload:signature",title:"Signature",color:"teal",hex:i,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=s.slice(200,202);if(a.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-text-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-text-muted",children:["Node Type: ",t.nodeType]})]})}),n+=1,void 0!==t.latitude){const r=s.slice(2*n,2*n+8);a.push({id:"payload:latitude",title:"Latitude",color:"green",hex:r,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),n+=4}if(void 0!==t.longitude){const r=s.slice(2*n,2*n+8);a.push({id:"payload:longitude",title:"Longitude",color:"purple",hex:r,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),n+=4}if(t.name){const r=s.slice(2*n),l=r.length/2;a.push({id:"payload:name",title:"Name",color:"amber",hex:r,startByte:n,endByte:n+l-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:['"',t.name,'"']})]})})}return a}(t,s);case"ack":return function(t,s){return[{id:"payload:crc",title:"CRC",color:"green",hex:s.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}(t,s);case"grp_txt":return function(t,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&a.push({id:"payload:mac",title:"MAC",color:"purple",hex:s.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.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-text-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["From: ",t.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"AES-128-ECB encrypted"})]})}),a}(t,s);case"grp_data":return function(t,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&a.push({id:"payload:mac",title:"MAC",color:"purple",hex:s.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.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-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:(t.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),a}(t,s);case"path":return function(t,s){return[{id:"payload:path",title:"Path Hops",color:"amber",hex:s,startByte:0,endByte:s.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&e.jsx(r,{className:"w-3 h-3 text-text-muted"}),e.jsx(U,{color:"amber",className:"font-mono",children:t})]},s))}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.path.length," hops"]})]})}]}(t,s);case"trace":return function(t,s){const a=[];a.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:s.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Unique trace request identifier"})]})}),a.push({id:"payload:mac",title:"Auth Code",color:"purple",hex:s.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Authentication/verification code"})]})}),a.push({id:"payload:flags",title:"Flags",color:"amber",hex:s.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:0===t.flags?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const n=s.slice(18);if(n){const s=e=>e>=7?"green":e>=0?"yellow":e>=-5?"orange":"red";a.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((a,n)=>{const l=t.snrValues[n],i=void 0!==l?s(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[n>0&&e.jsx(r,{className:"w-3 h-3 text-text-muted"}),e.jsx(U,{color:"indigo",className:"font-mono",children:a}),void 0!==l&&e.jsxs(U,{color:i,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},n)})}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.pathHashes.length," target ",1===t.pathHashes.length?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${1===t.snrValues.length?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})})}return a}(t,s);case"multipart":return function(t,s){const a=[];a.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:s.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Unique message identifier"})]})}),a.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:s.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"0-indexed part number"})]})}),a.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:s.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const n=s.slice(8);return n&&a.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[n.length/2," bytes"]})]})}),a}(t,s);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:s,startByte:0,endByte:s.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:s.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[s.length/2," bytes"]})]})}]}}(v,y.payloadHex),[v,y.payloadHex]),k="payload"===g||Ze(g),C=t.useMemo(()=>{const e=[{id:"header",hex:y.headerHex,color:"red"},...y.transportCodesHex?[{id:"transportCodes",hex:y.transportCodesHex,color:"purple"}]:[],{id:"pathLength",hex:y.pathLengthHex,color:"green"},...y.pathDataHex?[{id:"pathData",hex:y.pathDataHex,color:"amber"}]:[]];return k?[...e,...(t=w,t.map(e=>({id:e.id,hex:e.hex,color:e.color})))]:[...e,{id:"payload",hex:y.payloadHex,color:"cyan"}];var t},[y,k,w]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[(()=>{switch(v.type){case"advert":return e.jsx(xt,{advert:v,timestamp:s.timestamp});case"grp_data":return e.jsx(mt,{decoded:v,timestamp:s.timestamp});case"grp_txt":return e.jsx(pt,{decoded:v,timestamp:s.timestamp,isLoading:b});case"ack":return e.jsx(ht,{decoded:v,timestamp:s.timestamp});case"path":return e.jsx(ut,{decoded:v,timestamp:s.timestamp});case"trace":return e.jsx(gt,{decoded:v,timestamp:s.timestamp});case"txt_msg":return e.jsx(ft,{decoded:v,timestamp:s.timestamp});case"multipart":return e.jsx(jt,{decoded:v,timestamp:s.timestamp});case"generic":return N.payloadType===xe.REQ||N.payloadType===xe.RESPONSE||N.payloadType===xe.ANON_REQ?e.jsx(yt,{decoded:v,timestamp:s.timestamp,payloadType:N.payloadType}):null;default:return null}})(),e.jsx("div",{className:"bg-black rounded-2xl p-6",children:e.jsx(ct,{segments:C,selectedSegment:g,onSegmentClick:j})}),e.jsx(m,{children:e.jsx(p.div,{layout:!0,transition:rt,className:"space-y-2 min-w-0",children:(()=>{var t,s,a,n;const r=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${y.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted border-b border-border-subtle font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:"Bits"}),e.jsx("th",{className:"py-1 font-medium",children:"Field"}),e.jsx("th",{className:"py-1 font-medium",children:"Value"}),e.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),e.jsx("tbody",{children:y.headerFields.map(t=>e.jsx(ot,{...t},t.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"purple",startByte:1,endByte:4,hexBytes:(null==(t=y.transportCodesHex)?void 0:t.toUpperCase())||"",condition:!!y.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-text-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-text-secondary",children:["Code 1: 0x",null==(s=y.transportCodesHex)?void 0:s.slice(0,4).toUpperCase()," | Code 2: 0x",null==(a=y.transportCodesHex)?void 0:a.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:y.transportCodesHex?5:1,endByte:y.transportCodesHex?5:1,hexBytes:`0x${y.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-text-muted pt-1",children:[N.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:y.transportCodesHex?6:2,endByte:(y.transportCodesHex?5:1)+N.pathLen,hexBytes:(null==(n=y.pathDataHex)?void 0:n.toUpperCase())||"",condition:N.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(bt,{pathHex:y.pathDataHex}),e.jsx("p",{className:"text-xs text-text-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:y.payloadStartByte,endByte:l-1,hexBytes:y.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!Ze(g)&&e.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(Nt,{decoded:v,payloadType:N.payloadType})]}),!Ze(g)&&w.length>0&&e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),Ze(g)&&e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(e=>e.condition),i=Ze(g)?w.find(e=>e.id===g):null,c=Ze(g)?[...r].sort((e,t)=>"payload"===e.id?-1:"payload"===t.id?1:0):[...r].sort((e,t)=>e.id===g?-1:t.id===g?1:0),o=Ze(g)?w.filter(e=>e.id!==g):[];return e.jsxs(e.Fragment,{children:[i&&e.jsx(dt,{id:`subfield-${i.id}`,title:i.title,color:i.color,startByte:y.payloadStartByte+i.startByte,endByte:y.payloadStartByte+i.endByte,hexBytes:i.hex.toUpperCase(),isSelected:!0,children:i.decoded},i.id),c.map(t=>e.jsx(dt,{id:`section-${t.id}`,title:t.title,color:t.color,startByte:t.startByte,endByte:t.endByte,hexBytes:t.hexBytes,isSelected:t.id===g,children:t.content},t.id)),o.map(t=>e.jsxs(p.div,{layout:"position",layoutId:`subfield-${t.id}`,transition:rt,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:st,boxShadow:at},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(U,{color:t.color,children:t.title}),t.hex.length<=32&&Xe(t.hex).map((s,a)=>e.jsx(U,{color:t.color,className:"font-mono",children:s.toUpperCase()},a))]}),e.jsxs("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:["Bytes ",y.payloadStartByte+t.startByte,"-",y.payloadStartByte+t.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:t.decoded})]},t.id))]})})()})})]})});function wt(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function kt(e){return e?(e.startsWith("0x")?e.slice(2):e).slice(0,2).toUpperCase():""}function Ct({hop:s,compact:a=!1,index:n=0,highlightIndex:r=-1,isTrace:l=!1}){var i;const c=n===r,o=S();return t.useEffect(()=>{c&&l&&o.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[c,l,o]),e.jsxs(p.div,{className:E("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:c?1.05:1,opacity:c?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(p.div,{className:E("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-zinc-700/50 text-zinc-200 ring-1 ring-zinc-600/50"),animate:o,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&e.jsx(P,{className:"w-3 h-3"}),e.jsx("span",{children:s.prefix}),void 0!==s.confidence&&s.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(100*s.confidence).toFixed(0),"%"]})]}),!a&&(null==(i=s.neighborInfo)?void 0:i.name)&&e.jsx("span",{className:"text-[10px] text-text-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function St({snr:t}){const s=ke(t),a=we()[s]||"#6b7280",n=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(U,{customColor:a,compact:!0,className:"font-mono",children:[t>=0?"+":"",n,"dB"]})}function Pt({hops:s,compact:a,isTrace:n=!1}){const[r,l]=t.useState(-1);return t.useEffect(()=>{if(0===s.length)return;const e=setTimeout(()=>{l(0)},400),t=setInterval(()=>{l(e=>{const a=e+1;return a>=s.length?(clearInterval(t),-1):a})},n?500:600);return()=>{clearTimeout(e),clearInterval(t)}},[s.length,n]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((t,l)=>{const i=l%2==0,c=l===s.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:E("flex items-center","justify-end"),children:i&&e.jsx(Ct,{hop:t,compact:a,index:l,highlightIndex:r,isTrace:n})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-zinc-600/40 min-h-[8px]"}),void 0!==t.snr&&e.jsx(St,{snr:t.snr}),e.jsx("svg",{className:"w-3 h-3 text-zinc-500 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:E("flex items-center","justify-start"),children:!i&&e.jsx(Ct,{hop:t,compact:a,index:l,highlightIndex:r,isTrace:n})})]},`${t.prefix}-${l}`)})})}const _t=t.memo(function({packet:s,neighbors:a,localHash:n,neighborAffinity:i,ghostPrefixes:c,direction:o="horizontal",compact:d=!1,traceSnr:x,overridePath:m}){const p=void 0!==x&&x.length>0,h=wt(s.original_path),u=wt(s.forwarded_path),g=m??(u.length>0?u:h),f=kt(n),j=t.useMemo(()=>g.map((e,t)=>{const s=e.toUpperCase(),n=s===f,r=(null==c?void 0:c.has(s))??!1,l=function(e,t,s){const a=e.toUpperCase();if(s){let e=null,n=0;if(s.forEach((t,s)=>{if(kt(s)===a){const a=t.combinedScore??0;a>n&&(n=a,e=s)}}),e&&t[e])return{hash:e,info:t[e],confidence:n}}for(const[n,r]of Object.entries(t))if(kt(n)===a)return{hash:n,info:r,confidence:void 0};return null}(s,a,i);return{prefix:s,fullHash:null==l?void 0:l.hash,neighborInfo:null==l?void 0:l.info,isLocal:n,isGhost:r,confidence:null==l?void 0:l.confidence,snr:null==x?void 0:x[t]}}),[g,a,i,f,c,x]);if(0===j.length)return e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-xs",children:[e.jsx(v,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if("flowchart"===o)return e.jsx(Pt,{hops:j,compact:d,isTrace:p});const y="horizontal"===o?r:l;return e.jsx("div",{className:E("flex gap-1.5","horizontal"===o?"flex-row flex-wrap items-center":"flex-col items-start"),children:j.map((t,s)=>e.jsxs("div",{className:E("flex items-center gap-1.5","vertical"===o&&"flex-col"),children:[e.jsx(Ct,{hop:t,compact:d}),s0,c=sl&&a(s-1),disabled:!l,className:E("p-0.5 rounded transition-colors",l?"text-text-muted hover:text-text-primary hover:bg-white/10":"text-white/20 cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(B,{className:r?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((t,n)=>{const l=n===s,i=new Date(1e3*t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(te,{color:l?"cyan":"zinc",filled:l,compact:r,onClick:()=>a(n),title:`Observation ${n+1} at ${i}`,className:E("transition-all duration-150",!l&&"opacity-60 hover:opacity-100"),children:r?e.jsx("span",{className:"tabular-nums",children:n+1}):e.jsxs("span",{className:"tabular-nums text-[10px]",children:["#",n+1,null!=t.rssi&&e.jsx("span",{className:"ml-1 opacity-70",children:t.rssi})]})},`${t.timestamp}_${n}`)})}),e.jsx("button",{onClick:()=>c&&a(s+1),disabled:!c,className:E("p-0.5 rounded transition-colors",c?"text-text-muted hover:text-text-primary hover:bg-white/10":"text-white/20 cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(i,{className:r?"size-3":"size-4"})}),e.jsxs("span",{className:E("text-text-muted ml-1",r?"text-[9px]":"text-[10px]"),children:[e.jsx(n,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Bt({icon:t,label:s,disabled:a=!1}){return e.jsx(p.div,{className:"flex items-center gap-1 text-[10px]",title:s,animate:{opacity:a?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:E("flex items-center justify-center size-5 rounded border transition-colors duration-150",a?"bg-white/[0.02] border-white/5":"bg-white/5 border-white/10"),children:t})})}function Mt({hasDuplicates:t,hasPrev:s,hasNext:a,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(Bt,{icon:e.jsx(M,{className:"size-3"}),label:"Previous packet (↑)",disabled:!s}),e.jsx(Bt,{icon:e.jsx(F,{className:"size-3"}),label:"Next packet (↓)",disabled:!a})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Bt,{icon:e.jsx(B,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Bt,{icon:e.jsx(i,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}const Ft=t.memo(function({packets:s,initialIndex:a=0,onClose:n,onNavigatePrev:r,onNavigateNext:l,hasPrev:i=!1,hasNext:c=!1}){const[d,x]=t.useState(a),m=s[d]??s[0],h=s.length>1,u=d>0,f=d{x(Math.max(0,Math.min(e,s.length-1)))},[s.length]);t.useEffect(()=>{const e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case"ArrowUp":e.preventDefault(),null==r||r();break;case"ArrowDown":e.preventDefault(),null==l||l();break;case"ArrowLeft":e.preventDefault(),u&&x(e=>e-1);break;case"ArrowRight":e.preventDefault(),f&&x(e=>e+1)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,f]);const y=K(),b=Y(),N=J(),w=X(),k=t.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),C=m.payload_type_name||V(m.payload_type??m.type),S=m.route_type_name||Q(m.route_type??m.route),P=m.payload_length??m.length??0,B=Tt(m.original_path),M=Tt(m.forwarded_path),F=B.length>0||M.length>0,L=M.length>0?M:B,D=t.useMemo(()=>{var e;if(null==(e=null==y?void 0:y.config)?void 0:e.repeater)return{latitude:y.config.repeater.latitude,longitude:y.config.repeater.longitude,name:y.config.node_name||"Local Node"}},[y]),z=(null==y?void 0:y.neighbors)??{},A=N.size>0?N:void 0,E=m.raw_packet&&m.raw_packet.length>0,R=t.useMemo(()=>{if((m.payload_type??m.type)!==xe.TRACE||!m.payload)return null;try{const e=oe(m.payload),t=m.original_path||m.forwarded_path||[];let s=[];if("string"==typeof t)try{const e=JSON.parse(t);Array.isArray(e)&&(s=e.map(e=>parseInt(e,16)))}catch{s=[]}else Array.isArray(t)&&(s=t.map(e=>parseInt(e,16)));return de(e,s)}catch{return null}},[m]),I=null==R?void 0:R.snrValues,$=t.useMemo(()=>{if((m.payload_type??m.type)!==xe.ADVERT||!m.payload)return null;try{const e=oe(m.payload),t=ue(e);if(!t)return null;const s=t.publicKey.slice(0,2).toUpperCase();return{...t,prefix:s}}catch{return null}},[m]),O=t.useMemo(()=>{if((null==$?void 0:$.latitude)&&(null==$?void 0:$.longitude))return{latitude:$.latitude,longitude:$.longitude,name:$.name||`Node ${$.prefix||"??"}`,prefix:$.prefix,publicKey:$.publicKey}},[$]),W=e=>e&&0!==e?new Date(1e3*e).toLocaleString():"Unknown",[G,q]=t.useState(null);t.useEffect(()=>{if((m.payload_type??m.type)!==xe.GRP_TXT||!m.payload)return void q(null);let e=!1;const t=oe(m.payload);return me(t).then(t=>{!e&&t&&q(t)}),()=>{e=!0}},[m]);const te=t.useCallback(e=>{if(!e)return null;const t=e.trim().match(/(-?\d+\.?\d*)\s*[,\s]\s*(-?\d+\.?\d*)/);if(!t)return null;const s=parseFloat(t[1]),a=parseFloat(t[2]);return isNaN(s)||isNaN(a)||s<-90||s>90||a<-180||a>180||0===s&&0===a?null:{lat:s,lon:a}},[]),se=t.useMemo(()=>{var e,t;if(!(null==G?void 0:G.decrypted))return;if(!(null==(e=G.channelName)?void 0:e.toLowerCase().includes("wardrive")))return;const s=te(G.text);return s?{latitude:s.lat,longitude:s.lon,name:G.senderName||"Wardrive Ping",prefix:(null==(t=G.senderName)?void 0:t.slice(0,2).toUpperCase())||"WD",nodeType:"wardrive"}:void 0},[G,te]),ae=(m.payload_type??m.type)===xe.ADVERT&&(void 0!==O||F),ne=void 0!==se,re=O??se;if(0===L.length)return null;const le=(null==y?void 0:y.local_hash)?(y.local_hash.startsWith("0x")?y.local_hash.slice(2,4):y.local_hash.slice(0,2)).toUpperCase():"";for(const e of L){const t=e.toUpperCase();if(t!==le)if(A){let e=0,s=0;if(A.forEach((a,n)=>{(n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===t&&(e++,s=Math.max(s,a.combinedScore??0))}),0===e)for(const a of Object.keys(z))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===t)break}else for(const e of Object.keys(z))if((e.startsWith("0x")?e.slice(2,4):e.slice(0,2)).toUpperCase()===t)break}const ie={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)"},ce=ie[ye[C]??"zinc"]||ie.zinc;return e.jsxs(Z,{open:!0,onClose:n,size:"5xl",motionPlus:!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-white/30","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(U,{color:ye[C]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:C}),e.jsx(U,{color:"DIRECT"===S||"T_DIRECT"===S?"cyan":"amber",className:"!text-[9px] !px-1.5 !py-0",children:S}),e.jsxs(U,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[P,"B"]})]}),e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-[15px] font-medium text-blue-400 active:text-blue-300 transition-colors flex-shrink-0 rounded-lg active:bg-white/5",children:"Done"})]}),h&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Ht,{packets:s,selectedIndex:d,onSelect:j,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(U,{color:ye[C]??"zinc",children:C}),e.jsx(U,{color:"DIRECT"===S||"T_DIRECT"===S?"cyan":"amber",children:S}),e.jsxs(U,{color:"zinc",children:[P,"B"]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-white/10"}),e.jsx(Ht,{packets:s,selectedIndex:d,onSelect:j})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Mt,{hasDuplicates:h,hasPrev:i,hasNext:c,canPrevDupe:u,canNextDupe:f}),e.jsx("button",{onClick:n,className:"p-1.5 -m-1.5 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-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:ce,opacity:.6}}),e.jsxs(ee,{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:"p-2 space-y-2",children:[(null!=m.rssi||null!=m.snr)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 rounded-lg bg-white/[0.03]",children:[e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.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(fe,{rssi:m.rssi,snr:m.snr,compact:!0,showValues:!0}),e.jsx("span",{className:"text-[11px] text-white/50",children:be(m.rssi)})]},d)}),L.length>0&&e.jsxs("span",{className:"text-[10px] font-mono text-white/40",children:[L.length," hop",1!==L.length?"s":""]})]}),(F&&L.length>0||ae||ne)&&e.jsx("div",{className:"overflow-hidden rounded-xl",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Je,{path:L,neighbors:z,localNode:D,localHash:null==y?void 0:y.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:A,hubNodes:[...b],traceSnr:I,advertiserSource:re})})}),R&&R.pathHashes.length>0&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",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:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(U,{color:R.isComplete?"green":"amber",compact:!0,children:R.isComplete?"Complete":"In Progress"})})]})}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,overridePath:R.pathHashes,traceSnr:R.snrValues})]}),F&&!R&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Path"}),e.jsxs(U,{color:"zinc",compact:!0,children:[L.length," hop",1!==L.length?"s":""]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,traceSnr:I})]}),$&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Advertiser Info"}),e.jsx(U,{color:"lime",compact:!0,children:$.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[$.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:$.name})]}),$.latitude&&$.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[$.latitude.toFixed(5),", ",$.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[10px] font-mono text-text-muted truncate",children:[$.publicKey.slice(0,16),"...",$.publicKey.slice(-8)]})]}),$.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-text-muted",children:W($.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:$.flagsDescription||`Flags: 0x${$.flags.toString(16).padStart(2,"0")}`})]})]})]}),E&&e.jsx("div",{className:"pt-1",children:e.jsx(vt,{packet:m})})]})}),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 p-4 border-r border-border-subtle",children:E&&e.jsx(vt,{packet:m})}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:F&&L.length>0||ae||ne?e.jsx("div",{className:"h-full w-full",children:e.jsx(Je,{path:L,neighbors:z,localNode:D,localHash:null==y?void 0:y.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:A,hubNodes:[...b],traceSnr:I,advertiserSource:re})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(v,{className:"w-8 h-8 text-text-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-text-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:[!R&&L.length<=1&&(null!=m.rssi||null!=m.snr)&&e.jsx("div",{className:"glass-card rounded-xl p-4",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-text-muted mb-1",children:"Signal"}),e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.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(fe,{rssi:m.rssi,snr:m.snr}),e.jsx("span",{className:"font-medium text-text-primary",children:be(m.rssi)})]},d)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-text-muted mb-1",children:"RF"}),e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.dd,{className:"font-mono text-text-secondary tabular-nums",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[null!=m.rssi&&`${m.rssi} dBm`,null!=m.snr&&` · ${m.snr.toFixed(1)} dB`]},d)})]})]})}),$&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Advertiser"}),e.jsx(U,{color:"lime",compact:!0,children:$.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[$.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:$.name})]}),$.latitude&&$.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[$.latitude.toFixed(5),", ",$.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-text-muted truncate",children:[$.publicKey.slice(0,16),"...",$.publicKey.slice(-8)]})]}),$.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-text-muted",children:W($.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-muted",children:$.flagsDescription||`Flags: 0x${$.flags.toString(16).padStart(2,"0")}`})]})]})]}),R&&R.pathHashes.length>0&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{color:R.isComplete?"green":"amber",compact:!0,children:R.isComplete?"Complete":"In Progress"}),e.jsxs(U,{color:"teal",compact:!0,children:[R.pathHashes.length,"h"]})]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,overridePath:R.pathHashes,traceSnr:R.snrValues})]}),F&&!R&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Path"}),e.jsxs(U,{color:"zinc",compact:!0,children:[L.length,"h"]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,traceSnr:I})]})]})]})]})]})]})}),Lt={type:"spring",visualDuration:.6,bounce:.25,opacity:{duration:.2,ease:"linear"}};function Dt({value:s,format:a,prefix:n,className:r}){const[l,i]=t.useState("waiting");if(t.useEffect(()=>{const e=setTimeout(()=>{i("mounted")},400);return()=>clearTimeout(e)},[]),t.useEffect(()=>{if("mounted"===l){const e=requestAnimationFrame(()=>{i("animating")});return()=>cancelAnimationFrame(e)}},[l]),"waiting"===l){const t=(0).toLocaleString(void 0,a);return e.jsxs("span",{className:r,children:[n,t]})}return e.jsx(z,{className:r,format:a,prefix:n,transition:Lt,children:"animating"===l?s:0})}function zt({label:t,numericValue:s,unit:a,icon:n,subtext:r,showSign:l=!1}){return e.jsxs("div",{className:"rounded-lg p-3 sm:rounded-xl sm:p-4 bg-white/[0.03] ring-1 ring-inset ring-white/[0.06]",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-[10px] sm:text-[11px] font-medium uppercase tracking-wide text-text-muted",children:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dt,{value:s,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:l?"always":"auto"},className:"font-mono text-xl sm:text-2xl font-semibold tabular-nums tracking-tight text-white"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-text-muted"}),a&&e.jsx("span",{className:"text-[10px] sm:text-xs font-medium leading-tight text-text-muted",children:a})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 font-mono text-[10px] sm:text-[11px] text-text-muted/80 truncate",children:r})]})}function At({snr:t}){const s=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:E("w-1.5 h-1.5 rounded-full flex-shrink-0",s),title:`SNR: ${t.toFixed(1)} dB`})}function Et({fromPrefix:t,toPrefix:s,fromName:a,toName:n,snr:l,maxSnr:i,isWeakest:c,isStrongest:o,index:d=0}){const x=Math.max(i+5,15),m=Math.max(0,Math.min(100,(l- -20)/(x- -20)*100)),h="bg-[#0074BE]",u=l>=5?"bg-sys-teal":l>=0?"bg-sys-green":l>=-5?"bg-sys-amber":l>=-10?"bg-sys-orange":"bg-sys-red",g=.3+.15*d;return e.jsxs("div",{className:"relative p-3 pl-5 rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06]",children:[e.jsx("span",{className:E("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",u)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(At,{snr:l})}),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-white/70 truncate",children:a||t}),e.jsx(r,{className:"w-3 h-3 text-white/30 flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-white truncate",children:n||s})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[c&&e.jsx(U,{color:"red",compact:!0,children:"Low"}),o&&!c&&e.jsxs(U,{color:"amber",compact:!0,children:[e.jsx(A,{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-white/[0.06] text-text-primary ring-1 ring-inset ring-white/[0.1]",children:[l>=0?"+":"−",Math.abs(l).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:e.jsx(p.div,{className:E("h-full rounded-full",h),initial:{width:0},animate:{width:`${m}%`},transition:{duration:1.5,delay:g,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:"font-mono text-xs text-text-muted",children:t}),a&&e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[100px]",children:a})]}),e.jsx(r,{className:"w-3 h-3 text-text-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-text-primary",children:s}),n&&e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&e.jsx(U,{color:"red",compact:!0,children:"Bottleneck"}),o&&!c&&e.jsxs(U,{color:"amber",compact:!0,children:[e.jsx(A,{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-white/[0.06] text-text-primary ring-1 ring-inset ring-white/[0.1]",children:[l>=0?"+":"−",Math.abs(l).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-bg-elevated rounded-full overflow-hidden",children:e.jsx(p.div,{className:E("h-full rounded-full",h),initial:{width:0},animate:{width:`${m}%`},transition:{duration:1.5,delay:g,ease:[.25,.1,.25,1]}})})]})]})}function Rt(e,t){if("You"===e)return"You";const s=e.toUpperCase();for(const[a,n]of Object.entries(t))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===s)return n.name||n.node_name||void 0}const Ut=t.memo(function({report:t,onClose:s}){var a,n;const r=K(),l=(null==r?void 0:r.neighbors)??{},i=(null==(a=null==r?void 0:r.config)?void 0:a.repeater)?{latitude:r.config.repeater.latitude,longitude:r.config.repeater.longitude,name:r.config.node_name||"Local Node"}:void 0,c=null==(n=t.bestObservation)?void 0:n.decoded.snrValues,o=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",d={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--text-muted)"}[o];return e.jsxs(Z,{open:!0,onClose:s,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-white/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-white",children:"Trace Report"}),e.jsx("button",{onClick:s,className:"text-[17px] font-medium text-blue-400 active:text-blue-300",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:d,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:"text-base sm:text-lg font-semibold text-text-primary",children:"Trace Report"}),e.jsxs(U,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",children:[e.jsx(L,{className:"w-3 h-3 mr-1"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-text-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:s,className:"p-1.5 -m-1.5 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-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-border-subtle",children:[e.jsxs(U,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",1!==t.targetHopCount?"s":""]})]}),e.jsxs(U,{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(U,{color:"purple",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:"font-mono text-xs text-text-muted tabular-nums",children:se(t.duration)}),t.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-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-[10px] 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-[10px] 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(ee,{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:"rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06] p-2.5 text-center",children:[e.jsx(Dt,{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-white"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(x,{className:"w-2.5 h-2.5 text-text-muted"}),e.jsx("span",{className:"text-[10px] text-white/40",children:"Min dB"})]})]}),e.jsxs("div",{className:"rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06] p-2.5 text-center",children:[e.jsx(Dt,{value:t.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-white tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(D,{className:"w-2.5 h-2.5 text-text-muted"}),e.jsx("span",{className:"text-[10px] text-white/40",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(U,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",compact:!0,children:[e.jsx(L,{className:"w-2.5 h-2.5 mr-0.5"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]}),e.jsxs(U,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(U,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"text-[10px] font-mono text-white/30 ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden rounded-xl",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Je,{path:t.targetPath,neighbors:l,localNode:i,localHash:null==r?void 0:r.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:c})})}),e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-[11px] font-medium text-white/60",children:"Route Path"}),t.linkQuality&&e.jsxs("span",{className:"text-[10px] font-mono text-white/40",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(_t,{packet:t.bestObservation.packet,neighbors:l,localHash:null==r?void 0:r.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-text-muted text-[11px]",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-white/40 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((s,a)=>{var n,r,i;const c=a{const s=t.targetPath[t.linkQuality.weakestLinkPosition],a=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",n=Rt(s,l),r=Rt(a,l),i=t.targetPath[t.linkQuality.strongestLinkPosition],c=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",o=Rt(i,l),d=Rt(c,l);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(zt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:x,subtext:`${n||s} → ${r||a}`}),e.jsx(zt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:D,subtext:`${o||i} → ${d||c}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:t.hopStats.length>0?t.hopStats.map((s,a)=>{var n,r,i;const c=a0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Je,{path:t.targetPath,neighbors:l,localNode:i,localHash:null==r?void 0:r.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:c})})}),e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(U,{color:"teal",compact:!0,children:[t.targetHopCount," hop",1!==t.targetHopCount?"s":""]})]})]}),t.linkQuality&&t.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 font-mono text-[10px] text-text-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-teal-400 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-accent-secondary 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(_t,{packet:t.bestObservation.packet,neighbors:l,localHash:null==r?void 0:r.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-text-muted text-xs",children:"No path data available"})]})]})]})]})]})});function It({message:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[e.jsx(v,{className:"size-6 text-text-muted mb-2"}),e.jsx("p",{className:"text-sm text-text-primary",children:t}),e.jsx("p",{className:"text-xs text-text-muted",children:"Packets will appear here"})]})}function $t(){return e.jsx("div",{className:"py-14 text-center text-sm text-text-muted",children:"Loading packets…"})}function Vt({showPagination:t,currentPage:s,perPage:a,displayCount:n,totalCount:r,action:l}){const i=t?(s-1)*a+1:1,c=t?Math.min(s*a,r):n;return e.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-white/5 px-4 py-3 text-xs text-text-muted sm:px-6",children:[e.jsxs("span",{children:["Showing"," ",e.jsx("span",{className:"font-medium text-text-secondary",children:t?`${i}–${c}`:n})," ","of"," ",e.jsx("span",{className:"font-medium text-text-secondary",children:r})," ","packets"]}),l]})}function Qt({packets:s,allPackets:a,localHash:n,neighbors:r,loading:l=!1,maxPackets:i,perPage:c=50,showPagination:o=!1,onPacketSelect:d,flashNewest:x=!1,emptyMessage:m="No packets found",className:p,footerAction:h}){const[u,g]=t.useState(null),[f,j]=t.useState(null),[y,b]=t.useState({traceTag:null,dupeGroup:null});t.useLayoutEffect(()=>{b({traceTag:null,dupeGroup:null})},[s]);const N=a??s,v=t.useMemo(()=>i&&i>0?s.slice(0,i):s,[s,i]),{currentPage:w,totalPages:k,goToPage:C,pageRange:S}=function(e,s,a){const[n,r]=t.useState(1),l=a?Math.ceil(e/s):1;t.useEffect(()=>{n>l&&l>0&&queueMicrotask(()=>r(1))},[l,n]);const i=t.useCallback(e=>r(Math.max(1,Math.min(e,l))),[l]),c=t.useMemo(()=>function(e,t,s=1){if(t<=7)return Array.from({length:t},(e,t)=>t+1);const a=Math.max(e-s,1),n=Math.min(e+s,t),r=a>2,l=nt+1),"gap",t]}if(r&&!l){const e=3+2*s;return[1,"gap",...Array.from({length:e},(s,a)=>t-e+a+1)]}return[1,"gap",...Array.from({length:n-a+1},(e,t)=>a+t),"gap",t]}(n,l),[n,l]);return{currentPage:n,totalPages:l,goToPage:i,pageRange:c}}(v.length,c,o),P=t.useMemo(()=>{if(!o)return v;const e=(w-1)*c;return v.slice(e,e+c)},[v,o,w,c]),_=t.useMemo(()=>function(e){const t=new Map;for(const s of e)if((s.payload_type??s.type)===ne.TRACE&&s.payload&&s.packet_hash){const e=Be(s.payload);e&&t.set(s.packet_hash,e)}return t}(P),[P]),T=t.useMemo(()=>function(e){const t=new Map;if(0===e.length)return t;for(let s=0;s{var t,a;if(!s||!e.length)return;const l=(null==(t=e[0])?void 0:t.timestamp)??0,i=l>r.current&&r.current>0;if(r.current=l,!i)return;const c=null==(a=e[0])?void 0:a.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>n(c)),d=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(d)}},[e,s]),a}(s,x),B=t.useCallback((e,t)=>{var s,a;const n=e.packet_hash;if(!n)return[e];let r=t;for(;r>0&&(null==(s=P[r-1])?void 0:s.packet_hash)===n;)r--;let l=t;for(;l{var t,s;const a=null==(t=P[e])?void 0:t.packet_hash;if(!a)return e;let n=e;for(;n>0&&(null==(s=P[n-1])?void 0:s.packet_hash)===a;)n--;return n},[P]),F=t.useCallback(e=>{var t,s;const a=null==(t=P[e])?void 0:t.packet_hash;if(!a)return e;let n=e;for(;n{if(d)d(e);else if(void 0!==t){const s=B(e,t),a=s.indexOf(e);g({packets:s,initialIndex:a>=0?a:0,rowIndex:t})}else g({packets:[e],initialIndex:0,rowIndex:0})},[d,B]),D=t.useCallback(()=>{if(!u)return;const e=M(u.rowIndex)-1;if(e<0)return;const t=P[e];if(!t)return;const s=B(t,e);g({packets:s,initialIndex:0,rowIndex:e})},[u,P,M,B]),z=t.useCallback(()=>{if(!u)return;const e=F(u.rowIndex)+1;if(e>=P.length)return;const t=P[e];if(!t)return;const s=B(t,e);g({packets:s,initialIndex:0,rowIndex:e})},[u,P,F,B]),A=t.useMemo(()=>!!u&&M(u.rowIndex)>0,[u,M]),R=t.useMemo(()=>!!u&&F(u.rowIndex)b(t=>({...t,traceTag:e})),[]),I=t.useCallback(e=>b(t=>({...t,dupeGroup:e})),[]),$=t.useCallback(()=>{b({traceTag:null,dupeGroup:null})},[]),V=t.useCallback(e=>{const t=N.filter(t=>(t.payload_type??t.type)===ne.TRACE&&t.payload&&Be(t.payload)===e);if(0===t.length)return;const s=function(e){const t=new Map;for(const s of e){const e=Fe(s);if(!e)continue;const a=e.decoded.traceTag,n=t.get(a)||[];n.push(e),t.set(a,n)}for(const[s,a]of t)a.sort((e,t)=>e.timestamp-t.timestamp),t.set(s,a);return t}(t),a=s.get(e);(null==a?void 0:a.length)&&j(function(e,t){if(0===t.length)return{traceTag:e,traceTagValue:0,targetPath:[],targetHopCount:0,observations:[],observationCount:0,firstSeen:0,lastSeen:0,duration:0,isComplete:!1,maxHopsObserved:0,progressPercent:0,bestObservation:null,hopStats:[],linkQuality:null};const s=[...t].sort((e,t)=>e.timestamp-t.timestamp),a=s.reduce((e,t)=>t.hopCount>e.hopCount?t:e,s[0]),n=s[0].timestamp,r=s[s.length-1].timestamp,l=a.decoded.pathHashes,i=l.length,c=a.hopCount,o=a.decoded.isComplete,d=[],x=a.decoded.snrValues;for(let p=0;p0){const e=Math.min(...x),t=Math.max(...x);m={minSnr:e,maxSnr:t,avgSnr:x.reduce((e,t)=>e+t,0)/x.length,weakestLinkPosition:x.indexOf(e),strongestLinkPosition:x.indexOf(t)}}return{traceTag:e,traceTagValue:a.decoded.traceTagValue,targetPath:l,targetHopCount:i,observations:s,observationCount:s.length,firstSeen:n,lastSeen:r,duration:r-n,isComplete:o,maxHopsObserved:c,progressPercent:i>0?Math.round(c/i*100):0,bestObservation:a,hopStats:d,linkQuality:m,srcHash:a.packet.src_hash,dstHash:a.packet.dst_hash}}(e,a))},[N]),Q=t.useCallback(e=>{const t=N.find(t=>t.packet_hash===e);t&&(j(null),L(t))},[N,L]),O=t=>{if(l&&0===s.length)return e.jsx($t,{});if(0===P.length)return e.jsx(It,{message:m});const a=t?Oe:Qe;return P.map((t,s)=>{const l=t.packet_hash?_.get(t.packet_hash):void 0,i=null!==y.traceTag&&l===y.traceTag,c=T.get(s),o=void 0!==c&&null!==y.dupeGroup&&t.packet_hash===y.dupeGroup;return e.jsx(a,{packet:t,onClick:e=>L(e,s),localHash:n,neighbors:r,isFlashing:x&&H===t.packet_hash,traceTag:l,isTraceHighlighted:i,onTraceHover:U,onViewTraceReport:V,dupeGroupPosition:c,isDupeGroupHovered:o,onDupeGroupHover:I},`${t.packet_hash}_${t.timestamp}_${s}`)})};return e.jsxs("div",{className:E("flex flex-col",p),onMouseLeave:$,children:[e.jsx("div",{className:"hidden divide-y divide-white/5 py-1 sm:block",children:O(!1)}),e.jsx("div",{className:"divide-y divide-white/5 sm:hidden",children:O(!0)}),o&&k>1&&e.jsx("nav",{className:"border-t border-white/5 px-4 py-3",children:e.jsxs(Ce,{className:"justify-center",children:[e.jsx(Se,{onClick:()=>C(w-1),disabled:1===w}),e.jsx(_e,{children:S.map((t,s)=>"gap"===t?e.jsx(He,{},`gap-${s}`):e.jsx(Te,{page:t,current:t===w,onClick:C},t))}),e.jsx(Pe,{onClick:()=>C(w+1),disabled:w===k})]})}),e.jsx(Vt,{showPagination:o,currentPage:w,perPage:c,displayCount:P.length,totalCount:o?v.length:s.length,action:h}),!d&&u&&e.jsx(Ft,{packets:u.packets,initialIndex:u.initialIndex,onClose:()=>g(null),onNavigatePrev:D,onNavigateNext:z,hasPrev:A,hasNext:R}),f&&e.jsx(Ut,{report:f,onClose:()=>j(null),onViewPacket:Q})]})}export{Qt as P,Ae as g}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-ChIFu4o3.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/BasemapLayer-S9Ush6Hh.js","assets/useThemeColors-AeHMyThq.js","assets/index-BJEgt3tp.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-CIefRaAd.css"])))=>i.map(i=>d[i]); +import{j as e,r as t,an as s,ao as a,a0 as n,a1 as r,aj as l,ap as i,aq as c,ar as o,as as d,at as x,e as m,m as p,au as h,av as u,D as g,aw as f,ax as j,ay as y,az as b,aA as N,E as v,aB as w,aC as k,t as C,aD as S,ab as P,A as _,aE as T,aF as H,aG as B,aH as M,C as F,V as L,a9 as D,aI as z,a5 as A}from"./vendor-react-C341c8YC.js";import{n as E}from"./recharts-6XUQYgRA.js";import{y as R,B as U,z as I,A as $,C as V,E as Q,G as O,n as W,H as G,I as q,e as K,J as Y,K as J,M as X,N as Z,O as ee,Q as te,U as se,V as ae,W as ne}from"./index-BJEgt3tp.js";import{P as re,d as le,g as ie,a as ce,h as oe,b as de,c as xe,e as me,f as pe,i as he,j as ue}from"./channel-keys-DJWRrSwE.js";import{D as ge,S as fe,R as je,P as ye,g as be}from"./SignalIndicator-BLrEkFNb.js";import{_ as Ne}from"./deckgl-DTsmDcfs.js";import{D as ve}from"./DataBox-CRX76VsB.js";import{g as we,s as ke}from"./useThemeColors-AeHMyThq.js";function Ce({"aria-label":t="Page navigation",className:s,...a}){return e.jsx("nav",{"aria-label":t,...a,className:E("flex gap-x-2",s)})}function Se({onClick:t,disabled:s=!1,className:a,children:n="Previous"}){return e.jsx("span",{className:E("grow basis-0",a),children:e.jsxs(R,{plain:!0,onClick:t,disabled:s,"aria-label":"Previous page",className:E("gap-1",s&&"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 Pe({onClick:t,disabled:s=!1,className:a,children:n="Next"}){return e.jsx("span",{className:E("flex grow basis-0 justify-end",a),children:e.jsxs(R,{plain:!0,onClick:t,disabled:s,"aria-label":"Next page",className:E("gap-1",s&&"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 _e({className:t,...s}){return e.jsx("span",{...s,className:E("hidden items-baseline gap-x-2 sm:flex",t)})}function Te({page:t,current:s=!1,onClick:a,className:n,children:r}){return e.jsx(R,{plain:!s,outline:s,onClick:()=>null==a?void 0:a(t),"aria-label":`Page ${t}`,"aria-current":s?"page":void 0,className:E("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",s&&"before:bg-white/5",n),children:r??t})}function He({className:t,...s}){return e.jsx("span",{"aria-hidden":"true",...s,className:E("w-[2.25rem] select-none text-center text-sm text-text-muted",t),children:"…"})}function Be(e){if(!e||e.length<8)return null;const t=parseInt(e.slice(0,2),16),s=parseInt(e.slice(2,4),16),a=parseInt(e.slice(4,6),16),n=parseInt(e.slice(6,8),16);return isNaN(t)||isNaN(s)||isNaN(a)||isNaN(n)?null:((t|s<<8|a<<16|n<<24)>>>0).toString(16).toUpperCase().padStart(8,"0")}function Me(e){return e>=10?"excellent":e>=5?"good":e>=0?"fair":e>=-5?"poor":"critical"}function Fe(e){if(!e.payload)return null;try{const t=oe(e.payload),s=function(e){const t=e.original_path||e.forwarded_path||[];if("string"==typeof t)try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(e=>parseInt(e,16))}catch{return[]}else if(Array.isArray(t))return t.map(e=>parseInt(e,16));return[]}(e),a=de(t,s);return a?{packet:e,decoded:a,timestamp:e.timestamp??0,hopCount:a.snrValues.length,rssi:e.rssi,snr:e.snr}:null}catch{return null}}const Le={rx:{icon:l,label:"Rx",badgeColor:ge.rx,avatarBg:"bg-emerald-500/15",avatarText:"text-emerald-400"},forward:{icon:r,label:"Fwd",badgeColor:ge.forward,avatarBg:"bg-sky-500/15",avatarText:"text-sky-400"},duplicate:{icon:n,label:"Dupe",badgeColor:ge.duplicate,avatarBg:"bg-zinc-500/15",avatarText:"text-zinc-400"},tx:{icon:a,label:"Tx",badgeColor:ge.tx,avatarBg:"bg-violet-500/15",avatarText:"text-violet-400"},dropped:{icon:s,label:"Drop",badgeColor:ge.dropped,avatarBg:"bg-amber-500/15",avatarText:"text-amber-400"}},De={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},ze={sm:"w-7 h-7",md:"w-8 h-8",lg:"w-9 h-9"};function Ae(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 Ee=t.memo(function({packet:t,showLabel:s=!0,variant:a="avatar",size:n="sm"}){const r=Ae(t),l=Le[r],i=l.icon;return"avatar"===a?e.jsx("div",{className:E("flex items-center justify-center rounded-full flex-shrink-0",l.avatarBg,ze[n]),children:e.jsx(i,{className:E(De[n],l.avatarText)})}):e.jsxs(U,{color:l.badgeColor,children:[e.jsx(i,{className:De[n]}),s&&l.label]})}),Re=t.memo(function({path:t,localHash:s,className:a}){if(!t||0===t.length)return e.jsx("span",{className:E("text-white/30 text-[10px]",a),children:"—"});const n=s?(s.startsWith("0x")?s.slice(2,4):s.slice(0,2)).toUpperCase():null;return e.jsx("span",{className:E("flex items-center gap-0.5 font-mono text-[10px] overflow-hidden",a),children:t.map((s,a)=>{const r=a===t.length-1,l=n&&s.toUpperCase()===n;return e.jsxs("span",{className:"flex items-center flex-shrink-0",children:[l?e.jsx("span",{className:"px-1 py-0.5 rounded bg-amber-500/20 text-amber-400 text-[9px] font-medium",children:"You"}):e.jsx("span",{className:"px-1 py-0.5 rounded bg-white/[0.06] text-white/60",children:s.toUpperCase()}),!r&&e.jsx(i,{className:"w-2.5 h-2.5 text-white/20 mx-0.5 flex-shrink-0"})]},`${s}-${a}`)})})}),Ue=t.memo(function({count:t,className:s}){const a=t>=2;return e.jsxs("span",{className:E("font-mono text-xs tabular-nums",a?"text-white/70":"text-white/30",s),children:[t,e.jsx("span",{className:"text-white/20",children:"→"})]})});function Ie(e){const t=e.payload_type_name||V(e.payload_type??e.type),s=e.route_type_name||Q(e.route_type??e.route);return{payloadType:t,routeType:s,payloadColor:ye[t]??"zinc",routeColor:je[s]??"zinc"}}function $e(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Ve(e,t){if(!e||!t)return null;const s=e.startsWith("0x")?e.slice(2):e;for(const[a,n]of Object.entries(t))if((a.startsWith("0x")?a.slice(2):a).toLowerCase().startsWith(s.toLowerCase()))return n.name||n.node_name||null;return null}const Qe=t.memo(function({packet:s,onClick:a,localHash:n,neighbors:r,isFlashing:l=!1,isPending:i,isTraceHighlighted:o,onTraceHover:d,traceTag:x,onViewTraceReport:m,dupeGroupPosition:p,isDupeGroupHovered:h=!1,onDupeGroupHover:u}){const g=I(s.is_duplicate),f=void 0!==p,{payloadType:j,routeType:y,payloadColor:b,routeColor:N}=Ie(s),v="tx_local"===s.packet_origin,w=i??s.isPending,k="TRACE"===j,C=$e(s.original_path),S=$e(s.forwarded_path),P=S.length>0?S:C,_=P.length,T=s.src_hash?(s.src_hash.startsWith("0x")?s.src_hash.slice(2,6):s.src_hash.slice(0,4)).toUpperCase():null,H=Ve(s.src_hash,r),B=s.payload_length??s.length??0;s.lbt_attempts;const M=t.useCallback(()=>{k&&x&&m?m(x):a(s)},[k,x,m,a,s]),F=t.useCallback(()=>{k&&x&&d&&d(x),f&&u&&s.packet_hash&&u(s.packet_hash)},[k,x,d,f,u,s.packet_hash]),L=t.useCallback(()=>{d&&d(null),u&&u(null)},[d,u]),D={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)",brown:"rgb(168, 133, 107)"},z=D[b]||D.zinc,A=h;return e.jsxs("div",{onClick:M,onMouseEnter:F,onMouseLeave:L,className:E("group relative cursor-pointer","hover:bg-white/[0.02]",g&&!h&&"opacity-40",l&&"flash-row",w&&"opacity-70",v&&"bg-violet-500/5",o&&"bg-teal-500/10"),children:[e.jsx("div",{className:E("absolute pointer-events-none transition-opacity duration-75",f?A?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:(()=>{const e={pointerEvents:"none"};return"first"===p?{...e,borderTop:`2px solid ${z}`,borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:"middle"===p?{...e,borderTop:"none",borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:"last"===p?{...e,borderTop:"none",borderLeft:`2px solid ${z}`,borderRight:`2px solid ${z}`,borderBottom:`2px solid ${z}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...e,border:`2px solid ${z}`,borderRadius:"8px",inset:"-2px"}})()}),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.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ee,{packet:s,variant:"avatar",size:"sm"}),w&&e.jsx(c,{className:"absolute -right-1 -bottom-1 w-3 h-3 text-amber-400 animate-spin"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-bold text-[13px] text-white font-sans truncate",children:T||"—"}),H&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-white/40 truncate max-w-[70px]",children:H})]})]}),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:"text-[10px] min-[600px]:text-[11px] text-white/50 font-mono tabular-nums whitespace-nowrap flex-shrink-0",children:$(s.timestamp)}),e.jsx(U,{color:b,className:"flex-shrink-0",children:j}),e.jsx("span",{className:"min-[600px]:hidden text-[10px] font-mono text-white/40 flex-shrink-0",children:y.charAt(0)}),e.jsx(U,{color:N,className:"flex-shrink-0 hidden min-[600px]:inline-flex",children:y}),e.jsx("div",{className:"flex-shrink-0 flex items-center",children:e.jsx(Ue,{count:_})}),e.jsxs("span",{className:"hidden min-[520px]:inline text-[10px] text-white/40 font-mono flex-shrink-0",children:[B,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:e.jsx(Re,{path:P,localHash:n})})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(fe,{rssi:s.rssi,snr:s.snr,compact:!0,showValues:!0})})]})]})}),Oe=t.memo(function({packet:t,onClick:s,localHash:a,neighbors:n,isFlashing:r=!1,isPending:l,isTraceHighlighted:i,traceTag:o,onViewTraceReport:d,dupeGroupPosition:x,isDupeGroupHovered:m=!1,onDupeGroupHover:p}){const{payloadType:h,routeType:u,payloadColor:g,routeColor:f}=Ie(t),j="tx_local"===t.packet_origin,y=l??t.isPending,b="TRACE"===h,N=I(t.is_duplicate),v=$e(t.original_path),w=$e(t.forwarded_path),k=w.length>0?w:v,C=k.length,S=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,P=Ve(t.src_hash,n),_=t.payload_length??t.length??0,T=t.lbt_attempts??0,H={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)"},B=H[g]||H.zinc;return e.jsxs("div",{onClick:()=>{b&&o&&d?d(o):s(t)},className:E("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-white/[0.04]",N&&"opacity-40",r&&"flash-row",y&&"opacity-70",j&&"bg-violet-500/5",i&&"bg-teal-500/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:(()=>{if(!x)return{opacity:0};const e=m?1:.4,t=m?"3px":"2px";return"first"===x?{backgroundColor:B,opacity:e,width:t,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:"middle"===x?{backgroundColor:B,opacity:e,width:t,top:0,bottom:0,borderRadius:0}:"last"===x?{backgroundColor:B,opacity:e,width:t,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:B,opacity:e,width:t,top:"6px",bottom:"6px",borderRadius:"9999px"}})()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"relative flex-shrink-0 mt-0.5",children:[e.jsx(Ee,{packet:t,variant:"avatar",size:"sm"}),y&&e.jsx(c,{className:"absolute -right-1 -bottom-1 w-2.5 h-2.5 text-amber-400 animate-spin"})]}),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:[e.jsx("span",{className:"font-semibold text-[14px] text-white tracking-tight",children:S||"—"}),P&&e.jsx("span",{className:"text-[12px] text-white/40 truncate max-w-[80px]",children:P}),e.jsx("div",{className:"flex-1"}),e.jsx(U,{color:g,className:"flex-shrink-0 !text-[9px] !px-1.5 !py-0",children:h}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-white/50 tabular-nums w-[28px] text-right",children:t.rssi}),e.jsx(fe,{rssi:t.rssi,compact:!0,showValues:!1})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-white/40 font-mono",children:[e.jsx("span",{className:"tabular-nums",children:$(t.timestamp)}),e.jsx(U,{color:f,className:"!text-[8px] !px-1 !py-0 !leading-none",children:u.charAt(0)}),C>0&&e.jsxs("span",{className:"text-white/30",children:[C,"h"]}),_>0&&e.jsxs("span",{className:"text-white/30",children:[_,"B"]}),T>0&&e.jsxs("span",{className:T>1?"text-amber-400/60":"text-white/30",children:["LBT:",T]}),null!=t.snr&&e.jsxs("span",{className:"text-white/30",children:[t.snr.toFixed(0),"dB"]})]}),C>0&&e.jsx("div",{className:"pt-0.5",children:e.jsx(Re,{path:k,localHash:a})})]})]})]})});function We(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 Ge=t.lazy(()=>Ne(()=>import("./PathMapMapLibre-ChIFu4o3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function qe(e){return`${(100*e).toFixed(0)}%`}function Ke(e,t){const s=document.documentElement,a=getComputedStyle(s),n={success:a.getPropertyValue("--accent-success").trim()||"#39D98A",secondary:a.getPropertyValue("--accent-secondary").trim()||"#F9D26F",poor:a.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:a.getPropertyValue("--accent-danger").trim()||"#FF5C7A",muted:a.getPropertyValue("--text-muted").trim()||"#767688"};let r;return r=0===t?n.muted:e>=1?n.success:e>=.5?n.secondary:e>=.25?n.poor:e>0?n.danger:n.muted,{color:r}}class Ye extends t.Component{constructor(e){super(e),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-text-muted",children:[e.jsx(x,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Je({path:s,neighbors:a,localNode:n,localHash:r,srcHash:l,dstHash:i,neighborAffinity:c,prefixLookup:x,hubNodes:m,traceSnr:p,advertiserSource:h}){const[u,g]=t.useState(null),f=t.useMemo(()=>{if(!h)return null;const e="wardrive"===h.nodeType;return{prefix:h.prefix||"??",candidates:[{hash:h.publicKey||h.prefix||"source",name:h.name,latitude:h.latitude,longitude:h.longitude,probability:1,isLocal:!1,isWardrive:e}],confidence:1,totalMatches:1,isSource:!0}},[h]),j=t.useMemo(()=>{if(h)return null;if(!l)return null;const e=W(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 s=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||l.slice(0,8);return{prefix:e,candidates:[{hash:l,name:s,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[h,l,a]),y=t.useMemo(()=>{const e=(null==i?void 0:i.startsWith("0x"))?i.slice(2):i;if((!e||"00"===e||"0000000000000000"===e)&&n&&r){const e=W(r),t=0!==n.latitude||0!==n.longitude;return{prefix:e,candidates:[{hash:r,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}}if(!i)return null;const t=W(i);if(r&&i===r&&n){const e=0!==n.latitude||0!==n.longitude;return{prefix:t,candidates:[{hash:i,name:n.name||"Local Node",latitude:e?n.latitude:0,longitude:e?n.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const s=a[i];if((null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&(0!==s.latitude||0!==s.longitude))return{prefix:t,candidates:[{hash:i,name:s.node_name||s.name||"Destination",latitude:s.latitude,longitude:s.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===s.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const l=(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||i.slice(0,8);return{prefix:t,candidates:[{hash:i,name:l,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,n,r]),b=t.useMemo(()=>function(e,t,s,a,n,r){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=e.length-1,i=e.map((i,c)=>{const o=c===l,d=e.length-c,{candidates:x,totalMatches:m}=function(e,t,s,a,n=!1,r,l,i){const c=function(e){const t={};for(const[s,a]of Object.entries(e))We(a)&&(t[s]=a);return t}(t);let o;if(l){const t=function(e,t,s){const a=t.toUpperCase(),n=e.get(a);if(!n||0===n.candidates.length)return{hash:null,confidence:0};if(null==s?void 0:s.isLastHop)return{hash:n.bestMatch,confidence:n.confidence};if(1===(null==s?void 0:s.position))return{hash:n.bestMatch,confidence:n.confidence};if((null==s?void 0:s.position)&&n.bestMatchForPosition.has(s.position)){const e=n.bestMatchForPosition.get(s.position),t=Math.max(e.confidence,n.confidence);return{hash:e.hash,confidence:t}}if((null==s?void 0:s.adjacentPrefixes)&&s.adjacentPrefixes.length>0){let e=n.bestMatch,t=0;for(const a of n.candidates){let n=0;for(const e of s.adjacentPrefixes)n+=a.adjacentPrefixCounts.get(e.toUpperCase())||0;const r=a.combinedScore+n/Math.max(1,a.totalAdjacentObservations)*.3;r>t&&(t=r,e=a.hash)}return{hash:e,confidence:n.confidence}}return{hash:n.bestMatch,confidence:n.confidence}}(l,e,{position:i,isLastHop:n});o=t.confidence}const{matches:d,probability:x}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),l=[],i=s&&O(r,s);i&&l.push(s);for(const p of Object.keys(t))O(r,p)&&l.push(p);if(n&&i&&s&&1===l.length)return{matches:l,probability:1,bestMatch:s};if(n&&i&&l.length>1){const e=l.filter(e=>e!==s);if(1===e.length)return{matches:l,probability:1,bestMatch:e[0]}}const c=l.length>0?1/l.length:0,o=[...l].sort();let d=null,x=-1;if(1===o.length)d=o[0];else if(o.length>1&&a){for(const e of o){const t=a.get(e),s=t?"number"==typeof t?t:t.combinedScore:0;s>x&&(x=s,d=e)}d||(d=o[0])}else o.length>0&&(d=o[0]);let m=c;if(l.length>1&&a&&x>0){let e=0;for(const t of l){const s=a.get(t);e+=s?"number"==typeof s?s:s.combinedScore:0}e>0&&(m=Math.min(.95,x/e))}return{matches:l,probability:m,bestMatch:d}}(e,c,a,r,n),m=d.length,p=[],h=e.toUpperCase(),u=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const f of d){if(a&&O(h,a)&&f===a&&u&&s){p.push({hash:f,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:x,isLocal:!0});continue}const e=c[f];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&p.push({hash:f,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:x,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const g=p.length;if(1===g)p[0].probability=o??1;else if(g>1)if(void 0!==o&&o>0){p[0].probability=o;const e=1-o,t=g-1;p.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=p.map(t=>{if(t.isLocal)return{candidate:t,score:1};const a=null==r?void 0:r.get(t.hash);let n=.5;var l;let i;return u&&s&&(n=(l=function(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,l=Math.sin(n/2)*Math.sin(n/2)+Math.cos(e*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}(s.latitude,s.longitude,t.latitude,t.longitude))<100?1:l<500?.9:l<1e3?.7:l<5e3?.5:l<1e4?.3:.1),a?i=.3*n+.3*a.hopConsistencyScore+.4*a.frequencyScore:(i=n,t.isDirectNeighbor&&(i=Math.max(i,.8))),e+=i,{candidate:t,score:i}});if(e>0)t.forEach(({candidate:t,score:s})=>{t.probability=Math.min(.95,s/e)});else{const e=1/g;p.forEach(t=>t.probability=e)}}return{candidates:p,totalMatches:m}}(i,t,s,a,o,n,r,d),p=x.length>0?Math.max(...x.map(e=>e.probability)):0;return{prefix:i,candidates:x,confidence:p,totalMatches:m}}),c=i.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),o=i.some(e=>e.candidates.length>0);return{hops:i,overallConfidence:c,hasValidPath:o}}(s,a,n,r,c,x),[s,a,n,r,c,x]),N=t.useMemo(()=>{const e=[];f?e.push(f):j&&e.push(j),e.push(...b.hops),y&&e.push(y);const t=e.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),s=e.some(e=>e.candidates.some(e=>0!==e.latitude||0!==e.longitude));return{hops:e,overallConfidence:t,hasValidPath:s}},[f,j,b,y]);return N.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-text-muted",children:"Path Confidence:"}),e.jsx("span",{className:(v=N.overallConfidence,v>=1?"text-accent-success":v>=.5?"text-accent-secondary":v>=.25?"text-signal-poor":v>0?"text-accent-danger":"text-text-muted"),children:qe(N.overallConfidence)}),e.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:e.jsx(d,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),e.jsx("span",{className:"text-text-muted",children:"Exact"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),e.jsx("span",{className:"text-text-muted",children:"Multi"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),e.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(Ye,{children:e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"h-full bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:e.jsx(Ge,{resolvedPath:N,localNode:n,hubNodes:m,hoveredHopIndex:u,onHoverHop:g,traceSnr:p})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:N.hops.map((t,s)=>{var a,n,r;const l=!0===t.isSource,i=!0===t.isDestination,c=u===s;let o;return o=l?`Source: ${(null==(a=t.candidates[0])?void 0:a.name)||"Unknown"}`:i?`Destination: ${(null==(n=t.candidates[0])?void 0:n.name)||"Unknown"}`:0===t.totalMatches?"No matching nodes found":1===t.totalMatches?`Exact match: ${(null==(r=t.candidates[0])?void 0:r.name)||"Unknown"}`:`${t.totalMatches} possible matches (${(100*t.confidence).toFixed(0)}% confidence)`,e.jsxs("div",{className:E("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono cursor-pointer transition-all",c?"bg-accent-primary/20 ring-1 ring-accent-primary/50":"bg-bg-elevated hover:bg-bg-subtle",l&&"border border-accent-success/30",i&&"border border-accent-primary/30"),title:o,onMouseEnter:()=>g(s),onMouseLeave:()=>g(null),children:[l&&e.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),i&&e.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:Ke(t.confidence,t.totalMatches),children:t.prefix}),!l&&!i&&t.totalMatches>1&&e.jsxs("span",{className:"text-text-muted",children:["×",t.totalMatches]}),!l&&!i&&0===t.totalMatches&&e.jsx("span",{className:"text-text-muted",children:"?"})]},s)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[e.jsx(o,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var v}function Xe(e){return e.match(/.{1,2}/g)||[]}function Ze(e){return null!==e&&e.startsWith("payload:")}const et={red:"var(--sys-red)",orange:"var(--sys-orange)",amber:"var(--sys-amber)",yellow:"var(--sys-yellow)",lime:"var(--sys-green)",green:"var(--sys-green)",emerald:"var(--sys-green)",teal:"var(--sys-teal)",cyan:"var(--sys-cyan)",sky:"var(--sys-cyan)",blue:"var(--sys-blue)",indigo:"var(--sys-indigo)",violet:"var(--sys-indigo)",purple:"var(--sys-purple)",fuchsia:"var(--sys-pink)",pink:"var(--sys-pink)",rose:"var(--sys-red)",brown:"var(--sys-brown)",zinc:"var(--text-muted)"},tt=15,st="color-mix(in srgb, var(--bg-elevated) 60%, var(--bg-body))",at="\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n ",nt=2,rt={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function lt(e,t){return e?`inset 0 0 0 ${nt}px ${et[t]}`:at}function it(e,t){return e?t:`color-mix(in srgb, ${t} ${tt}%, transparent)`}function ct({segments:s,selectedSegment:a,onSegmentClick:n}){const[r,l]=t.useState(null),[i,c]=t.useState(null),o=s.some(e=>void 0!==e.id)&&n,d=[];for(const e of s){const t=Xe(e.hex);for(const s of t)d.push({byte:s.toUpperCase(),color:e.color,id:e.id})}const x=[];for(let e=0;e{const d=t.length<16;return e.jsx("div",{className:"flex rounded-md overflow-hidden",children:t.map(({byte:s,color:x,id:m},p)=>{const h=p===t.length-1,u=d&&h,g=et[x],f=m?r===m:i===x,j=Boolean(m&&a===m),y=f||j;return e.jsx("span",{className:"w-[1.75rem] text-xs text-center py-0.5 font-mono select-none "+(o?"cursor-pointer":""),style:{backgroundColor:it(y,g),color:y?"rgba(255,255,255,0.95)":g,transition:y?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...u?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{m?l(m):c(x)},onMouseLeave:()=>{l(null),c(null)},onClick:()=>m&&(null==n?void 0:n(m)),onTouchStart:()=>{m?l(m):c(x)},onTouchEnd:()=>{l(null),c(null)},children:s},p)})},s)})})}function ot({bits:t,field:s,value:a,binary:n}){return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-text-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-text-secondary",children:s}),e.jsx("td",{className:"py-1.5",children:(()=>{if("Payload Type"===s){const t=ye[a]||"zinc";return e.jsx(U,{color:t,children:a})}if("Route Type"===s){const t=je[a]||"zinc";return e.jsx(U,{color:t,children:a})}return e.jsx("span",{className:"text-sm text-text-primary",children:a})})()}),e.jsx("td",{className:"py-1.5 font-mono text-xs text-sys-cyan",children:n})]})}function dt({id:t,title:s,color:a,hexBytes:n,startByte:r,endByte:l,isSelected:i,children:c}){const o=n?Xe(n):[];return e.jsxs(p.div,{layout:"position",layoutId:t,transition:rt,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:st,boxShadow:lt(i,a)},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(U,{color:a,children:s}),o.length>0&&o.length<=16&&o.map((t,s)=>e.jsx(U,{color:a,className:"font-mono",children:t.toUpperCase()},s))]}),e.jsxs("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:["Bytes ",r,"-",l]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function xt({advert:t,timestamp:s}){const a=q(s||t.timestamp);return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-purple-500/10 dark:bg-purple-400/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-purple) 0%, var(--sys-blue) 100%)"},children:e.jsx(v,{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-text-primary font-sans truncate leading-tight",children:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[void 0!==t.latitude&&void 0!==t.longitude&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(o,{className:"w-4 h-4 text-purple-600 dark:text-purple-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-purple-600 dark:text-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]})]})]})})}function mt({decoded:t,timestamp:s}){const a=s?q(s):"Unknown";return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-teal-500/10 dark:bg-teal-400/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(N,{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-text-primary font-sans truncate leading-tight",children:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.decrypted?"Decrypted":"Encrypted"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(u,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-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(g,{className:"w-4 h-4 text-teal-600 dark:text-teal-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]}),t.decrypted&&t.decryptedHex&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mb-1 font-sans",children:"Decrypted Data"}),e.jsx("div",{className:"max-w-full overflow-x-auto",children:e.jsx(ve,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function pt({decoded:t,timestamp:s,isLoading:a=!1}){const n=s?q(s):"Unknown";return a?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(--bg-elevated) 60%, var(--bg-body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[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-white/[0.08] animate-pulse"}),e.jsx("div",{className:"h-2.5 w-16 rounded bg-white/[0.08] 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-white/[0.15] animate-pulse"}),e.jsx("div",{className:"h-3.5 w-32 rounded bg-white/[0.15] 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(--bg-elevated) 60%, var(--bg-body))",boxShadow:"\n inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 6%, transparent),\n inset 0 1px 0 color-mix(in srgb, white 3%, transparent),\n 0 1px 2px color-mix(in srgb, black 5%, transparent)\n "},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-text-muted font-sans",children:["From ",e.jsx("span",{className:"text-text-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-text-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 dark:bg-zinc-400/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-zinc) 0%, color-mix(in srgb, var(--sys-zinc) 70%, black) 100%)"},children:e.jsx(f,{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-text-primary font-sans truncate leading-tight",children:"Encrypted Message"}),e.jsxs("p",{className:"text-sm text-text-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-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-zinc-500 dark:text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:n})]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Private channel or unknown hash channel. Channel secret required for decryption."})]})]})})}function ht({decoded:t,timestamp:s}){const a=s?q(s):"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(b,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary font-sans",children:"Acknowledgment"}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:["CRC: ",e.jsxs("span",{className:"font-mono text-sys-green",children:["0x",t.crc]})," · ",a]})]})]})}function ut({decoded:t,timestamp:s}){const a=s?q(s):"Unknown",n=t.path.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-amber-500/10 dark:bg-amber-400/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(y,{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-text-primary font-sans truncate leading-tight",children:"Path Response"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:[n," ",1===n?"hop":"hops"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]}),t.path.length>0&&e.jsx("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.path.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsx(r,{className:"w-4 h-4 text-amber-500 dark:text-amber-400"}),e.jsx(U,{color:"amber",className:"font-mono",children:t})]},s))})})]})]})})}function gt({decoded:t,timestamp:s}){const a=s?q(s):"Unknown",n=t.pathHashes.length,l=t.snrValues.length;return e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"rounded-2xl overflow-hidden bg-blue-500/10 dark:bg-blue-400/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(j,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-medium text-text-primary truncate leading-tight",children:["Trace ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-text-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.isComplete&&" • ✓"]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary",children:a})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-text-muted",children:[e.jsxs("span",{children:[n," target ",1===n?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[l," SNR ",1===l?"sample":"samples"]}),0!==t.authCode&&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((s,a)=>{const n=t.snrValues[a],l=void 0!==n?(e=>e>=7?"green":e>=0?"yellow":e>=-5?"orange":"red")(n):"zinc",i=void 0!==n;return e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsx(r,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(U,{color:i?"blue":"zinc",className:"font-mono",children:s}),i&&e.jsxs(U,{color:l,className:"font-mono",children:[n>=0?"+":"",Number.isInteger(n)?n:n.toFixed(1),"dB"]})]})]},a)})})]})]})})}function ft({decoded:t,timestamp:s}){const a=s?q(s):"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-purple) 0%, var(--sys-indigo) 100%)"},children:e.jsx(f,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-text-primary font-sans",children:"Encrypted Message"}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:[t.srcHash," → ",t.destHash," · ",a]})]})]}):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-text-muted font-sans",children:[e.jsx("span",{className:"font-mono text-text-secondary",children:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-text-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-text-muted font-sans",children:["· ",a]})]}),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 jt({decoded:t,timestamp:s}){const a=s?q(s):"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-yellow-500/10 dark:bg-yellow-400/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(h,{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-text-primary font-sans truncate leading-tight",children:"Multipart Segment"}),e.jsxs("p",{className:"text-sm text-text-muted font-sans mt-0.5",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})]}),e.jsx("div",{className:"mx-4 border-t border-black/10 dark:border-white/10"}),e.jsxs("div",{className:"px-4 py-3 space-y-3",children:[e.jsx("div",{children:e.jsx("div",{className:"h-2 bg-black/10 dark:bg-white/10 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(u,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-text-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(g,{className:"w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-text-secondary font-sans",children:a})]})]})]})})}function yt({decoded:t,timestamp:s,payloadType:a}){const n=s?q(s):"Unknown",r=(()=>{switch(a){case xe.REQ:return{icon:C,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case xe.RESPONSE:return{icon:k,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case xe.ANON_REQ:return{icon:f,gradient:"var(--sys-purple), var(--sys-pink)",bg:"rgba(168, 85, 247, 0.15)",label:"Anonymous Request"};default:return{icon:w,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=r.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, ${r.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-text-primary font-sans",children:r.label}),e.jsxs("p",{className:"text-xs text-text-muted font-sans mt-0.5",children:[t.length," bytes · ",n]})]})]})}function bt({pathHex:t}){if(!t)return null;const s=Xe(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:s.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsx(r,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{size:"compact",copy:!0,children:t.toUpperCase()}),e.jsx("span",{className:"text-[10px] text-text-muted font-sans tabular-nums w-4 text-left",children:s+1})]})]},s))})}function Nt({decoded:t,payloadType:s}){const a=he[s]||`TYPE_${s}`;switch(t.type){case"advert":{const s="chat"===t.nodeType?"companion":t.nodeType.replace("_"," "),a=void 0!==t.latitude&&void 0!==t.longitude&&!(0===t.latitude&&0===t.longitude);return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Role:"})," ",s]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Name:"})," ",t.name]}),a&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Time:"})," ",q(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Flags:"})," ",t.flagsDescription]})]})}case"ack":return e.jsx("div",{className:"text-xs text-text-primary space-y-0.5",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"CRC:"})," 0x",t.crc]})});case"path":return e.jsx("div",{className:"text-xs text-text-primary space-y-1",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Path:"})," ",t.pathString||"(empty)"]})});case"trace":return e.jsxs("div",{className:"text-xs text-text-primary space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Tag:"})," 0x",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"SNR:"})," ",t.snrValues.map(e=>`${e>=0?"+":""}${Number.isInteger(e)?e:e.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-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-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Dest:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Src:"})," ",t.srcHash]}),t.encrypted?e.jsx("p",{className:"text-text-muted italic",children:"Encrypted content"}):e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Text:"})," ",t.text]})]});case"grp_txt":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Channel:"})," ",t.channelName?e.jsx("span",{className:"text-accent-success",children:t.channelName}):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-text-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Text:"})," ",t.text]})]}):e.jsx("p",{className:"text-text-muted italic",children:"Encrypted (unknown channel)"})]});case"grp_data":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-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-text-muted",children:"Data:"})," ",t.dataLength," bytes ",t.decrypted?"(decrypted)":"(encrypted)"]})]});case"multipart":return e.jsxs("div",{className:"text-xs text-text-primary space-y-0.5",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Part:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-text-muted",children:"Message ID:"})," ",t.messageId]})]});default:return e.jsxs("p",{className:"text-xs text-text-secondary",children:[a," (",t.length," bytes)"]})}}const vt=t.memo(function({packet:s}){var a;const n=s.raw_packet||"",l=n.length/2,i=G(),[c,o]=t.useState(null),[d,x]=t.useState(null),[h,u]=t.useState(!1),[g,f]=t.useState(null),j=t.useCallback(e=>{f(t=>t===e?null:e)},[]),y=t.useMemo(()=>function(e){if(!e||e.length<4)return null;const t=re.fromHex(e);if(!t.success||!t.packet)return null;const s=t.packet,a=function(e){const t=3&e,s=e>>2&15,a=e>>6&3;return[{bits:"0-1",field:"Route Type",value:ie(t),binary:(3&t).toString(2).padStart(2,"0")},{bits:"2-5",field:"Payload Type",value:ce(s),binary:(15&s).toString(2).padStart(4,"0")},{bits:"6-7",field:"Version",value:a.toString(),binary:(3&a).toString(2).padStart(2,"0")}]}(s.header),n=e.slice(0,2);let r=2,l="";s.hasTransportCodes()&&(l=e.slice(2,10),r=10);const i=e.slice(r,r+2),c=r+2,o=c+2*s.pathLen,d=e.slice(c,o),x=e.slice(o),m=le(s);return{packet:s,headerHex:n,headerFields:a,transportCodesHex:l,pathLengthHex:i,pathDataHex:d,payloadHex:x,payloadStartByte:Math.floor(o/2),decoded:m}}(n),[n]),b=(null==(a=null==y?void 0:y.packet)?void 0:a.payloadType)===xe.GRP_TXT&&(!i||h);if(t.useEffect(()=>{if(!(null==y?void 0:y.packet)||y.packet.payloadType!==xe.GRP_TXT)return o(null),void u(!1);if(!i)return void u(!0);u(!0);let e=!1;return me(y.packet.payload).then(t=>{e||(t&&o(t),u(!1))}),()=>{e=!0}},[null==y?void 0:y.packet,i]),t.useEffect(()=>{if(!(null==y?void 0:y.packet)||y.packet.payloadType!==xe.GRP_DATA)return void x(null);if(!i)return;let e=!1;return pe(y.packet.payload).then(t=>{!e&&t&&x(t)}),()=>{e=!0}},[null==y?void 0:y.packet,i]),!y||0===n.length)return e.jsx("div",{className:"p-4 text-center text-text-muted",children:e.jsx("p",{className:"text-sm",children:"No raw packet data available"})});const{packet:N}=y;let v=y.decoded;c&&"grp_txt"===y.decoded.type?v=c:d&&"grp_data"===y.decoded.type&&(v=d);const w=t.useMemo(()=>function(t,s){switch(t.type){case"advert":return function(t,s){const a=[];let n=0;const r=s.slice(0,64);a.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-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const l=s.slice(64,72);a.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:l,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:l.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.timestamp," (",q(t.timestamp),")"]})]})}),n+=4;const i=s.slice(72,200);a.push({id:"payload:signature",title:"Signature",color:"teal",hex:i,startByte:n,endByte:n+63,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),n+=64;const c=s.slice(200,202);if(a.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-text-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-text-muted",children:["Node Type: ",t.nodeType]})]})}),n+=1,void 0!==t.latitude){const r=s.slice(2*n,2*n+8);a.push({id:"payload:latitude",title:"Latitude",color:"green",hex:r,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),n+=4}if(void 0!==t.longitude){const r=s.slice(2*n,2*n+8);a.push({id:"payload:longitude",title:"Longitude",color:"purple",hex:r,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),n+=4}if(t.name){const r=s.slice(2*n),l=r.length/2;a.push({id:"payload:name",title:"Name",color:"amber",hex:r,startByte:n,endByte:n+l-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:['"',t.name,'"']})]})})}return a}(t,s);case"ack":return function(t,s){return[{id:"payload:crc",title:"CRC",color:"green",hex:s.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}(t,s);case"grp_txt":return function(t,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&a.push({id:"payload:mac",title:"MAC",color:"purple",hex:s.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.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-text-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["From: ",t.senderName]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:n.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"AES-128-ECB encrypted"})]})}),a}(t,s);case"grp_data":return function(t,s){const a=[];a.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:s.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-text-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&a.push({id:"payload:mac",title:"MAC",color:"purple",hex:s.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=s.slice(6);return n&&a.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-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:(t.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),a}(t,s);case"path":return function(t,s){return[{id:"payload:path",title:"Path Hops",color:"amber",hex:s,startByte:0,endByte:s.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-1",children:[s>0&&e.jsx(r,{className:"w-3 h-3 text-text-muted"}),e.jsx(U,{color:"amber",className:"font-mono",children:t})]},s))}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.path.length," hops"]})]})}]}(t,s);case"trace":return function(t,s){const a=[];a.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:s.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Unique trace request identifier"})]})}),a.push({id:"payload:mac",title:"Auth Code",color:"purple",hex:s.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Authentication/verification code"})]})}),a.push({id:"payload:flags",title:"Flags",color:"amber",hex:s.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ve,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:0===t.flags?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const n=s.slice(18);if(n){const s=e=>e>=7?"green":e>=0?"yellow":e>=-5?"orange":"red";a.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((a,n)=>{const l=t.snrValues[n],i=void 0!==l?s(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[n>0&&e.jsx(r,{className:"w-3 h-3 text-text-muted"}),e.jsx(U,{color:"indigo",className:"font-mono",children:a}),void 0!==l&&e.jsxs(U,{color:i,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},n)})}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[t.pathHashes.length," target ",1===t.pathHashes.length?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${1===t.snrValues.length?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})})}return a}(t,s);case"multipart":return function(t,s){const a=[];a.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:s.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Unique message identifier"})]})}),a.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:s.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"0-indexed part number"})]})}),a.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:s.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const n=s.slice(8);return n&&a.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:n,startByte:4,endByte:4+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:n.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[n.length/2," bytes"]})]})}),a}(t,s);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:s,startByte:0,endByte:s.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] text-text-secondary break-all p-2 rounded bg-bg-body/50 font-mono",children:s.toUpperCase()}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:[s.length/2," bytes"]})]})}]}}(v,y.payloadHex),[v,y.payloadHex]),k="payload"===g||Ze(g),C=t.useMemo(()=>{const e=[{id:"header",hex:y.headerHex,color:"red"},...y.transportCodesHex?[{id:"transportCodes",hex:y.transportCodesHex,color:"purple"}]:[],{id:"pathLength",hex:y.pathLengthHex,color:"green"},...y.pathDataHex?[{id:"pathData",hex:y.pathDataHex,color:"amber"}]:[]];return k?[...e,...(t=w,t.map(e=>({id:e.id,hex:e.hex,color:e.color})))]:[...e,{id:"payload",hex:y.payloadHex,color:"cyan"}];var t},[y,k,w]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[(()=>{switch(v.type){case"advert":return e.jsx(xt,{advert:v,timestamp:s.timestamp});case"grp_data":return e.jsx(mt,{decoded:v,timestamp:s.timestamp});case"grp_txt":return e.jsx(pt,{decoded:v,timestamp:s.timestamp,isLoading:b});case"ack":return e.jsx(ht,{decoded:v,timestamp:s.timestamp});case"path":return e.jsx(ut,{decoded:v,timestamp:s.timestamp});case"trace":return e.jsx(gt,{decoded:v,timestamp:s.timestamp});case"txt_msg":return e.jsx(ft,{decoded:v,timestamp:s.timestamp});case"multipart":return e.jsx(jt,{decoded:v,timestamp:s.timestamp});case"generic":return N.payloadType===xe.REQ||N.payloadType===xe.RESPONSE||N.payloadType===xe.ANON_REQ?e.jsx(yt,{decoded:v,timestamp:s.timestamp,payloadType:N.payloadType}):null;default:return null}})(),e.jsx("div",{className:"bg-black rounded-2xl p-6",children:e.jsx(ct,{segments:C,selectedSegment:g,onSegmentClick:j})}),e.jsx(m,{children:e.jsx(p.div,{layout:!0,transition:rt,className:"space-y-2 min-w-0",children:(()=>{var t,s,a,n;const r=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${y.headerHex.toUpperCase()}`,condition:!0,content:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted border-b border-border-subtle font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:"Bits"}),e.jsx("th",{className:"py-1 font-medium",children:"Field"}),e.jsx("th",{className:"py-1 font-medium",children:"Value"}),e.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),e.jsx("tbody",{children:y.headerFields.map(t=>e.jsx(ot,{...t},t.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"purple",startByte:1,endByte:4,hexBytes:(null==(t=y.transportCodesHex)?void 0:t.toUpperCase())||"",condition:!!y.transportCodesHex,content:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-text-muted",children:"Two 16-bit transport codes for encrypted routing"}),e.jsxs("div",{className:"mt-1 text-xs text-text-secondary",children:["Code 1: 0x",null==(s=y.transportCodesHex)?void 0:s.slice(0,4).toUpperCase()," | Code 2: 0x",null==(a=y.transportCodesHex)?void 0:a.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:y.transportCodesHex?5:1,endByte:y.transportCodesHex?5:1,hexBytes:`0x${y.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-text-muted pt-1",children:[N.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:y.transportCodesHex?6:2,endByte:(y.transportCodesHex?5:1)+N.pathLen,hexBytes:(null==(n=y.pathDataHex)?void 0:n.toUpperCase())||"",condition:N.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(bt,{pathHex:y.pathDataHex}),e.jsx("p",{className:"text-xs text-text-muted",children:"Historical route taken (bytes are added as packet floods through network)"})]})},{id:"payload",title:"Payload",color:"cyan",startByte:y.payloadStartByte,endByte:l-1,hexBytes:y.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!Ze(g)&&e.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(Nt,{decoded:v,payloadType:N.payloadType})]}),!Ze(g)&&w.length>0&&e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),Ze(g)&&e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-text-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(e=>e.condition),i=Ze(g)?w.find(e=>e.id===g):null,c=Ze(g)?[...r].sort((e,t)=>"payload"===e.id?-1:"payload"===t.id?1:0):[...r].sort((e,t)=>e.id===g?-1:t.id===g?1:0),o=Ze(g)?w.filter(e=>e.id!==g):[];return e.jsxs(e.Fragment,{children:[i&&e.jsx(dt,{id:`subfield-${i.id}`,title:i.title,color:i.color,startByte:y.payloadStartByte+i.startByte,endByte:y.payloadStartByte+i.endByte,hexBytes:i.hex.toUpperCase(),isSelected:!0,children:i.decoded},i.id),c.map(t=>e.jsx(dt,{id:`section-${t.id}`,title:t.title,color:t.color,startByte:t.startByte,endByte:t.endByte,hexBytes:t.hexBytes,isSelected:t.id===g,children:t.content},t.id)),o.map(t=>e.jsxs(p.div,{layout:"position",layoutId:`subfield-${t.id}`,transition:rt,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:st,boxShadow:at},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(U,{color:t.color,children:t.title}),t.hex.length<=32&&Xe(t.hex).map((s,a)=>e.jsx(U,{color:t.color,className:"font-mono",children:s.toUpperCase()},a))]}),e.jsxs("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:["Bytes ",y.payloadStartByte+t.startByte,"-",y.payloadStartByte+t.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:t.decoded})]},t.id))]})})()})})]})});function wt(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function kt(e){return e?(e.startsWith("0x")?e.slice(2):e).slice(0,2).toUpperCase():""}function Ct({hop:s,compact:a=!1,index:n=0,highlightIndex:r=-1,isTrace:l=!1}){var i;const c=n===r,o=S();return t.useEffect(()=>{c&&l&&o.start({boxShadow:["0 0 0 0px rgba(113, 156, 223, 0)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 2px rgba(113, 156, 223, 0.5)","0 0 0 0px rgba(113, 156, 223, 0)"],transition:{duration:.5,times:[0,.2,.7,1],ease:"easeInOut"}})},[c,l,o]),e.jsxs(p.div,{className:E("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:c?1.05:1,opacity:c?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(p.div,{className:E("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",s.isLocal?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-zinc-700/50 text-zinc-200 ring-1 ring-zinc-600/50"),animate:o,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[s.isLocal&&e.jsx(P,{className:"w-3 h-3"}),e.jsx("span",{children:s.prefix}),void 0!==s.confidence&&s.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(100*s.confidence).toFixed(0),"%"]})]}),!a&&(null==(i=s.neighborInfo)?void 0:i.name)&&e.jsx("span",{className:"text-[10px] text-text-muted truncate max-w-[80px]",children:s.neighborInfo.name})]})}function St({snr:t}){const s=ke(t),a=we()[s]||"#6b7280",n=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(U,{customColor:a,compact:!0,className:"font-mono",children:[t>=0?"+":"",n,"dB"]})}function Pt({hops:s,compact:a,isTrace:n=!1}){const[r,l]=t.useState(-1);return t.useEffect(()=>{if(0===s.length)return;const e=setTimeout(()=>{l(0)},400),t=setInterval(()=>{l(e=>{const a=e+1;return a>=s.length?(clearInterval(t),-1):a})},n?500:600);return()=>{clearTimeout(e),clearInterval(t)}},[s.length,n]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:s.map((t,l)=>{const i=l%2==0,c=l===s.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:E("flex items-center","justify-end"),children:i&&e.jsx(Ct,{hop:t,compact:a,index:l,highlightIndex:r,isTrace:n})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-zinc-600/40 min-h-[8px]"}),void 0!==t.snr&&e.jsx(St,{snr:t.snr}),e.jsx("svg",{className:"w-3 h-3 text-zinc-500 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:E("flex items-center","justify-start"),children:!i&&e.jsx(Ct,{hop:t,compact:a,index:l,highlightIndex:r,isTrace:n})})]},`${t.prefix}-${l}`)})})}const _t=t.memo(function({packet:s,neighbors:a,localHash:n,neighborAffinity:i,ghostPrefixes:c,direction:o="horizontal",compact:d=!1,traceSnr:x,overridePath:m}){const p=void 0!==x&&x.length>0,h=wt(s.original_path),u=wt(s.forwarded_path),g=m??(u.length>0?u:h),f=kt(n),j=t.useMemo(()=>g.map((e,t)=>{const s=e.toUpperCase(),n=s===f,r=(null==c?void 0:c.has(s))??!1,l=function(e,t,s){const a=e.toUpperCase();if(s){let e=null,n=0;if(s.forEach((t,s)=>{if(kt(s)===a){const a=t.combinedScore??0;a>n&&(n=a,e=s)}}),e&&t[e])return{hash:e,info:t[e],confidence:n}}for(const[n,r]of Object.entries(t))if(kt(n)===a)return{hash:n,info:r,confidence:void 0};return null}(s,a,i);return{prefix:s,fullHash:null==l?void 0:l.hash,neighborInfo:null==l?void 0:l.info,isLocal:n,isGhost:r,confidence:null==l?void 0:l.confidence,snr:null==x?void 0:x[t]}}),[g,a,i,f,c,x]);if(0===j.length)return e.jsxs("div",{className:"flex items-center gap-2 text-text-muted text-xs",children:[e.jsx(v,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if("flowchart"===o)return e.jsx(Pt,{hops:j,compact:d,isTrace:p});const y="horizontal"===o?r:l;return e.jsx("div",{className:E("flex gap-1.5","horizontal"===o?"flex-row flex-wrap items-center":"flex-col items-start"),children:j.map((t,s)=>e.jsxs("div",{className:E("flex items-center gap-1.5","vertical"===o&&"flex-col"),children:[e.jsx(Ct,{hop:t,compact:d}),s0,c=sl&&a(s-1),disabled:!l,className:E("p-0.5 rounded transition-colors",l?"text-text-muted hover:text-text-primary hover:bg-white/10":"text-white/20 cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(B,{className:r?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((t,n)=>{const l=n===s,i=new Date(1e3*t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(te,{color:l?"cyan":"zinc",filled:l,compact:r,onClick:()=>a(n),title:`Observation ${n+1} at ${i}`,className:E("transition-all duration-150",!l&&"opacity-60 hover:opacity-100"),children:r?e.jsx("span",{className:"tabular-nums",children:n+1}):e.jsxs("span",{className:"tabular-nums text-[10px]",children:["#",n+1,null!=t.rssi&&e.jsx("span",{className:"ml-1 opacity-70",children:t.rssi})]})},`${t.timestamp}_${n}`)})}),e.jsx("button",{onClick:()=>c&&a(s+1),disabled:!c,className:E("p-0.5 rounded transition-colors",c?"text-text-muted hover:text-text-primary hover:bg-white/10":"text-white/20 cursor-not-allowed"),"aria-label":"Next observation",children:e.jsx(i,{className:r?"size-3":"size-4"})}),e.jsxs("span",{className:E("text-text-muted ml-1",r?"text-[9px]":"text-[10px]"),children:[e.jsx(n,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Bt({icon:t,label:s,disabled:a=!1}){return e.jsx(p.div,{className:"flex items-center gap-1 text-[10px]",title:s,animate:{opacity:a?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:E("flex items-center justify-center size-5 rounded border transition-colors duration-150",a?"bg-white/[0.02] border-white/5":"bg-white/5 border-white/10"),children:t})})}function Mt({hasDuplicates:t,hasPrev:s,hasNext:a,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(Bt,{icon:e.jsx(M,{className:"size-3"}),label:"Previous packet (↑)",disabled:!s}),e.jsx(Bt,{icon:e.jsx(F,{className:"size-3"}),label:"Next packet (↓)",disabled:!a})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(Bt,{icon:e.jsx(B,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Bt,{icon:e.jsx(i,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}const Ft=t.memo(function({packets:s,initialIndex:a=0,onClose:n,onNavigatePrev:r,onNavigateNext:l,hasPrev:i=!1,hasNext:c=!1}){const[d,x]=t.useState(a),m=s[d]??s[0],h=s.length>1,u=d>0,f=d{x(Math.max(0,Math.min(e,s.length-1)))},[s.length]);t.useEffect(()=>{const e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case"ArrowUp":e.preventDefault(),null==r||r();break;case"ArrowDown":e.preventDefault(),null==l||l();break;case"ArrowLeft":e.preventDefault(),u&&x(e=>e-1);break;case"ArrowRight":e.preventDefault(),f&&x(e=>e+1)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l,u,f]);const y=K(),b=Y(),N=J(),w=X(),k=t.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),C=m.payload_type_name||V(m.payload_type??m.type),S=m.route_type_name||Q(m.route_type??m.route),P=m.payload_length??m.length??0,B=Tt(m.original_path),M=Tt(m.forwarded_path),F=B.length>0||M.length>0,L=M.length>0?M:B,D=t.useMemo(()=>{var e;if(null==(e=null==y?void 0:y.config)?void 0:e.repeater)return{latitude:y.config.repeater.latitude,longitude:y.config.repeater.longitude,name:y.config.node_name||"Local Node"}},[y]),z=(null==y?void 0:y.neighbors)??{},A=N.size>0?N:void 0,E=m.raw_packet&&m.raw_packet.length>0,R=t.useMemo(()=>{if((m.payload_type??m.type)!==xe.TRACE||!m.payload)return null;try{const e=oe(m.payload),t=m.original_path||m.forwarded_path||[];let s=[];if("string"==typeof t)try{const e=JSON.parse(t);Array.isArray(e)&&(s=e.map(e=>parseInt(e,16)))}catch{s=[]}else Array.isArray(t)&&(s=t.map(e=>parseInt(e,16)));return de(e,s)}catch{return null}},[m]),I=null==R?void 0:R.snrValues,$=t.useMemo(()=>{if((m.payload_type??m.type)!==xe.ADVERT||!m.payload)return null;try{const e=oe(m.payload),t=ue(e);if(!t)return null;const s=t.publicKey.slice(0,2).toUpperCase();return{...t,prefix:s}}catch{return null}},[m]),O=t.useMemo(()=>{if((null==$?void 0:$.latitude)&&(null==$?void 0:$.longitude))return{latitude:$.latitude,longitude:$.longitude,name:$.name||`Node ${$.prefix||"??"}`,prefix:$.prefix,publicKey:$.publicKey}},[$]),W=e=>e&&0!==e?new Date(1e3*e).toLocaleString():"Unknown",[G,q]=t.useState(null);t.useEffect(()=>{if((m.payload_type??m.type)!==xe.GRP_TXT||!m.payload)return void q(null);let e=!1;const t=oe(m.payload);return me(t).then(t=>{!e&&t&&q(t)}),()=>{e=!0}},[m]);const te=t.useCallback(e=>{if(!e)return null;const t=e.trim().match(/(-?\d+\.?\d*)\s*[,\s]\s*(-?\d+\.?\d*)/);if(!t)return null;const s=parseFloat(t[1]),a=parseFloat(t[2]);return isNaN(s)||isNaN(a)||s<-90||s>90||a<-180||a>180||0===s&&0===a?null:{lat:s,lon:a}},[]),se=t.useMemo(()=>{var e,t;if(!(null==G?void 0:G.decrypted))return;if(!(null==(e=G.channelName)?void 0:e.toLowerCase().includes("wardrive")))return;const s=te(G.text);return s?{latitude:s.lat,longitude:s.lon,name:G.senderName||"Wardrive Ping",prefix:(null==(t=G.senderName)?void 0:t.slice(0,2).toUpperCase())||"WD",nodeType:"wardrive"}:void 0},[G,te]),ae=(m.payload_type??m.type)===xe.ADVERT&&(void 0!==O||F),ne=void 0!==se,re=O??se;if(0===L.length)return null;const le=(null==y?void 0:y.local_hash)?(y.local_hash.startsWith("0x")?y.local_hash.slice(2,4):y.local_hash.slice(0,2)).toUpperCase():"";for(const e of L){const t=e.toUpperCase();if(t!==le)if(A){let e=0,s=0;if(A.forEach((a,n)=>{(n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===t&&(e++,s=Math.max(s,a.combinedScore??0))}),0===e)for(const a of Object.keys(z))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===t)break}else for(const e of Object.keys(z))if((e.startsWith("0x")?e.slice(2,4):e.slice(0,2)).toUpperCase()===t)break}const ie={lime:"rgb(132, 204, 22)",cyan:"rgb(34, 211, 238)",amber:"rgb(251, 191, 36)",violet:"rgb(167, 139, 250)",rose:"rgb(251, 113, 133)",emerald:"rgb(52, 211, 153)",sky:"rgb(56, 189, 248)",orange:"rgb(251, 146, 60)",pink:"rgb(244, 114, 182)",zinc:"rgb(161, 161, 170)",purple:"rgb(168, 85, 247)",indigo:"rgb(129, 140, 248)",teal:"rgb(45, 212, 191)",fuchsia:"rgb(232, 121, 249)",blue:"rgb(59, 130, 246)",green:"rgb(34, 197, 94)",yellow:"rgb(250, 204, 21)",red:"rgb(239, 68, 68)"},ce=ie[ye[C]??"zinc"]||ie.zinc;return e.jsxs(Z,{open:!0,onClose:n,size:"5xl",motionPlus:!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-white/30","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(U,{color:ye[C]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:C}),e.jsx(U,{color:"DIRECT"===S||"T_DIRECT"===S?"cyan":"amber",className:"!text-[9px] !px-1.5 !py-0",children:S}),e.jsxs(U,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[P,"B"]})]}),e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-[15px] font-medium text-blue-400 active:text-blue-300 transition-colors flex-shrink-0 rounded-lg active:bg-white/5",children:"Done"})]}),h&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Ht,{packets:s,selectedIndex:d,onSelect:j,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(U,{color:ye[C]??"zinc",children:C}),e.jsx(U,{color:"DIRECT"===S||"T_DIRECT"===S?"cyan":"amber",children:S}),e.jsxs(U,{color:"zinc",children:[P,"B"]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-white/10"}),e.jsx(Ht,{packets:s,selectedIndex:d,onSelect:j})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Mt,{hasDuplicates:h,hasPrev:i,hasNext:c,canPrevDupe:u,canNextDupe:f}),e.jsx("button",{onClick:n,className:"p-1.5 -m-1.5 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-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:ce,opacity:.6}}),e.jsxs(ee,{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:"p-2 space-y-2",children:[(null!=m.rssi||null!=m.snr)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 rounded-lg bg-white/[0.03]",children:[e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.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(fe,{rssi:m.rssi,snr:m.snr,compact:!0,showValues:!0}),e.jsx("span",{className:"text-[11px] text-white/50",children:be(m.rssi)})]},d)}),L.length>0&&e.jsxs("span",{className:"text-[10px] font-mono text-white/40",children:[L.length," hop",1!==L.length?"s":""]})]}),(F&&L.length>0||ae||ne)&&e.jsx("div",{className:"overflow-hidden rounded-xl",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Je,{path:L,neighbors:z,localNode:D,localHash:null==y?void 0:y.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:A,hubNodes:[...b],traceSnr:I,advertiserSource:re})})}),R&&R.pathHashes.length>0&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",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:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(U,{color:R.isComplete?"green":"amber",compact:!0,children:R.isComplete?"Complete":"In Progress"})})]})}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,overridePath:R.pathHashes,traceSnr:R.snrValues})]}),F&&!R&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Path"}),e.jsxs(U,{color:"zinc",compact:!0,children:[L.length," hop",1!==L.length?"s":""]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,traceSnr:I})]}),$&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wide",children:"Advertiser Info"}),e.jsx(U,{color:"lime",compact:!0,children:$.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[$.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:$.name})]}),$.latitude&&$.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[$.latitude.toFixed(5),", ",$.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[10px] font-mono text-text-muted truncate",children:[$.publicKey.slice(0,16),"...",$.publicKey.slice(-8)]})]}),$.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-text-muted",children:W($.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:$.flagsDescription||`Flags: 0x${$.flags.toString(16).padStart(2,"0")}`})]})]})]}),E&&e.jsx("div",{className:"pt-1",children:e.jsx(vt,{packet:m})})]})}),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 p-4 border-r border-border-subtle",children:E&&e.jsx(vt,{packet:m})}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:F&&L.length>0||ae||ne?e.jsx("div",{className:"h-full w-full",children:e.jsx(Je,{path:L,neighbors:z,localNode:D,localHash:null==y?void 0:y.local_hash,srcHash:m.src_hash,dstHash:m.dst_hash,neighborAffinity:A,hubNodes:[...b],traceSnr:I,advertiserSource:re})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(v,{className:"w-8 h-8 text-text-muted/50 mb-2"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Direct Reception"}),e.jsx("span",{className:"text-xs text-text-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:[!R&&L.length<=1&&(null!=m.rssi||null!=m.snr)&&e.jsx("div",{className:"glass-card rounded-xl p-4",children:e.jsxs("dl",{className:"text-xs grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-text-muted mb-1",children:"Signal"}),e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.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(fe,{rssi:m.rssi,snr:m.snr}),e.jsx("span",{className:"font-medium text-text-primary",children:be(m.rssi)})]},d)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-text-muted mb-1",children:"RF"}),e.jsx(_,{mode:"popLayout",initial:!1,children:e.jsxs(p.dd,{className:"font-mono text-text-secondary tabular-nums",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15,ease:[.4,0,.2,1]},children:[null!=m.rssi&&`${m.rssi} dBm`,null!=m.snr&&` · ${m.snr.toFixed(1)} dB`]},d)})]})]})}),$&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Advertiser"}),e.jsx(U,{color:"lime",compact:!0,children:$.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[$.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:$.name})]}),$.latitude&&$.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono text-text-secondary",children:[$.latitude.toFixed(5),", ",$.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-text-muted truncate",children:[$.publicKey.slice(0,16),"...",$.publicKey.slice(-8)]})]}),$.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-text-muted",children:W($.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-muted",children:$.flagsDescription||`Flags: 0x${$.flags.toString(16).padStart(2,"0")}`})]})]})]}),R&&R.pathHashes.length>0&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{color:R.isComplete?"green":"amber",compact:!0,children:R.isComplete?"Complete":"In Progress"}),e.jsxs(U,{color:"teal",compact:!0,children:[R.pathHashes.length,"h"]})]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,overridePath:R.pathHashes,traceSnr:R.snrValues})]}),F&&!R&&e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Path"}),e.jsxs(U,{color:"zinc",compact:!0,children:[L.length,"h"]})]}),e.jsx(_t,{packet:m,neighbors:z,localHash:null==y?void 0:y.local_hash,neighborAffinity:A,ghostPrefixes:k,direction:"flowchart",compact:!0,traceSnr:I})]})]})]})]})]})]})}),Lt={type:"spring",visualDuration:.6,bounce:.25,opacity:{duration:.2,ease:"linear"}};function Dt({value:s,format:a,prefix:n,className:r}){const[l,i]=t.useState("waiting");if(t.useEffect(()=>{const e=setTimeout(()=>{i("mounted")},400);return()=>clearTimeout(e)},[]),t.useEffect(()=>{if("mounted"===l){const e=requestAnimationFrame(()=>{i("animating")});return()=>cancelAnimationFrame(e)}},[l]),"waiting"===l){const t=(0).toLocaleString(void 0,a);return e.jsxs("span",{className:r,children:[n,t]})}return e.jsx(z,{className:r,format:a,prefix:n,transition:Lt,children:"animating"===l?s:0})}function zt({label:t,numericValue:s,unit:a,icon:n,subtext:r,showSign:l=!1}){return e.jsxs("div",{className:"rounded-lg p-3 sm:rounded-xl sm:p-4 bg-white/[0.03] ring-1 ring-inset ring-white/[0.06]",children:[e.jsx("div",{className:"mb-1.5 sm:mb-2",children:e.jsx("span",{className:"text-[10px] sm:text-[11px] font-medium uppercase tracking-wide text-text-muted",children:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dt,{value:s,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:l?"always":"auto"},className:"font-mono text-xl sm:text-2xl font-semibold tabular-nums tracking-tight text-white"}),e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(n,{className:"w-[14px] h-[14px] text-text-muted"}),a&&e.jsx("span",{className:"text-[10px] sm:text-xs font-medium leading-tight text-text-muted",children:a})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 font-mono text-[10px] sm:text-[11px] text-text-muted/80 truncate",children:r})]})}function At({snr:t}){const s=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:E("w-1.5 h-1.5 rounded-full flex-shrink-0",s),title:`SNR: ${t.toFixed(1)} dB`})}function Et({fromPrefix:t,toPrefix:s,fromName:a,toName:n,snr:l,maxSnr:i,isWeakest:c,isStrongest:o,index:d=0}){const x=Math.max(i+5,15),m=Math.max(0,Math.min(100,(l- -20)/(x- -20)*100)),h="bg-[#0074BE]",u=l>=5?"bg-sys-teal":l>=0?"bg-sys-green":l>=-5?"bg-sys-amber":l>=-10?"bg-sys-orange":"bg-sys-red",g=.3+.15*d;return e.jsxs("div",{className:"relative p-3 pl-5 rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06]",children:[e.jsx("span",{className:E("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",u)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(At,{snr:l})}),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-white/70 truncate",children:a||t}),e.jsx(r,{className:"w-3 h-3 text-white/30 flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-white truncate",children:n||s})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[c&&e.jsx(U,{color:"red",compact:!0,children:"Low"}),o&&!c&&e.jsxs(U,{color:"amber",compact:!0,children:[e.jsx(A,{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-white/[0.06] text-text-primary ring-1 ring-inset ring-white/[0.1]",children:[l>=0?"+":"−",Math.abs(l).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:e.jsx(p.div,{className:E("h-full rounded-full",h),initial:{width:0},animate:{width:`${m}%`},transition:{duration:1.5,delay:g,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:"font-mono text-xs text-text-muted",children:t}),a&&e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[100px]",children:a})]}),e.jsx(r,{className:"w-3 h-3 text-text-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-text-primary",children:s}),n&&e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[100px]",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&e.jsx(U,{color:"red",compact:!0,children:"Bottleneck"}),o&&!c&&e.jsxs(U,{color:"amber",compact:!0,children:[e.jsx(A,{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-white/[0.06] text-text-primary ring-1 ring-inset ring-white/[0.1]",children:[l>=0?"+":"−",Math.abs(l).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-bg-elevated rounded-full overflow-hidden",children:e.jsx(p.div,{className:E("h-full rounded-full",h),initial:{width:0},animate:{width:`${m}%`},transition:{duration:1.5,delay:g,ease:[.25,.1,.25,1]}})})]})]})}function Rt(e,t){if("You"===e)return"You";const s=e.toUpperCase();for(const[a,n]of Object.entries(t))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===s)return n.name||n.node_name||void 0}const Ut=t.memo(function({report:t,onClose:s}){var a,n;const r=K(),l=(null==r?void 0:r.neighbors)??{},i=(null==(a=null==r?void 0:r.config)?void 0:a.repeater)?{latitude:r.config.repeater.latitude,longitude:r.config.repeater.longitude,name:r.config.node_name||"Local Node"}:void 0,c=null==(n=t.bestObservation)?void 0:n.decoded.snrValues,o=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",d={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--text-muted)"}[o];return e.jsxs(Z,{open:!0,onClose:s,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-white/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-white",children:"Trace Report"}),e.jsx("button",{onClick:s,className:"text-[17px] font-medium text-blue-400 active:text-blue-300",children:"Done"})]})]}),e.jsx("div",{className:"sm:hidden h-[2px]",style:{backgroundColor:d,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:"text-base sm:text-lg font-semibold text-text-primary",children:"Trace Report"}),e.jsxs(U,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",children:[e.jsx(L,{className:"w-3 h-3 mr-1"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-text-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:s,className:"p-1.5 -m-1.5 text-text-muted hover:text-text-primary transition-colors rounded-lg hover:bg-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-border-subtle",children:[e.jsxs(U,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",1!==t.targetHopCount?"s":""]})]}),e.jsxs(U,{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(U,{color:"purple",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:"font-mono text-xs text-text-muted tabular-nums",children:se(t.duration)}),t.linkQuality&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-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-[10px] 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-[10px] 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(ee,{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:"rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06] p-2.5 text-center",children:[e.jsx(Dt,{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-white"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(x,{className:"w-2.5 h-2.5 text-text-muted"}),e.jsx("span",{className:"text-[10px] text-white/40",children:"Min dB"})]})]}),e.jsxs("div",{className:"rounded-lg bg-white/[0.03] ring-1 ring-inset ring-white/[0.06] p-2.5 text-center",children:[e.jsx(Dt,{value:t.linkQuality.maxSnr,format:{maximumFractionDigits:0,signDisplay:"always"},className:"text-[20px] font-bold font-mono text-white tabular-nums flex items-center justify-center"}),e.jsxs("div",{className:"flex items-center justify-center gap-1 mt-1",children:[e.jsx(D,{className:"w-2.5 h-2.5 text-text-muted"}),e.jsx("span",{className:"text-[10px] text-white/40",children:"Max dB"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(U,{color:"excellent"===o||"good"===o?"green":"fair"===o?"amber":"red",compact:!0,children:[e.jsx(L,{className:"w-2.5 h-2.5 mr-0.5"}),"excellent"===o?"Excellent":"good"===o?"Good":"fair"===o?"Fair":"Poor"]}),e.jsxs(U,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(U,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"text-[10px] font-mono text-white/30 ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden rounded-xl",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Je,{path:t.targetPath,neighbors:l,localNode:i,localHash:null==r?void 0:r.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:c})})}),e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[e.jsx("span",{className:"text-[11px] font-medium text-white/60",children:"Route Path"}),t.linkQuality&&e.jsxs("span",{className:"text-[10px] font-mono text-white/40",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(_t,{packet:t.bestObservation.packet,neighbors:l,localHash:null==r?void 0:r.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-6 text-center text-text-muted text-[11px]",children:"No path data available"})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-white/40 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((s,a)=>{var n,r,i;const c=a{const s=t.targetPath[t.linkQuality.weakestLinkPosition],a=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",n=Rt(s,l),r=Rt(a,l),i=t.targetPath[t.linkQuality.strongestLinkPosition],c=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",o=Rt(i,l),d=Rt(c,l);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(zt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:x,subtext:`${n||s} → ${r||a}`}),e.jsx(zt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:D,subtext:`${o||i} → ${d||c}`})]})})(),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted mb-3",children:"Link Details"}),e.jsx("div",{className:"space-y-2",children:t.hopStats.length>0?t.hopStats.map((s,a)=>{var n,r,i;const c=a0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Je,{path:t.targetPath,neighbors:l,localNode:i,localHash:null==r?void 0:r.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:c})})}),e.jsxs("div",{className:"rounded-xl bg-black overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wide",children:"Trace Route"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(U,{color:"teal",compact:!0,children:[t.targetHopCount," hop",1!==t.targetHopCount?"s":""]})]})]}),t.linkQuality&&t.bestObservation&&e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-2 font-mono text-[10px] text-text-muted",children:[e.jsxs("span",{children:[e.jsx("span",{className:"opacity-60",children:"Tag"})," ",e.jsx("code",{className:"text-teal-400 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-accent-secondary 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(_t,{packet:t.bestObservation.packet,neighbors:l,localHash:null==r?void 0:r.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-text-muted text-xs",children:"No path data available"})]})]})]})]})]})});function It({message:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-14 text-center",children:[e.jsx(v,{className:"size-6 text-text-muted mb-2"}),e.jsx("p",{className:"text-sm text-text-primary",children:t}),e.jsx("p",{className:"text-xs text-text-muted",children:"Packets will appear here"})]})}function $t(){return e.jsx("div",{className:"py-14 text-center text-sm text-text-muted",children:"Loading packets…"})}function Vt({showPagination:t,currentPage:s,perPage:a,displayCount:n,totalCount:r,action:l}){const i=t?(s-1)*a+1:1,c=t?Math.min(s*a,r):n;return e.jsxs("div",{className:"flex items-center justify-between gap-4 border-t border-white/5 px-4 py-3 text-xs text-text-muted sm:px-6",children:[e.jsxs("span",{children:["Showing"," ",e.jsx("span",{className:"font-medium text-text-secondary",children:t?`${i}–${c}`:n})," ","of"," ",e.jsx("span",{className:"font-medium text-text-secondary",children:r})," ","packets"]}),l]})}function Qt({packets:s,allPackets:a,localHash:n,neighbors:r,loading:l=!1,maxPackets:i,perPage:c=50,showPagination:o=!1,onPacketSelect:d,flashNewest:x=!1,emptyMessage:m="No packets found",className:p,footerAction:h}){const[u,g]=t.useState(null),[f,j]=t.useState(null),[y,b]=t.useState({traceTag:null,dupeGroup:null});t.useLayoutEffect(()=>{b({traceTag:null,dupeGroup:null})},[s]);const N=a??s,v=t.useMemo(()=>i&&i>0?s.slice(0,i):s,[s,i]),{currentPage:w,totalPages:k,goToPage:C,pageRange:S}=function(e,s,a){const[n,r]=t.useState(1),l=a?Math.ceil(e/s):1;t.useEffect(()=>{n>l&&l>0&&queueMicrotask(()=>r(1))},[l,n]);const i=t.useCallback(e=>r(Math.max(1,Math.min(e,l))),[l]),c=t.useMemo(()=>function(e,t,s=1){if(t<=7)return Array.from({length:t},(e,t)=>t+1);const a=Math.max(e-s,1),n=Math.min(e+s,t),r=a>2,l=nt+1),"gap",t]}if(r&&!l){const e=3+2*s;return[1,"gap",...Array.from({length:e},(s,a)=>t-e+a+1)]}return[1,"gap",...Array.from({length:n-a+1},(e,t)=>a+t),"gap",t]}(n,l),[n,l]);return{currentPage:n,totalPages:l,goToPage:i,pageRange:c}}(v.length,c,o),P=t.useMemo(()=>{if(!o)return v;const e=(w-1)*c;return v.slice(e,e+c)},[v,o,w,c]),_=t.useMemo(()=>function(e){const t=new Map;for(const s of e)if((s.payload_type??s.type)===ne.TRACE&&s.payload&&s.packet_hash){const e=Be(s.payload);e&&t.set(s.packet_hash,e)}return t}(P),[P]),T=t.useMemo(()=>function(e){const t=new Map;if(0===e.length)return t;for(let s=0;s{var t,a;if(!s||!e.length)return;const l=(null==(t=e[0])?void 0:t.timestamp)??0,i=l>r.current&&r.current>0;if(r.current=l,!i)return;const c=null==(a=e[0])?void 0:a.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>n(c)),d=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(d)}},[e,s]),a}(s,x),B=t.useCallback((e,t)=>{var s,a;const n=e.packet_hash;if(!n)return[e];let r=t;for(;r>0&&(null==(s=P[r-1])?void 0:s.packet_hash)===n;)r--;let l=t;for(;l{var t,s;const a=null==(t=P[e])?void 0:t.packet_hash;if(!a)return e;let n=e;for(;n>0&&(null==(s=P[n-1])?void 0:s.packet_hash)===a;)n--;return n},[P]),F=t.useCallback(e=>{var t,s;const a=null==(t=P[e])?void 0:t.packet_hash;if(!a)return e;let n=e;for(;n{if(d)d(e);else if(void 0!==t){const s=B(e,t),a=s.indexOf(e);g({packets:s,initialIndex:a>=0?a:0,rowIndex:t})}else g({packets:[e],initialIndex:0,rowIndex:0})},[d,B]),D=t.useCallback(()=>{if(!u)return;const e=M(u.rowIndex)-1;if(e<0)return;const t=P[e];if(!t)return;const s=B(t,e);g({packets:s,initialIndex:0,rowIndex:e})},[u,P,M,B]),z=t.useCallback(()=>{if(!u)return;const e=F(u.rowIndex)+1;if(e>=P.length)return;const t=P[e];if(!t)return;const s=B(t,e);g({packets:s,initialIndex:0,rowIndex:e})},[u,P,F,B]),A=t.useMemo(()=>!!u&&M(u.rowIndex)>0,[u,M]),R=t.useMemo(()=>!!u&&F(u.rowIndex)b(t=>({...t,traceTag:e})),[]),I=t.useCallback(e=>b(t=>({...t,dupeGroup:e})),[]),$=t.useCallback(()=>{b({traceTag:null,dupeGroup:null})},[]),V=t.useCallback(e=>{const t=N.filter(t=>(t.payload_type??t.type)===ne.TRACE&&t.payload&&Be(t.payload)===e);if(0===t.length)return;const s=function(e){const t=new Map;for(const s of e){const e=Fe(s);if(!e)continue;const a=e.decoded.traceTag,n=t.get(a)||[];n.push(e),t.set(a,n)}for(const[s,a]of t)a.sort((e,t)=>e.timestamp-t.timestamp),t.set(s,a);return t}(t),a=s.get(e);(null==a?void 0:a.length)&&j(function(e,t){if(0===t.length)return{traceTag:e,traceTagValue:0,targetPath:[],targetHopCount:0,observations:[],observationCount:0,firstSeen:0,lastSeen:0,duration:0,isComplete:!1,maxHopsObserved:0,progressPercent:0,bestObservation:null,hopStats:[],linkQuality:null};const s=[...t].sort((e,t)=>e.timestamp-t.timestamp),a=s.reduce((e,t)=>t.hopCount>e.hopCount?t:e,s[0]),n=s[0].timestamp,r=s[s.length-1].timestamp,l=a.decoded.pathHashes,i=l.length,c=a.hopCount,o=a.decoded.isComplete,d=[],x=a.decoded.snrValues;for(let p=0;p0){const e=Math.min(...x),t=Math.max(...x);m={minSnr:e,maxSnr:t,avgSnr:x.reduce((e,t)=>e+t,0)/x.length,weakestLinkPosition:x.indexOf(e),strongestLinkPosition:x.indexOf(t)}}return{traceTag:e,traceTagValue:a.decoded.traceTagValue,targetPath:l,targetHopCount:i,observations:s,observationCount:s.length,firstSeen:n,lastSeen:r,duration:r-n,isComplete:o,maxHopsObserved:c,progressPercent:i>0?Math.round(c/i*100):0,bestObservation:a,hopStats:d,linkQuality:m,srcHash:a.packet.src_hash,dstHash:a.packet.dst_hash}}(e,a))},[N]),Q=t.useCallback(e=>{const t=N.find(t=>t.packet_hash===e);t&&(j(null),L(t))},[N,L]),O=t=>{if(l&&0===s.length)return e.jsx($t,{});if(0===P.length)return e.jsx(It,{message:m});const a=t?Oe:Qe;return P.map((t,s)=>{const l=t.packet_hash?_.get(t.packet_hash):void 0,i=null!==y.traceTag&&l===y.traceTag,c=T.get(s),o=void 0!==c&&null!==y.dupeGroup&&t.packet_hash===y.dupeGroup;return e.jsx(a,{packet:t,onClick:e=>L(e,s),localHash:n,neighbors:r,isFlashing:x&&H===t.packet_hash,traceTag:l,isTraceHighlighted:i,onTraceHover:U,onViewTraceReport:V,dupeGroupPosition:c,isDupeGroupHovered:o,onDupeGroupHover:I},`${t.packet_hash}_${t.timestamp}_${s}`)})};return e.jsxs("div",{className:E("flex flex-col",p),onMouseLeave:$,children:[e.jsx("div",{className:"hidden divide-y divide-white/5 py-1 sm:block",children:O(!1)}),e.jsx("div",{className:"divide-y divide-white/5 sm:hidden",children:O(!0)}),o&&k>1&&e.jsx("nav",{className:"border-t border-white/5 px-4 py-3",children:e.jsxs(Ce,{className:"justify-center",children:[e.jsx(Se,{onClick:()=>C(w-1),disabled:1===w}),e.jsx(_e,{children:S.map((t,s)=>"gap"===t?e.jsx(He,{},`gap-${s}`):e.jsx(Te,{page:t,current:t===w,onClick:C},t))}),e.jsx(Pe,{onClick:()=>C(w+1),disabled:w===k})]})}),e.jsx(Vt,{showPagination:o,currentPage:w,perPage:c,displayCount:P.length,totalCount:o?v.length:s.length,action:h}),!d&&u&&e.jsx(Ft,{packets:u.packets,initialIndex:u.initialIndex,onClose:()=>g(null),onNavigatePrev:D,onNavigateNext:z,hasPrev:A,hasNext:R}),f&&e.jsx(Ut,{report:f,onClose:()=>j(null),onViewPacket:Q})]})}export{Qt as P,Ae as g}; diff --git a/frontend/dist/assets/Packets-DHxvwdwr.js b/frontend/dist/assets/Packets-BHJJxf8a.js similarity index 97% rename from frontend/dist/assets/Packets-DHxvwdwr.js rename to frontend/dist/assets/Packets-BHJJxf8a.js index ef04680a..4ed4198e 100644 --- a/frontend/dist/assets/Packets-DHxvwdwr.js +++ b/frontend/dist/assets/Packets-BHJJxf8a.js @@ -1 +1 @@ -import{r as e,j as a,ae as s,af as l,ag as t,C as i,ah as r,ai as n,$ as o,aj as c,a1 as d,ad as m,a0 as u,ak as p,al as x,am as h,E as b,X as g}from"./vendor-react-C341c8YC.js";import{n as v}from"./recharts-6XUQYgRA.js";import{u as j,e as f,d as y,v as N,x as w,R as k,L as C,y as S}from"./index-CPdqYR4z.js";import{g as P,P as R}from"./PacketList-CnSxB7Jy.js";import{P as L,b as M,a as F}from"./PageLayout-CcoYWyzO.js";import{C as _}from"./Card-BeZKc0xw.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./channel-keys-DJWRrSwE.js";import"./SignalIndicator-BLrEkFNb.js";import"./DataBox-CRX76VsB.js";import"./useThemeColors-AeHMyThq.js";function D({options:n,value:o,onChange:c,defaultValue:d,displayValue:m,filter:u,placeholder:p,disabled:x,invalid:h,name:b,"aria-label":g,className:j,children:f}){const[y,N]=e.useState(""),w=m??(e=>null!=e?String(e):""),k=u??((e,a)=>w(e).toLowerCase().includes(a.toLowerCase())),C=e.useMemo(()=>y?n.filter(e=>k(e,y)):n,[n,y,k]);return a.jsx(s,{value:o,onChange:c,defaultValue:d,disabled:x,name:b,onClose:()=>N(""),children:a.jsxs("div",{className:v("relative",j),children:[a.jsxs("div",{className:"relative",children:[a.jsx(l,{"aria-label":g,displayValue:w,onChange:e=>N(e.target.value),placeholder:p,className:v(["w-full rounded-lg py-2 pl-3 pr-10","text-sm text-text-primary placeholder:text-text-muted","bg-bg-subtle border",h?"border-accent-danger":"border-border-subtle","focus:outline-none focus:border-accent-primary/50 focus:ring-1 focus:ring-accent-primary/20","hover:border-border-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"])}),a.jsx(t,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:a.jsx(i,{className:"w-4 h-4 text-text-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),a.jsx(r,{anchor:"bottom start",transition:!0,className:v(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","rounded-lg p-1 mt-1","glass-card-elevated","focus:outline-none","transition-opacity duration-150 ease-out","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:0===C.length&&""!==y?a.jsx("div",{className:"px-3 py-2 text-sm text-text-muted",children:"No results found"}):C.map((s,l)=>a.jsx(e.Fragment,{children:f(s)},l))})]})})}function A({value:s,disabled:l,className:t,children:i}){return a.jsx(n,{as:e.Fragment,value:s,disabled:l,children:({selected:e,focus:s})=>a.jsxs("div",{className:v("flex items-center gap-2 px-3 py-2 rounded-md cursor-default","text-sm",s&&"bg-accent-primary text-white",!s&&"text-text-primary",e&&!s&&"text-accent-primary",l&&"opacity-50 cursor-not-allowed",t),children:[a.jsx("span",{className:"w-4 flex-shrink-0",children:e&&a.jsx(o,{className:"w-4 h-4"})}),a.jsx("span",{className:"truncate flex-1",children:i})]})})}function T({className:e,...s}){return a.jsx("span",{...s,className:v("truncate",e)})}function V({value:e,onChange:s,options:l,placeholder:t,disabled:i,className:r,"aria-label":n}){const o=l.find(a=>a.value===e);return a.jsx(D,{options:l,value:o,onChange:e=>{e&&s(e.value)},displayValue:e=>(null==e?void 0:e.label)??"",filter:(e,a)=>e.label.toLowerCase().includes(a.toLowerCase()),placeholder:t,disabled:i,className:r,"aria-label":n,children:e=>a.jsx(A,{value:e,disabled:e.disabled,children:a.jsx(T,{children:e.label})})})}function q({icon:e,label:s,value:l,color:t,percentage:i}){return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:v("p-1.5 rounded-md",t),children:e}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm font-semibold text-text-primary",children:l.toLocaleString()}),a.jsxs("span",{className:"text-[10px] text-text-muted leading-tight",children:[s,void 0!==i&&a.jsxs("span",{className:"ml-1 opacity-70",children:["(",i,"%)"]})]})]})]})}const H=e.memo(function({packets:s}){const l=e.useMemo(()=>{let e=0,a=0,l=0;const t=new Set;let i=0,r=0;for(const c of s){switch(P(c)){case"forward":e++;break;case"dropped":a++;break;case"duplicate":l++}c.src_hash&&t.add(c.src_hash),c.rssi&&(i+=c.rssi,r++)}const n=s.length,o=r>0?Math.round(i/r):0;return{total:n,rx:n,fwd:e,dropped:a,duplicate:l,uniqueSources:t.size,avgRssi:o,rxPercent:100,fwdPercent:n>0?Math.round(e/n*100):0,droppedPercent:n>0?Math.round(a/n*100):0}},[s]);return 0===s.length?null:a.jsx("div",{className:"glass-card p-3 pr-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[a.jsx(q,{icon:a.jsx(c,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Received",value:l.rx,color:"bg-accent-primary/10",percentage:l.rxPercent}),a.jsx(q,{icon:a.jsx(d,{className:"w-3.5 h-3.5 text-accent-success"}),label:"Forwarded",value:l.fwd,color:"bg-accent-success/10",percentage:l.fwdPercent}),a.jsx(q,{icon:a.jsx(m,{className:"w-3.5 h-3.5 text-accent-danger"}),label:"Dropped",value:l.dropped,color:"bg-accent-danger/10",percentage:l.droppedPercent}),a.jsx(q,{icon:a.jsx(u,{className:"w-3.5 h-3.5 text-text-muted"}),label:"Duplicates",value:l.duplicate,color:"bg-white/5"}),a.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[a.jsx(q,{icon:a.jsx(p,{className:"w-3.5 h-3.5 text-accent-secondary"}),label:"Sources",value:l.uniqueSources,color:"bg-accent-secondary/10"}),a.jsxs("div",{className:"flex flex-col items-end pr-1",children:[a.jsxs("span",{className:"text-sm font-mono text-text-secondary",children:[l.avgRssi," dBm"]}),a.jsx("span",{className:"text-[10px] text-text-muted",children:"Avg Signal"})]})]})]})})});function z(){const s=j(),l=f(),t=y(),i=N(),r=null==l?void 0:l.local_hash,n=null==l?void 0:l.neighbors,[o,c]=e.useState(!1),[d,m]=e.useState({limit:500,status:"all"}),[u,p]=e.useState(Date.now);e.useEffect(()=>{d.timeRange&&d.timeRange>0&&queueMicrotask(()=>p(Date.now()))},[d.timeRange,s]);const D=e.useMemo(()=>{const e=d.limit??500;return[...s.length<=e?s:s.slice(-e)].sort((e,a)=>(a.timestamp??0)-(e.timestamp??0))},[s,d.limit]),A=0===s.length,T=e.useMemo(()=>{let e=D;if(void 0!==d.type){const a=w[d.type];e=e.filter(e=>{const s=e.type??e.payload_type,l=e.payload_type_name;return s===d.type||l===a})}if(void 0!==d.route){const a=k[d.route];e=e.filter(e=>{const s=e.route??e.route_type,l=e.route_type_name;return s===d.route||l===a})}if(d.status&&"all"!==d.status&&(e=e.filter(e=>P(e)===d.status)),void 0!==d.signalMin&&(e=e.filter(e=>e.rssi>=d.signalMin)),d.timeRange&&d.timeRange>0){const a=u/1e3-3600*d.timeRange;e=e.filter(e=>e.timestamp>=a)}return e},[D,d.type,d.route,d.status,d.signalMin,d.timeRange,u]),q=(e,a)=>m(s=>({...s,[e]:a})),z=void 0!==d.type||void 0!==d.route||d.status&&"all"!==d.status||void 0!==d.signalMin||d.timeRange&&d.timeRange>0;return a.jsxs(L,{children:[a.jsx(M,{title:"Packet History",icon:a.jsx(b,{}),controls:a.jsxs(a.Fragment,{children:[t&&a.jsx(C,{showLabel:!0}),a.jsxs(S,{outline:!0,color:z?"primary":"muted",onClick:()=>c(!o),className:"sm:hidden",children:[a.jsx(x,{"data-slot":"icon"}),z&&a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),a.jsxs(S,{outline:!0,color:t?"success":"muted",onClick:()=>i(!t),children:[a.jsx(h,{"data-slot":"icon",className:v(t&&"animate-spin")}),a.jsx("span",{className:"hidden xs:inline",children:t?"Live":"Paused"})]})]})}),a.jsxs(F,{noPadding:!0,className:v("overflow-hidden transition-all duration-200",o?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[a.jsx(_,{listHeader:!0,icon:a.jsx(x,{className:"icon-sm"}),title:"Filters",actions:z?a.jsxs(S,{plain:!0,color:"muted",onClick:()=>m({limit:d.limit,status:"all"}),className:"!text-xs !py-0.5 !px-1.5",children:[a.jsx(g,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),a.jsx("div",{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Type"}),a.jsx(V,{value:d.type??"",onChange:e=>q("type",""===e?void 0:Number(e)),options:[{value:"",label:"All Types"},...Object.entries(w).map(([e,a])=>({value:Number(e),label:a}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Route"}),a.jsx(V,{value:d.route??"",onChange:e=>q("route",""===e?void 0:Number(e)),options:[{value:"",label:"All Routes"},...Object.entries(k).map(([e,a])=>({value:Number(e),label:a}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Status"}),a.jsx(V,{value:d.status??"all",onChange:e=>q("status",e),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),a.jsxs("div",{className:"flex-1 min-w-[120px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Time"}),a.jsx(V,{value:d.timeRange??0,onChange:e=>q("timeRange",0===e?void 0:e),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),a.jsxs("div",{className:"flex-1 min-w-[130px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),a.jsx(V,{value:d.signalMin??"",onChange:e=>q("signalMin",""===e?void 0:Number(e)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),a.jsxs("div",{className:"flex-1 min-w-[100px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),a.jsx(V,{value:d.limit??500,onChange:e=>q("limit",e),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1000"},{value:2e3,label:"2000"}],placeholder:"Limit...","aria-label":"Packet limit"})]})]})})]}),a.jsx(H,{packets:T}),a.jsx(F,{noPadding:!0,className:"!overflow-visible",children:a.jsx(R,{packets:T,allPackets:s,localHash:r,neighbors:n,loading:A,showPagination:!0,perPage:50,emptyMessage:"No packets found"})})]})}export{z as default}; +import{r as e,j as a,ae as s,af as l,ag as t,C as i,ah as r,ai as n,$ as o,aj as c,a1 as d,ad as m,a0 as u,ak as p,al as x,am as h,E as b,X as g}from"./vendor-react-C341c8YC.js";import{n as v}from"./recharts-6XUQYgRA.js";import{u as j,e as f,d as y,v as N,x as w,R as k,L as C,y as S}from"./index-BJEgt3tp.js";import{g as P,P as R}from"./PacketList-BPeOqxkB.js";import{P as L,b as M,a as F}from"./PageLayout-CnF5SScd.js";import{C as _}from"./Card-2pQSGkKC.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./channel-keys-DJWRrSwE.js";import"./SignalIndicator-BLrEkFNb.js";import"./DataBox-CRX76VsB.js";import"./useThemeColors-AeHMyThq.js";function D({options:n,value:o,onChange:c,defaultValue:d,displayValue:m,filter:u,placeholder:p,disabled:x,invalid:h,name:b,"aria-label":g,className:j,children:f}){const[y,N]=e.useState(""),w=m??(e=>null!=e?String(e):""),k=u??((e,a)=>w(e).toLowerCase().includes(a.toLowerCase())),C=e.useMemo(()=>y?n.filter(e=>k(e,y)):n,[n,y,k]);return a.jsx(s,{value:o,onChange:c,defaultValue:d,disabled:x,name:b,onClose:()=>N(""),children:a.jsxs("div",{className:v("relative",j),children:[a.jsxs("div",{className:"relative",children:[a.jsx(l,{"aria-label":g,displayValue:w,onChange:e=>N(e.target.value),placeholder:p,className:v(["w-full rounded-lg py-2 pl-3 pr-10","text-sm text-text-primary placeholder:text-text-muted","bg-bg-subtle border",h?"border-accent-danger":"border-border-subtle","focus:outline-none focus:border-accent-primary/50 focus:ring-1 focus:ring-accent-primary/20","hover:border-border-strong","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"])}),a.jsx(t,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:a.jsx(i,{className:"w-4 h-4 text-text-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),a.jsx(r,{anchor:"bottom start",transition:!0,className:v(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","rounded-lg p-1 mt-1","glass-card-elevated","focus:outline-none","transition-opacity duration-150 ease-out","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:0===C.length&&""!==y?a.jsx("div",{className:"px-3 py-2 text-sm text-text-muted",children:"No results found"}):C.map((s,l)=>a.jsx(e.Fragment,{children:f(s)},l))})]})})}function A({value:s,disabled:l,className:t,children:i}){return a.jsx(n,{as:e.Fragment,value:s,disabled:l,children:({selected:e,focus:s})=>a.jsxs("div",{className:v("flex items-center gap-2 px-3 py-2 rounded-md cursor-default","text-sm",s&&"bg-accent-primary text-white",!s&&"text-text-primary",e&&!s&&"text-accent-primary",l&&"opacity-50 cursor-not-allowed",t),children:[a.jsx("span",{className:"w-4 flex-shrink-0",children:e&&a.jsx(o,{className:"w-4 h-4"})}),a.jsx("span",{className:"truncate flex-1",children:i})]})})}function T({className:e,...s}){return a.jsx("span",{...s,className:v("truncate",e)})}function V({value:e,onChange:s,options:l,placeholder:t,disabled:i,className:r,"aria-label":n}){const o=l.find(a=>a.value===e);return a.jsx(D,{options:l,value:o,onChange:e=>{e&&s(e.value)},displayValue:e=>(null==e?void 0:e.label)??"",filter:(e,a)=>e.label.toLowerCase().includes(a.toLowerCase()),placeholder:t,disabled:i,className:r,"aria-label":n,children:e=>a.jsx(A,{value:e,disabled:e.disabled,children:a.jsx(T,{children:e.label})})})}function q({icon:e,label:s,value:l,color:t,percentage:i}){return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:v("p-1.5 rounded-md",t),children:e}),a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm font-semibold text-text-primary",children:l.toLocaleString()}),a.jsxs("span",{className:"text-[10px] text-text-muted leading-tight",children:[s,void 0!==i&&a.jsxs("span",{className:"ml-1 opacity-70",children:["(",i,"%)"]})]})]})]})}const H=e.memo(function({packets:s}){const l=e.useMemo(()=>{let e=0,a=0,l=0;const t=new Set;let i=0,r=0;for(const c of s){switch(P(c)){case"forward":e++;break;case"dropped":a++;break;case"duplicate":l++}c.src_hash&&t.add(c.src_hash),c.rssi&&(i+=c.rssi,r++)}const n=s.length,o=r>0?Math.round(i/r):0;return{total:n,rx:n,fwd:e,dropped:a,duplicate:l,uniqueSources:t.size,avgRssi:o,rxPercent:100,fwdPercent:n>0?Math.round(e/n*100):0,droppedPercent:n>0?Math.round(a/n*100):0}},[s]);return 0===s.length?null:a.jsx("div",{className:"glass-card p-3 pr-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[a.jsx(q,{icon:a.jsx(c,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Received",value:l.rx,color:"bg-accent-primary/10",percentage:l.rxPercent}),a.jsx(q,{icon:a.jsx(d,{className:"w-3.5 h-3.5 text-accent-success"}),label:"Forwarded",value:l.fwd,color:"bg-accent-success/10",percentage:l.fwdPercent}),a.jsx(q,{icon:a.jsx(m,{className:"w-3.5 h-3.5 text-accent-danger"}),label:"Dropped",value:l.dropped,color:"bg-accent-danger/10",percentage:l.droppedPercent}),a.jsx(q,{icon:a.jsx(u,{className:"w-3.5 h-3.5 text-text-muted"}),label:"Duplicates",value:l.duplicate,color:"bg-white/5"}),a.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[a.jsx(q,{icon:a.jsx(p,{className:"w-3.5 h-3.5 text-accent-secondary"}),label:"Sources",value:l.uniqueSources,color:"bg-accent-secondary/10"}),a.jsxs("div",{className:"flex flex-col items-end pr-1",children:[a.jsxs("span",{className:"text-sm font-mono text-text-secondary",children:[l.avgRssi," dBm"]}),a.jsx("span",{className:"text-[10px] text-text-muted",children:"Avg Signal"})]})]})]})})});function z(){const s=j(),l=f(),t=y(),i=N(),r=null==l?void 0:l.local_hash,n=null==l?void 0:l.neighbors,[o,c]=e.useState(!1),[d,m]=e.useState({limit:500,status:"all"}),[u,p]=e.useState(Date.now);e.useEffect(()=>{d.timeRange&&d.timeRange>0&&queueMicrotask(()=>p(Date.now()))},[d.timeRange,s]);const D=e.useMemo(()=>{const e=d.limit??500;return[...s.length<=e?s:s.slice(-e)].sort((e,a)=>(a.timestamp??0)-(e.timestamp??0))},[s,d.limit]),A=0===s.length,T=e.useMemo(()=>{let e=D;if(void 0!==d.type){const a=w[d.type];e=e.filter(e=>{const s=e.type??e.payload_type,l=e.payload_type_name;return s===d.type||l===a})}if(void 0!==d.route){const a=k[d.route];e=e.filter(e=>{const s=e.route??e.route_type,l=e.route_type_name;return s===d.route||l===a})}if(d.status&&"all"!==d.status&&(e=e.filter(e=>P(e)===d.status)),void 0!==d.signalMin&&(e=e.filter(e=>e.rssi>=d.signalMin)),d.timeRange&&d.timeRange>0){const a=u/1e3-3600*d.timeRange;e=e.filter(e=>e.timestamp>=a)}return e},[D,d.type,d.route,d.status,d.signalMin,d.timeRange,u]),q=(e,a)=>m(s=>({...s,[e]:a})),z=void 0!==d.type||void 0!==d.route||d.status&&"all"!==d.status||void 0!==d.signalMin||d.timeRange&&d.timeRange>0;return a.jsxs(L,{children:[a.jsx(M,{title:"Packet History",icon:a.jsx(b,{}),controls:a.jsxs(a.Fragment,{children:[t&&a.jsx(C,{showLabel:!0}),a.jsxs(S,{outline:!0,color:z?"primary":"muted",onClick:()=>c(!o),className:"sm:hidden",children:[a.jsx(x,{"data-slot":"icon"}),z&&a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),a.jsxs(S,{outline:!0,color:t?"success":"muted",onClick:()=>i(!t),children:[a.jsx(h,{"data-slot":"icon",className:v(t&&"animate-spin")}),a.jsx("span",{className:"hidden xs:inline",children:t?"Live":"Paused"})]})]})}),a.jsxs(F,{noPadding:!0,className:v("overflow-hidden transition-all duration-200",o?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[a.jsx(_,{listHeader:!0,icon:a.jsx(x,{className:"icon-sm"}),title:"Filters",actions:z?a.jsxs(S,{plain:!0,color:"muted",onClick:()=>m({limit:d.limit,status:"all"}),className:"!text-xs !py-0.5 !px-1.5",children:[a.jsx(g,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),a.jsx("div",{className:"p-3 sm:p-4",children:a.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Type"}),a.jsx(V,{value:d.type??"",onChange:e=>q("type",""===e?void 0:Number(e)),options:[{value:"",label:"All Types"},...Object.entries(w).map(([e,a])=>({value:Number(e),label:a}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Route"}),a.jsx(V,{value:d.route??"",onChange:e=>q("route",""===e?void 0:Number(e)),options:[{value:"",label:"All Routes"},...Object.entries(k).map(([e,a])=>({value:Number(e),label:a}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),a.jsxs("div",{className:"flex-1 min-w-[140px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Status"}),a.jsx(V,{value:d.status??"all",onChange:e=>q("status",e),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),a.jsxs("div",{className:"flex-1 min-w-[120px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Time"}),a.jsx(V,{value:d.timeRange??0,onChange:e=>q("timeRange",0===e?void 0:e),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),a.jsxs("div",{className:"flex-1 min-w-[130px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),a.jsx(V,{value:d.signalMin??"",onChange:e=>q("signalMin",""===e?void 0:Number(e)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),a.jsxs("div",{className:"flex-1 min-w-[100px]",children:[a.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),a.jsx(V,{value:d.limit??500,onChange:e=>q("limit",e),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1000"},{value:2e3,label:"2000"}],placeholder:"Limit...","aria-label":"Packet limit"})]})]})})]}),a.jsx(H,{packets:T}),a.jsx(F,{noPadding:!0,className:"!overflow-visible",children:a.jsx(R,{packets:T,allPackets:s,localHash:r,neighbors:n,loading:A,showPagination:!0,perPage:50,emptyMessage:"No packets found"})})]})}export{z as default}; diff --git a/frontend/dist/assets/PageLayout-CcoYWyzO.js b/frontend/dist/assets/PageLayout-CnF5SScd.js similarity index 98% rename from frontend/dist/assets/PageLayout-CcoYWyzO.js rename to frontend/dist/assets/PageLayout-CnF5SScd.js index 3e9f2786..070b63e5 100644 --- a/frontend/dist/assets/PageLayout-CcoYWyzO.js +++ b/frontend/dist/assets/PageLayout-CnF5SScd.js @@ -1 +1 @@ -import{j as s}from"./vendor-react-C341c8YC.js";import{n as e}from"./recharts-6XUQYgRA.js";import"./index-CPdqYR4z.js";const a=[45,72,33,58,80,42,65,28,55,75,38,62];function l({className:a,style:l}){return s.jsx("div",{className:e("animate-pulse bg-white/[0.06] rounded",a),style:l})}function c(){return s.jsx("div",{className:"p-3 rounded-lg border border-border-subtle bg-bg-subtle",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(l,{className:"w-14 h-6 rounded shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[s.jsx(l,{className:"h-4 w-full"}),s.jsx(l,{className:"h-4 w-3/4"}),s.jsx(l,{className:"h-3 w-32 mt-1"})]})]})})}function r({count:e=8}){return s.jsx("div",{className:"space-y-2",children:Array.from({length:e}).map((e,a)=>s.jsx(c,{},a))})}function i(){return s.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]}),s.jsx(l,{className:"h-8 w-20"}),s.jsxs("div",{className:"flex-1 flex flex-col justify-end gap-2",children:[s.jsx(l,{className:"h-3 w-full"}),s.jsx(l,{className:"h-3 w-3/4"})]})]})}function n(){return s.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]}),s.jsx("div",{className:"flex-1 flex items-end gap-1",children:a.slice(0,8).map((e,a)=>s.jsx(l,{className:"flex-1",style:{height:`${e}%`}},a))})]})}function t({rows:e=5}){return s.jsxs("div",{className:"flex flex-col h-full","aria-hidden":"true",children:[s.jsx("div",{className:"pb-3 border-b border-border-subtle",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]})}),s.jsx("div",{className:"flex-1 pt-3 flex flex-col gap-3",children:Array.from({length:e}).map((e,a)=>s.jsx(l,{className:"h-6 w-full"},a))})]})}function d({children:a,className:l}){return s.jsx("div",{className:e("section-gap",l),children:a})}function x({title:e,icon:a,controls:l,subtitle:c}){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[s.jsxs("h1",{className:"type-title text-text-primary flex items-center gap-2 sm:gap-3 h-9 min-w-0",children:[a&&s.jsx("span",{className:"w-5 h-5 sm:w-6 sm:h-6 text-icon-page-title flex-shrink-0",children:a}),s.jsx("span",{className:"truncate",children:e})]}),l&&s.jsx("div",{className:"flex items-center gap-2 sm:gap-3 h-9 flex-shrink-0",children:l})]}),c&&s.jsx("div",{children:c})]})}const m={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:"card-auto"};function h({children:a,size:l,compact:c,noPadding:r,className:d,style:x,onClick:h,isLoaded:o=!0,skeletonType:f="card"}){return s.jsxs("div",{className:e("glass-card h-full flex flex-col relative",!r&&(c?"card-padding-sm":"card-padding"),l&&m[l],d),style:x,onClick:h,children:[a,!o&&(()=>{switch(f){case"chart":return s.jsx(n,{});case"list":return s.jsx(t,{});default:return s.jsx(i,{})}})()]})}export{i as C,r as L,d as P,l as S,h as a,x as b}; +import{j as s}from"./vendor-react-C341c8YC.js";import{n as e}from"./recharts-6XUQYgRA.js";import"./index-BJEgt3tp.js";const a=[45,72,33,58,80,42,65,28,55,75,38,62];function l({className:a,style:l}){return s.jsx("div",{className:e("animate-pulse bg-white/[0.06] rounded",a),style:l})}function c(){return s.jsx("div",{className:"p-3 rounded-lg border border-border-subtle bg-bg-subtle",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(l,{className:"w-14 h-6 rounded shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[s.jsx(l,{className:"h-4 w-full"}),s.jsx(l,{className:"h-4 w-3/4"}),s.jsx(l,{className:"h-3 w-32 mt-1"})]})]})})}function r({count:e=8}){return s.jsx("div",{className:"space-y-2",children:Array.from({length:e}).map((e,a)=>s.jsx(c,{},a))})}function i(){return s.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]}),s.jsx(l,{className:"h-8 w-20"}),s.jsxs("div",{className:"flex-1 flex flex-col justify-end gap-2",children:[s.jsx(l,{className:"h-3 w-full"}),s.jsx(l,{className:"h-3 w-3/4"})]})]})}function n(){return s.jsxs("div",{className:"flex flex-col gap-3 h-full","aria-hidden":"true",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]}),s.jsx("div",{className:"flex-1 flex items-end gap-1",children:a.slice(0,8).map((e,a)=>s.jsx(l,{className:"flex-1",style:{height:`${e}%`}},a))})]})}function t({rows:e=5}){return s.jsxs("div",{className:"flex flex-col h-full","aria-hidden":"true",children:[s.jsx("div",{className:"pb-3 border-b border-border-subtle",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l,{className:"w-5 h-5"}),s.jsx(l,{className:"h-4 w-24"})]})}),s.jsx("div",{className:"flex-1 pt-3 flex flex-col gap-3",children:Array.from({length:e}).map((e,a)=>s.jsx(l,{className:"h-6 w-full"},a))})]})}function d({children:a,className:l}){return s.jsx("div",{className:e("section-gap",l),children:a})}function x({title:e,icon:a,controls:l,subtitle:c}){return s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[s.jsxs("h1",{className:"type-title text-text-primary flex items-center gap-2 sm:gap-3 h-9 min-w-0",children:[a&&s.jsx("span",{className:"w-5 h-5 sm:w-6 sm:h-6 text-icon-page-title flex-shrink-0",children:a}),s.jsx("span",{className:"truncate",children:e})]}),l&&s.jsx("div",{className:"flex items-center gap-2 sm:gap-3 h-9 flex-shrink-0",children:l})]}),c&&s.jsx("div",{children:c})]})}const m={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:"card-auto"};function h({children:a,size:l,compact:c,noPadding:r,className:d,style:x,onClick:h,isLoaded:o=!0,skeletonType:f="card"}){return s.jsxs("div",{className:e("glass-card h-full flex flex-col relative",!r&&(c?"card-padding-sm":"card-padding"),l&&m[l],d),style:x,onClick:h,children:[a,!o&&(()=>{switch(f){case"chart":return s.jsx(n,{});case"list":return s.jsx(t,{});default:return s.jsx(i,{})}})()]})}export{i as C,r as L,d as P,l as S,h as a,x as b}; diff --git a/frontend/dist/assets/PathMapMapLibre-Ouls8uhs.js b/frontend/dist/assets/PathMapMapLibre-ChIFu4o3.js similarity index 99% rename from frontend/dist/assets/PathMapMapLibre-Ouls8uhs.js rename to frontend/dist/assets/PathMapMapLibre-ChIFu4o3.js index 2b85a5cd..84cace77 100644 --- a/frontend/dist/assets/PathMapMapLibre-Ouls8uhs.js +++ b/frontend/dist/assets/PathMapMapLibre-ChIFu4o3.js @@ -1 +1 @@ -import{r as e,j as t,bj as o,bk as r,bl as n,bm as a,bM as i,aD as s,m as l,bN as d,ab as c}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{n as u}from"./recharts-6XUQYgRA.js";import{u as m,B as p}from"./BasemapLayer-S9Ush6Hh.js";import{h,s as x,p as g}from"./useThemeColors-AeHMyThq.js";import{H as f,B as b}from"./index-CPdqYR4z.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const v={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},y={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=g(e);return o?`#${o.r.toString(16).padStart(2,"0")}${o.g.toString(16).padStart(2,"0")}${o.b.toString(16).padStart(2,"0")}`:t}function j(){if("undefined"==typeof document)return y;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:C(t.getPropertyValue("--map-node-stroke").trim(),y.nodeColor),localColor:C(t.getPropertyValue("--map-local-color").trim(),y.localColor),hubColor:C(t.getPropertyValue("--map-hub-color").trim(),y.hubColor),edgeColor:C(t.getPropertyValue("--map-edge-rest").trim(),y.edgeColor),ambiguousColor:C(t.getPropertyValue("--accent-secondary").trim(),y.ambiguousColor),highlightColor:C(t.getPropertyValue("--accent-primary").trim(),y.highlightColor),sourceColor:C(t.getPropertyValue("--accent-success").trim(),y.sourceColor),destinationColor:C(t.getPropertyValue("--accent-primary").trim(),y.destinationColor)}}function k({prefix:o,isLocal:r,isSource:n,isDestination:a,isLastHop:i,isHighlighted:m,isAnimating:p,isWardrive:h,candidate:x,onHover:g,onLeave:f,onClick:v}){const y=s(),[C,j]=e.useState(!1);e.useEffect(()=>{p&&y.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"}})},[p,y]);const k=e.useCallback(()=>{j(!0),g()},[g]),N=e.useCallback(()=>{j(!1),f()},[f]);return h?t.jsxs(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded-full",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:u("flex items-center justify-center","w-7 h-7 rounded-full","bg-orange-500 text-white","shadow-lg border-2 border-orange-300/50","transition-transform duration-150",C&&"scale-110"),children:t.jsx(d,{className:"w-4 h-4",strokeWidth:2.5})}),C&&t.jsxs(b,{color:"orange",filled:!0,className:"ml-1 text-[10px] font-mono shadow-lg",children:[o,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:t.jsxs(b,{color:h?"orange":r?"amber":n?"green":i?"amber":a?"purple":"blue",filled:!0,className:"font-mono text-[10px] shadow-lg border border-current/30",children:[r&&t.jsx(c,{className:"w-2.5 h-2.5 mr-1"}),o,C&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function N({hopNumber:e,snr:o,edgeColor:r}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:r||"#71717a",color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e}),void 0!==o&&t.jsx(b,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:o.toFixed(1)})]})}function S({resolvedPath:s,localNode:l,hubNodes:d=[],hoveredHopIndex:c,onHoverHop:g,traceSnr:b}){const y=void 0!==b&&b.length>0,C=e.useRef(null),S=m(),w=e.useMemo(()=>new Set(d),[d]),[F,L]=e.useState(null),D=f(),[E,M]=e.useState(!1),[P,H]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},n=()=>{H(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",n),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",n)}},[P]);const{positions:$,markers:V,edges:B}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let n=0,a=!1;return s.hops.forEach((i,s)=>{const l=i.candidates.filter(e=>{return t=e.latitude,o=e.longitude,0!==t||0!==o;var t,o});if(0===l.length)return;const d=[...l].sort((e,t)=>t.probability-e.probability)[0],c=[d.longitude,d.latitude];if(r.push(c),r.length>=2){const e=r[r.length-2],t=r.length-2,n=null==b?void 0:b[t],i=c[0]-e[0],s=c[1]-e[1],l=Math.atan2(i,s)*(180/Math.PI),d=j();let u;u=a?"#F97316":void 0!==n?h()[x(n)]||"#71717a":d.edgeColor,o.push({from:e,to:c,snrFwd:n,midpoint:[(e[0]+c[0])/2,(e[1]+c[1])/2],bearing:l,color:u,isFromWardrive:a})}const u=!0===i.isSource,m=!0===i.isDestination,p=!0===d.isWardrive;a=p,l.forEach((o,r)=>{const a=[o.latitude,o.longitude];e.push(a);const d=0===r;t.push({position:a,prefix:i.prefix,confidence:i.confidence,candidateCount:l.length,hopIndex:s,candidate:o,isHub:w.has(o.hash),isPrimary:d,isSource:u,isDestination:m,validIndex:n})}),n++}),{positions:e,markers:t,edges:o}},[s,w,b]),I=e.useMemo(()=>{const e=V.filter(e=>e.isPrimary&&(e.confidence>=.5||e.isSource||e.isDestination));if(0===e.length)return null;let t=1/0,o=-1/0,r=1/0,n=-1/0;for(const a of e){const[e,i]=a.position;eo&&(o=e),in&&(n=i)}return[[r,t],[n,o]]},[V]),W=e.useMemo(()=>{if(0===$.length)return l?[l.longitude,l.latitude]:[0,0];let e=0,t=0;for(const[o,r]of $)e+=o,t+=r;return[t/$.length,e/$.length]},[$,l]),A=e.useCallback(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();t&&I?(t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{M(!0)},50)):M(!0)},[I]),z=e.useMemo(()=>I?`${I[0][0].toFixed(5)},${I[0][1].toFixed(5)},${I[1][0].toFixed(5)},${I[1][1].toFixed(5)}`:"",[I]);e.useEffect(()=>{var e;if(!E)return;const t=null==(e=C.current)?void 0:e.getMap();t&&I&&t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[z,E,I]);const R=D&&E,O=e.useCallback(e=>{L({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return 0===$.length?t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm bg-bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[t.jsx("div",{className:u("absolute inset-0 bg-bg-elevated flex items-center justify-center","transition-opacity duration-200 ease-out pointer-events-none",R?"opacity-0":"opacity-100"),children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:R?1:0},children:t.jsxs(o,{ref:C,initialViewState:{longitude:W[0],latitude:W[1],zoom:10},onLoad:A,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(p,{mode:S}),B.map((e,o)=>{const a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]};return t.jsx(r,{id:`edge-${o}`,type:"geojson",data:a,children:t.jsx(n,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)}),B.map((e,o)=>t.jsx(a,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(N,{hopNumber:o+1,snr:y?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=V.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const n=c===e.hopIndex,i=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(a,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(k,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:i,isHighlighted:n,isAnimating:!1,isWardrive:e.candidate.isWardrive||!1,candidate:e.candidate,onHover:()=>null==g?void 0:g(e.hopIndex),onLeave:()=>null==g?void 0:g(null),onClick:()=>O(e)})},`${e.hopIndex}-${e.candidate.hash}`)})})(),F&&t.jsx(i,{longitude:F.longitude,latitude:F.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>L(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:F.marker.candidate.name}),(()=>{const e=j();return t.jsxs(t.Fragment,{children:[F.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),F.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),F.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),F.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),F.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-text-muted font-mono text-[10px]",children:[F.marker.prefix," • ",F.marker.candidate.hash.slice(0,10),"..."]}),!F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{style:{color:j().ambiguousColor},children:["Alternative (",(100*F.marker.candidate.probability).toFixed(0),"%)"]}),F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{className:"text-text-muted",children:[F.marker.candidateCount," candidates"]})]})})]},P)})]})}export{S as default}; +import{r as e,j as t,bj as o,bk as r,bl as n,bm as a,bM as i,aD as s,m as l,bN as d,ab as c}from"./vendor-react-C341c8YC.js";import"./maplibre-gl-Bk5DsYkB.js";import{n as u}from"./recharts-6XUQYgRA.js";import{u as m,B as p}from"./BasemapLayer-S9Ush6Hh.js";import{h,s as x,p as g}from"./useThemeColors-AeHMyThq.js";import{H as f,B as b}from"./index-BJEgt3tp.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const v={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},y={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(e,t){if(!e)return t;if(e.startsWith("#"))return e;const o=g(e);return o?`#${o.r.toString(16).padStart(2,"0")}${o.g.toString(16).padStart(2,"0")}${o.b.toString(16).padStart(2,"0")}`:t}function j(){if("undefined"==typeof document)return y;const e=document.documentElement,t=getComputedStyle(e);return{nodeColor:C(t.getPropertyValue("--map-node-stroke").trim(),y.nodeColor),localColor:C(t.getPropertyValue("--map-local-color").trim(),y.localColor),hubColor:C(t.getPropertyValue("--map-hub-color").trim(),y.hubColor),edgeColor:C(t.getPropertyValue("--map-edge-rest").trim(),y.edgeColor),ambiguousColor:C(t.getPropertyValue("--accent-secondary").trim(),y.ambiguousColor),highlightColor:C(t.getPropertyValue("--accent-primary").trim(),y.highlightColor),sourceColor:C(t.getPropertyValue("--accent-success").trim(),y.sourceColor),destinationColor:C(t.getPropertyValue("--accent-primary").trim(),y.destinationColor)}}function k({prefix:o,isLocal:r,isSource:n,isDestination:a,isLastHop:i,isHighlighted:m,isAnimating:p,isWardrive:h,candidate:x,onHover:g,onLeave:f,onClick:v}){const y=s(),[C,j]=e.useState(!1);e.useEffect(()=>{p&&y.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"}})},[p,y]);const k=e.useCallback(()=>{j(!0),g()},[g]),N=e.useCallback(()=>{j(!1),f()},[f]);return h?t.jsxs(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded-full",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(249, 115, 22, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:u("flex items-center justify-center","w-7 h-7 rounded-full","bg-orange-500 text-white","shadow-lg border-2 border-orange-300/50","transition-transform duration-150",C&&"scale-110"),children:t.jsx(d,{className:"w-4 h-4",strokeWidth:2.5})}),C&&t.jsxs(b,{color:"orange",filled:!0,className:"ml-1 text-[10px] font-mono shadow-lg",children:[o,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx(l.div,{className:u("flex items-center cursor-pointer","transition-all duration-150",m&&"ring-2 ring-accent-primary/50 rounded",C&&"relative z-50"),animate:y,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},onMouseEnter:k,onMouseLeave:N,onClick:v,style:{pointerEvents:"auto"},children:t.jsxs(b,{color:h?"orange":r?"amber":n?"green":i?"amber":a?"purple":"blue",filled:!0,className:"font-mono text-[10px] shadow-lg border border-current/30",children:[r&&t.jsx(c,{className:"w-2.5 h-2.5 mr-1"}),o,C&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function N({hopNumber:e,snr:o,edgeColor:r}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:r||"#71717a",color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e}),void 0!==o&&t.jsx(b,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:o.toFixed(1)})]})}function S({resolvedPath:s,localNode:l,hubNodes:d=[],hoveredHopIndex:c,onHoverHop:g,traceSnr:b}){const y=void 0!==b&&b.length>0,C=e.useRef(null),S=m(),w=e.useMemo(()=>new Set(d),[d]),[F,L]=e.useState(null),D=f(),[E,M]=e.useState(!1),[P,H]=e.useState(0);e.useEffect(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();if(!t)return;const o=t.getCanvas();if(!o)return;const r=e=>{e.preventDefault()},n=()=>{H(e=>e+1)};return o.addEventListener("webglcontextlost",r),o.addEventListener("webglcontextrestored",n),()=>{o.removeEventListener("webglcontextlost",r),o.removeEventListener("webglcontextrestored",n)}},[P]);const{positions:$,markers:V,edges:B}=e.useMemo(()=>{const e=[],t=[],o=[],r=[];let n=0,a=!1;return s.hops.forEach((i,s)=>{const l=i.candidates.filter(e=>{return t=e.latitude,o=e.longitude,0!==t||0!==o;var t,o});if(0===l.length)return;const d=[...l].sort((e,t)=>t.probability-e.probability)[0],c=[d.longitude,d.latitude];if(r.push(c),r.length>=2){const e=r[r.length-2],t=r.length-2,n=null==b?void 0:b[t],i=c[0]-e[0],s=c[1]-e[1],l=Math.atan2(i,s)*(180/Math.PI),d=j();let u;u=a?"#F97316":void 0!==n?h()[x(n)]||"#71717a":d.edgeColor,o.push({from:e,to:c,snrFwd:n,midpoint:[(e[0]+c[0])/2,(e[1]+c[1])/2],bearing:l,color:u,isFromWardrive:a})}const u=!0===i.isSource,m=!0===i.isDestination,p=!0===d.isWardrive;a=p,l.forEach((o,r)=>{const a=[o.latitude,o.longitude];e.push(a);const d=0===r;t.push({position:a,prefix:i.prefix,confidence:i.confidence,candidateCount:l.length,hopIndex:s,candidate:o,isHub:w.has(o.hash),isPrimary:d,isSource:u,isDestination:m,validIndex:n})}),n++}),{positions:e,markers:t,edges:o}},[s,w,b]),I=e.useMemo(()=>{const e=V.filter(e=>e.isPrimary&&(e.confidence>=.5||e.isSource||e.isDestination));if(0===e.length)return null;let t=1/0,o=-1/0,r=1/0,n=-1/0;for(const a of e){const[e,i]=a.position;eo&&(o=e),in&&(n=i)}return[[r,t],[n,o]]},[V]),W=e.useMemo(()=>{if(0===$.length)return l?[l.longitude,l.latitude]:[0,0];let e=0,t=0;for(const[o,r]of $)e+=o,t+=r;return[t/$.length,e/$.length]},[$,l]),A=e.useCallback(()=>{var e;const t=null==(e=C.current)?void 0:e.getMap();t&&I?(t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{M(!0)},50)):M(!0)},[I]),z=e.useMemo(()=>I?`${I[0][0].toFixed(5)},${I[0][1].toFixed(5)},${I[1][0].toFixed(5)},${I[1][1].toFixed(5)}`:"",[I]);e.useEffect(()=>{var e;if(!E)return;const t=null==(e=C.current)?void 0:e.getMap();t&&I&&t.fitBounds(I,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[z,E,I]);const R=D&&E,O=e.useCallback(e=>{L({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return 0===$.length?t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm bg-bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[t.jsx("div",{className:u("absolute inset-0 bg-bg-elevated flex items-center justify-center","transition-opacity duration-200 ease-out pointer-events-none",R?"opacity-0":"opacity-100"),children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:R?1:0},children:t.jsxs(o,{ref:C,initialViewState:{longitude:W[0],latitude:W[1],zoom:10},onLoad:A,style:{height:"100%",width:"100%"},mapStyle:v,attributionControl:!1,children:[t.jsx(p,{mode:S}),B.map((e,o)=>{const a={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]};return t.jsx(r,{id:`edge-${o}`,type:"geojson",data:a,children:t.jsx(n,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)}),B.map((e,o)=>t.jsx(a,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(N,{hopNumber:o+1,snr:y?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=V.filter(e=>e.isPrimary),o=e.length>1?e.length-2:-1;return e.map((e,r)=>{const n=c===e.hopIndex,i=r===o&&!e.candidate.isLocal&&!e.isDestination;return t.jsx(a,{longitude:e.position[1],latitude:e.position[0],anchor:"center",children:t.jsx(k,{prefix:e.prefix,isLocal:e.candidate.isLocal||!1,isSource:e.isSource,isDestination:e.isDestination,isLastHop:i,isHighlighted:n,isAnimating:!1,isWardrive:e.candidate.isWardrive||!1,candidate:e.candidate,onHover:()=>null==g?void 0:g(e.hopIndex),onLeave:()=>null==g?void 0:g(null),onClick:()=>O(e)})},`${e.hopIndex}-${e.candidate.hash}`)})})(),F&&t.jsx(i,{longitude:F.longitude,latitude:F.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>L(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:F.marker.candidate.name}),(()=>{const e=j();return t.jsxs(t.Fragment,{children:[F.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),F.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),F.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),F.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),F.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-text-muted font-mono text-[10px]",children:[F.marker.prefix," • ",F.marker.candidate.hash.slice(0,10),"..."]}),!F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{style:{color:j().ambiguousColor},children:["Alternative (",(100*F.marker.candidate.probability).toFixed(0),"%)"]}),F.marker.isPrimary&&F.marker.candidateCount>1&&t.jsxs("div",{className:"text-text-muted",children:[F.marker.candidateCount," candidates"]})]})})]},P)})]})}export{S as default}; diff --git a/frontend/dist/assets/Statistics-DqgywSJF.js b/frontend/dist/assets/Statistics-sXHAGtEF.js similarity index 99% rename from frontend/dist/assets/Statistics-DqgywSJF.js rename to frontend/dist/assets/Statistics-sXHAGtEF.js index 8378e71d..40930941 100644 --- a/frontend/dist/assets/Statistics-DqgywSJF.js +++ b/frontend/dist/assets/Statistics-sXHAGtEF.js @@ -1 +1 @@ -var e,t,s=Object.defineProperty,a=(e,t,a)=>((e,t,a)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);import{r as n,j as r,au as l,D as i,b2 as o,a3 as c,b3 as C,b4 as A,b5 as D,b6 as B,b7 as F,b8 as E,b9 as m,ba as d,bb as u,bc as h,bd as x,av as p,be as g,bf as f,at as b,ay as y,bg as v,bh as j,bi as N,aJ as w,W as k,q as M,o as S,aX as T,E as R}from"./vendor-react-C341c8YC.js";import{a7 as $,a8 as P,a9 as L,W as z,aa as _,ab as H,ac as O,ad as W,x as I,F as V,ae as q,af as G,ag as X,Y as K,ah as Y,e as U,h as Q,f as Z,u as J,p as ee,r as te,j as se,q as ae,ai as ne,k as re,aj as le}from"./index-CPdqYR4z.js";import{u as ie}from"./usePolling-CtRLadGa.js";import{b as oe,c as ce,a as Ce,d as Ae,e as De,f as Be,s as Fe}from"./useThemeColors-AeHMyThq.js";import{R as Ee,w as me,L as de,C as ue,X as he,Y as xe,T as pe,u as ge}from"./recharts-6XUQYgRA.js";import{T as fe}from"./TimeRangeSelector-DGCfekAv.js";import{a as be,P as ye,b as ve}from"./PageLayout-CcoYWyzO.js";import{D as je}from"./DataBox-CRX76VsB.js";import{C as Ne}from"./CollisionExplorerModal-Vkgg9Koo.js";import{C as we,a as ke}from"./Card-BeZKc0xw.js";import{R as Me,C as Se}from"./Grid-BOO-7ObJ.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./maplibre-gl-Bk5DsYkB.js";import"./BasemapLayer-S9Ush6Hh.js";const Te={acton:{discrete:["#260D40","#2B1345","#2F194B","#342152","#382657","#3C2C5C","#403261","#443766","#483E6C","#4C4371","#504876","#544D7B","#57527F","#5D5884","#625C88","#685F8A","#6E618C","#74628D","#7B638D","#81638E","#88648E","#8E648E","#95658F","#9D658F","#A4668F","#AB6690","#B26790","#BB6992","#C26B94","#C86F97","#CD749B","#D07AA0","#D382A7","#D688AC","#D88FB2","#D995B8","#DB9CBD","#DEA4C4","#DFABC9","#E1B1CE","#E3B7D3","#E5BED8","#E6C5DE","#E8CBE2","#E9D0E6","#EBD6EA","#ECDBEE","#EDE1F3","#EFE6F6","#F0EAFA"],categorical:["#260D40","#F0EAFA","#A76690","#DDA1C2","#585380","#7D638E","#E8CAE1","#CF789E","#403261","#4C4371","#ECDBEE","#69608B","#E3B6D2","#D78CB0","#91648F","#BE6A92","#342152","#EAD3E8","#524B79","#73628D","#463A69","#605B86","#E5C0DA","#D382A7","#C86F97","#86648E","#EEE3F4","#DA97B9","#9B658F","#B26790","#2D1749","#E0ACCA","#3A2959","#8B648E","#311C4D","#EBD7EB","#EDDFF1","#AC6790","#A1668F","#6E618C","#E6C5DE","#78628D","#433665","#DEA7C6","#81638E","#554F7C","#B86891","#3D2D5D","#4F4775","#EFE7F7","#E9CEE4","#D27DA3","#2A1244","#655D89","#C36C94","#E1B1CE","#493F6D","#5C5783","#CC739A","#DB9CBD","#D892B4","#D587AB","#96658F","#E4BBD6","#362455","#4E4573","#7F638E","#D37FA5","#E1AECC","#382657","#EBD9ED","#DFA9C8","#A4668F","#8E648E","#99658F","#675F8A","#B56891","#BB6992","#E5BED8","#E2B4D0","#D07AA0","#71618C","#E6C2DC","#AA6690","#625C88","#EDE1F3","#E8CCE3","#AF6790","#CA7199","#C16B93","#453867","#57517E","#84638E","#4B416F","#E7C7DF","#423463","#514977","#3E2F5F","#544D7B","#93658F"]},bam:{discrete:["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"],categorical:["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"]},bamako:{discrete:["#003B47","#023C46","#053E45","#083F43","#0A4141","#0D4340","#0F443E","#12463C","#16483A","#194A38","#1C4D36","#204F34","#235132","#28542F","#2C572C","#305A2A","#355C27","#395F24","#3F6321","#44661E","#49691A","#4E6D17","#537014","#5A7410","#5F780D","#657C09","#6A7F05","#718302","#788501","#7F8700","#858800","#8C8A00","#948C01","#9B8E04","#A1920B","#A89713","#AE9C1B","#B7A225","#BEA82E","#C5AD37","#CBB341","#D2B84D","#D9BF5B","#DEC567","#E4CA73","#E9D07E","#EFD58A","#F5DB97","#FAE0A3","#FFE5AD"],categorical:["#003B47","#FFE5AD","#61790B","#B4A022","#245231","#406420","#898900","#DDC464","#0F443E","#EFD58A","#CAB23F","#194A38","#748401","#506E16","#9E9108","#315A29","#083F43","#A99815","#948C01","#6A7F05","#BFA930","#7F8700","#14473B","#1E4E35","#F7DD9C","#2A562D","#043D45","#597411","#E6CC77","#385F25","#48691B","#D4BB51","#0B4241","#8F8A00","#44661E","#1B4C37","#547113","#6F8203","#12463D","#998E03","#27542F","#4C6B18","#A4940E","#2E582B","#355C27","#B9A529","#215033","#EAD181","#FBE1A5","#C5AD37","#3C6122","#848800","#063E44","#E2C86E","#D9BF5B","#CFB648","#16493A","#798600","#023C46","#667C08","#5D770E","#0D433F","#AE9C1B","#F3D993","#094042","#A69611","#8C8A00","#053E45","#0C4240","#365E26","#6D8004","#9C8F05","#4A6A1A","#D6BD56","#B19E1F","#F9DFA0","#647B0A","#2F592A","#10453D","#818800","#C7AF3B","#46681C","#0E443F","#265330","#174A39","#335B28","#5B750F","#778501","#5F780D","#E8CF7C","#718302","#F1D78E","#978D02","#F5DB97","#204F34","#AC9A18","#29552E","#A1920B","#B7A225","#033C46"]},bamo:{discrete:["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"],categorical:["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"]},batlow:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144D62","#165162","#195662","#1C5A62","#205E61","#26635F","#2C665D","#33695A","#3A6C57","#416F53","#4A724E","#52744A","#5A7745","#627941","#6A7B3D","#747E38","#7D8134","#868330","#8F862D","#9B892B","#A58B2C","#AF8D2E","#B98F32","#C29037","#CD923F","#D69446","#DE964F","#E69858","#ED9A62","#F39E70","#F8A17B","#FAA587","#FCA993","#FDAC9E","#FDB1AB","#FDB4B6","#FDB8C0","#FDBCCB","#FCBFD6","#FCC4E3","#FBC8EF","#FACCFA"],categorical:["#011959","#FACCFA","#828231","#226061","#F29D6D","#4D734D","#114360","#C09036","#FDB4B4","#DD954D","#356A59","#FCBFD6","#175262","#677B3E","#A18A2B","#0D315D","#FCA890","#FBC6E8","#2B655E","#B18D2F","#5A7745","#FDAEA2","#CF9340","#0F3B5F","#E9995C","#FDBAC4","#416F53","#91862D","#1B5962","#08255B","#747E38","#134B61","#F9A380","#8A842F","#0E365E","#124761","#154F62","#E39754","#7B8034","#1E5D62","#99882C","#195662","#0B2B5C","#FDB7BC","#C8913B","#FCC3DF","#EE9B64","#A98C2C","#FDB1AB","#FDBCCD","#FBC9F1","#051F5A","#F6A077","#607942","#FDAB9A","#477150","#3B6D56","#B98F32","#26635F","#537549","#D69446","#6D7C3B","#30685C","#103F60","#FBA689","#BD8F34","#CB923E","#EB9A60","#FDB8C0","#FBC7EC","#F09C69","#8E852E","#FDBBC9","#7F8133","#031C5A","#114160","#FDAC9E","#5D7844","#FCA995","#185462","#787F36","#A58B2C","#0A285C","#9D892B","#33695A","#0D335E","#637A40","#165062","#124561","#205E61","#144D62","#1D5B62","#0C2E5D","#D9954A","#3E6E55","#AD8C2D","#F49F72","#868330","#B58E30","#577647"]},batlowk:{discrete:["#04050A","#0A0D15","#0F141E","#121B29","#152233","#18293D","#1C3146","#21384F","#274156","#2C485B","#314E5E","#36535F","#3B575F","#405C5E","#445F5D","#49625B","#4D6558","#526756","#586B52","#5E6E4F","#63724B","#6A7548","#717845","#797D41","#81813E","#8A853B","#938839","#9F8D38","#A99139","#B3943B","#BE973E","#C89A43","#D39D4C","#DB9F54","#E2A15D","#E8A366","#EEA570","#F3A77C","#F6A986","#F8AC91","#FAAE9A","#FCB1A4","#FDB4B0","#FDB7B9","#FDBAC3","#FDBDCD","#FDC1D8","#FCC5E4","#FBC8EF","#FACCFA"],categorical:["#04050A","#FDC0D6","#787C41","#38555F","#E5A160","#536855","#AF933A","#FAAE9A","#1A2E43","#FDB6B7","#294458","#455F5C","#63724B","#CD9B47","#91883A","#F3A77E","#111A27","#F7AB8D","#FDBBC5","#FCB2AA","#D99E52","#A18E38","#4C6459","#21384F","#3F5B5E","#152335","#0C1019","#EEA570","#5B6D50","#6C7647","#314E5E","#85823D","#BE973E","#7E7F3F","#FBB0A2","#49625B","#576A53","#0F151F","#2D495B","#DFA059","#727944","#FDBDCD","#253E54","#EAA368","#C69942","#3C585F","#998B38","#677449","#F1A678","#F9AC92","#141F2F","#1D3248","#506657","#090C13","#A99139","#5F6F4E","#35525F","#435D5D","#FDB8BD","#F5A984","#B5953B","#FDB5B2","#17273B","#D39D4C","#8C853B","#9D8C38","#415C5E","#1F354B","#33505E","#FCB1A6","#101723","#3E595F","#121C2B","#757B43","#06080F","#FCB3AE","#3A565F","#274156","#61704D","#88843C","#2B475A","#FDBED1","#6A7548","#596C51","#192B3F","#6F7845","#233B51","#C99A45","#F0A574","#DC9F55","#2F4B5D","#47615C","#F6AA88","#FDB9C1","#C29840","#4A635A","#FAAD96","#81813E","#7B7E40","#E7A264"]},batloww:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144C62","#165062","#185562","#1B5962","#1F5D62","#246261","#2A665F","#30695D","#366C5A","#3D7056","#467352","#4E764E","#56794A","#5E7C46","#667F42","#70823D","#798539","#828936","#8C8C33","#989032","#A29433","#AD9738","#B79B3F","#C19E48","#CBA154","#D3A45E","#D9A669","#DFA872","#E4AA7C","#E9AC88","#EEAF91","#F2B39C","#F6B9A8","#F9C0B5","#FCCAC4","#FED3CF","#FFDBDA","#FFE3E2","#FFEAEA","#FFF2F2","#FFF8F8","#FFFEFE"],categorical:["#FFFEFE","#011959","#7E8737","#205F61","#E7AB84","#497451","#114360","#FED1CD","#BF9D46","#637E44","#9E9233","#FFEAEA","#0D315D","#326B5C","#F5B7A6","#165162","#D7A564","#0F3B5F","#1A5862","#3D7056","#FFF5F5","#FFDFDD","#FAC3BA","#134A61","#08255B","#70823D","#EEB094","#56794A","#E0A874","#8E8D33","#28655F","#AF9839","#CBA154","#EBAD8B","#1D5C62","#051F5A","#124761","#FFE5E4","#B79B3F","#A79535","#386D59","#5C7B47","#185562","#DBA76D","#F8BDAF","#FFF0F0","#246261","#F2B39C","#868A35","#4F774D","#E4AA7C","#2D685E","#77853A","#FED8D6","#103F60","#FFFAF9","#968F32","#D1A35C","#144E62","#FCCAC4","#437254","#698040","#0E365E","#0B2B5C","#C59F4C","#30695D","#1C5A62","#A29433","#407155","#FFDBDA","#0C2E5D","#F7BAAA","#E5AB80","#175362","#828936","#1F5D62","#BB9C42","#E9AC88","#FFF7F7","#3A6E58","#9A9132","#8A8B34","#4C754F","#FFEDED","#D9A669","#144C62","#266460","#FDCDC9","#FCC6BF","#FFE2E1","#FFFCFC","#7B8639","#2B675E","#155062","#5F7C45","#F9C0B5","#356C5A","#F3B5A1","#EDAF8F","#FED5D2"]},berlin:{discrete:["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"],categorical:["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"]},bilbao:{discrete:["#4C0001","#54070B","#5B0E13","#64161A","#6B1D20","#712227","#77282D","#7D2E34","#84343B","#8A3A41","#8F4047","#94464B","#984C4F","#9B5253","#9D5754","#9E5C56","#A06057","#A16458","#A26959","#A36D5A","#A4715B","#A5745B","#A6785C","#A77C5D","#A8805E","#A9845F","#AA875F","#AC8C60","#AD9061","#AE9463","#AF9864","#B19D68","#B3A36E","#B6A975","#B8AD7E","#BBB287","#BDB590","#C0B99A","#C2BCA3","#C4BFAA","#C6C2B2","#C8C5B9","#CBCAC1","#CFCEC9","#D5D4D1","#DBDBDA","#E3E3E2","#EDEDED","#F6F6F6","#FFFFFF"],categorical:["#4C0001","#F8F8F8","#A9815E","#984D50","#BEB794","#AF9965","#CCCAC3","#78292F","#A26A59","#9F5D56","#64161A","#B6AA77","#C4C0AC","#A6765C","#8A3A41","#AC8C60","#DDDDDB","#A16358","#C7C5B7","#B3A16B","#A4705A","#6E2024","#EAEAE9","#92434A","#BAB185","#9C5554","#AD9262","#580B10","#813137","#C1BCA1","#AA865F","#D2D2CE","#A77C5D","#D7D7D4","#BCB48D","#B4A571","#C0B99A","#9E5955","#AB8960","#A6795C","#A36D5A","#8E3F46","#85353C","#A16758","#732529","#CAC7BD","#F1F1F0","#520509","#AC8F61","#5E1115","#C6C2B2","#E3E3E2","#691B1F","#B8AD7E","#95484D","#AE9663","#B19D68","#A5735B","#A06057","#9A5152","#A87E5D","#7D2E34","#A9835E","#C3BEA6","#CFCEC9","#A46E5A","#F4F4F4","#DADAD8","#B29F69","#EDEDED","#BBB289","#9D5754","#AF9764","#904148","#994F51","#B3A36E","#A87F5E","#A26859","#AC8D61","#BDB590","#AA875F","#A77A5D","#AB8A60","#A4715B","#611418","#BFB897","#E6E6E6","#9B5353","#D5D4D1","#974A4F","#C8C6BA","#A16558","#9F5E56","#76272C","#67191D","#8C3C43","#B9AF82","#C3BFA9","#B5A874","#4F0205"]},broc:{discrete:["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"],categorical:["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"]},broco:{discrete:["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"],categorical:["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"]},buda:{discrete:["#B301B3","#B30BAE","#B314AA","#B31CA6","#B323A2","#B3289F","#B32E9D","#B4339A","#B53998","#B63E96","#B84394","#B94892","#BB4C91","#BD528F","#BE568D","#C05B8C","#C15F8A","#C36389","#C46987","#C66D86","#C77184","#C97583","#CA7982","#CB7E80","#CD837F","#CE877E","#CF8B7D","#D0917B","#D1957A","#D29979","#D49E78","#D5A277","#D6A776","#D7AC75","#D8B073","#D9B572","#DAB971","#DCBF70","#DDC36F","#DEC86E","#DFCC6C","#E0D16B","#E2D76A","#E4DC69","#E6E168","#E9E667","#EDEC67","#F3F366","#F9F966","#FFFF66"],categorical:["#B301B3","#FFFF66","#CD857E","#BC4E90","#DBBD70","#C56A87","#B32F9C","#E3DB69","#D4A177","#EDEC67","#D1937B","#B73F95","#C05C8B","#DFCB6D","#C97882","#B31CA6","#D8AE74","#E7E368","#DAB572","#B311AC","#D39A79","#C36389","#C77184","#B53798","#E1D36B","#BE558E","#B94793","#CB7E80","#CF8C7C","#DDC46E","#B326A0","#F6F566","#D6A875","#DAB971","#C66E86","#E2D76A","#B32B9E","#B317A9","#B4339A","#BA4B91","#C46788","#C2608A","#B309AF","#D49E78","#B63B97","#BD528F","#DCC06F","#EAE767","#FAFA66","#D2977A","#F1F066","#D0907C","#CE897D","#C87483","#CC827F","#D5A576","#B321A3","#E5DF68","#B84394","#D9B273","#E0CF6C","#CA7B81","#DEC86E","#BF598C","#D7AB75","#E6E168","#D1957A","#CC8080","#D39C78","#E0CD6C","#CD847F","#B63D96","#C87384","#C66C86","#F8F866","#D49F78","#D9B473","#DAB772","#BF578D","#CB7D81","#CF8A7D","#B32D9D","#D08E7C","#DBBB71","#C2628A","#E2D56A","#DCBF70","#BC508F","#C46987","#C05B8C","#DFCA6D","#DDC26F","#C15E8B","#D7AD74","#F3F366","#DEC66E","#D5A377","#B31AA7","#BA4992","#CE877E"]},bukavu:{discrete:["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"],categorical:["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"]},cork:{discrete:["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"],categorical:["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"]},corko:{discrete:["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"],categorical:["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"]},davos:{discrete:["#00054A","#010E51","#041459","#081C61","#0C2368","#102A6F","#133075","#17377C","#1C3F83","#204588","#244C8D","#295291","#2D5895","#335F98","#38649A","#3C699C","#416E9D","#46729D","#4C779D","#517B9C","#567F9B","#5A829A","#5F8598","#658996","#698C94","#6E8F92","#739290","#78968D","#7D998C","#829D8A","#88A089","#8DA488","#95AA87","#9BAF88","#A3B489","#ABBB8C","#B4C190","#BFCA96","#C9D29E","#D2D9A6","#DBE0AF","#E3E7B8","#EBEDC4","#F0F1CD","#F4F4D6","#F7F7DE","#FAF9E6","#FCFCF0","#FDFDF7","#FEFEFE"],categorical:["#00054A","#FDFDF4","#688B94","#2D5895","#B2C08F","#E8EBC0","#87A089","#133075","#4B769D","#5A829A","#204588","#76958E","#D0D8A4","#99AD88","#F6F6DB","#3C699C","#081C61","#031256","#1A3B7F","#537C9C","#A4B68A","#C1CC98","#7E9A8B","#FAFAE8","#356199","#0E266B","#DEE3B3","#274F90","#6F9091","#618697","#8FA588","#F0F1CD","#43709D","#1D4084","#47739D","#F3F4D4","#658996","#567F9B","#17367A","#FCFBEE","#4F799D","#C9D29E","#93A987","#39659B","#D8DEAB","#ABBB8C","#739290","#B9C693","#F8F8E1","#234A8C","#112B70","#7A978D","#9EB188","#315C97","#829D8A","#05175B","#010C50","#3F6C9D","#0B2065","#5D8499","#2A5392","#8BA388","#6B8D93","#EDEFC7","#E3E7B8","#22488A","#638897","#122E73","#00094D","#AEBD8D","#4D789D","#CDD5A1","#5F8598","#58819A","#071A5E","#0C2368","#18387D","#91A787","#37639A","#EBEDC4","#F2F2D0","#FBFBEB","#74938F","#2F5A96","#335F98","#809B8B","#BDC995","#49759D","#719191","#9BAF88","#F7F7DE","#1B3E82","#A8B88B","#849E89","#557E9B","#E6E9BC","#45719D","#1E4386","#96AB87","#89A188"]},devon:{discrete:["#2C1A4C","#2B1E51","#2B2356","#2A295B","#2A2D60","#293265","#29376A","#283B6E","#274174","#27467A","#274C7F","#275186","#28568C","#2A5C95","#2D609C","#3064A3","#3468AA","#396BB1","#3F70B9","#4774C0","#4F79C6","#597DCC","#6382D1","#6F88D7","#798CDB","#8290DF","#8C95E2","#969AE6","#9E9EE9","#A6A3EB","#ACA7ED","#B1ACEF","#B7B1F0","#BBB5F1","#BFB9F2","#C3BEF3","#C7C2F4","#CCC7F4","#D0CCF5","#D4D0F6","#D8D4F7","#DCD9F8","#E1DEF9","#E5E3FA","#E9E7FB","#EDECFB","#F2F0FC","#F7F6FD","#FBFAFE","#FFFFFF"],categorical:["#2C1A4C","#F8F8FE","#758AD9","#C6C0F3","#28568C","#29376A","#AAA5ED","#DEDCF8","#3D6EB7","#EBE9FB","#9197E4","#3063A2","#274579","#577CCB","#D2CEF6","#2A285A","#BAB3F1","#B2ADEF","#F2F0FC","#274E82","#2A2F62","#CCC7F4","#9E9EE9","#4875C1","#C0BAF2","#2B5D98","#3669AD","#2B2154","#E4E2FA","#8290DF","#D8D4F7","#6784D3","#283E71","#C9C4F4","#BDB7F1","#DBD8F8","#283A6D","#4F79C6","#A4A2EB","#EEEDFC","#CFCBF5","#E8E5FA","#5F80CF","#4272BC","#B6B0F0","#2B1D50","#AEA9EE","#275287","#2A2B5E","#989BE7","#293366","#27497D","#8A94E1","#295A92","#3266A7","#F5F4FD","#7B8DDC","#274174","#2D609C","#2B2558","#6F88D7","#E1DEF9","#3A6CB2","#D5D1F6","#C3BEF3","#2E629F","#3165A4","#8D95E3","#3468AA","#DAD6F7","#D1CDF5","#9B9CE8","#275084","#B8B2F0","#27477B","#6382D1","#4573BF","#A2A0EA","#F7F6FD","#C7C2F4","#F3F2FD","#274376","#8692E0","#2B1F52","#CAC6F4","#ACA7ED","#E3E0F9","#F0EEFC","#E6E4FA","#386AB0","#2C1C4E","#6B86D5","#28396B","#283C6F","#2A5C95","#2A2D60","#BEB9F2","#C2BCF2","#7E8FDD","#3F70B9"]},fes:{discrete:["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"],categorical:["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"]},glasgow:{discrete:["#361338","#3B1434","#401530","#45172C","#491828","#4D1924","#511B21","#561C1D","#5B1E18","#602014","#662210","#6B260B","#6F2B07","#723203","#743802","#743E01","#754300","#744900","#744F01","#745402","#735905","#725F0B","#716413","#70691E","#6E6E27","#6C7231","#6B763A","#697B46","#677F4F","#658359","#648763","#628B6C","#618F78","#609381","#60978A","#619B94","#659F9D","#6CA5A8","#74A9B0","#7DADB8","#86B1BF","#8EB4C6","#99B9CE","#A1BCD5","#AABFDB","#B2C3E1","#BBC6E7","#C6CBF0","#D0CFF7","#DBD3FF"],categorical:["#361338","#DBD3FF","#6D702B","#69A3A5","#702D06","#A0BBD3","#638968","#521B20","#745101","#84B0BE","#754001","#5F9587","#BBC6E7","#612013","#45172C","#687D4A","#726210","#618F78","#4B1926","#3E1532","#629C96","#658359","#CACCF3","#76AAB2","#6B763A","#744900","#6A250C","#ADC1DD","#735905","#92B6C9","#591D1A","#743702","#70681C","#4F1A23","#754400","#6D2909","#60998E","#41162F","#744D00","#745503","#B4C3E2","#697A42","#7DADB8","#628C70","#8BB3C3","#561C1D","#D2D0F9","#99B9CE","#3A1435","#6F6C23","#743B01","#60927F","#662210","#648661","#659F9D","#678051","#725E0A","#481829","#6FA6AB","#6C7332","#5D1E17","#A6BED8","#C2C9ED","#723203","#716617","#68240E","#6F6A20","#C6CBF0","#79ABB5","#72600D","#754200","#43162D","#67A1A1","#6B7536","#5F1F15","#735B07","#571C1B","#72A8AF","#744F01","#BEC8EA","#381337","#8EB4C6","#628B6C","#677E4D","#60917B","#639E9A","#4A1827","#A3BDD6","#3C1433","#743901","#632112","#B7C5E5","#4D1924","#65845D","#618E74","#609483","#9CBAD1","#46172A","#87B1C1","#6D712F"]},grayc:{discrete:["#000000","#090909","#111111","#171717","#1C1C1C","#212121","#252525","#2A2A2A","#303030","#343434","#393939","#3D3D3D","#424242","#474747","#4B4B4B","#505050","#545454","#585858","#5D5D5D","#616161","#656565","#696969","#6D6D6D","#717171","#757575","#797979","#7D7D7D","#818181","#858585","#898989","#8E8E8E","#929292","#979797","#9C9C9C","#A1A1A1","#A6A6A6","#ABABAB","#B1B1B1","#B6B6B6","#BCBCBC","#C1C1C1","#C7C7C7","#CECECE","#D5D5D5","#DBDBDB","#E2E2E2","#E8E8E8","#F1F1F1","#F8F8F8","#FFFFFF"],categorical:["#070707","#F9F9F9","#777777","#454545","#AEAEAE","#909090","#292929","#5F5F5F","#D1D1D1","#9E9E9E","#525252","#E4E4E4","#6C6C6C","#BFBFBF","#1A1A1A","#373737","#848484","#595959","#222222","#B6B6B6","#A6A6A6","#3E3E3E","#7D7D7D","#666666","#969696","#8A8A8A","#4B4B4B","#DADADA","#C8C8C8","#313131","#717171","#131313","#EFEFEF","#C4C4C4","#A2A2A2","#424242","#878787","#252525","#2D2D2D","#4F4F4F","#3B3B3B","#808080","#1E1E1E","#BBBBBB","#AAAAAA","#EAEAEA","#696969","#7A7A7A","#DFDFDF","#636363","#565656","#B2B2B2","#0E0E0E","#9A9A9A","#5C5C5C","#747474","#F3F3F3","#333333","#6E6E6E","#D5D5D5","#8D8D8D","#939393","#494949","#CCCCCC","#171717","#BDBDBD","#575757","#C1C1C1","#404040","#828282","#E2E2E2","#151515","#1C1C1C","#0B0B0B","#9C9C9C","#858585","#2F2F2F","#B4B4B4","#888888","#242424","#272727","#3C3C3C","#B0B0B0","#353535","#545454","#5B5B5B","#393939","#D7D7D7","#A4A4A4","#A8A8A8","#959595","#767676","#646464","#989898","#444444","#474747","#111111","#F6F6F6","#ECECEC","#4D4D4D"]},hawaii:{discrete:["#8C0273","#8E0D6E","#8F1569","#901D63","#91235F","#91285A","#922D56","#933252","#94384D","#943D4A","#954246","#964742","#964C3F","#97523B","#985638","#985C34","#996131","#9A662E","#9B6C2A","#9B7226","#9C7823","#9C7E20","#9D841E","#9D8C1C","#9C921C","#9B991D","#9AA021","#97A828","#94AE30","#91B439","#8CB942","#88BE4C","#82C359","#7EC663","#79CA6E","#74CE79","#70D183","#6AD591","#66D89C","#62DCA7","#60DFB2","#5FE2BD","#61E6CA","#67E9D5","#6FEBDE","#7AEEE7","#87EFEE","#98F1F5","#A6F1F9","#B3F2FD"],categorical:["#8C0273","#B3F2FD","#9C951C","#6CD48C","#964D3E","#8ABC48","#9B6D29","#66E8D3","#922E55","#9C801F","#87EFEE","#995D34","#7BC969","#901D63","#60DEB0","#96AA2B","#943D4A","#975439","#82C359","#5FE4C2","#9AA021","#73CE7B","#65D99E","#954544","#9D8A1C","#8E126B","#91B439","#9DF1F7","#73ECE2","#91265C","#9C7724","#9A652E","#93364F","#922A59","#996131","#9D851D","#9D901C","#9A692C","#68D695","#902160","#9B9A1E","#985836","#9B7226","#933252","#77CC72","#9C7B21","#954147","#8D0A6F","#93AF32","#62DCA7","#92F0F3","#8F1867","#7DEEE8","#97513C","#6CEBDB","#61E6CA","#A8F2FA","#964941","#7FC661","#86BF50","#98A526","#70D183","#5FE1B9","#8DB840","#94394D","#9C7923","#8F1569","#985A35","#60E0B4","#9A6B2A","#91245E","#97A828","#9B7425","#6AD591","#95AD2E","#5FE2BD","#60E5C6","#953F48","#933054","#63E7CF","#84C154","#8D0671","#82EFEB","#9B9D1F","#99A323","#88BE4C","#6ED288","#6FEBDE","#9A672D","#91285A","#75CD76","#995F32","#68E9D7","#9B7028","#61DDAB","#943B4B","#933450","#8DF0F0","#8F1A65","#81C45D"]},imola:{discrete:["#1A33B3","#1C37B1","#1E3AAF","#203EAD","#2242AB","#2345AA","#2548A8","#274CA6","#2950A4","#2A53A3","#2C56A1","#2E599F","#2F5D9E","#32609B","#346499","#366797","#386A95","#3B6C92","#3E708F","#41738C","#44768A","#467987","#4A7C85","#4E8082","#518480","#56887E","#5A8C7D","#5F927B","#64967A","#689B79","#6DA078","#72A576","#78AB75","#7DB074","#82B572","#87BA71","#8CBF70","#93C66E","#98CB6D","#9ED06C","#A4D66A","#ACDB69","#B5E268","#BFE767","#C8EB67","#D3F066","#DDF466","#EAF866","#F5FB66","#FFFF66"],categorical:["#1A33B3","#FFFF66","#54867F","#305E9D","#91C36F","#3F718E","#2549A8","#BDE667","#70A377","#2B53A2","#376896","#80B373","#A3D56B","#DDF466","#203EAD","#487B86","#62947A","#2D59A0","#88BB71","#5B8D7D","#CDED66","#4E8082","#EEF966","#33639A","#284EA5","#44768A","#2344AA","#AFDE69","#3B6C92","#78AB75","#1D39B0","#99CC6D","#699C79","#3D6F90","#2C56A1","#2F5B9E","#5E917B","#4B7D84","#9ED06C","#1F3CAE","#C4EA67","#84B772","#274CA6","#D5F066","#2951A4","#74A776","#578A7E","#2446A9","#1C36B1","#A9D96A","#95C86E","#467888","#2141AC","#7CAF74","#356598","#B5E268","#66987A","#396A94","#F7FC66","#8CBF70","#E6F666","#32609B","#518380","#41738C","#6DA078","#6B9E78","#B9E468","#7AAD74","#528580","#32629B","#86B971","#3C6E91","#5C8F7C","#C8EB67","#ACDB69","#D1EF66","#E2F566","#97CA6D","#1B35B2","#1C37B0","#2345AA","#2F5D9E","#1F3DAE","#457789","#3A6B93","#598B7D","#D9F266","#346499","#386995","#A6D76A","#366797","#274DA6","#56887E","#A1D36B","#42748B","#7EB173","#72A576","#477987","#4C7F83","#F2FB66"]},lajolla:{discrete:["#191900","#1E1B02","#221C05","#271E08","#2C200B","#31220E","#362411","#3C2614","#442817","#4B2B1B","#532D1F","#5B3023","#633328","#6E362D","#783932","#813C37","#8B3F3B","#96423F","#A24543","#AD4746","#B74A48","#C04D49","#C9514B","#D1564C","#D75C4D","#DB634E","#DD694F","#E0714F","#E17750","#E37D50","#E48351","#E58951","#E79052","#E89652","#E99C52","#EAA253","#EBA853","#EDAF54","#EEB555","#F0BC57","#F1C25A","#F3CA5F","#F5D369","#F7DA74","#F9E282","#FBE890","#FCEF9F","#FDF5B0","#FEFABE","#FFFECB"],categorical:["#191900","#FFFECB","#D85F4D","#ECAC54","#653329","#F7D971","#A44544","#E58751","#362411","#E1744F","#C44E4A","#E99A52","#4B2B1B","#833D38","#F1C159","#FCEF9F","#271E08","#FEF7B6","#402716","#D0554C","#FAE587","#E79052","#EFB655","#B54947","#201C04","#E37D50","#743830","#DD694F","#EBA353","#94413E","#572F21","#F4CD61","#2E210C","#FDF3AB","#32220F","#241D06","#F5D369","#7B3B34","#1D1B02","#F0BC57","#5E3125","#F8DF7C","#512D1E","#CA514B","#E48251","#E68C51","#EA9E53","#E89552","#BC4C49","#6C362C","#EDB154","#9C4341","#E27950","#FBEA93","#3B2513","#FEFBC0","#452918","#EBA853","#F2C75C","#8B3F3B","#DB644E","#AD4746","#DF6E4F","#D55A4D","#2B200A","#783932","#E79352","#D75C4D","#FEF9BB","#EDAF54","#E0714F","#7F3C36","#613227","#F7DC77","#C7504B","#F1C45A","#30210D","#F4D065","#1E1B03","#FAE78D","#F9E282","#DA614E","#392412","#4E2C1D","#E99C52","#EFB956","#221C05","#EBA553","#FDF5B0","#984240","#E38050","#8F403D","#542E20","#ECAA54","#E68E51","#70372E","#DE6C4F","#B94A48","#291F09","#1B1A01"]},lapaz:{discrete:["#1A0C64","#1C1368","#1E196D","#202071","#212675","#222B79","#23317D","#253681","#263C85","#274189","#29478C","#2A4C8F","#2C5192","#2E5795","#305C98","#32609A","#35659C","#386A9E","#3C70A0","#3F74A1","#4379A2","#487DA3","#4D81A3","#5386A4","#588AA3","#5E8EA3","#6591A2","#6C95A1","#7398A0","#7A9A9E","#809D9D","#879F9B","#90A199","#97A397","#9EA596","#A5A795","#ADAA95","#B7AD96","#BFB199","#C8B69C","#D2BBA2","#DAC1A8","#E4C9B2","#EBCFBB","#F1D5C4","#F5DBCD","#F9E1D6","#FBE8E1","#FDEDEA","#FEF2F3"],categorical:["#1A0C64","#FEF2F3","#5B8BA3","#B3AC96","#2C5292","#3C70A0","#EACEB9","#859E9C","#24327E","#6F96A1","#33619A","#202071","#D0BAA0","#9BA496","#F9E1D6","#4A7FA3","#284289","#90A199","#FCEAE5","#1D176B","#37699D","#F3D8C8","#A7A895","#5285A4","#7A9A9E","#2F5A97","#4278A2","#263A84","#6591A2","#C1B299","#DEC3AB","#222978","#2A4B8E","#5688A4","#D7BEA6","#FDEEEC","#608EA3","#EFD3C0","#A1A696","#6A94A1","#FBE6DD","#ADAA95","#F6DDCF","#4E82A3","#2E5695","#3A6D9F","#C8B69C","#1C1268","#232D7B","#3F74A1","#467BA3","#1E1C6E","#7F9C9D","#BAAF97","#253681","#315E99","#29478C","#E4C9B2","#74989F","#273E87","#212575","#95A398","#8AA09A","#35659C","#2B4F91","#23307C","#E7CBB5","#F1D5C4","#2B4D90","#202373","#588AA3","#D3BCA3","#5487A4","#447AA2","#6792A2","#24347F","#253882","#ECD0BD","#879F9B","#305C98","#E1C6AF","#1E196D","#5D8DA3","#AAA995","#386B9E","#487DA3","#77999F","#F7DFD3","#BEB098","#1F1E70","#325F99","#4176A2","#F4DACB","#4C80A3","#2D5494","#8DA099","#6C95A1","#FAE3DA","#FDECE8","#B7AD96"]},lipari:{discrete:["#031326","#05192F","#062038","#092844","#0C2E4D","#103557","#163C5F","#1E4368","#294B70","#345075","#3E5578","#47587A","#4F5B7B","#575C7A","#5D5D79","#635E78","#695E76","#6E5F75","#765F73","#7C6071","#826070","#89606E","#90616C","#98616A","#A06268","#A86266","#B06364","#BA6462","#C36660","#CB685F","#D46B5E","#DB705F","#E27760","#E77E63","#E98567","#EA8D6B","#EA946F","#E89C75","#E7A279","#E6A87E","#E5AF84","#E5B58A","#E6BD92","#E7C49A","#EACCA3","#EDD3AD","#F0DBB7","#F5E5C4","#F9EDCF","#FDF5DA"],categorical:["#031326","#FDF5DA","#A56267","#525B7A","#E99B74","#785F72","#DA6F5E","#183E61","#E7C398","#8D616D","#365176","#092844","#655E77","#E98466","#BF6561","#F0DBB7","#E5AD82","#B26364","#EBCFA7","#5C5D79","#061D35","#25486D","#0E3353","#EA906D","#98616A","#E37861","#E5B88C","#826070","#CD685F","#6E5F75","#45587A","#F6E8C9","#E7A37A","#615E78","#E77E63","#D46B5E","#9F6268","#E99570","#93616B","#87606E","#7D6071","#F3E1C0","#575C7A","#0B2D4B","#2D4D72","#E6A87E","#E9C99F","#FAEED1","#1E4368","#EA8A69","#B86462","#6A5E76","#AB6365","#735F74","#DF735F","#E5B287","#13385A","#05182D","#E6BD92","#3E5578","#EDD5AF","#07223C","#C6665F","#4C5A7A","#E8A077","#B56363","#FBF1D6","#A26267","#E6C095","#0A2A48","#F8EBCD","#EACCA3","#AE6364","#7A5F72","#635E78","#E98768","#041629","#715F74","#ECD2AB","#A86266","#8A606E","#96616B","#545C7A","#EFD8B3","#F5E5C4","#9B6169","#F2DEBB","#765F73","#6C5F75","#294B70","#22466B","#E89D76","#E88165","#BC6461","#E6A67C","#85606F","#C36660","#1B4064","#D06A5E","#103557"]},lisbon:{discrete:["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"],categorical:["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"]},managua:{discrete:["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"],categorical:["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"]},navia:{discrete:["#031327","#041930","#051E3A","#052546","#062B50","#06315A","#073764","#083E6D","#0B4578","#0E4C80","#115286","#15588B","#195E8E","#1E6491","#216991","#246D91","#27718F","#2A748E","#2D788C","#307A8A","#337D89","#368087","#398385","#3C8683","#3F8981","#428C7F","#468F7D","#4A937A","#4E9678","#529A76","#579E73","#5BA271","#62A86E","#67AD6B","#6EB269","#76B768","#7FBD68","#8CC56A","#98CB6F","#A4D176","#B1D67F","#BCDB89","#C9E096","#D3E3A1","#DCE7AC","#E3EAB6","#EAEDBF","#F1F0CA","#F7F2D2","#FCF4D9"],categorical:["#031327","#FCF4D9","#408A80","#87C269","#1B608F","#59A072","#073966","#D1E39F","#2F798B","#EAEDBF","#052546","#266F90","#6BB06A","#0E4D81","#AED57D","#4C947A","#378186","#DFE8B0","#337D89","#2A748E","#14578A","#051C36","#9ACC70","#0A4374","#468F7D","#529A76","#F4F1CD","#062F56","#C1DC8D","#206891","#78B968","#62A86E","#3C8583","#569D74","#236C91","#F8F3D3","#D8E5A8","#0C487B","#04182E","#71B469","#B8D985","#07345E","#05213E","#4F9778","#5DA470","#3E8882","#062A4E","#7FBD68","#EFEFC6","#C9E096","#115286","#2C768D","#1E6491","#49917B","#66AC6C","#28718F","#A4D176","#90C76C","#438C7F","#175C8D","#083E6D","#E5EAB8","#317B8A","#357F87","#398385","#B3D781","#0D4A7E","#1C6290","#052342","#579F73","#9FCE73","#448D7E","#051A32","#FAF3D6","#428B7F","#29738F","#104F84","#5FA66F","#509877","#8CC56A","#094071","#2D788C","#083B6A","#D5E4A3","#2B758D","#226A91","#04162B","#BCDB89","#47907C","#4D9579","#E2E9B4","#7BBB68","#6EB269","#135488","#4A937A","#F1F0CA","#5BA271","#C5DE92","#F6F2D0","#CDE19B"]},naviaw:{discrete:["#041427","#051A31","#05203B","#062747","#072D52","#08345C","#0A3A66","#0C416F","#0F4979","#135080","#175686","#1B5D8A","#1F628D","#23698F","#276D8F","#2A728F","#2D758E","#30798D","#347D8B","#378089","#3A8388","#3D8686","#408984","#448C82","#489080","#4B937E","#50977C","#559C79","#5AA077","#5FA575","#65AA73","#6CAF71","#76B671","#7FBD71","#89C474","#95CB78","#A2D27F","#B1D98A","#BEDF95","#C9E5A1","#D3E9AD","#DBEDB9","#E4F1C6","#E9F4D0","#EEF6D9","#F2F8E1","#F6FAE9","#F9FCF1","#FCFDF7","#FEFEFD"],categorical:["#041427","#FBFDF6","#478F80","#9FD07D","#1F628D","#64A973","#E3F0C4","#0A3A66","#337C8B","#C7E49E","#7DBC71","#549B7A","#2A718F","#135080","#F2F8E1","#3C8586","#062747","#D7EBB2","#418A83","#B4DB8C","#2E778D","#6FB271","#EBF5D4","#0E4574","#051D37","#4D957D","#256B8F","#195A88","#388189","#F7FAEC","#5CA276","#8CC574","#073056","#31798C","#367E8A","#69AD72","#E7F3CC","#104A7A","#95CB78","#EFF6DB","#0B406D","#2C748E","#4A927F","#DDEEBB","#50987C","#165584","#589E78","#76B671","#3F8785","#05192F","#BEDF95","#448C82","#22678E","#06223F","#A9D684","#08355E","#CFE8A8","#F9FCF1","#286E8F","#85C172","#072C50","#F5F9E7","#1C5F8B","#3A8387","#60A675","#F3F9E4","#0C4271","#266D8F","#81BE72","#0A3D6A","#4B937E","#9ACD7B","#EDF5D7","#90C876","#A4D381","#378089","#1B5D8A","#489080","#145282","#DAECB6","#67AB73","#CBE6A3","#B9DD90","#3D8686","#23698F","#6CAF71","#FAFCF3","#79B971","#D3E9AD","#5AA077","#458E81","#72B471","#327B8C","#E5F1C8","#051B33","#F8FBEE","#062443","#398288","#2B728F","#06294C"]},nuuk:{discrete:["#05598C","#0E5B8B","#155C89","#1C5E87","#226085","#276184","#2C6383","#326682","#386982","#3E6C82","#446F82","#4A7283","#517584","#587A86","#5F7D88","#66818A","#6C858C","#73898E","#7B8E91","#819192","#879594","#8D9996","#939C97","#99A097","#9EA498","#A2A798","#A6AA97","#ABAD96","#AEAF95","#B1B194","#B3B492","#B6B690","#B8B88E","#BABA8C","#BDBC8A","#BFBE88","#C1C187","#C4C385","#C7C684","#CAC983","#CDCD83","#D2D184","#D7D787","#DDDD8B","#E3E290","#E8E895","#EEEE9C","#F4F4A4","#F9F9AB","#FEFEB2"],categorical:["#05598C","#FEFEB2","#A1A698","#537785","#C3C385","#B5B591","#7D8F91","#2D6483","#DDDD8B","#919B96","#BCBC8B","#3F6C82","#CDCD83","#1C5E87","#ADAE95","#68838B","#EEEE9C","#A7AA97","#879594","#C8C783","#F6F6A7","#135C89","#B9B98E","#497183","#73898E","#366882","#C0BF88","#D4D486","#99A097","#B1B293","#5E7D88","#256185","#E6E693","#829293","#788C90","#9DA398","#AAAC96","#E1E18F","#3B6A82","#638089","#B3B492","#A4A897","#446F82","#BABA8C","#D8D888","#185D88","#8C9895","#215F86","#BEBD89","#B7B78F","#CACA83","#4E7484","#C1C186","#959E97","#F2F2A1","#AFB094","#326682","#587A86","#296284","#FAFAAD","#6E868C","#C5C584","#D1D084","#0D5B8B","#E9E997","#DFDF8D","#66818A","#B0B194","#5B7B87","#2B6383","#859493","#CCCB83","#F8F8AA","#D2D285","#1F5F86","#70878D","#4B7383","#768B8F","#FCFCAF","#A9AB97","#BFBE88","#C9C983","#346782","#DBDA89","#236085","#BDBD8A","#BAB98D","#B8B88E","#2F6583","#939C97","#9FA498","#A2A798","#CFCF84","#B4B591","#C4C485","#979F97","#F0F09E","#155C89","#9BA298","#517584"]},oleron:{discrete:["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"],categorical:["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"]},oslo:{discrete:["#010101","#04070B","#060C13","#0A121B","#0C1620","#0D1927","#0E1D2D","#0F2133","#10263C","#112A43","#122E4A","#133251","#153758","#173C61","#194169","#1B4670","#1E4A78","#214F80","#255589","#295A91","#2E5F99","#3364A1","#3A6AA9","#4371B2","#4B77B9","#537DBE","#5B83C3","#6489C6","#6B8EC8","#7292C9","#7896C9","#7E9ACA","#859ECA","#8BA2C9","#91A6C9","#97A9C9","#9DADC9","#A4B2CA","#AAB6CA","#B1BBCB","#B8BFCD","#BFC5CF","#C7CCD3","#CFD2D8","#D7D9DD","#DEE0E2","#E6E7E9","#EFF0F1","#F7F7F8","#FFFFFF"],categorical:["#030609","#F9F9F9","#507BBC","#163B5E","#A0AFC9","#7B98CA","#27588E","#0E2032","#CACED5","#122D48","#3767A6","#1D4875","#8DA3C9","#E2E3E5","#678BC7","#B4BDCC","#0C151F","#BFC5CF","#97A9C9","#4371B2","#10263D","#080E16","#7292C9","#215081","#2E5F99","#AAB6CA","#ECEDEE","#0D1A28","#143454","#D5D8DC","#5B83C3","#19426A","#859ECA","#13314E","#0E1D2D","#3D6CAC","#6C8FC8","#7795C9","#F3F3F4","#4976B8","#245488","#DBDDE0","#112A43","#92A6C9","#C5C9D2","#809BCA","#0F2337","#3263A0","#050A10","#B9C1CD","#1F4C7B","#183E64","#A5B3CA","#0A121B","#9CACC9","#6187C5","#0D1824","#8AA1CA","#2A5B93","#547EBF","#D1D3D9","#E6E7E9","#1B456F","#B0BACB","#153758","#7494C9","#D8DADE","#6A8DC8","#90A5C9","#99ABC9","#235285","#133251","#060C13","#406EAF","#7E9ACA","#173C61","#4C78BA","#122F4B","#1C4772","#87A0CA","#CED1D7","#C2C7D1","#0F253A","#2C5D96","#C7CCD3","#112B45","#EFF0F1","#6F90C9","#0E1E2F","#ADB8CB","#7997CA","#4673B5","#15395B","#091018","#194067","#30619C","#94A8C9","#F6F6F6","#0F2135","#A3B1CA"]},roma:{discrete:["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"],categorical:["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"]},romao:{discrete:["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"],categorical:["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"]},tofino:{discrete:["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"],categorical:["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"]},tokyo:{discrete:["#1C0E34","#241036","#2D1339","#37163D","#3F1A40","#481E43","#4F2345","#562948","#5D304A","#62354C","#663B4D","#69404E","#6B454F","#6D4B50","#6E4F50","#6F5251","#6F5651","#705951","#715C52","#715F52","#716252","#726452","#726753","#736B53","#736E53","#747153","#757554","#757A54","#767E55","#778355","#788856","#798E57","#7B9558","#7C9B5A","#7EA25C","#81A95E","#84B062","#88B968","#8DC16E","#93CA76","#9BD27F","#A4DA8A","#AFE398","#BAEAA4","#C5EFB0","#CFF4BB","#D8F7C5","#E2F9CF","#E9FBD7","#EFFCDD"],categorical:["#1C0E34","#EFFCDD","#747053","#6C4750","#87B666","#B8E8A1","#512446","#715D52","#798B56","#7D9F5B","#37163D","#726653","#99D07D","#63374C","#6F5451","#D8F7C5","#767C54","#705951","#5B2D49","#7B9558","#441D41","#291238","#E5FAD2","#C9F1B4","#716252","#81AA5F","#683F4E","#736B53","#6E4E50","#757654","#8EC370","#A7DD8E","#778455","#747354","#84B062","#231036","#93CA76","#DFF9CC","#30143A","#A0D785","#7FA45D","#EAFBD8","#6A434F","#C1EDAB","#736D53","#562948","#6D4B50","#7A9057","#7C9A59","#4B2044","#715F52","#663B4D","#D1F4BD","#705651","#8ABD6A","#6E5151","#AFE398","#5F324B","#757954","#3E193F","#726853","#726452","#778055","#705B52","#788756","#61344C","#746E53","#ABE093","#532747","#85B364","#7EA25C","#261137","#736C53","#E8FBD5","#4E2245","#88B968","#798E57","#767E55","#726753","#757754","#715E52","#3A183E","#6E4F51","#778255","#7B9759","#DCF8C9","#EDFCDA","#411B40","#7D9C5A","#767B54","#726352","#6F5551","#726552","#82AD60","#D5F6C1","#34153C","#9CD481","#747454","#C5EFB0","#481E43"]},turku:{discrete:["#000000","#090908","#111110","#181816","#1D1D1A","#22221F","#272723","#2C2C27","#33322B","#38382F","#3D3D32","#424235","#474738","#4E4D3C","#53523E","#585841","#5D5D43","#626246","#686848","#6E6D4B","#73724D","#797750","#7F7D52","#878356","#8E8859","#968E5C","#9D9360","#A79864","#AF9C68","#B69F6C","#BEA270","#C4A474","#CCA579","#D1A67D","#D7A781","#DBA886","#E0A98B","#E6AB92","#EAAD98","#EFB09F","#F2B4A7","#F6B9AE","#F9BFB7","#FBC4BF","#FDC9C6","#FECFCC","#FED4D3","#FFDBDA","#FFE0E0","#FFE6E6"],categorical:["#070707","#FFE6E6","#948D5B","#E5AA90","#4D4C3B","#2C2C27","#C3A374","#6D6C4A","#FBC4BF","#D6A780","#F2B4A7","#1C1C19","#3D3D32","#AC9A67","#7E7C52","#FED6D4","#5D5D43","#35342D","#DDA888","#141312","#55543F","#242420","#FDCDCA","#F7BCB3","#898456","#B8A06D","#ECAE9B","#CDA57A","#FFDEDD","#646447","#454537","#9F9461","#76744E","#71704C","#30302A","#414135","#181816","#FCC8C4","#EFB1A1","#838054","#F5B8AD","#E1A98C","#C8A477","#686848","#595941","#20201D","#8E8859","#D1A67D","#B29D6A","#E9AC95","#BEA270","#FED1CF","#0E0E0D","#A59764","#DAA784","#282823","#F9C0B9","#51503D","#393930","#FFDAD9","#49493A","#606045","#FFE2E1","#9A915E","#797750","#F4B6AA","#F6BAB0","#CBA578","#FFD8D6","#FECFCC","#262622","#C0A272","#868255","#1A1A18","#FAC2BC","#8B8658","#E3AA8E","#161614","#4F4E3C","#C6A475","#2E2E28","#BBA16F","#6B6A49","#E7AB93","#CFA67C","#626246","#53523E","#5B5B42","#FED3D1","#7C7A51","#817E53","#73724D","#FFDCDB","#37372E","#F8BEB6","#0B0B0A","#575740","#DFA98A","#474738","#B59F6C"]},vanimo:{discrete:["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"],categorical:["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"]},vik:{discrete:["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"],categorical:["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"]},viko:{discrete:["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"],categorical:["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"]}};function Re(e){const t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}const $e={waves:"batlow",blksand:"tokyo",breeze:"imola",magma:"batlow",ribbon:"hawaii",stars:"batlow",folds:"imola"},Pe={[z.ADVERT]:1,[z.TXT_MSG]:4,[z.GRP_TXT]:2,[z.RESPONSE]:8,[z.REQ]:13,[z.ANON_REQ]:7,[z.ACK]:11,[z.PATH]:24,[z.TRACE]:16,[z.GRP_DATA]:34,[z.MULTIPART]:52,[z.RAW_CUSTOM]:14};function Le(){let e="waves",t=!0;if("undefined"!=typeof window){e=localStorage.getItem("pymc-color-scheme")||"waves";const s=L(e);t=(null==s?void 0:s.meta.isDark)??!0}const s=$e[e]??"batlow",a=Te[s],n=a.discrete.length,r=Math.floor(n/2);return{colormap:a,colormapName:s,isDark:t,baseIndex:t?r:0,halfSize:r}}let ze=null;function _e(e){const{colormap:t,isDark:s}=Le();if("number"!=typeof e)return s?"#A5A5A5":"#666666";const a=Pe[e];if(void 0===a)return s?"#A5A5A5":"#666666";const n=t.categorical;return n[Math.min(a,n.length-1)]}function He(e){return Re(_e(e))}const Oe={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function We(e,t){if(0===e.length)return 0;const s=t/100*(e.length-1),a=Math.floor(s),n=Math.ceil(s);return a===n?e[a]:e[a]+(e[n]-e[a])*(s-a)}function Ie(e){if(0===e.length)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const t=[...e].sort((e,t)=>e-t);return{median:We(t,50),p90:We(t,90),p95:We(t,95),p99:We(t,99),max:t[t.length-1],min:t[0]}}function Ve(e,t,s){const a=s-t;if(0===a)return"moderate";const n=(e-t)/a;return n>.66?"critical":n>.33?"severe":"moderate"}n.memo(function({options:e,data:t,className:s="",onCreate:a}){const l=n.useRef(null),i=n.useRef(null);return n.useEffect(()=>{const s=l.current;if(!s)return;const n=s.getBoundingClientRect(),r=Math.floor(n.width)||400,o=Math.floor(n.height)||200,c=new _({...e,width:r,height:o},t,s);return i.current=c,null==a||a(c),()=>{c.destroy(),i.current=null}},[e]),n.useEffect(()=>{i.current&&t&&i.current.setData(t)},[t]),n.useEffect(()=>{const e=l.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!i.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&i.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.jsx("div",{ref:l,className:`w-full h-full ${s}`,style:{minHeight:100}})});const qe=new Map;function Ge(e){var t;if(!e.startsWith("var("))return e;const s=qe.get(e);if(s)return s;const a=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!a)return e;const n=a[1].trim(),r=(null==(t=a[2])?void 0:t.trim())||"#888888",l=getComputedStyle(document.documentElement).getPropertyValue(n).trim()||r;return qe.set(e,l),l}function Xe(e,t,s=!1){if(t.length<2)return;if(e.beginPath(),e.moveTo(t[0].x,t[0].y),2===t.length)return void e.lineTo(t[1].x,t[1].y);const a=.5;for(let n=0;n{F.current=e,E.current=t,m.current=a,d.current=s});const h=n.useRef({band:l,innerBand:i,mean:o,median:c,average:C,cursor:A});n.useLayoutEffect(()=>{h.current={band:l,innerBand:i,mean:o,median:c,average:C,cursor:A}});const x=n.useMemo(()=>[e.map(e=>e.timestamp),e.map(e=>e.max)],[e]),p=n.useMemo(()=>{const e=function(e,t,s,a){return{hooks:{draw:n=>{const r=e.current,l=t.current,i=s.current,o=a.current;if(0===r.length)return;const c=n.ctx,C=n.bbox,A=C.left,D=C.top,B=C.width,F=C.height;if(B<=0||F<=0)return;const E=n.data[0],m=E.length;if(0===m)return;const d=E[0],u=E[m-1]-d||1,h=e=>A+(e-d)/u*B,x=e=>D+F*(1-e/l),p={min:r.map(e=>({x:h(e.timestamp),y:x(e.min)})),max:r.map(e=>({x:h(e.timestamp),y:x(e.max)})),p5:r.map(e=>({x:h(e.timestamp),y:x(e.p5)})),p95:r.map(e=>({x:h(e.timestamp),y:x(e.p95)})),p25:r.map(e=>({x:h(e.timestamp),y:x(e.p25)})),p75:r.map(e=>({x:h(e.timestamp),y:x(e.p75)})),mean:r.map(e=>({x:h(e.timestamp),y:x(e.mean)})),median:r.map(e=>({x:h(e.timestamp),y:x(e.median)})),average:r.map(e=>({x:h(e.timestamp),y:x(e.average)}))},g=(e,t)=>i?i===e?Math.min(1,1.5*t):"minMax"===i||"p5p95"===i||"p25p75"===i?.3*t:t:t,f=e=>i?i===e?1:"mean"===i||"median"===i||"average"===i?.3:1:1,b={band:Ge(o.band),innerBand:Ge(o.innerBand),mean:Ge(o.mean),median:Ge(o.median),average:Ge(o.average)};c.save(),c.strokeStyle=b.average,c.lineWidth=4,c.globalAlpha=f("average"),Xe(c,p.average),c.stroke(),c.globalAlpha=g("minMax",.15),c.fillStyle=b.band,c.beginPath(),Xe(c,p.max);const y=[...p.min].reverse();for(const e of y)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=g("p5p95",.3),c.fillStyle=b.band,c.beginPath(),Xe(c,p.p95);const v=[...p.p5].reverse();for(const e of v)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=g("p25p75",.55),c.fillStyle=b.innerBand,c.beginPath(),Xe(c,p.p75);const j=[...p.p25].reverse();for(const e of j)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=b.median,c.lineWidth=1.5,c.globalAlpha=f("median"),c.setLineDash([4,4]),Xe(c,p.median),c.stroke(),c.strokeStyle=b.mean,c.lineWidth=1.5,c.globalAlpha=f("mean"),c.setLineDash([]),Xe(c,p.mean),c.stroke(),c.restore()}}}}(F,E,m,h);return{width:400,height:200,padding:[4,4,4,4],cursor:{show:!0,x:!0,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,t]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],hooks:{setCursor:[e=>{var t,s;const a=e.cursor.idx;null!=a&&a>=0?null==(t=d.current)||t.call(d,a):null==(s=d.current)||s.call(d,null)}]},plugins:[e]}},[t]);n.useEffect(()=>{const t=D.current;if(!t||0===e.length)return;const s=u.current,a=e.length,n=Math.abs(a-s);if(!(!B.current||n>100||s>0&&n/s>.1)&&B.current)return B.current.setData(x),void(u.current=a);B.current&&B.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new _({...p,width:l,height:i},x,t);return B.current=o,u.current=a,()=>{o.destroy(),B.current=null}},[p,x,e.length]),n.useEffect(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!B.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&B.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),n.useEffect(()=>{B.current&&B.current.redraw()},[a,e]);const g=n.useCallback(()=>{null==s||s(null)},[s]);return 0===e.length?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):r.jsx("div",{ref:D,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})});const Ke="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Ye(){const e=getComputedStyle(document.documentElement);return{fontFamily:e.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',axisColor:e.getPropertyValue("--chart-axis-tick").trim()||"rgba(255, 255, 255, 0.4)",gridColor:e.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)",textMuted:e.getPropertyValue("--text-muted").trim()||"#727272",textPrimary:e.getPropertyValue("--text-primary").trim()||"#FFFFFF"}}const Ue=["min","max","p75","p95","p99","mean","median","average","midpoint"];function Qe(e){const t=Re(function(e){const{colormap:t,baseIndex:s,halfSize:a}=Le(),n=Math.max(0,Math.min(1,e)),r=Math.min(s+Math.floor(n*(a-1)),t.discrete.length-1);return t.discrete[r]}(e)),s=`color(display-p3 ${(t.r/255).toFixed(3)} ${(t.g/255).toFixed(3)} ${(t.b/255).toFixed(3)})`;return{...t,p3:s}}function Ze(e,t,s,a,n,r,l,i,o,c=null,C=null,A=1,D=null,B="airtime",F=.5){if(0===t.length)return;const E=e.ctx,{left:m,top:d,width:u,height:h}=e.bbox,x=window.devicePixelRatio||1;if(u<=0||h<=0)return;const p=e.data[0],g=p.length;if(0===g)return;const f=p[0],b=p[g-1],y=s,v="share"===B,j=v?function(e){const t=[10,20,25,50,100,200,250,500,1e3],s=e/4.5;for(const a of t)if(a>=s)return a;return e>5e3?1e3*Math.ceil(s/1e3):100*Math.ceil(s/100)}(y):5,N=getComputedStyle(document.documentElement),w=N.getPropertyValue("--signal-critical").trim()||"#EF4444",k=N.getPropertyValue("--bg-body").trim()||"#171717";E.save(),E.fillStyle="#000000";const M=8*x;E.beginPath(),E.roundRect(m,d,u,h,M),E.fill(),E.restore();const S=parseInt(k.slice(1,3),16)||23,T=parseInt(k.slice(3,5),16)||23,R=parseInt(k.slice(5,7),16)||23;if(!v&&y>=20){E.save();const e=d+h*(1-20/y);E.fillStyle=`rgba(${S}, ${T}, ${R}, 0.5)`,E.fillRect(m,d,u,e-d),E.restore()}E.save(),E.lineWidth=1*x,E.setLineDash([4*x,4*x]);for(let P=j;Ps+n)return;const i=getComputedStyle(document.documentElement).getPropertyValue("--text-primary").trim()||"#FFFFFF";e.save(),e.strokeStyle=i,e.globalAlpha=.5,e.lineWidth=1*l,e.setLineDash([4*l,4*l]),e.beginPath(),e.moveTo(Math.round(t)+.5,a),e.lineTo(Math.round(t)+.5,a+r),e.stroke(),e.restore()}(E,D,m,d,u,h,x),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:C,rawValues:A,count:D,packetTypes:B,timestamps:F}=t,E=1*o*(window.devicePixelRatio||1);e.globalCompositeOperation="source-over";const m=l?parseInt(l.replace("TYPE_",""),10):null;for(let d=0;d=i.start&&e0&&function(e,t,s,a,n,r,l,i,o,c,C=.5){if(0===t.length)return;const A=o-i||1,D=function(e,t=1.3,s=.15){const a=function(e){const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);if(t){const e=parseFloat(t[1]),s=parseFloat(t[2]),a=parseFloat(t[3]);return{r:Math.round(255*e),g:Math.round(255*s),b:Math.round(255*a),p3r:e,p3g:s,p3b:a}}if(e.startsWith("#")){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return{r:s,g:a,b:n,p3r:s/255,p3g:a/255,p3b:n/255}}const s=e.match(/rgba?\(([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(s){const e=Math.round(parseFloat(s[1])),t=Math.round(parseFloat(s[2])),a=Math.round(parseFloat(s[3]));return{r:e,g:t,b:a,p3r:e/255,p3g:t/255,p3b:a/255}}return{r:255,g:255,b:255,p3r:1,p3g:1,p3b:1}}(e),n=function(e,t,s,a=1.25,n=.15){const r=(Math.max(e,t,s)+Math.min(e,t,s))/2;return{p3r:Math.min(1,r+(e-r)*a+n),p3g:Math.min(1,r+(t-r)*a+n),p3b:Math.min(1,r+(s-r)*a+n)}}(a.p3r,a.p3g,a.p3b,t,s);return{r:Math.round(255*Math.min(1,n.p3r)),g:Math.round(255*Math.min(1,n.p3g)),b:Math.round(255*Math.min(1,n.p3b)),p3r:Math.min(1,n.p3r),p3g:Math.min(1,n.p3g),p3b:Math.min(1,n.p3b)}}(getComputedStyle(document.documentElement).getPropertyValue("--signal-critical").trim()||"#EF4444");e.save(),e.globalAlpha=C,e.fillStyle=Ke?`color(display-p3 ${D.p3r} ${D.p3g} ${D.p3b})`:`rgb(${D.r}, ${D.g}, ${D.b})`;for(const B of t){if(B.endTso)continue;const t=a+(Math.max(B.startTs,i)-i)/A*r,s=a+(Math.min(B.endTs,o)-i)/A*r,C=Math.max(s-t,2*c);e.fillRect(t,n,C,l)}e.restore()}(E,i,0,m,d,u,h,f,b,x,C?Math.max(.03,.03*F):F)}const Je=n.memo(function({data:e,maxValue:t,visibleLines:s=Ue,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:C=.5,highlightedType:A=null,hoveredTimeRange:D=null,timeRangeHours:B=24,yAxisMode:F="airtime"}){const E=n.useRef(null),m=n.useRef(null),d=n.useRef(e),u=n.useRef(t),h=n.useRef(s),x=n.useRef(a),p=n.useRef(l),g=n.useRef(i),f=n.useRef(o),b=n.useRef(c),y=n.useRef(A),v=n.useRef(D),j=n.useRef(null),N=n.useRef(null),w=n.useRef(F),k=n.useRef(C),M=B<=12?1.2:1,S=n.useRef(M),T=n.useRef(e.length);n.useLayoutEffect(()=>{d.current=e,u.current=t,h.current=s,x.current=a,p.current=l,g.current=i,f.current=o,b.current=c,y.current=A,v.current=D,S.current=M,w.current=F,k.current=C}),n.useEffect(()=>{j.current=Ye()},[]);const R=n.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),$=n.useMemo(()=>({hooks:{draw:e=>{const t=j.current||Ye();Ze(e,d.current,u.current,h.current,x.current,t,g.current,f.current,b.current,y.current,v.current,S.current,N.current,w.current,k.current)}}}),[]),P=n.useMemo(()=>({width:400,height:200,padding:[8,0,8,28],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[$]}),[$]);n.useEffect(()=>{const t=E.current;if(!t||0===e.length)return;const s=T.current,a=e.length,n=Math.abs(a-s);if(!(!m.current||n>100||s>0&&n/s>.1)&&m.current)return m.current.setData(R),void(T.current=a);m.current&&m.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new _({...P,width:l,height:i},R,t);return m.current=o,T.current=a,()=>{o.destroy(),m.current=null}},[P,R,e.length]),n.useEffect(()=>{const e=E.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!m.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&m.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),n.useEffect(()=>{m.current&&m.current.redraw()},[a,s,e,i,o,c,C,A,D,M]);const L=n.useCallback(t=>{var s,a;const n=E.current,r=m.current;if(!n||!r||0===e.length)return;const l=n.getBoundingClientRect(),i=t.clientX-l.left,o=window.devicePixelRatio||1,c=r.bbox,C=c.left/o,A=c.width/o;if(iC+A)return N.current=null,r.redraw(),void(null==(s=p.current)||s.call(p,null));N.current=i*o;const D=(i-C)/A,B=e.length,F=Math.floor(D*B),d=Math.max(0,Math.min(B-1,F));r.redraw(),null==(a=p.current)||a.call(p,d)},[e.length]),z=n.useCallback(()=>{var e;N.current=null,m.current&&m.current.redraw(),null==(e=p.current)||e.call(p,null)},[]);return 0===e.length?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):r.jsx("div",{ref:E,className:"w-full h-full rounded-lg overflow-hidden",onMouseMove:L,onMouseLeave:z})}),et=function(e){const t=_e(e);return null===ze&&(ze=P()),ze?$(t):t};function tt({sortedTypes:e,highlightedType:t,onTypeHover:s,aggregateShares:a,hoverData:l}){const i=n.useMemo(()=>{if(!l)return null;const e=new Map;for(const t of l.items)e.set(t.key,t.value);return e},[l]),o=null!==i;return r.jsx("div",{className:"flex-shrink-0 pt-3 mt-2",children:r.jsx("div",{className:"grid ml-9 gap-y-0.5",style:{gridTemplateColumns:"repeat(auto-fill, minmax(105px, 1fr))"},onMouseLeave:()=>s(null),children:e.map(e=>{const n=et(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,C=o?l:c,A=C>1e-4,D=t===e.key,B=["legend-item",D&&"legend-item-active",(t&&!D||o&&l<=1e-4)&&"legend-item-dimmed",!t&&o&&l>1e-4&&"legend-item-chart-active"].filter(Boolean).join(" ");return r.jsxs("div",{className:B,onMouseEnter:()=>s(e.key),children:[r.jsx("div",{className:"flex-shrink-0",style:{backgroundColor:n,width:9,height:16,borderRadius:1}}),r.jsx("span",{className:"legend-label",children:e.label}),A&&r.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*C).toFixed(1),"%"]})]},e.key)})})})}const st='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';function at({x:e,y:t,width:s,height:a,name:n,size:l,index:i,depth:o,hoveredIndex:c,onHover:C,total:A,typeNum:D}){if(1!==o)return null;const B=null!==c&&!(c===i),F=et(D),E=A>0?l/A*100:0,m=s>36&&a>20,d=s>36&&a>32;return r.jsxs("g",{onMouseEnter:e=>C(i,e),onMouseLeave:()=>C(null),style:{cursor:"default"},children:[r.jsx("rect",{x:e,y:t,width:s,height:a,fill:F,opacity:B?.4:1,stroke:"rgba(0,0,0,0.2)",strokeWidth:1,rx:3,style:{transition:"opacity 150ms ease"}}),m&&r.jsxs(r.Fragment,{children:[d&&r.jsxs("text",{x:e+4,y:t+a-4-11,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.6)",fontSize:8,fontFamily:st,fontWeight:500,style:{pointerEvents:"none"},children:[E.toFixed(1),"%"]}),r.jsx("text",{x:e+4,y:t+a-4,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.85)",fontSize:9,fontFamily:st,fontWeight:600,style:{pointerEvents:"none"},children:n})]})]})}function nt({data:e,total:t,color:s,position:a,containerWidth:n}){if(!e||!a)return null;const l=(e.value/t*100).toFixed(1),i=n-a.x<184?Math.max(8,a.x-160-8):a.x+16;return r.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:i,top:Math.max(8,a.y-60)},children:r.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl min-w-[140px]",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:s}}),r.jsx("span",{className:"type-data-sm font-semibold text-text-primary",children:e.name})]}),r.jsxs("div",{className:"space-y-0.5 type-data-xs text-text-muted",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Count"}),r.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:e.value.toLocaleString()})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Share"}),r.jsxs("span",{className:"text-text-primary tabular-nums font-medium",children:[l,"%"]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:t.toLocaleString()})]})]})]})})}function rt({sortedTypes:e,aggregateShares:t}){var s,a,i;const[o,c]=n.useState(null),[C,A]=n.useState(null),[D,B]=n.useState(0),[F,E]=n.useState(null),m=n.useRef(null),d=n.useMemo(()=>e.reduce((e,t)=>e+t.totalCount,0),[e]),u=n.useMemo(()=>e.map((e,t)=>({name:e.label,size:e.totalCount,index:t,typeNum:e.typeNum,key:e.key})),[e]),h=n.useCallback((e,t)=>{if(c(e),t&&null!==e){const e=m.current;if(e){const s=e.getBoundingClientRect();B(s.width),A({x:t.clientX-s.left,y:t.clientY-s.top})}}else A(null)},[]),x=n.useCallback(e=>{if(E(e),e){const t=u.findIndex(t=>t.key===e);c(t>=0?t:null)}else c(null)},[u]),p=null!==o?{name:(null==(s=u[o])?void 0:s.name)??"",value:(null==(a=u[o])?void 0:a.size)??0}:null,g=null!==o?et(null==(i=u[o])?void 0:i.typeNum):"";return 0===e.length||0===d?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet type data available"})]}):r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",ref:m,children:[r.jsx(Ee,{width:"100%",height:"100%",children:r.jsx(me,{data:u,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:r.jsx(at,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:o,onHover:h,total:d,typeNum:0})})}),r.jsx(nt,{data:p,total:d,color:g,position:C,containerWidth:D})]}),r.jsx(tt,{sortedTypes:e,highlightedType:F,onTypeHover:x,aggregateShares:t})]})}function lt(e){return e>=1e9?`${(e/1e9).toFixed(1)} Gb`:e>=1e6?`${(e/1e6).toFixed(1)} Mb`:e>=1e3?`${(e/1e3).toFixed(1)} Kb`:`${e.toFixed(0)} B`}function it({active:e,payload:t,label:s,mode:a}){if(!e||!t||0===t.length)return null;const n=t.filter(e=>null!==e.value&&void 0!==e.value);if(0===n.length)return null;const l=s?new Date(1e3*s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):"";return r.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[r.jsx("div",{className:"font-medium text-text-primary mb-1 font-mono",children:l}),n.map((e,t)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-3 h-0.5",style:{backgroundColor:e.color}}),r.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),r.jsx("span",{className:"text-text-primary tabular-nums font-mono",children:"share"===a?`${Number(e.value).toLocaleString()} B`:`${Number(e.value).toFixed(2)}%`})]},t))]})}function ot({packets:e,mode:t,startTs:s,endTs:a,radioConfig:o,bucketCount:c}){const C=oe(),A=ce(),D=C.primary,B=C.tertiary,[F,E]=n.useState(null),{trendData:m,totals:d}=n.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const n=a-s,r=Math.min(Math.ceil(n/300),c),l=n/r,i=[];let C=0,A=0,D=0,B=0;for(const t of e){const e=t.timestamp;if(e=a)continue;const n=H(t),r=O(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble}),l={timestamp:e,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};t.transmitted?(l.txAirtime=r,l.txBytes=n,A+=n,B+=r):(l.rxAirtime=r,l.rxBytes=n,C+=n,D+=r),i.push(l)}i.sort((e,t)=>e.timestamp-t.timestamp);const F=new Float64Array(i.length+1),E=new Float64Array(i.length+1),m=new Float64Array(i.length+1),d=new Float64Array(i.length+1),u=new Float64Array(i.length);for(let e=0;e{let t=0,s=u.length;for(;t>>1;u[a]0?e:null,tx:t>0?t:null})}else{const e=(F[i]-F[r])/p*100,t=(E[i]-E[r])/p*100;x.push({timestamp:a,rx:e>0?e:null,tx:t>0?t:null})}}const g=2/31;let f=null;return{trendData:x.map(e=>{const t=e.rx;return null!==t&&t>0&&(f=null===f?t:g*t+(1-g)*f),{...e,rxSmooth:null!==f&&f>0?f:null}}),totals:{rxBytes:C,txBytes:A,rxAirtime:D,txAirtime:B}}},[e,s,a,c,t,o]),u=n.useMemo(()=>{if(0===m.length)return"share"===t?100:10;let e=0;for(const t of m){const s=t.rx??0,a=t.tx??0;s>e&&(e=s),a>e&&(e=a)}const s=1.1*e;return"share"===t?s<=100?100:s<=500?100*Math.ceil(s/100):s<=1e3?200*Math.ceil(s/200):s<=5e3?500*Math.ceil(s/500):s<=1e4?1e3*Math.ceil(s/1e3):5e3*Math.ceil(s/5e3):Math.max(1,Math.ceil(s))},[m,t]),h=n.useMemo(()=>{if(null!==F&&m[F]){const e=m[F],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:lt(s),tx:lt(a),total:lt(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:lt(d.rxBytes),tx:lt(d.txBytes),total:lt(d.rxBytes+d.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of m)null===r.rx&&null===r.tx||(e+=r.rx??0,t+=r.tx??0,s++);const a=s>0?e/s:0,n=s>0?t/s:0;return{rx:`${a.toFixed(2)}%`,tx:`${n.toFixed(2)}%`,total:`${(a+n).toFixed(2)}%`,isHovered:!1}}},[F,m,d,t]),x=n.useMemo(()=>{const e=a-s,t=e/3600;return[0,.25,.5,.75,1].map(a=>{const n=new Date(1e3*(s+e*a)),r=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),l=n.toLocaleDateString([],{weekday:"short"});return{pct:a,label:t>24?`${l} ${r}`:r,mobileHidden:.25===a||.75===a}})},[s,a]),p=n.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;E("number"==typeof t?t:null)},[]),g=n.useCallback(e=>"share"===t?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toFixed(0):`${e.toFixed(0)}%`,[t]);return 0===m.length?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]}):r.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[r.jsx("div",{className:"flex items-center flex-shrink-0 text-text-secondary",style:{height:20,paddingLeft:44,paddingRight:8},children:r.jsx("div",{className:"relative w-full h-full flex items-center",children:x.map((e,t)=>r.jsxs("div",{className:"absolute flex items-center gap-0.5 sm:gap-1 type-data-xs "+(e.mobileHidden?"hidden sm:flex":""),style:{left:100*e.pct+"%",transform:0===e.pct?"translateX(0)":1===e.pct?"translateX(-100%)":"translateX(-50%)"},children:[r.jsx(i,{className:"w-2.5 h-2.5 opacity-60 hidden sm:block"}),r.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),r.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:r.jsx(Ee,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:r.jsxs(de,{data:m,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:p,onMouseLeave:()=>E(null),children:[r.jsx(ue,{strokeDasharray:"3 3",stroke:A.secondary,strokeOpacity:.3,vertical:!1}),r.jsx(he,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),r.jsx(xe,{axisLine:!1,tickLine:!1,tick:{fill:A.secondary,fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},dx:-8,width:44,tickFormatter:g,domain:[0,u]}),r.jsx(pe,{content:r.jsx(it,{mode:t})}),r.jsx(ge,{type:"linear",dataKey:"rx",name:"RX",stroke:D,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),r.jsx(ge,{type:"linear",dataKey:"tx",name:"TX",stroke:B,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),r.jsx(ge,{type:"basis",dataKey:"rxSmooth",name:"RX Avg",stroke:"var(--sys-brown)",strokeWidth:2,strokeOpacity:1,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})}),r.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-1.5 sm:mt-2",children:[r.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 text-xs font-mono pl-2 sm:pl-11",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-3 sm:w-4 h-0.5",style:{backgroundColor:D}}),r.jsx("span",{className:"text-text-secondary",children:"RX"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-3 sm:w-4 h-0.5",style:{backgroundColor:B}}),r.jsx("span",{className:"text-text-secondary",children:"TX"})]}),r.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[r.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:"var(--sys-brown)"}}),r.jsx("span",{className:"text-text-secondary",children:"Avg"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 text-right pr-1 sm:pr-2 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("span",{className:"text-xs font-medium",style:{color:D},children:"RX"}),r.jsx("span",{className:"font-bold text-lg sm:text-xl text-text-primary",children:h.rx})]}),r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("span",{className:"text-xs font-medium",style:{color:B},children:"TX"}),r.jsx("span",{className:"font-bold text-lg sm:text-xl text-text-primary",children:h.tx})]}),h.isHovered&&r.jsx("span",{className:"text-xs text-text-muted hidden sm:inline",children:"bucket"})]})]})]})}function ct(e){const{values:t,sum:s}=e;if(0===t.length)return{min:0,mean:0,median:0,p75:0,p95:0,p99:0,max:0};const a=[...t].sort((e,t)=>e-t),n=a.length,r=s/n,l=a[0],i=a[n-1],o=e=>{const t=Math.min(Math.ceil(e*n)-1,n-1);return a[Math.max(0,t)]};return{min:l,mean:r,median:n%2==0?(a[n/2-1]+a[n/2])/2:a[Math.floor(n/2)],p75:o(.75),p95:o(.95),p99:o(.99),max:i}}function Ct({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:i,radioConfig:o,sortedTypes:c,aggregateShares:C,noiseFloorAnomalies:A,showNoiseFloorOverlay:D,overlayOpacity:B=.5}){const[F,E]=n.useState(null),[m,d]=n.useState(null),u=n.useMemo(()=>(i-a)/3600,[a,i]),h=n.useCallback(e=>{d(e)},[]),x=function(e,t,s,a,r){return n.useMemo(()=>{if(0===e.length||!r)return null;const n=e.filter(e=>e.timestamp>=t&&e.timestamp<=s);if(0===n.length)return null;const l=[],i=new Map;for(const e of n){const s=e.type??e.payload_type??-1,n=H(e);let o;if(o="airtime"===a?O(e,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble}):1,n<=0)continue;const c=Math.floor((e.timestamp-t)/300),C={timestamp:e.timestamp,airtimeMs:o,byteSize:n,packetType:s,bucketIndex:c};l.push(C),i.has(c)||i.set(c,[]),i.get(c).push(C)}if(0===l.length)return null;const o=[],c=[],C=[],A=new Map;if("share"===a)for(const[,e]of i)for(const t of e)A.set(t,t.byteSize);else for(const[,e]of i){const t=e.reduce((e,t)=>e+t.airtimeMs,0)/3e5*100;let s=0;for(const a of e)a.airtimeMs>s&&(s=a.airtimeMs);for(const a of e){const e=a.airtimeMs/s*t;A.set(a,e)}}for(const e of l){const t=A.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),C.push(e.packetType))}let D=c[0],B=c[0];for(let e=1;eB&&(B=c[e]);const F=B-D||1,E=[...o].sort((e,t)=>e-t),m=E[0],d=E[E.length-1],u=Math.floor(.05*E.length),h=Math.floor(.5*E.length),x=Math.min(Math.ceil(.95*E.length),E.length-1),p=E[u],g=E[h],f=E[x],b=new Map;for(const e of o){const t=Math.round(100*e)/100;b.set(t,(b.get(t)??0)+1)}const y=b.size,v=[...b.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let j;if("share"===a)j=200;else{const e=5,t=Math.ceil(d/e)*e;j=t<=10?10:t+e}const N=new Float32Array(2*o.length),w=new Float32Array(o.length),k=new Uint8Array(o.length),M=new Float32Array(o.length);for(let e=0;e=0?C[e]:255,M[e]=c[e]}return{points:N,rawValues:w,packetTypes:k,timestamps:M,count:o.length,minTime:D,maxTime:B,minValue:0,maxValue:j,rawMinValue:m,rawMaxValue:d,unit:"%",stats:{p5:p,p50:g,p95:f,uniqueValues:y,topValues:v}}},[e,t,s,a,r])}(s,a,i,"share"===t?"share":"airtime",o),{data:p}=n.useMemo(()=>function(e,t){var s;const a=e.length;if(0===a)return{data:[],windowSize:0,windowDurationMs:0};const n=(null==(s=e[0])?void 0:s.bucketDurationMs)??1e3,r=Math.min(Math.max(5,Math.round(3e5/n)),a),l=Math.floor(r/2),i=[];let o=0,c=0;for(let C=0;Cp.map(e=>({timestamp:e.timestamp,min:e.min,max:e.max,p75:e.p75,p95:e.p95,p99:e.p99,mean:e.mean,median:e.median,average:e.average,midpoint:e.midpoint})),[p]),f=n.useMemo(()=>(null==x?void 0:x.maxValue)?x.maxValue:"share"===t?200:10,[x,t]),b=n.useCallback(e=>{E(e)},[]),y=n.useMemo(()=>{if(null===F||!p[F])return null;const e=p[F];let t;t=u>=168?75:u>=72?35:u>=24?15:u>=3?10:5;const s=60*t/2,a=e.timestamp;return{start:a-s,end:a+s}},[F,p,u]),v=n.useMemo(()=>{if(null===F||!p[F]||!y)return null;const e=p[F].time,{start:a,end:n}=y,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:et(e.typeNum)}))};const l=new Map,i=new Map;let C=0,A=0;for(const t of r){const e=`TYPE_${t.type??t.payload_type??-1}`;if(l.set(e,(l.get(e)??0)+1),C++,o){const s=O(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble});i.set(e,(i.get(e)??0)+s),A+=s}}const D=c.map(e=>{let s;return s="airtime"===t?A>0?(i.get(e.key)??0)/A:0:C>0?(l.get(e.key)??0)/C:0,{key:e.key,label:e.label,value:s,color:et(e.typeNum)}});return{timestamp:p[F].timestamp,timeLabel:e,items:D}},[F,p,y,s,c,t,o]);if(0===p.length)return r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]});const j=(null==v?void 0:v.timeLabel)??null;return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",children:[r.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:r.jsx(Je,{data:g,maxValue:f,onHover:b,scatterData:x,noiseFloorAnomalies:A,showNoiseFloorOverlay:D,overlayOpacity:B,highlightedType:m,hoveredTimeRange:y,timeRangeHours:u,yAxisMode:"share"===t?"share":"airtime"})}),j&&r.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-bg-elevated/90 rounded text-xs text-accent-secondary font-mono pointer-events-none",children:j})]}),r.jsx(tt,{sortedTypes:c,highlightedType:m,onTypeHover:h,aggregateShares:C,hoverData:v})]})}const At=new class{constructor(){a(this,"buckets",new Map),a(this,"lastProcessedTimestamp",0),a(this,"processedPacketCount",0),a(this,"cacheKey",null),a(this,"bucketDuration",60),a(this,"bucketDurationMs",6e4)}getBuckets(e,t,s,a){const n={startTs:t,endTs:s,radioConfigHash:this.hashRadioConfig(a)};return this.isCacheValid(n)?this.processPackets(e,t,s,a,!1):(this.invalidate(n),this.processPackets(e,t,s,a,!0)),this.toBucketDataArray(t,s)}processPackets(e,t,s,a,n){const r=Math.ceil((s-t)/this.bucketDuration);let l=0;for(const i of e){const e=i.timestamp;if(e=s)continue;if(!n&&e<=this.lastProcessedTimestamp)continue;const o=Math.min(Math.floor((e-t)/this.bucketDuration),r-1),c=this.buckets.get(o)??{total:0,totalAirtime:0};c.total+=1,c.totalAirtime+=O(i,{spreadingFactor:a.sf,bandwidthHz:a.bw,codingRate:a.cr,preambleLength:a.preamble}),this.buckets.set(o,c),e>this.lastProcessedTimestamp&&(this.lastProcessedTimestamp=e),l++}this.processedPacketCount+=l}toBucketDataArray(e,t){const s=t-e,a=Math.ceil(s/this.bucketDuration),n=s/3600,r=[];for(let l=0;l24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),i=this.buckets.get(l)??{total:0,totalAirtime:0};r.push({timestamp:t,time:a,total:i.total,totalAirtime:i.totalAirtime,bucketDurationMs:this.bucketDurationMs})}return r}isCacheValid(e){return!!this.cacheKey&&this.cacheKey.startTs===e.startTs&&this.cacheKey.endTs===e.endTs&&this.cacheKey.radioConfigHash===e.radioConfigHash}invalidate(e){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=e}hashRadioConfig(e){return`${e.sf}-${e.bw}-${e.cr}-${e.preamble}`}clear(){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=null}getStats(){return{bucketCount:this.buckets.size,processedPackets:this.processedPacketCount,lastTimestamp:this.lastProcessedTimestamp,cacheKey:this.cacheKey}}};function Dt({mode:e,onChange:t}){return r.jsxs("div",{className:"toggle-group toggle-group-sm",children:[r.jsx("button",{onClick:()=>t("share"),className:"toggle-group-item "+("share"===e?"active":""),children:"Total"}),r.jsx("button",{onClick:()=>t("airtime"),className:"toggle-group-item "+("airtime"===e?"active":""),children:"Airtime"})]})}function Bt({smoothing:e,onChange:t}){return r.jsxs("div",{className:"toggle-group toggle-group-sm",children:[r.jsx("button",{onClick:()=>t("stats"),className:"toggle-group-item "+("stats"===e?"active":""),title:"Statistics view (scatter plot)",children:r.jsx(C,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("trend"),className:"toggle-group-item "+("trend"===e?"active":""),title:"Trend line chart",children:r.jsx(A,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("raw"),className:"toggle-group-item "+("raw"===e?"active":""),title:"No smoothing (raw values)",children:r.jsx(D,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("zlema"),className:"toggle-group-item "+("zlema"===e?"active":""),title:"Light smoothing",children:r.jsx(B,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"Moderate smoothing",children:r.jsx(F,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"Heavy smoothing",children:r.jsx(E,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"Ultra smoothing",children:r.jsx(m,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap)",children:r.jsx(d,{className:"w-3.5 h-3.5"})})]})}function Ft({enabled:e,onChange:t,anomalyCount:s=0,showTuning:a=!1,onTuningChange:n}){return r.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[e&&n&&r.jsx("button",{onClick:()=>n(!a),className:"toggle-group toggle-group-sm "+(a?"active":""),title:a?"Hide tuning panel":"Show tuning panel",children:r.jsx("span",{className:"toggle-group-item "+(a?"active":""),children:r.jsx(o,{className:"w-3.5 h-3.5"})})}),r.jsx("button",{onClick:()=>t(!e),className:"toggle-group toggle-group-sm "+(e?"active":""),title:e?"Hide noise floor anomalies":"Show noise floor anomalies",children:r.jsx("span",{className:"toggle-group-item "+(e?"active":""),children:r.jsx(c,{className:"w-3.5 h-3.5"})})}),s>0&&r.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-accent-danger text-white text-[10px] font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}const Et={sf:10,bw:25e4,cr:5,preamble:8};function mt(e){return I[e]??`TYPE_${e.toString(16).toUpperCase()}`}function dt(e,t){if(0===e.length)return[];const s=Math.floor((t-1)/2),a=[];for(let n=0;n=s?e[n-s]:e[0];a.push(e[n]+(e[n]-t))}return function(e,t){if(0===e.length)return[];const s=2/(t+1),a=[e[0]];for(let n=1;n{const t=Math.abs(e.length-p.current);if(0===t&&u.length>0)return;x.current&&clearTimeout(x.current);const s=t>100?50:500;return x.current=setTimeout(()=>{p.current=e.length,h(e)},s),()=>{x.current&&clearTimeout(x.current)}},[e,u.length]);const g=n.useMemo(()=>function(e,t){const s=new Map;for(const n of e){const e=n.type??n.payload_type??-1,a=O(n,{spreadingFactor:t.sf,bandwidthHz:t.bw,codingRate:t.cr,preambleLength:t.preamble}),r=s.get(e)??{count:0,airtime:0};s.set(e,{count:r.count+1,airtime:r.airtime+a})}const a=[];for(const[n,r]of s)a.push({typeNum:n,key:`TYPE_${n}`,label:mt(n),totalCount:r.count,totalAirtime:r.airtime});return a.sort((e,t)=>t.totalCount-e.totalCount)}(u,i),[u,i]),f=n.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=l/3600,C=[];for(let A=0;A24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o};for(const t of r)a.counts[t.key]=0,a.airtimes[t.key]=0;C.push(a)}for(const A of e){const e=A.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${A.type??A.payload_type??-1}`;C[r].counts[l]=(C[r].counts[l]??0)+1,C[r].total++;const o=O(A,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});C[r].airtimes[l]=(C[r].airtimes[l]??0)+o,C[r].totalAirtime+=o}for(const A of C)for(const e of r)A.shares[e.key]=A.total>0?A.counts[e.key]/A.total*100:0;return C}(u,t,s,a,i,g),[u,t,s,a,i,g]),b=n.useMemo(()=>At.getBuckets(u,t,s,i),[u,t,s,i]),y=n.useMemo(()=>g.reduce((e,t)=>e+t.totalCount,0),[g]),v=n.useMemo(()=>g.reduce((e,t)=>e+t.totalAirtime,0),[g]),{sortedTypes:j,aggregateShares:N}=n.useMemo(()=>{const e=new Map,t="share"===o?y:v;if(t>0)for(const s of g){const a="share"===o?s.totalCount:s.totalAirtime;e.set(s.key,a/t)}return{sortedTypes:[...g].sort((t,s)=>(e.get(s.key)??0)-(e.get(t.key)??0)),aggregateShares:e}},[g,y,v,o]),w=n.useMemo(()=>function(e,t,s,a="raw"){const n=function(e,t,s){if(e.length<=360)return e;const a=Math.ceil(e.length/360),n=[];for(let r=0;r0?l.counts[e.key]/l.total*100:0;n.push(l)}return n}(e,0,s),r=n.length,l=s.length,i=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;D0?(e.counts[s[t].key]??0)/e.total:0;else{let t=0;for(let a=0;a0?(e.airtimes[s[a].key]??0)/t:0}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;Dfunction(e,t){switch(t){case"zlema":return dt(e,6);case"ema":return dt(e,12);case"smooth":return dt(e,24);case"ultra":return dt(e,96);default:return e}}(e,a)),C=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;D0?c[D-1][e]:0;C[D][e]=Math.min(1,Math.max(0,c[D][e]-t))}for(let D=0;D0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;eE(e),[]),M=n.useCallback(e=>d(e),[]),S=n.useMemo(()=>{if(null===m||!w[m])return null;const e=w[m];return{timestamp:e.timestamp,timeLabel:e.time,items:j.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:et(t.typeNum)}))}},[m,w,j]),T=n.useMemo(()=>({timestamps:w.map(e=>e.timestamp),series:j.map(e=>({key:e.key,label:e.label,color:et(e.typeNum),values:w.map(t=>t[e.key]??0)}))}),[w,j]);return 0===u.length?0===e.length?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===c?r.jsx(rt,{sortedTypes:j,aggregateShares:N}):"stats"===c?r.jsx(Ct,{statsBuckets:b,mode:o,packets:u,startTs:t,endTs:s,radioConfig:i,sortedTypes:j,aggregateShares:N,noiseFloorAnomalies:C,showNoiseFloorOverlay:A,overlayOpacity:D}):"trend"===c?r.jsx(ot,{packets:u,mode:o,startTs:t,endTs:s,radioConfig:i,bucketCount:a}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"analyzer-chart-height relative flex-shrink-0",children:r.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:r.jsx(W,{timestamps:T.timestamps,series:T.series,highlightedKey:F,cursorColor:B.cursor,onHover:M})})}),r.jsx(tt,{sortedTypes:j,highlightedType:F,onTypeHover:k,aggregateShares:N,hoverData:S})]})}),ht={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},xt=[1,5,10,25,50,100,150];function pt(e,t,s,a){const n=Math.PI/180,r=(a-t)*n,l=e*n,i=s*n,o=Math.sin(r)*Math.cos(i),c=Math.cos(l)*Math.sin(i)-Math.sin(l)*Math.cos(i)*Math.cos(r);return(180*Math.atan2(o,c)/Math.PI+360)%360}function gt(e,t,s,a){const n=Math.PI/180,r=(s-e)*n,l=(a-t)*n,i=Math.sin(r/2)**2+Math.cos(e*n)*Math.cos(s*n)*Math.sin(l/2)**2;return 12742*Math.atan2(Math.sqrt(i),Math.sqrt(1-i))}const ft=[{min:10,label:"Excellent"},{min:7,label:"Very Good"},{min:4,label:"Good"},{min:1,label:"Fair+"},{min:-2,label:"Fair"},{min:-5,label:"Fair-"},{min:-8,label:"Poor"},{min:-11,label:"Bad"},{min:-1/0,label:"Critical"}];function bt(e,t){return t[Fe(e)]||"#808080"}const yt=n.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=n.useState(null),[c,C]=n.useState(new Set),[A,D]=n.useState({width:0,height:0}),[B,F]=n.useState("1x"),[E,m]=n.useState(1),d=n.useRef(null),h=n.useRef({}),x=n.useRef(null),p=n.useRef(null),g=n.useRef(E);g.current=E;const f=Ae(),b=oe(),y=De(),v=ce(),j=Be(),N=j?v.secondary:v.primary,w=j?.4:.15,k=j?.25:.08,M=j?v.primary:b.primary;n.useEffect(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:s}=t.contentRect;e>0&&s>0&&D({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&D({width:s.width,height:s.height}),()=>t.disconnect()},[]);const S=n.useMemo(()=>{const e=new Set;if(t)for(const s of t)e.add(s.hash);return e},[t]),T=n.useMemo(()=>{const e=new Map;if(t)for(const s of t)e.set(s.hash,{snr:s.avgSnr,rssi:s.avgRssi});return e},[t]),{processedNeighbors:R,maxDistance:$,totalNeighbors:P,zeroHopCount:L}=n.useMemo(()=>{const t=[];for(const[r,l]of Object.entries(e)){if(!l.latitude||!l.longitude||0===l.latitude||0===l.longitude)continue;if(!S.has(r))continue;const e=pt(s,a,l.latitude,l.longitude),n=gt(s,a,l.latitude,l.longitude),i=T.get(r);t.push({hash:r.slice(0,8),name:l.node_name||l.name||"Unknown",snr:(null==i?void 0:i.snr)??l.snr??null,rssi:(null==i?void 0:i.rssi)??l.rssi??null,bearing:e,distance:n,normalizedDistance:0,lastSeen:l.last_seen,isZeroHop:!0})}const n=1.08*(t.length>0?Math.max(...t.map(e=>e.distance)):0);return t.sort((e,t)=>(e.snr??-1/0)-(t.snr??-1/0)),{processedNeighbors:t,maxDistance:n,totalNeighbors:t.length,zeroHopCount:t.length}},[e,s,a,S,T]);n.useEffect(()=>{null==l||l({zeroHopCount:L,totalCount:P,maxDistanceKm:$})},[L,P,$]),n.useEffect(()=>{const e=ht[B],t=g.current;d.current&&cancelAnimationFrame(d.current);const s=performance.now(),a=n=>{const r=n-s,l=Math.min(r/400,1),i=(o=l)<.5?8*o*o*o*o:1-Math.pow(-2*o+2,4)/2;var o;m(t+(e-t)*i),d.current=l<1?requestAnimationFrame(a):null};return d.current=requestAnimationFrame(a),()=>{d.current&&cancelAnimationFrame(d.current)}},[B]);const z=$/E,_=n.useMemo(()=>xt.filter(e=>e<=1.1*z),[z]);n.useEffect(()=>{const e=[];for(const s of R){const t=h.current[s.hash];void 0!==t&&t!==s.lastSeen&&e.push(s.hash),h.current[s.hash]=s.lastSeen}if(0===e.length)return;queueMicrotask(()=>{C(t=>new Set([...t,...e]))});const t=setTimeout(()=>{C(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[R]);const H=0!==s&&0!==a,O=n.useMemo(()=>{const{width:e,height:t}=A,s=e/2,a=t/2,n=Math.max(10,e/2-12),r=Math.max(10,t/2-12),l=Math.max(10,n-16),i=Math.max(10,r-16);return{width:e,height:t,centerX:s,centerY:a,maxRadiusX:l,maxRadiusY:i,labelRadiusX:n,labelRadiusY:r,cornerRadius:.2*Math.min(l,i)}},[A]),{width:W,height:I,centerX:q,centerY:G,maxRadiusX:X,maxRadiusY:K,labelRadiusX:Y,labelRadiusY:U,cornerRadius:Q}=O,Z=n.useCallback((e,t=1)=>{const s=X*t,a=K*t,n=Math.min(Q*t,s,a),r=(e%360+360)%360,l=r*Math.PI/180,i=180*Math.atan2(a-n,s-n)/Math.PI;let o,c;if(r<=45-i||r>315+i){const e=Math.tan(l);o=Math.max(q-s+n,Math.min(q+s-n,q+a*e*(s/a))),c=G-a}else if(r>45-i&&r<=45+i)o=q+s-n+n*Math.sin(l),c=G-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(G-a+n,Math.min(G+a-n,G-s*e*(a/s))),o=q+s}else if(r>135-i&&r<=135+i)o=q+s-n+n*Math.sin(l),c=G+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(q-s+n,Math.min(q+s-n,q-a*e*(s/a))),c=G+a}else if(r>225-i&&r<=225+i)o=q-s+n+n*Math.sin(l),c=G+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(G-a+n,Math.min(G+a-n,G-s*e*(a/s))),o=q-s}else o=q-s+n+n*Math.sin(l),c=G-a+n-n*Math.cos(l);return{x:o,y:c}},[q,G,X,K,Q]),J=n.useCallback((e,t)=>{const s=Z(e,1);return{x:q+(s.x-q)*t,y:G+(s.y-G)*t}},[Z,q,G]),ee=n.useCallback(e=>({N:{x:q,y:G-U},S:{x:q,y:G+U},E:{x:q+Y,y:G},W:{x:q-Y,y:G},NE:{x:q+Y,y:G-U},SE:{x:q+Y,y:G+U},SW:{x:q-Y,y:G+U},NW:{x:q-Y,y:G-U}}[e]),[q,G,Y,U]),te=n.useCallback(e=>{const t=X*e,s=K*e,a=Math.min(Q*e,t,s),n=q-t,r=q+t,l=G-s,i=G+s;return[`M ${n+a} ${l}`,`L ${r-a} ${l}`,`Q ${r} ${l} ${r} ${l+a}`,`L ${r} ${i-a}`,`Q ${r} ${i} ${r-a} ${i}`,`L ${n+a} ${i}`,`Q ${n} ${i} ${n} ${i-a}`,`L ${n} ${l+a}`,`Q ${n} ${l} ${n+a} ${l}`,"Z"].join(" ")},[q,G,X,K,Q]),se=n.useCallback(e=>{o(e)},[]),ae=n.useCallback(e=>{F(e)},[]),ne=n.useCallback(e=>$<=0?0:e/$*E,[$,E]),re=e=>`${e}km`,le=n.useMemo(()=>{const e=_.map(e=>{const t=e/$*E;return{km:e,scale:t,labelY:G-K*t*.71}}).filter(e=>e.scale<=1.05&&e.scale>=.02).sort((e,t)=>t.km-e.km),t=[];for(const s of e)t.some(e=>Math.abs(e.labelY-s.labelY)<28)||t.push(s);return t},[_,$,E,G,K]),ie=A.width>0&&A.height>0;return H?0===P?r.jsxs("div",{ref:x,className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[r.jsx(u,{className:"w-8 h-8 mb-2 opacity-50"}),r.jsx("p",{children:"No nodes with location data"})]}):r.jsxs("div",{ref:x,className:"relative h-full w-full flex overflow-hidden",children:[r.jsx("div",{ref:p,className:"relative flex-1 min-w-0 h-full",children:ie&&r.jsxs("svg",{width:W,height:I,className:"absolute inset-0 z-0",children:[r.jsxs("defs",{children:[r.jsx("style",{children:"\n @keyframes neighbor-blink-scale {\n 0%, 100% {\n transform: scale(1);\n opacity: 0;\n }\n 50% {\n transform: scale(1.3);\n opacity: 0.8;\n }\n }\n .neighbor-blink-ring {\n transform-origin: center;\n animation: neighbor-blink-scale 600ms ease-out forwards;\n }\n "}),r.jsx("clipPath",{id:"radar-clip",children:r.jsx("path",{d:te(1)})})]}),_.map(e=>{const t=ne(e);if(t>1.05||t<.02)return null;const s=le.some(t=>t.km===e),a=q+X*t*.71,n=G-K*t*.71;return r.jsxs("g",{children:[r.jsx("path",{d:te(t),fill:"none",stroke:N,strokeOpacity:w,strokeWidth:1}),s&&r.jsx("text",{x:a+4,y:n-2,textAnchor:"start",dominantBaseline:"auto",className:"fill-text-secondary",fontSize:10,fontFamily:V,children:re(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?q:"E"===e?q+X:q-X,a=t?"N"===e?G-K:G+K:G;return r.jsx("line",{x1:q,y1:G,x2:s,y2:a,stroke:N,strokeOpacity:w,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=ee(e);return r.jsx("line",{x1:q,y1:G,x2:t.x,y2:t.y,stroke:N,strokeOpacity:k,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=ee(e),s="E"===e?"end":"W"===e?"start":"middle",a="N"===e?"hanging":"S"===e?"auto":"middle";return r.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:M,fontSize:16,fontWeight:600,fontFamily:V,"aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=ee(e),s="NE"===e||"SE"===e?"end":"start",a="NE"===e||"NW"===e?"hanging":"auto";return r.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:M,fontSize:16,fontWeight:600,fontFamily:V,"aria-hidden":"true",children:e},e)}),r.jsx("circle",{cx:q,cy:G,r:5,fill:y.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),r.jsx("g",{clipPath:"url(#radar-clip)",children:R.map(e=>{const t=$>0?e.distance/$*E:0;if(t>1)return null;const{x:s,y:a}=J(e.bearing,t),n=null!==e.snr?bt(e.snr,f):"#808080",l=(null==i?void 0:i.hash)===e.hash,o=c.has(e.hash);return r.jsxs("g",{role:"img","aria-label":`${e.name}: ${e.distance.toFixed(1)}km ${e.bearing.toFixed(0)}°`,children:[o&&r.jsx("circle",{cx:s,cy:a,r:10.5,fill:"none",stroke:"rgba(255,255,255,0.9)",strokeWidth:2,className:"neighbor-blink-ring"}),l&&r.jsx("circle",{cx:s,cy:a,r:10.5,fill:n,opacity:.3}),r.jsx("circle",{cx:s,cy:a,r:l?7:5,fill:n,stroke:"rgba(0,0,0,0.5)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>se(e),onMouseLeave:()=>se(null)})]},e.hash)})})]})}),r.jsx("div",{className:"flex flex-col h-full items-stretch gap-1 py-2 pl-2 flex-shrink-0",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(e=>r.jsx("button",{onClick:()=>ae(e),"aria-pressed":B===e,className:"flex flex-1 items-center justify-center px-1.5 text-xs font-medium rounded transition-colors "+(B===e?"bg-accent-primary/20 text-accent-primary":"bg-white/5 text-text-secondary hover:bg-white/10 hover:text-text-primary"),children:e},e))}),i&&r.jsxs("div",{className:"absolute bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm pointer-events-none z-10 shadow-xl",style:{left:"50%",bottom:8,transform:"translateX(-50%)"},children:[r.jsx("div",{className:"font-medium text-text-primary",children:i.name}),r.jsx("div",{className:"text-text-secondary text-xs font-mono",children:i.hash}),null!==i.snr?r.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"SNR:"})," ",r.jsxs("span",{className:"tabular-nums",style:{color:bt(i.snr,f)},children:[i.snr.toFixed(1)," dB"]}),r.jsxs("span",{className:"text-text-secondary ml-1",children:["(",(Ce=i.snr,(null==(Fe=ft.find(e=>Ce>=e.min))?void 0:Fe.label)??"Critical"),")"]})]})}):r.jsx("div",{className:"text-xs text-text-secondary mt-1",children:"No SNR data"}),r.jsxs("div",{className:"flex gap-3 text-xs",children:[r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"Distance:"})," ",r.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.distance.toFixed(2)," km"]})]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"Bearing:"})," ",r.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):r.jsxs("div",{ref:x,className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[r.jsx(u,{className:"w-8 h-8 mb-2 opacity-50"}),r.jsx("p",{children:"Local node coordinates not configured"}),r.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]});var Ce,Fe});function vt(e,t){if(0===e.length)return 0;const s=t/100*(e.length-1),a=Math.floor(s),n=Math.ceil(s);return a===n?e[a]:e[a]+(e[n]-e[a])*(s-a)}const jt=n.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const{theme:i}=q(),[o,c]=n.useState(!0),C=n.useMemo(()=>{if(0===t.length)return null;const e=Math.min(...t),s=Math.max(...t),a=t.reduce((e,t)=>e+t,0)/t.length,n=[...t].sort((e,t)=>e-t);return{min:e,max:s,avg:a,p5:vt(n,5),p95:vt(n,95)}},[t]);n.useEffect(()=>{null==s||s(C)},[C]);const A=n.useCallback(()=>{c(e=>!e)},[]),{heatmapData:D,xLabels:B,yLabels:F}=n.useMemo(()=>{if(0===e.length||0===t.length||!C)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(C.p95-C.p5||1);s=C.p5-e,a=C.p95+e}else{const e=.1*(C.max-C.min||1);s=C.min-e,a=C.max+e}const n=a-s,r=e[0],l=e[e.length-1]-r||1,i=new Float32Array(2*e.length);for(let o=0;o{const e=m.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:s}=t.contentRect;e>0&&s>0&&u({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&u({width:s.width,height:s.height}),()=>t.disconnect()},[]),n.useEffect(()=>{const e=E.current;if(!e||!D||0===d.width)return;const t=e.getContext("2d");if(!t)return;const{width:s,height:a}=d,n=window.devicePixelRatio||1;e.width=s*n,e.height=a*n,e.style.width=`${s}px`,e.style.height=`${a}px`,t.scale(n,n),t.clearRect(0,0,s,a);const r=getComputedStyle(document.documentElement).getPropertyValue("--accent-primary").trim(),{r:l,g:i,b:o}=(e=>{const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\)/);if(t)return{r:Math.round(255*parseFloat(t[1])),g:Math.round(255*parseFloat(t[2])),b:Math.round(255*parseFloat(t[3]))};const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:{r:250,g:189,b:47}})(r),{points:c,count:C}=D,A=Math.max(3,Math.min(8,s/C*4));t.globalCompositeOperation="source-over";for(let D=0;Dr.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),r.jsxs("div",{ref:m,className:"absolute overflow-hidden",style:{left:32,right:0,top:0,bottom:20},children:[r.jsx("svg",{className:"absolute inset-0 w-full h-full",preserveAspectRatio:"none","aria-hidden":"true",children:[0,25,50,75,100].map(e=>r.jsx("line",{x1:"0",y1:`${e}%`,x2:"100%",y2:`${e}%`,stroke:"var(--chart-grid-line, rgba(255,255,255,0.06))",strokeDasharray:"3 3"},e))}),r.jsx("canvas",{ref:E,className:"absolute inset-0 w-full h-full","aria-hidden":"true"}),r.jsx("button",{type:"button",onClick:A,className:"absolute bottom-1 right-1 p-1.5 rounded bg-tooltip-bg/80 hover:bg-tooltip-bg active:bg-tooltip-bg transition-colors touch-manipulation",title:o?"Show full range (min/max)":"Show trimmed range (P5-P95)","aria-label":o?"Expand to show full data range":"Shrink to show trimmed percentile range","aria-pressed":!o,children:o?r.jsx(h,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"}):r.jsx(x,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"})})]}),r.jsx("div",{className:"absolute left-0 right-0 bottom-0",style:{left:32,height:20},"aria-hidden":"true",children:B.map((e,t)=>r.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums absolute top-1",style:{left:`${e.pos}%`,transform:"translateX(-50%)"},children:e.label},t))})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No noise floor data available"})}),Nt={repeater:"var(--accent-primary)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function wt(e){if(e.contact_type){const t=e.contact_type.toLowerCase();if("repeater"===t||"rep"===t)return"repeater";if("room server"===t||"room_server"===t||"room"===t||"server"===t)return"room_server";if("companion"===t||"client"===t||"cli"===t)return"companion"}return e.is_repeater?"repeater":"companion"}const kt=n.memo(function({neighbors:e}){const t=n.useMemo(()=>{const t={repeater:0,companion:0,room_server:0};for(const a of Object.values(e)){const e=wt(a);t[e]=(t[e]||0)+1}const s=Object.values(t).reduce((e,t)=>e+t,0);return{items:[{label:"Repeaters",count:t.repeater,percent:0,color:Nt.repeater},{label:"Companions",count:t.companion,percent:0,color:Nt.companion},{label:"Room Servers",count:t.room_server,percent:0,color:Nt.room_server}].map(e=>({...e,percent:s>0?e.count/s*100:0})).filter(e=>e.count>0).sort((e,t)=>t.count-e.count),total:s}},[e]);return 0===t.total?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted type-body-sm",children:"No neighbors discovered yet"}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:t.items.map(e=>r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"type-data-sm text-text-secondary",children:e.label}),r.jsxs("span",{className:"type-data-sm text-text-secondary tabular-nums",children:[e.count," ",r.jsxs("span",{className:"text-text-secondary/60",children:["(",e.percent.toFixed(0),"%)"]})]})]}),r.jsx("div",{className:"h-2.5 bg-bg-elevated overflow-hidden",children:r.jsx("div",{className:"h-full transition-all duration-500 ease-out",style:{width:`${e.percent}%`,backgroundColor:e.color,minWidth:e.count>0?"4px":"0"}})})]},e.label))}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border-subtle",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Total Nodes"}),r.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function Mt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=n.useRef(null),[o,c]=n.useState(!1),[C,A]=n.useState(!1);n.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{const t=e.isIntersecting;A(t),t&&c(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>{t.disconnect()}},[s]);const D=C||a&&o;return r.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:D?e:r.jsx("div",{className:"h-full w-full flex items-center justify-center text-text-muted/50",children:r.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const St={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-accent-primary"},Tt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-accent-primary/10"};function Rt(){const e=G(),t=X(),[s,a]=n.useState(null),l=n.useCallback((e,t)=>{a({prefix:e,candidateHashes:t})},[]),i=n.useCallback(()=>{a(null)},[]);if(!t)return r.jsxs(be,{children:[r.jsx(we,{icon:r.jsx(p,{}),title:"Prefix Conflicts",largeTitle:!0}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-text-secondary",children:[r.jsx(g,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{className:"type-data-xs",children:"No topology data available"}),r.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const o=(c=e.avgConfidence)>=.9?"excellent":c>=.7?"good":c>=.5?"fair":"poor";var c;const C=(A=e.collisionRate)<=10?"excellent":A<=25?"good":"poor";var A;const D="poor"===o||"poor"===C?"poor":"fair"===o||"fair"===C?"fair":"good"===o||"good"===C?"good":"excellent",B="excellent"===D||"good"===D?f:b;return r.jsxs(be,{className:"flex flex-col overflow-hidden",children:[r.jsx(we,{icon:r.jsx(p,{}),title:"Prefix Conflicts",largeTitle:!0,actions:r.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Tt[D]}`,children:[r.jsx(B,{className:`w-3.5 h-3.5 ${St[D]}`}),r.jsx("span",{className:`type-data-xs font-medium ${St[D]}`,children:"excellent"===D?"Excellent":"good"===D?"Good":"fair"===D?"Fair":"Needs Attention"})]})}),r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-1.5 sm:gap-2 py-3 sm:py-4",children:[r.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2",title:"Total unique 2-character prefixes observed in packet paths.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.totalPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm text-text-secondary mt-0.5 sm:mt-1",children:"Prefixes"})]}),r.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.unambiguousPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm text-text-secondary mt-0.5 sm:mt-1",children:"Unique"})]}),r.jsxs("div",{className:"flex flex-col items-center cursor-help rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2 "+(e.collisionPrefixes>0?"bg-accent-primary/15":"bg-white/5"),title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-primary"),style:{letterSpacing:"-0.05em"},children:e.collisionPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm mt-0.5 sm:mt-1 "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-secondary"),children:"Conflicts"})]})]}),e.highCollisionPrefixes.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"type-data-xs text-text-secondary mb-1.5",children:"Problem Prefixes"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:e.highCollisionPrefixes.map(({prefix:e,candidateCount:t,candidateHashes:s})=>r.jsxs("button",{type:"button",onClick:()=>l(e,s),className:"inline-flex items-center gap-0.5 group",title:`${t} candidates - click to explore`,children:[r.jsx(je,{children:e}),r.jsxs("span",{className:"text-text-muted type-data-xs group-hover:text-text-secondary transition-colors",children:["×",t]})]},e))})]}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&r.jsx("div",{className:"flex-1 flex items-center",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(f,{className:"w-3.5 h-3.5 text-signal-excellent"}),r.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Confidence"}),r.jsxs("span",{className:`data-box ${St[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Collisions"}),r.jsxs("span",{className:`data-box ${St[C]}`,children:[e.collisionRate.toFixed(1),"%"]})]})]})]}),r.jsx(Ne,{isOpen:!!s,prefix:(null==s?void 0:s.prefix)||"",candidateHashes:(null==s?void 0:s.candidateHashes)||[],onClose:i})]})}function $t({icon:e,label:t,value:s,sublabel:a,highlight:n,tooltip:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 "+(l?"cursor-help":""),title:l,children:[r.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-0",children:[r.jsx("span",{className:"icon-xs text-icon-widget flex-shrink-0",children:e}),r.jsx("span",{className:"type-body-sm text-text-secondary truncate",children:t})]}),r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 flex-shrink-0",children:[r.jsx("span",{className:"data-box",style:n?{"--data-box-color":"var(--accent-primary)"}:void 0,children:s}),a&&r.jsx("span",{className:"type-data-xs text-text-secondary hidden sm:inline",children:a})]})]})}function Pt(){const e=K(),t=Y().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:n,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:C,echolocationEdgesInferred:A}=e,D=s>0?((s-a)/s*100).toFixed(1):"0",B=s>0?(n/s*100).toFixed(1):"0",F=l+i,E=F>0||o>0,m=c>0||A>0;return r.jsxs(be,{children:[r.jsx(we,{title:"Path Decoder",icon:r.jsx(y,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),r.jsxs(ke,{children:[r.jsxs("div",{children:[r.jsx($t,{icon:r.jsx(v,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${D}%`,sublabel:`of ${s.toLocaleString()} paths`,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),r.jsx($t,{icon:r.jsx(j,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${B}%`,sublabel:"adapted",tooltip:"How often real traffic patterns improved our predictions over geography alone. Higher values mean the decoder is learning your mesh's actual behavior — which routes are preferred, which nodes are most active."})]}),E&&r.jsxs("div",{className:"mt-3",children:[r.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),r.jsxs("div",{children:[r.jsx($t,{icon:r.jsx(N,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:F.toLocaleString(),sublabel:l>0?`(${l} TRACE)`:void 0,tooltip:"TRACE/PATH packets from distant nodes share their routing tables. This reveals connections we can't directly observe — mapping parts of the mesh we don't touch."}),r.jsx($t,{icon:r.jsx(w,{className:"w-3.5 h-3.5"}),label:"Remote Links",value:o.toLocaleString(),highlight:o>0,tooltip:"Node-to-node connections discovered from route reports. These links exist outside our RF range but help complete the topology picture."})]})]}),m&&r.jsx($t,{icon:r.jsx(k,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:C>0?`(${C} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),t>0&&r.jsx($t,{icon:r.jsx(M,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Ghost Repeaters",value:t,highlight:!0,tooltip:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map."})]})]})}function Lt(){var e,t,s,a,i,o,c,C,A,D,B,F,E,m,d,h,x;const p=U(),g=Q(),f=Z(),b=J(),y=ee(),v=te(),j=se(),N=ae(),[w,k]=n.useState([]),[M,$]=n.useState(null),[P,L]=n.useState(null),[z,_]=n.useState(!0),[H,O]=n.useState(null),[W,I]=n.useState(()=>{const e=localStorage.getItem("statistics-view-mode");return"share"===e||"airtime"===e?e:"airtime"});n.useEffect(()=>{localStorage.setItem("statistics-view-mode",W)},[W]);const[V,q]=n.useState(()=>{const e=localStorage.getItem("statistics-smoothing-mode");return["raw","ema","zlema","smooth","ultra","mosaic","stats","trend"].includes(e)?e:"trend"});n.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",V)},[V]);const[G,X]=n.useState(!1),[K,Y]=n.useState(!1),[oe,ce]=n.useState(Oe),[Ce,Ae]=n.useState(.5),De=n.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6}[j]??3),[j]),Be=ne[De].hours,Fe=60*Be,Ee=ne[De],me=le(Be),de=v.isBackgroundLoading,ue=n.useCallback(e=>{N({0:1,1:2,2:3,3:4,4:5,5:6,6:7}[e]??4)},[N]),he=n.useMemo(()=>{var e;if(!(null==(e=null==p?void 0:p.config)?void 0:e.radio))return null;const t=p.config.radio;return{sf:t.spreading_factor??10,bw:t.bandwidth??25e4,cr:t.coding_rate??5,preamble:t.preamble_length??8}},[null==(t=null==(e=null==p?void 0:p.config)?void 0:e.radio)?void 0:t.spreading_factor,null==(a=null==(s=null==p?void 0:p.config)?void 0:s.radio)?void 0:a.bandwidth,null==(o=null==(i=null==p?void 0:p.config)?void 0:i.radio)?void 0:o.coding_rate,null==(C=null==(c=null==p?void 0:p.config)?void 0:c.radio)?void 0:C.preamble_length]);n.useEffect(()=>{!async function(){var e;O(null);try{const t=await re(Be);t.success&&(null==(e=t.data)?void 0:e.history)&&k(t.data.history)}catch(t){O(t instanceof Error?t.message:"Failed to load chart data")}finally{_(!1)}}()},[Be]);const xe=n.useMemo(()=>72===Be?6e5:168===Be?18e5:336===Be?36e5:3e5,[Be]),pe=n.useCallback(async()=>{var e;try{const t=await re(Be);t.success&&(null==(e=t.data)?void 0:e.history)&&k(t.data.history)}catch{}},[Be]);ie(pe,xe,!0,!0);const ge=n.useMemo(()=>0===w.length?{timestamps:[],values:[]}:{timestamps:w.map(e=>e.timestamp),values:w.map(e=>e.noise_floor_dbm)},[w]),je=n.useMemo(()=>{if(w.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Oe,...t};if(e.length<10)return{anomalies:[],thresholds:Ie([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=Ie(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=We(r,s.baselinePercentile),i=We(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let C=null,A=0;for(const D of o)if(D.noise_floor_dbm>l&&D.noise_floor_dbme+t,0)/C.values.length):(C.values.length>=s.minSequenceLength&&c.push(C),C={startTs:D.timestamp,endTs:D.timestamp,values:[D.noise_floor_dbm],timestamps:[D.timestamp],rollingAvg:D.noise_floor_dbm})}else C={startTs:D.timestamp,endTs:D.timestamp,values:[D.noise_floor_dbm],timestamps:[D.timestamp],rollingAvg:D.noise_floor_dbm};else C&&C.values.length>=s.minSequenceLength&&c.push(C),C=null;return C&&C.values.length>=s.minSequenceLength&&c.push(C),0===c.length?{anomalies:[],thresholds:n,totalSamples:e.length,anomalySamples:A,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:A}}:{anomalies:c.map(e=>{const t=Math.max(...e.values),s=e.values.reduce((e,t)=>e+t,0)/e.values.length;return{startTs:e.startTs,endTs:e.endTs,peakValue:t,avgValue:s,severity:Ve(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:A,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:A}}}(w,oe);return{anomalies:e.anomalies,debug:e.debug}},[w,oe]),Ne=je.anomalies,ke=n.useMemo(()=>{const e=(null==p?void 0:p.neighbors)??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!g.has(e)))},[null==p?void 0:p.neighbors,g]),Te=n.useMemo(()=>{const e=Date.now()/1e3-3600*Be;return Object.fromEntries(Object.entries(ke).filter(([,t])=>t.last_seen>=e))},[ke,Be]),Re=n.useMemo(()=>{const e=60*Fe/me,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*Fe,end:s}},[Fe,me]);return r.jsxs(ye,{children:[r.jsx(ve,{title:"Statistics",icon:r.jsx(S,{}),controls:r.jsx(fe,{ranges:ne,selectedIndex:De,onSelect:ue,isPending:de})}),H&&r.jsx(be,{className:"border border-accent-red/50 bg-accent-red/10",children:r.jsx("p",{className:"text-accent-red",children:H})}),G&&K&&r.jsxs(be,{className:"border border-accent-purple/30 bg-glass-surface/50",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),r.jsxs("span",{className:"type-data-xs text-text-muted",children:["(",Ee.label,")"]})]}),r.jsx("button",{onClick:()=>ce(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(oe.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:oe.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Baseline"}),r.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(D=null==(A=je.debug)?void 0:A.baselineCutoff)?void 0:D.toFixed(1))??"—"," dBm"]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Spike"}),r.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(F=null==(B=je.debug)?void 0:B.spikeCutoff)?void 0:F.toFixed(1))??"—"," dBm"]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Mid-band"}),r.jsx("span",{className:"ml-2 type-data-sm text-accent-purple",children:(null==(E=je.debug)?void 0:E.midBandSamples)??0})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Anomalies"}),r.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:Ne.length})]})]}),r.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[oe.useAbsoluteThresholds?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",oe.baselineDbm," dBm)"]}),r.jsx("input",{type:"range",min:"-120",max:"-60",value:oe.baselineDbm,onChange:e=>ce(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",oe.spikeDbm," dBm)"]}),r.jsx("input",{type:"range",min:"-100",max:"-20",value:oe.spikeDbm,onChange:e=>ce(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),r.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",oe.minSequenceLength,")"]}),r.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),r.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*Ce),"%)"]}),r.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:Ce,onChange:e=>Ae(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",oe.baselinePercentile,")"]}),r.jsx("input",{type:"range",min:"1",max:"50",value:oe.baselinePercentile,onChange:e=>ce(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",oe.spikePercentile,")"]}),r.jsx("input",{type:"range",min:"50",max:"99",value:oe.spikePercentile,onChange:e=>ce(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),r.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",oe.minSequenceLength,")"]}),r.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),r.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*Ce),"%)"]}),r.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:Ce,onChange:e=>Ae(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}),r.jsxs("div",{className:"mt-4 p-3 bg-glass-elevated rounded-lg",children:[r.jsx("div",{className:"type-micro mb-1",children:"Config output"}),r.jsxs("div",{className:"type-data-sm text-status-success",children:[oe.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${oe.baselineDbm}, spikeDbm: ${oe.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${oe.baselinePercentile}, spikePercentile: ${oe.spikePercentile}`,", mergeGapSeconds: ",oe.mergeGapSeconds,", minSequenceLength: ",oe.minSequenceLength,", similarityToleranceDbm: ",oe.similarityToleranceDbm]})]})]})]}),de&&r.jsx(Me,{template:"auto",children:r.jsx(be,{className:"border border-accent-primary/30 bg-accent-primary/5",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex h-3 w-3",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-accent-primary"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"type-body-sm text-text-primary",children:["Loading ",Ee.label," data..."]}),v.loadProgress&&r.jsxs("p",{className:"type-data-xs text-text-muted mt-0.5",children:[v.loadProgress.loaded.toLocaleString()," packets (",v.loadProgress.percent,"%)"]})]})]})})}),z?r.jsx(Me,{template:"auto",children:r.jsx(be,{className:"text-center py-12",children:r.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading statistics..."})})}):r.jsxs(r.Fragment,{children:[r.jsx(Me,{template:"hero-auto",children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(l,{}),title:"Packet Analyzer",badge:Ee.label,largeTitle:!0,stackActionsOnMobile:!0,actions:r.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&r.jsx(Ft,{enabled:G,onChange:X,anomalyCount:Ne.length,showTuning:K,onTuningChange:Y}),r.jsx(Bt,{smoothing:V,onChange:q}),r.jsx(Dt,{mode:W,onChange:I})]})}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ut,{packets:b,startTs:Re.start,endTs:Re.end,bucketCount:me,radioConfig:he??void 0,mode:W,smoothing:V,noiseFloorAnomalies:Ne,showNoiseFloorOverlay:G,overlayOpacity:Ce})})]})})}),r.jsxs(Me,{template:"panel",children:[r.jsx(Se,{span:12,md:6,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(u,{}),title:"Link Quality",badge:Ee.label,largeTitle:!0,actions:P?r.jsxs("div",{className:"flex items-center gap-3 type-data-xs text-text-muted",children:[r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.zeroHopCount})," nbr"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.totalCount})," obs"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.maxDistanceKm.toFixed(0)})," km"]})]}):null}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(yt,{neighbors:Te,quickNeighbors:f,localLat:(null==(d=null==(m=null==p?void 0:p.config)?void 0:m.repeater)?void 0:d.latitude)??0,localLon:(null==(x=null==(h=null==p?void 0:p.config)?void 0:h.repeater)?void 0:x.longitude)??0,onStatsChange:L})})})]})})}),r.jsx(Se,{span:12,md:6,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(T,{}),title:"Network Composition",badge:Ee.label,largeTitle:!0}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(kt,{neighbors:Te})})})]})})})]}),r.jsxs(Me,{template:"panel",children:[r.jsx(Se,{span:12,md:6,children:r.jsx(Rt,{})}),r.jsx(Se,{span:12,md:6,children:r.jsx(Pt,{})})]}),r.jsx(Me,{template:"panel",children:r.jsx(Se,{span:12,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(R,{}),title:"RF Noise Floor",largeTitle:!0,stackActionsOnMobile:!0,actions:M?r.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["min ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.min.toFixed(0)})]}),r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["avg ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.avg.toFixed(0)})]}),r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["max ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.max.toFixed(0)})]}),r.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})]}):r.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(jt,{timestamps:ge.timestamps,values:ge.values,onStatsChange:$})})})]})})})})]})]})}export{Lt as default}; +var e,t,s=Object.defineProperty,a=(e,t,a)=>((e,t,a)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a)(e,"symbol"!=typeof t?t+"":t,a);import{r as n,j as r,au as l,D as i,b2 as o,a3 as c,b3 as C,b4 as A,b5 as D,b6 as B,b7 as F,b8 as E,b9 as m,ba as d,bb as u,bc as h,bd as x,av as p,be as g,bf as f,at as b,ay as y,bg as v,bh as j,bi as N,aJ as w,W as k,q as M,o as S,aX as T,E as R}from"./vendor-react-C341c8YC.js";import{a7 as $,a8 as P,a9 as L,W as z,aa as _,ab as H,ac as O,ad as W,x as I,F as V,ae as q,af as G,ag as X,Y as K,ah as Y,e as U,h as Q,f as Z,u as J,p as ee,r as te,j as se,q as ae,ai as ne,k as re,aj as le}from"./index-BJEgt3tp.js";import{u as ie}from"./usePolling-CtRLadGa.js";import{b as oe,c as ce,a as Ce,d as Ae,e as De,f as Be,s as Fe}from"./useThemeColors-AeHMyThq.js";import{R as Ee,w as me,L as de,C as ue,X as he,Y as xe,T as pe,u as ge}from"./recharts-6XUQYgRA.js";import{T as fe}from"./TimeRangeSelector-DGCfekAv.js";import{a as be,P as ye,b as ve}from"./PageLayout-CnF5SScd.js";import{D as je}from"./DataBox-CRX76VsB.js";import{C as Ne}from"./CollisionExplorerModal-DTnzK_xA.js";import{C as we,a as ke}from"./Card-2pQSGkKC.js";import{R as Me,C as Se}from"./Grid-BOO-7ObJ.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./maplibre-gl-Bk5DsYkB.js";import"./BasemapLayer-S9Ush6Hh.js";const Te={acton:{discrete:["#260D40","#2B1345","#2F194B","#342152","#382657","#3C2C5C","#403261","#443766","#483E6C","#4C4371","#504876","#544D7B","#57527F","#5D5884","#625C88","#685F8A","#6E618C","#74628D","#7B638D","#81638E","#88648E","#8E648E","#95658F","#9D658F","#A4668F","#AB6690","#B26790","#BB6992","#C26B94","#C86F97","#CD749B","#D07AA0","#D382A7","#D688AC","#D88FB2","#D995B8","#DB9CBD","#DEA4C4","#DFABC9","#E1B1CE","#E3B7D3","#E5BED8","#E6C5DE","#E8CBE2","#E9D0E6","#EBD6EA","#ECDBEE","#EDE1F3","#EFE6F6","#F0EAFA"],categorical:["#260D40","#F0EAFA","#A76690","#DDA1C2","#585380","#7D638E","#E8CAE1","#CF789E","#403261","#4C4371","#ECDBEE","#69608B","#E3B6D2","#D78CB0","#91648F","#BE6A92","#342152","#EAD3E8","#524B79","#73628D","#463A69","#605B86","#E5C0DA","#D382A7","#C86F97","#86648E","#EEE3F4","#DA97B9","#9B658F","#B26790","#2D1749","#E0ACCA","#3A2959","#8B648E","#311C4D","#EBD7EB","#EDDFF1","#AC6790","#A1668F","#6E618C","#E6C5DE","#78628D","#433665","#DEA7C6","#81638E","#554F7C","#B86891","#3D2D5D","#4F4775","#EFE7F7","#E9CEE4","#D27DA3","#2A1244","#655D89","#C36C94","#E1B1CE","#493F6D","#5C5783","#CC739A","#DB9CBD","#D892B4","#D587AB","#96658F","#E4BBD6","#362455","#4E4573","#7F638E","#D37FA5","#E1AECC","#382657","#EBD9ED","#DFA9C8","#A4668F","#8E648E","#99658F","#675F8A","#B56891","#BB6992","#E5BED8","#E2B4D0","#D07AA0","#71618C","#E6C2DC","#AA6690","#625C88","#EDE1F3","#E8CCE3","#AF6790","#CA7199","#C16B93","#453867","#57517E","#84638E","#4B416F","#E7C7DF","#423463","#514977","#3E2F5F","#544D7B","#93658F"]},bam:{discrete:["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"],categorical:["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"]},bamako:{discrete:["#003B47","#023C46","#053E45","#083F43","#0A4141","#0D4340","#0F443E","#12463C","#16483A","#194A38","#1C4D36","#204F34","#235132","#28542F","#2C572C","#305A2A","#355C27","#395F24","#3F6321","#44661E","#49691A","#4E6D17","#537014","#5A7410","#5F780D","#657C09","#6A7F05","#718302","#788501","#7F8700","#858800","#8C8A00","#948C01","#9B8E04","#A1920B","#A89713","#AE9C1B","#B7A225","#BEA82E","#C5AD37","#CBB341","#D2B84D","#D9BF5B","#DEC567","#E4CA73","#E9D07E","#EFD58A","#F5DB97","#FAE0A3","#FFE5AD"],categorical:["#003B47","#FFE5AD","#61790B","#B4A022","#245231","#406420","#898900","#DDC464","#0F443E","#EFD58A","#CAB23F","#194A38","#748401","#506E16","#9E9108","#315A29","#083F43","#A99815","#948C01","#6A7F05","#BFA930","#7F8700","#14473B","#1E4E35","#F7DD9C","#2A562D","#043D45","#597411","#E6CC77","#385F25","#48691B","#D4BB51","#0B4241","#8F8A00","#44661E","#1B4C37","#547113","#6F8203","#12463D","#998E03","#27542F","#4C6B18","#A4940E","#2E582B","#355C27","#B9A529","#215033","#EAD181","#FBE1A5","#C5AD37","#3C6122","#848800","#063E44","#E2C86E","#D9BF5B","#CFB648","#16493A","#798600","#023C46","#667C08","#5D770E","#0D433F","#AE9C1B","#F3D993","#094042","#A69611","#8C8A00","#053E45","#0C4240","#365E26","#6D8004","#9C8F05","#4A6A1A","#D6BD56","#B19E1F","#F9DFA0","#647B0A","#2F592A","#10453D","#818800","#C7AF3B","#46681C","#0E443F","#265330","#174A39","#335B28","#5B750F","#778501","#5F780D","#E8CF7C","#718302","#F1D78E","#978D02","#F5DB97","#204F34","#AC9A18","#29552E","#A1920B","#B7A225","#033C46"]},bamo:{discrete:["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"],categorical:["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"]},batlow:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144D62","#165162","#195662","#1C5A62","#205E61","#26635F","#2C665D","#33695A","#3A6C57","#416F53","#4A724E","#52744A","#5A7745","#627941","#6A7B3D","#747E38","#7D8134","#868330","#8F862D","#9B892B","#A58B2C","#AF8D2E","#B98F32","#C29037","#CD923F","#D69446","#DE964F","#E69858","#ED9A62","#F39E70","#F8A17B","#FAA587","#FCA993","#FDAC9E","#FDB1AB","#FDB4B6","#FDB8C0","#FDBCCB","#FCBFD6","#FCC4E3","#FBC8EF","#FACCFA"],categorical:["#011959","#FACCFA","#828231","#226061","#F29D6D","#4D734D","#114360","#C09036","#FDB4B4","#DD954D","#356A59","#FCBFD6","#175262","#677B3E","#A18A2B","#0D315D","#FCA890","#FBC6E8","#2B655E","#B18D2F","#5A7745","#FDAEA2","#CF9340","#0F3B5F","#E9995C","#FDBAC4","#416F53","#91862D","#1B5962","#08255B","#747E38","#134B61","#F9A380","#8A842F","#0E365E","#124761","#154F62","#E39754","#7B8034","#1E5D62","#99882C","#195662","#0B2B5C","#FDB7BC","#C8913B","#FCC3DF","#EE9B64","#A98C2C","#FDB1AB","#FDBCCD","#FBC9F1","#051F5A","#F6A077","#607942","#FDAB9A","#477150","#3B6D56","#B98F32","#26635F","#537549","#D69446","#6D7C3B","#30685C","#103F60","#FBA689","#BD8F34","#CB923E","#EB9A60","#FDB8C0","#FBC7EC","#F09C69","#8E852E","#FDBBC9","#7F8133","#031C5A","#114160","#FDAC9E","#5D7844","#FCA995","#185462","#787F36","#A58B2C","#0A285C","#9D892B","#33695A","#0D335E","#637A40","#165062","#124561","#205E61","#144D62","#1D5B62","#0C2E5D","#D9954A","#3E6E55","#AD8C2D","#F49F72","#868330","#B58E30","#577647"]},batlowk:{discrete:["#04050A","#0A0D15","#0F141E","#121B29","#152233","#18293D","#1C3146","#21384F","#274156","#2C485B","#314E5E","#36535F","#3B575F","#405C5E","#445F5D","#49625B","#4D6558","#526756","#586B52","#5E6E4F","#63724B","#6A7548","#717845","#797D41","#81813E","#8A853B","#938839","#9F8D38","#A99139","#B3943B","#BE973E","#C89A43","#D39D4C","#DB9F54","#E2A15D","#E8A366","#EEA570","#F3A77C","#F6A986","#F8AC91","#FAAE9A","#FCB1A4","#FDB4B0","#FDB7B9","#FDBAC3","#FDBDCD","#FDC1D8","#FCC5E4","#FBC8EF","#FACCFA"],categorical:["#04050A","#FDC0D6","#787C41","#38555F","#E5A160","#536855","#AF933A","#FAAE9A","#1A2E43","#FDB6B7","#294458","#455F5C","#63724B","#CD9B47","#91883A","#F3A77E","#111A27","#F7AB8D","#FDBBC5","#FCB2AA","#D99E52","#A18E38","#4C6459","#21384F","#3F5B5E","#152335","#0C1019","#EEA570","#5B6D50","#6C7647","#314E5E","#85823D","#BE973E","#7E7F3F","#FBB0A2","#49625B","#576A53","#0F151F","#2D495B","#DFA059","#727944","#FDBDCD","#253E54","#EAA368","#C69942","#3C585F","#998B38","#677449","#F1A678","#F9AC92","#141F2F","#1D3248","#506657","#090C13","#A99139","#5F6F4E","#35525F","#435D5D","#FDB8BD","#F5A984","#B5953B","#FDB5B2","#17273B","#D39D4C","#8C853B","#9D8C38","#415C5E","#1F354B","#33505E","#FCB1A6","#101723","#3E595F","#121C2B","#757B43","#06080F","#FCB3AE","#3A565F","#274156","#61704D","#88843C","#2B475A","#FDBED1","#6A7548","#596C51","#192B3F","#6F7845","#233B51","#C99A45","#F0A574","#DC9F55","#2F4B5D","#47615C","#F6AA88","#FDB9C1","#C29840","#4A635A","#FAAD96","#81813E","#7B7E40","#E7A264"]},batloww:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144C62","#165062","#185562","#1B5962","#1F5D62","#246261","#2A665F","#30695D","#366C5A","#3D7056","#467352","#4E764E","#56794A","#5E7C46","#667F42","#70823D","#798539","#828936","#8C8C33","#989032","#A29433","#AD9738","#B79B3F","#C19E48","#CBA154","#D3A45E","#D9A669","#DFA872","#E4AA7C","#E9AC88","#EEAF91","#F2B39C","#F6B9A8","#F9C0B5","#FCCAC4","#FED3CF","#FFDBDA","#FFE3E2","#FFEAEA","#FFF2F2","#FFF8F8","#FFFEFE"],categorical:["#FFFEFE","#011959","#7E8737","#205F61","#E7AB84","#497451","#114360","#FED1CD","#BF9D46","#637E44","#9E9233","#FFEAEA","#0D315D","#326B5C","#F5B7A6","#165162","#D7A564","#0F3B5F","#1A5862","#3D7056","#FFF5F5","#FFDFDD","#FAC3BA","#134A61","#08255B","#70823D","#EEB094","#56794A","#E0A874","#8E8D33","#28655F","#AF9839","#CBA154","#EBAD8B","#1D5C62","#051F5A","#124761","#FFE5E4","#B79B3F","#A79535","#386D59","#5C7B47","#185562","#DBA76D","#F8BDAF","#FFF0F0","#246261","#F2B39C","#868A35","#4F774D","#E4AA7C","#2D685E","#77853A","#FED8D6","#103F60","#FFFAF9","#968F32","#D1A35C","#144E62","#FCCAC4","#437254","#698040","#0E365E","#0B2B5C","#C59F4C","#30695D","#1C5A62","#A29433","#407155","#FFDBDA","#0C2E5D","#F7BAAA","#E5AB80","#175362","#828936","#1F5D62","#BB9C42","#E9AC88","#FFF7F7","#3A6E58","#9A9132","#8A8B34","#4C754F","#FFEDED","#D9A669","#144C62","#266460","#FDCDC9","#FCC6BF","#FFE2E1","#FFFCFC","#7B8639","#2B675E","#155062","#5F7C45","#F9C0B5","#356C5A","#F3B5A1","#EDAF8F","#FED5D2"]},berlin:{discrete:["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"],categorical:["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"]},bilbao:{discrete:["#4C0001","#54070B","#5B0E13","#64161A","#6B1D20","#712227","#77282D","#7D2E34","#84343B","#8A3A41","#8F4047","#94464B","#984C4F","#9B5253","#9D5754","#9E5C56","#A06057","#A16458","#A26959","#A36D5A","#A4715B","#A5745B","#A6785C","#A77C5D","#A8805E","#A9845F","#AA875F","#AC8C60","#AD9061","#AE9463","#AF9864","#B19D68","#B3A36E","#B6A975","#B8AD7E","#BBB287","#BDB590","#C0B99A","#C2BCA3","#C4BFAA","#C6C2B2","#C8C5B9","#CBCAC1","#CFCEC9","#D5D4D1","#DBDBDA","#E3E3E2","#EDEDED","#F6F6F6","#FFFFFF"],categorical:["#4C0001","#F8F8F8","#A9815E","#984D50","#BEB794","#AF9965","#CCCAC3","#78292F","#A26A59","#9F5D56","#64161A","#B6AA77","#C4C0AC","#A6765C","#8A3A41","#AC8C60","#DDDDDB","#A16358","#C7C5B7","#B3A16B","#A4705A","#6E2024","#EAEAE9","#92434A","#BAB185","#9C5554","#AD9262","#580B10","#813137","#C1BCA1","#AA865F","#D2D2CE","#A77C5D","#D7D7D4","#BCB48D","#B4A571","#C0B99A","#9E5955","#AB8960","#A6795C","#A36D5A","#8E3F46","#85353C","#A16758","#732529","#CAC7BD","#F1F1F0","#520509","#AC8F61","#5E1115","#C6C2B2","#E3E3E2","#691B1F","#B8AD7E","#95484D","#AE9663","#B19D68","#A5735B","#A06057","#9A5152","#A87E5D","#7D2E34","#A9835E","#C3BEA6","#CFCEC9","#A46E5A","#F4F4F4","#DADAD8","#B29F69","#EDEDED","#BBB289","#9D5754","#AF9764","#904148","#994F51","#B3A36E","#A87F5E","#A26859","#AC8D61","#BDB590","#AA875F","#A77A5D","#AB8A60","#A4715B","#611418","#BFB897","#E6E6E6","#9B5353","#D5D4D1","#974A4F","#C8C6BA","#A16558","#9F5E56","#76272C","#67191D","#8C3C43","#B9AF82","#C3BFA9","#B5A874","#4F0205"]},broc:{discrete:["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"],categorical:["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"]},broco:{discrete:["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"],categorical:["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"]},buda:{discrete:["#B301B3","#B30BAE","#B314AA","#B31CA6","#B323A2","#B3289F","#B32E9D","#B4339A","#B53998","#B63E96","#B84394","#B94892","#BB4C91","#BD528F","#BE568D","#C05B8C","#C15F8A","#C36389","#C46987","#C66D86","#C77184","#C97583","#CA7982","#CB7E80","#CD837F","#CE877E","#CF8B7D","#D0917B","#D1957A","#D29979","#D49E78","#D5A277","#D6A776","#D7AC75","#D8B073","#D9B572","#DAB971","#DCBF70","#DDC36F","#DEC86E","#DFCC6C","#E0D16B","#E2D76A","#E4DC69","#E6E168","#E9E667","#EDEC67","#F3F366","#F9F966","#FFFF66"],categorical:["#B301B3","#FFFF66","#CD857E","#BC4E90","#DBBD70","#C56A87","#B32F9C","#E3DB69","#D4A177","#EDEC67","#D1937B","#B73F95","#C05C8B","#DFCB6D","#C97882","#B31CA6","#D8AE74","#E7E368","#DAB572","#B311AC","#D39A79","#C36389","#C77184","#B53798","#E1D36B","#BE558E","#B94793","#CB7E80","#CF8C7C","#DDC46E","#B326A0","#F6F566","#D6A875","#DAB971","#C66E86","#E2D76A","#B32B9E","#B317A9","#B4339A","#BA4B91","#C46788","#C2608A","#B309AF","#D49E78","#B63B97","#BD528F","#DCC06F","#EAE767","#FAFA66","#D2977A","#F1F066","#D0907C","#CE897D","#C87483","#CC827F","#D5A576","#B321A3","#E5DF68","#B84394","#D9B273","#E0CF6C","#CA7B81","#DEC86E","#BF598C","#D7AB75","#E6E168","#D1957A","#CC8080","#D39C78","#E0CD6C","#CD847F","#B63D96","#C87384","#C66C86","#F8F866","#D49F78","#D9B473","#DAB772","#BF578D","#CB7D81","#CF8A7D","#B32D9D","#D08E7C","#DBBB71","#C2628A","#E2D56A","#DCBF70","#BC508F","#C46987","#C05B8C","#DFCA6D","#DDC26F","#C15E8B","#D7AD74","#F3F366","#DEC66E","#D5A377","#B31AA7","#BA4992","#CE877E"]},bukavu:{discrete:["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"],categorical:["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"]},cork:{discrete:["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"],categorical:["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"]},corko:{discrete:["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"],categorical:["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"]},davos:{discrete:["#00054A","#010E51","#041459","#081C61","#0C2368","#102A6F","#133075","#17377C","#1C3F83","#204588","#244C8D","#295291","#2D5895","#335F98","#38649A","#3C699C","#416E9D","#46729D","#4C779D","#517B9C","#567F9B","#5A829A","#5F8598","#658996","#698C94","#6E8F92","#739290","#78968D","#7D998C","#829D8A","#88A089","#8DA488","#95AA87","#9BAF88","#A3B489","#ABBB8C","#B4C190","#BFCA96","#C9D29E","#D2D9A6","#DBE0AF","#E3E7B8","#EBEDC4","#F0F1CD","#F4F4D6","#F7F7DE","#FAF9E6","#FCFCF0","#FDFDF7","#FEFEFE"],categorical:["#00054A","#FDFDF4","#688B94","#2D5895","#B2C08F","#E8EBC0","#87A089","#133075","#4B769D","#5A829A","#204588","#76958E","#D0D8A4","#99AD88","#F6F6DB","#3C699C","#081C61","#031256","#1A3B7F","#537C9C","#A4B68A","#C1CC98","#7E9A8B","#FAFAE8","#356199","#0E266B","#DEE3B3","#274F90","#6F9091","#618697","#8FA588","#F0F1CD","#43709D","#1D4084","#47739D","#F3F4D4","#658996","#567F9B","#17367A","#FCFBEE","#4F799D","#C9D29E","#93A987","#39659B","#D8DEAB","#ABBB8C","#739290","#B9C693","#F8F8E1","#234A8C","#112B70","#7A978D","#9EB188","#315C97","#829D8A","#05175B","#010C50","#3F6C9D","#0B2065","#5D8499","#2A5392","#8BA388","#6B8D93","#EDEFC7","#E3E7B8","#22488A","#638897","#122E73","#00094D","#AEBD8D","#4D789D","#CDD5A1","#5F8598","#58819A","#071A5E","#0C2368","#18387D","#91A787","#37639A","#EBEDC4","#F2F2D0","#FBFBEB","#74938F","#2F5A96","#335F98","#809B8B","#BDC995","#49759D","#719191","#9BAF88","#F7F7DE","#1B3E82","#A8B88B","#849E89","#557E9B","#E6E9BC","#45719D","#1E4386","#96AB87","#89A188"]},devon:{discrete:["#2C1A4C","#2B1E51","#2B2356","#2A295B","#2A2D60","#293265","#29376A","#283B6E","#274174","#27467A","#274C7F","#275186","#28568C","#2A5C95","#2D609C","#3064A3","#3468AA","#396BB1","#3F70B9","#4774C0","#4F79C6","#597DCC","#6382D1","#6F88D7","#798CDB","#8290DF","#8C95E2","#969AE6","#9E9EE9","#A6A3EB","#ACA7ED","#B1ACEF","#B7B1F0","#BBB5F1","#BFB9F2","#C3BEF3","#C7C2F4","#CCC7F4","#D0CCF5","#D4D0F6","#D8D4F7","#DCD9F8","#E1DEF9","#E5E3FA","#E9E7FB","#EDECFB","#F2F0FC","#F7F6FD","#FBFAFE","#FFFFFF"],categorical:["#2C1A4C","#F8F8FE","#758AD9","#C6C0F3","#28568C","#29376A","#AAA5ED","#DEDCF8","#3D6EB7","#EBE9FB","#9197E4","#3063A2","#274579","#577CCB","#D2CEF6","#2A285A","#BAB3F1","#B2ADEF","#F2F0FC","#274E82","#2A2F62","#CCC7F4","#9E9EE9","#4875C1","#C0BAF2","#2B5D98","#3669AD","#2B2154","#E4E2FA","#8290DF","#D8D4F7","#6784D3","#283E71","#C9C4F4","#BDB7F1","#DBD8F8","#283A6D","#4F79C6","#A4A2EB","#EEEDFC","#CFCBF5","#E8E5FA","#5F80CF","#4272BC","#B6B0F0","#2B1D50","#AEA9EE","#275287","#2A2B5E","#989BE7","#293366","#27497D","#8A94E1","#295A92","#3266A7","#F5F4FD","#7B8DDC","#274174","#2D609C","#2B2558","#6F88D7","#E1DEF9","#3A6CB2","#D5D1F6","#C3BEF3","#2E629F","#3165A4","#8D95E3","#3468AA","#DAD6F7","#D1CDF5","#9B9CE8","#275084","#B8B2F0","#27477B","#6382D1","#4573BF","#A2A0EA","#F7F6FD","#C7C2F4","#F3F2FD","#274376","#8692E0","#2B1F52","#CAC6F4","#ACA7ED","#E3E0F9","#F0EEFC","#E6E4FA","#386AB0","#2C1C4E","#6B86D5","#28396B","#283C6F","#2A5C95","#2A2D60","#BEB9F2","#C2BCF2","#7E8FDD","#3F70B9"]},fes:{discrete:["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"],categorical:["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"]},glasgow:{discrete:["#361338","#3B1434","#401530","#45172C","#491828","#4D1924","#511B21","#561C1D","#5B1E18","#602014","#662210","#6B260B","#6F2B07","#723203","#743802","#743E01","#754300","#744900","#744F01","#745402","#735905","#725F0B","#716413","#70691E","#6E6E27","#6C7231","#6B763A","#697B46","#677F4F","#658359","#648763","#628B6C","#618F78","#609381","#60978A","#619B94","#659F9D","#6CA5A8","#74A9B0","#7DADB8","#86B1BF","#8EB4C6","#99B9CE","#A1BCD5","#AABFDB","#B2C3E1","#BBC6E7","#C6CBF0","#D0CFF7","#DBD3FF"],categorical:["#361338","#DBD3FF","#6D702B","#69A3A5","#702D06","#A0BBD3","#638968","#521B20","#745101","#84B0BE","#754001","#5F9587","#BBC6E7","#612013","#45172C","#687D4A","#726210","#618F78","#4B1926","#3E1532","#629C96","#658359","#CACCF3","#76AAB2","#6B763A","#744900","#6A250C","#ADC1DD","#735905","#92B6C9","#591D1A","#743702","#70681C","#4F1A23","#754400","#6D2909","#60998E","#41162F","#744D00","#745503","#B4C3E2","#697A42","#7DADB8","#628C70","#8BB3C3","#561C1D","#D2D0F9","#99B9CE","#3A1435","#6F6C23","#743B01","#60927F","#662210","#648661","#659F9D","#678051","#725E0A","#481829","#6FA6AB","#6C7332","#5D1E17","#A6BED8","#C2C9ED","#723203","#716617","#68240E","#6F6A20","#C6CBF0","#79ABB5","#72600D","#754200","#43162D","#67A1A1","#6B7536","#5F1F15","#735B07","#571C1B","#72A8AF","#744F01","#BEC8EA","#381337","#8EB4C6","#628B6C","#677E4D","#60917B","#639E9A","#4A1827","#A3BDD6","#3C1433","#743901","#632112","#B7C5E5","#4D1924","#65845D","#618E74","#609483","#9CBAD1","#46172A","#87B1C1","#6D712F"]},grayc:{discrete:["#000000","#090909","#111111","#171717","#1C1C1C","#212121","#252525","#2A2A2A","#303030","#343434","#393939","#3D3D3D","#424242","#474747","#4B4B4B","#505050","#545454","#585858","#5D5D5D","#616161","#656565","#696969","#6D6D6D","#717171","#757575","#797979","#7D7D7D","#818181","#858585","#898989","#8E8E8E","#929292","#979797","#9C9C9C","#A1A1A1","#A6A6A6","#ABABAB","#B1B1B1","#B6B6B6","#BCBCBC","#C1C1C1","#C7C7C7","#CECECE","#D5D5D5","#DBDBDB","#E2E2E2","#E8E8E8","#F1F1F1","#F8F8F8","#FFFFFF"],categorical:["#070707","#F9F9F9","#777777","#454545","#AEAEAE","#909090","#292929","#5F5F5F","#D1D1D1","#9E9E9E","#525252","#E4E4E4","#6C6C6C","#BFBFBF","#1A1A1A","#373737","#848484","#595959","#222222","#B6B6B6","#A6A6A6","#3E3E3E","#7D7D7D","#666666","#969696","#8A8A8A","#4B4B4B","#DADADA","#C8C8C8","#313131","#717171","#131313","#EFEFEF","#C4C4C4","#A2A2A2","#424242","#878787","#252525","#2D2D2D","#4F4F4F","#3B3B3B","#808080","#1E1E1E","#BBBBBB","#AAAAAA","#EAEAEA","#696969","#7A7A7A","#DFDFDF","#636363","#565656","#B2B2B2","#0E0E0E","#9A9A9A","#5C5C5C","#747474","#F3F3F3","#333333","#6E6E6E","#D5D5D5","#8D8D8D","#939393","#494949","#CCCCCC","#171717","#BDBDBD","#575757","#C1C1C1","#404040","#828282","#E2E2E2","#151515","#1C1C1C","#0B0B0B","#9C9C9C","#858585","#2F2F2F","#B4B4B4","#888888","#242424","#272727","#3C3C3C","#B0B0B0","#353535","#545454","#5B5B5B","#393939","#D7D7D7","#A4A4A4","#A8A8A8","#959595","#767676","#646464","#989898","#444444","#474747","#111111","#F6F6F6","#ECECEC","#4D4D4D"]},hawaii:{discrete:["#8C0273","#8E0D6E","#8F1569","#901D63","#91235F","#91285A","#922D56","#933252","#94384D","#943D4A","#954246","#964742","#964C3F","#97523B","#985638","#985C34","#996131","#9A662E","#9B6C2A","#9B7226","#9C7823","#9C7E20","#9D841E","#9D8C1C","#9C921C","#9B991D","#9AA021","#97A828","#94AE30","#91B439","#8CB942","#88BE4C","#82C359","#7EC663","#79CA6E","#74CE79","#70D183","#6AD591","#66D89C","#62DCA7","#60DFB2","#5FE2BD","#61E6CA","#67E9D5","#6FEBDE","#7AEEE7","#87EFEE","#98F1F5","#A6F1F9","#B3F2FD"],categorical:["#8C0273","#B3F2FD","#9C951C","#6CD48C","#964D3E","#8ABC48","#9B6D29","#66E8D3","#922E55","#9C801F","#87EFEE","#995D34","#7BC969","#901D63","#60DEB0","#96AA2B","#943D4A","#975439","#82C359","#5FE4C2","#9AA021","#73CE7B","#65D99E","#954544","#9D8A1C","#8E126B","#91B439","#9DF1F7","#73ECE2","#91265C","#9C7724","#9A652E","#93364F","#922A59","#996131","#9D851D","#9D901C","#9A692C","#68D695","#902160","#9B9A1E","#985836","#9B7226","#933252","#77CC72","#9C7B21","#954147","#8D0A6F","#93AF32","#62DCA7","#92F0F3","#8F1867","#7DEEE8","#97513C","#6CEBDB","#61E6CA","#A8F2FA","#964941","#7FC661","#86BF50","#98A526","#70D183","#5FE1B9","#8DB840","#94394D","#9C7923","#8F1569","#985A35","#60E0B4","#9A6B2A","#91245E","#97A828","#9B7425","#6AD591","#95AD2E","#5FE2BD","#60E5C6","#953F48","#933054","#63E7CF","#84C154","#8D0671","#82EFEB","#9B9D1F","#99A323","#88BE4C","#6ED288","#6FEBDE","#9A672D","#91285A","#75CD76","#995F32","#68E9D7","#9B7028","#61DDAB","#943B4B","#933450","#8DF0F0","#8F1A65","#81C45D"]},imola:{discrete:["#1A33B3","#1C37B1","#1E3AAF","#203EAD","#2242AB","#2345AA","#2548A8","#274CA6","#2950A4","#2A53A3","#2C56A1","#2E599F","#2F5D9E","#32609B","#346499","#366797","#386A95","#3B6C92","#3E708F","#41738C","#44768A","#467987","#4A7C85","#4E8082","#518480","#56887E","#5A8C7D","#5F927B","#64967A","#689B79","#6DA078","#72A576","#78AB75","#7DB074","#82B572","#87BA71","#8CBF70","#93C66E","#98CB6D","#9ED06C","#A4D66A","#ACDB69","#B5E268","#BFE767","#C8EB67","#D3F066","#DDF466","#EAF866","#F5FB66","#FFFF66"],categorical:["#1A33B3","#FFFF66","#54867F","#305E9D","#91C36F","#3F718E","#2549A8","#BDE667","#70A377","#2B53A2","#376896","#80B373","#A3D56B","#DDF466","#203EAD","#487B86","#62947A","#2D59A0","#88BB71","#5B8D7D","#CDED66","#4E8082","#EEF966","#33639A","#284EA5","#44768A","#2344AA","#AFDE69","#3B6C92","#78AB75","#1D39B0","#99CC6D","#699C79","#3D6F90","#2C56A1","#2F5B9E","#5E917B","#4B7D84","#9ED06C","#1F3CAE","#C4EA67","#84B772","#274CA6","#D5F066","#2951A4","#74A776","#578A7E","#2446A9","#1C36B1","#A9D96A","#95C86E","#467888","#2141AC","#7CAF74","#356598","#B5E268","#66987A","#396A94","#F7FC66","#8CBF70","#E6F666","#32609B","#518380","#41738C","#6DA078","#6B9E78","#B9E468","#7AAD74","#528580","#32629B","#86B971","#3C6E91","#5C8F7C","#C8EB67","#ACDB69","#D1EF66","#E2F566","#97CA6D","#1B35B2","#1C37B0","#2345AA","#2F5D9E","#1F3DAE","#457789","#3A6B93","#598B7D","#D9F266","#346499","#386995","#A6D76A","#366797","#274DA6","#56887E","#A1D36B","#42748B","#7EB173","#72A576","#477987","#4C7F83","#F2FB66"]},lajolla:{discrete:["#191900","#1E1B02","#221C05","#271E08","#2C200B","#31220E","#362411","#3C2614","#442817","#4B2B1B","#532D1F","#5B3023","#633328","#6E362D","#783932","#813C37","#8B3F3B","#96423F","#A24543","#AD4746","#B74A48","#C04D49","#C9514B","#D1564C","#D75C4D","#DB634E","#DD694F","#E0714F","#E17750","#E37D50","#E48351","#E58951","#E79052","#E89652","#E99C52","#EAA253","#EBA853","#EDAF54","#EEB555","#F0BC57","#F1C25A","#F3CA5F","#F5D369","#F7DA74","#F9E282","#FBE890","#FCEF9F","#FDF5B0","#FEFABE","#FFFECB"],categorical:["#191900","#FFFECB","#D85F4D","#ECAC54","#653329","#F7D971","#A44544","#E58751","#362411","#E1744F","#C44E4A","#E99A52","#4B2B1B","#833D38","#F1C159","#FCEF9F","#271E08","#FEF7B6","#402716","#D0554C","#FAE587","#E79052","#EFB655","#B54947","#201C04","#E37D50","#743830","#DD694F","#EBA353","#94413E","#572F21","#F4CD61","#2E210C","#FDF3AB","#32220F","#241D06","#F5D369","#7B3B34","#1D1B02","#F0BC57","#5E3125","#F8DF7C","#512D1E","#CA514B","#E48251","#E68C51","#EA9E53","#E89552","#BC4C49","#6C362C","#EDB154","#9C4341","#E27950","#FBEA93","#3B2513","#FEFBC0","#452918","#EBA853","#F2C75C","#8B3F3B","#DB644E","#AD4746","#DF6E4F","#D55A4D","#2B200A","#783932","#E79352","#D75C4D","#FEF9BB","#EDAF54","#E0714F","#7F3C36","#613227","#F7DC77","#C7504B","#F1C45A","#30210D","#F4D065","#1E1B03","#FAE78D","#F9E282","#DA614E","#392412","#4E2C1D","#E99C52","#EFB956","#221C05","#EBA553","#FDF5B0","#984240","#E38050","#8F403D","#542E20","#ECAA54","#E68E51","#70372E","#DE6C4F","#B94A48","#291F09","#1B1A01"]},lapaz:{discrete:["#1A0C64","#1C1368","#1E196D","#202071","#212675","#222B79","#23317D","#253681","#263C85","#274189","#29478C","#2A4C8F","#2C5192","#2E5795","#305C98","#32609A","#35659C","#386A9E","#3C70A0","#3F74A1","#4379A2","#487DA3","#4D81A3","#5386A4","#588AA3","#5E8EA3","#6591A2","#6C95A1","#7398A0","#7A9A9E","#809D9D","#879F9B","#90A199","#97A397","#9EA596","#A5A795","#ADAA95","#B7AD96","#BFB199","#C8B69C","#D2BBA2","#DAC1A8","#E4C9B2","#EBCFBB","#F1D5C4","#F5DBCD","#F9E1D6","#FBE8E1","#FDEDEA","#FEF2F3"],categorical:["#1A0C64","#FEF2F3","#5B8BA3","#B3AC96","#2C5292","#3C70A0","#EACEB9","#859E9C","#24327E","#6F96A1","#33619A","#202071","#D0BAA0","#9BA496","#F9E1D6","#4A7FA3","#284289","#90A199","#FCEAE5","#1D176B","#37699D","#F3D8C8","#A7A895","#5285A4","#7A9A9E","#2F5A97","#4278A2","#263A84","#6591A2","#C1B299","#DEC3AB","#222978","#2A4B8E","#5688A4","#D7BEA6","#FDEEEC","#608EA3","#EFD3C0","#A1A696","#6A94A1","#FBE6DD","#ADAA95","#F6DDCF","#4E82A3","#2E5695","#3A6D9F","#C8B69C","#1C1268","#232D7B","#3F74A1","#467BA3","#1E1C6E","#7F9C9D","#BAAF97","#253681","#315E99","#29478C","#E4C9B2","#74989F","#273E87","#212575","#95A398","#8AA09A","#35659C","#2B4F91","#23307C","#E7CBB5","#F1D5C4","#2B4D90","#202373","#588AA3","#D3BCA3","#5487A4","#447AA2","#6792A2","#24347F","#253882","#ECD0BD","#879F9B","#305C98","#E1C6AF","#1E196D","#5D8DA3","#AAA995","#386B9E","#487DA3","#77999F","#F7DFD3","#BEB098","#1F1E70","#325F99","#4176A2","#F4DACB","#4C80A3","#2D5494","#8DA099","#6C95A1","#FAE3DA","#FDECE8","#B7AD96"]},lipari:{discrete:["#031326","#05192F","#062038","#092844","#0C2E4D","#103557","#163C5F","#1E4368","#294B70","#345075","#3E5578","#47587A","#4F5B7B","#575C7A","#5D5D79","#635E78","#695E76","#6E5F75","#765F73","#7C6071","#826070","#89606E","#90616C","#98616A","#A06268","#A86266","#B06364","#BA6462","#C36660","#CB685F","#D46B5E","#DB705F","#E27760","#E77E63","#E98567","#EA8D6B","#EA946F","#E89C75","#E7A279","#E6A87E","#E5AF84","#E5B58A","#E6BD92","#E7C49A","#EACCA3","#EDD3AD","#F0DBB7","#F5E5C4","#F9EDCF","#FDF5DA"],categorical:["#031326","#FDF5DA","#A56267","#525B7A","#E99B74","#785F72","#DA6F5E","#183E61","#E7C398","#8D616D","#365176","#092844","#655E77","#E98466","#BF6561","#F0DBB7","#E5AD82","#B26364","#EBCFA7","#5C5D79","#061D35","#25486D","#0E3353","#EA906D","#98616A","#E37861","#E5B88C","#826070","#CD685F","#6E5F75","#45587A","#F6E8C9","#E7A37A","#615E78","#E77E63","#D46B5E","#9F6268","#E99570","#93616B","#87606E","#7D6071","#F3E1C0","#575C7A","#0B2D4B","#2D4D72","#E6A87E","#E9C99F","#FAEED1","#1E4368","#EA8A69","#B86462","#6A5E76","#AB6365","#735F74","#DF735F","#E5B287","#13385A","#05182D","#E6BD92","#3E5578","#EDD5AF","#07223C","#C6665F","#4C5A7A","#E8A077","#B56363","#FBF1D6","#A26267","#E6C095","#0A2A48","#F8EBCD","#EACCA3","#AE6364","#7A5F72","#635E78","#E98768","#041629","#715F74","#ECD2AB","#A86266","#8A606E","#96616B","#545C7A","#EFD8B3","#F5E5C4","#9B6169","#F2DEBB","#765F73","#6C5F75","#294B70","#22466B","#E89D76","#E88165","#BC6461","#E6A67C","#85606F","#C36660","#1B4064","#D06A5E","#103557"]},lisbon:{discrete:["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"],categorical:["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"]},managua:{discrete:["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"],categorical:["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"]},navia:{discrete:["#031327","#041930","#051E3A","#052546","#062B50","#06315A","#073764","#083E6D","#0B4578","#0E4C80","#115286","#15588B","#195E8E","#1E6491","#216991","#246D91","#27718F","#2A748E","#2D788C","#307A8A","#337D89","#368087","#398385","#3C8683","#3F8981","#428C7F","#468F7D","#4A937A","#4E9678","#529A76","#579E73","#5BA271","#62A86E","#67AD6B","#6EB269","#76B768","#7FBD68","#8CC56A","#98CB6F","#A4D176","#B1D67F","#BCDB89","#C9E096","#D3E3A1","#DCE7AC","#E3EAB6","#EAEDBF","#F1F0CA","#F7F2D2","#FCF4D9"],categorical:["#031327","#FCF4D9","#408A80","#87C269","#1B608F","#59A072","#073966","#D1E39F","#2F798B","#EAEDBF","#052546","#266F90","#6BB06A","#0E4D81","#AED57D","#4C947A","#378186","#DFE8B0","#337D89","#2A748E","#14578A","#051C36","#9ACC70","#0A4374","#468F7D","#529A76","#F4F1CD","#062F56","#C1DC8D","#206891","#78B968","#62A86E","#3C8583","#569D74","#236C91","#F8F3D3","#D8E5A8","#0C487B","#04182E","#71B469","#B8D985","#07345E","#05213E","#4F9778","#5DA470","#3E8882","#062A4E","#7FBD68","#EFEFC6","#C9E096","#115286","#2C768D","#1E6491","#49917B","#66AC6C","#28718F","#A4D176","#90C76C","#438C7F","#175C8D","#083E6D","#E5EAB8","#317B8A","#357F87","#398385","#B3D781","#0D4A7E","#1C6290","#052342","#579F73","#9FCE73","#448D7E","#051A32","#FAF3D6","#428B7F","#29738F","#104F84","#5FA66F","#509877","#8CC56A","#094071","#2D788C","#083B6A","#D5E4A3","#2B758D","#226A91","#04162B","#BCDB89","#47907C","#4D9579","#E2E9B4","#7BBB68","#6EB269","#135488","#4A937A","#F1F0CA","#5BA271","#C5DE92","#F6F2D0","#CDE19B"]},naviaw:{discrete:["#041427","#051A31","#05203B","#062747","#072D52","#08345C","#0A3A66","#0C416F","#0F4979","#135080","#175686","#1B5D8A","#1F628D","#23698F","#276D8F","#2A728F","#2D758E","#30798D","#347D8B","#378089","#3A8388","#3D8686","#408984","#448C82","#489080","#4B937E","#50977C","#559C79","#5AA077","#5FA575","#65AA73","#6CAF71","#76B671","#7FBD71","#89C474","#95CB78","#A2D27F","#B1D98A","#BEDF95","#C9E5A1","#D3E9AD","#DBEDB9","#E4F1C6","#E9F4D0","#EEF6D9","#F2F8E1","#F6FAE9","#F9FCF1","#FCFDF7","#FEFEFD"],categorical:["#041427","#FBFDF6","#478F80","#9FD07D","#1F628D","#64A973","#E3F0C4","#0A3A66","#337C8B","#C7E49E","#7DBC71","#549B7A","#2A718F","#135080","#F2F8E1","#3C8586","#062747","#D7EBB2","#418A83","#B4DB8C","#2E778D","#6FB271","#EBF5D4","#0E4574","#051D37","#4D957D","#256B8F","#195A88","#388189","#F7FAEC","#5CA276","#8CC574","#073056","#31798C","#367E8A","#69AD72","#E7F3CC","#104A7A","#95CB78","#EFF6DB","#0B406D","#2C748E","#4A927F","#DDEEBB","#50987C","#165584","#589E78","#76B671","#3F8785","#05192F","#BEDF95","#448C82","#22678E","#06223F","#A9D684","#08355E","#CFE8A8","#F9FCF1","#286E8F","#85C172","#072C50","#F5F9E7","#1C5F8B","#3A8387","#60A675","#F3F9E4","#0C4271","#266D8F","#81BE72","#0A3D6A","#4B937E","#9ACD7B","#EDF5D7","#90C876","#A4D381","#378089","#1B5D8A","#489080","#145282","#DAECB6","#67AB73","#CBE6A3","#B9DD90","#3D8686","#23698F","#6CAF71","#FAFCF3","#79B971","#D3E9AD","#5AA077","#458E81","#72B471","#327B8C","#E5F1C8","#051B33","#F8FBEE","#062443","#398288","#2B728F","#06294C"]},nuuk:{discrete:["#05598C","#0E5B8B","#155C89","#1C5E87","#226085","#276184","#2C6383","#326682","#386982","#3E6C82","#446F82","#4A7283","#517584","#587A86","#5F7D88","#66818A","#6C858C","#73898E","#7B8E91","#819192","#879594","#8D9996","#939C97","#99A097","#9EA498","#A2A798","#A6AA97","#ABAD96","#AEAF95","#B1B194","#B3B492","#B6B690","#B8B88E","#BABA8C","#BDBC8A","#BFBE88","#C1C187","#C4C385","#C7C684","#CAC983","#CDCD83","#D2D184","#D7D787","#DDDD8B","#E3E290","#E8E895","#EEEE9C","#F4F4A4","#F9F9AB","#FEFEB2"],categorical:["#05598C","#FEFEB2","#A1A698","#537785","#C3C385","#B5B591","#7D8F91","#2D6483","#DDDD8B","#919B96","#BCBC8B","#3F6C82","#CDCD83","#1C5E87","#ADAE95","#68838B","#EEEE9C","#A7AA97","#879594","#C8C783","#F6F6A7","#135C89","#B9B98E","#497183","#73898E","#366882","#C0BF88","#D4D486","#99A097","#B1B293","#5E7D88","#256185","#E6E693","#829293","#788C90","#9DA398","#AAAC96","#E1E18F","#3B6A82","#638089","#B3B492","#A4A897","#446F82","#BABA8C","#D8D888","#185D88","#8C9895","#215F86","#BEBD89","#B7B78F","#CACA83","#4E7484","#C1C186","#959E97","#F2F2A1","#AFB094","#326682","#587A86","#296284","#FAFAAD","#6E868C","#C5C584","#D1D084","#0D5B8B","#E9E997","#DFDF8D","#66818A","#B0B194","#5B7B87","#2B6383","#859493","#CCCB83","#F8F8AA","#D2D285","#1F5F86","#70878D","#4B7383","#768B8F","#FCFCAF","#A9AB97","#BFBE88","#C9C983","#346782","#DBDA89","#236085","#BDBD8A","#BAB98D","#B8B88E","#2F6583","#939C97","#9FA498","#A2A798","#CFCF84","#B4B591","#C4C485","#979F97","#F0F09E","#155C89","#9BA298","#517584"]},oleron:{discrete:["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"],categorical:["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"]},oslo:{discrete:["#010101","#04070B","#060C13","#0A121B","#0C1620","#0D1927","#0E1D2D","#0F2133","#10263C","#112A43","#122E4A","#133251","#153758","#173C61","#194169","#1B4670","#1E4A78","#214F80","#255589","#295A91","#2E5F99","#3364A1","#3A6AA9","#4371B2","#4B77B9","#537DBE","#5B83C3","#6489C6","#6B8EC8","#7292C9","#7896C9","#7E9ACA","#859ECA","#8BA2C9","#91A6C9","#97A9C9","#9DADC9","#A4B2CA","#AAB6CA","#B1BBCB","#B8BFCD","#BFC5CF","#C7CCD3","#CFD2D8","#D7D9DD","#DEE0E2","#E6E7E9","#EFF0F1","#F7F7F8","#FFFFFF"],categorical:["#030609","#F9F9F9","#507BBC","#163B5E","#A0AFC9","#7B98CA","#27588E","#0E2032","#CACED5","#122D48","#3767A6","#1D4875","#8DA3C9","#E2E3E5","#678BC7","#B4BDCC","#0C151F","#BFC5CF","#97A9C9","#4371B2","#10263D","#080E16","#7292C9","#215081","#2E5F99","#AAB6CA","#ECEDEE","#0D1A28","#143454","#D5D8DC","#5B83C3","#19426A","#859ECA","#13314E","#0E1D2D","#3D6CAC","#6C8FC8","#7795C9","#F3F3F4","#4976B8","#245488","#DBDDE0","#112A43","#92A6C9","#C5C9D2","#809BCA","#0F2337","#3263A0","#050A10","#B9C1CD","#1F4C7B","#183E64","#A5B3CA","#0A121B","#9CACC9","#6187C5","#0D1824","#8AA1CA","#2A5B93","#547EBF","#D1D3D9","#E6E7E9","#1B456F","#B0BACB","#153758","#7494C9","#D8DADE","#6A8DC8","#90A5C9","#99ABC9","#235285","#133251","#060C13","#406EAF","#7E9ACA","#173C61","#4C78BA","#122F4B","#1C4772","#87A0CA","#CED1D7","#C2C7D1","#0F253A","#2C5D96","#C7CCD3","#112B45","#EFF0F1","#6F90C9","#0E1E2F","#ADB8CB","#7997CA","#4673B5","#15395B","#091018","#194067","#30619C","#94A8C9","#F6F6F6","#0F2135","#A3B1CA"]},roma:{discrete:["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"],categorical:["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"]},romao:{discrete:["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"],categorical:["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"]},tofino:{discrete:["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"],categorical:["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"]},tokyo:{discrete:["#1C0E34","#241036","#2D1339","#37163D","#3F1A40","#481E43","#4F2345","#562948","#5D304A","#62354C","#663B4D","#69404E","#6B454F","#6D4B50","#6E4F50","#6F5251","#6F5651","#705951","#715C52","#715F52","#716252","#726452","#726753","#736B53","#736E53","#747153","#757554","#757A54","#767E55","#778355","#788856","#798E57","#7B9558","#7C9B5A","#7EA25C","#81A95E","#84B062","#88B968","#8DC16E","#93CA76","#9BD27F","#A4DA8A","#AFE398","#BAEAA4","#C5EFB0","#CFF4BB","#D8F7C5","#E2F9CF","#E9FBD7","#EFFCDD"],categorical:["#1C0E34","#EFFCDD","#747053","#6C4750","#87B666","#B8E8A1","#512446","#715D52","#798B56","#7D9F5B","#37163D","#726653","#99D07D","#63374C","#6F5451","#D8F7C5","#767C54","#705951","#5B2D49","#7B9558","#441D41","#291238","#E5FAD2","#C9F1B4","#716252","#81AA5F","#683F4E","#736B53","#6E4E50","#757654","#8EC370","#A7DD8E","#778455","#747354","#84B062","#231036","#93CA76","#DFF9CC","#30143A","#A0D785","#7FA45D","#EAFBD8","#6A434F","#C1EDAB","#736D53","#562948","#6D4B50","#7A9057","#7C9A59","#4B2044","#715F52","#663B4D","#D1F4BD","#705651","#8ABD6A","#6E5151","#AFE398","#5F324B","#757954","#3E193F","#726853","#726452","#778055","#705B52","#788756","#61344C","#746E53","#ABE093","#532747","#85B364","#7EA25C","#261137","#736C53","#E8FBD5","#4E2245","#88B968","#798E57","#767E55","#726753","#757754","#715E52","#3A183E","#6E4F51","#778255","#7B9759","#DCF8C9","#EDFCDA","#411B40","#7D9C5A","#767B54","#726352","#6F5551","#726552","#82AD60","#D5F6C1","#34153C","#9CD481","#747454","#C5EFB0","#481E43"]},turku:{discrete:["#000000","#090908","#111110","#181816","#1D1D1A","#22221F","#272723","#2C2C27","#33322B","#38382F","#3D3D32","#424235","#474738","#4E4D3C","#53523E","#585841","#5D5D43","#626246","#686848","#6E6D4B","#73724D","#797750","#7F7D52","#878356","#8E8859","#968E5C","#9D9360","#A79864","#AF9C68","#B69F6C","#BEA270","#C4A474","#CCA579","#D1A67D","#D7A781","#DBA886","#E0A98B","#E6AB92","#EAAD98","#EFB09F","#F2B4A7","#F6B9AE","#F9BFB7","#FBC4BF","#FDC9C6","#FECFCC","#FED4D3","#FFDBDA","#FFE0E0","#FFE6E6"],categorical:["#070707","#FFE6E6","#948D5B","#E5AA90","#4D4C3B","#2C2C27","#C3A374","#6D6C4A","#FBC4BF","#D6A780","#F2B4A7","#1C1C19","#3D3D32","#AC9A67","#7E7C52","#FED6D4","#5D5D43","#35342D","#DDA888","#141312","#55543F","#242420","#FDCDCA","#F7BCB3","#898456","#B8A06D","#ECAE9B","#CDA57A","#FFDEDD","#646447","#454537","#9F9461","#76744E","#71704C","#30302A","#414135","#181816","#FCC8C4","#EFB1A1","#838054","#F5B8AD","#E1A98C","#C8A477","#686848","#595941","#20201D","#8E8859","#D1A67D","#B29D6A","#E9AC95","#BEA270","#FED1CF","#0E0E0D","#A59764","#DAA784","#282823","#F9C0B9","#51503D","#393930","#FFDAD9","#49493A","#606045","#FFE2E1","#9A915E","#797750","#F4B6AA","#F6BAB0","#CBA578","#FFD8D6","#FECFCC","#262622","#C0A272","#868255","#1A1A18","#FAC2BC","#8B8658","#E3AA8E","#161614","#4F4E3C","#C6A475","#2E2E28","#BBA16F","#6B6A49","#E7AB93","#CFA67C","#626246","#53523E","#5B5B42","#FED3D1","#7C7A51","#817E53","#73724D","#FFDCDB","#37372E","#F8BEB6","#0B0B0A","#575740","#DFA98A","#474738","#B59F6C"]},vanimo:{discrete:["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"],categorical:["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"]},vik:{discrete:["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"],categorical:["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"]},viko:{discrete:["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"],categorical:["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"]}};function Re(e){const t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}const $e={waves:"batlow",blksand:"tokyo",breeze:"imola",magma:"batlow",ribbon:"hawaii",stars:"batlow",folds:"imola"},Pe={[z.ADVERT]:1,[z.TXT_MSG]:4,[z.GRP_TXT]:2,[z.RESPONSE]:8,[z.REQ]:13,[z.ANON_REQ]:7,[z.ACK]:11,[z.PATH]:24,[z.TRACE]:16,[z.GRP_DATA]:34,[z.MULTIPART]:52,[z.RAW_CUSTOM]:14};function Le(){let e="waves",t=!0;if("undefined"!=typeof window){e=localStorage.getItem("pymc-color-scheme")||"waves";const s=L(e);t=(null==s?void 0:s.meta.isDark)??!0}const s=$e[e]??"batlow",a=Te[s],n=a.discrete.length,r=Math.floor(n/2);return{colormap:a,colormapName:s,isDark:t,baseIndex:t?r:0,halfSize:r}}let ze=null;function _e(e){const{colormap:t,isDark:s}=Le();if("number"!=typeof e)return s?"#A5A5A5":"#666666";const a=Pe[e];if(void 0===a)return s?"#A5A5A5":"#666666";const n=t.categorical;return n[Math.min(a,n.length-1)]}function He(e){return Re(_e(e))}const Oe={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function We(e,t){if(0===e.length)return 0;const s=t/100*(e.length-1),a=Math.floor(s),n=Math.ceil(s);return a===n?e[a]:e[a]+(e[n]-e[a])*(s-a)}function Ie(e){if(0===e.length)return{median:0,p90:0,p95:0,p99:0,max:0,min:0};const t=[...e].sort((e,t)=>e-t);return{median:We(t,50),p90:We(t,90),p95:We(t,95),p99:We(t,99),max:t[t.length-1],min:t[0]}}function Ve(e,t,s){const a=s-t;if(0===a)return"moderate";const n=(e-t)/a;return n>.66?"critical":n>.33?"severe":"moderate"}n.memo(function({options:e,data:t,className:s="",onCreate:a}){const l=n.useRef(null),i=n.useRef(null);return n.useEffect(()=>{const s=l.current;if(!s)return;const n=s.getBoundingClientRect(),r=Math.floor(n.width)||400,o=Math.floor(n.height)||200,c=new _({...e,width:r,height:o},t,s);return i.current=c,null==a||a(c),()=>{c.destroy(),i.current=null}},[e]),n.useEffect(()=>{i.current&&t&&i.current.setData(t)},[t]),n.useEffect(()=>{const e=l.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!i.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&i.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.jsx("div",{ref:l,className:`w-full h-full ${s}`,style:{minHeight:100}})});const qe=new Map;function Ge(e){var t;if(!e.startsWith("var("))return e;const s=qe.get(e);if(s)return s;const a=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!a)return e;const n=a[1].trim(),r=(null==(t=a[2])?void 0:t.trim())||"#888888",l=getComputedStyle(document.documentElement).getPropertyValue(n).trim()||r;return qe.set(e,l),l}function Xe(e,t,s=!1){if(t.length<2)return;if(e.beginPath(),e.moveTo(t[0].x,t[0].y),2===t.length)return void e.lineTo(t[1].x,t[1].y);const a=.5;for(let n=0;n{F.current=e,E.current=t,m.current=a,d.current=s});const h=n.useRef({band:l,innerBand:i,mean:o,median:c,average:C,cursor:A});n.useLayoutEffect(()=>{h.current={band:l,innerBand:i,mean:o,median:c,average:C,cursor:A}});const x=n.useMemo(()=>[e.map(e=>e.timestamp),e.map(e=>e.max)],[e]),p=n.useMemo(()=>{const e=function(e,t,s,a){return{hooks:{draw:n=>{const r=e.current,l=t.current,i=s.current,o=a.current;if(0===r.length)return;const c=n.ctx,C=n.bbox,A=C.left,D=C.top,B=C.width,F=C.height;if(B<=0||F<=0)return;const E=n.data[0],m=E.length;if(0===m)return;const d=E[0],u=E[m-1]-d||1,h=e=>A+(e-d)/u*B,x=e=>D+F*(1-e/l),p={min:r.map(e=>({x:h(e.timestamp),y:x(e.min)})),max:r.map(e=>({x:h(e.timestamp),y:x(e.max)})),p5:r.map(e=>({x:h(e.timestamp),y:x(e.p5)})),p95:r.map(e=>({x:h(e.timestamp),y:x(e.p95)})),p25:r.map(e=>({x:h(e.timestamp),y:x(e.p25)})),p75:r.map(e=>({x:h(e.timestamp),y:x(e.p75)})),mean:r.map(e=>({x:h(e.timestamp),y:x(e.mean)})),median:r.map(e=>({x:h(e.timestamp),y:x(e.median)})),average:r.map(e=>({x:h(e.timestamp),y:x(e.average)}))},g=(e,t)=>i?i===e?Math.min(1,1.5*t):"minMax"===i||"p5p95"===i||"p25p75"===i?.3*t:t:t,f=e=>i?i===e?1:"mean"===i||"median"===i||"average"===i?.3:1:1,b={band:Ge(o.band),innerBand:Ge(o.innerBand),mean:Ge(o.mean),median:Ge(o.median),average:Ge(o.average)};c.save(),c.strokeStyle=b.average,c.lineWidth=4,c.globalAlpha=f("average"),Xe(c,p.average),c.stroke(),c.globalAlpha=g("minMax",.15),c.fillStyle=b.band,c.beginPath(),Xe(c,p.max);const y=[...p.min].reverse();for(const e of y)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=g("p5p95",.3),c.fillStyle=b.band,c.beginPath(),Xe(c,p.p95);const v=[...p.p5].reverse();for(const e of v)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=g("p25p75",.55),c.fillStyle=b.innerBand,c.beginPath(),Xe(c,p.p75);const j=[...p.p25].reverse();for(const e of j)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=b.median,c.lineWidth=1.5,c.globalAlpha=f("median"),c.setLineDash([4,4]),Xe(c,p.median),c.stroke(),c.strokeStyle=b.mean,c.lineWidth=1.5,c.globalAlpha=f("mean"),c.setLineDash([]),Xe(c,p.mean),c.stroke(),c.restore()}}}}(F,E,m,h);return{width:400,height:200,padding:[4,4,4,4],cursor:{show:!0,x:!0,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,t]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],hooks:{setCursor:[e=>{var t,s;const a=e.cursor.idx;null!=a&&a>=0?null==(t=d.current)||t.call(d,a):null==(s=d.current)||s.call(d,null)}]},plugins:[e]}},[t]);n.useEffect(()=>{const t=D.current;if(!t||0===e.length)return;const s=u.current,a=e.length,n=Math.abs(a-s);if(!(!B.current||n>100||s>0&&n/s>.1)&&B.current)return B.current.setData(x),void(u.current=a);B.current&&B.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new _({...p,width:l,height:i},x,t);return B.current=o,u.current=a,()=>{o.destroy(),B.current=null}},[p,x,e.length]),n.useEffect(()=>{const e=D.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!B.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&B.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),n.useEffect(()=>{B.current&&B.current.redraw()},[a,e]);const g=n.useCallback(()=>{null==s||s(null)},[s]);return 0===e.length?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):r.jsx("div",{ref:D,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})});const Ke="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Ye(){const e=getComputedStyle(document.documentElement);return{fontFamily:e.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',axisColor:e.getPropertyValue("--chart-axis-tick").trim()||"rgba(255, 255, 255, 0.4)",gridColor:e.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)",textMuted:e.getPropertyValue("--text-muted").trim()||"#727272",textPrimary:e.getPropertyValue("--text-primary").trim()||"#FFFFFF"}}const Ue=["min","max","p75","p95","p99","mean","median","average","midpoint"];function Qe(e){const t=Re(function(e){const{colormap:t,baseIndex:s,halfSize:a}=Le(),n=Math.max(0,Math.min(1,e)),r=Math.min(s+Math.floor(n*(a-1)),t.discrete.length-1);return t.discrete[r]}(e)),s=`color(display-p3 ${(t.r/255).toFixed(3)} ${(t.g/255).toFixed(3)} ${(t.b/255).toFixed(3)})`;return{...t,p3:s}}function Ze(e,t,s,a,n,r,l,i,o,c=null,C=null,A=1,D=null,B="airtime",F=.5){if(0===t.length)return;const E=e.ctx,{left:m,top:d,width:u,height:h}=e.bbox,x=window.devicePixelRatio||1;if(u<=0||h<=0)return;const p=e.data[0],g=p.length;if(0===g)return;const f=p[0],b=p[g-1],y=s,v="share"===B,j=v?function(e){const t=[10,20,25,50,100,200,250,500,1e3],s=e/4.5;for(const a of t)if(a>=s)return a;return e>5e3?1e3*Math.ceil(s/1e3):100*Math.ceil(s/100)}(y):5,N=getComputedStyle(document.documentElement),w=N.getPropertyValue("--signal-critical").trim()||"#EF4444",k=N.getPropertyValue("--bg-body").trim()||"#171717";E.save(),E.fillStyle="#000000";const M=8*x;E.beginPath(),E.roundRect(m,d,u,h,M),E.fill(),E.restore();const S=parseInt(k.slice(1,3),16)||23,T=parseInt(k.slice(3,5),16)||23,R=parseInt(k.slice(5,7),16)||23;if(!v&&y>=20){E.save();const e=d+h*(1-20/y);E.fillStyle=`rgba(${S}, ${T}, ${R}, 0.5)`,E.fillRect(m,d,u,e-d),E.restore()}E.save(),E.lineWidth=1*x,E.setLineDash([4*x,4*x]);for(let P=j;Ps+n)return;const i=getComputedStyle(document.documentElement).getPropertyValue("--text-primary").trim()||"#FFFFFF";e.save(),e.strokeStyle=i,e.globalAlpha=.5,e.lineWidth=1*l,e.setLineDash([4*l,4*l]),e.beginPath(),e.moveTo(Math.round(t)+.5,a),e.lineTo(Math.round(t)+.5,a+r),e.stroke(),e.restore()}(E,D,m,d,u,h,x),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:C,rawValues:A,count:D,packetTypes:B,timestamps:F}=t,E=1*o*(window.devicePixelRatio||1);e.globalCompositeOperation="source-over";const m=l?parseInt(l.replace("TYPE_",""),10):null;for(let d=0;d=i.start&&e0&&function(e,t,s,a,n,r,l,i,o,c,C=.5){if(0===t.length)return;const A=o-i||1,D=function(e,t=1.3,s=.15){const a=function(e){const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);if(t){const e=parseFloat(t[1]),s=parseFloat(t[2]),a=parseFloat(t[3]);return{r:Math.round(255*e),g:Math.round(255*s),b:Math.round(255*a),p3r:e,p3g:s,p3b:a}}if(e.startsWith("#")){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return{r:s,g:a,b:n,p3r:s/255,p3g:a/255,p3b:n/255}}const s=e.match(/rgba?\(([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(s){const e=Math.round(parseFloat(s[1])),t=Math.round(parseFloat(s[2])),a=Math.round(parseFloat(s[3]));return{r:e,g:t,b:a,p3r:e/255,p3g:t/255,p3b:a/255}}return{r:255,g:255,b:255,p3r:1,p3g:1,p3b:1}}(e),n=function(e,t,s,a=1.25,n=.15){const r=(Math.max(e,t,s)+Math.min(e,t,s))/2;return{p3r:Math.min(1,r+(e-r)*a+n),p3g:Math.min(1,r+(t-r)*a+n),p3b:Math.min(1,r+(s-r)*a+n)}}(a.p3r,a.p3g,a.p3b,t,s);return{r:Math.round(255*Math.min(1,n.p3r)),g:Math.round(255*Math.min(1,n.p3g)),b:Math.round(255*Math.min(1,n.p3b)),p3r:Math.min(1,n.p3r),p3g:Math.min(1,n.p3g),p3b:Math.min(1,n.p3b)}}(getComputedStyle(document.documentElement).getPropertyValue("--signal-critical").trim()||"#EF4444");e.save(),e.globalAlpha=C,e.fillStyle=Ke?`color(display-p3 ${D.p3r} ${D.p3g} ${D.p3b})`:`rgb(${D.r}, ${D.g}, ${D.b})`;for(const B of t){if(B.endTso)continue;const t=a+(Math.max(B.startTs,i)-i)/A*r,s=a+(Math.min(B.endTs,o)-i)/A*r,C=Math.max(s-t,2*c);e.fillRect(t,n,C,l)}e.restore()}(E,i,0,m,d,u,h,f,b,x,C?Math.max(.03,.03*F):F)}const Je=n.memo(function({data:e,maxValue:t,visibleLines:s=Ue,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:C=.5,highlightedType:A=null,hoveredTimeRange:D=null,timeRangeHours:B=24,yAxisMode:F="airtime"}){const E=n.useRef(null),m=n.useRef(null),d=n.useRef(e),u=n.useRef(t),h=n.useRef(s),x=n.useRef(a),p=n.useRef(l),g=n.useRef(i),f=n.useRef(o),b=n.useRef(c),y=n.useRef(A),v=n.useRef(D),j=n.useRef(null),N=n.useRef(null),w=n.useRef(F),k=n.useRef(C),M=B<=12?1.2:1,S=n.useRef(M),T=n.useRef(e.length);n.useLayoutEffect(()=>{d.current=e,u.current=t,h.current=s,x.current=a,p.current=l,g.current=i,f.current=o,b.current=c,y.current=A,v.current=D,S.current=M,w.current=F,k.current=C}),n.useEffect(()=>{j.current=Ye()},[]);const R=n.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),$=n.useMemo(()=>({hooks:{draw:e=>{const t=j.current||Ye();Ze(e,d.current,u.current,h.current,x.current,t,g.current,f.current,b.current,y.current,v.current,S.current,N.current,w.current,k.current)}}}),[]),P=n.useMemo(()=>({width:400,height:200,padding:[8,0,8,28],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[$]}),[$]);n.useEffect(()=>{const t=E.current;if(!t||0===e.length)return;const s=T.current,a=e.length,n=Math.abs(a-s);if(!(!m.current||n>100||s>0&&n/s>.1)&&m.current)return m.current.setData(R),void(T.current=a);m.current&&m.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new _({...P,width:l,height:i},R,t);return m.current=o,T.current=a,()=>{o.destroy(),m.current=null}},[P,R,e.length]),n.useEffect(()=>{const e=E.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!m.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&m.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),n.useEffect(()=>{m.current&&m.current.redraw()},[a,s,e,i,o,c,C,A,D,M]);const L=n.useCallback(t=>{var s,a;const n=E.current,r=m.current;if(!n||!r||0===e.length)return;const l=n.getBoundingClientRect(),i=t.clientX-l.left,o=window.devicePixelRatio||1,c=r.bbox,C=c.left/o,A=c.width/o;if(iC+A)return N.current=null,r.redraw(),void(null==(s=p.current)||s.call(p,null));N.current=i*o;const D=(i-C)/A,B=e.length,F=Math.floor(D*B),d=Math.max(0,Math.min(B-1,F));r.redraw(),null==(a=p.current)||a.call(p,d)},[e.length]),z=n.useCallback(()=>{var e;N.current=null,m.current&&m.current.redraw(),null==(e=p.current)||e.call(p,null)},[]);return 0===e.length?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):r.jsx("div",{ref:E,className:"w-full h-full rounded-lg overflow-hidden",onMouseMove:L,onMouseLeave:z})}),et=function(e){const t=_e(e);return null===ze&&(ze=P()),ze?$(t):t};function tt({sortedTypes:e,highlightedType:t,onTypeHover:s,aggregateShares:a,hoverData:l}){const i=n.useMemo(()=>{if(!l)return null;const e=new Map;for(const t of l.items)e.set(t.key,t.value);return e},[l]),o=null!==i;return r.jsx("div",{className:"flex-shrink-0 pt-3 mt-2",children:r.jsx("div",{className:"grid ml-9 gap-y-0.5",style:{gridTemplateColumns:"repeat(auto-fill, minmax(105px, 1fr))"},onMouseLeave:()=>s(null),children:e.map(e=>{const n=et(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,C=o?l:c,A=C>1e-4,D=t===e.key,B=["legend-item",D&&"legend-item-active",(t&&!D||o&&l<=1e-4)&&"legend-item-dimmed",!t&&o&&l>1e-4&&"legend-item-chart-active"].filter(Boolean).join(" ");return r.jsxs("div",{className:B,onMouseEnter:()=>s(e.key),children:[r.jsx("div",{className:"flex-shrink-0",style:{backgroundColor:n,width:9,height:16,borderRadius:1}}),r.jsx("span",{className:"legend-label",children:e.label}),A&&r.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*C).toFixed(1),"%"]})]},e.key)})})})}const st='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';function at({x:e,y:t,width:s,height:a,name:n,size:l,index:i,depth:o,hoveredIndex:c,onHover:C,total:A,typeNum:D}){if(1!==o)return null;const B=null!==c&&!(c===i),F=et(D),E=A>0?l/A*100:0,m=s>36&&a>20,d=s>36&&a>32;return r.jsxs("g",{onMouseEnter:e=>C(i,e),onMouseLeave:()=>C(null),style:{cursor:"default"},children:[r.jsx("rect",{x:e,y:t,width:s,height:a,fill:F,opacity:B?.4:1,stroke:"rgba(0,0,0,0.2)",strokeWidth:1,rx:3,style:{transition:"opacity 150ms ease"}}),m&&r.jsxs(r.Fragment,{children:[d&&r.jsxs("text",{x:e+4,y:t+a-4-11,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.6)",fontSize:8,fontFamily:st,fontWeight:500,style:{pointerEvents:"none"},children:[E.toFixed(1),"%"]}),r.jsx("text",{x:e+4,y:t+a-4,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.85)",fontSize:9,fontFamily:st,fontWeight:600,style:{pointerEvents:"none"},children:n})]})]})}function nt({data:e,total:t,color:s,position:a,containerWidth:n}){if(!e||!a)return null;const l=(e.value/t*100).toFixed(1),i=n-a.x<184?Math.max(8,a.x-160-8):a.x+16;return r.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:i,top:Math.max(8,a.y-60)},children:r.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl min-w-[140px]",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:s}}),r.jsx("span",{className:"type-data-sm font-semibold text-text-primary",children:e.name})]}),r.jsxs("div",{className:"space-y-0.5 type-data-xs text-text-muted",children:[r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Count"}),r.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:e.value.toLocaleString()})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Share"}),r.jsxs("span",{className:"text-text-primary tabular-nums font-medium",children:[l,"%"]})]}),r.jsxs("div",{className:"flex justify-between gap-4",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:t.toLocaleString()})]})]})]})})}function rt({sortedTypes:e,aggregateShares:t}){var s,a,i;const[o,c]=n.useState(null),[C,A]=n.useState(null),[D,B]=n.useState(0),[F,E]=n.useState(null),m=n.useRef(null),d=n.useMemo(()=>e.reduce((e,t)=>e+t.totalCount,0),[e]),u=n.useMemo(()=>e.map((e,t)=>({name:e.label,size:e.totalCount,index:t,typeNum:e.typeNum,key:e.key})),[e]),h=n.useCallback((e,t)=>{if(c(e),t&&null!==e){const e=m.current;if(e){const s=e.getBoundingClientRect();B(s.width),A({x:t.clientX-s.left,y:t.clientY-s.top})}}else A(null)},[]),x=n.useCallback(e=>{if(E(e),e){const t=u.findIndex(t=>t.key===e);c(t>=0?t:null)}else c(null)},[u]),p=null!==o?{name:(null==(s=u[o])?void 0:s.name)??"",value:(null==(a=u[o])?void 0:a.size)??0}:null,g=null!==o?et(null==(i=u[o])?void 0:i.typeNum):"";return 0===e.length||0===d?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet type data available"})]}):r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",ref:m,children:[r.jsx(Ee,{width:"100%",height:"100%",children:r.jsx(me,{data:u,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:r.jsx(at,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:o,onHover:h,total:d,typeNum:0})})}),r.jsx(nt,{data:p,total:d,color:g,position:C,containerWidth:D})]}),r.jsx(tt,{sortedTypes:e,highlightedType:F,onTypeHover:x,aggregateShares:t})]})}function lt(e){return e>=1e9?`${(e/1e9).toFixed(1)} Gb`:e>=1e6?`${(e/1e6).toFixed(1)} Mb`:e>=1e3?`${(e/1e3).toFixed(1)} Kb`:`${e.toFixed(0)} B`}function it({active:e,payload:t,label:s,mode:a}){if(!e||!t||0===t.length)return null;const n=t.filter(e=>null!==e.value&&void 0!==e.value);if(0===n.length)return null;const l=s?new Date(1e3*s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):"";return r.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[r.jsx("div",{className:"font-medium text-text-primary mb-1 font-mono",children:l}),n.map((e,t)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-3 h-0.5",style:{backgroundColor:e.color}}),r.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),r.jsx("span",{className:"text-text-primary tabular-nums font-mono",children:"share"===a?`${Number(e.value).toLocaleString()} B`:`${Number(e.value).toFixed(2)}%`})]},t))]})}function ot({packets:e,mode:t,startTs:s,endTs:a,radioConfig:o,bucketCount:c}){const C=oe(),A=ce(),D=C.primary,B=C.tertiary,[F,E]=n.useState(null),{trendData:m,totals:d}=n.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const n=a-s,r=Math.min(Math.ceil(n/300),c),l=n/r,i=[];let C=0,A=0,D=0,B=0;for(const t of e){const e=t.timestamp;if(e=a)continue;const n=H(t),r=O(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble}),l={timestamp:e,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};t.transmitted?(l.txAirtime=r,l.txBytes=n,A+=n,B+=r):(l.rxAirtime=r,l.rxBytes=n,C+=n,D+=r),i.push(l)}i.sort((e,t)=>e.timestamp-t.timestamp);const F=new Float64Array(i.length+1),E=new Float64Array(i.length+1),m=new Float64Array(i.length+1),d=new Float64Array(i.length+1),u=new Float64Array(i.length);for(let e=0;e{let t=0,s=u.length;for(;t>>1;u[a]0?e:null,tx:t>0?t:null})}else{const e=(F[i]-F[r])/p*100,t=(E[i]-E[r])/p*100;x.push({timestamp:a,rx:e>0?e:null,tx:t>0?t:null})}}const g=2/31;let f=null;return{trendData:x.map(e=>{const t=e.rx;return null!==t&&t>0&&(f=null===f?t:g*t+(1-g)*f),{...e,rxSmooth:null!==f&&f>0?f:null}}),totals:{rxBytes:C,txBytes:A,rxAirtime:D,txAirtime:B}}},[e,s,a,c,t,o]),u=n.useMemo(()=>{if(0===m.length)return"share"===t?100:10;let e=0;for(const t of m){const s=t.rx??0,a=t.tx??0;s>e&&(e=s),a>e&&(e=a)}const s=1.1*e;return"share"===t?s<=100?100:s<=500?100*Math.ceil(s/100):s<=1e3?200*Math.ceil(s/200):s<=5e3?500*Math.ceil(s/500):s<=1e4?1e3*Math.ceil(s/1e3):5e3*Math.ceil(s/5e3):Math.max(1,Math.ceil(s))},[m,t]),h=n.useMemo(()=>{if(null!==F&&m[F]){const e=m[F],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:lt(s),tx:lt(a),total:lt(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:lt(d.rxBytes),tx:lt(d.txBytes),total:lt(d.rxBytes+d.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of m)null===r.rx&&null===r.tx||(e+=r.rx??0,t+=r.tx??0,s++);const a=s>0?e/s:0,n=s>0?t/s:0;return{rx:`${a.toFixed(2)}%`,tx:`${n.toFixed(2)}%`,total:`${(a+n).toFixed(2)}%`,isHovered:!1}}},[F,m,d,t]),x=n.useMemo(()=>{const e=a-s,t=e/3600;return[0,.25,.5,.75,1].map(a=>{const n=new Date(1e3*(s+e*a)),r=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),l=n.toLocaleDateString([],{weekday:"short"});return{pct:a,label:t>24?`${l} ${r}`:r,mobileHidden:.25===a||.75===a}})},[s,a]),p=n.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;E("number"==typeof t?t:null)},[]),g=n.useCallback(e=>"share"===t?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:e.toFixed(0):`${e.toFixed(0)}%`,[t]);return 0===m.length?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]}):r.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[r.jsx("div",{className:"flex items-center flex-shrink-0 text-text-secondary",style:{height:20,paddingLeft:44,paddingRight:8},children:r.jsx("div",{className:"relative w-full h-full flex items-center",children:x.map((e,t)=>r.jsxs("div",{className:"absolute flex items-center gap-0.5 sm:gap-1 type-data-xs "+(e.mobileHidden?"hidden sm:flex":""),style:{left:100*e.pct+"%",transform:0===e.pct?"translateX(0)":1===e.pct?"translateX(-100%)":"translateX(-50%)"},children:[r.jsx(i,{className:"w-2.5 h-2.5 opacity-60 hidden sm:block"}),r.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),r.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:r.jsx(Ee,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:r.jsxs(de,{data:m,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:p,onMouseLeave:()=>E(null),children:[r.jsx(ue,{strokeDasharray:"3 3",stroke:A.secondary,strokeOpacity:.3,vertical:!1}),r.jsx(he,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),r.jsx(xe,{axisLine:!1,tickLine:!1,tick:{fill:A.secondary,fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},dx:-8,width:44,tickFormatter:g,domain:[0,u]}),r.jsx(pe,{content:r.jsx(it,{mode:t})}),r.jsx(ge,{type:"linear",dataKey:"rx",name:"RX",stroke:D,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),r.jsx(ge,{type:"linear",dataKey:"tx",name:"TX",stroke:B,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),r.jsx(ge,{type:"basis",dataKey:"rxSmooth",name:"RX Avg",stroke:"var(--sys-brown)",strokeWidth:2,strokeOpacity:1,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})}),r.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-1.5 sm:mt-2",children:[r.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 text-xs font-mono pl-2 sm:pl-11",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-3 sm:w-4 h-0.5",style:{backgroundColor:D}}),r.jsx("span",{className:"text-text-secondary",children:"RX"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-3 sm:w-4 h-0.5",style:{backgroundColor:B}}),r.jsx("span",{className:"text-text-secondary",children:"TX"})]}),r.jsxs("div",{className:"hidden sm:flex items-center gap-1.5",children:[r.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:"var(--sys-brown)"}}),r.jsx("span",{className:"text-text-secondary",children:"Avg"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 text-right pr-1 sm:pr-2 font-mono",children:[r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("span",{className:"text-xs font-medium",style:{color:D},children:"RX"}),r.jsx("span",{className:"font-bold text-lg sm:text-xl text-text-primary",children:h.rx})]}),r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("span",{className:"text-xs font-medium",style:{color:B},children:"TX"}),r.jsx("span",{className:"font-bold text-lg sm:text-xl text-text-primary",children:h.tx})]}),h.isHovered&&r.jsx("span",{className:"text-xs text-text-muted hidden sm:inline",children:"bucket"})]})]})]})}function ct(e){const{values:t,sum:s}=e;if(0===t.length)return{min:0,mean:0,median:0,p75:0,p95:0,p99:0,max:0};const a=[...t].sort((e,t)=>e-t),n=a.length,r=s/n,l=a[0],i=a[n-1],o=e=>{const t=Math.min(Math.ceil(e*n)-1,n-1);return a[Math.max(0,t)]};return{min:l,mean:r,median:n%2==0?(a[n/2-1]+a[n/2])/2:a[Math.floor(n/2)],p75:o(.75),p95:o(.95),p99:o(.99),max:i}}function Ct({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:i,radioConfig:o,sortedTypes:c,aggregateShares:C,noiseFloorAnomalies:A,showNoiseFloorOverlay:D,overlayOpacity:B=.5}){const[F,E]=n.useState(null),[m,d]=n.useState(null),u=n.useMemo(()=>(i-a)/3600,[a,i]),h=n.useCallback(e=>{d(e)},[]),x=function(e,t,s,a,r){return n.useMemo(()=>{if(0===e.length||!r)return null;const n=e.filter(e=>e.timestamp>=t&&e.timestamp<=s);if(0===n.length)return null;const l=[],i=new Map;for(const e of n){const s=e.type??e.payload_type??-1,n=H(e);let o;if(o="airtime"===a?O(e,{spreadingFactor:r.sf,bandwidthHz:r.bw,codingRate:r.cr,preambleLength:r.preamble}):1,n<=0)continue;const c=Math.floor((e.timestamp-t)/300),C={timestamp:e.timestamp,airtimeMs:o,byteSize:n,packetType:s,bucketIndex:c};l.push(C),i.has(c)||i.set(c,[]),i.get(c).push(C)}if(0===l.length)return null;const o=[],c=[],C=[],A=new Map;if("share"===a)for(const[,e]of i)for(const t of e)A.set(t,t.byteSize);else for(const[,e]of i){const t=e.reduce((e,t)=>e+t.airtimeMs,0)/3e5*100;let s=0;for(const a of e)a.airtimeMs>s&&(s=a.airtimeMs);for(const a of e){const e=a.airtimeMs/s*t;A.set(a,e)}}for(const e of l){const t=A.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),C.push(e.packetType))}let D=c[0],B=c[0];for(let e=1;eB&&(B=c[e]);const F=B-D||1,E=[...o].sort((e,t)=>e-t),m=E[0],d=E[E.length-1],u=Math.floor(.05*E.length),h=Math.floor(.5*E.length),x=Math.min(Math.ceil(.95*E.length),E.length-1),p=E[u],g=E[h],f=E[x],b=new Map;for(const e of o){const t=Math.round(100*e)/100;b.set(t,(b.get(t)??0)+1)}const y=b.size,v=[...b.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let j;if("share"===a)j=200;else{const e=5,t=Math.ceil(d/e)*e;j=t<=10?10:t+e}const N=new Float32Array(2*o.length),w=new Float32Array(o.length),k=new Uint8Array(o.length),M=new Float32Array(o.length);for(let e=0;e=0?C[e]:255,M[e]=c[e]}return{points:N,rawValues:w,packetTypes:k,timestamps:M,count:o.length,minTime:D,maxTime:B,minValue:0,maxValue:j,rawMinValue:m,rawMaxValue:d,unit:"%",stats:{p5:p,p50:g,p95:f,uniqueValues:y,topValues:v}}},[e,t,s,a,r])}(s,a,i,"share"===t?"share":"airtime",o),{data:p}=n.useMemo(()=>function(e,t){var s;const a=e.length;if(0===a)return{data:[],windowSize:0,windowDurationMs:0};const n=(null==(s=e[0])?void 0:s.bucketDurationMs)??1e3,r=Math.min(Math.max(5,Math.round(3e5/n)),a),l=Math.floor(r/2),i=[];let o=0,c=0;for(let C=0;Cp.map(e=>({timestamp:e.timestamp,min:e.min,max:e.max,p75:e.p75,p95:e.p95,p99:e.p99,mean:e.mean,median:e.median,average:e.average,midpoint:e.midpoint})),[p]),f=n.useMemo(()=>(null==x?void 0:x.maxValue)?x.maxValue:"share"===t?200:10,[x,t]),b=n.useCallback(e=>{E(e)},[]),y=n.useMemo(()=>{if(null===F||!p[F])return null;const e=p[F];let t;t=u>=168?75:u>=72?35:u>=24?15:u>=3?10:5;const s=60*t/2,a=e.timestamp;return{start:a-s,end:a+s}},[F,p,u]),v=n.useMemo(()=>{if(null===F||!p[F]||!y)return null;const e=p[F].time,{start:a,end:n}=y,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:et(e.typeNum)}))};const l=new Map,i=new Map;let C=0,A=0;for(const t of r){const e=`TYPE_${t.type??t.payload_type??-1}`;if(l.set(e,(l.get(e)??0)+1),C++,o){const s=O(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble});i.set(e,(i.get(e)??0)+s),A+=s}}const D=c.map(e=>{let s;return s="airtime"===t?A>0?(i.get(e.key)??0)/A:0:C>0?(l.get(e.key)??0)/C:0,{key:e.key,label:e.label,value:s,color:et(e.typeNum)}});return{timestamp:p[F].timestamp,timeLabel:e,items:D}},[F,p,y,s,c,t,o]);if(0===p.length)return r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]});const j=(null==v?void 0:v.timeLabel)??null;return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",children:[r.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:r.jsx(Je,{data:g,maxValue:f,onHover:b,scatterData:x,noiseFloorAnomalies:A,showNoiseFloorOverlay:D,overlayOpacity:B,highlightedType:m,hoveredTimeRange:y,timeRangeHours:u,yAxisMode:"share"===t?"share":"airtime"})}),j&&r.jsx("div",{className:"absolute top-1 right-1 px-2 py-0.5 bg-bg-elevated/90 rounded text-xs text-accent-secondary font-mono pointer-events-none",children:j})]}),r.jsx(tt,{sortedTypes:c,highlightedType:m,onTypeHover:h,aggregateShares:C,hoverData:v})]})}const At=new class{constructor(){a(this,"buckets",new Map),a(this,"lastProcessedTimestamp",0),a(this,"processedPacketCount",0),a(this,"cacheKey",null),a(this,"bucketDuration",60),a(this,"bucketDurationMs",6e4)}getBuckets(e,t,s,a){const n={startTs:t,endTs:s,radioConfigHash:this.hashRadioConfig(a)};return this.isCacheValid(n)?this.processPackets(e,t,s,a,!1):(this.invalidate(n),this.processPackets(e,t,s,a,!0)),this.toBucketDataArray(t,s)}processPackets(e,t,s,a,n){const r=Math.ceil((s-t)/this.bucketDuration);let l=0;for(const i of e){const e=i.timestamp;if(e=s)continue;if(!n&&e<=this.lastProcessedTimestamp)continue;const o=Math.min(Math.floor((e-t)/this.bucketDuration),r-1),c=this.buckets.get(o)??{total:0,totalAirtime:0};c.total+=1,c.totalAirtime+=O(i,{spreadingFactor:a.sf,bandwidthHz:a.bw,codingRate:a.cr,preambleLength:a.preamble}),this.buckets.set(o,c),e>this.lastProcessedTimestamp&&(this.lastProcessedTimestamp=e),l++}this.processedPacketCount+=l}toBucketDataArray(e,t){const s=t-e,a=Math.ceil(s/this.bucketDuration),n=s/3600,r=[];for(let l=0;l24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),i=this.buckets.get(l)??{total:0,totalAirtime:0};r.push({timestamp:t,time:a,total:i.total,totalAirtime:i.totalAirtime,bucketDurationMs:this.bucketDurationMs})}return r}isCacheValid(e){return!!this.cacheKey&&this.cacheKey.startTs===e.startTs&&this.cacheKey.endTs===e.endTs&&this.cacheKey.radioConfigHash===e.radioConfigHash}invalidate(e){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=e}hashRadioConfig(e){return`${e.sf}-${e.bw}-${e.cr}-${e.preamble}`}clear(){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=null}getStats(){return{bucketCount:this.buckets.size,processedPackets:this.processedPacketCount,lastTimestamp:this.lastProcessedTimestamp,cacheKey:this.cacheKey}}};function Dt({mode:e,onChange:t}){return r.jsxs("div",{className:"toggle-group toggle-group-sm",children:[r.jsx("button",{onClick:()=>t("share"),className:"toggle-group-item "+("share"===e?"active":""),children:"Total"}),r.jsx("button",{onClick:()=>t("airtime"),className:"toggle-group-item "+("airtime"===e?"active":""),children:"Airtime"})]})}function Bt({smoothing:e,onChange:t}){return r.jsxs("div",{className:"toggle-group toggle-group-sm",children:[r.jsx("button",{onClick:()=>t("stats"),className:"toggle-group-item "+("stats"===e?"active":""),title:"Statistics view (scatter plot)",children:r.jsx(C,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("trend"),className:"toggle-group-item "+("trend"===e?"active":""),title:"Trend line chart",children:r.jsx(A,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("raw"),className:"toggle-group-item "+("raw"===e?"active":""),title:"No smoothing (raw values)",children:r.jsx(D,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("zlema"),className:"toggle-group-item "+("zlema"===e?"active":""),title:"Light smoothing",children:r.jsx(B,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"Moderate smoothing",children:r.jsx(F,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"Heavy smoothing",children:r.jsx(E,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"Ultra smoothing",children:r.jsx(m,{className:"w-3.5 h-3.5"})}),r.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap)",children:r.jsx(d,{className:"w-3.5 h-3.5"})})]})}function Ft({enabled:e,onChange:t,anomalyCount:s=0,showTuning:a=!1,onTuningChange:n}){return r.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[e&&n&&r.jsx("button",{onClick:()=>n(!a),className:"toggle-group toggle-group-sm "+(a?"active":""),title:a?"Hide tuning panel":"Show tuning panel",children:r.jsx("span",{className:"toggle-group-item "+(a?"active":""),children:r.jsx(o,{className:"w-3.5 h-3.5"})})}),r.jsx("button",{onClick:()=>t(!e),className:"toggle-group toggle-group-sm "+(e?"active":""),title:e?"Hide noise floor anomalies":"Show noise floor anomalies",children:r.jsx("span",{className:"toggle-group-item "+(e?"active":""),children:r.jsx(c,{className:"w-3.5 h-3.5"})})}),s>0&&r.jsx("span",{className:"absolute -top-2 -right-2 min-w-[18px] h-[18px] px-1 rounded-full bg-accent-danger text-white text-[10px] font-bold flex items-center justify-center pointer-events-none z-10",children:s>99?"99+":s})]})}const Et={sf:10,bw:25e4,cr:5,preamble:8};function mt(e){return I[e]??`TYPE_${e.toString(16).toUpperCase()}`}function dt(e,t){if(0===e.length)return[];const s=Math.floor((t-1)/2),a=[];for(let n=0;n=s?e[n-s]:e[0];a.push(e[n]+(e[n]-t))}return function(e,t){if(0===e.length)return[];const s=2/(t+1),a=[e[0]];for(let n=1;n{const t=Math.abs(e.length-p.current);if(0===t&&u.length>0)return;x.current&&clearTimeout(x.current);const s=t>100?50:500;return x.current=setTimeout(()=>{p.current=e.length,h(e)},s),()=>{x.current&&clearTimeout(x.current)}},[e,u.length]);const g=n.useMemo(()=>function(e,t){const s=new Map;for(const n of e){const e=n.type??n.payload_type??-1,a=O(n,{spreadingFactor:t.sf,bandwidthHz:t.bw,codingRate:t.cr,preambleLength:t.preamble}),r=s.get(e)??{count:0,airtime:0};s.set(e,{count:r.count+1,airtime:r.airtime+a})}const a=[];for(const[n,r]of s)a.push({typeNum:n,key:`TYPE_${n}`,label:mt(n),totalCount:r.count,totalAirtime:r.airtime});return a.sort((e,t)=>t.totalCount-e.totalCount)}(u,i),[u,i]),f=n.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=l/3600,C=[];for(let A=0;A24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o};for(const t of r)a.counts[t.key]=0,a.airtimes[t.key]=0;C.push(a)}for(const A of e){const e=A.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${A.type??A.payload_type??-1}`;C[r].counts[l]=(C[r].counts[l]??0)+1,C[r].total++;const o=O(A,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});C[r].airtimes[l]=(C[r].airtimes[l]??0)+o,C[r].totalAirtime+=o}for(const A of C)for(const e of r)A.shares[e.key]=A.total>0?A.counts[e.key]/A.total*100:0;return C}(u,t,s,a,i,g),[u,t,s,a,i,g]),b=n.useMemo(()=>At.getBuckets(u,t,s,i),[u,t,s,i]),y=n.useMemo(()=>g.reduce((e,t)=>e+t.totalCount,0),[g]),v=n.useMemo(()=>g.reduce((e,t)=>e+t.totalAirtime,0),[g]),{sortedTypes:j,aggregateShares:N}=n.useMemo(()=>{const e=new Map,t="share"===o?y:v;if(t>0)for(const s of g){const a="share"===o?s.totalCount:s.totalAirtime;e.set(s.key,a/t)}return{sortedTypes:[...g].sort((t,s)=>(e.get(s.key)??0)-(e.get(t.key)??0)),aggregateShares:e}},[g,y,v,o]),w=n.useMemo(()=>function(e,t,s,a="raw"){const n=function(e,t,s){if(e.length<=360)return e;const a=Math.ceil(e.length/360),n=[];for(let r=0;r0?l.counts[e.key]/l.total*100:0;n.push(l)}return n}(e,0,s),r=n.length,l=s.length,i=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;D0?(e.counts[s[t].key]??0)/e.total:0;else{let t=0;for(let a=0;a0?(e.airtimes[s[a].key]??0)/t:0}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;Dfunction(e,t){switch(t){case"zlema":return dt(e,6);case"ema":return dt(e,12);case"smooth":return dt(e,24);case"ultra":return dt(e,96);default:return e}}(e,a)),C=Array.from({length:l},()=>new Array(r).fill(0));for(let D=0;D0?c[D-1][e]:0;C[D][e]=Math.min(1,Math.max(0,c[D][e]-t))}for(let D=0;D0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;eE(e),[]),M=n.useCallback(e=>d(e),[]),S=n.useMemo(()=>{if(null===m||!w[m])return null;const e=w[m];return{timestamp:e.timestamp,timeLabel:e.time,items:j.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:et(t.typeNum)}))}},[m,w,j]),T=n.useMemo(()=>({timestamps:w.map(e=>e.timestamp),series:j.map(e=>({key:e.key,label:e.label,color:et(e.typeNum),values:w.map(t=>t[e.key]??0)}))}),[w,j]);return 0===u.length?0===e.length?r.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[r.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),r.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===c?r.jsx(rt,{sortedTypes:j,aggregateShares:N}):"stats"===c?r.jsx(Ct,{statsBuckets:b,mode:o,packets:u,startTs:t,endTs:s,radioConfig:i,sortedTypes:j,aggregateShares:N,noiseFloorAnomalies:C,showNoiseFloorOverlay:A,overlayOpacity:D}):"trend"===c?r.jsx(ot,{packets:u,mode:o,startTs:t,endTs:s,radioConfig:i,bucketCount:a}):r.jsxs("div",{className:"flex flex-col",children:[r.jsx("div",{className:"analyzer-chart-height relative flex-shrink-0",children:r.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:r.jsx(W,{timestamps:T.timestamps,series:T.series,highlightedKey:F,cursorColor:B.cursor,onHover:M})})}),r.jsx(tt,{sortedTypes:j,highlightedType:F,onTypeHover:k,aggregateShares:N,hoverData:S})]})}),ht={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},xt=[1,5,10,25,50,100,150];function pt(e,t,s,a){const n=Math.PI/180,r=(a-t)*n,l=e*n,i=s*n,o=Math.sin(r)*Math.cos(i),c=Math.cos(l)*Math.sin(i)-Math.sin(l)*Math.cos(i)*Math.cos(r);return(180*Math.atan2(o,c)/Math.PI+360)%360}function gt(e,t,s,a){const n=Math.PI/180,r=(s-e)*n,l=(a-t)*n,i=Math.sin(r/2)**2+Math.cos(e*n)*Math.cos(s*n)*Math.sin(l/2)**2;return 12742*Math.atan2(Math.sqrt(i),Math.sqrt(1-i))}const ft=[{min:10,label:"Excellent"},{min:7,label:"Very Good"},{min:4,label:"Good"},{min:1,label:"Fair+"},{min:-2,label:"Fair"},{min:-5,label:"Fair-"},{min:-8,label:"Poor"},{min:-11,label:"Bad"},{min:-1/0,label:"Critical"}];function bt(e,t){return t[Fe(e)]||"#808080"}const yt=n.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=n.useState(null),[c,C]=n.useState(new Set),[A,D]=n.useState({width:0,height:0}),[B,F]=n.useState("1x"),[E,m]=n.useState(1),d=n.useRef(null),h=n.useRef({}),x=n.useRef(null),p=n.useRef(null),g=n.useRef(E);g.current=E;const f=Ae(),b=oe(),y=De(),v=ce(),j=Be(),N=j?v.secondary:v.primary,w=j?.4:.15,k=j?.25:.08,M=j?v.primary:b.primary;n.useEffect(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:s}=t.contentRect;e>0&&s>0&&D({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&D({width:s.width,height:s.height}),()=>t.disconnect()},[]);const S=n.useMemo(()=>{const e=new Set;if(t)for(const s of t)e.add(s.hash);return e},[t]),T=n.useMemo(()=>{const e=new Map;if(t)for(const s of t)e.set(s.hash,{snr:s.avgSnr,rssi:s.avgRssi});return e},[t]),{processedNeighbors:R,maxDistance:$,totalNeighbors:P,zeroHopCount:L}=n.useMemo(()=>{const t=[];for(const[r,l]of Object.entries(e)){if(!l.latitude||!l.longitude||0===l.latitude||0===l.longitude)continue;if(!S.has(r))continue;const e=pt(s,a,l.latitude,l.longitude),n=gt(s,a,l.latitude,l.longitude),i=T.get(r);t.push({hash:r.slice(0,8),name:l.node_name||l.name||"Unknown",snr:(null==i?void 0:i.snr)??l.snr??null,rssi:(null==i?void 0:i.rssi)??l.rssi??null,bearing:e,distance:n,normalizedDistance:0,lastSeen:l.last_seen,isZeroHop:!0})}const n=1.08*(t.length>0?Math.max(...t.map(e=>e.distance)):0);return t.sort((e,t)=>(e.snr??-1/0)-(t.snr??-1/0)),{processedNeighbors:t,maxDistance:n,totalNeighbors:t.length,zeroHopCount:t.length}},[e,s,a,S,T]);n.useEffect(()=>{null==l||l({zeroHopCount:L,totalCount:P,maxDistanceKm:$})},[L,P,$]),n.useEffect(()=>{const e=ht[B],t=g.current;d.current&&cancelAnimationFrame(d.current);const s=performance.now(),a=n=>{const r=n-s,l=Math.min(r/400,1),i=(o=l)<.5?8*o*o*o*o:1-Math.pow(-2*o+2,4)/2;var o;m(t+(e-t)*i),d.current=l<1?requestAnimationFrame(a):null};return d.current=requestAnimationFrame(a),()=>{d.current&&cancelAnimationFrame(d.current)}},[B]);const z=$/E,_=n.useMemo(()=>xt.filter(e=>e<=1.1*z),[z]);n.useEffect(()=>{const e=[];for(const s of R){const t=h.current[s.hash];void 0!==t&&t!==s.lastSeen&&e.push(s.hash),h.current[s.hash]=s.lastSeen}if(0===e.length)return;queueMicrotask(()=>{C(t=>new Set([...t,...e]))});const t=setTimeout(()=>{C(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[R]);const H=0!==s&&0!==a,O=n.useMemo(()=>{const{width:e,height:t}=A,s=e/2,a=t/2,n=Math.max(10,e/2-12),r=Math.max(10,t/2-12),l=Math.max(10,n-16),i=Math.max(10,r-16);return{width:e,height:t,centerX:s,centerY:a,maxRadiusX:l,maxRadiusY:i,labelRadiusX:n,labelRadiusY:r,cornerRadius:.2*Math.min(l,i)}},[A]),{width:W,height:I,centerX:q,centerY:G,maxRadiusX:X,maxRadiusY:K,labelRadiusX:Y,labelRadiusY:U,cornerRadius:Q}=O,Z=n.useCallback((e,t=1)=>{const s=X*t,a=K*t,n=Math.min(Q*t,s,a),r=(e%360+360)%360,l=r*Math.PI/180,i=180*Math.atan2(a-n,s-n)/Math.PI;let o,c;if(r<=45-i||r>315+i){const e=Math.tan(l);o=Math.max(q-s+n,Math.min(q+s-n,q+a*e*(s/a))),c=G-a}else if(r>45-i&&r<=45+i)o=q+s-n+n*Math.sin(l),c=G-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(G-a+n,Math.min(G+a-n,G-s*e*(a/s))),o=q+s}else if(r>135-i&&r<=135+i)o=q+s-n+n*Math.sin(l),c=G+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(q-s+n,Math.min(q+s-n,q-a*e*(s/a))),c=G+a}else if(r>225-i&&r<=225+i)o=q-s+n+n*Math.sin(l),c=G+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(G-a+n,Math.min(G+a-n,G-s*e*(a/s))),o=q-s}else o=q-s+n+n*Math.sin(l),c=G-a+n-n*Math.cos(l);return{x:o,y:c}},[q,G,X,K,Q]),J=n.useCallback((e,t)=>{const s=Z(e,1);return{x:q+(s.x-q)*t,y:G+(s.y-G)*t}},[Z,q,G]),ee=n.useCallback(e=>({N:{x:q,y:G-U},S:{x:q,y:G+U},E:{x:q+Y,y:G},W:{x:q-Y,y:G},NE:{x:q+Y,y:G-U},SE:{x:q+Y,y:G+U},SW:{x:q-Y,y:G+U},NW:{x:q-Y,y:G-U}}[e]),[q,G,Y,U]),te=n.useCallback(e=>{const t=X*e,s=K*e,a=Math.min(Q*e,t,s),n=q-t,r=q+t,l=G-s,i=G+s;return[`M ${n+a} ${l}`,`L ${r-a} ${l}`,`Q ${r} ${l} ${r} ${l+a}`,`L ${r} ${i-a}`,`Q ${r} ${i} ${r-a} ${i}`,`L ${n+a} ${i}`,`Q ${n} ${i} ${n} ${i-a}`,`L ${n} ${l+a}`,`Q ${n} ${l} ${n+a} ${l}`,"Z"].join(" ")},[q,G,X,K,Q]),se=n.useCallback(e=>{o(e)},[]),ae=n.useCallback(e=>{F(e)},[]),ne=n.useCallback(e=>$<=0?0:e/$*E,[$,E]),re=e=>`${e}km`,le=n.useMemo(()=>{const e=_.map(e=>{const t=e/$*E;return{km:e,scale:t,labelY:G-K*t*.71}}).filter(e=>e.scale<=1.05&&e.scale>=.02).sort((e,t)=>t.km-e.km),t=[];for(const s of e)t.some(e=>Math.abs(e.labelY-s.labelY)<28)||t.push(s);return t},[_,$,E,G,K]),ie=A.width>0&&A.height>0;return H?0===P?r.jsxs("div",{ref:x,className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[r.jsx(u,{className:"w-8 h-8 mb-2 opacity-50"}),r.jsx("p",{children:"No nodes with location data"})]}):r.jsxs("div",{ref:x,className:"relative h-full w-full flex overflow-hidden",children:[r.jsx("div",{ref:p,className:"relative flex-1 min-w-0 h-full",children:ie&&r.jsxs("svg",{width:W,height:I,className:"absolute inset-0 z-0",children:[r.jsxs("defs",{children:[r.jsx("style",{children:"\n @keyframes neighbor-blink-scale {\n 0%, 100% {\n transform: scale(1);\n opacity: 0;\n }\n 50% {\n transform: scale(1.3);\n opacity: 0.8;\n }\n }\n .neighbor-blink-ring {\n transform-origin: center;\n animation: neighbor-blink-scale 600ms ease-out forwards;\n }\n "}),r.jsx("clipPath",{id:"radar-clip",children:r.jsx("path",{d:te(1)})})]}),_.map(e=>{const t=ne(e);if(t>1.05||t<.02)return null;const s=le.some(t=>t.km===e),a=q+X*t*.71,n=G-K*t*.71;return r.jsxs("g",{children:[r.jsx("path",{d:te(t),fill:"none",stroke:N,strokeOpacity:w,strokeWidth:1}),s&&r.jsx("text",{x:a+4,y:n-2,textAnchor:"start",dominantBaseline:"auto",className:"fill-text-secondary",fontSize:10,fontFamily:V,children:re(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?q:"E"===e?q+X:q-X,a=t?"N"===e?G-K:G+K:G;return r.jsx("line",{x1:q,y1:G,x2:s,y2:a,stroke:N,strokeOpacity:w,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=ee(e);return r.jsx("line",{x1:q,y1:G,x2:t.x,y2:t.y,stroke:N,strokeOpacity:k,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=ee(e),s="E"===e?"end":"W"===e?"start":"middle",a="N"===e?"hanging":"S"===e?"auto":"middle";return r.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:M,fontSize:16,fontWeight:600,fontFamily:V,"aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=ee(e),s="NE"===e||"SE"===e?"end":"start",a="NE"===e||"NW"===e?"hanging":"auto";return r.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:M,fontSize:16,fontWeight:600,fontFamily:V,"aria-hidden":"true",children:e},e)}),r.jsx("circle",{cx:q,cy:G,r:5,fill:y.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),r.jsx("g",{clipPath:"url(#radar-clip)",children:R.map(e=>{const t=$>0?e.distance/$*E:0;if(t>1)return null;const{x:s,y:a}=J(e.bearing,t),n=null!==e.snr?bt(e.snr,f):"#808080",l=(null==i?void 0:i.hash)===e.hash,o=c.has(e.hash);return r.jsxs("g",{role:"img","aria-label":`${e.name}: ${e.distance.toFixed(1)}km ${e.bearing.toFixed(0)}°`,children:[o&&r.jsx("circle",{cx:s,cy:a,r:10.5,fill:"none",stroke:"rgba(255,255,255,0.9)",strokeWidth:2,className:"neighbor-blink-ring"}),l&&r.jsx("circle",{cx:s,cy:a,r:10.5,fill:n,opacity:.3}),r.jsx("circle",{cx:s,cy:a,r:l?7:5,fill:n,stroke:"rgba(0,0,0,0.5)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>se(e),onMouseLeave:()=>se(null)})]},e.hash)})})]})}),r.jsx("div",{className:"flex flex-col h-full items-stretch gap-1 py-2 pl-2 flex-shrink-0",role:"group","aria-label":"Zoom level",children:["1x","2x","4x","8x","16x","36x"].map(e=>r.jsx("button",{onClick:()=>ae(e),"aria-pressed":B===e,className:"flex flex-1 items-center justify-center px-1.5 text-xs font-medium rounded transition-colors "+(B===e?"bg-accent-primary/20 text-accent-primary":"bg-white/5 text-text-secondary hover:bg-white/10 hover:text-text-primary"),children:e},e))}),i&&r.jsxs("div",{className:"absolute bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm pointer-events-none z-10 shadow-xl",style:{left:"50%",bottom:8,transform:"translateX(-50%)"},children:[r.jsx("div",{className:"font-medium text-text-primary",children:i.name}),r.jsx("div",{className:"text-text-secondary text-xs font-mono",children:i.hash}),null!==i.snr?r.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"SNR:"})," ",r.jsxs("span",{className:"tabular-nums",style:{color:bt(i.snr,f)},children:[i.snr.toFixed(1)," dB"]}),r.jsxs("span",{className:"text-text-secondary ml-1",children:["(",(Ce=i.snr,(null==(Fe=ft.find(e=>Ce>=e.min))?void 0:Fe.label)??"Critical"),")"]})]})}):r.jsx("div",{className:"text-xs text-text-secondary mt-1",children:"No SNR data"}),r.jsxs("div",{className:"flex gap-3 text-xs",children:[r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"Distance:"})," ",r.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.distance.toFixed(2)," km"]})]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary",children:"Bearing:"})," ",r.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):r.jsxs("div",{ref:x,className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[r.jsx(u,{className:"w-8 h-8 mb-2 opacity-50"}),r.jsx("p",{children:"Local node coordinates not configured"}),r.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]});var Ce,Fe});function vt(e,t){if(0===e.length)return 0;const s=t/100*(e.length-1),a=Math.floor(s),n=Math.ceil(s);return a===n?e[a]:e[a]+(e[n]-e[a])*(s-a)}const jt=n.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const{theme:i}=q(),[o,c]=n.useState(!0),C=n.useMemo(()=>{if(0===t.length)return null;const e=Math.min(...t),s=Math.max(...t),a=t.reduce((e,t)=>e+t,0)/t.length,n=[...t].sort((e,t)=>e-t);return{min:e,max:s,avg:a,p5:vt(n,5),p95:vt(n,95)}},[t]);n.useEffect(()=>{null==s||s(C)},[C]);const A=n.useCallback(()=>{c(e=>!e)},[]),{heatmapData:D,xLabels:B,yLabels:F}=n.useMemo(()=>{if(0===e.length||0===t.length||!C)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(C.p95-C.p5||1);s=C.p5-e,a=C.p95+e}else{const e=.1*(C.max-C.min||1);s=C.min-e,a=C.max+e}const n=a-s,r=e[0],l=e[e.length-1]-r||1,i=new Float32Array(2*e.length);for(let o=0;o{const e=m.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:s}=t.contentRect;e>0&&s>0&&u({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&u({width:s.width,height:s.height}),()=>t.disconnect()},[]),n.useEffect(()=>{const e=E.current;if(!e||!D||0===d.width)return;const t=e.getContext("2d");if(!t)return;const{width:s,height:a}=d,n=window.devicePixelRatio||1;e.width=s*n,e.height=a*n,e.style.width=`${s}px`,e.style.height=`${a}px`,t.scale(n,n),t.clearRect(0,0,s,a);const r=getComputedStyle(document.documentElement).getPropertyValue("--accent-primary").trim(),{r:l,g:i,b:o}=(e=>{const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\)/);if(t)return{r:Math.round(255*parseFloat(t[1])),g:Math.round(255*parseFloat(t[2])),b:Math.round(255*parseFloat(t[3]))};const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:{r:250,g:189,b:47}})(r),{points:c,count:C}=D,A=Math.max(3,Math.min(8,s/C*4));t.globalCompositeOperation="source-over";for(let D=0;Dr.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),r.jsxs("div",{ref:m,className:"absolute overflow-hidden",style:{left:32,right:0,top:0,bottom:20},children:[r.jsx("svg",{className:"absolute inset-0 w-full h-full",preserveAspectRatio:"none","aria-hidden":"true",children:[0,25,50,75,100].map(e=>r.jsx("line",{x1:"0",y1:`${e}%`,x2:"100%",y2:`${e}%`,stroke:"var(--chart-grid-line, rgba(255,255,255,0.06))",strokeDasharray:"3 3"},e))}),r.jsx("canvas",{ref:E,className:"absolute inset-0 w-full h-full","aria-hidden":"true"}),r.jsx("button",{type:"button",onClick:A,className:"absolute bottom-1 right-1 p-1.5 rounded bg-tooltip-bg/80 hover:bg-tooltip-bg active:bg-tooltip-bg transition-colors touch-manipulation",title:o?"Show full range (min/max)":"Show trimmed range (P5-P95)","aria-label":o?"Expand to show full data range":"Shrink to show trimmed percentile range","aria-pressed":!o,children:o?r.jsx(h,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"}):r.jsx(x,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"})})]}),r.jsx("div",{className:"absolute left-0 right-0 bottom-0",style:{left:32,height:20},"aria-hidden":"true",children:B.map((e,t)=>r.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums absolute top-1",style:{left:`${e.pos}%`,transform:"translateX(-50%)"},children:e.label},t))})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No noise floor data available"})}),Nt={repeater:"var(--accent-primary)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function wt(e){if(e.contact_type){const t=e.contact_type.toLowerCase();if("repeater"===t||"rep"===t)return"repeater";if("room server"===t||"room_server"===t||"room"===t||"server"===t)return"room_server";if("companion"===t||"client"===t||"cli"===t)return"companion"}return e.is_repeater?"repeater":"companion"}const kt=n.memo(function({neighbors:e}){const t=n.useMemo(()=>{const t={repeater:0,companion:0,room_server:0};for(const a of Object.values(e)){const e=wt(a);t[e]=(t[e]||0)+1}const s=Object.values(t).reduce((e,t)=>e+t,0);return{items:[{label:"Repeaters",count:t.repeater,percent:0,color:Nt.repeater},{label:"Companions",count:t.companion,percent:0,color:Nt.companion},{label:"Room Servers",count:t.room_server,percent:0,color:Nt.room_server}].map(e=>({...e,percent:s>0?e.count/s*100:0})).filter(e=>e.count>0).sort((e,t)=>t.count-e.count),total:s}},[e]);return 0===t.total?r.jsx("div",{className:"h-full flex items-center justify-center text-text-muted type-body-sm",children:"No neighbors discovered yet"}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:t.items.map(e=>r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"type-data-sm text-text-secondary",children:e.label}),r.jsxs("span",{className:"type-data-sm text-text-secondary tabular-nums",children:[e.count," ",r.jsxs("span",{className:"text-text-secondary/60",children:["(",e.percent.toFixed(0),"%)"]})]})]}),r.jsx("div",{className:"h-2.5 bg-bg-elevated overflow-hidden",children:r.jsx("div",{className:"h-full transition-all duration-500 ease-out",style:{width:`${e.percent}%`,backgroundColor:e.color,minWidth:e.count>0?"4px":"0"}})})]},e.label))}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border-subtle",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Total Nodes"}),r.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function Mt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=n.useRef(null),[o,c]=n.useState(!1),[C,A]=n.useState(!1);n.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{const t=e.isIntersecting;A(t),t&&c(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>{t.disconnect()}},[s]);const D=C||a&&o;return r.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:D?e:r.jsx("div",{className:"h-full w-full flex items-center justify-center text-text-muted/50",children:r.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const St={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-accent-primary"},Tt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-accent-primary/10"};function Rt(){const e=G(),t=X(),[s,a]=n.useState(null),l=n.useCallback((e,t)=>{a({prefix:e,candidateHashes:t})},[]),i=n.useCallback(()=>{a(null)},[]);if(!t)return r.jsxs(be,{children:[r.jsx(we,{icon:r.jsx(p,{}),title:"Prefix Conflicts",largeTitle:!0}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-text-secondary",children:[r.jsx(g,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{className:"type-data-xs",children:"No topology data available"}),r.jsx("p",{className:"type-data-xs opacity-70",children:"Run deep analysis to see stats"})]})})]});const o=(c=e.avgConfidence)>=.9?"excellent":c>=.7?"good":c>=.5?"fair":"poor";var c;const C=(A=e.collisionRate)<=10?"excellent":A<=25?"good":"poor";var A;const D="poor"===o||"poor"===C?"poor":"fair"===o||"fair"===C?"fair":"good"===o||"good"===C?"good":"excellent",B="excellent"===D||"good"===D?f:b;return r.jsxs(be,{className:"flex flex-col overflow-hidden",children:[r.jsx(we,{icon:r.jsx(p,{}),title:"Prefix Conflicts",largeTitle:!0,actions:r.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Tt[D]}`,children:[r.jsx(B,{className:`w-3.5 h-3.5 ${St[D]}`}),r.jsx("span",{className:`type-data-xs font-medium ${St[D]}`,children:"excellent"===D?"Excellent":"good"===D?"Good":"fair"===D?"Fair":"Needs Attention"})]})}),r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-1.5 sm:gap-2 py-3 sm:py-4",children:[r.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2",title:"Total unique 2-character prefixes observed in packet paths.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.totalPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm text-text-secondary mt-0.5 sm:mt-1",children:"Prefixes"})]}),r.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.unambiguousPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm text-text-secondary mt-0.5 sm:mt-1",children:"Unique"})]}),r.jsxs("div",{className:"flex flex-col items-center cursor-help rounded-lg sm:rounded-xl py-2 sm:py-3 px-1.5 sm:px-2 "+(e.collisionPrefixes>0?"bg-accent-primary/15":"bg-white/5"),title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[r.jsx("span",{className:"font-mono text-2xl sm:text-3xl font-semibold tabular-nums "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-primary"),style:{letterSpacing:"-0.05em"},children:e.collisionPrefixes}),r.jsx("span",{className:"type-data-xs sm:type-data-sm mt-0.5 sm:mt-1 "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-secondary"),children:"Conflicts"})]})]}),e.highCollisionPrefixes.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"type-data-xs text-text-secondary mb-1.5",children:"Problem Prefixes"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:e.highCollisionPrefixes.map(({prefix:e,candidateCount:t,candidateHashes:s})=>r.jsxs("button",{type:"button",onClick:()=>l(e,s),className:"inline-flex items-center gap-0.5 group",title:`${t} candidates - click to explore`,children:[r.jsx(je,{children:e}),r.jsxs("span",{className:"text-text-muted type-data-xs group-hover:text-text-secondary transition-colors",children:["×",t]})]},e))})]}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&r.jsx("div",{className:"flex-1 flex items-center",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(f,{className:"w-3.5 h-3.5 text-signal-excellent"}),r.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Confidence"}),r.jsxs("span",{className:`data-box ${St[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[r.jsx("span",{className:"type-data-xs text-text-secondary",children:"Collisions"}),r.jsxs("span",{className:`data-box ${St[C]}`,children:[e.collisionRate.toFixed(1),"%"]})]})]})]}),r.jsx(Ne,{isOpen:!!s,prefix:(null==s?void 0:s.prefix)||"",candidateHashes:(null==s?void 0:s.candidateHashes)||[],onClose:i})]})}function $t({icon:e,label:t,value:s,sublabel:a,highlight:n,tooltip:l}){return r.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 "+(l?"cursor-help":""),title:l,children:[r.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-0",children:[r.jsx("span",{className:"icon-xs text-icon-widget flex-shrink-0",children:e}),r.jsx("span",{className:"type-body-sm text-text-secondary truncate",children:t})]}),r.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 flex-shrink-0",children:[r.jsx("span",{className:"data-box",style:n?{"--data-box-color":"var(--accent-primary)"}:void 0,children:s}),a&&r.jsx("span",{className:"type-data-xs text-text-secondary hidden sm:inline",children:a})]})]})}function Pt(){const e=K(),t=Y().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:n,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:C,echolocationEdgesInferred:A}=e,D=s>0?((s-a)/s*100).toFixed(1):"0",B=s>0?(n/s*100).toFixed(1):"0",F=l+i,E=F>0||o>0,m=c>0||A>0;return r.jsxs(be,{children:[r.jsx(we,{title:"Path Decoder",icon:r.jsx(y,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),r.jsxs(ke,{children:[r.jsxs("div",{children:[r.jsx($t,{icon:r.jsx(v,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${D}%`,sublabel:`of ${s.toLocaleString()} paths`,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),r.jsx($t,{icon:r.jsx(j,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${B}%`,sublabel:"adapted",tooltip:"How often real traffic patterns improved our predictions over geography alone. Higher values mean the decoder is learning your mesh's actual behavior — which routes are preferred, which nodes are most active."})]}),E&&r.jsxs("div",{className:"mt-3",children:[r.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),r.jsxs("div",{children:[r.jsx($t,{icon:r.jsx(N,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:F.toLocaleString(),sublabel:l>0?`(${l} TRACE)`:void 0,tooltip:"TRACE/PATH packets from distant nodes share their routing tables. This reveals connections we can't directly observe — mapping parts of the mesh we don't touch."}),r.jsx($t,{icon:r.jsx(w,{className:"w-3.5 h-3.5"}),label:"Remote Links",value:o.toLocaleString(),highlight:o>0,tooltip:"Node-to-node connections discovered from route reports. These links exist outside our RF range but help complete the topology picture."})]})]}),m&&r.jsx($t,{icon:r.jsx(k,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:C>0?`(${C} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),t>0&&r.jsx($t,{icon:r.jsx(M,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Ghost Repeaters",value:t,highlight:!0,tooltip:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map."})]})]})}function Lt(){var e,t,s,a,i,o,c,C,A,D,B,F,E,m,d,h,x;const p=U(),g=Q(),f=Z(),b=J(),y=ee(),v=te(),j=se(),N=ae(),[w,k]=n.useState([]),[M,$]=n.useState(null),[P,L]=n.useState(null),[z,_]=n.useState(!0),[H,O]=n.useState(null),[W,I]=n.useState(()=>{const e=localStorage.getItem("statistics-view-mode");return"share"===e||"airtime"===e?e:"airtime"});n.useEffect(()=>{localStorage.setItem("statistics-view-mode",W)},[W]);const[V,q]=n.useState(()=>{const e=localStorage.getItem("statistics-smoothing-mode");return["raw","ema","zlema","smooth","ultra","mosaic","stats","trend"].includes(e)?e:"trend"});n.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",V)},[V]);const[G,X]=n.useState(!1),[K,Y]=n.useState(!1),[oe,ce]=n.useState(Oe),[Ce,Ae]=n.useState(.5),De=n.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6}[j]??3),[j]),Be=ne[De].hours,Fe=60*Be,Ee=ne[De],me=le(Be),de=v.isBackgroundLoading,ue=n.useCallback(e=>{N({0:1,1:2,2:3,3:4,4:5,5:6,6:7}[e]??4)},[N]),he=n.useMemo(()=>{var e;if(!(null==(e=null==p?void 0:p.config)?void 0:e.radio))return null;const t=p.config.radio;return{sf:t.spreading_factor??10,bw:t.bandwidth??25e4,cr:t.coding_rate??5,preamble:t.preamble_length??8}},[null==(t=null==(e=null==p?void 0:p.config)?void 0:e.radio)?void 0:t.spreading_factor,null==(a=null==(s=null==p?void 0:p.config)?void 0:s.radio)?void 0:a.bandwidth,null==(o=null==(i=null==p?void 0:p.config)?void 0:i.radio)?void 0:o.coding_rate,null==(C=null==(c=null==p?void 0:p.config)?void 0:c.radio)?void 0:C.preamble_length]);n.useEffect(()=>{!async function(){var e;O(null);try{const t=await re(Be);t.success&&(null==(e=t.data)?void 0:e.history)&&k(t.data.history)}catch(t){O(t instanceof Error?t.message:"Failed to load chart data")}finally{_(!1)}}()},[Be]);const xe=n.useMemo(()=>72===Be?6e5:168===Be?18e5:336===Be?36e5:3e5,[Be]),pe=n.useCallback(async()=>{var e;try{const t=await re(Be);t.success&&(null==(e=t.data)?void 0:e.history)&&k(t.data.history)}catch{}},[Be]);ie(pe,xe,!0,!0);const ge=n.useMemo(()=>0===w.length?{timestamps:[],values:[]}:{timestamps:w.map(e=>e.timestamp),values:w.map(e=>e.noise_floor_dbm)},[w]),je=n.useMemo(()=>{if(w.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Oe,...t};if(e.length<10)return{anomalies:[],thresholds:Ie([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=Ie(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=We(r,s.baselinePercentile),i=We(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let C=null,A=0;for(const D of o)if(D.noise_floor_dbm>l&&D.noise_floor_dbme+t,0)/C.values.length):(C.values.length>=s.minSequenceLength&&c.push(C),C={startTs:D.timestamp,endTs:D.timestamp,values:[D.noise_floor_dbm],timestamps:[D.timestamp],rollingAvg:D.noise_floor_dbm})}else C={startTs:D.timestamp,endTs:D.timestamp,values:[D.noise_floor_dbm],timestamps:[D.timestamp],rollingAvg:D.noise_floor_dbm};else C&&C.values.length>=s.minSequenceLength&&c.push(C),C=null;return C&&C.values.length>=s.minSequenceLength&&c.push(C),0===c.length?{anomalies:[],thresholds:n,totalSamples:e.length,anomalySamples:A,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:A}}:{anomalies:c.map(e=>{const t=Math.max(...e.values),s=e.values.reduce((e,t)=>e+t,0)/e.values.length;return{startTs:e.startTs,endTs:e.endTs,peakValue:t,avgValue:s,severity:Ve(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:A,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:A}}}(w,oe);return{anomalies:e.anomalies,debug:e.debug}},[w,oe]),Ne=je.anomalies,ke=n.useMemo(()=>{const e=(null==p?void 0:p.neighbors)??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!g.has(e)))},[null==p?void 0:p.neighbors,g]),Te=n.useMemo(()=>{const e=Date.now()/1e3-3600*Be;return Object.fromEntries(Object.entries(ke).filter(([,t])=>t.last_seen>=e))},[ke,Be]),Re=n.useMemo(()=>{const e=60*Fe/me,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*Fe,end:s}},[Fe,me]);return r.jsxs(ye,{children:[r.jsx(ve,{title:"Statistics",icon:r.jsx(S,{}),controls:r.jsx(fe,{ranges:ne,selectedIndex:De,onSelect:ue,isPending:de})}),H&&r.jsx(be,{className:"border border-accent-red/50 bg-accent-red/10",children:r.jsx("p",{className:"text-accent-red",children:H})}),G&&K&&r.jsxs(be,{className:"border border-accent-purple/30 bg-glass-surface/50",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),r.jsxs("span",{className:"type-data-xs text-text-muted",children:["(",Ee.label,")"]})]}),r.jsx("button",{onClick:()=>ce(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(oe.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:oe.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Baseline"}),r.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(D=null==(A=je.debug)?void 0:A.baselineCutoff)?void 0:D.toFixed(1))??"—"," dBm"]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Spike"}),r.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(F=null==(B=je.debug)?void 0:B.spikeCutoff)?void 0:F.toFixed(1))??"—"," dBm"]})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Mid-band"}),r.jsx("span",{className:"ml-2 type-data-sm text-accent-purple",children:(null==(E=je.debug)?void 0:E.midBandSamples)??0})]}),r.jsxs("div",{children:[r.jsx("span",{className:"type-micro",children:"Anomalies"}),r.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:Ne.length})]})]}),r.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[oe.useAbsoluteThresholds?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",oe.baselineDbm," dBm)"]}),r.jsx("input",{type:"range",min:"-120",max:"-60",value:oe.baselineDbm,onChange:e=>ce(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",oe.spikeDbm," dBm)"]}),r.jsx("input",{type:"range",min:"-100",max:"-20",value:oe.spikeDbm,onChange:e=>ce(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),r.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",oe.minSequenceLength,")"]}),r.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),r.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*Ce),"%)"]}),r.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:Ce,onChange:e=>Ae(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",oe.baselinePercentile,")"]}),r.jsx("input",{type:"range",min:"1",max:"50",value:oe.baselinePercentile,onChange:e=>ce(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",oe.spikePercentile,")"]}),r.jsx("input",{type:"range",min:"50",max:"99",value:oe.spikePercentile,onChange:e=>ce(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),r.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",oe.minSequenceLength,")"]}),r.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),r.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*Ce),"%)"]}),r.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:Ce,onChange:e=>Ae(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}),r.jsxs("div",{className:"mt-4 p-3 bg-glass-elevated rounded-lg",children:[r.jsx("div",{className:"type-micro mb-1",children:"Config output"}),r.jsxs("div",{className:"type-data-sm text-status-success",children:[oe.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${oe.baselineDbm}, spikeDbm: ${oe.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${oe.baselinePercentile}, spikePercentile: ${oe.spikePercentile}`,", mergeGapSeconds: ",oe.mergeGapSeconds,", minSequenceLength: ",oe.minSequenceLength,", similarityToleranceDbm: ",oe.similarityToleranceDbm]})]})]})]}),de&&r.jsx(Me,{template:"auto",children:r.jsx(be,{className:"border border-accent-primary/30 bg-accent-primary/5",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex h-3 w-3",children:[r.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-accent-primary"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"type-body-sm text-text-primary",children:["Loading ",Ee.label," data..."]}),v.loadProgress&&r.jsxs("p",{className:"type-data-xs text-text-muted mt-0.5",children:[v.loadProgress.loaded.toLocaleString()," packets (",v.loadProgress.percent,"%)"]})]})]})})}),z?r.jsx(Me,{template:"auto",children:r.jsx(be,{className:"text-center py-12",children:r.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading statistics..."})})}):r.jsxs(r.Fragment,{children:[r.jsx(Me,{template:"hero-auto",children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(l,{}),title:"Packet Analyzer",badge:Ee.label,largeTitle:!0,stackActionsOnMobile:!0,actions:r.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&r.jsx(Ft,{enabled:G,onChange:X,anomalyCount:Ne.length,showTuning:K,onTuningChange:Y}),r.jsx(Bt,{smoothing:V,onChange:q}),r.jsx(Dt,{mode:W,onChange:I})]})}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(ut,{packets:b,startTs:Re.start,endTs:Re.end,bucketCount:me,radioConfig:he??void 0,mode:W,smoothing:V,noiseFloorAnomalies:Ne,showNoiseFloorOverlay:G,overlayOpacity:Ce})})]})})}),r.jsxs(Me,{template:"panel",children:[r.jsx(Se,{span:12,md:6,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(u,{}),title:"Link Quality",badge:Ee.label,largeTitle:!0,actions:P?r.jsxs("div",{className:"flex items-center gap-3 type-data-xs text-text-muted",children:[r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.zeroHopCount})," nbr"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.totalCount})," obs"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:P.maxDistanceKm.toFixed(0)})," km"]})]}):null}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(yt,{neighbors:Te,quickNeighbors:f,localLat:(null==(d=null==(m=null==p?void 0:p.config)?void 0:m.repeater)?void 0:d.latitude)??0,localLon:(null==(x=null==(h=null==p?void 0:p.config)?void 0:h.repeater)?void 0:x.longitude)??0,onStatsChange:L})})})]})})}),r.jsx(Se,{span:12,md:6,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(T,{}),title:"Network Composition",badge:Ee.label,largeTitle:!0}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(kt,{neighbors:Te})})})]})})})]}),r.jsxs(Me,{template:"panel",children:[r.jsx(Se,{span:12,md:6,children:r.jsx(Rt,{})}),r.jsx(Se,{span:12,md:6,children:r.jsx(Pt,{})})]}),r.jsx(Me,{template:"panel",children:r.jsx(Se,{span:12,children:r.jsx(be,{isLoaded:y,skeletonType:"chart",children:y&&r.jsxs(r.Fragment,{children:[r.jsx(we,{icon:r.jsx(R,{}),title:"RF Noise Floor",largeTitle:!0,stackActionsOnMobile:!0,actions:M?r.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["min ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.min.toFixed(0)})]}),r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["avg ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.avg.toFixed(0)})]}),r.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["max ",r.jsx("span",{className:"text-text-secondary tabular-nums",children:M.max.toFixed(0)})]}),r.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})]}):r.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Mt,{children:r.jsx(jt,{timestamps:ge.timestamps,values:ge.values,onStatsChange:$})})})]})})})})]})]})}export{Lt as default}; diff --git a/frontend/dist/assets/System-Cw2qx9Xo.js b/frontend/dist/assets/System-BPwbPFCW.js similarity index 98% rename from frontend/dist/assets/System-Cw2qx9Xo.js rename to frontend/dist/assets/System-BPwbPFCW.js index 00eeae87..b3bd5fb3 100644 --- a/frontend/dist/assets/System-Cw2qx9Xo.js +++ b/frontend/dist/assets/System-BPwbPFCW.js @@ -1 +1 @@ -import{r as e,j as t,am as s,bx as a,ax as n,ao as r,aX as l,aj as c,by as i,bz as o,aH as m,C as x,at as d}from"./vendor-react-C341c8YC.js";import{n as u,R as p,A as h,C as j,X as f,Y as g,T as y,v as b}from"./recharts-6XUQYgRA.js";import{ao as v,ap as N,aq as w,ar as k,S as _,as as C,at as M,F as S}from"./index-CPdqYR4z.js";import{a as F,b as T}from"./useThemeColors-AeHMyThq.js";import{P as B,b as R,a as L}from"./PageLayout-CcoYWyzO.js";import{R as $,C as P}from"./Grid-BOO-7ObJ.js";import{C as A}from"./Card-BeZKc0xw.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const U=_.hero,D=_.hero,E={warning:80,danger:95},G={warning:85,danger:95},K={warning:70,danger:85},O=[{threshold:30,color:"var(--accent-tertiary)"},{threshold:50,color:"var(--accent-primary)"},{threshold:65,color:"var(--accent-secondary)"},{threshold:80,color:"var(--signal-poor)"}];function W(e,t,s){const a=s-t,n={cold:(30-t)/a*100,normal:(50-t)/a*100,warm:(65-t)/a*100,hot:(80-t)/a*100};return`linear-gradient(to right, ${[{pos:0,color:"var(--accent-tertiary)"},{pos:n.cold,color:"var(--accent-tertiary)"},{pos:n.cold,color:"var(--accent-primary)"},{pos:n.normal,color:"var(--accent-primary)"},{pos:n.normal,color:"var(--accent-secondary)"},{pos:n.warm,color:"var(--accent-secondary)"},{pos:n.warm,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--accent-danger)"},{pos:100,color:"var(--accent-danger)"}].map(t=>{const s=e>0?t.pos/e*100:0;return`${t.color} ${Math.min(s,100)}%`}).join(", ")})`}function I(e,t){return e>=t.danger?"danger":e>=t.warning?"warning":"none"}function X(e){let t="none";for(const s of Object.values(e)){const e=I(s,K);if("danger"===e)return"danger";"warning"===e&&(t="warning")}return t}function z(e){let t,s,a;return e>=1073741824?(t=e/1073741824,s="GB/s"):e>=1048576?(t=e/1048576,s="MB/s"):e>=1024?(t=e/1024,s="KB/s"):(t=e,s="B/s"),a=t>=100?t.toFixed(0):t.toFixed(1),`${a} ${s}`}function H(e){return e>=1073741824?{value:(e/1073741824).toFixed(1),unit:"GiB"}:e>=1048576?{value:(e/1048576).toFixed(1),unit:"MiB"}:e>=1024?{value:(e/1024).toFixed(1),unit:"KiB"}:{value:String(e),unit:"B"}}const q=e.memo(function({level:e}){return"none"===e?null:t.jsxs("span",{className:u("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium","danger"===e&&"bg-accent-danger/20 text-accent-danger","warning"===e&&"bg-accent-secondary/20 text-accent-secondary"),children:[t.jsx(d,{className:"w-3 h-3"}),"danger"===e?"High":"Warn"]})}),Y=e.memo(function({data:e,color:s,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-e.length)).fill(0),...e.slice(-n)],l=Math.max(...r,1),c=r.map(e=>0===e?0:Math.max(e/l*100,3));return t.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:c.map((e,a)=>t.jsx("div",{className:"flex-1 min-w-0",style:{height:e>0?`${e}%`:"0%",backgroundColor:e>0?s:"transparent"}},a))})}),J=e.memo(function({value:e,max:s=100,width:a=10,color:n="primary"}){const r=Math.min(e/s,1),l=Math.round(r*a),c=a-l,i="■".repeat(l),o="·".repeat(c),m={primary:"text-accent-primary",secondary:"text-accent-secondary",success:"text-accent-success",danger:"text-accent-danger"}[n];return t.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[t.jsx("span",{className:m,children:i}),t.jsx("span",{className:"text-text-muted/40",children:o})]})}),Q=e.memo(function({index:e,usage:s}){const a=s>90?"danger":s>70?"secondary":"primary";return t.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono",children:[t.jsxs("span",{className:"text-text-muted w-5",children:["C",e]}),t.jsx(J,{value:s,width:8,color:a}),t.jsxs("span",{className:u("w-7 text-right tabular-nums",s>90?"text-accent-danger":s>70?"text-accent-secondary":"text-accent-success"),children:[s.toFixed(0),"%"]})]})}),V=e.memo(function({pid:e,name:s,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:l=!1}){return t.jsxs("div",{className:"flex items-center gap-2 py-1 text-sm font-mono hover:bg-subtle-fill -mx-1 px-1 rounded",children:[t.jsx("span",{className:"text-text-muted w-14 tabular-nums",children:e}),t.jsx("span",{className:"flex-1 truncate text-text-primary",children:s}),t.jsx(J,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"}),t.jsx("span",{className:u("w-12 text-right tabular-nums",r?"text-text-primary":a>50?"text-accent-danger":a>20?"text-accent-secondary":"text-text-muted"),children:a.toFixed(1)}),t.jsx("span",{className:u("w-12 text-right tabular-nums",l?"text-text-primary":n>50?"text-accent-danger":n>20?"text-accent-secondary":"text-text-muted"),children:n.toFixed(1)})]})}),Z=e.memo(function({value:e,label:s,min:a=20,max:n=100}){const r=Math.min(Math.max((e-a)/(n-a)*100,0),100),l=function(e){return e<30?{text:"Cool",color:"text-accent-tertiary"}:e<50?{text:"Normal",color:"text-accent-primary"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=n-a;return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:s}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:l.text}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded text-sm font-mono tabular-nums",children:[t.jsx("span",{className:l.color,children:e.toFixed(1)}),t.jsx("span",{className:"text-text-primary",children:"°C"})]})]})]}),t.jsxs("div",{className:"relative h-3 bg-subtle-fill overflow-hidden",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 transition-all duration-300 ease-out",style:{background:W(r,a,n),width:`${r}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:O.map(({threshold:e,color:s})=>{const n=(e-a)/c*100;return n<0||n>100?null:t.jsx("div",{className:"absolute w-px h-full",style:{left:`${n}%`,backgroundColor:s}},e)})})]})]})});function ee({active:e,payload:s,label:a}){return e&&(null==s?void 0:s.length)?t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[t.jsx("div",{className:"font-medium text-text-primary mb-1",children:a}),s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),t.jsxs("span",{className:"text-text-primary tabular-nums",children:[e.value.toFixed(1),"%"]})]},s))]}):null}const te=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:n}){const r=function(e){const t=[],s=Math.max(0,U-e.length),a=Date.now(),n=C.system;for(let l=0;l`${e}%`}),t.jsx(y,{content:t.jsx(ee,{})}),t.jsx(b,{type:"stepAfter",dataKey:"cpu",name:"CPU",stroke:"none",fill:s,fillOpacity:1,isAnimationActive:!1,connectNulls:!1}),t.jsx(b,{type:"stepAfter",dataKey:"memory",name:"Memory",stroke:a,strokeWidth:2.5,fill:"none",isAnimationActive:!1,connectNulls:!1})]})})})});function se(){var d;const[p,h]=e.useState(null),[j,f]=e.useState([]),[g,y]=e.useState(!0),[b,S]=e.useState(null),[K,O]=e.useState(!1),[W,J]=e.useState(!1),[ee,se]=e.useState([]),[ae,ne]=e.useState(0),[re,le]=e.useState(0),ce=e.useRef(null),ie=v(),oe=N(),me=F(),xe=T(),de=xe.primary,ue=xe.tertiary,pe=function(){const[t,s]=e.useState("undefined"!=typeof window&&window.matchMedia("(max-width: 767px)").matches);return e.useEffect(()=>{const e=window.matchMedia("(max-width: 767px)");s(e.matches);const t=e=>s(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),t?_.hero:40}(),he=e.useCallback(async()=>{var e;try{const[t,s]=await Promise.all([w(),k()]);if(t.success&&t.data){const e=t.data;h(e),S(null),oe(e.cpu.usage_percent,e.memory.usage_percent,U);const s=Date.now(),a={timestamp:s,bytesRecv:e.network.bytes_recv,bytesSent:e.network.bytes_sent};if(ce.current){const e=(s-ce.current.timestamp)/1e3;if(e>0){const t=(a.bytesRecv-ce.current.bytesRecv)/e,s=(a.bytesSent-ce.current.bytesSent)/e;t>=0&&s>=0&&(ne(t),le(s))}}ce.current=a,se(e=>[...e,a].slice(-D))}else S(t.error??"Failed to fetch hardware stats");s.success&&(null==(e=s.data)?void 0:e.processes)&&f(s.data.processes)}catch(t){S(t instanceof Error?t.message:"Failed to fetch hardware stats")}},[oe]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await he(),e&&y(!1))})(),"undefined"==typeof Worker){const t=setInterval(he,C.system);return()=>{e=!1,clearInterval(t)}}{const s=`setInterval(() => postMessage('tick'), ${C.system});`,a=new Blob([s],{type:"application/javascript"});t=new Worker(URL.createObjectURL(a)),t.onmessage=()=>{e&&he()}}return()=>{e=!1,null==t||t.terminate()}},[he]),t.jsxs(B,{children:[t.jsx(R,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{O(!0),await he(),O(!1)},disabled:K,className:"flex items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2 bg-bg-subtle hover:bg-bg-elevated rounded-lg transition-colors text-sm text-text-muted hover:text-text-primary self-start sm:self-auto",children:[t.jsx(s,{className:u("w-4 h-4",K&&"animate-spin")}),"Refresh"]})}),b&&t.jsx(L,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:b})}),g?t.jsx(L,{className:"p-12 text-center",children:t.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading system stats..."})}):p?t.jsxs(t.Fragment,{children:[t.jsx($,{template:"hero",children:t.jsxs(L,{children:[t.jsx(A,{icon:t.jsx(n,{}),title:"System Resources",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-4",children:[(null==(d=p.system)?void 0:d.uptime)&&t.jsx("span",{className:"px-2 py-0.5 bg-white/[0.04] rounded text-sm font-mono tabular-nums text-text-primary",children:M(p.system.uptime)}),t.jsx(q,{level:I(p.cpu.usage_percent,E)}),t.jsx(q,{level:I(p.memory.usage_percent,G)}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:"CPU"}),t.jsxs("span",{className:"text-base font-mono font-semibold tabular-nums",style:{color:de},children:[p.cpu.usage_percent.toFixed(0),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:"MEM"}),t.jsxs("span",{className:"text-base font-mono font-semibold tabular-nums",style:{color:ue},children:[p.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0 mt-2",children:t.jsx(te,{data:ie,cpuColor:de,memoryColor:ue,chartGridColors:me})}),p.cpu.per_core_percent&&p.cpu.per_core_percent.length>0&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:p.cpu.per_core_percent.map((e,s)=>t.jsx(Q,{index:s,usage:e},s))})})]})}),t.jsxs($,{template:"compact",children:[t.jsx(P,{span:12,md:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(l,{}),title:"Network",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(r,{className:"w-3.5 h-3.5",style:{color:ue}}),t.jsx("span",{className:"text-xs font-mono",style:{color:ue},children:"TX"}),t.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded text-sm font-mono tabular-nums text-text-primary",children:z(re)})]})}),t.jsxs("div",{className:"flex-1 flex flex-col min-h-[80px]",children:[t.jsx("div",{className:"flex-1 min-h-[40px]",children:t.jsx(Y,{data:ee.map((e,t,s)=>{if(0===t)return 0;const a=(e.timestamp-s[t-1].timestamp)/1e3;return a>0?(e.bytesSent-s[t-1].bytesSent)/a:0}),color:ue,fixedSlots:pe})}),t.jsx("div",{className:"flex-1 min-h-[40px]",children:t.jsx(Y,{data:ee.map((e,t,s)=>{if(0===t)return 0;const a=(e.timestamp-s[t-1].timestamp)/1e3;return a>0?(e.bytesRecv-s[t-1].bytesRecv)/a:0}),color:de,flipped:!0,fixedSlots:pe})})]}),t.jsxs("div",{className:"pt-2 flex justify-between items-center text-sm font-mono",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Total"}),t.jsxs("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[t.jsx("span",{className:"text-accent-tertiary",children:H(p.network.bytes_sent).value})," ",t.jsx("span",{className:"text-text-muted",children:H(p.network.bytes_sent).unit})]}),t.jsxs("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[t.jsx("span",{className:"text-accent-primary",children:H(p.network.bytes_recv).value})," ",t.jsx("span",{className:"text-text-muted",children:H(p.network.bytes_recv).unit})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(c,{className:"w-3.5 h-3.5",style:{color:de}}),t.jsx("span",{className:"text-xs font-mono",style:{color:de},children:"RX"}),t.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:z(ae)})]})]})]})}),t.jsx(P,{span:12,md:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(i,{}),title:"Temperature",largeTitle:!0,actions:p.temperatures&&t.jsx(q,{level:X(p.temperatures)})}),t.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:p.temperatures&&Object.keys(p.temperatures).length>0?t.jsxs("div",{className:"space-y-3",children:[void 0!==p.temperatures.cpu_thermal&&t.jsx(Z,{value:p.temperatures.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(p.temperatures).filter(([e])=>"cpu_thermal"!==e).slice(0,2).map(([e,s])=>t.jsx(Z,{value:s,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),min:20,max:100},e))]}):t.jsxs("div",{className:"flex items-center justify-center text-text-muted text-sm",children:[t.jsx(n,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})})]}),t.jsxs($,{template:"compact",children:[t.jsx(P,{span:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(n,{}),title:"Memory",largeTitle:!0,actions:t.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded text-base font-mono tabular-nums",style:{color:ue},children:[p.memory.usage_percent.toFixed(0),"%"]})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[t.jsxs("div",{className:"flex gap-1 h-12",children:[t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-primary",style:{width:`${p.memory.usage_percent}%`}}),t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-tertiary",style:{width:100-p.memory.usage_percent+"%"}})]}),t.jsxs("div",{className:"flex items-center justify-between text-xs font-mono pt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-primary"}),t.jsx("span",{className:"text-text-muted",children:"Used"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:[(p.memory.used/1048576).toFixed(0)," MB"]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-tertiary"}),t.jsx("span",{className:"text-text-muted",children:"Avail"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-muted",children:[(p.memory.available/1048576).toFixed(0)," MB"]})]})]})]})]})}),t.jsx(P,{span:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(o,{}),title:"Disk",largeTitle:!0,actions:t.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded text-base font-mono tabular-nums",style:{color:de},children:[p.disk.usage_percent.toFixed(0),"%"]})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[t.jsxs("div",{className:"flex gap-1 h-12",children:[t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-primary",style:{width:`${p.disk.usage_percent}%`}}),t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-tertiary",style:{width:100-p.disk.usage_percent+"%"}})]}),t.jsxs("div",{className:"flex items-center justify-between text-xs font-mono pt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-primary"}),t.jsx("span",{className:"text-text-muted",children:"Used"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:[(p.disk.used/1073741824).toFixed(1)," GB"]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-tertiary"}),t.jsx("span",{className:"text-text-muted",children:"Free"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-muted",children:[(p.disk.free/1073741824).toFixed(1)," GB"]})]})]})]})]})})]}),j.length>0&&t.jsx($,{template:"auto",children:t.jsx(L,{noPadding:!0,children:t.jsxs("div",{className:"px-4 py-3",children:[t.jsx(A,{icon:t.jsx(n,{}),title:"Processes",largeTitle:!0,actions:t.jsxs("button",{onClick:()=>J(!W),className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[W?"Less":"More",W?t.jsx(m,{className:"w-3 h-3"}):t.jsx(x,{className:"w-3 h-3"})]})}),t.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-sm text-text-muted border-b border-border-subtle font-mono",children:[t.jsx("span",{className:"w-14",children:"PID"}),t.jsx("span",{className:"flex-1",children:"Program"}),t.jsx("span",{className:"w-[52px]"}),t.jsx("span",{className:"w-12 text-right",children:"CPU%"}),t.jsx("span",{className:"w-12 text-right",children:"MEM%"})]}),(()=>{const e=j.slice(0,W?10:5),s=Math.max(...e.map(e=>e.cpu_percent)),a=Math.max(...e.map(e=>e.memory_percent));return e.map(e=>t.jsx(V,{pid:e.pid,name:e.name,cpu:e.cpu_percent,mem:e.memory_percent,isTopCpu:e.cpu_percent===s&&s>0,isTopMem:e.memory_percent===a&&a>0},e.pid))})()]})})})]}):null]})}export{se as default}; +import{r as e,j as t,am as s,bx as a,ax as n,ao as r,aX as l,aj as c,by as i,bz as o,aH as m,C as x,at as d}from"./vendor-react-C341c8YC.js";import{n as u,R as p,A as h,C as j,X as f,Y as g,T as y,v as b}from"./recharts-6XUQYgRA.js";import{ao as v,ap as N,aq as w,ar as k,S as _,as as C,at as M,F as S}from"./index-BJEgt3tp.js";import{a as F,b as T}from"./useThemeColors-AeHMyThq.js";import{P as B,b as R,a as L}from"./PageLayout-CnF5SScd.js";import{R as $,C as P}from"./Grid-BOO-7ObJ.js";import{C as A}from"./Card-2pQSGkKC.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const U=_.hero,D=_.hero,E={warning:80,danger:95},G={warning:85,danger:95},K={warning:70,danger:85},O=[{threshold:30,color:"var(--accent-tertiary)"},{threshold:50,color:"var(--accent-primary)"},{threshold:65,color:"var(--accent-secondary)"},{threshold:80,color:"var(--signal-poor)"}];function W(e,t,s){const a=s-t,n={cold:(30-t)/a*100,normal:(50-t)/a*100,warm:(65-t)/a*100,hot:(80-t)/a*100};return`linear-gradient(to right, ${[{pos:0,color:"var(--accent-tertiary)"},{pos:n.cold,color:"var(--accent-tertiary)"},{pos:n.cold,color:"var(--accent-primary)"},{pos:n.normal,color:"var(--accent-primary)"},{pos:n.normal,color:"var(--accent-secondary)"},{pos:n.warm,color:"var(--accent-secondary)"},{pos:n.warm,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--signal-poor)"},{pos:n.hot,color:"var(--accent-danger)"},{pos:100,color:"var(--accent-danger)"}].map(t=>{const s=e>0?t.pos/e*100:0;return`${t.color} ${Math.min(s,100)}%`}).join(", ")})`}function I(e,t){return e>=t.danger?"danger":e>=t.warning?"warning":"none"}function X(e){let t="none";for(const s of Object.values(e)){const e=I(s,K);if("danger"===e)return"danger";"warning"===e&&(t="warning")}return t}function z(e){let t,s,a;return e>=1073741824?(t=e/1073741824,s="GB/s"):e>=1048576?(t=e/1048576,s="MB/s"):e>=1024?(t=e/1024,s="KB/s"):(t=e,s="B/s"),a=t>=100?t.toFixed(0):t.toFixed(1),`${a} ${s}`}function H(e){return e>=1073741824?{value:(e/1073741824).toFixed(1),unit:"GiB"}:e>=1048576?{value:(e/1048576).toFixed(1),unit:"MiB"}:e>=1024?{value:(e/1024).toFixed(1),unit:"KiB"}:{value:String(e),unit:"B"}}const q=e.memo(function({level:e}){return"none"===e?null:t.jsxs("span",{className:u("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium","danger"===e&&"bg-accent-danger/20 text-accent-danger","warning"===e&&"bg-accent-secondary/20 text-accent-secondary"),children:[t.jsx(d,{className:"w-3 h-3"}),"danger"===e?"High":"Warn"]})}),Y=e.memo(function({data:e,color:s,flipped:a=!1,fixedSlots:n}){const r=[...Array(Math.max(0,n-e.length)).fill(0),...e.slice(-n)],l=Math.max(...r,1),c=r.map(e=>0===e?0:Math.max(e/l*100,3));return t.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:c.map((e,a)=>t.jsx("div",{className:"flex-1 min-w-0",style:{height:e>0?`${e}%`:"0%",backgroundColor:e>0?s:"transparent"}},a))})}),J=e.memo(function({value:e,max:s=100,width:a=10,color:n="primary"}){const r=Math.min(e/s,1),l=Math.round(r*a),c=a-l,i="■".repeat(l),o="·".repeat(c),m={primary:"text-accent-primary",secondary:"text-accent-secondary",success:"text-accent-success",danger:"text-accent-danger"}[n];return t.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[t.jsx("span",{className:m,children:i}),t.jsx("span",{className:"text-text-muted/40",children:o})]})}),Q=e.memo(function({index:e,usage:s}){const a=s>90?"danger":s>70?"secondary":"primary";return t.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono",children:[t.jsxs("span",{className:"text-text-muted w-5",children:["C",e]}),t.jsx(J,{value:s,width:8,color:a}),t.jsxs("span",{className:u("w-7 text-right tabular-nums",s>90?"text-accent-danger":s>70?"text-accent-secondary":"text-accent-success"),children:[s.toFixed(0),"%"]})]})}),V=e.memo(function({pid:e,name:s,cpu:a,mem:n,isTopCpu:r=!1,isTopMem:l=!1}){return t.jsxs("div",{className:"flex items-center gap-2 py-1 text-sm font-mono hover:bg-subtle-fill -mx-1 px-1 rounded",children:[t.jsx("span",{className:"text-text-muted w-14 tabular-nums",children:e}),t.jsx("span",{className:"flex-1 truncate text-text-primary",children:s}),t.jsx(J,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"}),t.jsx("span",{className:u("w-12 text-right tabular-nums",r?"text-text-primary":a>50?"text-accent-danger":a>20?"text-accent-secondary":"text-text-muted"),children:a.toFixed(1)}),t.jsx("span",{className:u("w-12 text-right tabular-nums",l?"text-text-primary":n>50?"text-accent-danger":n>20?"text-accent-secondary":"text-text-muted"),children:n.toFixed(1)})]})}),Z=e.memo(function({value:e,label:s,min:a=20,max:n=100}){const r=Math.min(Math.max((e-a)/(n-a)*100,0),100),l=function(e){return e<30?{text:"Cool",color:"text-accent-tertiary"}:e<50?{text:"Normal",color:"text-accent-primary"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=n-a;return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:s}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:l.text}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded text-sm font-mono tabular-nums",children:[t.jsx("span",{className:l.color,children:e.toFixed(1)}),t.jsx("span",{className:"text-text-primary",children:"°C"})]})]})]}),t.jsxs("div",{className:"relative h-3 bg-subtle-fill overflow-hidden",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 transition-all duration-300 ease-out",style:{background:W(r,a,n),width:`${r}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:O.map(({threshold:e,color:s})=>{const n=(e-a)/c*100;return n<0||n>100?null:t.jsx("div",{className:"absolute w-px h-full",style:{left:`${n}%`,backgroundColor:s}},e)})})]})]})});function ee({active:e,payload:s,label:a}){return e&&(null==s?void 0:s.length)?t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[t.jsx("div",{className:"font-medium text-text-primary mb-1",children:a}),s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),t.jsxs("span",{className:"text-text-primary tabular-nums",children:[e.value.toFixed(1),"%"]})]},s))]}):null}const te=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:n}){const r=function(e){const t=[],s=Math.max(0,U-e.length),a=Date.now(),n=C.system;for(let l=0;l`${e}%`}),t.jsx(y,{content:t.jsx(ee,{})}),t.jsx(b,{type:"stepAfter",dataKey:"cpu",name:"CPU",stroke:"none",fill:s,fillOpacity:1,isAnimationActive:!1,connectNulls:!1}),t.jsx(b,{type:"stepAfter",dataKey:"memory",name:"Memory",stroke:a,strokeWidth:2.5,fill:"none",isAnimationActive:!1,connectNulls:!1})]})})})});function se(){var d;const[p,h]=e.useState(null),[j,f]=e.useState([]),[g,y]=e.useState(!0),[b,S]=e.useState(null),[K,O]=e.useState(!1),[W,J]=e.useState(!1),[ee,se]=e.useState([]),[ae,ne]=e.useState(0),[re,le]=e.useState(0),ce=e.useRef(null),ie=v(),oe=N(),me=F(),xe=T(),de=xe.primary,ue=xe.tertiary,pe=function(){const[t,s]=e.useState("undefined"!=typeof window&&window.matchMedia("(max-width: 767px)").matches);return e.useEffect(()=>{const e=window.matchMedia("(max-width: 767px)");s(e.matches);const t=e=>s(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),t?_.hero:40}(),he=e.useCallback(async()=>{var e;try{const[t,s]=await Promise.all([w(),k()]);if(t.success&&t.data){const e=t.data;h(e),S(null),oe(e.cpu.usage_percent,e.memory.usage_percent,U);const s=Date.now(),a={timestamp:s,bytesRecv:e.network.bytes_recv,bytesSent:e.network.bytes_sent};if(ce.current){const e=(s-ce.current.timestamp)/1e3;if(e>0){const t=(a.bytesRecv-ce.current.bytesRecv)/e,s=(a.bytesSent-ce.current.bytesSent)/e;t>=0&&s>=0&&(ne(t),le(s))}}ce.current=a,se(e=>[...e,a].slice(-D))}else S(t.error??"Failed to fetch hardware stats");s.success&&(null==(e=s.data)?void 0:e.processes)&&f(s.data.processes)}catch(t){S(t instanceof Error?t.message:"Failed to fetch hardware stats")}},[oe]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await he(),e&&y(!1))})(),"undefined"==typeof Worker){const t=setInterval(he,C.system);return()=>{e=!1,clearInterval(t)}}{const s=`setInterval(() => postMessage('tick'), ${C.system});`,a=new Blob([s],{type:"application/javascript"});t=new Worker(URL.createObjectURL(a)),t.onmessage=()=>{e&&he()}}return()=>{e=!1,null==t||t.terminate()}},[he]),t.jsxs(B,{children:[t.jsx(R,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{O(!0),await he(),O(!1)},disabled:K,className:"flex items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2 bg-bg-subtle hover:bg-bg-elevated rounded-lg transition-colors text-sm text-text-muted hover:text-text-primary self-start sm:self-auto",children:[t.jsx(s,{className:u("w-4 h-4",K&&"animate-spin")}),"Refresh"]})}),b&&t.jsx(L,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:b})}),g?t.jsx(L,{className:"p-12 text-center",children:t.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading system stats..."})}):p?t.jsxs(t.Fragment,{children:[t.jsx($,{template:"hero",children:t.jsxs(L,{children:[t.jsx(A,{icon:t.jsx(n,{}),title:"System Resources",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-4",children:[(null==(d=p.system)?void 0:d.uptime)&&t.jsx("span",{className:"px-2 py-0.5 bg-white/[0.04] rounded text-sm font-mono tabular-nums text-text-primary",children:M(p.system.uptime)}),t.jsx(q,{level:I(p.cpu.usage_percent,E)}),t.jsx(q,{level:I(p.memory.usage_percent,G)}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:"CPU"}),t.jsxs("span",{className:"text-base font-mono font-semibold tabular-nums",style:{color:de},children:[p.cpu.usage_percent.toFixed(0),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-mono text-text-muted",children:"MEM"}),t.jsxs("span",{className:"text-base font-mono font-semibold tabular-nums",style:{color:ue},children:[p.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0 mt-2",children:t.jsx(te,{data:ie,cpuColor:de,memoryColor:ue,chartGridColors:me})}),p.cpu.per_core_percent&&p.cpu.per_core_percent.length>0&&t.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:p.cpu.per_core_percent.map((e,s)=>t.jsx(Q,{index:s,usage:e},s))})})]})}),t.jsxs($,{template:"compact",children:[t.jsx(P,{span:12,md:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(l,{}),title:"Network",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(r,{className:"w-3.5 h-3.5",style:{color:ue}}),t.jsx("span",{className:"text-xs font-mono",style:{color:ue},children:"TX"}),t.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded text-sm font-mono tabular-nums text-text-primary",children:z(re)})]})}),t.jsxs("div",{className:"flex-1 flex flex-col min-h-[80px]",children:[t.jsx("div",{className:"flex-1 min-h-[40px]",children:t.jsx(Y,{data:ee.map((e,t,s)=>{if(0===t)return 0;const a=(e.timestamp-s[t-1].timestamp)/1e3;return a>0?(e.bytesSent-s[t-1].bytesSent)/a:0}),color:ue,fixedSlots:pe})}),t.jsx("div",{className:"flex-1 min-h-[40px]",children:t.jsx(Y,{data:ee.map((e,t,s)=>{if(0===t)return 0;const a=(e.timestamp-s[t-1].timestamp)/1e3;return a>0?(e.bytesRecv-s[t-1].bytesRecv)/a:0}),color:de,flipped:!0,fixedSlots:pe})})]}),t.jsxs("div",{className:"pt-2 flex justify-between items-center text-sm font-mono",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Total"}),t.jsxs("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[t.jsx("span",{className:"text-accent-tertiary",children:H(p.network.bytes_sent).value})," ",t.jsx("span",{className:"text-text-muted",children:H(p.network.bytes_sent).unit})]}),t.jsxs("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[t.jsx("span",{className:"text-accent-primary",children:H(p.network.bytes_recv).value})," ",t.jsx("span",{className:"text-text-muted",children:H(p.network.bytes_recv).unit})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(c,{className:"w-3.5 h-3.5",style:{color:de}}),t.jsx("span",{className:"text-xs font-mono",style:{color:de},children:"RX"}),t.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:z(ae)})]})]})]})}),t.jsx(P,{span:12,md:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(i,{}),title:"Temperature",largeTitle:!0,actions:p.temperatures&&t.jsx(q,{level:X(p.temperatures)})}),t.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:p.temperatures&&Object.keys(p.temperatures).length>0?t.jsxs("div",{className:"space-y-3",children:[void 0!==p.temperatures.cpu_thermal&&t.jsx(Z,{value:p.temperatures.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(p.temperatures).filter(([e])=>"cpu_thermal"!==e).slice(0,2).map(([e,s])=>t.jsx(Z,{value:s,label:e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),min:20,max:100},e))]}):t.jsxs("div",{className:"flex items-center justify-center text-text-muted text-sm",children:[t.jsx(n,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})})]}),t.jsxs($,{template:"compact",children:[t.jsx(P,{span:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(n,{}),title:"Memory",largeTitle:!0,actions:t.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded text-base font-mono tabular-nums",style:{color:ue},children:[p.memory.usage_percent.toFixed(0),"%"]})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[t.jsxs("div",{className:"flex gap-1 h-12",children:[t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-primary",style:{width:`${p.memory.usage_percent}%`}}),t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-tertiary",style:{width:100-p.memory.usage_percent+"%"}})]}),t.jsxs("div",{className:"flex items-center justify-between text-xs font-mono pt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-primary"}),t.jsx("span",{className:"text-text-muted",children:"Used"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:[(p.memory.used/1048576).toFixed(0)," MB"]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-tertiary"}),t.jsx("span",{className:"text-text-muted",children:"Avail"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-muted",children:[(p.memory.available/1048576).toFixed(0)," MB"]})]})]})]})]})}),t.jsx(P,{span:6,children:t.jsxs(L,{className:"flex flex-col",children:[t.jsx(A,{icon:t.jsx(o,{}),title:"Disk",largeTitle:!0,actions:t.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded text-base font-mono tabular-nums",style:{color:de},children:[p.disk.usage_percent.toFixed(0),"%"]})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[t.jsxs("div",{className:"flex gap-1 h-12",children:[t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-primary",style:{width:`${p.disk.usage_percent}%`}}),t.jsx("div",{className:"h-full transition-all duration-300 bg-accent-tertiary",style:{width:100-p.disk.usage_percent+"%"}})]}),t.jsxs("div",{className:"flex items-center justify-between text-xs font-mono pt-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-primary"}),t.jsx("span",{className:"text-text-muted",children:"Used"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-primary",children:[(p.disk.used/1073741824).toFixed(1)," GB"]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-accent-tertiary"}),t.jsx("span",{className:"text-text-muted",children:"Free"}),t.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-text-muted",children:[(p.disk.free/1073741824).toFixed(1)," GB"]})]})]})]})]})})]}),j.length>0&&t.jsx($,{template:"auto",children:t.jsx(L,{noPadding:!0,children:t.jsxs("div",{className:"px-4 py-3",children:[t.jsx(A,{icon:t.jsx(n,{}),title:"Processes",largeTitle:!0,actions:t.jsxs("button",{onClick:()=>J(!W),className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[W?"Less":"More",W?t.jsx(m,{className:"w-3 h-3"}):t.jsx(x,{className:"w-3 h-3"})]})}),t.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-sm text-text-muted border-b border-border-subtle font-mono",children:[t.jsx("span",{className:"w-14",children:"PID"}),t.jsx("span",{className:"flex-1",children:"Program"}),t.jsx("span",{className:"w-[52px]"}),t.jsx("span",{className:"w-12 text-right",children:"CPU%"}),t.jsx("span",{className:"w-12 text-right",children:"MEM%"})]}),(()=>{const e=j.slice(0,W?10:5),s=Math.max(...e.map(e=>e.cpu_percent)),a=Math.max(...e.map(e=>e.memory_percent));return e.map(e=>t.jsx(V,{pid:e.pid,name:e.name,cpu:e.cpu_percent,mem:e.memory_percent,isTopCpu:e.cpu_percent===s&&s>0,isTopMem:e.memory_percent===a&&a>0},e.pid))})()]})})})]}):null]})}export{se as default}; diff --git a/frontend/dist/assets/Terminal-BQEu4TKw.js b/frontend/dist/assets/Terminal-jVZnyeIH.js similarity index 99% rename from frontend/dist/assets/Terminal-BQEu4TKw.js rename to frontend/dist/assets/Terminal-jVZnyeIH.js index 5e54b4f0..abebb669 100644 --- a/frontend/dist/assets/Terminal-BQEu4TKw.js +++ b/frontend/dist/assets/Terminal-jVZnyeIH.js @@ -1 +1 @@ -import{i as e,r as t,j as a,S as r}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{ay as n,R as o,x as i,e as l,u as c,az as d,aA as p,aB as m,aC as u,aD as y,aE as g}from"./index-CPdqYR4z.js";import{a as h}from"./ping-BvkXSZG_.js";import{P as f,d as v,h as b,k as x}from"./channel-keys-DJWRrSwE.js";import{P as w,b as _,a as S}from"./PageLayout-CcoYWyzO.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";function k(){const e=new Date;return`${e.toISOString().slice(0,10)}_${e.toTimeString().slice(0,8).replace(/:/g,"-")}`}function O(e,t){return`pymc-${e.toISOString().slice(0,10)}-${e.toTimeString().slice(0,5).replace(":","")}-${t}s.json`}const $=e((e,t)=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:a=>{const{captureTimer:r}=t();r&&clearTimeout(r),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(a.map(e=>e.packet_hash))})},stopCapture:a=>{const{isCapturing:r,captureStartTime:s,captureStartPacketHashes:n,captureTimer:o}=t();if(!r||!s)return null;o&&clearTimeout(o);const i=new Date,l=Math.round((i.getTime()-s.getTime())/1e3),c=s.getTime()/1e3,d=a.filter(e=>!n.has(e.packet_hash)&&e.timestamp>=c).sort((e,t)=>e.timestamp-t.timestamp),p={id:k(),filename:O(s,l),startTime:s,endTime:i,durationSec:l,packetCount:d.length,packets:d,sizeBytes:500*d.length};return e(e=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[p,...e.reports].slice(0,10)})),p},getReport:e=>t().reports.find(t=>t.id===e),_setTimer:t=>e({captureTimer:t})}));function P(e){var t;return(null==(t=e.match(/.{1,2}/g))?void 0:t.join(" ").toUpperCase())||""}function T(e){return void 0===e?"UNKNOWN":i[e]??`TYPE_${e}`}function C(e){return void 0===e?"UNKNOWN":o[e]??`ROUTE_${e}`}function E(e,t){switch(e){case 4:return function(e){const t=[];let a=0;if(e.length>=32&&(t.push({name:"public_key",offset:a,length:32,bytes:P(x(e.slice(a,a+32))),decoded:{value:x(e.slice(a,a+32))}}),a+=32),e.length>=a+4){const r=e.slice(a,a+4),s=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;t.push({name:"timestamp",offset:a,length:4,bytes:P(x(r)),decoded:{value:s>>>0,iso:new Date(1e3*s).toISOString()}}),a+=4}if(e.length>=a+64&&(t.push({name:"signature",offset:a,length:64,bytes:P(x(e.slice(a,a+64))),decoded:{value:x(e.slice(a,a+64))}}),a+=64),e.length>a){const r=e[a],s=[];if(1&r&&s.push("CHAT_NODE"),2&r&&s.push("REPEATER"),3&r&&s.push("ROOM_SERVER"),16&r&&s.push("HAS_LOCATION"),128&r&&s.push("HAS_NAME"),t.push({name:"flags",offset:a,length:1,bytes:P(x(e.slice(a,a+1))),decoded:{value:r,binary:r.toString(2).padStart(8,"0"),flags:s}}),a+=1,16&r&&e.length>=a+8){const r=e.slice(a,a+8),s=new ArrayBuffer(8);new Uint8Array(s).set(r);const n=new DataView(s),o=n.getInt32(0,!0),i=n.getInt32(4,!0);t.push({name:"location",offset:a,length:8,bytes:P(x(r)),decoded:{lat_raw:o,lon_raw:i,latitude:o/1e6,longitude:i/1e6}}),a+=8}if(128&r&&e.length>a){const r=e.slice(a);let s=r.indexOf(0);-1===s&&(s=r.length);const n=(new TextDecoder).decode(r.slice(0,s));t.push({name:"name",offset:a,length:s+(0===r[s]?1:0),bytes:P(x(r.slice(0,s+1))),decoded:{value:n,encoding:"utf-8",null_terminated:0===r[s]}})}}return t}(t);case 3:return function(e){if(e.length<4)return[];const t=e.slice(0,4),a=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:P(x(t)),decoded:{value:a>>>0,hex:(a>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}(t);case 9:return function(e){const t=[];if(e.length<9)return t;const a=e.slice(0,4),r=a[0]|a[1]<<8|a[2]<<16|a[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:P(x(a)),decoded:{value:r>>>0,hex:(r>>>0).toString(16).toUpperCase().padStart(8,"0")}});const s=e.slice(4,8),n=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:P(x(s)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:P(x(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const a=e.slice(9),r=Array.from(a).map(e=>e.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:a.length,bytes:P(x(a)),decoded:{hops:r,path_string:r.join("->")}})}return t}(t);case 8:return function(e){if(0===e.length)return[];const t=Array.from(e).map(e=>e.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:P(x(e)),decoded:{hops:t,path_string:t.join("->")}}]}(t);case 5:return function(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:P(x(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const a=12,r=e.length-1-a;t.push({name:"ciphertext",offset:1,length:r,bytes:P(x(e.slice(1,1+r))),decoded:{length:r,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+r,length:a,bytes:P(x(e.slice(-a))),decoded:{note:"Message authentication code"}})}return t}(t);default:return function(e){return 0===e.length?[]:[{name:"raw_data",offset:0,length:e.length,bytes:P(x(e)),decoded:{length:e.length}}]}(t)}}function N(e){const t=e.type??e.payload_type??0,a=e.route??e.route_type??0,r=e.raw_packet||"";let s,n=null;if(r){const t=f.fromHex(r);if(t.success&&t.packet){const e=t.packet;try{n=v(e)}catch{n=null}const a=b(r);let o=0;const i={offset:0,length:1,bytes:P(r.slice(0,2)),decoded:{route_type:e.routeType,route_name:e.routeTypeName,payload_type:e.payloadType,payload_name:e.payloadTypeName,version:e.payloadVersion}};o+=1,e.hasTransportCodes()&&(o+=4);const l={offset:o,length:1,bytes:P(x(a.slice(o,o+1))),decoded:{value:e.pathLen}};o+=1;const c=o,d=a.slice(o,o+e.pathLen),p=Array.from(e.path).map(e=>e.toString(16).toUpperCase().padStart(2,"0")),m=9===e.payloadType,u={offset:c,length:e.pathLen,bytes:P(x(d)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...m&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(e.path).map(e=>{let t=e;return t>127&&(t-=256),t/4})}}};o+=e.pathLen,s={header:i,path_length:l,path:u,payload:{offset:o,length:e.payload.length,bytes:P(e.payloadHex),sections:E(e.payloadType,e.payload)}}}else s=j(e)}else s=j(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:T(t),route:a,route_name:C(a),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:r,structure:s,decoded:n}}function j(e){var t;const a=e.type??e.payload_type??0,r=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:r,route_name:C(r),payload_type:a,payload_name:T(a),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:(null==(t=e.payload)?void 0:t.length)??0,bytes:e.payload??"",sections:e.payload?E(a,b(e.payload)):[]}}}function D(e,t){const a=function(e,t){var a;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(null==t?void 0:t.node_name)??"unknown",local_hash:(null==t?void 0:t.local_hash)??"unknown",pymc_console_version:n,pymc_repeater_version:(null==t?void 0:t.version)??"unknown",radio_config:(null==(a=null==t?void 0:t.config)?void 0:a.radio)?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(N)}}(e,t),r=JSON.stringify(a,null,2),s=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=e.filename,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function R(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}const I=e(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const a="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),r={...t,id:a,timestamp:Date.now()};return e(e=>({entries:[...e.entries,r]})),a},updateEntry:(t,a)=>{e(e=>({entries:e.entries.map(e=>e.id===t?{...e,...a}:e)}))},addCommand:t=>{e(e=>({commandHistory:[...e.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}})),A=new Set(["start ota","erase","reboot"]),G=["gps","sensor"],L=[{cmd:"help",desc:"Show available commands"},{cmd:"clear",desc:"Clear terminal screen"},{cmd:"status",desc:"Get repeater status summary"},{cmd:"uptime",desc:"Show system uptime"},{cmd:"packets",desc:"Show packet statistics"},{cmd:"board",desc:"Show board/platform info"},{cmd:"ping",desc:"Ping neighbor (name or 0xXX)",params:"{target} [timeout]",required:!0},{cmd:"convert hex",desc:"Hex → base64 (for config.yaml)",params:"{hex}",required:!0},{cmd:"convert base64",desc:"Base64 → hex",params:"{base64}",required:!0},{cmd:"cap",desc:"Show capture help"},{cmd:"start cap",desc:"Start packet capture (default 120s)",params:"[seconds]"},{cmd:"end cap",desc:"Stop current capture"},{cmd:"list cap",desc:"List capture reports (clickable download)"},{cmd:"export cap",desc:"Download a capture report",params:"{id}"},...[{name:"get adc.multiplier",category:"get",params:[],description:"Get ADC multiplier for battery",serialOnly:!1,hasParam:!1},{name:"get advert.interval",category:"get",params:[],description:"Get local advert interval (minutes)",serialOnly:!1,hasParam:!1},{name:"get af",category:"get",params:[],description:"Get airtime factor",serialOnly:!1,hasParam:!1},{name:"get agc.reset.interval",category:"get",params:[],description:"Get AGC reset interval (seconds)",serialOnly:!1,hasParam:!1},{name:"get allow.read.only",category:"get",params:[],description:"Get read-only access setting",serialOnly:!1,hasParam:!1},{name:"get bridge.baud",category:"get",params:[],description:"Get bridge baud rate",serialOnly:!1,hasParam:!1},{name:"get bridge.channel",category:"get",params:[],description:"Get bridge channel (ESP-NOW)",serialOnly:!1,hasParam:!1},{name:"get bridge.delay",category:"get",params:[],description:"Get bridge delay (ms)",serialOnly:!1,hasParam:!1},{name:"get bridge.enabled",category:"get",params:[],description:"Get bridge enabled status",serialOnly:!1,hasParam:!1},{name:"get bridge.secret",category:"get",params:[],description:"Get bridge encryption secret",serialOnly:!1,hasParam:!1},{name:"get bridge.source",category:"get",params:[],description:"Get bridge packet source",serialOnly:!1,hasParam:!1},{name:"get bridge.type",category:"get",params:[],description:"Get bridge type (rs232/espnow/none)",serialOnly:!1,hasParam:!1},{name:"get direct.txdelay",category:"get",params:[],description:"Get direct TX delay factor",serialOnly:!1,hasParam:!1},{name:"get flood.advert.interval",category:"get",params:[],description:"Get flood advert interval (hours)",serialOnly:!1,hasParam:!1},{name:"get flood.max",category:"get",params:[],description:"Get max flood hops",serialOnly:!1,hasParam:!1},{name:"get freq",category:"get",params:[],description:"Get frequency (MHz)",serialOnly:!1,hasParam:!1},{name:"get guest.password",category:"get",params:[],description:"Get guest password",serialOnly:!1,hasParam:!1},{name:"get int.thresh",category:"get",params:[],description:"Get interference threshold",serialOnly:!1,hasParam:!1},{name:"get lat",category:"get",params:[],description:"Get latitude",serialOnly:!1,hasParam:!1},{name:"get lon",category:"get",params:[],description:"Get longitude",serialOnly:!1,hasParam:!1},{name:"get multi.acks",category:"get",params:[],description:"Get multi-ack setting",serialOnly:!1,hasParam:!1},{name:"get name",category:"get",params:[],description:"Get node name",serialOnly:!1,hasParam:!1},{name:"get prv.key",category:"get",params:[],description:"Get private key (hex)",serialOnly:!1,hasParam:!1},{name:"get public.key",category:"get",params:[],description:"Get public key (hex)",serialOnly:!1,hasParam:!1},{name:"get radio",category:"get",params:[],description:"Get radio params (freq,bw,sf,cr)",serialOnly:!1,hasParam:!1},{name:"get repeat",category:"get",params:[],description:"Get repeat/forward status (on/off)",serialOnly:!1,hasParam:!1},{name:"get role",category:"get",params:[],description:"Get device role",serialOnly:!1,hasParam:!1},{name:"get rxdelay",category:"get",params:[],description:"Get RX delay base",serialOnly:!1,hasParam:!1},{name:"get tx",category:"get",params:[],description:"Get TX power (dBm)",serialOnly:!1,hasParam:!1},{name:"get txdelay",category:"get",params:[],description:"Get TX delay factor",serialOnly:!1,hasParam:!1},{name:"gps",category:"gps",params:[],description:"Show GPS status",serialOnly:!1,hasParam:!1},{name:"gps advert",category:"gps",params:[],description:"Get/set GPS advert location policy",serialOnly:!1,hasParam:!0},{name:"gps off",category:"gps",params:[],description:"Disable GPS",serialOnly:!1,hasParam:!0},{name:"gps on",category:"gps",params:[],description:"Enable GPS",serialOnly:!1,hasParam:!0},{name:"gps setloc",category:"gps",params:[],description:"Set node location from GPS",serialOnly:!1,hasParam:!0},{name:"gps sync",category:"gps",params:[],description:"Sync time from GPS",serialOnly:!1,hasParam:!0},{name:"log",category:"logging",params:[],description:"Dump log file (serial only)",serialOnly:!0,hasParam:!1},{name:"log erase",category:"logging",params:[],description:"Erase log file",serialOnly:!1,hasParam:!0},{name:"log start",category:"logging",params:[],description:"Start packet logging",serialOnly:!1,hasParam:!0},{name:"log stop",category:"logging",params:[],description:"Stop packet logging",serialOnly:!1,hasParam:!0},{name:"neighbor.remove",category:"neighbor",params:[],description:"Remove neighbor by pubkey",serialOnly:!1,hasParam:!0},{name:"neighbors",category:"neighbor",params:[],description:"List neighbors",serialOnly:!1,hasParam:!1},{name:"get",category:"other",params:[],description:"Execute get command",serialOnly:!1,hasParam:!0},{name:"set",category:"other",params:[{name:"value",type:"float"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Execute set command",serialOnly:!1,hasParam:!0},{name:"tempradio",category:"radio",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Apply temporary radio params (freq bw sf cr timeout_mins)",serialOnly:!1,hasParam:!0},{name:"sensor get",category:"sensor",params:[],description:"Get sensor/custom variable value",serialOnly:!1,hasParam:!0},{name:"sensor list",category:"sensor",params:[{name:"value",type:"int"}],description:"List all sensor/custom variables",serialOnly:!1,hasParam:!0},{name:"sensor set",category:"sensor",params:[],description:"Set sensor/custom variable value",serialOnly:!1,hasParam:!0},{name:"set adc.multiplier",category:"set",params:[{name:"value",type:"float"}],description:"Set ADC multiplier",serialOnly:!1,hasParam:!0},{name:"set advert.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"string"}],description:"Set local advert interval (1-10080 min, 0=off)",serialOnly:!1,hasParam:!0},{name:"set af",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set airtime factor (0-9)",serialOnly:!1,hasParam:!0},{name:"set agc.reset.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set AGC reset interval (seconds, rounded to 4)",serialOnly:!1,hasParam:!0},{name:"set allow.read.only",category:"set",params:[{name:"value",type:"int"}],description:"Set read-only access (on/off)",serialOnly:!1,hasParam:!0},{name:"set bridge.baud",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set bridge baud (9600-115200)",serialOnly:!1,hasParam:!0},{name:"set bridge.channel",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"string"}],description:"Set bridge channel (1-14)",serialOnly:!1,hasParam:!0},{name:"set bridge.delay",category:"set",params:[{name:"value",type:"int"}],description:"Set bridge delay (0-10000 ms)",serialOnly:!1,hasParam:!0},{name:"set bridge.enabled",category:"set",params:[{name:"value",type:"int"}],description:"Enable/disable bridge",serialOnly:!1,hasParam:!0},{name:"set bridge.secret",category:"set",params:[{name:"value",type:"string"},{name:"value",type:"float"}],description:"Set bridge encryption secret",serialOnly:!1,hasParam:!0},{name:"set bridge.source",category:"set",params:[{name:"value",type:"int"}],description:"Set bridge source (rx/tx)",serialOnly:!1,hasParam:!0},{name:"set direct.txdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set direct TX delay factor",serialOnly:!1,hasParam:!0},{name:"set flood.advert.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set flood advert interval (3-48 hours, 0=off)",serialOnly:!1,hasParam:!0},{name:"set flood.max",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"float"}],description:"Set max flood hops (0-64)",serialOnly:!1,hasParam:!0},{name:"set freq",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set frequency MHz (serial only, reboot required)",serialOnly:!0,hasParam:!0},{name:"set guest.password",category:"set",params:[{name:"value",type:"string"}],description:"Set guest password",serialOnly:!1,hasParam:!0},{name:"set int.thresh",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set interference threshold",serialOnly:!1,hasParam:!0},{name:"set lat",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set latitude",serialOnly:!1,hasParam:!0},{name:"set lon",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set longitude",serialOnly:!1,hasParam:!0},{name:"set multi.acks",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set multi-ack (0/1)",serialOnly:!1,hasParam:!0},{name:"set name",category:"set",params:[{name:"value",type:"string"},{name:"value",type:"int"}],description:"Set node name",serialOnly:!1,hasParam:!0},{name:"set prv.key",category:"set",params:[{name:"value",type:"string"}],description:"Set private key (hex, restart required)",serialOnly:!1,hasParam:!0},{name:"set radio",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set radio params (freq bw sf cr)",serialOnly:!1,hasParam:!0},{name:"set repeat",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set repeat/forward (on/off)",serialOnly:!1,hasParam:!0},{name:"set rxdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set RX delay base",serialOnly:!1,hasParam:!0},{name:"set tx",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"float"}],description:"Set TX power (dBm)",serialOnly:!1,hasParam:!0},{name:"set txdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set TX delay factor",serialOnly:!1,hasParam:!0},{name:"stats-core",category:"stats",params:[],description:"Show core statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"stats-packets",category:"stats",params:[],description:"Show packet statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"stats-radio",category:"stats",params:[],description:"Show radio statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"advert",category:"system",params:[],description:"Send self advertisement",serialOnly:!1,hasParam:!1},{name:"board",category:"system",params:[],description:"Show board/manufacturer name",serialOnly:!1,hasParam:!1},{name:"clear stats",category:"system",params:[],description:"Reset statistics counters",serialOnly:!1,hasParam:!0},{name:"clock",category:"system",params:[{name:"value",type:"int"}],description:"Display current time",serialOnly:!1,hasParam:!0},{name:"clock sync",category:"system",params:[],description:"Sync clock from sender timestamp",serialOnly:!1,hasParam:!0},{name:"password",category:"system",params:[{name:"value",type:"string"}],description:"Change admin password",serialOnly:!1,hasParam:!0},{name:"reboot",category:"system",params:[],description:"Reboot the device",serialOnly:!1,hasParam:!1},{name:"start ota",category:"system",params:[{name:"value",type:"int"}],description:"Start OTA firmware update",serialOnly:!1,hasParam:!0},{name:"time",category:"system",params:[{name:"value",type:"int"}],description:"Set time to epoch seconds",serialOnly:!1,hasParam:!0},{name:"ver",category:"system",params:[],description:"Show firmware version and build date",serialOnly:!1,hasParam:!1}].filter(e=>!e.serialOnly&&!A.has(e.name)&&!G.some(t=>e.name.startsWith(t))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],W={"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning"],"start cap":["30","60","120","300"]};function U(e){switch(e){case"success":return"text-accent-success";case"error":return"text-accent-danger";case"warning":return"text-amber-400";case"info":return"text-accent-tertiary";case"value":return"text-accent-primary";case"system":return"text-text-muted";default:return"text-text-secondary"}}const F=t.memo(function({entry:e}){const r=$(),n=l(),o=t.useCallback(e=>{const t=r.getReport(e);t?D(t,n):alert("Report no longer available. Captures are stored in session memory only.")},[r,n]);return"command"===e.type?a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx("span",{className:"text-text-muted font-medium select-none",children:"$"}),a.jsx("span",{className:"text-text-primary font-semibold",children:e.content})]}):"system"===e.type?a.jsx("div",{className:s("py-0.5",U(e.outputType||"system")),children:e.content}):e.content.includes("██")?a.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",U(e.outputType||"value")),children:e.content}):a.jsx("div",{className:"ml-4 font-mono text-[13px] py-1",children:e.content.split("\n").map((t,r)=>{const s=function(e,t){if(e.startsWith("REC:::"))return[{text:"●",color:"text-red-500 animate-pulse",isRecording:!0},{text:` ${e.slice(6)}`,color:"text-text-muted"}];const a=e.trimStart();if(a.startsWith("DOWNLOAD:::")){const t=e.slice(0,e.length-a.length),r=a.slice(11).split(":::"),[s,n]=r;return[{text:`${t}⇓ download "${n}"`,color:"text-accent-primary underline cursor-pointer hover:text-accent-secondary",isDownload:!0,downloadId:s,downloadFilename:n}]}if(e.startsWith("HELP_HEADER:::"))return[{text:e.slice(14),color:"text-text-primary font-bold"}];if(e.startsWith("HELP_NOTE:::"))return[{text:e.slice(12),color:"text-text-muted italic"}];const r=e.match(/^([a-z][a-z0-9.]*(?:\s+[a-z][a-z0-9.]*)?):::(.+)$/);if(r){const[,e,t]=r,a=e.split(" "),s=a[0];let n="text-accent-tertiary";"get"===s?n="text-accent-success":"set"===s&&(n="text-amber-400");const o=[{text:` ${s}`,color:`${n} font-semibold`}];a.length>1&&o.push({text:` ${a.slice(1).join(" ")}`,color:"text-accent-primary"});const i=" ".repeat(Math.max(1,22-e.length));return o.push({text:`${i}${t}`,color:"text-text-muted"}),o}if("error"===t||"warning"===t)return[{text:e,color:U(t)}];if("value"===t)return[{text:e,color:U("value")}];const s=e.match(/^([\w\s.]+):\s*(.+)$/);if(s){const[,e,t]=s;return[{text:`${e}: `,color:"text-text-muted"},{text:t,color:"text-accent-primary font-semibold"}]}return e.startsWith("OK")?[{text:e,color:U("success")}]:[{text:e,color:U(t)}]}(t,e.outputType||"default");return a.jsx("div",{className:"leading-relaxed",children:s.map((e,t)=>e.isDownload?a.jsx("span",{className:e.color,onClick:()=>o(e.downloadId),role:"button",tabIndex:0,onKeyDown:t=>"Enter"===t.key&&o(e.downloadId),children:e.text},t):a.jsx("span",{className:e.color,children:e.text},t))},r)})})});function H(){const e=l(),n=c(),o=$(),i=I(e=>e.entries),f=I(e=>e.commandHistory),v=I(e=>e.isInitialized),{addEntry:b,updateEntry:x,addCommand:k,clearEntries:O,setInitialized:P}=I(),[T,C]=t.useState(""),[E,N]=t.useState(-1),[j,A]=t.useState(!1),[G,U]=t.useState([]),[H,M]=t.useState(0),[z,q]=t.useState(0),[B,K]=t.useState(!1),X=t.useRef(null),V=t.useRef(null),J=t.useRef(null),Q=t.useRef(n);t.useEffect(()=>{Q.current=n},[n]),t.useEffect(()=>{v||(async()=>{b({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=b({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),x(e,{content:"✓ Initializing terminal...",outputType:"success"});const t=b({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),x(t,{content:"✓ Connected to repeater",outputType:"success"}),b({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),P(!0)})()},[v,b,x,P]),t.useEffect(()=>{V.current&&(V.current.scrollTop=V.current.scrollHeight)},[i]);const Y=t.useCallback(()=>{var e;const t=window.getSelection();t&&t.toString().length>0||null==(e=X.current)||e.focus()},[]),Z=t.useMemo(()=>(null==e?void 0:e.neighbors)?Object.values(e.neighbors).map(e=>e.node_name||e.name).filter(e=>!!e).sort():[],[null==e?void 0:e.neighbors]),ee=t.useCallback(e=>{const t=e.trim().toLowerCase();if(!t)return A(!1),void U([]);const a=L.filter(e=>e.cmd.toLowerCase().startsWith(t));if(a.length>0)return U(a),M(0),void A(!0);if(t.includes(" ")){const e=t.lastIndexOf(" "),a=t.substring(0,e),r=t.substring(e+1);if("ping"===a&&Z.length>0){const e=Z.filter(e=>e.toLowerCase().startsWith(r)).slice(0,10).map(e=>({cmd:`ping ${e}`,desc:`→ ${e}`}));if(e.length>0)return U(e),M(0),void A(!0)}if("export cap"===a&&o.reports.length>0){const e=o.reports.map((e,t)=>({id:e.id,index:String(t+1),pkts:e.packetCount,duration:e.durationSec})).filter(e=>e.id.toLowerCase().startsWith(r)||e.index.startsWith(r)).slice(0,10).map(e=>({cmd:`export cap ${e.index}`,desc:`${e.pkts} pkts • ${e.duration}s`}));if(e.length>0)return U(e),M(0),void A(!0)}const s=L.find(e=>e.cmd.toLowerCase()===a);if(s&&W[s.cmd]){const e=W[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return U(e),M(0),void A(!0)}}A(!1),U([])},[Z,o.reports]),te=t.useCallback(e=>{var t;const a=G[e];a&&(a.required&&a.params?(C(a.cmd+" "),ee(a.cmd+" ")):(C(a.cmd),A(!1)),null==(t=X.current)||t.focus())},[G,ee]),ae=t.useCallback(async t=>{var a,r,s,i,l,c,f,v,w;const _=t.trim();if(!_)return;const S=_.toLowerCase();if(k(_),b({type:"command",content:_}),"clear"===S)return void O();if("help"===S){const e=L.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void b({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const P=b({type:"output",content:"processing...",outputType:"system"});try{const t=await d();let k="",O="info";const E=e=>{const t=Math.floor(e/86400),a=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${a}h ${r}m`:a>0?`${a}h ${r}m`:`${r}m`};if("status"===S){k=`Mode: ${(null==(r=null==(a=t.config)?void 0:a.repeater)?void 0:r.mode)||"unknown"} | Neighbors: ${Object.keys(t.neighbors||{}).length} | Uptime: ${E(t.uptime_seconds||0)}`}else if("uptime"===S)k=E(t.uptime_seconds||0),O="value";else if("packets"===S)k=`rx: ${t.rx_count??0}\ntx: ${t.tx_count??0}\nfwd: ${t.forwarded_count??0}\ndrop: ${t.dropped_count??0}`;else if("neighbors"===S){const e=t.neighbors||{},a=Object.entries(e);if(0===a.length)k="No neighbors discovered yet.",O="warning";else{const e=a.map(([e,t])=>{const a=t.name||t.node_name||"Unknown";return` ${e.slice(0,8)} ${a}`});k=`Neighbors (${a.length}):\n${e.join("\n")}`}}else if("board"===S)k="pyMC_Repeater (Linux/RPi)",O="value";else if(S.startsWith("get ")){const e=S.slice(4).trim(),a=null==(s=t.config)?void 0:s.delays,r=null==(i=t.config)?void 0:i.radio,n=null==(l=t.config)?void 0:l.repeater,o=null==(c=t.config)?void 0:c.duty_cycle;switch(e){case"name":k=(null==(f=t.config)?void 0:f.node_name)||"Unknown";break;case"role":k="repeater";break;case"lat":k=null!=(null==n?void 0:n.latitude)?String(n.latitude):"not set";break;case"lon":k=null!=(null==n?void 0:n.longitude)?String(n.longitude):"not set";break;case"freq":k=(null==r?void 0:r.frequency)?(r.frequency/1e6).toFixed(3):"?";break;case"tx":k=String((null==r?void 0:r.tx_power)??"?");break;case"bw":k=(null==r?void 0:r.bandwidth)?String(r.bandwidth/1e3):"?";break;case"sf":k=String((null==r?void 0:r.spreading_factor)??"?");break;case"cr":k=String((null==r?void 0:r.coding_rate)??"?");break;case"radio":k=r?`freq: ${(r.frequency/1e6).toFixed(3)} MHz\nbw: ${r.bandwidth/1e3} kHz\nsf: ${r.spreading_factor}\ncr: 4/${r.coding_rate}`:"?";break;case"af":case"txdelay":k=String((null==a?void 0:a.tx_delay_factor)??"1.0");break;case"direct.txdelay":k=String((null==a?void 0:a.direct_tx_delay_factor)??"0.5");break;case"mode":k=(null==n?void 0:n.mode)||"forward";break;case"repeat":k="forward"===(null==n?void 0:n.mode)?"on":"off";break;case"flood.max":k=String((null==n?void 0:n.max_flood_hops)??"3");break;case"flood.advert.interval":k=null!=(null==n?void 0:n.send_advert_interval_hours)?`${n.send_advert_interval_hours}h`:"?";break;case"advert.interval":k=null!=(null==n?void 0:n.advert_interval_minutes)?`${n.advert_interval_minutes}m`:"120m";break;case"rxdelay":k=String((null==a?void 0:a.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":k=(null==o?void 0:o.enforcement_enabled)?"on":"off";break;case"duty.max":k=null!=(null==o?void 0:o.max_airtime_percent)?`${o.max_airtime_percent}%`:"?";break;case"public.key":k=t.public_key||"not available";break;case"prv.key":k="Private key stored in /etc/pymc_repeater/config.yaml\n\nTo view: sudo grep identity_key /etc/pymc_repeater/config.yaml\nTo set: sudo ./convert_firmware_key.sh <64-byte-hex>",O="info";break;case"guest.password":case"allow.read.only":k="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",O="warning";break;default:k=`Unknown parameter: ${e}\nAvailable: name, role, lat, lon, freq, tx, bw, sf, cr, radio, af, txdelay, direct.txdelay, rxdelay, mode, repeat, flood.max, advert.interval, duty, public.key`,O="error"}"error"!==O&&(O="value")}else if("advert"===S){const e=await p();k=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,O=e.success?"success":"error"}else if(S.startsWith("set mode ")){const e=S.split(" ")[2];if("forward"!==e&&"monitor"!==e)k='Error: Mode must be "forward" or "monitor"',O="error";else{const t=await m(e);k=t.success?`OK - Mode set to ${e}`:"Error: Failed",O=t.success?"success":"error"}}else if(S.startsWith("set duty ")){const e=S.split(" ")[2],t="on"===e||"1"===e,a=await u(t);k=a.success?"OK - Duty cycle "+(t?"enabled":"disabled"):"Error: Failed",O=a.success?"success":"error"}else if(S.startsWith("set tx ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||e<2||e>22)k="Error: TX power must be 2-22 dBm (SX1262 chip max)",O="error";else{const t=await y({tx_power:e});k=t.success?`OK - TX power set to ${e}dBm`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set af ")||S.startsWith("set txdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0||e>5)k="Error: TX delay factor must be 0.0-5.0",O="error";else{const t=await y({tx_delay_factor:e});k=t.success?`OK - TX delay set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set direct.txdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0||e>5)k="Error: Direct TX delay must be 0.0-5.0",O="error";else{const t=await y({direct_tx_delay_factor:e});k=t.success?`OK - Direct TX delay set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set log ")){const e=null==(v=S.split(" ")[2])?void 0:v.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const t=await g(e);k=t.success?`OK - Log level set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}else k="Error: Level must be debug, info, warning, or error",O="error"}else if(S.startsWith("set rxdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0)k="Error: RX delay must be >= 0",O="error";else{const t=await y({rx_delay_base:e});k=t.success?`OK - RX delay base set to ${e}s`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set name ")){const e=_.substring(9).trim();if(e){const t=await y({node_name:e});k=t.success?`OK - Node name set to "${e}"`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}else k="Error: Node name cannot be empty",O="error"}else if(S.startsWith("set lat ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<-90||e>90)k="Error: Latitude must be -90 to 90",O="error";else{const t=await y({latitude:e});k=t.success?`OK - Latitude set to ${e}°`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set lon ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<-180||e>180)k="Error: Longitude must be -180 to 180",O="error";else{const t=await y({longitude:e});k=t.success?`OK - Longitude set to ${e}°`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set flood.max ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||e<0||e>64)k="Error: Max flood hops must be 0-64",O="error";else{const t=await y({max_flood_hops:e});k=t.success?`OK - Max flood hops set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set flood.advert.interval ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))k="Error: Flood advert interval must be 0 (off) or 3-48 hours",O="error";else{const t=await y({flood_advert_interval_hours:e});k=t.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set advert.interval ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))k="Error: Advert interval must be 0 (off) or 1-10080 minutes",O="error";else{const t=await y({advert_interval_minutes:e});k=t.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set prv.key ")){const e=_.substring(12).trim();e?/^[0-9a-fA-F]+$/.test(e)?128!==e.length?(k=`Error: Key must be 64 bytes (128 hex chars), got ${e.length} chars`,O="error"):(k=`To set this key, run on the Pi:\n\n sudo ./convert_firmware_key.sh ${e}\n\nThen restart: sudo systemctl restart pymc-repeater`,O="info"):(k="Error: Private key must be a hex string",O="error"):(k="Error: Private key cannot be empty",O="error")}else if(S.startsWith("convert hex ")){const e=_.substring(12).trim();if(e)if(/^[0-9a-fA-F]+$/.test(e))if(e.length%2!=0)k="Error: Hex string must have even length",O="error";else try{const t=new Uint8Array(e.length/2);for(let s=0;s1&&!isNaN(r)&&r>0,n=s?t.slice(0,-1).join(" "):e,o=s?r:30;if(n){let e=1;const t=setInterval(()=>{e=e%3+1,x(P,{content:`Pinging ${n}${".".repeat(e)}`,outputType:"system"})},800);try{const e=await h(n,o);if(clearInterval(t),e.success&&e.data){const t=e.data,a=(null==(w=t.path)?void 0:w.length)?t.path.join(" → "):"direct";k=`Reply from ${t.target_id}\n RTT: ${t.rtt_ms.toFixed(1)}ms\n RSSI: ${t.rssi}dBm\n SNR: ${t.snr_db}dB\n Path: ${a}\n Quality: ${t.quality}`,O="success"}else k=e.error||"Ping failed",O="error"}catch(C){throw clearInterval(t),C}}else k="Usage: ping [timeout]",O="error"}else if("cap"===S||"cap help"===S){const e=o.isCapturing?'\nREC:::Recording in progress... use "end cap" to stop':"",t=o.reports.length;k=`HELP_HEADER:::Packet Capture\n\nstart cap:::Start capture (default: 120s)\nend cap:::Stop capture early\nlist cap:::List saved captures${t>0?` (${t} saved)`:""}\nexport cap:::Download capture by ID\n\nHELP_NOTE:::Captures stored in session memory. JSON includes decoded payloads.${e}`,O="info"}else if("start cap"===S||S.startsWith("start cap ")){const e=S.slice(10).trim(),t=e?parseInt(e):120;if(isNaN(t)||t<1||t>3600)k="Error: Duration must be 1-3600 seconds",O="error";else{if(!o.isCapturing){o.startCapture(n);let e=t;x(P,{content:`REC:::Capturing... ${e}s remaining`,outputType:"system"});const a=setInterval(()=>{e--;const t=$.getState();if(e>=0&&t.isCapturing){const a=Q.current.filter(e=>{if(!t.captureStartTime)return!1;const a=t.captureStartTime.getTime()/1e3;return e.timestamp>=a&&!t.captureStartPacketHashes.has(e.packet_hash)}).length;x(P,{content:`REC:::Capturing... ${e>0?`${e}s remaining`:"finishing..."} (${a} captured)`,outputType:"system"})}},1e3),r=setTimeout(()=>{clearInterval(a);const e=$.getState();if(e.isCapturing){const t=Q.current,a=e.stopCapture(t);b(a?{type:"output",content:`✓ Capture complete!\n Captured: ${a.packetCount} packets\n Duration: ${a.durationSec}s\n Size: ~${R(a.sizeBytes)}\n\nDOWNLOAD:::${a.id}:::${a.filename}`,outputType:"success"}:{type:"output",content:"Capture completed with no packets.",outputType:"warning"})}},1e3*t);return void o._setTimer(r)}k='Error: Capture already in progress. Use "end cap" first.',O="error"}}else if("end cap"===S)if(o.isCapturing){const e=o.stopCapture(n);e?(k=`✓ Capture complete!\n Captured: ${e.packetCount} packets\n Duration: ${e.durationSec}s\n Size: ~${R(e.sizeBytes)}\n\nDOWNLOAD:::${e.id}:::${e.filename}`,O="success"):(k="Capture stopped with no packets.",O="warning")}else k="No capture in progress.",O="warning";else if("list cap"===S){const e=o.reports;if(0===e.length)k="No capture reports available.\nStart a capture with: start cap [seconds]",O="info";else{const t=e.map((e,t)=>` ${t+1}. ${e.packetCount} pkts • ${e.durationSec}s • ~${R(e.sizeBytes)}\n DOWNLOAD:::${e.id}:::${e.filename}`);k=`Capture Reports (${e.length}):\n${t.join("\n")}`,O="info"}}else if("export cap"===S||S.startsWith("export cap ")){const t=S.slice(11).trim();if(t){const a=o.getReport(t);if(a)D(a,e),k=`✓ Downloading ${a.filename}...`,O="success";else{const a=parseInt(t)-1,r=o.reports[a];r?(D(r,e),k=`✓ Downloading ${r.filename}...`,O="success"):(k=`Error: Report "${t}" not found.\nUse "list cap" to see available reports.`,O="error")}}else{const e=o.reports;0===e.length?(k="No capture reports available.\nStart a capture with: start cap [seconds]",O="info"):(k=`Usage: export cap \n\nAvailable reports:\n${e.map((e,t)=>` ${t+1}. ${e.id}`).join("\n")}`,O="info")}}else k=`Unknown command: ${_}\nType 'help' for available commands.`,O="error";x(P,{content:k,outputType:O})}catch(E){x(P,{content:`Error: ${E instanceof Error?E.message:"Command failed"}`,outputType:"error"})}},[b,k,x,O,o,n,e]),re=t.useCallback(e=>{var t,a,r,s,n,o;if(j&&G.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(H+1,G.length-1);return M(s),void(null==(r=null==(a=null==(t=J.current)?void 0:t.children[0])?void 0:a.children[s])||r.scrollIntoView({block:"nearest"}))}if("ArrowUp"===e.key){e.preventDefault();const t=Math.max(H-1,0);return M(t),void(null==(o=null==(n=null==(s=J.current)?void 0:s.children[0])?void 0:n.children[t])||o.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void te(H);if("Escape"===e.key)return e.preventDefault(),void A(!1)}if("Enter"===e.key){if(e.preventDefault(),j&&G.length>0){const e=G[H].cmd;return C(""),N(-1),A(!1),void ae(e)}const t=T;return C(""),N(-1),A(!1),void ae(t)}if("ArrowUp"!==e.key||j)if("ArrowDown"!==e.key||j);else if(e.preventDefault(),E>0){const e=E-1;N(e),C(f[f.length-1-e]||"")}else 0===E&&(N(-1),C(""));else if(e.preventDefault(),f.length>0&&E{C(e.target.value),q(e.target.selectionStart||e.target.value.length),ee(e.target.value)},[ee]),ne=t.useCallback(e=>{const t=e.target;q(t.selectionStart||0)},[]);return a.jsxs(w,{children:[a.jsx(_,{title:"Terminal",icon:a.jsx(r,{})}),a.jsxs(S,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:Y,children:[a.jsx("div",{ref:V,className:"flex-1 overflow-y-auto font-mono text-sm p-3 sm:p-4 md:p-5",style:{background:"var(--terminal-bg)"},children:i.map(e=>a.jsx(F,{entry:e},e.id))}),a.jsxs("div",{className:"relative",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-3",children:[a.jsx("span",{className:"text-text-muted font-mono font-bold select-none",children:"$"}),a.jsxs("div",{className:"flex-1 relative font-mono text-sm",children:[a.jsx("input",{ref:X,type:"text",value:T,onChange:se,onKeyDown:re,onSelect:ne,onFocus:()=>K(!0),onBlur:()=>K(!1),disabled:!v,className:"absolute inset-0 w-full bg-transparent text-transparent outline-none disabled:opacity-50 selection:bg-transparent",style:{caretColor:"transparent"},autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),a.jsx("div",{className:"relative pointer-events-none select-none","aria-hidden":!0,children:v?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-primary",children:T.slice(0,z)}),a.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",B?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:a.jsx("span",{className:"text-bg-primary",children:T[z]||""})}),a.jsx("span",{className:"text-text-primary",children:T.slice(z+1)})]}):a.jsx("span",{className:"text-text-muted",children:"Connecting..."})})]})]}),a.jsxs("div",{className:"px-3 sm:px-4 py-1 flex justify-between text-[10px] text-text-muted",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-status)"},children:[a.jsx("span",{className:"hidden sm:inline",children:"↑↓ History"}),a.jsx("span",{className:"sm:hidden",children:"Terminal"}),(null==e?void 0:e.version)&&a.jsxs("span",{children:["pyMC v",e.version]})]})]}),j&&G.length>0&&a.jsxs("div",{ref:J,className:"absolute left-2 right-2 bottom-[72px] rounded-xl shadow-2xl overflow-hidden z-50 backdrop-blur-xl",style:{border:"1px solid var(--terminal-autocomplete-border)",background:"var(--terminal-autocomplete-bg)"},children:[a.jsx("div",{className:"max-h-64 overflow-y-auto",children:G.map((e,t)=>a.jsxs("div",{onClick:()=>te(t),className:s("px-4 py-2.5 cursor-pointer last:border-b-0 transition-colors",t===H?"bg-accent-primary/25":""),style:{borderBottom:"1px solid var(--terminal-border)",...t!==H?{"--tw-bg-opacity":0}:{}},onMouseEnter:e=>{t!==H&&(e.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:e=>{t!==H&&(e.currentTarget.style.background="transparent")},children:[a.jsx("span",{className:s("font-mono text-sm",t===H?"text-accent-primary":"text-text-primary"),children:e.cmd}),a.jsx("span",{className:"text-xs text-text-muted ml-4",children:e.desc})]},e.cmd))}),a.jsx("div",{className:"px-3 py-1.5 text-[10px] text-text-muted text-right",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-autocomplete-hover)"},children:"Tab to select"})]})]})]})}export{H as default}; +import{i as e,r as t,j as a,S as r}from"./vendor-react-C341c8YC.js";import{n as s}from"./recharts-6XUQYgRA.js";import{ay as n,R as o,x as i,e as l,u as c,az as d,aA as p,aB as m,aC as u,aD as y,aE as g}from"./index-BJEgt3tp.js";import{a as h}from"./ping-DvLgBqTv.js";import{P as f,d as v,h as b,k as x}from"./channel-keys-DJWRrSwE.js";import{P as w,b as _,a as S}from"./PageLayout-CnF5SScd.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";function k(){const e=new Date;return`${e.toISOString().slice(0,10)}_${e.toTimeString().slice(0,8).replace(/:/g,"-")}`}function O(e,t){return`pymc-${e.toISOString().slice(0,10)}-${e.toTimeString().slice(0,5).replace(":","")}-${t}s.json`}const $=e((e,t)=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:a=>{const{captureTimer:r}=t();r&&clearTimeout(r),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(a.map(e=>e.packet_hash))})},stopCapture:a=>{const{isCapturing:r,captureStartTime:s,captureStartPacketHashes:n,captureTimer:o}=t();if(!r||!s)return null;o&&clearTimeout(o);const i=new Date,l=Math.round((i.getTime()-s.getTime())/1e3),c=s.getTime()/1e3,d=a.filter(e=>!n.has(e.packet_hash)&&e.timestamp>=c).sort((e,t)=>e.timestamp-t.timestamp),p={id:k(),filename:O(s,l),startTime:s,endTime:i,durationSec:l,packetCount:d.length,packets:d,sizeBytes:500*d.length};return e(e=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[p,...e.reports].slice(0,10)})),p},getReport:e=>t().reports.find(t=>t.id===e),_setTimer:t=>e({captureTimer:t})}));function P(e){var t;return(null==(t=e.match(/.{1,2}/g))?void 0:t.join(" ").toUpperCase())||""}function T(e){return void 0===e?"UNKNOWN":i[e]??`TYPE_${e}`}function C(e){return void 0===e?"UNKNOWN":o[e]??`ROUTE_${e}`}function E(e,t){switch(e){case 4:return function(e){const t=[];let a=0;if(e.length>=32&&(t.push({name:"public_key",offset:a,length:32,bytes:P(x(e.slice(a,a+32))),decoded:{value:x(e.slice(a,a+32))}}),a+=32),e.length>=a+4){const r=e.slice(a,a+4),s=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;t.push({name:"timestamp",offset:a,length:4,bytes:P(x(r)),decoded:{value:s>>>0,iso:new Date(1e3*s).toISOString()}}),a+=4}if(e.length>=a+64&&(t.push({name:"signature",offset:a,length:64,bytes:P(x(e.slice(a,a+64))),decoded:{value:x(e.slice(a,a+64))}}),a+=64),e.length>a){const r=e[a],s=[];if(1&r&&s.push("CHAT_NODE"),2&r&&s.push("REPEATER"),3&r&&s.push("ROOM_SERVER"),16&r&&s.push("HAS_LOCATION"),128&r&&s.push("HAS_NAME"),t.push({name:"flags",offset:a,length:1,bytes:P(x(e.slice(a,a+1))),decoded:{value:r,binary:r.toString(2).padStart(8,"0"),flags:s}}),a+=1,16&r&&e.length>=a+8){const r=e.slice(a,a+8),s=new ArrayBuffer(8);new Uint8Array(s).set(r);const n=new DataView(s),o=n.getInt32(0,!0),i=n.getInt32(4,!0);t.push({name:"location",offset:a,length:8,bytes:P(x(r)),decoded:{lat_raw:o,lon_raw:i,latitude:o/1e6,longitude:i/1e6}}),a+=8}if(128&r&&e.length>a){const r=e.slice(a);let s=r.indexOf(0);-1===s&&(s=r.length);const n=(new TextDecoder).decode(r.slice(0,s));t.push({name:"name",offset:a,length:s+(0===r[s]?1:0),bytes:P(x(r.slice(0,s+1))),decoded:{value:n,encoding:"utf-8",null_terminated:0===r[s]}})}}return t}(t);case 3:return function(e){if(e.length<4)return[];const t=e.slice(0,4),a=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:P(x(t)),decoded:{value:a>>>0,hex:(a>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}(t);case 9:return function(e){const t=[];if(e.length<9)return t;const a=e.slice(0,4),r=a[0]|a[1]<<8|a[2]<<16|a[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:P(x(a)),decoded:{value:r>>>0,hex:(r>>>0).toString(16).toUpperCase().padStart(8,"0")}});const s=e.slice(4,8),n=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:P(x(s)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:P(x(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const a=e.slice(9),r=Array.from(a).map(e=>e.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:a.length,bytes:P(x(a)),decoded:{hops:r,path_string:r.join("->")}})}return t}(t);case 8:return function(e){if(0===e.length)return[];const t=Array.from(e).map(e=>e.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:P(x(e)),decoded:{hops:t,path_string:t.join("->")}}]}(t);case 5:return function(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:P(x(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const a=12,r=e.length-1-a;t.push({name:"ciphertext",offset:1,length:r,bytes:P(x(e.slice(1,1+r))),decoded:{length:r,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+r,length:a,bytes:P(x(e.slice(-a))),decoded:{note:"Message authentication code"}})}return t}(t);default:return function(e){return 0===e.length?[]:[{name:"raw_data",offset:0,length:e.length,bytes:P(x(e)),decoded:{length:e.length}}]}(t)}}function N(e){const t=e.type??e.payload_type??0,a=e.route??e.route_type??0,r=e.raw_packet||"";let s,n=null;if(r){const t=f.fromHex(r);if(t.success&&t.packet){const e=t.packet;try{n=v(e)}catch{n=null}const a=b(r);let o=0;const i={offset:0,length:1,bytes:P(r.slice(0,2)),decoded:{route_type:e.routeType,route_name:e.routeTypeName,payload_type:e.payloadType,payload_name:e.payloadTypeName,version:e.payloadVersion}};o+=1,e.hasTransportCodes()&&(o+=4);const l={offset:o,length:1,bytes:P(x(a.slice(o,o+1))),decoded:{value:e.pathLen}};o+=1;const c=o,d=a.slice(o,o+e.pathLen),p=Array.from(e.path).map(e=>e.toString(16).toUpperCase().padStart(2,"0")),m=9===e.payloadType,u={offset:c,length:e.pathLen,bytes:P(x(d)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...m&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(e.path).map(e=>{let t=e;return t>127&&(t-=256),t/4})}}};o+=e.pathLen,s={header:i,path_length:l,path:u,payload:{offset:o,length:e.payload.length,bytes:P(e.payloadHex),sections:E(e.payloadType,e.payload)}}}else s=j(e)}else s=j(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:T(t),route:a,route_name:C(a),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:r,structure:s,decoded:n}}function j(e){var t;const a=e.type??e.payload_type??0,r=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:r,route_name:C(r),payload_type:a,payload_name:T(a),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:(null==(t=e.payload)?void 0:t.length)??0,bytes:e.payload??"",sections:e.payload?E(a,b(e.payload)):[]}}}function D(e,t){const a=function(e,t){var a;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(null==t?void 0:t.node_name)??"unknown",local_hash:(null==t?void 0:t.local_hash)??"unknown",pymc_console_version:n,pymc_repeater_version:(null==t?void 0:t.version)??"unknown",radio_config:(null==(a=null==t?void 0:t.config)?void 0:a.radio)?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(N)}}(e,t),r=JSON.stringify(a,null,2),s=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=e.filename,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function R(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}const I=e(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const a="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),r={...t,id:a,timestamp:Date.now()};return e(e=>({entries:[...e.entries,r]})),a},updateEntry:(t,a)=>{e(e=>({entries:e.entries.map(e=>e.id===t?{...e,...a}:e)}))},addCommand:t=>{e(e=>({commandHistory:[...e.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}})),A=new Set(["start ota","erase","reboot"]),G=["gps","sensor"],L=[{cmd:"help",desc:"Show available commands"},{cmd:"clear",desc:"Clear terminal screen"},{cmd:"status",desc:"Get repeater status summary"},{cmd:"uptime",desc:"Show system uptime"},{cmd:"packets",desc:"Show packet statistics"},{cmd:"board",desc:"Show board/platform info"},{cmd:"ping",desc:"Ping neighbor (name or 0xXX)",params:"{target} [timeout]",required:!0},{cmd:"convert hex",desc:"Hex → base64 (for config.yaml)",params:"{hex}",required:!0},{cmd:"convert base64",desc:"Base64 → hex",params:"{base64}",required:!0},{cmd:"cap",desc:"Show capture help"},{cmd:"start cap",desc:"Start packet capture (default 120s)",params:"[seconds]"},{cmd:"end cap",desc:"Stop current capture"},{cmd:"list cap",desc:"List capture reports (clickable download)"},{cmd:"export cap",desc:"Download a capture report",params:"{id}"},...[{name:"get adc.multiplier",category:"get",params:[],description:"Get ADC multiplier for battery",serialOnly:!1,hasParam:!1},{name:"get advert.interval",category:"get",params:[],description:"Get local advert interval (minutes)",serialOnly:!1,hasParam:!1},{name:"get af",category:"get",params:[],description:"Get airtime factor",serialOnly:!1,hasParam:!1},{name:"get agc.reset.interval",category:"get",params:[],description:"Get AGC reset interval (seconds)",serialOnly:!1,hasParam:!1},{name:"get allow.read.only",category:"get",params:[],description:"Get read-only access setting",serialOnly:!1,hasParam:!1},{name:"get bridge.baud",category:"get",params:[],description:"Get bridge baud rate",serialOnly:!1,hasParam:!1},{name:"get bridge.channel",category:"get",params:[],description:"Get bridge channel (ESP-NOW)",serialOnly:!1,hasParam:!1},{name:"get bridge.delay",category:"get",params:[],description:"Get bridge delay (ms)",serialOnly:!1,hasParam:!1},{name:"get bridge.enabled",category:"get",params:[],description:"Get bridge enabled status",serialOnly:!1,hasParam:!1},{name:"get bridge.secret",category:"get",params:[],description:"Get bridge encryption secret",serialOnly:!1,hasParam:!1},{name:"get bridge.source",category:"get",params:[],description:"Get bridge packet source",serialOnly:!1,hasParam:!1},{name:"get bridge.type",category:"get",params:[],description:"Get bridge type (rs232/espnow/none)",serialOnly:!1,hasParam:!1},{name:"get direct.txdelay",category:"get",params:[],description:"Get direct TX delay factor",serialOnly:!1,hasParam:!1},{name:"get flood.advert.interval",category:"get",params:[],description:"Get flood advert interval (hours)",serialOnly:!1,hasParam:!1},{name:"get flood.max",category:"get",params:[],description:"Get max flood hops",serialOnly:!1,hasParam:!1},{name:"get freq",category:"get",params:[],description:"Get frequency (MHz)",serialOnly:!1,hasParam:!1},{name:"get guest.password",category:"get",params:[],description:"Get guest password",serialOnly:!1,hasParam:!1},{name:"get int.thresh",category:"get",params:[],description:"Get interference threshold",serialOnly:!1,hasParam:!1},{name:"get lat",category:"get",params:[],description:"Get latitude",serialOnly:!1,hasParam:!1},{name:"get lon",category:"get",params:[],description:"Get longitude",serialOnly:!1,hasParam:!1},{name:"get multi.acks",category:"get",params:[],description:"Get multi-ack setting",serialOnly:!1,hasParam:!1},{name:"get name",category:"get",params:[],description:"Get node name",serialOnly:!1,hasParam:!1},{name:"get prv.key",category:"get",params:[],description:"Get private key (hex)",serialOnly:!1,hasParam:!1},{name:"get public.key",category:"get",params:[],description:"Get public key (hex)",serialOnly:!1,hasParam:!1},{name:"get radio",category:"get",params:[],description:"Get radio params (freq,bw,sf,cr)",serialOnly:!1,hasParam:!1},{name:"get repeat",category:"get",params:[],description:"Get repeat/forward status (on/off)",serialOnly:!1,hasParam:!1},{name:"get role",category:"get",params:[],description:"Get device role",serialOnly:!1,hasParam:!1},{name:"get rxdelay",category:"get",params:[],description:"Get RX delay base",serialOnly:!1,hasParam:!1},{name:"get tx",category:"get",params:[],description:"Get TX power (dBm)",serialOnly:!1,hasParam:!1},{name:"get txdelay",category:"get",params:[],description:"Get TX delay factor",serialOnly:!1,hasParam:!1},{name:"gps",category:"gps",params:[],description:"Show GPS status",serialOnly:!1,hasParam:!1},{name:"gps advert",category:"gps",params:[],description:"Get/set GPS advert location policy",serialOnly:!1,hasParam:!0},{name:"gps off",category:"gps",params:[],description:"Disable GPS",serialOnly:!1,hasParam:!0},{name:"gps on",category:"gps",params:[],description:"Enable GPS",serialOnly:!1,hasParam:!0},{name:"gps setloc",category:"gps",params:[],description:"Set node location from GPS",serialOnly:!1,hasParam:!0},{name:"gps sync",category:"gps",params:[],description:"Sync time from GPS",serialOnly:!1,hasParam:!0},{name:"log",category:"logging",params:[],description:"Dump log file (serial only)",serialOnly:!0,hasParam:!1},{name:"log erase",category:"logging",params:[],description:"Erase log file",serialOnly:!1,hasParam:!0},{name:"log start",category:"logging",params:[],description:"Start packet logging",serialOnly:!1,hasParam:!0},{name:"log stop",category:"logging",params:[],description:"Stop packet logging",serialOnly:!1,hasParam:!0},{name:"neighbor.remove",category:"neighbor",params:[],description:"Remove neighbor by pubkey",serialOnly:!1,hasParam:!0},{name:"neighbors",category:"neighbor",params:[],description:"List neighbors",serialOnly:!1,hasParam:!1},{name:"get",category:"other",params:[],description:"Execute get command",serialOnly:!1,hasParam:!0},{name:"set",category:"other",params:[{name:"value",type:"float"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Execute set command",serialOnly:!1,hasParam:!0},{name:"tempradio",category:"radio",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Apply temporary radio params (freq bw sf cr timeout_mins)",serialOnly:!1,hasParam:!0},{name:"sensor get",category:"sensor",params:[],description:"Get sensor/custom variable value",serialOnly:!1,hasParam:!0},{name:"sensor list",category:"sensor",params:[{name:"value",type:"int"}],description:"List all sensor/custom variables",serialOnly:!1,hasParam:!0},{name:"sensor set",category:"sensor",params:[],description:"Set sensor/custom variable value",serialOnly:!1,hasParam:!0},{name:"set adc.multiplier",category:"set",params:[{name:"value",type:"float"}],description:"Set ADC multiplier",serialOnly:!1,hasParam:!0},{name:"set advert.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"string"}],description:"Set local advert interval (1-10080 min, 0=off)",serialOnly:!1,hasParam:!0},{name:"set af",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set airtime factor (0-9)",serialOnly:!1,hasParam:!0},{name:"set agc.reset.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set AGC reset interval (seconds, rounded to 4)",serialOnly:!1,hasParam:!0},{name:"set allow.read.only",category:"set",params:[{name:"value",type:"int"}],description:"Set read-only access (on/off)",serialOnly:!1,hasParam:!0},{name:"set bridge.baud",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set bridge baud (9600-115200)",serialOnly:!1,hasParam:!0},{name:"set bridge.channel",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"string"}],description:"Set bridge channel (1-14)",serialOnly:!1,hasParam:!0},{name:"set bridge.delay",category:"set",params:[{name:"value",type:"int"}],description:"Set bridge delay (0-10000 ms)",serialOnly:!1,hasParam:!0},{name:"set bridge.enabled",category:"set",params:[{name:"value",type:"int"}],description:"Enable/disable bridge",serialOnly:!1,hasParam:!0},{name:"set bridge.secret",category:"set",params:[{name:"value",type:"string"},{name:"value",type:"float"}],description:"Set bridge encryption secret",serialOnly:!1,hasParam:!0},{name:"set bridge.source",category:"set",params:[{name:"value",type:"int"}],description:"Set bridge source (rx/tx)",serialOnly:!1,hasParam:!0},{name:"set direct.txdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set direct TX delay factor",serialOnly:!1,hasParam:!0},{name:"set flood.advert.interval",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set flood advert interval (3-48 hours, 0=off)",serialOnly:!1,hasParam:!0},{name:"set flood.max",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"float"}],description:"Set max flood hops (0-64)",serialOnly:!1,hasParam:!0},{name:"set freq",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set frequency MHz (serial only, reboot required)",serialOnly:!0,hasParam:!0},{name:"set guest.password",category:"set",params:[{name:"value",type:"string"}],description:"Set guest password",serialOnly:!1,hasParam:!0},{name:"set int.thresh",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set interference threshold",serialOnly:!1,hasParam:!0},{name:"set lat",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set latitude",serialOnly:!1,hasParam:!0},{name:"set lon",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set longitude",serialOnly:!1,hasParam:!0},{name:"set multi.acks",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set multi-ack (0/1)",serialOnly:!1,hasParam:!0},{name:"set name",category:"set",params:[{name:"value",type:"string"},{name:"value",type:"int"}],description:"Set node name",serialOnly:!1,hasParam:!0},{name:"set prv.key",category:"set",params:[{name:"value",type:"string"}],description:"Set private key (hex, restart required)",serialOnly:!1,hasParam:!0},{name:"set radio",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set radio params (freq bw sf cr)",serialOnly:!1,hasParam:!0},{name:"set repeat",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"int"}],description:"Set repeat/forward (on/off)",serialOnly:!1,hasParam:!0},{name:"set rxdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"float"}],description:"Set RX delay base",serialOnly:!1,hasParam:!0},{name:"set tx",category:"set",params:[{name:"value",type:"int"},{name:"value",type:"float"}],description:"Set TX power (dBm)",serialOnly:!1,hasParam:!0},{name:"set txdelay",category:"set",params:[{name:"value",type:"float"},{name:"value",type:"int"}],description:"Set TX delay factor",serialOnly:!1,hasParam:!0},{name:"stats-core",category:"stats",params:[],description:"Show core statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"stats-packets",category:"stats",params:[],description:"Show packet statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"stats-radio",category:"stats",params:[],description:"Show radio statistics (serial only)",serialOnly:!0,hasParam:!1},{name:"advert",category:"system",params:[],description:"Send self advertisement",serialOnly:!1,hasParam:!1},{name:"board",category:"system",params:[],description:"Show board/manufacturer name",serialOnly:!1,hasParam:!1},{name:"clear stats",category:"system",params:[],description:"Reset statistics counters",serialOnly:!1,hasParam:!0},{name:"clock",category:"system",params:[{name:"value",type:"int"}],description:"Display current time",serialOnly:!1,hasParam:!0},{name:"clock sync",category:"system",params:[],description:"Sync clock from sender timestamp",serialOnly:!1,hasParam:!0},{name:"password",category:"system",params:[{name:"value",type:"string"}],description:"Change admin password",serialOnly:!1,hasParam:!0},{name:"reboot",category:"system",params:[],description:"Reboot the device",serialOnly:!1,hasParam:!1},{name:"start ota",category:"system",params:[{name:"value",type:"int"}],description:"Start OTA firmware update",serialOnly:!1,hasParam:!0},{name:"time",category:"system",params:[{name:"value",type:"int"}],description:"Set time to epoch seconds",serialOnly:!1,hasParam:!0},{name:"ver",category:"system",params:[],description:"Show firmware version and build date",serialOnly:!1,hasParam:!1}].filter(e=>!e.serialOnly&&!A.has(e.name)&&!G.some(t=>e.name.startsWith(t))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],W={"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning"],"start cap":["30","60","120","300"]};function U(e){switch(e){case"success":return"text-accent-success";case"error":return"text-accent-danger";case"warning":return"text-amber-400";case"info":return"text-accent-tertiary";case"value":return"text-accent-primary";case"system":return"text-text-muted";default:return"text-text-secondary"}}const F=t.memo(function({entry:e}){const r=$(),n=l(),o=t.useCallback(e=>{const t=r.getReport(e);t?D(t,n):alert("Report no longer available. Captures are stored in session memory only.")},[r,n]);return"command"===e.type?a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx("span",{className:"text-text-muted font-medium select-none",children:"$"}),a.jsx("span",{className:"text-text-primary font-semibold",children:e.content})]}):"system"===e.type?a.jsx("div",{className:s("py-0.5",U(e.outputType||"system")),children:e.content}):e.content.includes("██")?a.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",U(e.outputType||"value")),children:e.content}):a.jsx("div",{className:"ml-4 font-mono text-[13px] py-1",children:e.content.split("\n").map((t,r)=>{const s=function(e,t){if(e.startsWith("REC:::"))return[{text:"●",color:"text-red-500 animate-pulse",isRecording:!0},{text:` ${e.slice(6)}`,color:"text-text-muted"}];const a=e.trimStart();if(a.startsWith("DOWNLOAD:::")){const t=e.slice(0,e.length-a.length),r=a.slice(11).split(":::"),[s,n]=r;return[{text:`${t}⇓ download "${n}"`,color:"text-accent-primary underline cursor-pointer hover:text-accent-secondary",isDownload:!0,downloadId:s,downloadFilename:n}]}if(e.startsWith("HELP_HEADER:::"))return[{text:e.slice(14),color:"text-text-primary font-bold"}];if(e.startsWith("HELP_NOTE:::"))return[{text:e.slice(12),color:"text-text-muted italic"}];const r=e.match(/^([a-z][a-z0-9.]*(?:\s+[a-z][a-z0-9.]*)?):::(.+)$/);if(r){const[,e,t]=r,a=e.split(" "),s=a[0];let n="text-accent-tertiary";"get"===s?n="text-accent-success":"set"===s&&(n="text-amber-400");const o=[{text:` ${s}`,color:`${n} font-semibold`}];a.length>1&&o.push({text:` ${a.slice(1).join(" ")}`,color:"text-accent-primary"});const i=" ".repeat(Math.max(1,22-e.length));return o.push({text:`${i}${t}`,color:"text-text-muted"}),o}if("error"===t||"warning"===t)return[{text:e,color:U(t)}];if("value"===t)return[{text:e,color:U("value")}];const s=e.match(/^([\w\s.]+):\s*(.+)$/);if(s){const[,e,t]=s;return[{text:`${e}: `,color:"text-text-muted"},{text:t,color:"text-accent-primary font-semibold"}]}return e.startsWith("OK")?[{text:e,color:U("success")}]:[{text:e,color:U(t)}]}(t,e.outputType||"default");return a.jsx("div",{className:"leading-relaxed",children:s.map((e,t)=>e.isDownload?a.jsx("span",{className:e.color,onClick:()=>o(e.downloadId),role:"button",tabIndex:0,onKeyDown:t=>"Enter"===t.key&&o(e.downloadId),children:e.text},t):a.jsx("span",{className:e.color,children:e.text},t))},r)})})});function H(){const e=l(),n=c(),o=$(),i=I(e=>e.entries),f=I(e=>e.commandHistory),v=I(e=>e.isInitialized),{addEntry:b,updateEntry:x,addCommand:k,clearEntries:O,setInitialized:P}=I(),[T,C]=t.useState(""),[E,N]=t.useState(-1),[j,A]=t.useState(!1),[G,U]=t.useState([]),[H,M]=t.useState(0),[z,q]=t.useState(0),[B,K]=t.useState(!1),X=t.useRef(null),V=t.useRef(null),J=t.useRef(null),Q=t.useRef(n);t.useEffect(()=>{Q.current=n},[n]),t.useEffect(()=>{v||(async()=>{b({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=b({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),x(e,{content:"✓ Initializing terminal...",outputType:"success"});const t=b({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),x(t,{content:"✓ Connected to repeater",outputType:"success"}),b({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),P(!0)})()},[v,b,x,P]),t.useEffect(()=>{V.current&&(V.current.scrollTop=V.current.scrollHeight)},[i]);const Y=t.useCallback(()=>{var e;const t=window.getSelection();t&&t.toString().length>0||null==(e=X.current)||e.focus()},[]),Z=t.useMemo(()=>(null==e?void 0:e.neighbors)?Object.values(e.neighbors).map(e=>e.node_name||e.name).filter(e=>!!e).sort():[],[null==e?void 0:e.neighbors]),ee=t.useCallback(e=>{const t=e.trim().toLowerCase();if(!t)return A(!1),void U([]);const a=L.filter(e=>e.cmd.toLowerCase().startsWith(t));if(a.length>0)return U(a),M(0),void A(!0);if(t.includes(" ")){const e=t.lastIndexOf(" "),a=t.substring(0,e),r=t.substring(e+1);if("ping"===a&&Z.length>0){const e=Z.filter(e=>e.toLowerCase().startsWith(r)).slice(0,10).map(e=>({cmd:`ping ${e}`,desc:`→ ${e}`}));if(e.length>0)return U(e),M(0),void A(!0)}if("export cap"===a&&o.reports.length>0){const e=o.reports.map((e,t)=>({id:e.id,index:String(t+1),pkts:e.packetCount,duration:e.durationSec})).filter(e=>e.id.toLowerCase().startsWith(r)||e.index.startsWith(r)).slice(0,10).map(e=>({cmd:`export cap ${e.index}`,desc:`${e.pkts} pkts • ${e.duration}s`}));if(e.length>0)return U(e),M(0),void A(!0)}const s=L.find(e=>e.cmd.toLowerCase()===a);if(s&&W[s.cmd]){const e=W[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return U(e),M(0),void A(!0)}}A(!1),U([])},[Z,o.reports]),te=t.useCallback(e=>{var t;const a=G[e];a&&(a.required&&a.params?(C(a.cmd+" "),ee(a.cmd+" ")):(C(a.cmd),A(!1)),null==(t=X.current)||t.focus())},[G,ee]),ae=t.useCallback(async t=>{var a,r,s,i,l,c,f,v,w;const _=t.trim();if(!_)return;const S=_.toLowerCase();if(k(_),b({type:"command",content:_}),"clear"===S)return void O();if("help"===S){const e=L.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void b({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const P=b({type:"output",content:"processing...",outputType:"system"});try{const t=await d();let k="",O="info";const E=e=>{const t=Math.floor(e/86400),a=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${a}h ${r}m`:a>0?`${a}h ${r}m`:`${r}m`};if("status"===S){k=`Mode: ${(null==(r=null==(a=t.config)?void 0:a.repeater)?void 0:r.mode)||"unknown"} | Neighbors: ${Object.keys(t.neighbors||{}).length} | Uptime: ${E(t.uptime_seconds||0)}`}else if("uptime"===S)k=E(t.uptime_seconds||0),O="value";else if("packets"===S)k=`rx: ${t.rx_count??0}\ntx: ${t.tx_count??0}\nfwd: ${t.forwarded_count??0}\ndrop: ${t.dropped_count??0}`;else if("neighbors"===S){const e=t.neighbors||{},a=Object.entries(e);if(0===a.length)k="No neighbors discovered yet.",O="warning";else{const e=a.map(([e,t])=>{const a=t.name||t.node_name||"Unknown";return` ${e.slice(0,8)} ${a}`});k=`Neighbors (${a.length}):\n${e.join("\n")}`}}else if("board"===S)k="pyMC_Repeater (Linux/RPi)",O="value";else if(S.startsWith("get ")){const e=S.slice(4).trim(),a=null==(s=t.config)?void 0:s.delays,r=null==(i=t.config)?void 0:i.radio,n=null==(l=t.config)?void 0:l.repeater,o=null==(c=t.config)?void 0:c.duty_cycle;switch(e){case"name":k=(null==(f=t.config)?void 0:f.node_name)||"Unknown";break;case"role":k="repeater";break;case"lat":k=null!=(null==n?void 0:n.latitude)?String(n.latitude):"not set";break;case"lon":k=null!=(null==n?void 0:n.longitude)?String(n.longitude):"not set";break;case"freq":k=(null==r?void 0:r.frequency)?(r.frequency/1e6).toFixed(3):"?";break;case"tx":k=String((null==r?void 0:r.tx_power)??"?");break;case"bw":k=(null==r?void 0:r.bandwidth)?String(r.bandwidth/1e3):"?";break;case"sf":k=String((null==r?void 0:r.spreading_factor)??"?");break;case"cr":k=String((null==r?void 0:r.coding_rate)??"?");break;case"radio":k=r?`freq: ${(r.frequency/1e6).toFixed(3)} MHz\nbw: ${r.bandwidth/1e3} kHz\nsf: ${r.spreading_factor}\ncr: 4/${r.coding_rate}`:"?";break;case"af":case"txdelay":k=String((null==a?void 0:a.tx_delay_factor)??"1.0");break;case"direct.txdelay":k=String((null==a?void 0:a.direct_tx_delay_factor)??"0.5");break;case"mode":k=(null==n?void 0:n.mode)||"forward";break;case"repeat":k="forward"===(null==n?void 0:n.mode)?"on":"off";break;case"flood.max":k=String((null==n?void 0:n.max_flood_hops)??"3");break;case"flood.advert.interval":k=null!=(null==n?void 0:n.send_advert_interval_hours)?`${n.send_advert_interval_hours}h`:"?";break;case"advert.interval":k=null!=(null==n?void 0:n.advert_interval_minutes)?`${n.advert_interval_minutes}m`:"120m";break;case"rxdelay":k=String((null==a?void 0:a.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":k=(null==o?void 0:o.enforcement_enabled)?"on":"off";break;case"duty.max":k=null!=(null==o?void 0:o.max_airtime_percent)?`${o.max_airtime_percent}%`:"?";break;case"public.key":k=t.public_key||"not available";break;case"prv.key":k="Private key stored in /etc/pymc_repeater/config.yaml\n\nTo view: sudo grep identity_key /etc/pymc_repeater/config.yaml\nTo set: sudo ./convert_firmware_key.sh <64-byte-hex>",O="info";break;case"guest.password":case"allow.read.only":k="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",O="warning";break;default:k=`Unknown parameter: ${e}\nAvailable: name, role, lat, lon, freq, tx, bw, sf, cr, radio, af, txdelay, direct.txdelay, rxdelay, mode, repeat, flood.max, advert.interval, duty, public.key`,O="error"}"error"!==O&&(O="value")}else if("advert"===S){const e=await p();k=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,O=e.success?"success":"error"}else if(S.startsWith("set mode ")){const e=S.split(" ")[2];if("forward"!==e&&"monitor"!==e)k='Error: Mode must be "forward" or "monitor"',O="error";else{const t=await m(e);k=t.success?`OK - Mode set to ${e}`:"Error: Failed",O=t.success?"success":"error"}}else if(S.startsWith("set duty ")){const e=S.split(" ")[2],t="on"===e||"1"===e,a=await u(t);k=a.success?"OK - Duty cycle "+(t?"enabled":"disabled"):"Error: Failed",O=a.success?"success":"error"}else if(S.startsWith("set tx ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||e<2||e>22)k="Error: TX power must be 2-22 dBm (SX1262 chip max)",O="error";else{const t=await y({tx_power:e});k=t.success?`OK - TX power set to ${e}dBm`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set af ")||S.startsWith("set txdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0||e>5)k="Error: TX delay factor must be 0.0-5.0",O="error";else{const t=await y({tx_delay_factor:e});k=t.success?`OK - TX delay set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set direct.txdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0||e>5)k="Error: Direct TX delay must be 0.0-5.0",O="error";else{const t=await y({direct_tx_delay_factor:e});k=t.success?`OK - Direct TX delay set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set log ")){const e=null==(v=S.split(" ")[2])?void 0:v.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const t=await g(e);k=t.success?`OK - Log level set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}else k="Error: Level must be debug, info, warning, or error",O="error"}else if(S.startsWith("set rxdelay ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<0)k="Error: RX delay must be >= 0",O="error";else{const t=await y({rx_delay_base:e});k=t.success?`OK - RX delay base set to ${e}s`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set name ")){const e=_.substring(9).trim();if(e){const t=await y({node_name:e});k=t.success?`OK - Node name set to "${e}"`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}else k="Error: Node name cannot be empty",O="error"}else if(S.startsWith("set lat ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<-90||e>90)k="Error: Latitude must be -90 to 90",O="error";else{const t=await y({latitude:e});k=t.success?`OK - Latitude set to ${e}°`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set lon ")){const e=parseFloat(S.split(" ")[2]);if(isNaN(e)||e<-180||e>180)k="Error: Longitude must be -180 to 180",O="error";else{const t=await y({longitude:e});k=t.success?`OK - Longitude set to ${e}°`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set flood.max ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||e<0||e>64)k="Error: Max flood hops must be 0-64",O="error";else{const t=await y({max_flood_hops:e});k=t.success?`OK - Max flood hops set to ${e}`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set flood.advert.interval ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))k="Error: Flood advert interval must be 0 (off) or 3-48 hours",O="error";else{const t=await y({flood_advert_interval_hours:e});k=t.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set advert.interval ")){const e=parseInt(S.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))k="Error: Advert interval must be 0 (off) or 1-10080 minutes",O="error";else{const t=await y({advert_interval_minutes:e});k=t.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${t.error||"Failed"}`,O=t.success?"success":"error"}}else if(S.startsWith("set prv.key ")){const e=_.substring(12).trim();e?/^[0-9a-fA-F]+$/.test(e)?128!==e.length?(k=`Error: Key must be 64 bytes (128 hex chars), got ${e.length} chars`,O="error"):(k=`To set this key, run on the Pi:\n\n sudo ./convert_firmware_key.sh ${e}\n\nThen restart: sudo systemctl restart pymc-repeater`,O="info"):(k="Error: Private key must be a hex string",O="error"):(k="Error: Private key cannot be empty",O="error")}else if(S.startsWith("convert hex ")){const e=_.substring(12).trim();if(e)if(/^[0-9a-fA-F]+$/.test(e))if(e.length%2!=0)k="Error: Hex string must have even length",O="error";else try{const t=new Uint8Array(e.length/2);for(let s=0;s1&&!isNaN(r)&&r>0,n=s?t.slice(0,-1).join(" "):e,o=s?r:30;if(n){let e=1;const t=setInterval(()=>{e=e%3+1,x(P,{content:`Pinging ${n}${".".repeat(e)}`,outputType:"system"})},800);try{const e=await h(n,o);if(clearInterval(t),e.success&&e.data){const t=e.data,a=(null==(w=t.path)?void 0:w.length)?t.path.join(" → "):"direct";k=`Reply from ${t.target_id}\n RTT: ${t.rtt_ms.toFixed(1)}ms\n RSSI: ${t.rssi}dBm\n SNR: ${t.snr_db}dB\n Path: ${a}\n Quality: ${t.quality}`,O="success"}else k=e.error||"Ping failed",O="error"}catch(C){throw clearInterval(t),C}}else k="Usage: ping [timeout]",O="error"}else if("cap"===S||"cap help"===S){const e=o.isCapturing?'\nREC:::Recording in progress... use "end cap" to stop':"",t=o.reports.length;k=`HELP_HEADER:::Packet Capture\n\nstart cap:::Start capture (default: 120s)\nend cap:::Stop capture early\nlist cap:::List saved captures${t>0?` (${t} saved)`:""}\nexport cap:::Download capture by ID\n\nHELP_NOTE:::Captures stored in session memory. JSON includes decoded payloads.${e}`,O="info"}else if("start cap"===S||S.startsWith("start cap ")){const e=S.slice(10).trim(),t=e?parseInt(e):120;if(isNaN(t)||t<1||t>3600)k="Error: Duration must be 1-3600 seconds",O="error";else{if(!o.isCapturing){o.startCapture(n);let e=t;x(P,{content:`REC:::Capturing... ${e}s remaining`,outputType:"system"});const a=setInterval(()=>{e--;const t=$.getState();if(e>=0&&t.isCapturing){const a=Q.current.filter(e=>{if(!t.captureStartTime)return!1;const a=t.captureStartTime.getTime()/1e3;return e.timestamp>=a&&!t.captureStartPacketHashes.has(e.packet_hash)}).length;x(P,{content:`REC:::Capturing... ${e>0?`${e}s remaining`:"finishing..."} (${a} captured)`,outputType:"system"})}},1e3),r=setTimeout(()=>{clearInterval(a);const e=$.getState();if(e.isCapturing){const t=Q.current,a=e.stopCapture(t);b(a?{type:"output",content:`✓ Capture complete!\n Captured: ${a.packetCount} packets\n Duration: ${a.durationSec}s\n Size: ~${R(a.sizeBytes)}\n\nDOWNLOAD:::${a.id}:::${a.filename}`,outputType:"success"}:{type:"output",content:"Capture completed with no packets.",outputType:"warning"})}},1e3*t);return void o._setTimer(r)}k='Error: Capture already in progress. Use "end cap" first.',O="error"}}else if("end cap"===S)if(o.isCapturing){const e=o.stopCapture(n);e?(k=`✓ Capture complete!\n Captured: ${e.packetCount} packets\n Duration: ${e.durationSec}s\n Size: ~${R(e.sizeBytes)}\n\nDOWNLOAD:::${e.id}:::${e.filename}`,O="success"):(k="Capture stopped with no packets.",O="warning")}else k="No capture in progress.",O="warning";else if("list cap"===S){const e=o.reports;if(0===e.length)k="No capture reports available.\nStart a capture with: start cap [seconds]",O="info";else{const t=e.map((e,t)=>` ${t+1}. ${e.packetCount} pkts • ${e.durationSec}s • ~${R(e.sizeBytes)}\n DOWNLOAD:::${e.id}:::${e.filename}`);k=`Capture Reports (${e.length}):\n${t.join("\n")}`,O="info"}}else if("export cap"===S||S.startsWith("export cap ")){const t=S.slice(11).trim();if(t){const a=o.getReport(t);if(a)D(a,e),k=`✓ Downloading ${a.filename}...`,O="success";else{const a=parseInt(t)-1,r=o.reports[a];r?(D(r,e),k=`✓ Downloading ${r.filename}...`,O="success"):(k=`Error: Report "${t}" not found.\nUse "list cap" to see available reports.`,O="error")}}else{const e=o.reports;0===e.length?(k="No capture reports available.\nStart a capture with: start cap [seconds]",O="info"):(k=`Usage: export cap \n\nAvailable reports:\n${e.map((e,t)=>` ${t+1}. ${e.id}`).join("\n")}`,O="info")}}else k=`Unknown command: ${_}\nType 'help' for available commands.`,O="error";x(P,{content:k,outputType:O})}catch(E){x(P,{content:`Error: ${E instanceof Error?E.message:"Command failed"}`,outputType:"error"})}},[b,k,x,O,o,n,e]),re=t.useCallback(e=>{var t,a,r,s,n,o;if(j&&G.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(H+1,G.length-1);return M(s),void(null==(r=null==(a=null==(t=J.current)?void 0:t.children[0])?void 0:a.children[s])||r.scrollIntoView({block:"nearest"}))}if("ArrowUp"===e.key){e.preventDefault();const t=Math.max(H-1,0);return M(t),void(null==(o=null==(n=null==(s=J.current)?void 0:s.children[0])?void 0:n.children[t])||o.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void te(H);if("Escape"===e.key)return e.preventDefault(),void A(!1)}if("Enter"===e.key){if(e.preventDefault(),j&&G.length>0){const e=G[H].cmd;return C(""),N(-1),A(!1),void ae(e)}const t=T;return C(""),N(-1),A(!1),void ae(t)}if("ArrowUp"!==e.key||j)if("ArrowDown"!==e.key||j);else if(e.preventDefault(),E>0){const e=E-1;N(e),C(f[f.length-1-e]||"")}else 0===E&&(N(-1),C(""));else if(e.preventDefault(),f.length>0&&E{C(e.target.value),q(e.target.selectionStart||e.target.value.length),ee(e.target.value)},[ee]),ne=t.useCallback(e=>{const t=e.target;q(t.selectionStart||0)},[]);return a.jsxs(w,{children:[a.jsx(_,{title:"Terminal",icon:a.jsx(r,{})}),a.jsxs(S,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:Y,children:[a.jsx("div",{ref:V,className:"flex-1 overflow-y-auto font-mono text-sm p-3 sm:p-4 md:p-5",style:{background:"var(--terminal-bg)"},children:i.map(e=>a.jsx(F,{entry:e},e.id))}),a.jsxs("div",{className:"relative",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[a.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-3",children:[a.jsx("span",{className:"text-text-muted font-mono font-bold select-none",children:"$"}),a.jsxs("div",{className:"flex-1 relative font-mono text-sm",children:[a.jsx("input",{ref:X,type:"text",value:T,onChange:se,onKeyDown:re,onSelect:ne,onFocus:()=>K(!0),onBlur:()=>K(!1),disabled:!v,className:"absolute inset-0 w-full bg-transparent text-transparent outline-none disabled:opacity-50 selection:bg-transparent",style:{caretColor:"transparent"},autoFocus:!0,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),a.jsx("div",{className:"relative pointer-events-none select-none","aria-hidden":!0,children:v?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-text-primary",children:T.slice(0,z)}),a.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",B?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:a.jsx("span",{className:"text-bg-primary",children:T[z]||""})}),a.jsx("span",{className:"text-text-primary",children:T.slice(z+1)})]}):a.jsx("span",{className:"text-text-muted",children:"Connecting..."})})]})]}),a.jsxs("div",{className:"px-3 sm:px-4 py-1 flex justify-between text-[10px] text-text-muted",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-status)"},children:[a.jsx("span",{className:"hidden sm:inline",children:"↑↓ History"}),a.jsx("span",{className:"sm:hidden",children:"Terminal"}),(null==e?void 0:e.version)&&a.jsxs("span",{children:["pyMC v",e.version]})]})]}),j&&G.length>0&&a.jsxs("div",{ref:J,className:"absolute left-2 right-2 bottom-[72px] rounded-xl shadow-2xl overflow-hidden z-50 backdrop-blur-xl",style:{border:"1px solid var(--terminal-autocomplete-border)",background:"var(--terminal-autocomplete-bg)"},children:[a.jsx("div",{className:"max-h-64 overflow-y-auto",children:G.map((e,t)=>a.jsxs("div",{onClick:()=>te(t),className:s("px-4 py-2.5 cursor-pointer last:border-b-0 transition-colors",t===H?"bg-accent-primary/25":""),style:{borderBottom:"1px solid var(--terminal-border)",...t!==H?{"--tw-bg-opacity":0}:{}},onMouseEnter:e=>{t!==H&&(e.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:e=>{t!==H&&(e.currentTarget.style.background="transparent")},children:[a.jsx("span",{className:s("font-mono text-sm",t===H?"text-accent-primary":"text-text-primary"),children:e.cmd}),a.jsx("span",{className:"text-xs text-text-muted ml-4",children:e.desc})]},e.cmd))}),a.jsx("div",{className:"px-3 py-1.5 text-[10px] text-text-muted text-right",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-autocomplete-hover)"},children:"Tab to select"})]})]})]})}export{H as default}; diff --git a/frontend/dist/assets/index-CPdqYR4z.js b/frontend/dist/assets/index-BJEgt3tp.js similarity index 99% rename from frontend/dist/assets/index-CPdqYR4z.js rename to frontend/dist/assets/index-BJEgt3tp.js index b433610f..383c6d0e 100644 --- a/frontend/dist/assets/index-CPdqYR4z.js +++ b/frontend/dist/assets/index-BJEgt3tp.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-zWarN3Ve.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-BIMfl_CK.js","assets/useThemeColors-AeHMyThq.js","assets/PageLayout-CcoYWyzO.js","assets/PacketList-CnSxB7Jy.js","assets/channel-keys-DJWRrSwE.js","assets/SignalIndicator-BLrEkFNb.js","assets/DataBox-CRX76VsB.js","assets/TimeRangeSelector-DGCfekAv.js","assets/link-scoring-BNnTohl3.js","assets/NodeInformationCard-D-IeNCCX.js","assets/Card-BeZKc0xw.js","assets/Grid-BOO-7ObJ.js","assets/Packets-DHxvwdwr.js","assets/Contacts-BcOss4J-.js","assets/ping-BvkXSZG_.js","assets/CollisionExplorerModal-Vkgg9Koo.js","assets/BasemapLayer-S9Ush6Hh.js","assets/ConfirmModal-DlFyryXJ.js","assets/maplibre-gl-B1CfjdFi.css","assets/Statistics-DqgywSJF.js","assets/usePolling-CtRLadGa.js","assets/MeshGraph-CdoFbL_m.js","assets/DeepAnalysisModal-DysenxvY.js","assets/System-Cw2qx9Xo.js","assets/Logs-EKbeyhLl.js","assets/Terminal-BQEu4TKw.js","assets/Configuration-_CjN4yUe.js","assets/font-loader-jlbdh9Fw.js"])))=>i.map(i=>d[i]); -var e=Object.defineProperty,t=(t,s,n)=>((t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n)(t,"symbol"!=typeof s?s+"":s,n);import{r as s,j as n,c as a,L as r,d as o,A as i,h as l,m as c,z as u,Q as d,e as h,M as m,y as f,X as g,x as p,C as b,f as y,g as x,i as w,u as v,k,l as S,n as C,o as j,W as T,G as M,F as L,S as N,p as _,q as E,t as P,v as D,w as I,B as F,D as A,E as R,H as z,b as B,I as O,J as $,K as W,N as H,O as U,T as q}from"./vendor-react-C341c8YC.js";import{_ as G}from"./deckgl-DTsmDcfs.js";import{n as J}from"./recharts-6XUQYgRA.js";import"./vendor-core-WoOfkQwm.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const s of e)if("childList"===s.type)for(const e of s.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();const Y={surfaces:{glass:{tint:"#252525",light:"#ffffff",dark:"#000000",reflexLight:.15,reflexDark:.8,blur:6,blurElevated:8,brightness:1,opacity:8,opacityElevated:12},card:{radius:"1.125rem",padding:"1.25rem",paddingCompact:"0.75rem"},sidebar:{tint:"rgba(113, 156, 223, 0.06)",width:"16rem",drawerWidth:"85vw"},modal:{radius:"1.125rem",backdropBlur:"8px",backdropColor:"rgba(0, 0, 0, 0.6)"}},colors:{bg:{body:"#171717",surface:"#252525",elevated:"#333233",subtle:"#3F3F3F"},border:{subtle:"#4B4B4B",strong:"#616161"},text:{primary:"#E1E1E1",secondary:"#BFBFBF",muted:"#727272",inverse:"#171717"},accent:{primary:"#719CDF",secondary:"#DFBC72",tertiary:"#6FBCBD",success:"#719872",danger:"#E12672"},signal:{excellent:"#00FF00",good:"#8CE619",fair:"#FFD900",poor:"#FF8C26",critical:"#FF3333",unknown:"#616161"},status:{success:"#719872",warning:"#DFBC72",danger:"#E12672",info:"#6FBCBD",muted:"#616161"},chart:{c1:"#719CDF",c2:"#0074BE",c3:"#6FBCBD",c4:"#DFBC72",c5:"#719872",c6:"#E12672",c7:"#E17899",c8:"#999ABD",grid:"rgba(255, 255, 255, 0.06)",axis:"rgba(255, 255, 255, 0.4)",cursor:"rgba(255, 255, 255, 0.2)"},metric:{received:"#719872",forwarded:"#0074BE",transmitted:"#DFBC72",dropped:"#E12672"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#8E4EC6",local:"#FFB224",neighbor:"#46A758",mobile:"#F76B15",room:"#D6409F",edge:"#4B4B4B",edgeHover:"#6FBCBD"}},typography:{font:{title:"'Inter', system-ui, sans-serif",display:"'Inter', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xs:"0.64rem",sm:"0.8rem",base:"1rem",md:"1.125rem",lg:"1.25rem",xl:"1.563rem",xxl:"1.953rem",hero:"3.052rem"},weight:{normal:400,medium:500,semibold:600,bold:700},leading:{tight:1.1,snug:1.25,normal:1.5},tracking:{tight:"-0.02em",normal:"0",wide:"0.05em"}},spacing:{space:{gap:"1.5rem",gapMobile:"0.75rem",page:"1.5rem",pageMobile:"1rem",section:"2rem"},radius:{sm:"0.5rem",md:"0.875rem",lg:"1.125rem",xl:"1.5rem",pill:"9999px"}},motion:{fast:"0.1s",normal:"0.15s",slow:"0.4s",easing:"ease-out"}};function V(e){const t=e.replace("#","");if(6!==t.length&&3!==t.length)return e;let s,n,a;return 3===t.length?(s=parseInt(t[0]+t[0],16)/255,n=parseInt(t[1]+t[1],16)/255,a=parseInt(t[2]+t[2],16)/255):(s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255),`color(display-p3 ${s.toFixed(3)} ${n.toFixed(3)} ${a.toFixed(3)})`}function K(){return"undefined"!=typeof window&&CSS.supports("color","color(display-p3 1 1 1)")}function X(e){return K()?V(e):e}function Q(e,t){const s={...e};for(const n of Object.keys(t)){const a=t[n],r=e[n];void 0!==a&&("object"!=typeof a||null===a||Array.isArray(a)||"object"!=typeof r||null===r||Array.isArray(r)?s[n]=a:s[n]=Q(r,a))}return s}function Z(e){return{meta:e.meta,display:e.display,surfaces:e.surfaces?Q(Y.surfaces,e.surfaces):Y.surfaces,colors:e.colors?Q(Y.colors,e.colors):Y.colors,typography:e.typography?Q(Y.typography,e.typography):Y.typography,spacing:e.spacing?Q(Y.spacing,e.spacing):Y.spacing,motion:e.motion?Q(Y.motion,e.motion):Y.motion}}function ee(e){const t=e.replace("#","");return 6===t.length?`${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}`:"255, 255, 255"}function te(e){return{id:e.meta.id,colorScheme:{name:e.meta.name,dataTheme:e.meta.dataTheme,previewColor:e.meta.previewColor},background:{src:e.meta.backgroundImage,suggestedBrightness:e.meta.backgroundBrightness},display:{font:e.display.font,color:e.display.color,size:e.display.size,paletteColors:e.display.palette}}}const se="#fafafa",ne="#a1a1aa",ae="#71717a",re="#3f3f46",oe="#27272a",ie="#18181b",le="#09090b",ce="#ef4444",ue="#f97316",de="#f59e0b",he="#eab308",me="#22c55e",fe="#10b981",ge="#06b6d4",pe="#3b82f6",be="#8b5cf6",ye=Z({meta:{id:"",name:"",dataTheme:"",previewColor:pe,backgroundImage:"",backgroundBrightness:100,isDark:!0},display:{font:"Inter, sans-serif",color:ne,size:1,palette:[[pe,me,he,ue,ce],[le,ie,oe,re,se]]},typography:{font:{title:"Inter, sans-serif",display:"Inter, sans-serif",mono:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},weight:{normal:400,medium:500,semibold:600,bold:700,badge:700},tracking:{tight:"-0.02em",normal:"0",wide:"0.025em"},badge:{textTransform:"capitalize"}},surfaces:{glass:{tint:ie,light:re,dark:le,reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:100,opacityElevated:100,catalystMode:!0},sidebar:{tint:`${oe}80`},card:{radius:"0.5rem"},modal:{radius:"0.75rem"}},colors:{bg:{body:le,surface:ie,elevated:oe,subtle:oe},border:{subtle:oe,strong:"#52525b"},text:{primary:"#fff",secondary:ne,muted:ae,inverse:le},accent:{primary:pe,secondary:he,tertiary:ge,success:me,danger:ce},signal:{excellent:me,good:"#84cc16",fair:he,poor:ue,critical:ce,unknown:ae},status:{success:me,warning:de,danger:ce,info:pe,muted:ae},chart:{c1:pe,c2:fe,c3:de,c4:ue,c5:"#f43f5e",c6:be,c7:ge,c8:ae,grid:`${se}0d`,axis:`${se}33`,cursor:`${pe}33`},metric:{received:pe,forwarded:fe,transmitted:ue,dropped:ce},map:{nodeFill:pe,nodeStroke:`${se}e6`,hub:be,local:de,neighbor:fe,mobile:ue,room:"#ec4899",edge:re,edgeHover:pe}}}),xe=ye;te(ye);const we=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#B39DF3",backgroundImage:"/assets/sand.jpg",backgroundBrightness:80,isDark:!0},display:{font:"'Rubik Mono One', monospace",color:"#4A4A52",size:.8,palette:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]]},typography:{font:{title:"'Rubik Mono One', monospace"}},surfaces:{glass:{tint:"#252525",blur:6,blurElevated:8},sidebar:{tint:"rgba(113, 156, 223, 0.06)"}}}),ve=we;te(we);const ke=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#fabd2f",backgroundImage:"/assets/magma.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Jacquard 12', serif",color:"#fe8019",size:1.75,palette:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]]},typography:{font:{title:"'Jacquard 12', serif"},size:{xxl:"2.344rem"}},surfaces:{glass:{tint:"#282828"},sidebar:{tint:"rgba(250, 189, 47, 0.06)"}},colors:{accent:{primary:"#fabd2f",secondary:"#fb4934",tertiary:"#8ec07c",success:"#b8bb26",danger:"#fb4934"},signal:{excellent:"#b8bb26",good:"#8ec07c",fair:"#fabd2f",poor:"#fe8019",critical:"#fb4934",unknown:"#928374"},status:{success:"#b8bb26",warning:"#fabd2f",danger:"#fb4934",info:"#83a598",muted:"#928374"},chart:{c1:"#fabd2f",c2:"#fe8019",c3:"#fb4934",c4:"#d3869b",c5:"#b8bb26",c6:"#8ec07c",c7:"#83a598",c8:"#d65d0e",grid:"rgba(251, 241, 199, 0.06)",axis:"rgba(251, 241, 199, 0.4)",cursor:"rgba(251, 241, 199, 0.2)"},metric:{received:"#b8bb26",forwarded:"#83a598",transmitted:"#fabd2f",dropped:"#fb4934"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b16286",local:"#fabd2f",neighbor:"#fabd2f",mobile:"#fe8019",room:"#d3869b",edge:"#665c54",edgeHover:"#8ec07c"}}}),Se=ke;te(ke);const Ce=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#83a598",backgroundImage:"/assets/water.webp",backgroundBrightness:40,isDark:!0},display:{font:"'Cantora One', sans-serif",color:"#83a598",size:1.25,palette:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]]},typography:{font:{title:"'Cantora One', sans-serif"},size:{xxl:"2.148rem"},weight:{semibold:500}},surfaces:{glass:{tint:"#1e1e1e"},sidebar:{tint:"rgba(131, 165, 152, 0.06)"}},colors:{accent:{primary:"#83a598",secondary:"#a89984",tertiary:"#8ec07c",success:"#8ec07c",danger:"#cc241d"},signal:{excellent:"#8ec07c",good:"#b8bb26",fair:"#d79921",poor:"#fe8019",critical:"#cc241d",unknown:"#7c6f64"},status:{success:"#8ec07c",warning:"#d79921",danger:"#cc241d",info:"#83a598",muted:"#7c6f64"},chart:{c1:"#83a598",c2:"#8ec07c",c3:"#d79921",c4:"#b16286",c5:"#fe8019",c6:"#cc241d",c7:"#a89984",c8:"#7c6f64",grid:"rgba(213, 196, 161, 0.06)",axis:"rgba(213, 196, 161, 0.4)",cursor:"rgba(213, 196, 161, 0.2)"},metric:{received:"#8ec07c",forwarded:"#83a598",transmitted:"#d79921",dropped:"#cc241d"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b16286",local:"#d79921",neighbor:"#d79921",mobile:"#fe8019",room:"#b16286",edge:"#504945",edgeHover:"#83a598"}}}),je=Ce;te(Ce);const Te=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#33859d",backgroundImage:"/assets/stars.jpg",backgroundBrightness:100,isDark:!0},display:{font:"'IBM Plex Mono', monospace",color:"#c23127",size:1.25,palette:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]]},typography:{font:{title:"'IBM Plex Mono', monospace"}},surfaces:{glass:{tint:"#0a0e14",blur:1,blurElevated:2},sidebar:{tint:"rgba(51, 133, 157, 0.06)"}},colors:{accent:{primary:"#33859d",secondary:"#edb54b",tertiary:"#26a98b",success:"#26a98b",danger:"#c33027"},signal:{excellent:"#26a98b",good:"#7ec07c",fair:"#edb54b",poor:"#d26939",critical:"#c33027",unknown:"#195465"},status:{success:"#26a98b",warning:"#edb54b",danger:"#c33027",info:"#599caa",muted:"#195465"},chart:{c1:"#33859d",c2:"#edb54b",c3:"#26a98b",c4:"#599caa",c5:"#d26939",c6:"#c33027",c7:"#888ba5",c8:"#195465",grid:"rgba(153, 209, 206, 0.06)",axis:"rgba(153, 209, 206, 0.4)",cursor:"rgba(153, 209, 206, 0.2)"},metric:{received:"#26a98b",forwarded:"#33859d",transmitted:"#edb54b",dropped:"#c33027"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#888ba5",local:"#edb54b",neighbor:"#edb54b",mobile:"#d26939",room:"#888ba5",edge:"#245361",edgeHover:"#26a98b"}}}),Me=Te;te(Te);const Le="#2D2D2D",Ne="#4A4A4A",_e="#7A7A7A",Ee=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#9ed072",backgroundImage:"",backgroundColor:"#F5F5F5",backgroundBrightness:100,isDark:!1},display:{font:"'JetBrains Mono', monospace",color:"#2D2D2D",size:1,palette:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]]},typography:{font:{title:"'JetBrains Mono', 'SF Mono', Monaco, monospace",display:"'Instrument Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace",cardTitle:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xxl:"1.875rem",cardTitle:"1rem"},weight:{normal:400,medium:500,semibold:600,bold:600,cardTitle:600}},surfaces:{glass:{tint:"#FFFFFF",light:"rgba(255, 255, 255, 1)",dark:"rgba(0, 0, 0, 0.1)",reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:0,opacityElevated:0,ribbonMode:!0,ribbonBorderWidth:2,ribbonBorderColor:_e},sidebar:{tint:"rgba(0, 0, 0, 0.02)"}},colors:{bg:{body:"#F5F5F5",surface:"#FFFFFF",elevated:"#FFFFFF",subtle:"#EBEBEB"},border:{subtle:"#E0E0E0",strong:"#BFBFBF"},text:{primary:Le,secondary:Ne,muted:_e,inverse:"#FFFFFF"},accent:{primary:"#9ed072",secondary:"#e7c664",tertiary:"#76cce0",success:"#9ed072",danger:"#fc5d7c"},signal:{excellent:"#9ed072",good:"#c5d93d",fair:"#e7c664",poor:"#f39660",critical:"#fc5d7c",unknown:"#7f8490"},status:{success:"#9ed072",warning:"#e7c664",danger:"#fc5d7c",info:"#76cce0",muted:"#7f8490"},chart:{c1:"#2E8B57",c2:"#E14D6B",c3:"#D4A832",c4:"#4A9EA0",c5:"#8B6BAE",c6:"#D97A4A",c7:_e,c8:Ne,grid:"rgba(45, 45, 45, 0.08)",axis:"rgba(45, 45, 45, 0.5)",cursor:"rgba(45, 45, 45, 0.15)"},metric:{received:"#9ed072",forwarded:"#76cce0",transmitted:"#e7c664",dropped:"#fc5d7c"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b39df3",local:"#e7c664",neighbor:"#e7c664",mobile:"#f39660",room:"#fc5d7c",edge:_e,edgeHover:"#76cce0"},icon:{pageTitle:Le,cardTitle:Le,widget:Ne,action:Ne,nav:_e,navActive:Le},sidebar:{bg:"rgba(0, 0, 0, 0.02)",navHoverBg:"rgba(0, 0, 0, 0.04)",navActiveBg:"rgba(0, 0, 0, 0.06)",navActiveText:Le}}}),Pe=Ee;te(Ee);const De=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#7E9CD8",backgroundImage:"/assets/folds.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Inter', sans-serif",color:"#7E9CD8",size:1.25,palette:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]]},typography:{font:{title:"'Inter', sans-serif"}},surfaces:{glass:{tint:"#1F1F28"},sidebar:{tint:"rgba(126, 156, 216, 0.06)"}},colors:{accent:{primary:"#7E9CD8",secondary:"#E6C384",tertiary:"#7FB4CA",success:"#98BB6C",danger:"#E46876"},signal:{excellent:"#98BB6C",good:"#B8CC5C",fair:"#E6C384",poor:"#FFA066",critical:"#E46876",unknown:"#54546D"},status:{success:"#98BB6C",warning:"#E6C384",danger:"#E46876",info:"#7FB4CA",muted:"#727169"},chart:{c1:"#7E9CD8",c2:"#E6C384",c3:"#98BB6C",c4:"#957FB8",c5:"#7FB4CA",c6:"#E46876",c7:"#FFA066",c8:"#D27E99",grid:"rgba(220, 215, 186, 0.06)",axis:"rgba(220, 215, 186, 0.4)",cursor:"rgba(220, 215, 186, 0.2)"},metric:{received:"#98BB6C",forwarded:"#7E9CD8",transmitted:"#E6C384",dropped:"#E46876"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#957FB8",local:"#E6C384",neighbor:"#E6C384",mobile:"#FFA066",room:"#D27E99",edge:"#54546D",edgeHover:"#7AA89F"}}}),Ie=De;te(De);const Fe={"KDE Breeze":xe,Magma:Se,Folds:Ie,Ribbon:Pe,BLKSAND:ve,Waves:je,Stars:Me};function Ae(e,t){const s=e.toLowerCase();return{...t,meta:{...t.meta,id:s,name:e,dataTheme:s}}}const Re=Object.fromEntries(Object.entries(Fe).map(([e,t])=>[e,Ae(e,t)])),ze=Object.fromEntries(Object.entries(Re).map(([e,t])=>[e,te(t)])),Be=Object.values(Re);function Oe(e){return Be.find(t=>t.meta.id===e)}new Map(Object.entries(Re));const $e=Object.values(ze);new Map(Object.entries(ze));const We=Object.entries(ze).map(([e,t])=>function(e,t){return{id:e.id,name:e.colorScheme.name,displayName:t,colorScheme:e.id,backgroundImage:e.background.src,paletteColors:e.display.paletteColors,displayFont:e.display.font,displayColor:e.display.color,displaySize:e.display.size}}(t,e)),He=$e.map(function(e){return{id:e.id,name:e.colorScheme.name,dataTheme:e.colorScheme.dataTheme,previewColor:e.colorScheme.previewColor}}),Ue=$e.map(function(e){return{id:e.id,src:e.background.src,suggestedScheme:e.id,suggestedBrightness:e.background.suggestedBrightness}}),qe=Re["KDE Breeze"];ze["KDE Breeze"];const Ge=qe.meta.id,Je=qe.meta.backgroundImage,Ye=qe.meta.backgroundBrightness,Ve=He,Ke=Ue,Xe=We,Qe={colorScheme:Ge,backgroundImage:Je,brightness:Ye},Ze="pymc-color-scheme",et="pymc-background-image",tt="pymc-bg-brightness",st="pymc-background";function nt(e){(new Image).src=e}const at={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},rt=[50,100,200,300,400,500,600,700,800,900],ot=["red","orange","yellow","green","aqua","blue","purple"];function it(e,t,s){const n=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(s)}`}function lt(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ct(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function ut(e,t,s){const n=s*(Math.PI/180),a=t*Math.cos(n),r=t*Math.sin(n),o=e+.3963377774*a+.2158037573*r,i=e-.1055613458*a-.0638541728*r,l=e-.0894841775*a-1.291485548*r,c=o*o*o,u=i*i*i,d=l*l*l,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,m=-.0041960863*c-.7034186147*u+1.707614701*d;return[ct(4.0767416621*c-3.3077115913*u+.2309699292*d),ct(h),ct(m)]}function dt(e){const[t,s,n]=function(e){const t=e.replace("#","");return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}(e),[,a,r]=function(e,t,s){const n=lt(e),a=lt(t),r=lt(s),o=.4122214708*n+.5363325363*a+.0514459929*r,i=.2119034982*n+.6806995451*a+.1073969566*r,l=.0883024619*n+.2817188376*a+.6299787005*r,c=Math.cbrt(o),u=Math.cbrt(i),d=Math.cbrt(l),h=.2104542553*c+.793617785*u-.0040720468*d,m=1.9779984951*c-2.428592205*u+.4505937099*d,f=.0259040371*c+.7827717662*u-.808675766*d,g=Math.sqrt(m*m+f*f);let p=Math.atan2(f,m)*(180/Math.PI);return p<0&&(p+=360),[h,g,p]}(t,s,n),o={};for(const i of rt){const e=at[i],t=a*(1-.3*Math.abs(e-.5)),[s,n,l]=ut(e,t,r);o[i]=it(s,n,l)}return o}function ht(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function mt(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const ft="u-off",gt="u-label",pt="width",bt="height",yt="top",xt="bottom",wt="left",vt="right",kt="#000",St=kt+"0",Ct="mousemove",jt="mousedown",Tt="mouseup",Mt="mouseenter",Lt="mouseleave",Nt="dblclick",_t="change",Et="dppxchange",Pt="--",Dt="undefined"!=typeof window,It=Dt?document:null,Ft=Dt?window:null,At=Dt?navigator:null;let Rt,zt;function Bt(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function Ot(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function $t(e,t,s){e.style[t]=s+"px"}function Wt(e,t,s,n){let a=It.createElement(e);return null!=t&&Bt(a,t),null!=s&&s.insertBefore(a,n),a}function Ht(e,t){return Wt("div",e,t)}const Ut=new WeakMap;function qt(e,t,s,n,a){let r="translate("+t+"px,"+s+"px)";r!=Ut.get(e)&&(e.style.transform=r,Ut.set(e,r),t<0||s<0||t>n||s>a?Bt(e,ft):Ot(e,ft))}const Gt=new WeakMap;function Jt(e,t,s){let n=t+s;n!=Gt.get(e)&&(Gt.set(e,n),e.style.background=t,e.style.borderColor=s)}const Yt=new WeakMap;function Vt(e,t,s,n){let a=t+""+s;a!=Yt.get(e)&&(Yt.set(e,a),e.style.height=s+"px",e.style.width=t+"px",e.style.marginLeft=n?-t/2+"px":0,e.style.marginTop=n?-s/2+"px":0)}const Kt={passive:!0},Xt={...Kt,capture:!0};function Qt(e,t,s,n){t.addEventListener(e,s,n?Xt:Kt)}function Zt(e,t,s,n){t.removeEventListener(e,s,Kt)}function es(e,t,s,n){let a;s=s||0;let r=(n=n||t.length-1)<=2147483647;for(;n-s>1;)a=r?s+n>>1:xs((s+n)/2),t[a]{let a=-1,r=-1;for(let o=s;o<=n;o++)if(e(t[o])){a=o;break}for(let o=n;o>=s;o--)if(e(t[o])){r=o;break}return[a,r]}}Dt&&function e(){let t=devicePixelRatio;Rt!=t&&(Rt=t,zt&&Zt(_t,zt,e),zt=matchMedia(`(min-resolution: ${Rt-.001}dppx) and (max-resolution: ${Rt+.001}dppx)`),Qt(_t,zt,e),Ft.dispatchEvent(new CustomEvent(Et)))}();const ss=e=>null!=e,ns=e=>null!=e&&e>0,as=ts(ss),rs=ts(ns);function os(e,t,s,n){let a=js(e),r=js(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let o=10==s?Ts:Ms,i=1==r?vs:xs,l=(1==a?xs:vs)(o(ys(e))),c=i(o(ys(t))),u=Cs(s,l),d=Cs(s,c);return 10==s&&(l<0&&(u=Us(u,-l)),c<0&&(d=Us(d,-c))),n||2==s?(e=u*a,t=d*r):(e=Hs(e,u),t=Ws(t,d)),[e,t]}function is(e,t,s,n){let a=os(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const ls={mode:3,pad:.1},cs={pad:0,soft:null,mode:0},us={min:cs,max:cs};function ds(e,t,s,n){return en(s)?ms(e,t,s):(cs.pad=s,cs.soft=n?0:null,cs.mode=n?3:0,ms(e,t,us))}function hs(e,t){return null==e?t:e}function ms(e,t,s){let n=s.min,a=s.max,r=hs(n.pad,0),o=hs(a.pad,0),i=hs(n.hard,-Ns),l=hs(a.hard,Ns),c=hs(n.soft,Ns),u=hs(a.soft,-Ns),d=hs(n.mode,0),h=hs(a.mode,0),m=t-e,f=Ts(m),g=Ss(ys(e),ys(t)),p=Ts(g),b=ys(p-f);(m<1e-24||b>10)&&(m=0,0!=e&&0!=t||(m=1e-24,2==d&&c!=Ns&&(r=0),2==h&&u!=-Ns&&(o=0)));let y=m||g||1e3,x=Ts(y),w=Cs(10,xs(x)),v=Us(Hs(e-y*(0==m?0==e?.1:1:r),w/10),24),k=e>=c&&(1==d||3==d&&v<=c||2==d&&v>=c)?c:Ns,S=Ss(i,v=k?k:ks(k,v)),C=Us(Ws(t+y*(0==m?0==t?.1:1:o),w/10),24),j=t<=u&&(1==h||3==h&&C>=u||2==h&&C<=u)?u:-Ns,T=ks(l,C>j&&t<=j?j:Ss(j,C));return S==T&&0==S&&(T=100),[S,T]}const fs=new Intl.NumberFormat(Dt?At.language:"en-US"),gs=e=>fs.format(e),ps=Math,bs=ps.PI,ys=ps.abs,xs=ps.floor,ws=ps.round,vs=ps.ceil,ks=ps.min,Ss=ps.max,Cs=ps.pow,js=ps.sign,Ts=ps.log10,Ms=ps.log2,Ls=(e,t=1)=>ps.asinh(e/t),Ns=1/0;function _s(e){return 1+(0|Ts((e^e>>31)-(e>>31)))}function Es(e,t,s){return ks(Ss(e,t),s)}function Ps(e){return"function"==typeof e}function Ds(e){return Ps(e)?e:()=>e}const Is=e=>e,Fs=(e,t)=>t,As=e=>null,Rs=e=>!0,zs=(e,t)=>e==t,Bs=/\.\d*?(?=9{6,}|0{6,})/gm,Os=e=>{if(Qs(e)||qs.has(e))return e;const t=`${e}`,s=t.match(Bs);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${Os(e)}e${s}`}return Us(e,n)};function $s(e,t){return Os(Us(Os(e/t))*t)}function Ws(e,t){return Os(vs(Os(e/t))*t)}function Hs(e,t){return Os(xs(Os(e/t))*t)}function Us(e,t=0){if(Qs(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return ws(n)/s}const qs=new Map;function Gs(e){return((""+e).split(".")[1]||"").length}function Js(e,t,s,n){let a=[],r=n.map(Gs);for(let o=t;o=0?0:t)+(o>=r[i]?0:r[i]),u=10==e?l:Us(l,c);a.push(u),qs.set(u,c)}}return a}const Ys={},Vs=[],Ks=[null,null],Xs=Array.isArray,Qs=Number.isInteger;function Zs(e){return"string"==typeof e}function en(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function tn(e){return null!=e&&"object"==typeof e}const sn=Object.getPrototypeOf(Uint8Array),nn="__proto__";function an(e,t=en){let s;if(Xs(e)){let n=e.find(e=>null!=e);if(Xs(n)||t(n)){s=Array(e.length);for(let n=0;nr){for(n=o-1;n>=0&&null==e[n];)e[n--]=null;for(n=o+1;nPromise.resolve().then(e):queueMicrotask,cn=["January","February","March","April","May","June","July","August","September","October","November","December"],un=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function dn(e){return e.slice(0,3)}const hn=un.map(dn),mn=cn.map(dn),fn={MMMM:cn,MMM:mn,WWWW:un,WWW:hn};function gn(e){return(e<10?"0":"")+e}const pn={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,t)=>t.MMMM[e.getMonth()],MMM:(e,t)=>t.MMM[e.getMonth()],MM:e=>gn(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>gn(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>gn(e.getHours()),H:e=>e.getHours(),h:e=>{let t=e.getHours();return 0==t?12:t>12?t-12:t},AA:e=>e.getHours()>=12?"PM":"AM",aa:e=>e.getHours()>=12?"pm":"am",a:e=>e.getHours()>=12?"p":"a",mm:e=>gn(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>gn(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function bn(e,t){t=t||fn;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?pn[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,wn=[1,2,2.5,5],vn=Js(10,-32,0,wn),kn=Js(10,0,32,wn),Sn=kn.filter(xn),Cn=vn.concat(kn),jn="{YYYY}",Tn="\n"+jn,Mn="{M}/{D}",Ln="\n"+Mn,Nn=Ln+"/{YY}",_n="{aa}",En="{h}:{mm}"+_n,Pn="\n"+En,Dn=":{ss}",In=null;function Fn(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,r=30*a,o=365*a;return[(1==e?Js(10,0,3,wn).filter(xn):Js(10,-3,0,wn)).concat([t,5*t,10*t,15*t,30*t,s,5*s,10*s,15*s,30*s,n,2*n,3*n,4*n,6*n,8*n,12*n,a,2*a,3*a,4*a,5*a,6*a,7*a,8*a,9*a,10*a,15*a,r,2*r,3*r,4*r,6*r,o,2*o,5*o,10*o,25*o,50*o,100*o]),[[o,jn,In,In,In,In,In,In,1],[28*a,"{MMM}",Tn,In,In,In,In,In,1],[a,Mn,Tn,In,In,In,In,In,1],[n,"{h}"+_n,Nn,In,Ln,In,In,In,1],[s,En,Nn,In,Ln,In,In,In,1],[t,Dn,Nn+" "+En,In,Ln+" "+En,In,Pn,In,1],[e,Dn+".{fff}",Nn+" "+En,In,Ln+" "+En,In,Pn,In,1]],function(t){return(i,l,c,u,d,h)=>{let m=[],f=d>=o,g=d>=r&&d=a?a:d,o=x+(xs(c)-xs(b))+Ws(b-x,r);m.push(o);let f=t(o),g=f.getHours()+f.getMinutes()/s+f.getSeconds()/n,p=d/n,y=h/i.axes[l]._space;for(;o=Us(o+d,1==e?0:3),!(o>u);)if(p>1){let e=xs(Us(g+p,6))%24,s=t(o).getHours()-e;s>1&&(s=-1),o-=s*n,g=(g+p)%24,Us((o-m[m.length-1])/d,3)*y>=.7&&m.push(o)}else m.push(o)}return m}}]}const[An,Rn,zn]=Fn(1),[Bn,On,$n]=Fn(.001);function Wn(e,t){return e.map(e=>e.map((s,n)=>0==n||8==n||null==s?s:t(1==n||0==e[8]?s:e[1]+s)))}function Hn(e,t){return(s,n,a,r,o)=>{let i,l,c,u,d,h,m=t.find(e=>o>=e[0])||t[t.length-1];return n.map(t=>{let s=e(t),n=s.getFullYear(),a=s.getMonth(),r=s.getDate(),o=s.getHours(),f=s.getMinutes(),g=s.getSeconds(),p=n!=i&&m[2]||a!=l&&m[3]||r!=c&&m[4]||o!=u&&m[5]||f!=d&&m[6]||g!=h&&m[7]||m[1];return i=n,l=a,c=r,u=o,d=f,h=g,p(s)})}}function Un(e,t,s){return new Date(e,t,s)}function qn(e,t){return t(e)}function Gn(e,t){return(s,n,a,r)=>null==r?Pt:t(e(n))}Js(2,-53,53,[1]);const Jn={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,t){let s=e.series[t];return s.width?s.stroke(e,t):s.points.width?s.points.stroke(e,t):null},fill:function(e,t){return e.series[t].fill(e,t)},dash:"solid"},idx:null,idxs:null,values:[]},Yn=[0,0];function Vn(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function Kn(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const Xn={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return Yn[0]=t,Yn[1]=s,Yn},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=Ht(),a=s.size(e,t);$t(n,pt,a),$t(n,bt,a);let r=a/-2;$t(n,"marginLeft",r),$t(n,"marginTop",r);let o=s.width(e,t,a);return o&&$t(n,"borderWidth",o),n},size:function(e,t){return e.series[t].points.size},width:0,stroke:function(e,t){let s=e.series[t].points;return s._stroke||s._fill},fill:function(e,t){let s=e.series[t].points;return s._fill||s._stroke}},bind:{mousedown:Vn,mouseup:Vn,click:Vn,dblclick:Vn,mousemove:Kn,mouseleave:Kn,mouseenter:Kn},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,s,n,a)=>n-a,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Qn={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Zn=rn({},Qn,{filter:Fs}),ea=rn({},Zn,{size:10}),ta=rn({},Qn,{show:!1}),sa='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',na="bold "+sa,aa={show:!0,scale:"x",stroke:kt,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:na,side:2,grid:Zn,ticks:ea,border:ta,font:sa,lineGap:1.5,rotate:0},ra={show:!0,scale:"x",auto:!1,sorted:1,min:Ns,max:-Ns,idxs:[]};function oa(e,t,s,n,a){return t.map(e=>null==e?"":gs(e))}function ia(e,t,s,n,a,r,o){let i=[],l=qs.get(a)||0;for(let c=s=o?s:Us(Ws(s,a),l);c<=n;c=Us(c+a,l))i.push(Object.is(c,-0)?0:c);return i}function la(e,t,s,n,a,r,o){const i=[],l=e.scales[e.axes[t].scale].log,c=xs((10==l?Ts:Ms)(s));a=Cs(l,c),10==l&&(a=Cn[es(a,Cn)]);let u=s,d=a*l;10==l&&(d=Cn[es(d,Cn)]);do{i.push(u),u+=a,10!=l||qs.has(u)||(u=Us(u,qs.get(a))),u>=d&&(d=(a=u)*l,10==l&&(d=Cn[es(d,Cn)]))}while(u<=n);return i}function ca(e,t,s,n,a,r,o){let i=e.scales[e.axes[t].scale].asinh,l=n>i?la(e,t,Ss(i,s),n,a):[i],c=n>=0&&s<=0?[0]:[];return(s<-i?la(e,t,Ss(i,-n),-s,a):[i]).reverse().map(e=>-e).concat(c,l)}const ua=/./,da=/[12357]/,ha=/[125]/,ma=/1/,fa=(e,t,s,n)=>e.map((e,a)=>4==t&&0==e||a%n==0&&s.test(e.toExponential()[e<0?1:0])?e:null);function ga(e,t,s,n,a){let r=e.axes[s],o=r.scale,i=e.scales[o],l=e.valToPos,c=r._space,u=l(10,o),d=l(9,o)-u>=c?ua:l(7,o)-u>=c?da:l(5,o)-u>=c?ha:ma;if(d==ma){let e=ys(l(1,o)-u);if(ea,va={show:!0,auto:!0,sorted:0,gaps:wa,alpha:1,facets:[rn({},xa,{scale:"x"}),rn({},xa,{scale:"y"})]},ka={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:wa,alpha:1,points:{show:function(e,t){let{scale:s,idxs:n}=e.series[0],a=e._data[0],r=e.valToPos(a[n[0]],s,!0),o=e.valToPos(a[n[1]],s,!0),i=ys(o-r)/(e.series[t].points.space*Rt);return n[1]-n[0]<=i},filter:null},values:null,min:Ns,max:-Ns,idxs:[],path:null,clip:null};function Sa(e,t,s,n,a){return s/10}const Ca={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},ja=rn({},Ca,{time:!1,ori:1}),Ta={};function Ma(e,t){let s=Ta[e];return s||(s={key:e,plots:[],sub(e){s.plots.push(e)},unsub(e){s.plots=s.plots.filter(t=>t!=e)},pub(e,t,n,a,r,o,i){for(let l=0;l{let g=e.pxRound;const p=i.dir*(0==i.ori?1:-1),b=0==i.ori?za:Ba;let y,x;1==p?(y=s,x=n):(y=n,x=s);let w=g(c(t[y],i,m,d)),v=g(u(o[y],l,f,h)),k=g(c(t[x],i,m,d)),S=g(u(1==r?l.max:l.min,l,f,h)),C=new Path2D(a);return b(C,k,S),b(C,w,S),b(C,w,v),C})}function Pa(e,t,s,n,a,r){let o=null;if(e.length>0){o=new Path2D;const i=0==t?Oa:$a;let l=s;for(let t=0;ts[0]){let e=s[0]-l;e>0&&i(o,l,n,e,n+r),l=s[1]}}let c=s+a-l,u=10;c>0&&i(o,l,n-u/2,c,n+r+u)}return o}function Da(e,t,s,n,a,r,o){let i=[],l=e.length;for(let c=1==a?s:n;c>=s&&c<=n;c+=a)if(null===t[c]){let u=c,d=c;if(1==a)for(;++c<=n&&null===t[c];)d=c;else for(;--c>=s&&null===t[c];)d=c;let h=r(e[u]),m=d==u?h:r(e[d]),f=u-a;h=o<=0&&f>=0&&f=0&&g>=0&&g=h&&i.push([h,m])}return i}function Ia(e){return 0==e?Is:1==e?ws:t=>$s(t,e)}function Fa(e){let t=0==e?Aa:Ra,s=0==e?(e,t,s,n,a,r)=>{e.arcTo(t,s,n,a,r)}:(e,t,s,n,a,r)=>{e.arcTo(s,t,a,n,r)},n=0==e?(e,t,s,n,a)=>{e.rect(t,s,n,a)}:(e,t,s,n,a)=>{e.rect(s,t,a,n)};return(e,a,r,o,i,l=0,c=0)=>{0==l&&0==c?n(e,a,r,o,i):(l=ks(l,o/2,i/2),c=ks(c,o/2,i/2),t(e,a+l,r),s(e,a+o,r,a+o,r+i,l),s(e,a+o,r+i,a,r+i,c),s(e,a,r+i,a,r,c),s(e,a,r,a+o,r,l),e.closePath())}}const Aa=(e,t,s)=>{e.moveTo(t,s)},Ra=(e,t,s)=>{e.moveTo(s,t)},za=(e,t,s)=>{e.lineTo(t,s)},Ba=(e,t,s)=>{e.lineTo(s,t)},Oa=Fa(0),$a=Fa(1),Wa=(e,t,s,n,a,r)=>{e.arc(t,s,n,a,r)},Ha=(e,t,s,n,a,r)=>{e.arc(s,t,n,a,r)},Ua=(e,t,s,n,a,r,o)=>{e.bezierCurveTo(t,s,n,a,r,o)},qa=(e,t,s,n,a,r,o)=>{e.bezierCurveTo(s,t,a,n,o,r)};function Ga(e){return(e,t,s,n,a)=>La(e,t,(t,r,o,i,l,c,u,d,h,m,f)=>{let g,p,{pxRound:b,points:y}=t;0==i.ori?(g=Aa,p=Wa):(g=Ra,p=Ha);const x=Us(y.width*Rt,3);let w=(y.size-y.width)/2*Rt,v=Us(2*w,3),k=new Path2D,S=new Path2D,{left:C,top:j,width:T,height:M}=e.bbox;Oa(S,C-v,j-v,T+2*v,M+2*v);const L=e=>{if(null!=o[e]){let t=b(c(r[e],i,m,d)),s=b(u(o[e],l,f,h));g(k,t+w,s),p(k,t,s,w,0,2*bs)}};if(a)a.forEach(L);else for(let e=s;e<=n;e++)L(e);return{stroke:x>0?k:null,fill:k,clip:S,flags:3}})}function Ja(e){return(t,s,n,a,r,o)=>{n!=a&&(r!=n&&o!=n&&e(t,s,n),r!=a&&o!=a&&e(t,s,a),e(t,s,o))}}const Ya=Ja(za),Va=Ja(Ba);function Ka(e){const t=hs(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>La(e,s,(r,o,i,l,c,u,d,h,m,f,g)=>{[n,a]=as(i,n,a);let p,b,y=r.pxRound,x=e=>y(u(e,l,f,h)),w=e=>y(d(e,c,g,m));0==l.ori?(p=za,b=Ya):(p=Ba,b=Va);const v=l.dir*(0==l.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=k.stroke;let C=!1;if(a-n>=4*f){let t,s,r,c=t=>e.posToVal(t,l.key,!0),u=null,d=null,h=x(o[1==v?n:a]),m=x(o[n]),f=x(o[a]),g=c(1==v?m+1:f-1);for(let e=1==v?n:a;e>=n&&e<=a;e+=v){let n=o[e],a=(1==v?ng)?h:x(n),r=i[e];a==h?null!=r?(s=r,null==u?(p(S,a,w(s)),t=u=d=s):sd&&(d=s)):null===r&&(C=!0):(null!=u&&b(S,h,w(u),w(d),w(t),w(s)),null!=r?(s=r,p(S,a,w(s)),u=d=t=s):(u=d=null,null===r&&(C=!0)),h=a,g=c(h+v))}null!=u&&u!=d&&r!=h&&b(S,h,w(u),w(d),w(t),w(s))}else for(let e=1==v?n:a;e>=n&&e<=a;e+=v){let t=i[e];null===t?C=!0:null!=t&&p(S,x(o[e]),w(t))}let[j,T]=Na(e,s);if(null!=r.fill||0!=j){let t=k.fill=new Path2D(S),i=w(r.fillTo(e,s,r.min,r.max,j)),l=x(o[n]),c=x(o[a]);-1==v&&([c,l]=[l,c]),p(t,c,i),p(t,l,i)}if(!r.spanGaps){let c=[];C&&c.push(...Da(o,i,n,a,v,x,t)),k.gaps=c=r.gaps(e,s,n,a,c),k.clip=Pa(c,l.ori,h,m,f,g)}return 0!=T&&(k.band=2==T?[Ea(e,s,n,a,S,-1),Ea(e,s,n,a,S,1)]:Ea(e,s,n,a,S,T)),k})}function Xa(e,t,s,n,a,r,o=Ns){if(e.length>1){let i=null;for(let l=0,c=1/0;l0!=n[e]>0?s[e]=0:(s[e]=3*(l[e-1]+l[e])/((2*l[e]+l[e-1])/n[e-1]+(l[e]+2*l[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[o-1]=n[o-2];for(let c=0;c{fr.pxRatio=Rt}));const tr=Ka(),sr=Ga();function nr(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>ar(e,n,t,s))}function ar(e,t,s,n){return rn({},0==t?s:n,e)}function rr(e,t,s){return null==t?Ks:[t,s]}const or=rr;function ir(e,t,s){return null==t?Ks:ds(t,s,.1,!0)}function lr(e,t,s,n){return null==t?Ks:os(t,s,e.scales[n].log,!1)}const cr=lr;function ur(e,t,s,n){return null==t?Ks:is(t,s,e.scales[n].log,!1)}const dr=ur;function hr(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=ws((s=+n)*Rt))+"px"),t,s]}function mr(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Us(e[2]*Rt,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function fr(e,t,s){const n={mode:hs(e.mode,1)},a=n.mode;function r(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?1-a:a)}function o(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?a:1-a)}function i(e,t,s,n){return 0==t.ori?r(e,t,s,n):o(e,t,s,n)}n.valToPosH=r,n.valToPosV=o;let l=!1;n.status=0;const c=n.root=Ht("uplot");null!=e.id&&(c.id=e.id),Bt(c,e.class),e.title&&(Ht("u-title",c).textContent=e.title);const u=Wt("canvas"),d=n.ctx=u.getContext("2d"),h=Ht("u-wrap",c);Qt("click",h,e=>{e.target===f&&(xs!=us||js!=ms)&&sn.click(n,e)},!0);const m=n.under=Ht("u-under",h);h.appendChild(u);const f=n.over=Ht("u-over",h),g=+hs((e=an(e)).pxAlign,1),p=Ia(g);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const b=e.ms||.001,y=n.series=1==a?nr(e.series||[],ra,ka,!1):(x=e.series||[null],w=va,x.map((e,t)=>0==t?{}:rn({},w,e)));var x,w;const v=n.axes=nr(e.axes||[],aa,ya,!0),k=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=Ds(e.fill||null),e.dir=hs(e.dir,-1)});const C=2==a?y[1].facets[0].scale:y[0].scale,j={axes:function(){for(let e=0;est[e]):b,x=2==m.distr?st[b[1]]-st[b[0]]:u,w=t.ticks,S=t.border,C=w.show?w.size:0,j=ws(C*Rt),T=ws((2==t.alignTo?t._size-C-t.gap:t.gap)*Rt),M=t._rotate*-bs/180,L=p(t._pos*Rt),N=L+(j+T)*c;a=0==o?N:0,s=1==o?N:0,it(t.font[0],l,1==t.align?wt:2==t.align?vt:M>0?wt:M<0?vt:0==o?"center":3==r?vt:wt,M||1==o?"middle":2==r?yt:xt);let _=t.font[1]*t.lineGap,E=b.map(e=>p(i(e,m,f,g))),P=t._values;for(let e=0;e0){let e=y.some(e=>e._focus)&&tt!=_e.alpha;e&&(d.globalAlpha=tt=_e.alpha),y.forEach((e,s)=>{if(s>0&&e.show&&(ut(s,!1),ut(s,!0),null==e._paths)){let r=tt;tt!=e.alpha&&(d.globalAlpha=tt=e.alpha);let o=2==a?[0,t[s][0].length-1]:function(e){let t=Es(He-1,0,We-1),s=Es(Ue+1,0,We-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=tt;tt!=e.alpha&&(d.globalAlpha=tt=e.alpha),null!=e._paths&&dt(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,He,Ue,s),r=e.points.filter(n,t,a,s);(a||r)&&(e.points._paths=e.points.paths(n,t,He,Ue,r),dt(t,!0))}tt!=s&&(d.globalAlpha=tt=s),na("drawSeries",t)}}),e&&(d.globalAlpha=tt=1)}}},T=(e.drawOrder||["axes","series"]).map(e=>j[e]);function M(e){const t=3==e.distr?t=>Ts(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>Ls(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return s=>{let n=t(s),{_min:a,_max:r}=e;return(n-a)/(r-a)}}function L(t){let s=k[t];if(null==s){let n=(e.scales||Ys)[t]||Ys;if(null!=n.from){L(n.from);let e=rn({},k[n.from],n,{key:t});e.valToPct=M(e),k[t]=e}else{s=k[t]=rn({},t==C?Ca:ja,n),s.key=t;let e=s.time,r=s.range,o=Xs(r);if((t!=C||2==a&&!e)&&(!o||null!=r[0]&&null!=r[1]||(r={min:null==r[0]?ls:{mode:1,hard:r[0],soft:r[0]},max:null==r[1]?ls:{mode:1,hard:r[1],soft:r[1]}},o=!1),!o&&en(r))){let e=r;r=(t,s,n)=>null==s?Ks:ds(s,n,e)}s.range=Ds(r||(e?or:t==C?3==s.distr?cr:4==s.distr?dr:rr:3==s.distr?lr:4==s.distr?ur:ir)),s.auto=Ds(!o&&s.auto),s.clamp=Ds(s.clamp||Sa),s._min=s._max=null,s.valToPct=M(s)}}}L("x"),L("y"),1==a&&y.forEach(e=>{L(e.scale)}),v.forEach(e=>{L(e.scale)});for(let ft in e.scales)L(ft);const N=k[C],_=N.distr;let E,P;0==N.ori?(Bt(c,"u-hz"),E=r,P=o):(Bt(c,"u-vt"),E=o,P=r);const D={};for(let ft in k){let e=k[ft];null==e.min&&null==e.max||(D[ft]={min:e.min,max:e.max},e.min=e.max=null)}const I=e.tzDate||(e=>new Date(ws(e/b))),F=e.fmtDate||bn,A=1==b?zn(I):$n(I),R=Hn(I,Wn(1==b?Rn:On,F)),z=Gn(I,qn("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",F)),B=[],O=n.legend=rn({},Jn,e.legend),$=n.cursor=rn({},Xn,{drag:{y:2==a}},e.cursor),W=O.show,H=$.show,U=O.markers;let q,G,J;O.idxs=B,U.width=Ds(U.width),U.dash=Ds(U.dash),U.stroke=Ds(U.stroke),U.fill=Ds(U.fill);let Y,V=[],K=[],X=!1,Q={};if(O.live){const e=y[1]?y[1].values:null;X=null!=e,Y=X?e(n,1,0):{_:0};for(let t in Y)Q[t]=Pt}if(W)if(q=Wt("table","u-legend",c),J=Wt("tbody",null,q),O.mount(n,q),X){G=Wt("thead",null,q,J);let e=Wt("tr",null,G);for(var Z in Wt("th",null,e),Y)Wt("th",gt,e).textContent=Z}else Bt(q,"u-inline"),O.live&&Bt(q,"u-live");const ee={show:!0},te={show:!1},se=new Map;function ne(e,t,s,a=!0){const r=se.get(t)||{},o=$.bind[e](n,t,s,a);o&&(Qt(e,t,r[e]=o),se.set(t,r))}function ae(e,t,s){const n=se.get(t)||{};for(let a in n)null!=e&&a!=e||(Zt(a,t,n[a]),delete n[a]);null==e&&se.delete(t)}let re=0,oe=0,ie=0,le=0,ce=0,ue=0,de=ce,he=ue,me=ie,fe=le,ge=0,pe=0,be=0,ye=0;n.bbox={};let xe=!1,we=!1,ve=!1,ke=!1,Se=!1,Ce=!1;function je(e,t,s){(s||e!=n.width||t!=n.height)&&Te(e,t),Ut(!1),ve=!0,we=!0,Ws()}function Te(e,t){n.width=re=ie=e,n.height=oe=le=t,ce=ue=0,function(){let e=!1,t=!1,s=!1,n=!1;v.forEach((a,r)=>{if(a.show&&a._show){let{side:r,_size:o}=a,i=r%2,l=o+(null!=a.label?a.labelSize:0);l>0&&(i?(ie-=l,3==r?(ce+=l,n=!0):s=!0):(le-=l,0==r?(ue+=l,e=!0):t=!0))}}),ze[0]=e,ze[1]=s,ze[2]=t,ze[3]=n,ie-=$e[1]+$e[3],ce+=$e[3],le-=$e[2]+$e[0],ue+=$e[0]}(),function(){let e=ce+ie,t=ue+le,s=ce,n=ue;function a(a,r){switch(a){case 1:return e+=r,e-r;case 2:return t+=r,t-r;case 3:return s-=r,s+r;case 0:return n-=r,n+r}}v.forEach((e,t)=>{if(e.show&&e._show){let t=e.side;e._pos=a(t,e._size),null!=e.label&&(e._lpos=a(t,e.labelSize))}})}();let s=n.bbox;ge=s.left=$s(ce*Rt,.5),pe=s.top=$s(ue*Rt,.5),be=s.width=$s(ie*Rt,.5),ye=s.height=$s(le*Rt,.5)}const Me=3;if(n.setSize=function({width:e,height:t}){je(e,t)},null==$.dataIdx){let e=$.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=Ds(e.prox),a=e.bias??(e.bias=0);$.dataIdx=(e,r,o,i)=>{if(0==r)return o;let l=o,c=n(e,r,o,i)??Ns,u=c>=0&&c0;)s.has(f[e])||(t=e);if(0==a||1==a)for(e=o;null==n&&e++c&&(l=null);return l}}const Le=e=>{$.event=e};$.idxs=B,$._lock=!1;let Ne=$.points;Ne.show=Ds(Ne.show),Ne.size=Ds(Ne.size),Ne.stroke=Ds(Ne.stroke),Ne.width=Ds(Ne.width),Ne.fill=Ds(Ne.fill);const _e=n.focus=rn({},e.focus||{alpha:.3},$.focus),Ee=_e.prox>=0,Pe=Ee&&Ne.one;let De=[],Ie=[],Fe=[];function Ae(e,t){let s=Ne.show(n,t);if(s instanceof HTMLElement)return Bt(s,"u-cursor-pt"),Bt(s,e.class),qt(s,-10,-10,ie,le),f.insertBefore(s,De[t]),s}function Re(e,t){if(1==a||t>0){let t=1==a&&k[e.scale].time,s=e.value;e.value=t?Zs(s)?Gn(I,qn(s,F)):s||z:s||ba,e.label=e.label||(t?"Time":"Value")}if(Pe||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||tr||As,e.fillTo=Ds(e.fillTo||_a),e.pxAlign=+hs(e.pxAlign,g),e.pxRound=Ia(e.pxAlign),e.stroke=Ds(e.stroke||null),e.fill=Ds(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=Us(1*(3+2*(Ss(1,e.width)||1)),3),s=e.points=rn({},{size:t,width:Ss(1,.2*t),stroke:e.stroke,space:2*t,paths:sr,_stroke:null,_fill:null},e.points);s.show=Ds(s.show),s.filter=Ds(s.filter),s.fill=Ds(s.fill),s.stroke=Ds(s.stroke),s.paths=Ds(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(X||!O.live||2==a))return Ks;let s=[],r=Wt("tr","u-series",J,J.childNodes[t]);Bt(r,e.class),e.show||Bt(r,ft);let o=Wt("th",null,r);if(U.show){let e=Ht("u-marker",o);if(t>0){let s=U.width(n,t);s&&(e.style.border=s+"px "+U.dash(n,t)+" "+U.stroke(n,t)),e.style.background=U.fill(n,t)}}let i=Ht(gt,o);for(var l in e.label instanceof HTMLElement?i.appendChild(e.label):i.textContent=e.label,t>0&&(U.show||(i.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),ne("click",o,t=>{if($._lock)return;Le(t);let s=y.indexOf(e);if((t.ctrlKey||t.metaKey)!=O.isolate){let e=y.some((e,t)=>t>0&&t!=s&&e.show);y.forEach((t,n)=>{n>0&&mn(n,e?n==s?ee:te:ee,!0,da.setSeries)})}else mn(s,{show:!e.show},!0,da.setSeries)},!1),Ee&&ne(Mt,o,t=>{$._lock||(Le(t),mn(y.indexOf(e),yn,!0,da.setSeries))},!1)),Y){let e=Wt("td","u-value",r);e.textContent="--",s.push(e)}return[r,s]}(e,t);V.splice(t,0,s[0]),K.splice(t,0,s[1]),O.values.push(null)}if(H){B.splice(t,0,null);let s=null;Pe?0==t&&(s=Ae(e,t)):t>0&&(s=Ae(e,t)),De.splice(t,0,s),Ie.splice(t,0,0),Fe.splice(t,0,0)}na("addSeries",t)}n.addSeries=function(e,t){t=null==t?y.length:t,e=1==a?ar(e,t,ra,ka):ar(e,t,{},va),y.splice(t,0,e),Re(y[t],t)},n.delSeries=function(e){if(y.splice(e,1),W){O.values.splice(e,1),K.splice(e,1);let t=V.splice(e,1)[0];ae(null,t.firstChild),t.remove()}H&&(B.splice(e,1),De.splice(e,1)[0].remove(),Ie.splice(e,1),Fe.splice(e,1)),na("delSeries",e)};const ze=[!1,!1,!1,!1];function Be(e,t,s,n){let[a,r,o,i]=s,l=t%2,c=0;return 0==l&&(i||r)&&(c=0==t&&!a||2==t&&!o?ws(aa.size/3):0),1==l&&(a||o)&&(c=1==t&&!r||3==t&&!i?ws(ya.size/2):0),c}const Oe=n.padding=(e.padding||[Be,Be,Be,Be]).map(e=>Ds(hs(e,Be))),$e=n._padding=Oe.map((e,t)=>e(n,t,ze,0));let We,He=null,Ue=null;const qe=1==a?y[0].idxs:null;let Ge,Je,Ye,Ve,Ke,Xe,Qe,Ze,et,tt,st=null,nt=!1;function at(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){We=0;for(let e=1;e=0,Ce=!0,Ws()}}function rt(){let e,s;nt=!0,1==a&&(We>0?(He=qe[0]=0,Ue=qe[1]=We-1,e=t[0][He],s=t[0][Ue],2==_?(e=He,s=Ue):e==s&&(3==_?[e,s]=os(e,e,N.log,!1):4==_?[e,s]=is(e,e,N.log,!1):N.time?s=e+ws(86400/b):[e,s]=ds(e,s,.1,!0))):(He=qe[0]=e=null,Ue=qe[1]=s=null)),hn(C,e,s)}function ot(e,t,s,n,a,r){e??(e=St),s??(s=Vs),n??(n="butt"),a??(a=St),r??(r="round"),e!=Ge&&(d.strokeStyle=Ge=e),a!=Je&&(d.fillStyle=Je=a),t!=Ye&&(d.lineWidth=Ye=t),r!=Ke&&(d.lineJoin=Ke=r),n!=Xe&&(d.lineCap=Xe=n),s!=Ve&&d.setLineDash(Ve=s)}function it(e,t,s,n){t!=Je&&(d.fillStyle=Je=t),e!=Qe&&(d.font=Qe=e),s!=Ze&&(d.textAlign=Ze=s),n!=et&&(d.textBaseline=et=n)}function lt(e,t,s,a,r=0){if(a.length>0&&e.auto(n,nt)&&(null==t||null==t.min)){let t=hs(He,0),n=hs(Ue,a.length-1),o=null==s.min?function(e,t,s,n=0,a=!1){let r=a?rs:as,o=a?ns:ss;[t,s]=r(e,t,s);let i=e[t],l=e[t];if(t>-1)if(1==n)i=e[t],l=e[s];else if(-1==n)i=e[s],l=e[t];else for(let c=t;c<=s;c++){let t=e[c];o(t)&&(tl&&(l=t))}return[i??Ns,l??-Ns]}(a,t,n,r,3==e.distr):[s.min,s.max];e.min=ks(e.min,s.min=o[0]),e.max=Ss(e.max,s.max=o[1])}}n.setData=at;const ct={min:null,max:null};function ut(e,t){let s=t?y[e].points:y[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function dt(e,s){let a=s?y[e].points:y[e],{stroke:r,fill:o,clip:i,flags:l,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=Us(h*Rt,3);let m=null,f=h%2/2;s&&null==u&&(u=h>0?"#fff":c);let g=1==a.pxAlign&&f>0;if(g&&d.translate(f,f),!s){let e=ge-h/2,t=pe-h/2,s=be+h,n=ye+h;m=new Path2D,m.rect(e,t,s,n)}s?mt(c,h,a.dash,a.cap,u,r,o,l,i):function(e,s,a,r,o,i,l,c,u,d,h){let m=!1;0!=u&&S.forEach((f,g)=>{if(f.series[0]==e){let e,p=y[f.series[1]],b=t[f.series[1]],x=(p._paths||Ys).band;Xs(x)&&(x=1==f.dir?x[0]:x[1]);let w=null;p.show&&x&&function(e,t,s){for(t=hs(t,0),s=hs(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(b,He,Ue)?(w=f.fill(n,g)||i,e=p._paths.clip):x=null,mt(s,a,r,o,w,l,c,u,d,h,e,x),m=!0}}),m||mt(s,a,r,o,i,l,c,u,d,h)}(e,c,h,a.dash,a.cap,u,r,o,l,m,i),g&&d.translate(-f,-f)}const ht=3;function mt(e,t,s,n,a,r,o,i,l,c,u,h){ot(e,t,s,n,a),(l||c||h)&&(d.save(),l&&d.clip(l),c&&d.clip(c)),h?(i&ht)==ht?(d.clip(h),u&&d.clip(u),_t(a,o),kt(e,r,t)):2&i?(_t(a,o),d.clip(h),kt(e,r,t)):1&i&&(d.save(),d.clip(h),u&&d.clip(u),_t(a,o),d.restore(),kt(e,r,t)):(_t(a,o),kt(e,r,t)),(l||c||h)&&d.restore()}function kt(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=Ge=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function _t(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=Je=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function Dt(e,t,s,n,a,r,o,i,l,c){let u=o%2/2;1==g&&d.translate(u,u),ot(i,o,l,c,i),d.beginPath();let h,m,f,p,b=a+(0==n||3==n?-r:r);0==s?(m=a,p=b):(h=a,f=b);for(let g=0;g{if(!s.show)return;let r=k[s.scale];if(null==r.min)return void(s._show&&(t=!1,s._show=!1,Ut(!1)));s._show||(t=!1,s._show=!0,Ut(!1));let o=s.side,i=o%2,{min:l,max:c}=r,[u,d]=function(e,t,s,a){let r,o=v[e];if(a<=0)r=[0,0];else{let i=o._space=o.space(n,e,t,s,a);r=function(e,t,s,n,a){let r=Ss(_s(e),_s(t)),o=t-e,i=es(a/n*o,s);do{let e=s[i],t=n*e/o;if(t>=a&&r+(e<5?qs.get(e):0)<=17)return[e,t]}while(++ist[e]):m,g=2==r.distr?st[m[1]]-st[m[0]]:u,p=s._values=s.values(n,s.filter(n,f,a,d,g),a,d,g);s._rotate=2==o?s.rotate(n,p,a,d):0;let b=s._size;s._size=vs(s.size(n,p,a,e)),null!=b&&s._size!=b&&(t=!1)}),t}function zt(e){let t=!0;return Oe.forEach((s,a)=>{let r=s(n,a,ze,e);r!=$e[a]&&(t=!1),$e[a]=r}),t}function Ut(e){y.forEach((t,s)=>{s>0&&(t._paths=null,e&&(1==a?(t.min=null,t.max=null):t.facets.forEach(e=>{e.min=null,e.max=null})))})}let Gt,Yt,Kt,Xt,ts,cs,us,ms,fs,gs,xs,js,Ms=!1,Is=!1,Bs=[];function Os(){Is=!1;for(let e=0;e0){y.forEach((s,r)=>{if(1==a){let a=s.scale,o=D[a];if(null==o)return;let i=e[a];if(0==r){let e=i.range(n,i.min,i.max,a);i.min=e[0],i.max=e[1],He=es(i.min,t[0]),Ue=es(i.max,t[0]),Ue-He>1&&(t[0][He]i.max&&Ue--),s.min=st[He],s.max=st[Ue]}else s.show&&s.auto&<(i,o,s,t[r],s.sorted);s.idxs[0]=He,s.idxs[1]=Ue}else if(r>0&&s.show&&s.auto){let[n,a]=s.facets,o=n.scale,i=a.scale,[l,c]=t[r],u=e[o],d=e[i];null!=u&<(u,D[o],n,l,n.sorted),null!=d&<(d,D[i],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=D[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==Ns?null:s.min,s.max==-Ns?null:s.max,t);s.min=e[0],s.max=e[1]}}}for(let t in e){let s=e[t];if(null!=s.from){let a=e[s.from];if(null==a.min)s.min=s.max=null;else{let e=s.range(n,a.min,a.max,t);s.min=e[0],s.max=e[1]}}}let s={},r=!1;for(let t in e){let n=e[t],a=k[t];if(a.min!=n.min||a.max!=n.max){a.min=n.min,a.max=n.max;let e=a.distr;a._min=3==e?Ts(a.min):4==e?Ls(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?Ts(a.max):4==e?Ls(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=r=!0}}if(r){y.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)ve=!0,na("setScale",e);H&&$.left>=0&&(ke=Ce=!0)}for(let t in D)D[t]=null}(),xe=!1),ve&&(function(){let e=!1,t=0;for(;!e;){t++;let s=At(t),a=zt(t);e=t==Me||s&&a,e||(Te(n.width,n.height),we=!0)}}(),ve=!1),we){if($t(m,wt,ce),$t(m,yt,ue),$t(m,pt,ie),$t(m,bt,le),$t(f,wt,ce),$t(f,yt,ue),$t(f,pt,ie),$t(f,bt,le),$t(h,pt,re),$t(h,bt,oe),u.width=ws(re*Rt),u.height=ws(oe*Rt),v.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;$t(e,t?"left":"top",n-(3===a||0===a?s:0)),$t(e,t?"width":"height",s),$t(e,t?"top":"left",t?ue:ce),$t(e,t?"height":"width",t?le:ie),Ot(e,ft)}else Bt(e,ft)}),Ge=Je=Ye=Ke=Xe=Qe=Ze=et=Ve=null,tt=1,_n(!0),ce!=de||ue!=he||ie!=me||le!=fe){Ut(!1);let e=ie/me,t=le/fe;if(H&&!ke&&$.left>=0){$.left*=e,$.top*=t,Kt&&qt(Kt,ws($.left),0,ie,le),Xt&&qt(Xt,0,ws($.top),ie,le);for(let s=0;s=0&&cn.width>0){cn.left*=e,cn.width*=e,cn.top*=t,cn.height*=t;for(let e in Dn)$t(un,e,cn[e])}de=ce,he=ue,me=ie,fe=le}na("setSize"),we=!1}re>0&&oe>0&&(d.clearRect(0,0,u.width,u.height),na("drawClear"),T.forEach(e=>e()),na("draw")),cn.show&&Se&&(dn(cn),Se=!1),H&&ke&&(Ln(null,!0,!1),ke=!1),O.show&&O.live&&Ce&&(Tn(),Ce=!1),l||(l=!0,n.status=1,na("ready")),nt=!1,Ms=!1}function Js(e,s){let a=k[e];if(null==a.from){if(0==We){let t=a.range(n,s.min,s.max,e);s.min=t[0],s.max=t[1]}if(s.min>s.max){let e=s.min;s.min=s.max,s.max=e}if(We>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==C&&2==a.distr&&We>0&&(s.min=es(s.min,t[0]),s.max=es(s.max,t[0]),s.min==s.max&&s.max++),D[e]=s,xe=!0,Ws()}}n.batch=function(e,t=!1){Ms=!0,Is=t,e(n),Hs(),t&&Bs.length>0&&queueMicrotask(Os)},n.redraw=(e,t)=>{ve=t||!1,!1!==e?hn(C,N.min,N.max):Ws()},n.setScale=Js;let Qs=!1;const sn=$.drag;let nn=sn.x,on=sn.y;H&&($.x&&(Gt=Ht("u-cursor-x",f)),$.y&&(Yt=Ht("u-cursor-y",f)),0==N.ori?(Kt=Gt,Xt=Yt):(Kt=Yt,Xt=Gt),xs=$.left,js=$.top);const cn=n.select=rn({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),un=cn.show?Ht("u-select",cn.over?f:m):null;function dn(e,t){if(cn.show){for(let t in e)cn[t]=e[t],t in Dn&&$t(un,t,e[t]);!1!==t&&na("setSelect")}}function hn(e,t,s){Js(e,{min:t,max:s})}function mn(e,t,s,r){null!=t.focus&&function(e){if(e!=pn){let t=null==e,s=1!=_e.alpha;y.forEach((n,r)=>{if(1==a||r>0){let a=t||0==r||r==e;n._focus=t?null:a,s&&function(e,t){y[e].alpha=t,H&&null!=De[e]&&(De[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(r,a?1:_e.alpha)}}),pn=e,s&&Ws()}}(e),null!=t.show&&y.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(y[e].show)W&&Ot(V[e],ft);else if(W&&Bt(V[e],ft),H){let t=Pe?De[0]:De[e];null!=t&&qt(t,-10,-10,ie,le)}}(n),2==a?(hn(s.facets[0].scale,null,null),hn(s.facets[1].scale,null,null)):hn(s.scale,null,null),Ws())}),!1!==s&&na("setSeries",e,t),r&&fa("setSeries",n,e,t)}let fn,gn,pn;n.setSelect=dn,n.setSeries=mn,n.addBand=function(e,t){e.fill=Ds(e.fill||null),e.dir=hs(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){rn(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const yn={focus:!0};function xn(e,t,s){let n=k[t];s&&(e=e/Rt-(1==n.ori?ue:ce));let a=ie;1==n.ori&&(a=le,e=a-e),-1==n.dir&&(e=a-e);let r=n._min,o=r+(n._max-r)*(e/a),i=n.distr;return 3==i?Cs(10,o):4==i?((e,t=1)=>ps.sinh(e)*t)(o,n.asinh):100==i?n.bwd(o):o}function wn(e,t){$t(un,wt,cn.left=e),$t(un,pt,cn.width=t)}function vn(e,t){$t(un,yt,cn.top=e),$t(un,bt,cn.height=t)}W&&Ee&&ne(Lt,q,e=>{$._lock||(Le(e),null!=pn&&mn(null,yn,!0,da.setSeries))}),n.valToIdx=e=>es(e,t[0]),n.posToIdx=function(e,s){return es(xn(e,C,s),t[0],He,Ue)},n.posToVal=xn,n.valToPos=(e,t,s)=>0==k[t].ori?r(e,k[t],s?be:ie,s?ge:0):o(e,k[t],s?ye:le,s?pe:0),n.setCursor=(e,t,s)=>{xs=e.left,js=e.top,Ln(null,t,s)};let kn=0==N.ori?wn:vn,jn=1==N.ori?wn:vn;function Tn(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{B[t]=e}):void 0!==e.idx&&B.fill(e.idx),O.idx=B[0]),W&&O.live){for(let e=0;e0||1==a&&!X)&&Mn(e,B[e]);!function(){if(W&&O.live)for(let e=2==a?1:0;eUe;fn=Ns,gn=null;let l=0==N.ori?ie:le,c=1==N.ori?ie:le;if(xs<0||0==We||i){o=$.idx=null;for(let e=0;e0&&e.show){let s=null==w?-10:w==o?r:E(1==a?t[0][w]:t[p][0][w],N,l,0),b=null==v?-10:P(v,1==a?k[e.scale]:k[e.facets[1].scale],c,0);if(Ee&&null!=v){let t=1==N.ori?xs:js,s=ys(_e.dist(n,p,w,b,t));if(s=0?1:-1;r==(v>=0?1:-1)&&(1==r?1==n?v>=a:v<=a:1==n?v<=a:v>=a)&&(fn=s,gn=p)}else fn=s,gn=p}}if(Ce||Pe){let e,t;0==N.ori?(e=s,t=b):(e=b,t=s);let a,r,o,l,c,y,x=!0,w=Ne.bbox;if(null!=w){x=!1;let e=w(n,p);o=e.left,l=e.top,a=e.width,r=e.height}else o=e,l=t,a=r=Ne.size(n,p);if(y=Ne.fill(n,p),c=Ne.stroke(n,p),Pe)p==gn&&fn<=_e.prox&&(i=o,u=l,d=a,h=r,m=x,f=y,g=c);else{let e=De[p];null!=e&&(Ie[p]=o,Fe[p]=l,Vt(e,a,r,x),Jt(e,y,c),qt(e,vs(o),vs(l),ie,le))}}}}if(Pe){let e=_e.prox;if(Ce||(null==pn?fn<=e:fn>e||gn!=pn)){let e=De[0];null!=e&&(Ie[0]=i,Fe[0]=u,Vt(e,d,h,m),Jt(e,f,g),qt(e,vs(i),vs(u),ie,le))}}}if(cn.show&&Qs)if(null!=e){let[t,s]=da.scales,[n,a]=da.match,[r,o]=e.cursor.sync.scales,i=e.cursor.drag;if(nn=i._x,on=i._y,nn||on){let i,u,d,h,m,{left:f,top:g,width:p,height:b}=e.select,y=e.scales[r].ori,x=e.posToVal,w=null!=t&&n(t,r),v=null!=s&&a(s,o);w&&nn?(0==y?(i=f,u=p):(i=g,u=b),d=k[t],h=E(x(i,r),d,l,0),m=E(x(i+u,r),d,l,0),kn(ks(h,m),ys(m-h))):kn(0,l),v&&on?(1==y?(i=f,u=p):(i=g,u=b),d=k[s],h=P(x(i,o),d,c,0),m=P(x(i+u,o),d,c,0),jn(ks(h,m),ys(m-h))):jn(0,c)}else In()}else{let e=ys(fs-ts),t=ys(gs-cs);if(1==N.ori){let s=e;e=t,t=s}nn=sn.x&&e>=sn.dist,on=sn.y&&t>=sn.dist;let s,n,a=sn.uni;null!=a?nn&&on&&(nn=e>=a,on=t>=a,nn||on||(t>e?on=!0:nn=!0)):sn.x&&sn.y&&(nn||on)&&(nn=on=!0),nn&&(0==N.ori?(s=us,n=xs):(s=ms,n=js),kn(ks(s,n),ys(n-s)),on||jn(0,c)),on&&(1==N.ori?(s=us,n=xs):(s=ms,n=js),jn(ks(s,n),ys(n-s)),nn||kn(0,l)),nn||on||(kn(0,0),jn(0,0))}if(sn._x=nn,sn._y=on,null==e){if(r){if(null!=ha){let[e,t]=da.scales;da.values[0]=null!=e?xn(0==N.ori?xs:js,e):null,da.values[1]=null!=t?xn(1==N.ori?xs:js,t):null}fa(Ct,n,xs,js,ie,le,o)}if(Ee){let e=r&&da.setSeries,t=_e.prox;null==pn?fn<=t&&mn(gn,yn,!0,e):fn>t?mn(null,yn,!0,e):gn!=pn&&mn(gn,yn,!0,e)}}Ce&&(O.idx=o,Tn()),!1!==s&&na("setCursor")}n.setLegend=Tn;let Nn=null;function _n(e=!1){e?Nn=null:(Nn=f.getBoundingClientRect(),na("syncRect",Nn))}function En(e,t,s,n,a,r,o){$._lock||Qs&&null!=e&&0==e.movementX&&0==e.movementY||(Pn(e,t,s,n,a,r,0,!1,null!=e),null!=e?Ln(null,!0,!0):Ln(t,!0,!1))}function Pn(e,t,s,a,r,o,l,c,u){if(null==Nn&&_n(!1),Le(e),null!=e)s=e.clientX-Nn.left,a=e.clientY-Nn.top;else{if(s<0||a<0)return xs=-10,void(js=-10);let[e,n]=da.scales,l=t.cursor.sync,[c,u]=l.values,[d,h]=l.scales,[m,f]=da.match,g=t.axes[0].side%2==1,p=0==N.ori?ie:le,b=1==N.ori?ie:le,y=g?o:r,x=g?r:o,w=g?a:s,v=g?s:a;if(s=null!=d?m(e,d)?i(c,k[e],p,0):-10:p*(w/y),a=null!=h?f(n,h)?i(u,k[n],b,0):-10:b*(v/x),1==N.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=Ct||((s<=1||s>=ie-1)&&(s=$s(s,ie)),(a<=1||a>=le-1)&&(a=$s(a,le))),c?(ts=s,cs=a,[us,ms]=$.move(n,s,a)):(xs=s,js=a)}Object.defineProperty(n,"rect",{get:()=>(null==Nn&&_n(!1),Nn)});const Dn={width:0,height:0,left:0,top:0};function In(){dn(Dn,!1)}let Fn,Un,Yn,Vn;function Kn(e,t,s,a,r,o,i){Qs=!0,nn=on=sn._x=sn._y=!1,Pn(e,t,s,a,r,o,0,!0,!1),null!=e&&(ne(Tt,It,Qn,!1),fa(jt,n,us,ms,ie,le,null));let{left:l,top:c,width:u,height:d}=cn;Fn=l,Un=c,Yn=u,Vn=d}function Qn(e,t,s,a,r,o,i){Qs=sn._x=sn._y=!1,Pn(e,t,s,a,r,o,0,!1,!0);let{left:l,top:c,width:u,height:d}=cn,h=u>0||d>0,m=Fn!=l||Un!=c||Yn!=u||Vn!=d;if(h&&m&&dn(cn),sn.setScale&&h&&m){let e=l,t=u,s=c,n=d;if(1==N.ori&&(e=c,t=d,s=l,n=u),nn&&hn(C,xn(e,C),xn(e+t,C)),on)for(let a in k){let e=k[a];a!=C&&null==e.from&&e.min!=Ns&&hn(a,xn(s+n,a),xn(s,a))}In()}else $.lock&&($._lock=!$._lock,Ln(t,!0,null!=e));null!=e&&(ae(Tt,It),fa(Tt,n,xs,js,ie,le,null))}function Zn(e,t,s,a,r,o,i){$._lock||(Le(e),rt(),In(),null!=e&&fa(Nt,n,xs,js,ie,le,null))}function ea(){v.forEach(mr),je(n.width,n.height,!0)}Qt(Et,Ft,ea);const ta={};ta.mousedown=Kn,ta.mousemove=En,ta.mouseup=Qn,ta.dblclick=Zn,ta.setSeries=(e,t,s,a)=>{-1!=(s=(0,da.match[2])(n,t,s))&&mn(s,a,!0,!1)},H&&(ne(jt,f,Kn),ne(Ct,f,En),ne(Mt,f,e=>{Le(e),_n(!1)}),ne(Lt,f,function(e,t,s,n,a,r,o){if($._lock)return;Le(e);let i=Qs;if(Qs){let e,t,s=!0,n=!0,a=10;0==N.ori?(e=nn,t=on):(e=on,t=nn),e&&t&&(s=xs<=a||xs>=ie-a,n=js<=a||js>=le-a),e&&s&&(xs=xs{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)sa[t]=(sa[t]||[]).concat(e.hooks[t])});const ua=(e,t,s)=>s,da=rn({key:null,setSeries:!1,filters:{pub:Rs,sub:Rs},scales:[C,y[1]?y[1].scale:null],match:[zs,zs,ua],values:[null,null]},$.sync);2==da.match.length&&da.match.push(ua),$.sync=da;const ha=da.key,ma=Ma(ha);function fa(e,t,s,n,a,r,o){da.filters.pub(e,t,s,n,a,r,o)&&ma.pub(e,t,s,n,a,r,o)}function xa(){na("init",e,t),at(t||e.data,!1),D[C]?Js(C,D[C]):rt(),Se=cn.show&&(cn.width>0||cn.height>0),ke=Ce=!0,je(e.width,e.height)}return ma.sub(n),n.pub=function(e,t,s,n,a,r,o){da.filters.sub(e,t,s,n,a,r,o)&&ta[e](null,t,s,n,a,r,o)},n.destroy=function(){ma.unsub(n),Za.delete(n),se.clear(),Zt(Et,Ft,ea),c.remove(),null==q||q.remove(),na("destroy")},y.forEach(Re),v.forEach(function(e,t){if(e._show=e.show,e.show){let s=e.side%2,a=k[e.scale];null==a&&(e.scale=s?y[1].scale:C,a=k[e.scale]);let r=a.time;e.size=Ds(e.size),e.space=Ds(e.space),e.rotate=Ds(e.rotate),Xs(e.incrs)&&e.incrs.forEach(e=>{!qs.has(e)&&qs.set(e,Gs(e))}),e.incrs=Ds(e.incrs||(2==a.distr?Sn:r?1==b?An:Bn:Cn)),e.splits=Ds(e.splits||(r&&1==a.distr?A:3==a.distr?la:4==a.distr?ca:ia)),e.stroke=Ds(e.stroke),e.grid.stroke=Ds(e.grid.stroke),e.ticks.stroke=Ds(e.ticks.stroke),e.border.stroke=Ds(e.border.stroke);let o=e.values;e.values=Xs(o)&&!Xs(o[0])?Ds(o):r?Xs(o)?Hn(I,Wn(o,F)):Zs(o)?function(e,t){let s=bn(t);return(t,n,a,r,o)=>n.map(t=>s(e(t)))}(I,o):o||R:o||oa,e.filter=Ds(e.filter||(a.distr>=3&&10==a.log?ga:3==a.distr&&2==a.log?pa:Fs)),e.font=hr(e.font),e.labelFont=hr(e.labelFont),e._size=e.size(n,null,t,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(ze[t]=!0,e._el=Ht("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),xa()):s(n,xa):xa(),n}fr.assign=rn,fr.fmtNum=gs,fr.rangeNum=ds,fr.rangeLog=os,fr.rangeAsinh=is,fr.orient=La,fr.pxRatio=Rt,fr.join=function(e,t){if(function(e){let t=e[0][0],s=t.length;for(let n=1;n=n&&null==e[a];)a--;if(a<=n)return!0;const r=Ss(1,xs((a-n+1)/t));for(let o=e[n],i=n+r;i<=a;i+=r){const t=e[i];if(null!=t){if(t<=o)return!1;o=t}}return!0}(t[0])||(t=function(e){let t=e[0],s=t.length,n=Array(s);for(let r=0;rt[e]-t[s]);let a=[];for(let r=0;re-t)],a=n[0].length,r=new Map;for(let o=0;oLa(e,r,(l,c,u,d,h,m,f,g,p,b,y)=>{[o,i]=as(u,o,i);let x=l.pxRound,{left:w,width:v}=e.bbox,k=e=>x(m(e,d,b,g)),S=e=>x(f(e,h,y,p)),C=0==d.ori?za:Ba;const j={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=j.stroke,M=d.dir*(0==d.ori?1:-1);let L=S(u[1==M?o:i]),N=k(c[1==M?o:i]),_=N,E=N;a&&-1==t&&(E=w,C(T,E,L)),C(T,N,L);for(let e=1==M?o:i;e>=o&&e<=i;e+=M){let s=u[e];if(null==s)continue;let n=k(c[e]),a=S(s);1==t?C(T,n,L):C(T,_,a),C(T,n,a),L=a,_=n}let P=_;a&&1==t&&(P=w+v,C(T,P,L));let[D,I]=Na(e,r);if(null!=l.fill||0!=D){let t=j.fill=new Path2D(T),s=S(l.fillTo(e,r,l.min,l.max,D));C(t,P,s),C(t,E,s)}if(!l.spanGaps){let a=[];a.push(...Da(c,u,o,i,M,k,n));let h=l.width*Rt/2,m=s||1==t?h:-h,f=s||-1==t?-h:h;a.forEach(e=>{e[0]+=m,e[1]+=f}),j.gaps=a=l.gaps(e,r,o,i,a),j.clip=Pa(a,d.ori,g,p,b,y)}return 0!=I&&(j.band=2==I?[Ea(e,r,o,i,T,-1),Ea(e,r,o,i,T,1)]:Ea(e,r,o,i,T,I)),j})},e.bars=function(e){const t=hs((e=e||Ys).size,[.6,Ns,1]),s=e.align||0,n=e.gap||0;let a=e.radius;a=null==a?[0,0]:"number"==typeof a?[a,0]:a;const r=Ds(a),o=1-t[0],i=hs(t[1],Ns),l=hs(t[2],1),c=hs(e.disp,Ys),u=hs(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,m)=>La(e,t,(f,g,p,b,y,x,w,v,k,S,C)=>{let j,T,M=f.pxRound,L=s,N=n*Rt,_=i*Rt,E=l*Rt;0==b.ori?[j,T]=r(e,t):[T,j]=r(e,t);const P=b.dir*(0==b.ori?1:-1);let D,I,F,A=0==b.ori?Oa:$a,R=0==b.ori?u:(e,t,s,n,a,r,o)=>{u(e,t,s,a,n,o,r)},z=hs(e.bands,Vs).find(e=>e.series[0]==t),B=null!=z?z.dir:0,O=f.fillTo(e,t,f.min,f.max,B),$=M(w(O,y,C,k)),W=S,H=M(f.width*Rt),U=!1,q=null,G=null,J=null,Y=null;null==d||0!=H&&null==h||(U=!0,q=d.values(e,t,a,m),G=new Map,new Set(q).forEach(e=>{null!=e&&G.set(e,new Path2D)}),H>0&&(J=h.values(e,t,a,m),Y=new Map,new Set(J).forEach(e=>{null!=e&&Y.set(e,new Path2D)})));let{x0:V,size:K}=c;if(null!=V&&null!=K){L=1,g=V.values(e,t,a,m),2==V.unit&&(g=g.map(t=>e.posToVal(v+t*S,b.key,!0)));let s=K.values(e,t,a,m);I=2==K.unit?s[0]*S:x(s[0],b,S,v)-x(0,b,S,v),W=Xa(g,p,x,b,S,v,W),F=W-I+N}else W=Xa(g,p,x,b,S,v,W),F=W*o+N,I=W-F;F<1&&(F=0),H>=I/2&&(H=0),F<5&&(M=Is);let X=F>0;I=M(Es(W-F-(X?H:0),E,_)),D=(0==L?I/2:L==P?0:I)-L*P*((0==L?N/2:0)+(X?H/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Z=U?null:new Path2D;let ee=null;if(null!=z)ee=e.data[z.series[1]];else{let{y0:s,y1:n}=c;null!=s&&null!=n&&(p=n.values(e,t,a,m),ee=s.values(e,t,a,m))}let te=j*I,se=T*I;for(let s=1==P?a:m;s>=a&&s<=m;s+=P){let n=p[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;$=w(e,y,C,k)}let a=x(2!=b.distr||null!=c?g[s]:s,b,S,v),r=w(hs(n,O),y,C,k),o=M(a-D),i=M(Ss(r,$)),l=M(ks(r,$)),u=i-l;if(null!=n){let a=n<0?se:te,r=n<0?te:se;U?(H>0&&null!=J[s]&&A(Y.get(J[s]),o,l+xs(H/2),I,Ss(0,u-H),a,r),null!=q[s]&&A(G.get(q[s]),o,l+xs(H/2),I,Ss(0,u-H),a,r)):A(Z,o,l+xs(H/2),I,Ss(0,u-H),a,r),R(e,t,s,o-H/2,l,I+H,u)}}return H>0?Q.stroke=U?Y:Z:U||(Q._fill=0==f.width?f._fill:f._stroke??f._fill,Q.width=0),Q.fill=U?G:Z,Q})},e.spline=function(e){return function(e,t){const s=hs(null==t?void 0:t.alignGaps,0);return(t,n,a,r)=>La(t,n,(o,i,l,c,u,d,h,m,f,g,p)=>{[a,r]=as(l,a,r);let b,y,x,w=o.pxRound,v=e=>w(d(e,c,g,m)),k=e=>w(h(e,u,p,f));0==c.ori?(b=Aa,x=za,y=Ua):(b=Ra,x=Ba,y=qa);const S=c.dir*(0==c.ori?1:-1);let C=v(i[1==S?a:r]),j=C,T=[],M=[];for(let e=1==S?a:r;e>=a&&e<=r;e+=S)if(null!=l[e]){let t=v(i[e]);T.push(j=t),M.push(k(l[e]))}const L={stroke:e(T,M,b,x,y,w),fill:null,clip:null,band:null,gaps:null,flags:1},N=L.stroke;let[_,E]=Na(t,n);if(null!=o.fill||0!=_){let e=L.fill=new Path2D(N),s=k(o.fillTo(t,n,o.min,o.max,_));x(e,j,s),x(e,C,s)}if(!o.spanGaps){let e=[];e.push(...Da(i,l,a,r,S,v,s)),L.gaps=e=o.gaps(t,n,a,r,e),L.clip=Pa(e,c.ori,m,f,g,p)}return 0!=E&&(L.band=2==E?[Ea(t,n,a,r,N,-1),Ea(t,n,a,r,N,1)]:Ea(t,n,a,r,N,E)),L})}(Qa,e)}}const gr=new Map;function pr(e){var t;if(!e.startsWith("var("))return e;const s=gr.get(e);if(s)return s;const n=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!n)return e;const a=n[1].trim(),r=(null==(t=n[2])?void 0:t.trim())||"#888888",o=getComputedStyle(document.documentElement).getPropertyValue(a).trim()||r;return gr.set(e,o),o}const br=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:r=null,cursorColor:o="rgba(255,255,255,0.5)"}){const i=s.useRef(null),l=s.useRef(null),c=s.useRef(t),u=s.useRef(r),d=s.useRef(a),h=s.useRef(e.length);s.useLayoutEffect(()=>{c.current=t,u.current=r,d.current=a});const m=s.useMemo(()=>{const t=new Array(e.length).fill(1);return[e,t]},[e]),f=s.useMemo(()=>({hooks:{draw:e=>{!function(e,t,s){if(0===t.length)return;const n=e.ctx,a=e.bbox,r=a.left,o=a.top,i=a.width,l=a.height;if(i<=0||l<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,m=e=>{const t=c[e];return r+(t-d)/h*i},f=e=>o+l*(1-e);for(let g=0;g=0;t--){const e=m(t),s=f(r[t]);if(t===u-1)n.lineTo(e,s);else{const a=m(t+1);n.lineTo(a,s),n.lineTo(e,s)}}n.closePath(),n.fill(),n.restore()}}(e,c.current,u.current),function(e){const t=e.ctx,{left:s,top:n,width:a,height:r}=e.bbox,o=window.devicePixelRatio||1,i=function(){const e=getComputedStyle(document.documentElement);return{fontFamily:e.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:e.getPropertyValue("--text-primary").trim()||"#FFFFFF"}}();t.save(),t.strokeStyle=i.textPrimary,t.globalAlpha=.15,t.lineWidth=1*o,t.setLineDash([4*o,4*o]);for(const c of[.2,.4,.6,.8]){const e=Math.round(n+r*(1-c))+.5;t.beginPath(),t.moveTo(Math.round(s),e),t.lineTo(Math.round(s+a),e),t.stroke()}t.restore(),t.save(),t.font=`bold ${10*o}px ${i.fontFamily}`,t.fillStyle=i.textPrimary,t.textBaseline="middle",t.textAlign="left";const l=8*o;for(const c of[0,20,40,60,80,100]){const e=n+r*(1-c/100),s=Math.max(n+l,Math.min(n+r-l,e));t.fillText(`${c}%`,0,s)}t.restore()}(e)}}}),[]),g=s.useMemo(()=>({width:400,height:200,padding:[8,0,0,32],cursor:{show:!0,x:!0,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],hooks:{setCursor:[e=>{var t,s;const n=e.cursor.idx;if(null!=n&&n>=0){const s=e.data[0][n];null==(t=d.current)||t.call(d,n,s)}else null==(s=d.current)||s.call(d,null,null)}]},plugins:[f]}),[f]);s.useEffect(()=>{const t=i.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!l.current||a>100||s>0&&a/s>.1)&&l.current)return l.current.setData(m),void(h.current=n);l.current&&l.current.destroy();const r=t.getBoundingClientRect(),o=Math.floor(r.width)||400,c=Math.floor(r.height)||200,u=new fr({...g,width:o,height:c},m,t);return l.current=u,h.current=n,()=>{u.destroy(),l.current=null}},[g,m,e.length]),s.useEffect(()=>{const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!l.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&l.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{l.current&&l.current.redraw()},[r,t]);const p=s.useCallback(()=>{null==a||a(null,null)},[a]);return 0===e.length?n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):n.jsx("div",{ref:i,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:p})}),yr=s.createContext(null);function xr(e){const t=Oe(e);t&&function(e){if("undefined"==typeof document)return;const t=function(e){var t;const s={},n=e.surfaces.glass;s["--glass-tint"]=n.tint,s["--glass-light"]=n.light,s["--glass-dark"]=n.dark,s["--glass-reflex-light"]=String(n.reflexLight),s["--glass-reflex-dark"]=String(n.reflexDark),s["--glass-blur"]=`${n.blur}px`,s["--glass-blur-elevated"]=`${n.blurElevated}px`,s["--glass-brightness"]=String(n.brightness),s["--glass-bg-opacity"]=`${n.opacity}%`,s["--glass-bg-opacity-elevated"]=`${n.opacityElevated}%`,s["--glass-stroke-only"]=n.strokeOnly?"1":"0",s["--glass-stroke-width"]=n.strokeWidth?`${n.strokeWidth}px`:"0px",s["--glass-stroke-color"]=n.strokeColor||"transparent",s["--glass-ribbon-mode"]=n.ribbonMode?"1":"0",s["--glass-ribbon-border-width"]=n.ribbonBorderWidth?`${n.ribbonBorderWidth}px`:"0px",s["--glass-ribbon-border-color"]=n.ribbonBorderColor||"transparent",s["--sidebar-tint"]=e.surfaces.sidebar.tint,s["--tooltip-bg"]=e.colors.bg.surface,s["--hover-tint"]=`rgba(${ee(e.colors.accent.primary)}, 0.08)`,s["--shadow-tint"]=`rgba(${ee(e.colors.accent.primary)}, 0.35)`,s["--bg-body"]=e.colors.bg.body,s["--bg-surface"]=e.colors.bg.surface,s["--bg-elevated"]=e.colors.bg.elevated,s["--bg-subtle"]=e.colors.bg.subtle,s["--border-subtle"]=e.colors.border.subtle,s["--border-strong"]=e.colors.border.strong,s["--text-primary"]=e.colors.text.primary,s["--text-secondary"]=e.colors.text.secondary,s["--text-muted"]=e.colors.text.muted,s["--text-invert"]=e.colors.text.inverse,s["--accent-primary"]=e.colors.accent.primary,s["--accent-secondary"]=e.colors.accent.secondary,s["--accent-tertiary"]=e.colors.accent.tertiary,s["--accent-success"]=e.colors.accent.success,s["--accent-danger"]=e.colors.accent.danger,s["--signal-excellent"]=e.colors.signal.excellent,s["--signal-good"]=e.colors.signal.good,s["--signal-fair"]=e.colors.signal.fair,s["--signal-poor"]=e.colors.signal.poor,s["--signal-critical"]=e.colors.signal.critical,s["--signal-unknown"]=e.colors.signal.unknown,s["--sparkline-excellent"]=e.colors.signal.excellent,s["--sparkline-good"]=e.colors.signal.good,s["--sparkline-fair"]=e.colors.signal.fair,s["--sparkline-poor"]=e.colors.signal.poor,s["--sparkline-critical"]=e.colors.signal.critical,s["--status-success"]=e.colors.status.success,s["--status-warning"]=e.colors.status.warning,s["--status-danger"]=e.colors.status.danger,s["--status-info"]=e.colors.status.info,s["--status-muted"]=e.colors.status.muted;const a=e.colors.chart;s["--pkt-advert"]=e.colors.accent.secondary,s["--pkt-flood"]=e.colors.accent.tertiary,s["--pkt-txt-msg"]=e.colors.accent.success,s["--pkt-ack"]=a.c8,s["--pkt-trace"]=a.c3,s["--pkt-req"]=a.c2,s["--pkt-response"]=a.c5,s["--pkt-grp-txt"]=e.colors.map.room,s["--pkt-grp-data"]=e.colors.accent.danger,s["--pkt-path"]=a.c3,s["--pkt-anon"]=e.colors.accent.secondary,s["--pkt-unknown"]=e.colors.status.muted,s["--route-flood"]=e.colors.accent.primary,s["--route-direct"]=e.colors.accent.secondary,s["--route-transport"]=a.c8,s["--chart-1"]=a.c1,s["--chart-2"]=a.c2,s["--chart-3"]=a.c3,s["--chart-4"]=a.c4,s["--chart-5"]=a.c5,s["--chart-6"]=a.c6,s["--chart-7"]=a.c7,s["--chart-8"]=a.c8,s["--chart-grid"]=a.grid,s["--chart-axis-tick"]=a.axis,s["--chart-cursor"]=a.cursor,s["--metric-received"]=e.colors.metric.received,s["--metric-forwarded"]=e.colors.metric.forwarded,s["--metric-transmitted"]=e.colors.metric.transmitted,s["--metric-dropped"]=e.colors.metric.dropped,s["--metric-neutral"]=e.colors.text.secondary,s["--log-debug"]=e.colors.status.muted,s["--log-info"]=e.colors.status.info,s["--log-warning"]=e.colors.status.warning,s["--log-error"]=e.colors.accent.danger,s["--log-critical"]=e.colors.accent.danger;const r=e.colors.map;s["--map-node-fill"]="#3B82F6",s["--map-node-stroke"]="rgba(255,255,255,0.9)",s["--map-hub-color"]="#8E4EC6",s["--map-hub-stroke"]="rgba(255,255,255,0.9)",s["--map-gateway-color"]="#5B5BD6",s["--map-gateway-stroke"]="rgba(255,255,255,0.85)",s["--map-local-color"]="#FFB224",s["--map-neighbor-color"]="#FFB224",s["--map-neighbor-stroke"]="rgba(0,0,0,0.4)",s["--map-mobile-color"]="#F76B15",s["--map-room-color"]="#D6409F",s["--map-ghost-color"]="#00A2C7",s["--map-edge-rest"]=r.edge,s["--map-edge-rest-bright"]=e.colors.border.strong,s["--map-edge-rest-dim"]=e.colors.bg.subtle,s["--map-edge-hover-direct"]=r.edgeHover,s["--map-edge-hover-loop"]="#8E4EC6",s["--map-edge-hover-standard"]=e.colors.text.muted,s["--map-edge-hover-neighbor"]="#FFB224",s["--link-strong"]=e.colors.accent.success,s["--link-medium"]=e.colors.accent.secondary,s["--link-weak"]=e.colors.accent.danger,s["--hop-0"]=e.colors.accent.tertiary,s["--hop-1"]=e.colors.accent.success,s["--hop-2"]=a.c3,s["--hop-3"]=e.colors.accent.secondary,s["--hop-distant"]=e.colors.text.muted,s["--hop-hub"]=r.local;const o=e.colors.icon;s["--icon-page-title"]=(null==o?void 0:o.pageTitle)??e.colors.accent.primary,s["--icon-card-title"]=(null==o?void 0:o.cardTitle)??e.colors.accent.primary,s["--icon-widget"]=(null==o?void 0:o.widget)??e.colors.text.secondary,s["--icon-action"]=(null==o?void 0:o.action)??e.colors.text.secondary,s["--icon-nav"]=(null==o?void 0:o.nav)??e.colors.text.muted,s["--icon-nav-active"]=(null==o?void 0:o.navActive)??e.colors.accent.primary,s["--toggle-on"]=e.colors.accent.success,s["--toggle-off"]=e.colors.bg.elevated;const i=e.colors.sidebar;s["--sidebar-bg"]=(null==i?void 0:i.bg)??"transparent",s["--sidebar-nav-hover-bg"]=(null==i?void 0:i.navHoverBg)??"rgba(255, 255, 255, 0.05)",s["--sidebar-nav-active-bg"]=(null==i?void 0:i.navActiveBg)??`color-mix(in srgb, ${e.colors.accent.primary} 15%, transparent)`,s["--sidebar-nav-active-text"]=(null==i?void 0:i.navActiveText)??e.colors.accent.primary;const l=e.meta.isDark;s["--data-box-bg"]=l?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.03)",s["--data-box-border"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.08)",s["--subtle-fill"]=l?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.03)",s["--subtle-fill-hover"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.05)",s["--subtle-fill-strong"]=l?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",s["--color-pill-bg"]=l?"rgba(0, 0, 0, 0.3)":"rgba(255, 255, 255, 0.3)",s["--terminal-bg"]=l?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.03)",s["--terminal-bg-input"]=l?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0.05)",s["--terminal-bg-status"]=l?"rgba(0, 0, 0, 0.3)":"rgba(0, 0, 0, 0.02)",s["--terminal-border"]=l?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)",s["--terminal-autocomplete-bg"]=l?"rgba(0, 0, 0, 0.8)":"rgba(255, 255, 255, 0.95)",s["--terminal-autocomplete-border"]=l?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.15)",s["--terminal-autocomplete-hover"]=l?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",s["--livedot-idle"]=l?"#666677":"#999999",s["--ctrl-panel-top"]=l?"rgba(30, 30, 30, 0.95)":"rgba(240, 240, 240, 0.95)",s["--ctrl-panel-mid"]=l?"rgba(25, 25, 25, 0.95)":"rgba(235, 235, 235, 0.95)",s["--ctrl-panel-bottom"]=l?"rgba(20, 20, 20, 0.95)":"rgba(230, 230, 230, 0.95)",s["--ctrl-panel-border"]=l?"rgba(60, 60, 60, 1)":"rgba(200, 200, 200, 1)",s["--chart-grid-line"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.08)",s["--map-control-active-amber"]=l?"rgba(251, 191, 36, 0.15)":"rgba(217, 119, 6, 0.12)",s["--map-control-active-sky"]=l?"rgba(56, 189, 248, 0.15)":"rgba(14, 165, 233, 0.12)",s["--map-control-active-teal"]=l?"rgba(45, 212, 191, 0.15)":"rgba(20, 184, 166, 0.12)",s["--sidebar-action-active-green"]=l?"rgba(10, 26, 10, 1)":"rgba(220, 252, 231, 1)",s["--sidebar-action-active-teal"]=l?"rgba(10, 36, 32, 1)":"rgba(204, 251, 241, 1)",s["--sidebar-action-active-amber"]=l?"rgba(26, 20, 8, 1)":"rgba(254, 243, 199, 1)",s["--thumbnail-brightness"]=l?"1.5":"1.8",s["--font-title"]=e.typography.font.title,s["--font-display"]=e.typography.font.display,s["--font-data"]=e.typography.font.mono,s["--font-card-title"]=e.typography.font.cardTitle??e.typography.font.display,s["--font-badge"]=e.typography.font.badge??e.typography.font.display,s["--font-normal"]=String(e.typography.weight.normal),s["--font-medium"]=String(e.typography.weight.medium),s["--font-semibold"]=String(e.typography.weight.semibold),s["--font-bold"]=String(e.typography.weight.bold),s["--font-card-title-weight"]=String(e.typography.weight.cardTitle??e.typography.weight.semibold),s["--font-badge-weight"]=String(e.typography.weight.badge??e.typography.weight.medium),s["--badge-text-transform"]=(null==(t=e.typography.badge)?void 0:t.textTransform)??"none";const c=e.typography.size;c.xxl&&(s["--text-2xl"]=c.xxl),c.xl&&(s["--text-xl"]=c.xl),c.lg&&(s["--text-lg"]=c.lg),c.md&&(s["--text-md"]=c.md),c.base&&(s["--text-base"]=c.base),c.sm&&(s["--text-sm"]=c.sm),c.xs&&(s["--text-xs"]=c.xs),c.hero&&(s["--text-5xl"]=c.hero),c.cardTitle&&(s["--text-card-title"]=c.cardTitle);const u=e.typography.tracking;return u&&(s["--tracking-tight"]=u.tight,s["--tracking-normal"]=u.normal,s["--tracking-wide"]=u.wide),s["--theme-transition"]=`${e.motion.slow} ${e.motion.easing}`,function(e){if(!K())return e;const t={},s=/^#[0-9A-Fa-f]{3,6}$/;for(const[n,a]of Object.entries(e))t[n]=s.test(a)?V(a):a;return t}(s)}(e),s=document.documentElement;for(const[n,a]of Object.entries(t))s.style.setProperty(n,a);e.surfaces.glass.strokeOnly?s.classList.add("stroke-only"):s.classList.remove("stroke-only"),e.surfaces.glass.ribbonMode?s.classList.add("ribbon-mode"):s.classList.remove("ribbon-mode"),e.surfaces.glass.catalystMode?s.classList.add("catalyst-mode"):s.classList.remove("catalyst-mode")}(t),document.documentElement.dataset.colorScheme=e}function wr({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return Qe;try{let s=localStorage.getItem(Ze),n=localStorage.getItem(et);const a=localStorage.getItem(tt);if(!s&&!n){const e=localStorage.getItem(st);if(e){const t=Xe.find(t=>t.id===e);t&&(s=t.colorScheme,n=t.backgroundImage,localStorage.setItem(Ze,s),localStorage.setItem(et,n),localStorage.removeItem(st))}}const r=s&&"string"==typeof(t=s)&&Ve.some(e=>e.id===t)?s:Qe.colorScheme;let o=Qe.backgroundImage;""===n?o="":n&&"string"==typeof(e=n)&&Ke.some(t=>t.src===e)&&(o=n);let i=Qe.brightness;if(a){const e=parseInt(a,10);!isNaN(e)&&e>=0&&e<=100&&(i=e)}return{colorScheme:r,backgroundImage:o,brightness:i}}catch{return Qe}var e,t}()),r=s.useRef(!1),o=s.useRef(null),[i,l]=s.useState(null);s.useEffect(()=>{o.current&&(clearTimeout(o.current),o.current=null),r.current&&(l("#808080"),o.current=setTimeout(()=>{l(null),o.current=null},1800)),r.current=!0,xr(t.colorScheme),gr.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of ot){const e=ht(`--palette-${t}-bright`),s=ht(`--palette-${t}`),n=e||s;if(!n)continue;const a=dt(n);for(const r of rt)mt(`--palette-${t}-${r}`,a[r])}const e=ht("--palette-bg-4");if(e){const t=dt(e);for(const e of rt)mt(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(Ze,e.colorScheme),localStorage.setItem(et,e.backgroundImage),localStorage.setItem(tt,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{Ke.forEach(e=>{(new Image).src=e.src})},[]);const c=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),u=s.useCallback(e=>{const t=Ke.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),d=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),h=s.useCallback(e=>{const t=Xe.find(t=>t.id===e);if(t){const e=!t.backgroundImage,s=e?null:Ke.find(e=>e.src===t.backgroundImage);a(n=>({...n,colorScheme:t.colorScheme,backgroundImage:t.backgroundImage,brightness:e?100:(null==s?void 0:s.suggestedBrightness)??n.brightness}))}},[]),m=s.useMemo(()=>({theme:t,setColorScheme:c,setBackgroundImage:u,setBrightness:d,setThemePreset:h}),[t,c,u,d,h]);return n.jsxs(yr.Provider,{value:m,children:[e,i&&n.jsx("div",{className:"fixed inset-0 pointer-events-none z-[9999]",style:{backgroundColor:i,animation:"theme-crossfade 1.8s ease-out forwards"}},t.colorScheme),n.jsx("style",{children:"\n @keyframes theme-crossfade {\n from { opacity: 0.35; }\n to { opacity: 0; }\n }\n "})]})}function vr(){const e=s.useContext(yr);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const kr=s.forwardRef(function(e,t){const{href:s,...o}=e;return s.startsWith("http://")||s.startsWith("https://")||s.startsWith("//")?n.jsx(a,{children:n.jsx("a",{...o,href:s,ref:t})}):n.jsx(a,{children:n.jsx(r,{...o,to:s,ref:t})})}),Sr={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"},Cr={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},jr={REQ:0,RESPONSE:1,TXT_MSG:2,ACK:3,ADVERT:4,GRP_TXT:5,GRP_DATA:6,ANON_REQ:7,PATH:8,TRACE:9,MULTIPART:10,RAW_CUSTOM:15};function Tr(e){return 1===e||0===e}function Mr(e){return null==e?"UNKNOWN":Sr[e]||`TYPE_${e}`}function Lr(e){return null==e?"UNKNOWN":Cr[e]||`ROUTE_${e}`}function Nr(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function _r(e){const t=function(e){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255,r=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);return.2126*r(s)+.7152*r(n)+.0722*r(a)}(e);return Nr(t,1)>Nr(t,0)?"light":"dark"}function Er(e){return 1===e||!0===e}const Pr=J("inline-flex items-center gap-1","rounded-md px-1.5 py-0.5","text-xs"),Dr={fontFamily:"var(--font-badge)",fontWeight:"var(--font-badge-weight)",textTransform:"var(--badge-text-transform, none)"},Ir={red:"var(--sys-red)",orange:"var(--sys-orange)",amber:"var(--sys-amber)",yellow:"var(--sys-yellow)",lime:"var(--sys-green)",green:"var(--sys-green)",emerald:"var(--sys-green)",teal:"var(--sys-teal)",cyan:"var(--sys-cyan)",sky:"var(--sys-cyan)",blue:"var(--sys-blue)",indigo:"var(--sys-indigo)",violet:"var(--sys-indigo)",purple:"var(--sys-purple)",fuchsia:"var(--sys-pink)",pink:"var(--sys-pink)",rose:"var(--sys-red)",brown:"var(--sys-brown)",zinc:"var(--text-muted)"};function Fr(e){if(!e.startsWith("var("))return e;if("undefined"!=typeof window){const t=e.match(/var\((--[^,)]+)/);if(t){const e=getComputedStyle(document.documentElement).getPropertyValue(t[1]).trim();if(e&&e.startsWith("#"))return e}}return"#666666"}function Ar({color:e="zinc",customColor:t,filled:a=!1,compact:r=!1,className:o,title:i,children:l}){const c=s.useMemo(()=>{const s=t??Ir[e];if(a){if(t){const e=_r(Fr(t));return{backgroundColor:t,color:"light"===e?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.85)"}}return{backgroundColor:s,color:["amber","yellow","lime"].includes(e)?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"}}return{backgroundColor:`color-mix(in srgb, ${s} 15%, transparent)`,color:s}},[e,t,a]);return n.jsx("span",{className:J(Pr,r&&"!px-1 !py-0 !text-[10px]",o),style:{...Dr,...c},title:i,children:l})}const Rr=s.forwardRef(function({color:e="zinc",customColor:t,filled:a=!1,compact:r=!1,className:i,children:l,...c},u){const d=s.useMemo(()=>{const s=t??Ir[e];if(a){if(t){const e=_r(Fr(t));return{backgroundColor:t,color:"light"===e?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.85)"}}return{backgroundColor:s,color:["amber","yellow","lime"].includes(e)?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"}}return{backgroundColor:`color-mix(in srgb, ${s} 15%, transparent)`,color:s}},[e,t,a]),h=J(Pr,r&&"!px-1 !py-0 !text-[10px]","cursor-pointer transition-opacity hover:opacity-80",i);return"href"in c&&void 0!==c.href?n.jsx(kr,{...c,ref:u,className:h,style:{...Dr,...d},children:l}):n.jsx(o,{...c,ref:u,className:h,style:{...Dr,...d},children:l})}),zr=J("relative inline-flex items-center justify-center gap-2","text-sm font-medium whitespace-nowrap","rounded-lg px-3 py-1.5","focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-bg-body","disabled:opacity-50 disabled:cursor-not-allowed","transition-all duration-150","[&>[data-slot=icon]]:w-4 [&>[data-slot=icon]]:h-4 [&>[data-slot=icon]]:shrink-0"),Br={primary:J("bg-accent-primary text-white","hover:bg-accent-primary/90","active:bg-accent-primary/80","border border-accent-primary/20"),success:J("bg-accent-success text-white","hover:bg-accent-success/90","active:bg-accent-success/80","border border-accent-success/20"),danger:J("bg-accent-danger text-white","hover:bg-accent-danger/90","active:bg-accent-danger/80","border border-accent-danger/20"),warning:J("bg-accent-secondary text-bg-body","hover:bg-accent-secondary/90","active:bg-accent-secondary/80","border border-accent-secondary/20"),muted:J("bg-bg-elevated text-text-primary","hover:bg-bg-subtle","active:bg-bg-elevated","border border-border-subtle")},Or={primary:J("bg-transparent text-accent-primary","border border-accent-primary/30","hover:bg-accent-primary/10 hover:border-accent-primary/50","active:bg-accent-primary/20"),success:J("bg-transparent text-accent-success","border border-accent-success/30","hover:bg-accent-success/10 hover:border-accent-success/50","active:bg-accent-success/20"),danger:J("bg-transparent text-accent-danger","border border-accent-danger/30","hover:bg-accent-danger/10 hover:border-accent-danger/50","active:bg-accent-danger/20"),warning:J("bg-transparent text-accent-secondary","border border-accent-secondary/30","hover:bg-accent-secondary/10 hover:border-accent-secondary/50","active:bg-accent-secondary/20"),muted:J("bg-transparent text-text-muted","border border-border-subtle","hover:bg-bg-subtle hover:text-text-primary hover:border-border-strong","active:bg-bg-elevated")},$r={primary:J("bg-transparent text-accent-primary border-transparent","hover:bg-accent-primary/10","active:bg-accent-primary/20"),success:J("bg-transparent text-accent-success border-transparent","hover:bg-accent-success/10","active:bg-accent-success/20"),danger:J("bg-transparent text-accent-danger border-transparent","hover:bg-accent-danger/10","active:bg-accent-danger/20"),warning:J("bg-transparent text-accent-secondary border-transparent","hover:bg-accent-secondary/10","active:bg-accent-secondary/20"),muted:J("bg-transparent text-text-muted border-transparent","hover:bg-bg-subtle hover:text-text-primary","active:bg-bg-elevated")},Wr=s.forwardRef(function({color:e="muted",outline:t=!1,plain:s=!1,className:a,children:r,...i},l){const c=J(zr,s?$r[e]:t?Or[e]:Br[e],a);return"href"in i&&void 0!==i.href?n.jsx(kr,{...i,ref:l,className:c,children:r}):n.jsx(o,{...i,ref:l,className:c,children:r})}),Hr={duration:.15,ease:[.4,0,.2,1]},Ur={type:"tween",duration:.25,ease:[.4,0,.2,1]},qr={type:"tween",duration:.3,ease:[.4,0,.2,1]},Gr=s.createContext(!1);function Jr(){return s.useContext(Gr)}const Yr={xs:"sm:max-w-xs",sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl","3xl":"sm:max-w-3xl","4xl":"sm:max-w-4xl","5xl":"sm:max-w-5xl",full:"sm:max-w-[calc(100vw-2rem)]"};function Vr({open:e,onClose:t,size:a="md",className:r,children:o,bottomSheet:d=!0,motionPlus:h=!1}){const[m,f]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>(g.current&&(clearTimeout(g.current),g.current=null),e?g.current=setTimeout(()=>{f(!0)},350):queueMicrotask(()=>f(!1)),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[e]);const p=s.useCallback((e,s)=>{(s.offset.y>100||s.velocity.y>500)&&t()},[t]),b=h?qr:Ur,y=h?.98:.99,x=d?8:4;return n.jsx(i,{mode:"wait",children:e&&n.jsxs(l,{static:!0,open:e,onClose:t,className:"relative z-[10010]",children:[n.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:Hr,className:"fixed inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":"true"}),n.jsx("div",{className:"fixed inset-0 overflow-y-auto",children:n.jsx("div",{className:J("flex min-h-full justify-center",d?"items-end sm:items-center sm:p-4":"items-center p-4"),children:n.jsx(c.div,{drag:!!d&&"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.4},onDragEnd:p,initial:{opacity:0,scale:y,y:x},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.99,y:d?40:4},transition:b,style:{willChange:"transform, opacity"},className:J(d&&"w-full sm:w-auto"),children:n.jsx(u,{className:J("w-full bg-bg-surface shadow-2xl flex flex-col","ring-1 ring-inset ring-white/10",Yr[a],d?"rounded-t-2xl rounded-b-none sm:rounded-2xl pb-safe":"rounded-2xl",r),children:n.jsx(Gr.Provider,{value:m,children:o})})})})})]})})}function Kr({className:e,...t}){return n.jsx(d,{...t,className:J("text-base font-semibold text-text-primary sm:text-lg",e)})}function Xr({icon:e,title:t,onClose:s,className:a}){return n.jsxs("div",{className:J("flex items-center justify-between p-4 border-b border-border-subtle",a),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e&&n.jsx("div",{className:"p-2 rounded-lg bg-bg-subtle text-icon-card-title",children:e}),n.jsx(Kr,{children:t})]}),s&&n.jsx("button",{onClick:s,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors","aria-label":"Close",children:n.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}function Qr({className:e,...t}){return n.jsx("div",{...t,className:J("p-4",e)})}function Zr({className:e,...t}){return n.jsx("div",{...t,className:J("flex flex-col-reverse gap-3 p-4 pt-0","sm:flex-row sm:justify-end","*:w-full sm:*:w-auto",e)})}const eo={snappy:{type:"spring",stiffness:500,damping:30},smooth:{type:"spring",stiffness:300,damping:30},gentle:{type:"spring",stiffness:200,damping:25}},to={easeIn:[.4,0,1,1],cubicInOut:[.65,0,.35,1]},so={normal:.05};function no({className:e,...t}){return n.jsx("nav",{...t,className:J(e,"flex h-full min-h-0 flex-col")})}function ao({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex flex-col border-b border-border-subtle p-4","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function ro({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex flex-1 flex-col overflow-y-auto p-3","[&>[data-slot=section]+[data-slot=section]]:mt-6")})}function oo({className:e,...t}){return n.jsx("div",{...t,className:J(e,"mt-auto flex flex-col border-t border-border-subtle","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function io({className:e,...t}){const a=s.useId();return n.jsx(h,{id:a,children:n.jsx("div",{...t,"data-slot":"section",className:J(e,"flex flex-col gap-0.5")})})}const lo=s.forwardRef(function(e,t){const{current:s,className:a,children:i,...l}=e,u=J("flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left","min-h-[44px]","text-sm font-medium","[&>svg]:w-5 [&>svg]:h-5 [&>svg]:flex-shrink-0",s?"bg-accent-primary/15 text-accent-primary [&>svg]:text-accent-primary":"text-text-muted hover:text-text-primary hover:bg-subtle-fill [&>svg]:text-text-muted hover:[&>svg]:text-text-primary","transition-all duration-150");return n.jsxs("span",{className:J(a,"relative"),children:[s&&n.jsx(c.span,{layoutId:"sidebar-current-indicator",className:"absolute inset-y-2 -left-3 w-0.5 rounded-full bg-accent-primary"}),"string"==typeof l.href?n.jsx(r,{to:l.href,onClick:l.onClick,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,className:u,"data-current":s?"true":void 0,ref:t,children:i}):n.jsx(o,{...l,className:J("cursor-default",u),"data-current":s?"true":void 0,ref:t,children:i})]})});function co({className:e,...t}){return n.jsx("span",{...t,className:J(e,"truncate")})}function uo({className:e,variant:t="default",...s}){return n.jsx("span",{...s,className:J("ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full","text-xs font-medium",{default:"bg-bg-subtle text-text-muted",accent:"bg-accent-primary/20 text-accent-primary",success:"bg-accent-success/20 text-accent-success",warning:"bg-accent-secondary/20 text-accent-secondary",danger:"bg-accent-danger/20 text-accent-danger"}[t],e)})}const ho=s.createContext(null),mo={type:"spring",visualDuration:.35,bounce:.15};function fo({open:e,onClose:t,children:s}){return n.jsx(i,{children:e&&n.jsxs(l,{static:!0,open:e,onClose:t,className:"lg:hidden relative z-[10002]",children:[n.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:"easeOut"},className:"fixed inset-0 bg-black/60 backdrop-blur-sm","aria-hidden":"true"}),n.jsx(c.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:mo,className:"fixed inset-y-0 left-0 w-72 max-w-[85vw] z-[10003]",children:n.jsx(u,{className:"h-full",children:n.jsxs("div",{className:"flex h-full flex-col sidebar-panel",children:[n.jsx("div",{className:"absolute top-4 right-4 z-10",children:n.jsx(f,{className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-subtle-fill transition-colors","aria-label":"Close navigation",children:n.jsx(g,{className:"w-5 h-5"})})}),s]})})})]})})}function go({sidebar:e,navbar:t,children:a,className:r}){const[o,i]=s.useState(!1),l=()=>i(!0),c=()=>i(!1),u={isOpen:o,open:l,close:c,toggle:()=>i(e=>!e)};return n.jsx(ho.Provider,{value:u,children:n.jsxs("div",{className:"flex h-screen overflow-hidden bg-bg-body",children:[n.jsx("aside",{className:"hidden lg:flex flex-col w-64 flex-shrink-0 h-full relative sidebar-panel",children:e}),n.jsx(fo,{open:o,onClose:c,children:e}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsx("header",{className:"lg:hidden sticky top-0 z-[10001] h-14 mobile-header",children:n.jsxs("div",{className:"flex items-center h-full px-4",children:[n.jsx("button",{onClick:l,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-subtle-fill active:bg-subtle-fill transition-colors mr-2","aria-label":"Open navigation",children:n.jsx(m,{className:"w-5 h-5 text-text-primary"})}),n.jsx("div",{className:"flex-1 min-w-0",children:t})]})}),n.jsx("main",{className:J("flex-1 overflow-y-auto main-content",r),children:a})]})]})})}function po({className:e,...t}){return n.jsx("nav",{...t,className:J(e,"flex flex-1 items-center gap-3")})}function bo({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex items-center gap-3")})}function yo({className:e,...t}){return n.jsx("div",{"aria-hidden":"true",...t,className:J(e,"flex-1")})}function xo({defaultOpen:e=!1,className:t,children:s}){return n.jsx(y,{defaultOpen:e,children:n.jsx("div",{className:J("flex flex-col",t),children:s})})}s.forwardRef(function({children:e,elevated:t,compact:s,noPadding:a,className:r,...o},i){return n.jsx("div",{ref:i,className:J("rounded-lg","bg-bg-surface","ring-1 ring-inset ring-border-subtle","h-full flex flex-col",t&&"bg-bg-elevated",!a&&(s?"p-3 sm:p-4":"p-4 sm:p-5"),r),...o,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex items-center justify-between gap-4","pb-4 mb-4","border-b border-border-subtle",t),...s,children:e})}),s.forwardRef(function({children:e,icon:t,className:s,...a},r){return n.jsxs("h3",{ref:r,className:J("flex items-center gap-2","text-base font-semibold text-text-primary",s),...a,children:[t&&n.jsx("span",{className:"text-icon-card-title w-5 h-5 flex-shrink-0",children:t}),e]})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("p",{ref:a,className:J("text-sm text-text-muted",t),...s,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex-1 min-h-0",t),...s,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex items-center justify-end gap-3","pt-4 mt-4","border-t border-border-subtle",t),...s,children:e})}),s.forwardRef(function({children:e,border:t,className:s,...a},r){return n.jsx("div",{ref:r,className:J(t&&"pt-4 mt-4 border-t border-border-subtle",s),...a,children:e})});const wo=s.forwardRef(function({className:e,icon:t,children:s,...a},r){return n.jsx(p,{ref:r,className:J("flex w-full items-center justify-between gap-3","px-3 py-2 rounded-lg","text-sm font-medium text-text-muted","hover:bg-bg-surface hover:text-text-primary","transition-colors duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50",e),...a,children:({open:e})=>n.jsxs(n.Fragment,{children:[s,n.jsx("span",{className:J("transition-transform duration-200",e?"rotate-180":"rotate-0"),children:t||n.jsx(b,{className:"w-4 h-4"})})]})})});function vo({direction:e="down",className:t,children:s}){const a={hidden:{height:0,opacity:0,y:"up"===e?8:-8},visible:{height:"auto",opacity:1,y:0}};return n.jsx(x,{static:!0,children:({open:r})=>n.jsx(i,{initial:!1,children:r&&n.jsx(c.div,{initial:"hidden",animate:"visible",exit:"hidden",variants:a,transition:{height:{duration:.2,ease:[.4,0,.2,1]},opacity:{duration:.15},y:{duration:.15}},className:J("overflow-hidden",t),children:n.jsx("div",{className:J("up"===e?"pb-2":"pt-2"),children:s})})})})}function ko({label:e,icon:t,defaultOpen:s=!0,direction:a="down",className:r,dataId:o,children:i}){const l=o?{[`data-${o}-disclosure`]:!0}:{};return n.jsx(xo,{defaultOpen:s,className:r,children:"up"===a?n.jsxs(n.Fragment,{children:[n.jsx(vo,{direction:"up",children:i}),n.jsx(wo,{...l,children:n.jsxs("span",{className:"flex items-center gap-3",children:[t,n.jsx("span",{className:"text-xs uppercase tracking-wide",children:e})]})})]}):n.jsxs(n.Fragment,{children:[n.jsx(wo,{...l,children:n.jsxs("span",{className:"flex items-center gap-3",children:[t,n.jsx("span",{className:"text-xs uppercase tracking-wide",children:e})]})}),n.jsx(vo,{direction:"down",children:i})]})})}const So="0.9.194",Co="'JetBrains Mono', monospace",jo=s.memo(function({height:e=16,responsive:t=!1,className:s=""}){const a="var(--accent-primary)",r="var(--text-primary)";if(t){const e=145,t=24;return n.jsxs("svg",{className:s,viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"pyMC:Console",style:{display:"block",width:"80%",height:"auto"},children:[n.jsx("style",{children:`\n .logo-text {\n font-family: ${Co};\n }\n .logo-accent {\n fill: var(--accent-primary, #719CDF);\n }\n .logo-main {\n fill: var(--text-primary, #FFFFFF);\n }\n `}),n.jsxs("text",{x:"0",y:"18",className:"logo-text",fontSize:"20",fontWeight:"400",letterSpacing:"-0.02em",children:[n.jsx("tspan",{className:"logo-accent",children:"py"}),n.jsx("tspan",{className:"logo-main",children:"MC"}),n.jsx("tspan",{className:"logo-accent",children:":"}),n.jsx("tspan",{className:"logo-main",children:"Console"})]})]})}const o="string"==typeof e?parseFloat(e):e,i={fontFamily:Co,fontSize:.8*o+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:i,role:"img","aria-label":"pyMC:Console",children:[n.jsx("span",{style:{color:a},children:"py"}),n.jsx("span",{style:{color:r},children:"MC"}),n.jsx("span",{style:{color:a},children:":"}),n.jsx("span",{style:{color:r},children:"Console"})]})}),To="pymc_jwt_token",Mo="pymc_client_id",Lo="pymc_remember_me",No=new Set;function _o(e){return No.add(e),()=>No.delete(e)}function Eo(e){for(const s of No)try{s(e)}catch(t){}}function Po(){let e=localStorage.getItem(Mo);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(Mo,e)),e}function Do(){return"true"===localStorage.getItem(Lo)}function Io(e){e?localStorage.setItem(Lo,"true"):localStorage.removeItem(Lo)}function Fo(){return Do()?localStorage:sessionStorage}function Ao(){return Fo().getItem(To)||localStorage.getItem(To)||sessionStorage.getItem(To)}function Ro(e){Fo().setItem(To,e),Do()?sessionStorage.removeItem(To):localStorage.removeItem(To),Eo(e)}function zo(){localStorage.removeItem(To),sessionStorage.removeItem(To),Eo(null)}function Bo(){return!(!Ao()||$o()&&(zo(),1))}function Oo(e){try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(atob(t).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(s)}catch{return null}}function $o(){const e=Ao();if(!e)return!0;const t=Oo(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function Wo(){const e=Ao();if(!e)return 0;const t=Oo(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function Ho(){const e=Ao();if(!e)return!1;const t=Oo(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function Uo(){const e=Ao();if(!e)return null;const t=Oo(e);return t&&t.sub?t.sub:null}async function qo(e,t,s=!1){Io(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:Po()})}),n=s.headers.get("content-type");if(!n||!n.includes("application/json"))return{success:!1,error:`Server error: ${s.status}`};const a=await s.json();return a.success&&a.token?(Ro(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function Go(){const e=Ao();if(!e)return!1;const t=Oo(e);(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3);try{const t=await fetch("/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({client_id:Po()})});if(!t.ok){let e="";try{const s=await t.json();e=s.error||JSON.stringify(s)}catch{e=t.statusText}return!1}const s=await t.json();if(s.success&&s.token){Ro(s.token);const e=Oo(s.token);return(null==e?void 0:e.exp)&&Math.floor((1e3*e.exp-Date.now())/1e3),!0}return!1}catch(s){return!1}}let Jo=null;async function Yo(){const e=Ao();if(!e)return!1;const t=Oo(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!Ho()||Jo||(Jo=Go().finally(()=>{Jo=null}),Jo)}function Vo(){zo()}let Ko=!1;function Xo(){if(Ko)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!Ao())return;if($o())return zo(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=Wo();e>0&&e<300&&await Go()};document.addEventListener("visibilitychange",e),Ko=!0,"visible"===document.visibilityState&&e()}const Qo=Object.freeze(Object.defineProperty({__proto__:null,clearToken:zo,getClientId:Po,getRememberMe:Do,getToken:Ao,getTokenTimeRemaining:Wo,getUsername:Uo,isAuthenticated:Bo,isTokenExpired:$o,login:qo,logout:Vo,onTokenChange:_o,parseJWT:Oo,refreshToken:Go,refreshTokenIfNeeded:Yo,setRememberMe:Io,setToken:Ro,shouldRefreshToken:Ho,startVisibilityBasedRefresh:Xo},Symbol.toStringTag,{value:"Module"})),Zo=new Map;let ei=!1;async function ti(e,t,s=!1){const n=function(e,t){return(null==t?void 0:t.method)&&"GET"!==t.method?"":e}(e,t);if(n){const e=Zo.get(n);if(e)return e}const a=`${e}`;!s&&Ho()&&await Go();const r=Ao();if(!r&&!e.includes("/auth/"))throw window.location.href="/login",new Error("Not authenticated");const o=r?{Authorization:`Bearer ${r}`}:{};if(null==t?void 0:t.headers){const e=t.headers;e instanceof Headers?e.forEach((e,t)=>{o[t]=e}):Array.isArray(e)?e.forEach(([e,t])=>{o[e]=t}):Object.assign(o,e)}(null==t?void 0:t.body)&&(o["Content-Type"]="application/json");const i=(async()=>{const n=await fetch(a,{...t,headers:o});if(401===n.status){if(!s&&!ei&&await Go())return ti(e,t,!0);throw ei||(ei=!0,zo(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText} (${e})`);return n.json()})();return n&&(Zo.set(n,i),i.finally(()=>{Zo.delete(n)})),i}const si={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function ni(e){if(e.raw_packet){const t=e.raw_packet;if(/^[0-9a-fA-F]+$/.test(t)&&t.length%2==0)return t.length/2;if(/^[A-Za-z0-9+/=]+$/.test(t)){const e=(t.match(/=+$/)||[""])[0].length;return Math.floor(3*t.length/4)-e}return t.length}if(e.length&&e.length>0)return e.length;if(e.payload_length&&e.payload_length>0)return e.payload_length;if(e.payload){const t=e.payload;return/^[0-9a-fA-F]+$/.test(t)&&t.length%2==0?t.length/2:t.length}return 32}function ai(e,t={}){return void 0!==e.airtime_ms&&e.airtime_ms>0?e.airtime_ms:function(e,t={}){const s=t.spreadingFactor??si.spreadingFactor,n=t.bandwidthHz??si.bandwidthHz,a=t.codingRate??si.codingRate,r=t.preambleLength??si.preambleLength??8,o=t.crcEnabled??si.crcEnabled?1:0,i=t.explicitHeader??si.explicitHeader?0:1,l=s>=11&&n<=125e3?1:0,c=n/1e3,u=Math.pow(2,s)/c,d=(r+4.25)*u,h=Math.max(8*e-4*s+28+16*o-20*i,0),m=4*(s-2*l);return d+(8+Math.ceil(h/m)*a)*u}(ni(e),t)}function ri(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function oi(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=ri(t.contact_type);return e}(await ti("/api/stats"))}async function ii(){return ti("/api/logs")}async function li(e=24){return ti(`/api/noise_floor_history?hours=${e}`)}const ci=new Map;function ui(e=!1){if(e)ci.clear();else for(const[t]of ci)parseInt(t.split("-")[0],10)<=60&&ci.delete(t)}function di(e,t,s,n){const a=60*e/t,r=Math.floor(Date.now()/1e3),o=Math.floor(r/a)*a,i=o-60*e,l=s.filter(e=>e.timestamp>=i&&e.timestamp<=o),c=n?function(e){var t;const s=null==(t=null==e?void 0:e.config)?void 0:t.radio;return{spreadingFactor:(null==s?void 0:s.spreading_factor)??si.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??si.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??si.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??si.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):si,u=function(e,t,s,n,a){const r=new Array(t),o=new Array(t),i=new Array(t),l=new Array(t),c=new Array(t),u=new Array(t),d=new Array(t);for(let m=0;m=t)continue;const g=ai(h,a),p=h.packet_origin;if("tx_local"===p?(i[f].count++,i[f].airtime_ms+=g):"tx_forward"===p||h.transmitted?(l[f].count++,l[f].airtime_ms+=g):h.drop_reason&&(c[f].count++,c[f].airtime_ms+=g),"tx_local"!==p){r[f].count++,r[f].airtime_ms+=g,u[f].snr+=h.snr||0,u[f].rssi+=h.rssi||0,u[f].count++;const e=h.packet_hash;e&&!d[f].has(e)&&(d[f].add(e),o[f].count++,o[f].airtime_ms+=g)}}for(let m=0;m0&&(r[m].avg_snr=u[m].snr/u[m].count,r[m].avg_rssi=u[m].rssi/u[m].count);return{received:r,unique_received:o,transmitted:i,forwarded:l,dropped:c}}(l,t,i,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:i,end_time:o,...u}}async function hi(){return ti("/api/hardware_stats")}async function mi(){return ti("/api/hardware_processes")}async function fi(e){return ti("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function gi(){return ti("/api/send_advert",{method:"POST",body:"{}"})}async function pi(e){return ti("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function bi(e){return ti("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}async function yi(e){try{return await ti("/api/log_level",{method:"POST",body:JSON.stringify({level:e})})}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}const xi="pymc-packet-cache",wi="pymc-packet-cache-meta",vi=36e5,ki=2592e5,Si=6048e5,Ci=12096e5,ji=5e3,Ti=5e5,Mi=new class{constructor(){t(this,"packets",new Map),t(this,"sortedPackets",[]),t(this,"sortedDirty",!0),t(this,"meta",{oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1}),t(this,"isLoading",!1),t(this,"isBackgroundLoading",!1),t(this,"isTopologyLoading",!1),t(this,"listeners",new Set),t(this,"loadProgress",null),t(this,"statusMessage",""),this.loadFromStorage()}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getState(){return{isLoading:this.isLoading,isBackgroundLoading:this.isBackgroundLoading,isTopologyLoading:this.isTopologyLoading,backgroundLoadComplete:this.meta.backgroundLoadComplete,topologyLoadComplete:this.meta.topologyLoadComplete,packetCount:this.packets.size,statusMessage:this.statusMessage,loadProgress:this.loadProgress,dataTier:this.meta.dataTier,threeDayLoadComplete:this.meta.threeDayLoadComplete,sevenDayLoadComplete:this.meta.sevenDayLoadComplete,fourteenDayLoadComplete:this.meta.fourteenDayLoadComplete}}getDataTier(){return this.meta.dataTier}getPackets(){return this.sortedDirty&&(this.sortedPackets=Array.from(this.packets.values()).sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),this.sortedDirty=!1),this.sortedPackets}isStale(){return 0===this.packets.size||Date.now()-this.meta.lastUpdated>vi}isHeavyLoadInProgress(){return this.isBackgroundLoading||this.isTopologyLoading}async initialLoad(e){if(this.isStale()&&this.packets.size>0&&this.clear(),this.meta.backgroundLoadComplete&&this.packets.size>0)return this.getPackets();this.isLoading=!0;const t=Date.now(),s=Math.floor((t-864e5)/1e3),n=3e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 24h history...",this.notifyListeners();try{let t;this.packets.size>0&&(this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta.oldestTimestamp=0,this.meta.newestTimestamp=0);let a=0,r=0,o=0;const i=Math.ceil(100);for(let l=0;l0))break;{const n=this.packets.size;this.mergePackets(u.data);const o=this.packets.size-n;a+=o;const i=Math.min(...u.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===t||i=2)break}else r=0;if(u.data.length=Ti)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,this.meta.dataTier="24h",this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.saveToStorage()}catch(a){this.statusMessage="Load failed"}finally{this.isLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}return this.getPackets()}async quickLoad(){return this.initialLoad()}async backgroundLoad(){await this.initialLoad()}async loadThreeDays(e){this.meta.threeDayLoadComplete||this.isBackgroundLoading||await this.loadExtendedData("3d",ki,e)}async loadSevenDays(e){this.meta.sevenDayLoadComplete||this.isBackgroundLoading||(this.meta.threeDayLoadComplete||await this.loadThreeDays(e),await this.loadExtendedData("7d",Si,e))}async loadFourteenDays(e){this.meta.fourteenDayLoadComplete||this.isBackgroundLoading||(this.meta.sevenDayLoadComplete||await this.loadSevenDays(e),await this.loadExtendedData("14d",Ci,e))}async loadExtendedData(e,t,s){this.isBackgroundLoading=!0;const n=Date.now(),a=Math.floor((n-t)/1e3),r=3e4*("3d"===e?2:"7d"===e?4:7);this.loadProgress={loaded:0,target:r,percent:0},this.statusMessage=`Loading ${e} history...`,this.notifyListeners();try{let t=this.meta.oldestTimestamp||void 0,n=0,o=0,i=0;const l=Math.ceil(100);for(let u=0;u0))break;{const e=this.packets.size;this.mergePackets(d.data);const r=this.packets.size-e;n+=r;const i=Math.min(...d.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===t||i=2)break}else o=0;if(d.data.length=Ti)break}u=5)break;await this.delay(2e3)}}this.enforceMemoryCap();const c=Date.now()-1e3*this.meta.oldestTimestamp;"3d"===e?(this.meta.threeDayLoadComplete=c>=ki,this.meta.threeDayLoadComplete&&(this.meta.dataTier="3d")):"7d"===e?(this.meta.sevenDayLoadComplete=c>=Si,this.meta.sevenDayLoadComplete&&(this.meta.dataTier="7d")):(this.meta.fourteenDayLoadComplete=c>=Ci,this.meta.fourteenDayLoadComplete&&(this.meta.dataTier="14d")),this.loadProgress={loaded:n,target:n,percent:100},this.notifyListeners(),this.saveToStorage()}catch(o){this.statusMessage=`${e} load failed`}finally{this.isBackgroundLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}isDataTierAvailable(e){switch(e){case"24h":return this.meta.backgroundLoadComplete;case"3d":return this.meta.threeDayLoadComplete;case"7d":return this.meta.sevenDayLoadComplete;case"14d":return this.meta.fourteenDayLoadComplete;default:return!1}}async topologyLoad(){if(!this.meta.topologyLoadComplete&&!this.isTopologyLoading)return this.doTopologyLoad()}async forceTopologyLoad(){if(!this.isTopologyLoading)return this.meta.topologyLoadComplete=!1,this.doTopologyLoad()}async forceDeepLoad(){return this.forceTopologyLoad()}async doTopologyLoad(){this.isTopologyLoading=!0;const e=Date.now(),t=Math.floor((e-Ci)/1e3),s=42e4;this.statusMessage="Loading topology data...",this.loadProgress={loaded:this.packets.size,target:s,percent:0},this.notifyListeners();try{let e=this.meta.oldestTimestamp||void 0,n=0,a=0;const r=Math.ceil(100);for(let o=0;o0))break;{const s=this.packets.size;this.mergePackets(l.data);const a=this.packets.size-s,r=Math.min(...l.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===e||r=2)break}else n=0;if(this.packets.size>=Ti)break}o=5)break;await this.delay(2e3)}}this.enforceMemoryCap(),this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.meta.topologyLoadComplete=!0,this.meta.threeDayLoadComplete=!0,this.meta.sevenDayLoadComplete=!0,this.meta.fourteenDayLoadComplete=!0,this.meta.dataTier="14d",this.saveToStorage()}catch(n){this.statusMessage="Load failed"}finally{this.isTopologyLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}async poll(){try{const e=await this.fetchRecentPackets(100);if(e.success&&e.data){const t=this.packets.size;this.mergePackets(e.data),this.packets.size>t&&(this.saveToStorage(),this.notifyListeners())}}catch(e){}return this.getPackets()}clear(){this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta={oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1},this.clearStorage(),this.notifyListeners()}mergePacketsDirectly(e){const t=this.packets.size;this.mergePackets(e);const s=this.packets.size-t;return s>0&&(this.enforceMemoryCap(),this.saveToStorage(),this.notifyListeners()),s}mergePackets(e){let t=!1;for(const s of e){const e=s.packet_hash;if(!e)continue;const n=s.timestamp??0,a=`${e}:${n}`;this.packets.has(a)||(this.packets.set(a,s),t=!0),(0===this.meta.oldestTimestamp||nthis.meta.newestTimestamp&&(this.meta.newestTimestamp=n)}t&&(this.sortedDirty=!0),this.meta.lastUpdated=Date.now(),this.meta.packetCount=this.packets.size}notifyListeners(){const e=this.getState();for(const t of this.listeners)t(e)}delay(e){return new Promise(t=>setTimeout(t,e))}async fetchChunkWithRetry(e,t,s,n,a){for(let o=0;o<3;o++)try{return await this.fetchFilteredPackets(e,t,!1,a)}catch(r){const e=2===o,t=1e3*Math.pow(2,o);r instanceof Error&&r.name,e||(this.statusMessage=`Retry in ${Math.round(t/1e3)}s...`,this.notifyListeners(),await this.delay(t))}return null}enforceMemoryCap(){if(this.packets.size<=Ti)return;const e=this.getPackets(),t=e.length-Ti;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(wi);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(xi);if(t){const e=JSON.parse(t);for(const t of e)t.packet_hash&&this.packets.set(t.packet_hash,t)}if(this.meta.lastUpdated>0&&Date.now()-this.meta.lastUpdated>vi)return void this.clear();this.meta.backgroundLoadComplete=!1,this.meta.threeDayLoadComplete=!1,this.meta.sevenDayLoadComplete=!1,this.meta.fourteenDayLoadComplete=!1,this.meta.dataTier="24h";const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(xi,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(xi),localStorage.setItem(wi,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(xi),localStorage.removeItem(wi)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await G(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Qo);return{getToken:e}},void 0),a=n(),r={};a&&(r.Authorization=`Bearer ${a}`);const o=await fetch(s,{headers:r});if(401===o.status&&!t){const{refreshToken:t}=await G(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Qo);return{refreshToken:e}},void 0);if(await t())return this.fetchRecentPackets(e,!0)}if(!o.ok)throw new Error(`API error: ${o.status}`);return o.json()}async fetchFilteredPackets(e,t=5e3,s=!1,n){const a=new URLSearchParams;a.set("limit",String(t)),void 0!==e&&a.set("end_timestamp",String(e-.001)),void 0!==n&&a.set("start_timestamp",String(n));const r=`/api/filtered_packets?${a}`,{getToken:o}=await G(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Qo);return{getToken:e}},void 0),i=o(),l={};i&&(l.Authorization=`Bearer ${i}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(r,{headers:l,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await G(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Qo);return{refreshToken:e}},void 0);if(await s())return this.fetchFilteredPackets(e,t,!0)}if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}finally{clearTimeout(u)}}};function Li(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Ni(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const _i=new class{constructor(){t(this,"worker",null),t(this,"listeners",new Set),t(this,"currentTopology",{edges:[],validatedEdges:[],weakEdges:[],certainEdges:[],uncertainEdges:[],edgeMap:new Map,maxPacketCount:0,maxCertainCount:0,neighborAffinity:new Map,fullAffinity:new Map,localPrefix:null,centrality:new Map,hubNodes:[],gatewayNodes:[],loops:[],loopEdgeKeys:new Set,txDelayRecommendations:new Map,pathRegistry:Ni(),edgeBetweenness:new Map,backboneEdges:[],nodeMobility:new Map,mobileNodes:[],pathHealth:[],lastHopNeighbors:[],disambiguationStats:{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:[],viterbiStats:{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map,communityCount:0,backboneNodes:[]}),t(this,"isComputing",!1),t(this,"pendingRequest",null),t(this,"debounceTimer",null),t(this,"debounceMs",100),this.initWorker()}initWorker(){if("undefined"!=typeof window)try{this.worker=new Worker(new URL("/assets/topology.worker-B6JO1dmH.js",import.meta.url),{type:"module"}),this.worker.onmessage=e=>{this.handleWorkerMessage(e.data)},this.worker.onerror=e=>{}}catch(e){}}handleWorkerMessage(e){if(this.isComputing=!1,"error"!==e.type){var t;this.currentTopology={edges:(t=e.payload).edges??[],validatedEdges:t.validatedEdges??[],weakEdges:t.weakEdges??[],certainEdges:t.certainEdges??[],uncertainEdges:t.uncertainEdges??[],maxPacketCount:t.maxPacketCount??0,maxCertainCount:t.maxCertainCount??0,localPrefix:t.localPrefix??null,hubNodes:t.hubNodes??[],gatewayNodes:t.gatewayNodes??[],edgeMap:new Map(t.edgeMapEntries??[]),neighborAffinity:new Map(t.neighborAffinityEntries??[]),fullAffinity:new Map(t.fullAffinityEntries??[]),centrality:new Map(t.centralityEntries??[]),loops:t.loops??[],loopEdgeKeys:new Set(t.loopEdgeKeyEntries??[]),txDelayRecommendations:new Map(t.txDelayRecommendationEntries??[]),pathRegistry:t.pathRegistry?Li(t.pathRegistry):Ni(),edgeBetweenness:new Map(t.edgeBetweennessEntries??[]),backboneEdges:t.backboneEdges??[],nodeMobility:new Map(t.nodeMobilityEntries??[]),mobileNodes:t.mobileNodes??[],pathHealth:t.pathHealth??[],lastHopNeighbors:t.lastHopNeighbors??[],disambiguationStats:t.disambiguationStats??{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:t.discoveredNodes??[],viterbiStats:t.viterbiStats??{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map(t.nodeMetricsEntries??[]),communityCount:t.communityCount??0,backboneNodes:t.backboneNodes??[]};for(const t of this.listeners)try{t(this.currentTopology,e.computeTimeMs)}catch(s){}if(this.pendingRequest){const e=this.pendingRequest;this.pendingRequest=null,this.computeInternal(e)}}}computeInternal(e){if(!this.worker)return;this.isComputing=!0;const t={type:"compute",payload:e};this.worker.postMessage(t)}compute(e,t,s,n,a,r,o,i){const l={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:r,zeroHopNeighbors:o,terrainGrid:i,enableTerrainAware:void 0!==i};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=l:this.computeInternal(l)},this.debounceMs)}subscribe(e){return this.listeners.add(e),this.currentTopology.edges.length>0&&e(this.currentTopology,0),()=>{this.listeners.delete(e)}}getTopology(){return this.currentTopology}isWorking(){return this.isComputing}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},Ei=new class{constructor(){t(this,"worker",null),t(this,"listeners",new Set),t(this,"sparklines",new Map),t(this,"isComputing",!1),t(this,"lastComputeTimeMs",0),t(this,"pendingRequest",null),t(this,"debounceTimer",null),t(this,"debounceMs",150),this.initWorker()}initWorker(){if("undefined"!=typeof window)try{this.worker=new Worker(new URL("/assets/sparkline.worker-CmKhBAy5.js",import.meta.url),{type:"module"}),this.worker.onmessage=e=>{this.handleWorkerMessage(e.data)},this.worker.onerror=e=>{this.isComputing=!1,this.notifyListeners()}}catch(e){}}handleWorkerMessage(e){if(this.isComputing=!1,"error"!==e.type){if(this.sparklines=new Map(e.payload.sparklineEntries),this.lastComputeTimeMs=e.computeTimeMs,this.notifyListeners(),this.pendingRequest){const e=this.pendingRequest;this.pendingRequest=null,this.computeInternal(e.packets,e.nodeHashes)}}else this.notifyListeners()}computeInternal(e,t){if(!this.worker)return;if(0===t.length)return this.isComputing=!1,void this.notifyListeners();this.isComputing=!0,this.notifyListeners();const s={type:"compute",payload:{packets:e,nodeHashes:t}};this.worker.postMessage(s)}notifyListeners(){for(const t of this.listeners)try{t(this.sparklines,this.isComputing)}catch(e){}}compute(e,t){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest={packets:e,nodeHashes:t}:this.computeInternal(e,t)},this.debounceMs)}getSparkline(e){return this.sparklines.get(e)??[]}getAllSparklines(){return this.sparklines}hasSparkline(e){return this.sparklines.has(e)}isWorking(){return this.isComputing}getLastComputeTime(){return this.lastComputeTimeMs}subscribe(e){return this.listeners.add(e),e(this.sparklines,this.isComputing),()=>{this.listeners.delete(e)}}clear(){this.sparklines.clear(),this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},Pi=new class{constructor(){t(this,"worker",null),t(this,"isInitialized",!1),t(this,"statsListeners",new Set),t(this,"packetsListeners",new Set),t(this,"errorListeners",new Set),t(this,"readyResolve",null),t(this,"readyPromise",null),t(this,"unsubscribeTokenChange",null)}async init(e){if(!this.isInitialized&&"undefined"!=typeof window){this.readyPromise=new Promise(e=>{this.readyResolve=e});try{this.worker=new Worker(new URL("/assets/polling.worker-DFp1Qyu0.js",import.meta.url),{type:"module"}),this.worker.onmessage=this.handleMessage.bind(this),this.worker.onerror=e=>{};const t={type:"init",config:{apiBaseUrl:e.apiBaseUrl,authToken:e.authToken,statsIntervalMs:e.statsIntervalMs??3e3,packetsIntervalMs:e.packetsIntervalMs??3e3}};this.worker.postMessage(t),this.isInitialized=!0,this.unsubscribeTokenChange=_o(e=>{this.setAuthToken(e)}),await this.readyPromise}catch(t){throw t}}}handleMessage(e){var t;const s=e.data;switch(s.type){case"ready":null==(t=this.readyResolve)||t.call(this);break;case"stats":for(const e of this.statsListeners)try{e(s.data,s.timestamp)}catch(n){}break;case"packets":for(const e of this.packetsListeners)try{e(s.newPackets,s.totalCount,s.newestTimestamp)}catch(n){}break;case"packetsReset":for(const e of this.packetsListeners)try{e([],0,s.newestTimestamp)}catch(n){}break;case"error":for(const e of this.errorListeners)try{e(s.source,s.error)}catch(n){}}}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onPackets(e){return this.packetsListeners.add(e),()=>this.packetsListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}setAuthToken(e){if(!this.worker)return;const t={type:"setAuth",token:e};this.worker.postMessage(t)}setLiveMode(e){if(!this.worker)return;const t={type:"setLiveMode",enabled:e};this.worker.postMessage(t)}forceRefresh(){this.worker&&this.worker.postMessage({type:"forceRefresh"})}clearCache(){this.worker&&this.worker.postMessage({type:"clearCache"})}setTimeWindow(e){if(!this.worker)return;const t={type:"setTimeWindow",hours:e};this.worker.postMessage(t)}terminate(){if(this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.worker){const e={type:"stop"};this.worker.postMessage(e),this.worker.terminate(),this.worker=null}this.isInitialized=!1,this.statsListeners.clear(),this.packetsListeners.clear(),this.errorListeners.clear()}isReady(){return this.isInitialized}},Di=new class{constructor(){t(this,"ws",null),t(this,"connectionState","disconnected"),t(this,"reconnectAttempts",0),t(this,"pingIntervalId",null),t(this,"lastPongTime",Date.now()),t(this,"reconnectTimeoutId",null),t(this,"packetListeners",new Set),t(this,"statsListeners",new Set),t(this,"systemStatsListeners",new Set),t(this,"packetStatsListeners",new Set),t(this,"connectionListeners",new Set),t(this,"unsubscribeTokenChange",null),t(this,"wsSupported",!0)}buildWsUrl(){const e=Ao(),t=Po(),s=new URLSearchParams;e&&s.set("token",e),t&&s.set("client_id",t);const n=s.toString()?`?${s.toString()}`:"";return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws/packets${n}`}connect(){var e,t;if((null==(e=this.ws)?void 0:e.readyState)!==WebSocket.OPEN&&(null==(t=this.ws)?void 0:t.readyState)!==WebSocket.CONNECTING&&this.wsSupported){this.setConnectionState("connecting");try{const e=this.buildWsUrl();this.ws=new WebSocket(e),this.ws.onopen=this.handleOpen.bind(this),this.ws.onmessage=this.handleMessage.bind(this),this.ws.onerror=this.handleError.bind(this),this.ws.onclose=this.handleClose.bind(this),this.unsubscribeTokenChange||(this.unsubscribeTokenChange=_o(e=>{e&&"connected"===this.connectionState&&(this.disconnect(),this.connect())}))}catch(s){this.wsSupported=!1,this.setConnectionState("disconnected")}}}disconnect(){this.clearPingInterval(),this.clearReconnectTimeout(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING||this.ws.close(1e3,"Client disconnect"),this.ws=null),this.setConnectionState("disconnected"),this.reconnectAttempts=0}isConnected(){var e;return(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}isSupported(){return this.wsSupported}send(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return!1}}onPacket(e){return this.packetListeners.add(e),()=>this.packetListeners.delete(e)}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onSystemStats(e){return this.systemStatsListeners.add(e),()=>this.systemStatsListeners.delete(e)}onPacketStats(e){return this.packetStatsListeners.add(e),()=>this.packetStatsListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),e(this.connectionState,this.reconnectAttempts),()=>this.connectionListeners.delete(e)}handleOpen(){this.setConnectionState("connected"),this.reconnectAttempts=0,this.lastPongTime=Date.now();const e=Ao();e&&this.ws&&this.ws.send(JSON.stringify({type:"auth",token:e})),this.startPingInterval()}handleMessage(e){try{const t=JSON.parse(e.data);switch(t.type){case"packet":this.notifyPacketListeners(t.data);break;case"stats":{const e=t.data;e&&"noise_floor_dbm"in e&&this.notifyStatsListeners(e),(null==e?void 0:e.packet_stats)&&this.notifyPacketStatsListeners(e.packet_stats),(null==e?void 0:e.system_stats)&&this.notifySystemStatsListeners(e.system_stats);break}case"packet_stats":{const e=t.data;this.notifyPacketStatsListeners(e);break}case"system_stats":this.notifySystemStatsListeners(t.data);break;case"ping":this.lastPongTime=Date.now(),this.send({type:"pong"});break;case"pong":this.lastPongTime=Date.now()}}catch(t){}}handleError(e){}handleClose(e){this.clearPingInterval(),1e3!==e.code?(1006===e.code&&this.reconnectAttempts,this.scheduleReconnect()):this.setConnectionState("disconnected")}setConnectionState(e){if(this.connectionState!==e){this.connectionState=e;for(const s of this.connectionListeners)try{s(e,this.reconnectAttempts)}catch(t){}}}notifyPacketListeners(e){for(const s of this.packetListeners)try{s(e)}catch(t){}}notifyStatsListeners(e){for(const s of this.statsListeners)try{s(e)}catch(t){}}notifySystemStatsListeners(e){for(const s of this.systemStatsListeners)try{s(e)}catch(t){}}notifyPacketStatsListeners(e){for(const s of this.packetStatsListeners)try{s(e)}catch(t){}}startPingInterval(){this.clearPingInterval(),this.pingIntervalId=setInterval(()=>{var e;(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN&&(this.send({type:"ping"}),Date.now()-this.lastPongTime>6e4&&(this.disconnect(),this.connect()))},3e4)}clearPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null)}scheduleReconnect(){if(this.reconnectAttempts>=20)return this.wsSupported=!1,void this.setConnectionState("disconnected");this.setConnectionState("reconnecting");const e=Math.min(1e3*Math.pow(2,Math.min(this.reconnectAttempts,5)),3e4);this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout(()=>{this.reconnectTimeoutId=null,this.connect()},e)}clearReconnectTimeout(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)}terminate(){this.disconnect(),this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.packetListeners.clear(),this.statsListeners.clear(),this.systemStatsListeners.clear(),this.packetStatsListeners.clear(),this.connectionListeners.clear()}},Ii=3e4,Fi=new class{constructor(){t(this,"staged",new Map),t(this,"recentlyConfirmed",new Map),t(this,"listeners",new Set),t(this,"pruneIntervalId",null),this.startPruneInterval()}stage(e){const t=e.packet_hash;if(!t)return;if(this.staged.has(t))return;const s=this.recentlyConfirmed.get(t);s&&Date.now()-s=100&&this.removeOldest(),this.staged.set(t,{packet:e,stagedAt:Date.now()}),this.notifyListeners())}confirm(e){this.staged.delete(e)&&this.notifyListeners()}confirmBatch(e){let t=!1;const s=Date.now();for(const n of e)this.recentlyConfirmed.set(n,s),this.staged.delete(n)&&(t=!0);if(this.recentlyConfirmed.size>200){const e=s-Ii;for(const[t,s]of this.recentlyConfirmed)s(t.packet.timestamp??0)-(e.packet.timestamp??0))}isPending(e){return!!e&&this.staged.has(e)}getPendingCount(){return this.staged.size}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clear(){this.staged.size>0&&(this.staged.clear(),this.notifyListeners())}terminate(){this.stopPruneInterval(),this.staged.clear(),this.listeners.clear()}notifyListeners(){const e=this.getPendingPackets();for(const s of this.listeners)try{s(e)}catch(t){}}pruneExpired(){const e=Date.now();let t=!1;for(const[s,n]of this.staged)e-n.stagedAt>Ii&&(this.staged.delete(s),t=!0);t&&this.notifyListeners()}removeOldest(){let e=null,t=1/0;for(const[s,n]of this.staged)n.stagedAtthis.pruneExpired(),1e4))}stopPruneInterval(){this.pruneIntervalId&&(clearInterval(this.pruneIntervalId),this.pruneIntervalId=null)}},Ai=w(e=>({connectionState:"disconnected",isSupported:!0,reconnectAttempt:0,lastConnected:null,initialize:()=>{Di.onConnectionChange((t,s)=>{e(e=>({connectionState:t,reconnectAttempt:s??0,isSupported:Di.isSupported(),lastConnected:"connected"===t?Date.now():e.lastConnected}))}),Di.connect()}})),Ri=.05,zi=1e3,Bi="terrarium";function Oi(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const $i=w((e,t)=>({terrainGrid:null,isLoading:!1,error:null,lastLoadedAt:null,cachedBounds:null,terrainDisambiguationEnabled:!0,loadTerrain:async(s,n)=>{const a=t();if(!(a.isLoading||(r=a.cachedBounds,o=s,r&&r.minLat<=o.minLat&&r.maxLat>=o.maxLat&&r.minLng<=o.minLng&&r.maxLng>=o.maxLng))){var r,o;e({isLoading:!0,error:null});try{n.getTerrain()||(n.getSource(Bi)||(n.addSource(Bi,{type:"raster-dem",tiles:["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],encoding:"terrarium",tileSize:256}),await new Promise((e,t)=>{const s=setTimeout(()=>t(new Error("Terrain source load timeout")),1e4),a=t=>{t.sourceId===Bi&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:Bi}),await new Promise(e=>setTimeout(e,500)));const t=await async function(e,t){const{minLat:s,maxLat:n,minLng:a,maxLng:r}=t;let o=Math.ceil((r-a)/.001),i=Math.ceil((n-s)/.001);o>zi&&(o=zi),i>zi&&(i=zi);const l=(r-a)/o,c=(n-s)/i,u=Math.max(l,c),d=new Float32Array(o*i);let h=0;for(let m=0;msetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:o,height:i,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(i){const t=i instanceof Error?i.message:"Unknown error loading terrain";e({isLoading:!1,error:t})}}},preloadFromNodes:async(e,s)=>{const n=function(e){const t=e.filter(e=>void 0!==e.latitude&&void 0!==e.longitude&&(0!==e.latitude||0!==e.longitude));if(0===t.length)return null;let s=1/0,n=-1/0,a=1/0,r=-1/0;for(const o of t)s=Math.min(s,o.latitude),n=Math.max(n,o.latitude),a=Math.min(a,o.longitude),r=Math.max(r,o.longitude);return{minLat:s-Ri,maxLat:n+Ri,minLng:a-Ri,maxLng:r+Ri}}(e);n&&await t().loadTerrain(n,s)},clearTerrain:()=>{e({terrainGrid:null,cachedBounds:null,lastLoadedAt:null,error:null})},setTerrainDisambiguationEnabled:t=>{e({terrainDisambiguationEnabled:t})},getTerrainGridForDisambiguation:()=>{const e=t();return e.terrainDisambiguationEnabled?e.terrainGrid:null}})),Wi="pymc-stealth-location";function Hi(e){if("undefined"!=typeof window)try{localStorage.setItem(Wi,JSON.stringify(e))}catch{}}function Ui(e){return!isNaN(e)&&e>=-90&&e<=90}function qi(e){return!isNaN(e)&&e>=-180&&e<=180}const Gi=function(){if("undefined"==typeof window)return{};try{const e=localStorage.getItem(Wi);if(!e)return{};const t=JSON.parse(e);if("number"==typeof t.latitude&&"number"==typeof t.longitude&&"boolean"==typeof t.enabled&&Ui(t.latitude)&&qi(t.longitude))return t}catch{}return{}}(),Ji=w((e,t)=>({latitude:Gi.latitude??null,longitude:Gi.longitude??null,enabled:Gi.enabled??!1,setLocation:(s,n)=>{Ui(s)&&qi(n)&&(e({latitude:s,longitude:n}),Hi({latitude:s,longitude:n,enabled:t().enabled}))},enable:()=>{const{latitude:s,longitude:n}=t();null!==s&&null!==n&&(e({enabled:!0}),Hi({latitude:s,longitude:n,enabled:!0}))},disable:()=>{e({enabled:!1});const{latitude:s,longitude:n}=t();null!==s&&null!==n&&Hi({latitude:s,longitude:n,enabled:!1})},clear:()=>{e({latitude:null,longitude:null,enabled:!1}),function(){if("undefined"!=typeof window)try{localStorage.removeItem(Wi)}catch{}}()},getEffectiveLocation:()=>{const{latitude:e,longitude:s,enabled:n}=t();return n&&null!==e&&null!==s?{latitude:e,longitude:s}:null},isActive:()=>{const{latitude:e,longitude:s,enabled:n}=t();return n&&null!==e&&null!==s}}));function Yi(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function Vi(e,t){let s=e.forwarded_path??e.original_path;if("string"==typeof s)try{s=JSON.parse(s)}catch{return null}if(!s||!Array.isArray(s)||0===s.length)return null;const n=s.map(e=>String(e).toUpperCase()),a=t?Yi(t):null,r=n[n.length-1],o=null!==a&&r===a,i=o?n.slice(0,-1):[...n];return{effective:i,original:n,hadLocal:o,effectiveLength:i.length}}function Ki(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const Xi=[{label:"20m",minutes:20,buckets:80},{label:"1h",minutes:60,buckets:80},{label:"3h",minutes:180,buckets:80},{label:"12h",minutes:720,buckets:80},{label:"24h",minutes:1440,buckets:80},{label:"3d",minutes:4320,buckets:80},{label:"7d",minutes:10080,buckets:80},{label:"14d",minutes:20160,buckets:80}],Qi=[{label:"1h",hours:1},{label:"3h",hours:3},{label:"12h",hours:12},{label:"24h",hours:24},{label:"3d",hours:72},{label:"7d",hours:168},{label:"14d",hours:336}];function Zi(e,t=12){return Math.max(t,Math.round(e/15))}const el={hero:Zi(1200),statsCard:Zi(380)};function tl(e){switch(e){case 1:return 3600;case 3:case 12:return 5400;case 24:return 8640;case 72:case 168:case 336:return 720;default:{const t=3600*e,s=Math.round(t/10);return Math.min(Math.max(360,s),720)}}}const sl="'JetBrains Mono', 'SF Mono', Monaco, monospace",nl={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},al={DEBUG:"text-sys-brown",INFO:"text-sys-cyan",WARNING:"text-sys-amber",ERROR:"text-sys-red",CRITICAL:"text-sys-pink"};function rl(e){return al[e]??"text-text-muted border-border-subtle"}const ol="pymc-resource-history",il="pymc-resource-last-fetch",ll="pymc-hidden-contacts",cl="pymc-quick-neighbors",ul="pymc-local-hash",dl="pymc-global-time-range";let hl=null,ml=null;function fl(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function gl(e){return 4===(e.type??e.payload_type)&&!0!==e.transmitted&&function(e){const t=function(e){if(Array.isArray(e))return e;if("string"==typeof e&&e.startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return[]}(e.original_path),s=e.route??e.route_type;return 2===(n=s)||3===n?0===t.length:Tr(s)?t.length<=1:0===t.length;var n}(e)}function pl(e,t,s,n){if(!e)return null;let a=e;if(e.length<=4){const n=e.replace(/^0x/i,"").toUpperCase();if(n===t)return null;const r=s.get(n);if(!r)return null;a=r}return n.has(a)?Yi(a)===t?null:a:null}function bl(e,t){e.count++,void 0!==t.rssi&&null!==t.rssi&&(e.rssiSum+=t.rssi,e.rssiCount++),void 0!==t.snr&&null!==t.snr&&(e.snrSum+=t.snr,e.snrCount++);const s=t.timestamp??0;s>e.lastSeen&&(e.lastSeen=s)}function yl(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function xl(e,t){const s=fl(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:Yi(e.hash),count:e.count,avgRssi:e.rssiCount>0?e.rssiSum/e.rssiCount:null,avgSnr:e.snrCount>0?e.snrSum/e.snrCount:null,lastSeen:e.lastSeen,status:s}}function wl(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(cl);if(e)return JSON.parse(e)}catch{}return[]}function vl(e){"undefined"!=typeof window&&(ml&&clearTimeout(ml),ml=setTimeout(()=>{try{localStorage.setItem(cl,JSON.stringify(e))}catch{}ml=null},1e3))}function kl(){if("undefined"!=typeof window)try{const e=localStorage.getItem(ul);if(e)return e}catch{}}function Sl(e){if("undefined"!=typeof window)try{localStorage.setItem(ul,e)}catch{}}function Cl(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(ol);if(e)return JSON.parse(e)}catch{}return[]}function jl(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(ll);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Tl(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(il);if(e)return parseInt(e,10)||0}catch{}return 0}function Ml(){if("undefined"==typeof window)return 4;try{const e=localStorage.getItem(dl);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<=7)return t}}catch{}return 4}const Ll=w((e,t)=>({stats:null,statsLoading:!1,statsError:null,packets:[],packetsLoading:!1,packetsError:null,lastPacketTimestamp:0,logs:[],logsLoading:!1,liveMode:!0,flashReceived:0,flashAdvert:0,pendingAdvertLocalHash:null,pendingAdvertTimestamp:null,resourceHistory:Cl(),lastResourceFetch:Tl(),hiddenContacts:jl(),quickNeighbors:wl(),cachedLocalHash:kl(),initialized:!1,packetCacheState:Mi.getState(),mutationsInFlight:new Set,globalTimeRangeIndex:Ml(),initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),Mi.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await oi(),a=n.neighbors??{},r=Date.now(),o=[];for(const[e,t]of Object.entries(a)){if(s.has(e))continue;if(!t.zero_hop)continue;const n=fl(t.last_seen??0,r);"expired"!==n&&o.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:n})}o.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const i=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:o,cachedLocalHash:i}),vl(o),i&&Sl(i);const l=()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},c=await Mi.initialLoad(l);if(c.length>0){const s=c.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...c],packetsLoading:!1,lastPacketTimestamp:s}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}else e({packetsLoading:!1})}catch(n){e({statsError:n instanceof Error?n.message:"Failed to initialize",statsLoading:!1,packetsLoading:!1})}Ai.getState().initialize(),Di.onPacket(s=>{const{lastPacketTimestamp:n,mutationsInFlight:a}=t();if(a.size>0)return;Fi.stage(s);const r=s.timestamp??0;r>n&&e({flashReceived:t().flashReceived+1,lastPacketTimestamp:r})}),Di.onStats(s=>{const{mutationsInFlight:n,hiddenContacts:a}=t();if(n.size>0)return;const r=s.neighbors??{},o=Date.now(),i=[];for(const[e,t]of Object.entries(r)){if(a.has(e))continue;if(!t.zero_hop)continue;const s=fl(t.last_seen??0,o);"expired"!==s&&i.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}i.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const l=s.local_hash;e({stats:s,statsLoading:!1,statsError:null,quickNeighbors:i,cachedLocalHash:l}),vl(i),l&&Sl(l)}),Di.onPacketStats(s=>{const{stats:n,mutationsInFlight:a}=t();if(!n||a.size>0)return;const r={...n,rx_count:s.rx_count??n.rx_count,tx_count:s.tx_count??n.tx_count,forwarded_count:s.forwarded_count??n.forwarded_count,dropped_count:s.dropped_count??n.dropped_count};e({stats:r})});try{await Pi.init({apiBaseUrl:"",authToken:Ao()??void 0,statsIntervalMs:nl.stats,packetsIntervalMs:nl.packets}),Pi.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:r}=t();if(a.size>0)return;const o=s.neighbors??{},i=Date.now(),l=[];for(const[e,t]of Object.entries(o)){if(r.has(e))continue;if(!t.zero_hop)continue;const s=fl(t.last_seen??0,i);"expired"!==s&&l.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const c=s.local_hash;e({stats:s,statsLoading:!1,statsError:null,quickNeighbors:l,cachedLocalHash:c}),vl(l),c&&Sl(c)}),Pi.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:r}=t(),o=s.map(e=>e.packet_hash).filter(e=>!!e);Fi.confirmBatch(o),Mi.mergePacketsDirectly(s);const i=a>r;i&&ui();const l=Mi.getPackets();e({packets:l,packetsLoading:!1,packetsError:null,lastPacketTimestamp:a}),i&&t().triggerTopologyCompute()}),Pi.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||Pi.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},nl.stats),setInterval(()=>{e().liveMode&&!Mi.isHeavyLoadInProgress()&&e().fetchPackets()},nl.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":ii().catch(()=>{});break;case"/system":hi().catch(()=>{});break;case"/statistics":(async function(e=24){return ti(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),li(3).catch(()=>{});break;case"/settings":(async function(){return ti("/api/radio_presets")})().catch(()=>{})}},fetchStats:async s=>{const{stats:n,mutationsInFlight:a,hiddenContacts:r}=t();if(!(a.size>0)||(null==s?void 0:s.force)){n||e({statsLoading:!0}),e({statsError:null});try{const t=await oi(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,i]of Object.entries(s)){if(r.has(e))continue;if(!i.zero_hop)continue;const t=fl(i.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:Yi(e),count:i.advert_count??0,avgRssi:i.rssi??null,avgSnr:i.snr??null,lastSeen:i.last_seen??0,status:t})}a.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const o=t.local_hash;e({stats:t,statsLoading:!1,quickNeighbors:a,cachedLocalHash:o}),vl(a),o&&Sl(o)}catch(o){e({statsError:o instanceof Error?o.message:"Failed to fetch stats",statsLoading:!1})}}},fetchPackets:async s=>{const{packets:n,lastPacketTimestamp:a}=t();0===n.length&&e({packetsLoading:!0}),e({packetsError:null});try{const s=await Mi.poll(),r=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,o=r>a&&a>0,i=s.length!==n.length||o;o&&(e({flashReceived:t().flashReceived+1}),ui()),e(i?{packets:s,packetsLoading:!1,lastPacketTimestamp:r||a}:{packetsLoading:!1}),o&&t().triggerTopologyCompute()}catch(r){e({packetsError:r instanceof Error?r.message:"Failed to fetch packets",packetsLoading:!1})}},fetchLogs:async()=>{const{logs:s}=t();0===s.length&&e({logsLoading:!0});try{const t=await ii();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),Pi.isReady()&&Pi.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),r=new Set(a);r.add(n),e({mutationsInFlight:r});try{if(!(await pi(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(o){const{mutationsInFlight:s}=t(),a=new Set(s);throw a.delete(n),e({mutationsInFlight:a}),o}},clearModeMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setMode"),e({mutationsInFlight:n})},setDutyCycle:async s=>{const n="setDutyCycle",{mutationsInFlight:a}=t(),r=new Set(a);r.add(n),e({mutationsInFlight:r});try{if(!(await bi(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}finally{const{mutationsInFlight:s}=t(),a=new Set(s);a.delete(n),e({mutationsInFlight:a})}},setDutyCycleConfig:async s=>{var n;const a="setDutyCycleConfig",{mutationsInFlight:r}=t(),o=new Set(r);o.add(a),e({mutationsInFlight:o});try{const e=await async function(e){return ti("/api/update_duty_cycle_config",{method:"POST",body:JSON.stringify(e)})}(s);if(!e.success&&!(null==(n=e.data)?void 0:n.persisted))throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(i){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),i}},clearDutyCycleMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setDutyCycleConfig"),e({mutationsInFlight:n})},startMutation:s=>{const{mutationsInFlight:n}=t(),a=new Set(n);a.add(s),e({mutationsInFlight:a})},clearMutation:s=>{const{mutationsInFlight:n}=t(),a=new Set(n);a.delete(s),e({mutationsInFlight:a})},sendAdvert:async()=>{try{const s=await gi();return s.success?(e({flashAdvert:t().flashAdvert+1}),{success:!0}):{success:!1,error:s.error||"Failed to send advert"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Unknown error"}}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const r=Date.now(),{lastResourceFetch:o,resourceHistory:i}=t();if(r-o<1e3)return;const l=[...i,{timestamp:r,time:new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=l.length>a?l.slice(-a):l;var u,d;e({resourceHistory:c,lastResourceFetch:r}),u=c,d=r,"undefined"!=typeof window&&(hl&&clearTimeout(hl),hl=setTimeout(()=>{try{localStorage.setItem(ol,JSON.stringify(u)),localStorage.setItem(il,d.toString())}catch{}hl=null},1e3))},hideContact:s=>{const{hiddenContacts:n}=t(),a=new Set(n);a.add(s),e({hiddenContacts:a}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(ll,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{Mi.clear(),e({packets:[],lastPacketTimestamp:0}),Mi.quickLoad().then(s=>{if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:s,lastPacketTimestamp:n}),t().triggerTopologyCompute()}})},triggerTopologyCompute:()=>{var e,s,n,a;const{packets:r,stats:o,hiddenContacts:i}=t();if(0===r.length||!o)return;const l=o.neighbors??{},c=Object.fromEntries(Object.entries(l).filter(([e])=>!i.has(e))),u=o.local_hash;let d=null==(s=null==(e=o.config)?void 0:e.repeater)?void 0:s.latitude,h=null==(a=null==(n=o.config)?void 0:n.repeater)?void 0:a.longitude;if(!d||!h||0===d&&0===h){const e=Ji.getState().getEffectiveLocation();e&&(d=e.latitude,h=e.longitude)}const m=[];for(const[t,g]of Object.entries(c))g.zero_hop&&m.push({hash:t,advertCount:g.advert_count??1,avgRssi:g.rssi??null,avgSnr:g.snr??null,lastSeen:g.last_seen??0,latitude:g.latitude,longitude:g.longitude});const f=$i.getState().getTerrainGridForDisambiguation();_i.compute(r,c,u,d,h,void 0,m,f??void 0)},triggerDeepAnalysis:async()=>{await Mi.forceDeepLoad();const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:s,lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},updateQuickNeighbors:()=>{const{packets:s,stats:n,hiddenContacts:a}=t();if(0===s.length||!n)return;const r=n.neighbors??{},o=function(e,t,s){if(!s||0===e.length||0===Object.keys(t).length)return[];const n=Date.now(),a=Yi(s),r=new Set(Object.keys(t)),o=function(e){var t,s;const n=new Map;for(const a of Object.keys(e)){const r=Yi(a),o=n.get(r);if(o){const i=null==(t=e[o])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!i&&n.set(r,a)}else n.set(r,a)}return n}(t),i=new Map;for(const c of e){if(!gl(c))continue;const e=pl(c.src_hash,a,o,r);if(!e)continue;let t=i.get(e);t||(t=yl(e),i.set(e,t)),bl(t,c)}for(const[c,u]of Object.entries(t))Yi(c)!==a&&u.zero_hop&&!i.has(c)&&i.set(c,{hash:c,count:u.advert_count??0,rssiSum:u.rssi??0,rssiCount:void 0!==u.rssi?1:0,snrSum:u.snr??0,snrCount:void 0!==u.snr?1:0,lastSeen:u.last_seen??0});const l=[];for(const c of i.values()){const e=xl(c,n);e&&l.push(e)}return l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),l}(s,Object.fromEntries(Object.entries(r).filter(([e])=>!a.has(e))),n.local_hash),i=t().quickNeighbors;(o.length!==i.length||o.some((e,t)=>{var s,n;return e.hash!==(null==(s=i[t])?void 0:s.hash)||e.count!==(null==(n=i[t])?void 0:n.count)}))&&(e({quickNeighbors:o}),vl(o))},triggerSparklineCompute:()=>{const{packets:e,stats:s,hiddenContacts:n}=t();if(0===e.length||!s)return;const a=s.neighbors??{},r=Object.keys(a).filter(e=>!n.has(e));0!==r.length&&Ei.compute(e,r)},requestSevenDayData:async()=>{await Mi.loadSevenDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestThreeDayData:async()=>{await Mi.loadThreeDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestFourteenDayData:async()=>{await Mi.loadFourteenDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},setGlobalTimeRange:s=>{e({globalTimeRangeIndex:s}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(dl,e.toString())}catch{}}(s);const n={0:1,1:1,2:3,3:12,4:24,5:72,6:168,7:336}[s]??24;Pi.setTimeWindow(n);const{packetCacheState:a,requestThreeDayData:r,requestSevenDayData:o,requestFourteenDayData:i,triggerTopologyCompute:l,triggerSparklineCompute:c}=t();let u=!1;5!==s||a.threeDayLoadComplete||a.isBackgroundLoading||(r(),u=!0),6!==s||a.sevenDayLoadComplete||a.isBackgroundLoading||(o(),u=!0),7!==s||a.fourteenDayLoadComplete||a.isBackgroundLoading||(i(),u=!0),!u&&s>=5&&(l(),c())}})),Nl=Ll,_l=()=>Ll(e=>e.stats),El=()=>Ll(e=>e.statsError),Pl=()=>Ll(e=>e.packets),Dl=()=>Ll(e=>e.packetsLoading),Il=()=>Ll(e=>e.logs),Fl=()=>Ll(e=>e.logsLoading),Al=()=>Ll(e=>e.liveMode),Rl=()=>Ll(e=>e.fetchLogs),zl=()=>Ll(e=>e.setLiveMode),Bl=()=>Ll(e=>e.resourceHistory),Ol=()=>Ll(e=>e.addResourceDataPoint),$l=()=>Ll(e=>e.hiddenContacts),Wl=()=>Ll(e=>e.hideContact),Hl=()=>Ll(e=>e.packetCacheState),Ul=()=>Ll(e=>e.triggerDeepAnalysis),ql=()=>Ll(e=>e.quickNeighbors),Gl=()=>Ll(e=>e.cachedLocalHash),Jl=()=>Ll(e=>e.lastPacketTimestamp),Yl=()=>Ll(e=>e.globalTimeRangeIndex),Vl=()=>Ll(e=>e.setGlobalTimeRange),Kl=()=>Ll(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete);function Xl(){const e=Ll(e=>{var t,s,n;return null==(n=null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.repeater)?void 0:n.latitude}),t=Ll(e=>{var t,s,n;return null==(n=null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.repeater)?void 0:n.longitude}),s=Ll(e=>{var t,s,n;return(null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.node_name)||(null==(n=e.stats)?void 0:n.node_name)||"Local Node"}),n=Ji(e=>e.latitude),a=Ji(e=>e.longitude),r=Ji(e=>e.enabled);return e&&t&&(0!==e||0!==t)?{latitude:e,longitude:t,name:s,isStealth:!1}:r&&null!==n&&null!==a?{latitude:n,longitude:a,name:s,isStealth:!0}:null}const Ql={rx:{p3:"color(display-p3 0.2 1 0.4)",fallback:"#00FF66"},tx:{p3:"color(display-p3 1 0.9 0.2)",fallback:"#FFDD00"}};function Zl({showLabel:e=!1,className:t}){var a;const r=Ll(e=>e.flashReceived),o=Ll(e=>e.flashAdvert),i=Ai(e=>"connected"===e.connectionState),[l,c]=s.useState("idle"),u=s.useRef(0),d=s.useRef(0);s.useEffect(()=>{if(r<=0)return;const e=Date.now();if(e-u.current<50)return;u.current=e,c("rx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[r]),s.useEffect(()=>{if(o<=0)return;const e=Date.now();if(e-d.current<50)return;d.current=e,c("tx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[o]);const h="rx"===l?Ql.rx:"tx"===l?Ql.tx:null;return n.jsxs("span",{className:J("inline-flex items-center gap-2",t),title:i?"Real-time (WebSocket)":"Database polling",children:[n.jsx("span",{className:"inline-flex rounded-full w-1.5 h-1.5",style:h?{backgroundColor:h.fallback,...(null==(a=CSS.supports)?void 0:a.call(CSS,"color","color(display-p3 1 1 1)"))&&{backgroundColor:h.p3}}:{backgroundColor:"var(--livedot-idle)"}}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:i?"Live":"DB"})]})}function ec({borderRadius:e}){return n.jsx(c.div,{initial:{opacity:0},animate:{opacity:.8,backgroundPosition:["200% 0%","-200% 0%"]},exit:{opacity:0},transition:{opacity:{duration:.2},backgroundPosition:{duration:2,ease:"easeInOut",repeat:1/0}},style:{position:"absolute",inset:0,zIndex:1,pointerEvents:"none",borderRadius:e,padding:2,background:"linear-gradient(\n 90deg,\n transparent 0%,\n transparent 25%,\n var(--accent-primary) 50%,\n transparent 75%,\n transparent 100%\n )",backgroundSize:"200% 100%",mask:"\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0)\n ",maskComposite:"exclude",WebkitMaskComposite:"xor"}})}function tc({children:e,isLoading:t=!0,className:s,borderRadius:a=12}){return n.jsxs("div",{className:J("relative overflow-hidden",s),style:{borderRadius:a},children:[n.jsx(i,{children:t&&n.jsx(ec,{borderRadius:a})}),n.jsx("div",{className:"relative z-10",children:e})]})}function sc({className:e}){return n.jsx("div",{className:J("relative w-10 h-1 rounded-sm overflow-hidden","bg-bg-elevated",e),children:n.jsx(c.div,{animate:{backgroundPosition:["200% 0%","-200% 0%"]},transition:{duration:1.5,ease:"easeInOut",repeat:1/0},className:"absolute inset-0",style:{background:"linear-gradient(\n 90deg,\n transparent 0%,\n var(--accent-primary) 50%,\n transparent 100%\n )",backgroundSize:"200% 100%"}})})}const nc=w(e=>({sparklines:new Map,isComputing:!1,lastUpdated:0,nodeCount:0,setSparklines:t=>e({sparklines:t,lastUpdated:Date.now(),nodeCount:t.size,isComputing:!1}),setComputing:t=>e({isComputing:t})}));"undefined"!=typeof window&&setTimeout(()=>{Ei.subscribe((e,t)=>{const s=nc.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const ac=()=>nc(e=>e.isComputing),rc=[],oc=new Map;function ic(e){return nc(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return rc;const n=oc.get(e);return n===s?n:(oc.set(e,s),s)})}const lc=w(e=>({topology:{edges:[],validatedEdges:[],weakEdges:[],certainEdges:[],uncertainEdges:[],edgeMap:new Map,maxPacketCount:0,maxCertainCount:0,neighborAffinity:new Map,fullAffinity:new Map,localPrefix:null,centrality:new Map,hubNodes:[],gatewayNodes:[],loops:[],loopEdgeKeys:new Set,txDelayRecommendations:new Map,pathRegistry:Ni(),edgeBetweenness:new Map,backboneEdges:[],nodeMobility:new Map,mobileNodes:[],pathHealth:[],lastHopNeighbors:[],disambiguationStats:{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:[],viterbiStats:{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map,communityCount:0,backboneNodes:[]},isComputing:!1,lastComputeTimeMs:0,lastUpdated:0,setTopology:(t,s)=>e({topology:t,lastComputeTimeMs:s,lastUpdated:Date.now(),isComputing:!1}),setComputing:t=>e({isComputing:t})}));"undefined"!=typeof window&&_i.subscribe((e,t)=>{lc.getState().setTopology(e,t)});const cc=()=>lc(e=>e.topology),uc=()=>lc(e=>e.topology.hubNodes),dc=()=>lc(e=>e.topology.centrality),hc=()=>lc(e=>e.topology.fullAffinity);let mc=null,fc=null,gc=null,pc=null;const bc=()=>lc(e=>(e.topology.hubNodes!==fc&&(fc=e.topology.hubNodes,mc=new Set(e.topology.hubNodes)),mc)),yc=()=>lc(e=>e.topology.pathHealth),xc=()=>lc(e=>e.topology.disambiguationStats),wc=()=>lc(e=>e.topology.disambiguationStats.highCollisionPrefixes),vc=()=>lc(e=>e.topology.disambiguationStats.totalPrefixes>0),kc=()=>lc(e=>e.topology.discoveredNodes),Sc=()=>lc(e=>e.topology.viterbiStats),Cc=()=>lc(e=>(e.topology.discoveredNodes!==pc&&(pc=e.topology.discoveredNodes,gc=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),gc)),jc=()=>lc(e=>e.topology.nodeMetrics);let Tc=null,Mc=null;const Lc=()=>lc(e=>{if(e.topology.nodeMetrics!==Mc){Mc=e.topology.nodeMetrics,Tc={local:0,hub:0,gateway:0,backbone:0,neighbor:0,mobile:0,ghost:0,standard:0};for(const t of e.topology.nodeMetrics.values())Tc[t.nodeClass]++}return Tc});function Nc(e){if(e<60)return`${Math.floor(e)}s`;const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),n=Math.floor(e%3600/60),a=[];return t>0&&a.push(`${t}d`),s>0&&a.push(`${s}h`),(n>0||0===a.length)&&a.push(`${n}m`),a.join(" ")}function _c(e){const t=Date.now()/1e3-e;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Ec(e){return new Date(1e3*e).toLocaleString()}function Pc(e){const t=new Date(1e3*e);return`${t.toLocaleString("en-US",{month:"short"})} ${t.getDate()}, ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}`}function Dc(e){return new Date(1e3*e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ic(e){return`${(e/1e6).toFixed(3)} MHz`}function Fc(e){return`${(e/1e3).toFixed(1)} kHz`}function Ac(e){const t=e>1e12?e:1e3*e,s=Date.now(),n=Math.abs(s-t),a=Math.floor(n/1e3),r=Math.floor(a/60),o=Math.floor(r/60),i=Math.floor(o/24);return i>0?`${i} day${1!==i?"s":""}`:o>0?`${o} hour${1!==o?"s":""}`:r>0?`${r} minute${1!==r?"s":""}`:`${a} second${1!==a?"s":""}`}function Rc(e){e<0&&(e=0);const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60);if(n>0){const e=s%60;return e>0?`${n}h ${e}m`:`${n}h`}if(s>0){const e=t%60;return e>0?`${s}m ${e}s`:`${s}m`}if(t>0){const s=e%1e3;return s>0?`${t}.${Math.floor(s/100)}s`:`${t}s`}return`${e}ms`}const zc=[{name:"Dashboard",to:"/",icon:k},{name:"Contacts",to:"/contacts",icon:S},{name:"Packets",to:"/packets",icon:C},{name:"Statistics",to:"/statistics",icon:j},{name:"MeshGraph",to:"/meshgraph",icon:T},{name:"System",to:"/system",icon:M},{name:"Logs",to:"/logs",icon:L},{name:"Terminal",to:"/terminal",icon:N},{name:"Configuration",to:"/configuration",icon:_}],Bc="pymc-controls-expanded",Oc=()=>{if("undefined"==typeof window)return!0;const e=localStorage.getItem(Bc);return null===e||"true"===e};function $c(){var e,t,a,r,o,i;const{pathname:l}=v(),{stats:c,setMode:u,setDutyCycle:d,sendAdvert:h}=Nl(),m=Uo(),f=Ll(e=>e.prefetchForRoute),g=Hl(),p=Ll(e=>e.packetCacheState.dataTier),b=ac(),y=lc(e=>e.isComputing),x=Cc();let w=null;try{w=function(){const e=s.useContext(ho);if(!e)throw new Error("useSidebar must be used within a SidebarLayout");return e}()}catch{}const[k,S]=s.useState(!1),[C,j]=s.useState("idle"),[T,L]=s.useState(null),N=s.useRef(null),_=s.useCallback(e=>{e!==l&&(N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{f(e)},100))},[l,f]),B=s.useCallback(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);s.useEffect(()=>{const e=new MutationObserver(()=>{const e=document.querySelector("[data-controls-disclosure]");if(e){const t="true"===e.getAttribute("aria-expanded");localStorage.setItem(Bc,String(t))}}),t=document.querySelector("[data-controls-disclosure]");return t&&e.observe(t,{attributes:!0,attributeFilter:["aria-expanded"]}),()=>e.disconnect()},[]);const O=null==c?void 0:c.noise_floor_dbm,$=(null==(t=null==(e=null==c?void 0:c.config)?void 0:e.repeater)?void 0:t.mode)??"forward",W=(null==(r=null==(a=null==c?void 0:c.config)?void 0:a.duty_cycle)?void 0:r.enforcement_enabled)??!1,H=(null==(i=null==(o=null==c?void 0:c.config)?void 0:o.duty_cycle)?void 0:i.max_airtime_percent)??10,U=g.isLoading||g.isBackgroundLoading||g.isTopologyLoading,q=U||b||y,G=g.loadProgress,Y=()=>{null==w||w.close()};return n.jsxs(no,{children:[n.jsxs(ao,{className:"px-5 py-6",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(jo,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",So]})]}),n.jsxs(ro,{className:"py-4",children:[n.jsx(io,{children:zc.map(e=>{const t=l===e.to;return n.jsxs(lo,{href:e.to,current:t,onClick:Y,onMouseEnter:()=>_(e.to),onMouseLeave:B,children:[n.jsx(e.icon,{}),n.jsx(co,{children:e.name}),"/contacts"===e.to&&x.length>0&&n.jsxs(uo,{variant:"accent",children:[n.jsx(E,{className:"w-3 h-3"}),n.jsx("span",{children:x.length})]}),"/meshgraph"===e.to&&n.jsx(uo,{variant:"default",children:"Beta"})]},e.name)})}),q&&n.jsx("div",{className:"px-0 py-3",children:n.jsx(tc,{isLoading:U,borderRadius:12,children:n.jsxs("div",{className:"bg-glass-surface/50 rounded-xl p-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[n.jsxs("div",{className:"relative flex h-2 w-2",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-accent-primary"})]}),n.jsx("span",{className:"type-data-xs text-text-muted flex-1 truncate",children:g.isLoading&&G?"Loading 24h history...":g.isBackgroundLoading&&G?g.statusMessage||`Loading ${p} history...`:g.isTopologyLoading?"Loading topology data...":b?"Computing sparklines":y?"Building topology":"Analyzing database"}),null!==(null==G?void 0:G.percent)&&void 0!==(null==G?void 0:G.percent)&&U&&n.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[G.percent,"%"]})]}),n.jsx("div",{className:"mt-1.5 h-1 bg-subtle-fill rounded-full overflow-hidden",children:null!==(null==G?void 0:G.percent)&&void 0!==(null==G?void 0:G.percent)&&U?n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full transition-all duration-300 ease-out",style:{width:`${G.percent}%`}}):n.jsx("div",{className:"h-full bg-accent-primary/40 rounded-full w-full"})}),!U&&n.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"type-micro text-text-muted",children:"Data:"}),n.jsx("span",{className:"type-data-xs text-accent-primary",children:(e=>{switch(e){case"24h":return"24 hours";case"3d":return"3 days";case"7d":return"7 days";case"14d":return"14 days";default:return e}})(p)})]})]})})}),n.jsx("div",{className:"flex-1"}),n.jsx(ko,{label:"Controls",icon:n.jsx(F,{className:"w-5 h-5 text-accent-primary"}),defaultOpen:Oc(),direction:"up",dataId:"controls",children:n.jsxs("div",{className:"flex flex-col gap-2 px-1",children:[n.jsx(Wr,{color:"success"===C?"success":"error"===C?"danger":"primary",onClick:async()=>{S(!0),j("idle"),L(null);const e=await h();S(!1),e.success?(j("success"),setTimeout(()=>j("idle"),1500)):(j("error"),L(e.error||"Failed to send"),setTimeout(()=>{j("idle"),L(null)},3e3))},disabled:k,className:"w-full justify-center",children:k?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{"data-slot":"icon",className:"animate-spin",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Sending..."]}):"success"===C?n.jsxs(n.Fragment,{children:[n.jsx("svg",{"data-slot":"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent!"]}):"error"===C?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Failed"]}):n.jsxs(n.Fragment,{children:[n.jsx(P,{"data-slot":"icon"}),"Send Advert"]})}),T&&n.jsx("p",{className:"text-accent-danger text-xs text-center",children:T}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs text-text-muted",children:"Repeat"}),n.jsx("span",{className:J("text-xs font-medium","forward"===$?"text-accent-success":"text-accent-secondary"),children:"forward"===$?"ON":"OFF"})]}),n.jsx(Wr,{color:"forward"===$?"success":"warning",onClick:()=>{u("forward"===$?"monitor":"forward")},className:"w-full justify-center",children:"forward"===$?n.jsxs(n.Fragment,{children:[n.jsx(D,{"data-slot":"icon"}),"Repeating"]}):n.jsxs(n.Fragment,{children:[n.jsx(I,{"data-slot":"icon"}),"Monitor Only"]})}),n.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[n.jsx("span",{className:"text-xs text-text-muted",children:"Duty Cycle"}),n.jsx("span",{className:J("text-xs font-medium tabular-nums",W?"text-accent-secondary":"text-text-muted"),children:W?`${H}%`:"OFF"})]}),n.jsxs(Wr,{color:W?"warning":"muted",onClick:()=>{d(!W)},className:"w-full justify-center",children:[n.jsx(M,{"data-slot":"icon"}),W?`Limited to ${H}%`:"Disabled"]})]})})]}),n.jsxs(oo,{children:[void 0!==(null==c?void 0:c.uptime_seconds)&&n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3",children:[n.jsx(A,{className:"w-5 h-5 text-text-muted flex-shrink-0"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[Nc(c.uptime_seconds)," uptime"]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsx("div",{className:"bg-subtle-fill rounded-xl p-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(R,{className:"w-4 h-4 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted",children:"Noise Floor"})]}),n.jsx("span",{className:"type-data text-text-primary tabular-nums",children:null!=O?`${O.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3 border-t border-border-subtle",children:[n.jsx(Zl,{showLabel:!0}),(null==c?void 0:c.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted truncate max-w-[140px]",title:`v${c.version}`,children:["v",c.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:()=>{Vo(),window.location.href="/login"},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-text-muted hover:text-accent-danger hover:bg-accent-danger/10 transition-all duration-150",children:[n.jsx(z,{className:"w-4 h-4"}),n.jsx("span",{className:"type-body-sm",children:"Sign Out"}),m&&n.jsxs("span",{className:"ml-auto type-data-xs text-text-muted",children:["(",m,")"]})]})})]})]})}function Wc(){const e=Hl(),t=e.isLoading||e.isBackgroundLoading||e.isTopologyLoading;return n.jsxs(po,{children:[n.jsxs(bo,{children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(jo,{height:26,className:"block"}),t&&n.jsx(sc,{className:"ml-2"})]}),n.jsx(yo,{}),n.jsxs(bo,{children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",So]}),n.jsx(Zl,{})]})]})}const Hc=s.memo(function(){const{theme:e}=vr(),{backgroundImage:t,brightness:s,colorScheme:a}=e,r=Oe(a),o=(null==r?void 0:r.meta.backgroundImage)||null==r?void 0:r.meta.backgroundColor,i=(100-s)/100;return n.jsxs(n.Fragment,{children:[t?n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint"},"aria-hidden":"true",children:n.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat transition-opacity duration-300 ease-out",style:{backgroundImage:`url(${t})`}})}):o?n.jsx("div",{className:"fixed inset-0 -z-20 transition-colors duration-300 ease-out",style:{backgroundColor:o,contain:"paint"},"aria-hidden":"true"}):null,n.jsx("div",{className:"fixed inset-0 -z-10 bg-black pointer-events-none transition-opacity duration-200 ease-out",style:{opacity:i,contain:"paint"},"aria-hidden":"true"})]})}),Uc=20,qc=12,Gc=s.createContext(null);function Jc({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),r=s.useRef(null),[o,i]=s.useState({x:0,y:0}),l=s.useCallback((e,t,s)=>{a({content:e,mouseX:t,mouseY:s,visible:!0})},[]),c=s.useCallback(()=>{a(e=>({...e,visible:!1}))},[]),u=s.useCallback((e,t)=>{a(s=>s.visible?{...s,mouseX:e,mouseY:t}:s)},[]);s.useEffect(()=>{if(!t.visible||!r.current)return;const e=r.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,o=window.innerHeight;let l,c;l=s+Uc+e.width+qc>a?s-Uc-e.width:s+Uc,l=Math.max(qc,Math.min(l,a-e.width-qc)),c=n-Uc-e.height{c.current&&(clearTimeout(c.current),c.current=null)},h=s.useCallback(t=>{d(),c.current=setTimeout(()=>{u.current=!0,r(e,t.clientX,t.clientY)},a)},[r,e,a]),m=s.useCallback(e=>{u.current&&i(e.clientX,e.clientY)},[i]),f=s.useCallback(()=>{d(),u.current=!1,o()},[o]),g=s.useCallback(()=>{if(d(),!l.current)return;const t=l.current.getBoundingClientRect();c.current=setTimeout(()=>{u.current=!0,r(e,t.left+t.width/2,t.top)},a)},[r,e,a]),p=s.useCallback(()=>{d(),u.current=!1,o()},[o]);return s.useEffect(()=>()=>{d(),u.current&&(u.current=!1,o())},[o]),s.useEffect(()=>{const e=()=>{u.current&&(d(),u.current=!1,o())};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[o]),n.jsx("span",{ref:l,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onFocus:g,onBlur:p,className:"contents",children:t})}function Vc({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function Kc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-48"}),n.jsx(Vc,{className:"h-8 w-32"})]}),n.jsx(Vc,{className:"h-72"}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-3",children:Array.from({length:8}).map((e,t)=>n.jsx(Vc,{className:"h-24"},t))}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>n.jsx(Vc,{className:"h-44"},t))}),n.jsx(Vc,{className:"h-96"})]})}function Xc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-40"}),n.jsx(Vc,{className:"h-8 w-24"})]}),n.jsx(Vc,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(Vc,{className:"h-10 rounded-none"}),n.jsx("div",{className:"divide-y divide-border-subtle/30",children:Array.from({length:10}).map((e,t)=>n.jsx("div",{className:"px-4 py-3",children:n.jsx(Vc,{className:"h-6"})},t))})]})]})}function Qc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-32"}),n.jsx(Vc,{className:"h-6 w-48"})]}),n.jsx(Vc,{className:"h-[500px]"}),n.jsx(Vc,{className:"h-64"})]})}function Zc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-36"}),n.jsx(Vc,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(Vc,{className:"h-80"}),n.jsx(Vc,{className:"h-80"})]}),n.jsx(Vc,{className:"h-64"})]})}function eu(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(Vc,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(Vc,{className:"h-48"}),n.jsx(Vc,{className:"h-64"}),n.jsx(Vc,{className:"h-32"})]})]})}function tu(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(Vc,{className:"h-8 w-28"}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>n.jsx(Vc,{className:"h-28"},t))}),n.jsx(Vc,{className:"h-64"}),n.jsx(Vc,{className:"h-48"})]})}const su={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:.15}}},nu={initial:{opacity:0,y:8},animate:{opacity:1,y:0,transition:{duration:.3,ease:to.cubicInOut}},exit:{opacity:0,y:-8,transition:{duration:.15,ease:to.easeIn}}};function au({children:e,layoutKey:t}){return O()?n.jsx(n.Fragment,{children:e}):n.jsx(c.div,{initial:"initial",animate:"animate",exit:"exit",variants:nu,children:e},t)}const ru=s.lazy(()=>G(()=>import("./Login-zWarN3Ve.js"),__vite__mapDeps([0,1,2]))),ou=s.lazy(()=>G(()=>import("./Dashboard-BIMfl_CK.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14]))),iu=s.lazy(()=>G(()=>import("./Packets-DHxvwdwr.js"),__vite__mapDeps([15,1,2,6,7,8,9,4,5,13]))),lu=s.lazy(()=>G(()=>import("./Contacts-BcOss4J-.js").then(e=>e.C),__vite__mapDeps([16,1,2,17,5,9,8,18,19,20,21]))),cu=s.lazy(()=>G(()=>import("./Statistics-DqgywSJF.js"),__vite__mapDeps([22,1,2,23,4,10,5,9,18,19,13,14,21]))),uu=s.lazy(()=>G(()=>import("./MeshGraph-CdoFbL_m.js"),__vite__mapDeps([24,1,2,25]))),du=s.lazy(()=>G(()=>import("./System-Cw2qx9Xo.js"),__vite__mapDeps([26,1,2,4,5,14,13]))),hu=s.lazy(()=>G(()=>import("./Logs-EKbeyhLl.js"),__vite__mapDeps([27,1,2,23,5,13]))),mu=s.lazy(()=>G(()=>import("./Terminal-BQEu4TKw.js"),__vite__mapDeps([28,1,2,17,7,5]))),fu=s.lazy(()=>G(()=>import("./Configuration-_CjN4yUe.js"),__vite__mapDeps([29,1,2,20,30,12,5,9,13,14])));function gu({children:e}){const t=v();return Bo()?n.jsx(n.Fragment,{children:e}):n.jsx(H,{to:"/login",state:{from:t},replace:!0})}class pu extends s.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var e;return this.state.hasError?n.jsxs("div",{className:"glass-card p-8 text-center",children:[n.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Page failed to render"}),n.jsx("p",{className:"type-body text-white/50 mb-4",children:(null==(e=this.state.error)?void 0:e.message)||"Unknown error"}),n.jsx("button",{onClick:()=>this.setState({hasError:!1}),className:"px-4 py-2 bg-accent-primary/20 text-accent-primary rounded-lg hover:bg-accent-primary/30 transition-colors",children:"Try Again"})]}):this.props.children}}function bu(){const e=Ll(e=>e.initializeApp),t=Bo();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{Yo()},3e4);return Yo(),Xo(),()=>clearInterval(s)},[e,t]),n.jsxs(Jc,{children:[n.jsx(Hc,{}),n.jsxs($,{children:[n.jsx(W,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(ru,{})})}),n.jsx(W,{path:"/*",element:n.jsx(gu,{children:n.jsx(go,{sidebar:n.jsx($c,{}),navbar:n.jsx(Wc,{}),children:n.jsx("div",{className:"px-4 sm:px-6 lg:px-8 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:n.jsx(pu,{children:n.jsxs($,{children:[n.jsx(W,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(Kc,{}),children:n.jsx(au,{children:n.jsx(ou,{})})})}),n.jsx(W,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(iu,{})})})}),n.jsx(W,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(Qc,{}),children:n.jsx(au,{children:n.jsx(lu,{})})})}),n.jsx(W,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(Zc,{}),children:n.jsx(au,{children:n.jsx(cu,{})})})}),n.jsx(W,{path:"/meshgraph",element:n.jsx(s.Suspense,{fallback:n.jsx(Zc,{}),children:n.jsx(au,{children:n.jsx(uu,{})})})}),n.jsx(W,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(tu,{}),children:n.jsx(au,{children:n.jsx(du,{})})})}),n.jsx(W,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(hu,{})})})}),n.jsx(W,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(mu,{})})})}),n.jsx(W,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(eu,{}),children:n.jsx(au,{children:n.jsx(fu,{})})})})]})})})})})})]})]})}const yu=console.warn;console.warn=(...e)=>{const t=e[0];if("string"==typeof t){if(t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0"))return;if(t.includes("Unable to load glyph range"))return}yu.apply(console,e)},U.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx(wr,{children:n.jsx(q,{children:n.jsx(bu,{})})})}));export{ac as $,Dc as A,Ar as B,Mr as C,Xi as D,Lr as E,sl as F,Ki as G,Jr as H,Ec as I,bc as J,hc as K,Zl as L,kc as M,Vr as N,Qr as O,jo as P,Rr as Q,Cr as R,el as S,Yc as T,Rc as U,Pc as V,jr as W,yc as X,Sc as Y,Ac as Z,ic as _,so as a,wc as a0,Nl as a1,Wl as a2,uc as a3,dc as a4,Xl as a5,_c as a6,X as a7,K as a8,Oe as a9,gi as aA,pi as aB,bi as aC,fi as aD,yi as aE,ti as aF,Xe as aG,nt as aH,Ji as aI,Ic as aJ,Fc as aK,Xr as aL,Zr as aM,Mi as aN,Vi as aO,Tr as aP,Gl as aQ,$i as aR,tc as aS,su as aT,fr as aa,ni as ab,ai as ac,br as ad,vr as ae,xc as af,vc as ag,Cc as ah,Qi as ai,tl as aj,Ul as ak,cc as al,jc as am,Lc as an,Bl as ao,Ol as ap,hi as aq,mi as ar,nl as as,Nc as at,Il as au,Fl as av,Rl as aw,rl as ax,So as ay,oi as az,eo as b,Dl as c,Al as d,_l as e,ql as f,Do as g,$l as h,Bo as i,Yl as j,li as k,qo as l,Jl as m,Yi as n,El as o,Kl as p,Vl as q,Hl as r,Io as s,di as t,Pl as u,zl as v,Fi as w,Sr as x,Wr as y,Er as z}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-CkRuF4n8.js","assets/vendor-react-C341c8YC.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-DiETwG01.js","assets/useThemeColors-AeHMyThq.js","assets/PageLayout-CnF5SScd.js","assets/PacketList-BPeOqxkB.js","assets/channel-keys-DJWRrSwE.js","assets/SignalIndicator-BLrEkFNb.js","assets/DataBox-CRX76VsB.js","assets/TimeRangeSelector-DGCfekAv.js","assets/link-scoring-Cw0dJsWv.js","assets/NodeInformationCard-CEW2bogB.js","assets/Card-2pQSGkKC.js","assets/Grid-BOO-7ObJ.js","assets/Packets-BHJJxf8a.js","assets/Contacts-CyyU4xmf.js","assets/ping-DvLgBqTv.js","assets/CollisionExplorerModal-DTnzK_xA.js","assets/BasemapLayer-S9Ush6Hh.js","assets/ConfirmModal-CYXFGX_W.js","assets/maplibre-gl-B1CfjdFi.css","assets/Statistics-sXHAGtEF.js","assets/usePolling-CtRLadGa.js","assets/MeshGraph-DfCwG9Nt.js","assets/DeepAnalysisModal-D4eqwCNZ.js","assets/System-BPwbPFCW.js","assets/Logs-Cb5GXQFD.js","assets/Terminal-jVZnyeIH.js","assets/Configuration-BOsliPZn.js","assets/font-loader-jlbdh9Fw.js"])))=>i.map(i=>d[i]); +var e=Object.defineProperty,t=(t,s,n)=>((t,s,n)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n)(t,"symbol"!=typeof s?s+"":s,n);import{r as s,j as n,c as a,L as r,d as o,A as i,h as l,m as c,z as u,Q as d,e as h,M as m,y as f,X as g,x as p,C as b,f as y,g as x,i as w,u as v,k,l as S,n as C,o as j,W as T,G as M,F as L,S as N,p as _,q as E,t as P,v as D,w as I,B as F,D as A,E as R,H as z,b as B,I as O,J as $,K as W,N as H,O as U,T as q}from"./vendor-react-C341c8YC.js";import{_ as G}from"./deckgl-DTsmDcfs.js";import{n as J}from"./recharts-6XUQYgRA.js";import"./vendor-core-WoOfkQwm.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const s of e)if("childList"===s.type)for(const e of s.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();const Y={surfaces:{glass:{tint:"#252525",light:"#ffffff",dark:"#000000",reflexLight:.15,reflexDark:.8,blur:6,blurElevated:8,brightness:1,opacity:8,opacityElevated:12},card:{radius:"1.125rem",padding:"1.25rem",paddingCompact:"0.75rem"},sidebar:{tint:"rgba(113, 156, 223, 0.06)",width:"16rem",drawerWidth:"85vw"},modal:{radius:"1.125rem",backdropBlur:"8px",backdropColor:"rgba(0, 0, 0, 0.6)"}},colors:{bg:{body:"#171717",surface:"#252525",elevated:"#333233",subtle:"#3F3F3F"},border:{subtle:"#4B4B4B",strong:"#616161"},text:{primary:"#E1E1E1",secondary:"#BFBFBF",muted:"#727272",inverse:"#171717"},accent:{primary:"#719CDF",secondary:"#DFBC72",tertiary:"#6FBCBD",success:"#719872",danger:"#E12672"},signal:{excellent:"#00FF00",good:"#8CE619",fair:"#FFD900",poor:"#FF8C26",critical:"#FF3333",unknown:"#616161"},status:{success:"#719872",warning:"#DFBC72",danger:"#E12672",info:"#6FBCBD",muted:"#616161"},chart:{c1:"#719CDF",c2:"#0074BE",c3:"#6FBCBD",c4:"#DFBC72",c5:"#719872",c6:"#E12672",c7:"#E17899",c8:"#999ABD",grid:"rgba(255, 255, 255, 0.06)",axis:"rgba(255, 255, 255, 0.4)",cursor:"rgba(255, 255, 255, 0.2)"},metric:{received:"#719872",forwarded:"#0074BE",transmitted:"#DFBC72",dropped:"#E12672"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#8E4EC6",local:"#FFB224",neighbor:"#46A758",mobile:"#F76B15",room:"#D6409F",edge:"#4B4B4B",edgeHover:"#6FBCBD"}},typography:{font:{title:"'Inter', system-ui, sans-serif",display:"'Inter', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xs:"0.64rem",sm:"0.8rem",base:"1rem",md:"1.125rem",lg:"1.25rem",xl:"1.563rem",xxl:"1.953rem",hero:"3.052rem"},weight:{normal:400,medium:500,semibold:600,bold:700},leading:{tight:1.1,snug:1.25,normal:1.5},tracking:{tight:"-0.02em",normal:"0",wide:"0.05em"}},spacing:{space:{gap:"1.5rem",gapMobile:"0.75rem",page:"1.5rem",pageMobile:"1rem",section:"2rem"},radius:{sm:"0.5rem",md:"0.875rem",lg:"1.125rem",xl:"1.5rem",pill:"9999px"}},motion:{fast:"0.1s",normal:"0.15s",slow:"0.4s",easing:"ease-out"}};function V(e){const t=e.replace("#","");if(6!==t.length&&3!==t.length)return e;let s,n,a;return 3===t.length?(s=parseInt(t[0]+t[0],16)/255,n=parseInt(t[1]+t[1],16)/255,a=parseInt(t[2]+t[2],16)/255):(s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255),`color(display-p3 ${s.toFixed(3)} ${n.toFixed(3)} ${a.toFixed(3)})`}function K(){return"undefined"!=typeof window&&CSS.supports("color","color(display-p3 1 1 1)")}function X(e){return K()?V(e):e}function Q(e,t){const s={...e};for(const n of Object.keys(t)){const a=t[n],r=e[n];void 0!==a&&("object"!=typeof a||null===a||Array.isArray(a)||"object"!=typeof r||null===r||Array.isArray(r)?s[n]=a:s[n]=Q(r,a))}return s}function Z(e){return{meta:e.meta,display:e.display,surfaces:e.surfaces?Q(Y.surfaces,e.surfaces):Y.surfaces,colors:e.colors?Q(Y.colors,e.colors):Y.colors,typography:e.typography?Q(Y.typography,e.typography):Y.typography,spacing:e.spacing?Q(Y.spacing,e.spacing):Y.spacing,motion:e.motion?Q(Y.motion,e.motion):Y.motion}}function ee(e){const t=e.replace("#","");return 6===t.length?`${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}`:"255, 255, 255"}function te(e){return{id:e.meta.id,colorScheme:{name:e.meta.name,dataTheme:e.meta.dataTheme,previewColor:e.meta.previewColor},background:{src:e.meta.backgroundImage,suggestedBrightness:e.meta.backgroundBrightness},display:{font:e.display.font,color:e.display.color,size:e.display.size,paletteColors:e.display.palette}}}const se="#fafafa",ne="#a1a1aa",ae="#71717a",re="#3f3f46",oe="#27272a",ie="#18181b",le="#09090b",ce="#ef4444",ue="#f97316",de="#f59e0b",he="#eab308",me="#22c55e",fe="#10b981",ge="#06b6d4",pe="#3b82f6",be="#8b5cf6",ye=Z({meta:{id:"",name:"",dataTheme:"",previewColor:pe,backgroundImage:"",backgroundBrightness:100,isDark:!0},display:{font:"Inter, sans-serif",color:ne,size:1,palette:[[pe,me,he,ue,ce],[le,ie,oe,re,se]]},typography:{font:{title:"Inter, sans-serif",display:"Inter, sans-serif",mono:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'},weight:{normal:400,medium:500,semibold:600,bold:700,badge:700},tracking:{tight:"-0.02em",normal:"0",wide:"0.025em"},badge:{textTransform:"capitalize"}},surfaces:{glass:{tint:ie,light:re,dark:le,reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:100,opacityElevated:100,catalystMode:!0},sidebar:{tint:`${oe}80`},card:{radius:"0.5rem"},modal:{radius:"0.75rem"}},colors:{bg:{body:le,surface:ie,elevated:oe,subtle:oe},border:{subtle:oe,strong:"#52525b"},text:{primary:"#fff",secondary:ne,muted:ae,inverse:le},accent:{primary:pe,secondary:he,tertiary:ge,success:me,danger:ce},signal:{excellent:me,good:"#84cc16",fair:he,poor:ue,critical:ce,unknown:ae},status:{success:me,warning:de,danger:ce,info:pe,muted:ae},chart:{c1:pe,c2:fe,c3:de,c4:ue,c5:"#f43f5e",c6:be,c7:ge,c8:ae,grid:`${se}0d`,axis:`${se}33`,cursor:`${pe}33`},metric:{received:pe,forwarded:fe,transmitted:ue,dropped:ce},map:{nodeFill:pe,nodeStroke:`${se}e6`,hub:be,local:de,neighbor:fe,mobile:ue,room:"#ec4899",edge:re,edgeHover:pe}}}),xe=ye;te(ye);const we=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#B39DF3",backgroundImage:"/assets/sand.jpg",backgroundBrightness:80,isDark:!0},display:{font:"'Rubik Mono One', monospace",color:"#4A4A52",size:.8,palette:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]]},typography:{font:{title:"'Rubik Mono One', monospace"}},surfaces:{glass:{tint:"#252525",blur:6,blurElevated:8},sidebar:{tint:"rgba(113, 156, 223, 0.06)"}}}),ve=we;te(we);const ke=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#fabd2f",backgroundImage:"/assets/magma.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Jacquard 12', serif",color:"#fe8019",size:1.75,palette:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]]},typography:{font:{title:"'Jacquard 12', serif"},size:{xxl:"2.344rem"}},surfaces:{glass:{tint:"#282828"},sidebar:{tint:"rgba(250, 189, 47, 0.06)"}},colors:{accent:{primary:"#fabd2f",secondary:"#fb4934",tertiary:"#8ec07c",success:"#b8bb26",danger:"#fb4934"},signal:{excellent:"#b8bb26",good:"#8ec07c",fair:"#fabd2f",poor:"#fe8019",critical:"#fb4934",unknown:"#928374"},status:{success:"#b8bb26",warning:"#fabd2f",danger:"#fb4934",info:"#83a598",muted:"#928374"},chart:{c1:"#fabd2f",c2:"#fe8019",c3:"#fb4934",c4:"#d3869b",c5:"#b8bb26",c6:"#8ec07c",c7:"#83a598",c8:"#d65d0e",grid:"rgba(251, 241, 199, 0.06)",axis:"rgba(251, 241, 199, 0.4)",cursor:"rgba(251, 241, 199, 0.2)"},metric:{received:"#b8bb26",forwarded:"#83a598",transmitted:"#fabd2f",dropped:"#fb4934"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b16286",local:"#fabd2f",neighbor:"#fabd2f",mobile:"#fe8019",room:"#d3869b",edge:"#665c54",edgeHover:"#8ec07c"}}}),Se=ke;te(ke);const Ce=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#83a598",backgroundImage:"/assets/water.webp",backgroundBrightness:40,isDark:!0},display:{font:"'Cantora One', sans-serif",color:"#83a598",size:1.25,palette:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]]},typography:{font:{title:"'Cantora One', sans-serif"},size:{xxl:"2.148rem"},weight:{semibold:500}},surfaces:{glass:{tint:"#1e1e1e"},sidebar:{tint:"rgba(131, 165, 152, 0.06)"}},colors:{accent:{primary:"#83a598",secondary:"#a89984",tertiary:"#8ec07c",success:"#8ec07c",danger:"#cc241d"},signal:{excellent:"#8ec07c",good:"#b8bb26",fair:"#d79921",poor:"#fe8019",critical:"#cc241d",unknown:"#7c6f64"},status:{success:"#8ec07c",warning:"#d79921",danger:"#cc241d",info:"#83a598",muted:"#7c6f64"},chart:{c1:"#83a598",c2:"#8ec07c",c3:"#d79921",c4:"#b16286",c5:"#fe8019",c6:"#cc241d",c7:"#a89984",c8:"#7c6f64",grid:"rgba(213, 196, 161, 0.06)",axis:"rgba(213, 196, 161, 0.4)",cursor:"rgba(213, 196, 161, 0.2)"},metric:{received:"#8ec07c",forwarded:"#83a598",transmitted:"#d79921",dropped:"#cc241d"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b16286",local:"#d79921",neighbor:"#d79921",mobile:"#fe8019",room:"#b16286",edge:"#504945",edgeHover:"#83a598"}}}),je=Ce;te(Ce);const Te=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#33859d",backgroundImage:"/assets/stars.jpg",backgroundBrightness:100,isDark:!0},display:{font:"'IBM Plex Mono', monospace",color:"#c23127",size:1.25,palette:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]]},typography:{font:{title:"'IBM Plex Mono', monospace"}},surfaces:{glass:{tint:"#0a0e14",blur:1,blurElevated:2},sidebar:{tint:"rgba(51, 133, 157, 0.06)"}},colors:{accent:{primary:"#33859d",secondary:"#edb54b",tertiary:"#26a98b",success:"#26a98b",danger:"#c33027"},signal:{excellent:"#26a98b",good:"#7ec07c",fair:"#edb54b",poor:"#d26939",critical:"#c33027",unknown:"#195465"},status:{success:"#26a98b",warning:"#edb54b",danger:"#c33027",info:"#599caa",muted:"#195465"},chart:{c1:"#33859d",c2:"#edb54b",c3:"#26a98b",c4:"#599caa",c5:"#d26939",c6:"#c33027",c7:"#888ba5",c8:"#195465",grid:"rgba(153, 209, 206, 0.06)",axis:"rgba(153, 209, 206, 0.4)",cursor:"rgba(153, 209, 206, 0.2)"},metric:{received:"#26a98b",forwarded:"#33859d",transmitted:"#edb54b",dropped:"#c33027"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#888ba5",local:"#edb54b",neighbor:"#edb54b",mobile:"#d26939",room:"#888ba5",edge:"#245361",edgeHover:"#26a98b"}}}),Me=Te;te(Te);const Le="#2D2D2D",Ne="#4A4A4A",_e="#7A7A7A",Ee=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#9ed072",backgroundImage:"",backgroundColor:"#F5F5F5",backgroundBrightness:100,isDark:!1},display:{font:"'JetBrains Mono', monospace",color:"#2D2D2D",size:1,palette:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]]},typography:{font:{title:"'JetBrains Mono', 'SF Mono', Monaco, monospace",display:"'Instrument Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace",cardTitle:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xxl:"1.875rem",cardTitle:"1rem"},weight:{normal:400,medium:500,semibold:600,bold:600,cardTitle:600}},surfaces:{glass:{tint:"#FFFFFF",light:"rgba(255, 255, 255, 1)",dark:"rgba(0, 0, 0, 0.1)",reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:0,opacityElevated:0,ribbonMode:!0,ribbonBorderWidth:2,ribbonBorderColor:_e},sidebar:{tint:"rgba(0, 0, 0, 0.02)"}},colors:{bg:{body:"#F5F5F5",surface:"#FFFFFF",elevated:"#FFFFFF",subtle:"#EBEBEB"},border:{subtle:"#E0E0E0",strong:"#BFBFBF"},text:{primary:Le,secondary:Ne,muted:_e,inverse:"#FFFFFF"},accent:{primary:"#9ed072",secondary:"#e7c664",tertiary:"#76cce0",success:"#9ed072",danger:"#fc5d7c"},signal:{excellent:"#9ed072",good:"#c5d93d",fair:"#e7c664",poor:"#f39660",critical:"#fc5d7c",unknown:"#7f8490"},status:{success:"#9ed072",warning:"#e7c664",danger:"#fc5d7c",info:"#76cce0",muted:"#7f8490"},chart:{c1:"#2E8B57",c2:"#E14D6B",c3:"#D4A832",c4:"#4A9EA0",c5:"#8B6BAE",c6:"#D97A4A",c7:_e,c8:Ne,grid:"rgba(45, 45, 45, 0.08)",axis:"rgba(45, 45, 45, 0.5)",cursor:"rgba(45, 45, 45, 0.15)"},metric:{received:"#9ed072",forwarded:"#76cce0",transmitted:"#e7c664",dropped:"#fc5d7c"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#b39df3",local:"#e7c664",neighbor:"#e7c664",mobile:"#f39660",room:"#fc5d7c",edge:_e,edgeHover:"#76cce0"},icon:{pageTitle:Le,cardTitle:Le,widget:Ne,action:Ne,nav:_e,navActive:Le},sidebar:{bg:"rgba(0, 0, 0, 0.02)",navHoverBg:"rgba(0, 0, 0, 0.04)",navActiveBg:"rgba(0, 0, 0, 0.06)",navActiveText:Le}}}),Pe=Ee;te(Ee);const De=Z({meta:{id:"",name:"",dataTheme:"",previewColor:"#7E9CD8",backgroundImage:"/assets/folds.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Inter', sans-serif",color:"#7E9CD8",size:1.25,palette:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]]},typography:{font:{title:"'Inter', sans-serif"}},surfaces:{glass:{tint:"#1F1F28"},sidebar:{tint:"rgba(126, 156, 216, 0.06)"}},colors:{accent:{primary:"#7E9CD8",secondary:"#E6C384",tertiary:"#7FB4CA",success:"#98BB6C",danger:"#E46876"},signal:{excellent:"#98BB6C",good:"#B8CC5C",fair:"#E6C384",poor:"#FFA066",critical:"#E46876",unknown:"#54546D"},status:{success:"#98BB6C",warning:"#E6C384",danger:"#E46876",info:"#7FB4CA",muted:"#727169"},chart:{c1:"#7E9CD8",c2:"#E6C384",c3:"#98BB6C",c4:"#957FB8",c5:"#7FB4CA",c6:"#E46876",c7:"#FFA066",c8:"#D27E99",grid:"rgba(220, 215, 186, 0.06)",axis:"rgba(220, 215, 186, 0.4)",cursor:"rgba(220, 215, 186, 0.2)"},metric:{received:"#98BB6C",forwarded:"#7E9CD8",transmitted:"#E6C384",dropped:"#E46876"},map:{nodeFill:"#3B82F6",nodeStroke:"rgba(255,255,255,0.9)",hub:"#957FB8",local:"#E6C384",neighbor:"#E6C384",mobile:"#FFA066",room:"#D27E99",edge:"#54546D",edgeHover:"#7AA89F"}}}),Ie=De;te(De);const Fe={"KDE Breeze":xe,Magma:Se,Folds:Ie,Ribbon:Pe,BLKSAND:ve,Waves:je,Stars:Me};function Ae(e,t){const s=e.toLowerCase();return{...t,meta:{...t.meta,id:s,name:e,dataTheme:s}}}const Re=Object.fromEntries(Object.entries(Fe).map(([e,t])=>[e,Ae(e,t)])),ze=Object.fromEntries(Object.entries(Re).map(([e,t])=>[e,te(t)])),Be=Object.values(Re);function Oe(e){return Be.find(t=>t.meta.id===e)}new Map(Object.entries(Re));const $e=Object.values(ze);new Map(Object.entries(ze));const We=Object.entries(ze).map(([e,t])=>function(e,t){return{id:e.id,name:e.colorScheme.name,displayName:t,colorScheme:e.id,backgroundImage:e.background.src,paletteColors:e.display.paletteColors,displayFont:e.display.font,displayColor:e.display.color,displaySize:e.display.size}}(t,e)),He=$e.map(function(e){return{id:e.id,name:e.colorScheme.name,dataTheme:e.colorScheme.dataTheme,previewColor:e.colorScheme.previewColor}}),Ue=$e.map(function(e){return{id:e.id,src:e.background.src,suggestedScheme:e.id,suggestedBrightness:e.background.suggestedBrightness}}),qe=Re["KDE Breeze"];ze["KDE Breeze"];const Ge=qe.meta.id,Je=qe.meta.backgroundImage,Ye=qe.meta.backgroundBrightness,Ve=He,Ke=Ue,Xe=We,Qe={colorScheme:Ge,backgroundImage:Je,brightness:Ye},Ze="pymc-color-scheme",et="pymc-background-image",tt="pymc-bg-brightness",st="pymc-background";function nt(e){(new Image).src=e}const at={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},rt=[50,100,200,300,400,500,600,700,800,900],ot=["red","orange","yellow","green","aqua","blue","purple"];function it(e,t,s){const n=e=>Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(s)}`}function lt(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ct(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function ut(e,t,s){const n=s*(Math.PI/180),a=t*Math.cos(n),r=t*Math.sin(n),o=e+.3963377774*a+.2158037573*r,i=e-.1055613458*a-.0638541728*r,l=e-.0894841775*a-1.291485548*r,c=o*o*o,u=i*i*i,d=l*l*l,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,m=-.0041960863*c-.7034186147*u+1.707614701*d;return[ct(4.0767416621*c-3.3077115913*u+.2309699292*d),ct(h),ct(m)]}function dt(e){const[t,s,n]=function(e){const t=e.replace("#","");return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}(e),[,a,r]=function(e,t,s){const n=lt(e),a=lt(t),r=lt(s),o=.4122214708*n+.5363325363*a+.0514459929*r,i=.2119034982*n+.6806995451*a+.1073969566*r,l=.0883024619*n+.2817188376*a+.6299787005*r,c=Math.cbrt(o),u=Math.cbrt(i),d=Math.cbrt(l),h=.2104542553*c+.793617785*u-.0040720468*d,m=1.9779984951*c-2.428592205*u+.4505937099*d,f=.0259040371*c+.7827717662*u-.808675766*d,g=Math.sqrt(m*m+f*f);let p=Math.atan2(f,m)*(180/Math.PI);return p<0&&(p+=360),[h,g,p]}(t,s,n),o={};for(const i of rt){const e=at[i],t=a*(1-.3*Math.abs(e-.5)),[s,n,l]=ut(e,t,r);o[i]=it(s,n,l)}return o}function ht(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function mt(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const ft="u-off",gt="u-label",pt="width",bt="height",yt="top",xt="bottom",wt="left",vt="right",kt="#000",St=kt+"0",Ct="mousemove",jt="mousedown",Tt="mouseup",Mt="mouseenter",Lt="mouseleave",Nt="dblclick",_t="change",Et="dppxchange",Pt="--",Dt="undefined"!=typeof window,It=Dt?document:null,Ft=Dt?window:null,At=Dt?navigator:null;let Rt,zt;function Bt(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function Ot(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function $t(e,t,s){e.style[t]=s+"px"}function Wt(e,t,s,n){let a=It.createElement(e);return null!=t&&Bt(a,t),null!=s&&s.insertBefore(a,n),a}function Ht(e,t){return Wt("div",e,t)}const Ut=new WeakMap;function qt(e,t,s,n,a){let r="translate("+t+"px,"+s+"px)";r!=Ut.get(e)&&(e.style.transform=r,Ut.set(e,r),t<0||s<0||t>n||s>a?Bt(e,ft):Ot(e,ft))}const Gt=new WeakMap;function Jt(e,t,s){let n=t+s;n!=Gt.get(e)&&(Gt.set(e,n),e.style.background=t,e.style.borderColor=s)}const Yt=new WeakMap;function Vt(e,t,s,n){let a=t+""+s;a!=Yt.get(e)&&(Yt.set(e,a),e.style.height=s+"px",e.style.width=t+"px",e.style.marginLeft=n?-t/2+"px":0,e.style.marginTop=n?-s/2+"px":0)}const Kt={passive:!0},Xt={...Kt,capture:!0};function Qt(e,t,s,n){t.addEventListener(e,s,n?Xt:Kt)}function Zt(e,t,s,n){t.removeEventListener(e,s,Kt)}function es(e,t,s,n){let a;s=s||0;let r=(n=n||t.length-1)<=2147483647;for(;n-s>1;)a=r?s+n>>1:xs((s+n)/2),t[a]{let a=-1,r=-1;for(let o=s;o<=n;o++)if(e(t[o])){a=o;break}for(let o=n;o>=s;o--)if(e(t[o])){r=o;break}return[a,r]}}Dt&&function e(){let t=devicePixelRatio;Rt!=t&&(Rt=t,zt&&Zt(_t,zt,e),zt=matchMedia(`(min-resolution: ${Rt-.001}dppx) and (max-resolution: ${Rt+.001}dppx)`),Qt(_t,zt,e),Ft.dispatchEvent(new CustomEvent(Et)))}();const ss=e=>null!=e,ns=e=>null!=e&&e>0,as=ts(ss),rs=ts(ns);function os(e,t,s,n){let a=js(e),r=js(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let o=10==s?Ts:Ms,i=1==r?vs:xs,l=(1==a?xs:vs)(o(ys(e))),c=i(o(ys(t))),u=Cs(s,l),d=Cs(s,c);return 10==s&&(l<0&&(u=Us(u,-l)),c<0&&(d=Us(d,-c))),n||2==s?(e=u*a,t=d*r):(e=Hs(e,u),t=Ws(t,d)),[e,t]}function is(e,t,s,n){let a=os(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const ls={mode:3,pad:.1},cs={pad:0,soft:null,mode:0},us={min:cs,max:cs};function ds(e,t,s,n){return en(s)?ms(e,t,s):(cs.pad=s,cs.soft=n?0:null,cs.mode=n?3:0,ms(e,t,us))}function hs(e,t){return null==e?t:e}function ms(e,t,s){let n=s.min,a=s.max,r=hs(n.pad,0),o=hs(a.pad,0),i=hs(n.hard,-Ns),l=hs(a.hard,Ns),c=hs(n.soft,Ns),u=hs(a.soft,-Ns),d=hs(n.mode,0),h=hs(a.mode,0),m=t-e,f=Ts(m),g=Ss(ys(e),ys(t)),p=Ts(g),b=ys(p-f);(m<1e-24||b>10)&&(m=0,0!=e&&0!=t||(m=1e-24,2==d&&c!=Ns&&(r=0),2==h&&u!=-Ns&&(o=0)));let y=m||g||1e3,x=Ts(y),w=Cs(10,xs(x)),v=Us(Hs(e-y*(0==m?0==e?.1:1:r),w/10),24),k=e>=c&&(1==d||3==d&&v<=c||2==d&&v>=c)?c:Ns,S=Ss(i,v=k?k:ks(k,v)),C=Us(Ws(t+y*(0==m?0==t?.1:1:o),w/10),24),j=t<=u&&(1==h||3==h&&C>=u||2==h&&C<=u)?u:-Ns,T=ks(l,C>j&&t<=j?j:Ss(j,C));return S==T&&0==S&&(T=100),[S,T]}const fs=new Intl.NumberFormat(Dt?At.language:"en-US"),gs=e=>fs.format(e),ps=Math,bs=ps.PI,ys=ps.abs,xs=ps.floor,ws=ps.round,vs=ps.ceil,ks=ps.min,Ss=ps.max,Cs=ps.pow,js=ps.sign,Ts=ps.log10,Ms=ps.log2,Ls=(e,t=1)=>ps.asinh(e/t),Ns=1/0;function _s(e){return 1+(0|Ts((e^e>>31)-(e>>31)))}function Es(e,t,s){return ks(Ss(e,t),s)}function Ps(e){return"function"==typeof e}function Ds(e){return Ps(e)?e:()=>e}const Is=e=>e,Fs=(e,t)=>t,As=e=>null,Rs=e=>!0,zs=(e,t)=>e==t,Bs=/\.\d*?(?=9{6,}|0{6,})/gm,Os=e=>{if(Qs(e)||qs.has(e))return e;const t=`${e}`,s=t.match(Bs);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${Os(e)}e${s}`}return Us(e,n)};function $s(e,t){return Os(Us(Os(e/t))*t)}function Ws(e,t){return Os(vs(Os(e/t))*t)}function Hs(e,t){return Os(xs(Os(e/t))*t)}function Us(e,t=0){if(Qs(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return ws(n)/s}const qs=new Map;function Gs(e){return((""+e).split(".")[1]||"").length}function Js(e,t,s,n){let a=[],r=n.map(Gs);for(let o=t;o=0?0:t)+(o>=r[i]?0:r[i]),u=10==e?l:Us(l,c);a.push(u),qs.set(u,c)}}return a}const Ys={},Vs=[],Ks=[null,null],Xs=Array.isArray,Qs=Number.isInteger;function Zs(e){return"string"==typeof e}function en(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function tn(e){return null!=e&&"object"==typeof e}const sn=Object.getPrototypeOf(Uint8Array),nn="__proto__";function an(e,t=en){let s;if(Xs(e)){let n=e.find(e=>null!=e);if(Xs(n)||t(n)){s=Array(e.length);for(let n=0;nr){for(n=o-1;n>=0&&null==e[n];)e[n--]=null;for(n=o+1;nPromise.resolve().then(e):queueMicrotask,cn=["January","February","March","April","May","June","July","August","September","October","November","December"],un=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function dn(e){return e.slice(0,3)}const hn=un.map(dn),mn=cn.map(dn),fn={MMMM:cn,MMM:mn,WWWW:un,WWW:hn};function gn(e){return(e<10?"0":"")+e}const pn={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,t)=>t.MMMM[e.getMonth()],MMM:(e,t)=>t.MMM[e.getMonth()],MM:e=>gn(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>gn(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>gn(e.getHours()),H:e=>e.getHours(),h:e=>{let t=e.getHours();return 0==t?12:t>12?t-12:t},AA:e=>e.getHours()>=12?"PM":"AM",aa:e=>e.getHours()>=12?"pm":"am",a:e=>e.getHours()>=12?"p":"a",mm:e=>gn(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>gn(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function bn(e,t){t=t||fn;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?pn[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,wn=[1,2,2.5,5],vn=Js(10,-32,0,wn),kn=Js(10,0,32,wn),Sn=kn.filter(xn),Cn=vn.concat(kn),jn="{YYYY}",Tn="\n"+jn,Mn="{M}/{D}",Ln="\n"+Mn,Nn=Ln+"/{YY}",_n="{aa}",En="{h}:{mm}"+_n,Pn="\n"+En,Dn=":{ss}",In=null;function Fn(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,r=30*a,o=365*a;return[(1==e?Js(10,0,3,wn).filter(xn):Js(10,-3,0,wn)).concat([t,5*t,10*t,15*t,30*t,s,5*s,10*s,15*s,30*s,n,2*n,3*n,4*n,6*n,8*n,12*n,a,2*a,3*a,4*a,5*a,6*a,7*a,8*a,9*a,10*a,15*a,r,2*r,3*r,4*r,6*r,o,2*o,5*o,10*o,25*o,50*o,100*o]),[[o,jn,In,In,In,In,In,In,1],[28*a,"{MMM}",Tn,In,In,In,In,In,1],[a,Mn,Tn,In,In,In,In,In,1],[n,"{h}"+_n,Nn,In,Ln,In,In,In,1],[s,En,Nn,In,Ln,In,In,In,1],[t,Dn,Nn+" "+En,In,Ln+" "+En,In,Pn,In,1],[e,Dn+".{fff}",Nn+" "+En,In,Ln+" "+En,In,Pn,In,1]],function(t){return(i,l,c,u,d,h)=>{let m=[],f=d>=o,g=d>=r&&d=a?a:d,o=x+(xs(c)-xs(b))+Ws(b-x,r);m.push(o);let f=t(o),g=f.getHours()+f.getMinutes()/s+f.getSeconds()/n,p=d/n,y=h/i.axes[l]._space;for(;o=Us(o+d,1==e?0:3),!(o>u);)if(p>1){let e=xs(Us(g+p,6))%24,s=t(o).getHours()-e;s>1&&(s=-1),o-=s*n,g=(g+p)%24,Us((o-m[m.length-1])/d,3)*y>=.7&&m.push(o)}else m.push(o)}return m}}]}const[An,Rn,zn]=Fn(1),[Bn,On,$n]=Fn(.001);function Wn(e,t){return e.map(e=>e.map((s,n)=>0==n||8==n||null==s?s:t(1==n||0==e[8]?s:e[1]+s)))}function Hn(e,t){return(s,n,a,r,o)=>{let i,l,c,u,d,h,m=t.find(e=>o>=e[0])||t[t.length-1];return n.map(t=>{let s=e(t),n=s.getFullYear(),a=s.getMonth(),r=s.getDate(),o=s.getHours(),f=s.getMinutes(),g=s.getSeconds(),p=n!=i&&m[2]||a!=l&&m[3]||r!=c&&m[4]||o!=u&&m[5]||f!=d&&m[6]||g!=h&&m[7]||m[1];return i=n,l=a,c=r,u=o,d=f,h=g,p(s)})}}function Un(e,t,s){return new Date(e,t,s)}function qn(e,t){return t(e)}function Gn(e,t){return(s,n,a,r)=>null==r?Pt:t(e(n))}Js(2,-53,53,[1]);const Jn={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,t){let s=e.series[t];return s.width?s.stroke(e,t):s.points.width?s.points.stroke(e,t):null},fill:function(e,t){return e.series[t].fill(e,t)},dash:"solid"},idx:null,idxs:null,values:[]},Yn=[0,0];function Vn(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function Kn(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const Xn={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return Yn[0]=t,Yn[1]=s,Yn},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=Ht(),a=s.size(e,t);$t(n,pt,a),$t(n,bt,a);let r=a/-2;$t(n,"marginLeft",r),$t(n,"marginTop",r);let o=s.width(e,t,a);return o&&$t(n,"borderWidth",o),n},size:function(e,t){return e.series[t].points.size},width:0,stroke:function(e,t){let s=e.series[t].points;return s._stroke||s._fill},fill:function(e,t){let s=e.series[t].points;return s._fill||s._stroke}},bind:{mousedown:Vn,mouseup:Vn,click:Vn,dblclick:Vn,mousemove:Kn,mouseleave:Kn,mouseenter:Kn},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,s,n,a)=>n-a,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Qn={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Zn=rn({},Qn,{filter:Fs}),ea=rn({},Zn,{size:10}),ta=rn({},Qn,{show:!1}),sa='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',na="bold "+sa,aa={show:!0,scale:"x",stroke:kt,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:na,side:2,grid:Zn,ticks:ea,border:ta,font:sa,lineGap:1.5,rotate:0},ra={show:!0,scale:"x",auto:!1,sorted:1,min:Ns,max:-Ns,idxs:[]};function oa(e,t,s,n,a){return t.map(e=>null==e?"":gs(e))}function ia(e,t,s,n,a,r,o){let i=[],l=qs.get(a)||0;for(let c=s=o?s:Us(Ws(s,a),l);c<=n;c=Us(c+a,l))i.push(Object.is(c,-0)?0:c);return i}function la(e,t,s,n,a,r,o){const i=[],l=e.scales[e.axes[t].scale].log,c=xs((10==l?Ts:Ms)(s));a=Cs(l,c),10==l&&(a=Cn[es(a,Cn)]);let u=s,d=a*l;10==l&&(d=Cn[es(d,Cn)]);do{i.push(u),u+=a,10!=l||qs.has(u)||(u=Us(u,qs.get(a))),u>=d&&(d=(a=u)*l,10==l&&(d=Cn[es(d,Cn)]))}while(u<=n);return i}function ca(e,t,s,n,a,r,o){let i=e.scales[e.axes[t].scale].asinh,l=n>i?la(e,t,Ss(i,s),n,a):[i],c=n>=0&&s<=0?[0]:[];return(s<-i?la(e,t,Ss(i,-n),-s,a):[i]).reverse().map(e=>-e).concat(c,l)}const ua=/./,da=/[12357]/,ha=/[125]/,ma=/1/,fa=(e,t,s,n)=>e.map((e,a)=>4==t&&0==e||a%n==0&&s.test(e.toExponential()[e<0?1:0])?e:null);function ga(e,t,s,n,a){let r=e.axes[s],o=r.scale,i=e.scales[o],l=e.valToPos,c=r._space,u=l(10,o),d=l(9,o)-u>=c?ua:l(7,o)-u>=c?da:l(5,o)-u>=c?ha:ma;if(d==ma){let e=ys(l(1,o)-u);if(ea,va={show:!0,auto:!0,sorted:0,gaps:wa,alpha:1,facets:[rn({},xa,{scale:"x"}),rn({},xa,{scale:"y"})]},ka={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:wa,alpha:1,points:{show:function(e,t){let{scale:s,idxs:n}=e.series[0],a=e._data[0],r=e.valToPos(a[n[0]],s,!0),o=e.valToPos(a[n[1]],s,!0),i=ys(o-r)/(e.series[t].points.space*Rt);return n[1]-n[0]<=i},filter:null},values:null,min:Ns,max:-Ns,idxs:[],path:null,clip:null};function Sa(e,t,s,n,a){return s/10}const Ca={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},ja=rn({},Ca,{time:!1,ori:1}),Ta={};function Ma(e,t){let s=Ta[e];return s||(s={key:e,plots:[],sub(e){s.plots.push(e)},unsub(e){s.plots=s.plots.filter(t=>t!=e)},pub(e,t,n,a,r,o,i){for(let l=0;l{let g=e.pxRound;const p=i.dir*(0==i.ori?1:-1),b=0==i.ori?za:Ba;let y,x;1==p?(y=s,x=n):(y=n,x=s);let w=g(c(t[y],i,m,d)),v=g(u(o[y],l,f,h)),k=g(c(t[x],i,m,d)),S=g(u(1==r?l.max:l.min,l,f,h)),C=new Path2D(a);return b(C,k,S),b(C,w,S),b(C,w,v),C})}function Pa(e,t,s,n,a,r){let o=null;if(e.length>0){o=new Path2D;const i=0==t?Oa:$a;let l=s;for(let t=0;ts[0]){let e=s[0]-l;e>0&&i(o,l,n,e,n+r),l=s[1]}}let c=s+a-l,u=10;c>0&&i(o,l,n-u/2,c,n+r+u)}return o}function Da(e,t,s,n,a,r,o){let i=[],l=e.length;for(let c=1==a?s:n;c>=s&&c<=n;c+=a)if(null===t[c]){let u=c,d=c;if(1==a)for(;++c<=n&&null===t[c];)d=c;else for(;--c>=s&&null===t[c];)d=c;let h=r(e[u]),m=d==u?h:r(e[d]),f=u-a;h=o<=0&&f>=0&&f=0&&g>=0&&g=h&&i.push([h,m])}return i}function Ia(e){return 0==e?Is:1==e?ws:t=>$s(t,e)}function Fa(e){let t=0==e?Aa:Ra,s=0==e?(e,t,s,n,a,r)=>{e.arcTo(t,s,n,a,r)}:(e,t,s,n,a,r)=>{e.arcTo(s,t,a,n,r)},n=0==e?(e,t,s,n,a)=>{e.rect(t,s,n,a)}:(e,t,s,n,a)=>{e.rect(s,t,a,n)};return(e,a,r,o,i,l=0,c=0)=>{0==l&&0==c?n(e,a,r,o,i):(l=ks(l,o/2,i/2),c=ks(c,o/2,i/2),t(e,a+l,r),s(e,a+o,r,a+o,r+i,l),s(e,a+o,r+i,a,r+i,c),s(e,a,r+i,a,r,c),s(e,a,r,a+o,r,l),e.closePath())}}const Aa=(e,t,s)=>{e.moveTo(t,s)},Ra=(e,t,s)=>{e.moveTo(s,t)},za=(e,t,s)=>{e.lineTo(t,s)},Ba=(e,t,s)=>{e.lineTo(s,t)},Oa=Fa(0),$a=Fa(1),Wa=(e,t,s,n,a,r)=>{e.arc(t,s,n,a,r)},Ha=(e,t,s,n,a,r)=>{e.arc(s,t,n,a,r)},Ua=(e,t,s,n,a,r,o)=>{e.bezierCurveTo(t,s,n,a,r,o)},qa=(e,t,s,n,a,r,o)=>{e.bezierCurveTo(s,t,a,n,o,r)};function Ga(e){return(e,t,s,n,a)=>La(e,t,(t,r,o,i,l,c,u,d,h,m,f)=>{let g,p,{pxRound:b,points:y}=t;0==i.ori?(g=Aa,p=Wa):(g=Ra,p=Ha);const x=Us(y.width*Rt,3);let w=(y.size-y.width)/2*Rt,v=Us(2*w,3),k=new Path2D,S=new Path2D,{left:C,top:j,width:T,height:M}=e.bbox;Oa(S,C-v,j-v,T+2*v,M+2*v);const L=e=>{if(null!=o[e]){let t=b(c(r[e],i,m,d)),s=b(u(o[e],l,f,h));g(k,t+w,s),p(k,t,s,w,0,2*bs)}};if(a)a.forEach(L);else for(let e=s;e<=n;e++)L(e);return{stroke:x>0?k:null,fill:k,clip:S,flags:3}})}function Ja(e){return(t,s,n,a,r,o)=>{n!=a&&(r!=n&&o!=n&&e(t,s,n),r!=a&&o!=a&&e(t,s,a),e(t,s,o))}}const Ya=Ja(za),Va=Ja(Ba);function Ka(e){const t=hs(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>La(e,s,(r,o,i,l,c,u,d,h,m,f,g)=>{[n,a]=as(i,n,a);let p,b,y=r.pxRound,x=e=>y(u(e,l,f,h)),w=e=>y(d(e,c,g,m));0==l.ori?(p=za,b=Ya):(p=Ba,b=Va);const v=l.dir*(0==l.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=k.stroke;let C=!1;if(a-n>=4*f){let t,s,r,c=t=>e.posToVal(t,l.key,!0),u=null,d=null,h=x(o[1==v?n:a]),m=x(o[n]),f=x(o[a]),g=c(1==v?m+1:f-1);for(let e=1==v?n:a;e>=n&&e<=a;e+=v){let n=o[e],a=(1==v?ng)?h:x(n),r=i[e];a==h?null!=r?(s=r,null==u?(p(S,a,w(s)),t=u=d=s):sd&&(d=s)):null===r&&(C=!0):(null!=u&&b(S,h,w(u),w(d),w(t),w(s)),null!=r?(s=r,p(S,a,w(s)),u=d=t=s):(u=d=null,null===r&&(C=!0)),h=a,g=c(h+v))}null!=u&&u!=d&&r!=h&&b(S,h,w(u),w(d),w(t),w(s))}else for(let e=1==v?n:a;e>=n&&e<=a;e+=v){let t=i[e];null===t?C=!0:null!=t&&p(S,x(o[e]),w(t))}let[j,T]=Na(e,s);if(null!=r.fill||0!=j){let t=k.fill=new Path2D(S),i=w(r.fillTo(e,s,r.min,r.max,j)),l=x(o[n]),c=x(o[a]);-1==v&&([c,l]=[l,c]),p(t,c,i),p(t,l,i)}if(!r.spanGaps){let c=[];C&&c.push(...Da(o,i,n,a,v,x,t)),k.gaps=c=r.gaps(e,s,n,a,c),k.clip=Pa(c,l.ori,h,m,f,g)}return 0!=T&&(k.band=2==T?[Ea(e,s,n,a,S,-1),Ea(e,s,n,a,S,1)]:Ea(e,s,n,a,S,T)),k})}function Xa(e,t,s,n,a,r,o=Ns){if(e.length>1){let i=null;for(let l=0,c=1/0;l0!=n[e]>0?s[e]=0:(s[e]=3*(l[e-1]+l[e])/((2*l[e]+l[e-1])/n[e-1]+(l[e]+2*l[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[o-1]=n[o-2];for(let c=0;c{fr.pxRatio=Rt}));const tr=Ka(),sr=Ga();function nr(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>ar(e,n,t,s))}function ar(e,t,s,n){return rn({},0==t?s:n,e)}function rr(e,t,s){return null==t?Ks:[t,s]}const or=rr;function ir(e,t,s){return null==t?Ks:ds(t,s,.1,!0)}function lr(e,t,s,n){return null==t?Ks:os(t,s,e.scales[n].log,!1)}const cr=lr;function ur(e,t,s,n){return null==t?Ks:is(t,s,e.scales[n].log,!1)}const dr=ur;function hr(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=ws((s=+n)*Rt))+"px"),t,s]}function mr(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Us(e[2]*Rt,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function fr(e,t,s){const n={mode:hs(e.mode,1)},a=n.mode;function r(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?1-a:a)}function o(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?a:1-a)}function i(e,t,s,n){return 0==t.ori?r(e,t,s,n):o(e,t,s,n)}n.valToPosH=r,n.valToPosV=o;let l=!1;n.status=0;const c=n.root=Ht("uplot");null!=e.id&&(c.id=e.id),Bt(c,e.class),e.title&&(Ht("u-title",c).textContent=e.title);const u=Wt("canvas"),d=n.ctx=u.getContext("2d"),h=Ht("u-wrap",c);Qt("click",h,e=>{e.target===f&&(xs!=us||js!=ms)&&sn.click(n,e)},!0);const m=n.under=Ht("u-under",h);h.appendChild(u);const f=n.over=Ht("u-over",h),g=+hs((e=an(e)).pxAlign,1),p=Ia(g);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const b=e.ms||.001,y=n.series=1==a?nr(e.series||[],ra,ka,!1):(x=e.series||[null],w=va,x.map((e,t)=>0==t?{}:rn({},w,e)));var x,w;const v=n.axes=nr(e.axes||[],aa,ya,!0),k=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=Ds(e.fill||null),e.dir=hs(e.dir,-1)});const C=2==a?y[1].facets[0].scale:y[0].scale,j={axes:function(){for(let e=0;est[e]):b,x=2==m.distr?st[b[1]]-st[b[0]]:u,w=t.ticks,S=t.border,C=w.show?w.size:0,j=ws(C*Rt),T=ws((2==t.alignTo?t._size-C-t.gap:t.gap)*Rt),M=t._rotate*-bs/180,L=p(t._pos*Rt),N=L+(j+T)*c;a=0==o?N:0,s=1==o?N:0,it(t.font[0],l,1==t.align?wt:2==t.align?vt:M>0?wt:M<0?vt:0==o?"center":3==r?vt:wt,M||1==o?"middle":2==r?yt:xt);let _=t.font[1]*t.lineGap,E=b.map(e=>p(i(e,m,f,g))),P=t._values;for(let e=0;e0){let e=y.some(e=>e._focus)&&tt!=_e.alpha;e&&(d.globalAlpha=tt=_e.alpha),y.forEach((e,s)=>{if(s>0&&e.show&&(ut(s,!1),ut(s,!0),null==e._paths)){let r=tt;tt!=e.alpha&&(d.globalAlpha=tt=e.alpha);let o=2==a?[0,t[s][0].length-1]:function(e){let t=Es(He-1,0,We-1),s=Es(Ue+1,0,We-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=tt;tt!=e.alpha&&(d.globalAlpha=tt=e.alpha),null!=e._paths&&dt(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,He,Ue,s),r=e.points.filter(n,t,a,s);(a||r)&&(e.points._paths=e.points.paths(n,t,He,Ue,r),dt(t,!0))}tt!=s&&(d.globalAlpha=tt=s),na("drawSeries",t)}}),e&&(d.globalAlpha=tt=1)}}},T=(e.drawOrder||["axes","series"]).map(e=>j[e]);function M(e){const t=3==e.distr?t=>Ts(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>Ls(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return s=>{let n=t(s),{_min:a,_max:r}=e;return(n-a)/(r-a)}}function L(t){let s=k[t];if(null==s){let n=(e.scales||Ys)[t]||Ys;if(null!=n.from){L(n.from);let e=rn({},k[n.from],n,{key:t});e.valToPct=M(e),k[t]=e}else{s=k[t]=rn({},t==C?Ca:ja,n),s.key=t;let e=s.time,r=s.range,o=Xs(r);if((t!=C||2==a&&!e)&&(!o||null!=r[0]&&null!=r[1]||(r={min:null==r[0]?ls:{mode:1,hard:r[0],soft:r[0]},max:null==r[1]?ls:{mode:1,hard:r[1],soft:r[1]}},o=!1),!o&&en(r))){let e=r;r=(t,s,n)=>null==s?Ks:ds(s,n,e)}s.range=Ds(r||(e?or:t==C?3==s.distr?cr:4==s.distr?dr:rr:3==s.distr?lr:4==s.distr?ur:ir)),s.auto=Ds(!o&&s.auto),s.clamp=Ds(s.clamp||Sa),s._min=s._max=null,s.valToPct=M(s)}}}L("x"),L("y"),1==a&&y.forEach(e=>{L(e.scale)}),v.forEach(e=>{L(e.scale)});for(let ft in e.scales)L(ft);const N=k[C],_=N.distr;let E,P;0==N.ori?(Bt(c,"u-hz"),E=r,P=o):(Bt(c,"u-vt"),E=o,P=r);const D={};for(let ft in k){let e=k[ft];null==e.min&&null==e.max||(D[ft]={min:e.min,max:e.max},e.min=e.max=null)}const I=e.tzDate||(e=>new Date(ws(e/b))),F=e.fmtDate||bn,A=1==b?zn(I):$n(I),R=Hn(I,Wn(1==b?Rn:On,F)),z=Gn(I,qn("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",F)),B=[],O=n.legend=rn({},Jn,e.legend),$=n.cursor=rn({},Xn,{drag:{y:2==a}},e.cursor),W=O.show,H=$.show,U=O.markers;let q,G,J;O.idxs=B,U.width=Ds(U.width),U.dash=Ds(U.dash),U.stroke=Ds(U.stroke),U.fill=Ds(U.fill);let Y,V=[],K=[],X=!1,Q={};if(O.live){const e=y[1]?y[1].values:null;X=null!=e,Y=X?e(n,1,0):{_:0};for(let t in Y)Q[t]=Pt}if(W)if(q=Wt("table","u-legend",c),J=Wt("tbody",null,q),O.mount(n,q),X){G=Wt("thead",null,q,J);let e=Wt("tr",null,G);for(var Z in Wt("th",null,e),Y)Wt("th",gt,e).textContent=Z}else Bt(q,"u-inline"),O.live&&Bt(q,"u-live");const ee={show:!0},te={show:!1},se=new Map;function ne(e,t,s,a=!0){const r=se.get(t)||{},o=$.bind[e](n,t,s,a);o&&(Qt(e,t,r[e]=o),se.set(t,r))}function ae(e,t,s){const n=se.get(t)||{};for(let a in n)null!=e&&a!=e||(Zt(a,t,n[a]),delete n[a]);null==e&&se.delete(t)}let re=0,oe=0,ie=0,le=0,ce=0,ue=0,de=ce,he=ue,me=ie,fe=le,ge=0,pe=0,be=0,ye=0;n.bbox={};let xe=!1,we=!1,ve=!1,ke=!1,Se=!1,Ce=!1;function je(e,t,s){(s||e!=n.width||t!=n.height)&&Te(e,t),Ut(!1),ve=!0,we=!0,Ws()}function Te(e,t){n.width=re=ie=e,n.height=oe=le=t,ce=ue=0,function(){let e=!1,t=!1,s=!1,n=!1;v.forEach((a,r)=>{if(a.show&&a._show){let{side:r,_size:o}=a,i=r%2,l=o+(null!=a.label?a.labelSize:0);l>0&&(i?(ie-=l,3==r?(ce+=l,n=!0):s=!0):(le-=l,0==r?(ue+=l,e=!0):t=!0))}}),ze[0]=e,ze[1]=s,ze[2]=t,ze[3]=n,ie-=$e[1]+$e[3],ce+=$e[3],le-=$e[2]+$e[0],ue+=$e[0]}(),function(){let e=ce+ie,t=ue+le,s=ce,n=ue;function a(a,r){switch(a){case 1:return e+=r,e-r;case 2:return t+=r,t-r;case 3:return s-=r,s+r;case 0:return n-=r,n+r}}v.forEach((e,t)=>{if(e.show&&e._show){let t=e.side;e._pos=a(t,e._size),null!=e.label&&(e._lpos=a(t,e.labelSize))}})}();let s=n.bbox;ge=s.left=$s(ce*Rt,.5),pe=s.top=$s(ue*Rt,.5),be=s.width=$s(ie*Rt,.5),ye=s.height=$s(le*Rt,.5)}const Me=3;if(n.setSize=function({width:e,height:t}){je(e,t)},null==$.dataIdx){let e=$.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=Ds(e.prox),a=e.bias??(e.bias=0);$.dataIdx=(e,r,o,i)=>{if(0==r)return o;let l=o,c=n(e,r,o,i)??Ns,u=c>=0&&c0;)s.has(f[e])||(t=e);if(0==a||1==a)for(e=o;null==n&&e++c&&(l=null);return l}}const Le=e=>{$.event=e};$.idxs=B,$._lock=!1;let Ne=$.points;Ne.show=Ds(Ne.show),Ne.size=Ds(Ne.size),Ne.stroke=Ds(Ne.stroke),Ne.width=Ds(Ne.width),Ne.fill=Ds(Ne.fill);const _e=n.focus=rn({},e.focus||{alpha:.3},$.focus),Ee=_e.prox>=0,Pe=Ee&&Ne.one;let De=[],Ie=[],Fe=[];function Ae(e,t){let s=Ne.show(n,t);if(s instanceof HTMLElement)return Bt(s,"u-cursor-pt"),Bt(s,e.class),qt(s,-10,-10,ie,le),f.insertBefore(s,De[t]),s}function Re(e,t){if(1==a||t>0){let t=1==a&&k[e.scale].time,s=e.value;e.value=t?Zs(s)?Gn(I,qn(s,F)):s||z:s||ba,e.label=e.label||(t?"Time":"Value")}if(Pe||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||tr||As,e.fillTo=Ds(e.fillTo||_a),e.pxAlign=+hs(e.pxAlign,g),e.pxRound=Ia(e.pxAlign),e.stroke=Ds(e.stroke||null),e.fill=Ds(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=Us(1*(3+2*(Ss(1,e.width)||1)),3),s=e.points=rn({},{size:t,width:Ss(1,.2*t),stroke:e.stroke,space:2*t,paths:sr,_stroke:null,_fill:null},e.points);s.show=Ds(s.show),s.filter=Ds(s.filter),s.fill=Ds(s.fill),s.stroke=Ds(s.stroke),s.paths=Ds(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(X||!O.live||2==a))return Ks;let s=[],r=Wt("tr","u-series",J,J.childNodes[t]);Bt(r,e.class),e.show||Bt(r,ft);let o=Wt("th",null,r);if(U.show){let e=Ht("u-marker",o);if(t>0){let s=U.width(n,t);s&&(e.style.border=s+"px "+U.dash(n,t)+" "+U.stroke(n,t)),e.style.background=U.fill(n,t)}}let i=Ht(gt,o);for(var l in e.label instanceof HTMLElement?i.appendChild(e.label):i.textContent=e.label,t>0&&(U.show||(i.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),ne("click",o,t=>{if($._lock)return;Le(t);let s=y.indexOf(e);if((t.ctrlKey||t.metaKey)!=O.isolate){let e=y.some((e,t)=>t>0&&t!=s&&e.show);y.forEach((t,n)=>{n>0&&mn(n,e?n==s?ee:te:ee,!0,da.setSeries)})}else mn(s,{show:!e.show},!0,da.setSeries)},!1),Ee&&ne(Mt,o,t=>{$._lock||(Le(t),mn(y.indexOf(e),yn,!0,da.setSeries))},!1)),Y){let e=Wt("td","u-value",r);e.textContent="--",s.push(e)}return[r,s]}(e,t);V.splice(t,0,s[0]),K.splice(t,0,s[1]),O.values.push(null)}if(H){B.splice(t,0,null);let s=null;Pe?0==t&&(s=Ae(e,t)):t>0&&(s=Ae(e,t)),De.splice(t,0,s),Ie.splice(t,0,0),Fe.splice(t,0,0)}na("addSeries",t)}n.addSeries=function(e,t){t=null==t?y.length:t,e=1==a?ar(e,t,ra,ka):ar(e,t,{},va),y.splice(t,0,e),Re(y[t],t)},n.delSeries=function(e){if(y.splice(e,1),W){O.values.splice(e,1),K.splice(e,1);let t=V.splice(e,1)[0];ae(null,t.firstChild),t.remove()}H&&(B.splice(e,1),De.splice(e,1)[0].remove(),Ie.splice(e,1),Fe.splice(e,1)),na("delSeries",e)};const ze=[!1,!1,!1,!1];function Be(e,t,s,n){let[a,r,o,i]=s,l=t%2,c=0;return 0==l&&(i||r)&&(c=0==t&&!a||2==t&&!o?ws(aa.size/3):0),1==l&&(a||o)&&(c=1==t&&!r||3==t&&!i?ws(ya.size/2):0),c}const Oe=n.padding=(e.padding||[Be,Be,Be,Be]).map(e=>Ds(hs(e,Be))),$e=n._padding=Oe.map((e,t)=>e(n,t,ze,0));let We,He=null,Ue=null;const qe=1==a?y[0].idxs:null;let Ge,Je,Ye,Ve,Ke,Xe,Qe,Ze,et,tt,st=null,nt=!1;function at(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){We=0;for(let e=1;e=0,Ce=!0,Ws()}}function rt(){let e,s;nt=!0,1==a&&(We>0?(He=qe[0]=0,Ue=qe[1]=We-1,e=t[0][He],s=t[0][Ue],2==_?(e=He,s=Ue):e==s&&(3==_?[e,s]=os(e,e,N.log,!1):4==_?[e,s]=is(e,e,N.log,!1):N.time?s=e+ws(86400/b):[e,s]=ds(e,s,.1,!0))):(He=qe[0]=e=null,Ue=qe[1]=s=null)),hn(C,e,s)}function ot(e,t,s,n,a,r){e??(e=St),s??(s=Vs),n??(n="butt"),a??(a=St),r??(r="round"),e!=Ge&&(d.strokeStyle=Ge=e),a!=Je&&(d.fillStyle=Je=a),t!=Ye&&(d.lineWidth=Ye=t),r!=Ke&&(d.lineJoin=Ke=r),n!=Xe&&(d.lineCap=Xe=n),s!=Ve&&d.setLineDash(Ve=s)}function it(e,t,s,n){t!=Je&&(d.fillStyle=Je=t),e!=Qe&&(d.font=Qe=e),s!=Ze&&(d.textAlign=Ze=s),n!=et&&(d.textBaseline=et=n)}function lt(e,t,s,a,r=0){if(a.length>0&&e.auto(n,nt)&&(null==t||null==t.min)){let t=hs(He,0),n=hs(Ue,a.length-1),o=null==s.min?function(e,t,s,n=0,a=!1){let r=a?rs:as,o=a?ns:ss;[t,s]=r(e,t,s);let i=e[t],l=e[t];if(t>-1)if(1==n)i=e[t],l=e[s];else if(-1==n)i=e[s],l=e[t];else for(let c=t;c<=s;c++){let t=e[c];o(t)&&(tl&&(l=t))}return[i??Ns,l??-Ns]}(a,t,n,r,3==e.distr):[s.min,s.max];e.min=ks(e.min,s.min=o[0]),e.max=Ss(e.max,s.max=o[1])}}n.setData=at;const ct={min:null,max:null};function ut(e,t){let s=t?y[e].points:y[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function dt(e,s){let a=s?y[e].points:y[e],{stroke:r,fill:o,clip:i,flags:l,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=Us(h*Rt,3);let m=null,f=h%2/2;s&&null==u&&(u=h>0?"#fff":c);let g=1==a.pxAlign&&f>0;if(g&&d.translate(f,f),!s){let e=ge-h/2,t=pe-h/2,s=be+h,n=ye+h;m=new Path2D,m.rect(e,t,s,n)}s?mt(c,h,a.dash,a.cap,u,r,o,l,i):function(e,s,a,r,o,i,l,c,u,d,h){let m=!1;0!=u&&S.forEach((f,g)=>{if(f.series[0]==e){let e,p=y[f.series[1]],b=t[f.series[1]],x=(p._paths||Ys).band;Xs(x)&&(x=1==f.dir?x[0]:x[1]);let w=null;p.show&&x&&function(e,t,s){for(t=hs(t,0),s=hs(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(b,He,Ue)?(w=f.fill(n,g)||i,e=p._paths.clip):x=null,mt(s,a,r,o,w,l,c,u,d,h,e,x),m=!0}}),m||mt(s,a,r,o,i,l,c,u,d,h)}(e,c,h,a.dash,a.cap,u,r,o,l,m,i),g&&d.translate(-f,-f)}const ht=3;function mt(e,t,s,n,a,r,o,i,l,c,u,h){ot(e,t,s,n,a),(l||c||h)&&(d.save(),l&&d.clip(l),c&&d.clip(c)),h?(i&ht)==ht?(d.clip(h),u&&d.clip(u),_t(a,o),kt(e,r,t)):2&i?(_t(a,o),d.clip(h),kt(e,r,t)):1&i&&(d.save(),d.clip(h),u&&d.clip(u),_t(a,o),d.restore(),kt(e,r,t)):(_t(a,o),kt(e,r,t)),(l||c||h)&&d.restore()}function kt(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=Ge=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function _t(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=Je=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function Dt(e,t,s,n,a,r,o,i,l,c){let u=o%2/2;1==g&&d.translate(u,u),ot(i,o,l,c,i),d.beginPath();let h,m,f,p,b=a+(0==n||3==n?-r:r);0==s?(m=a,p=b):(h=a,f=b);for(let g=0;g{if(!s.show)return;let r=k[s.scale];if(null==r.min)return void(s._show&&(t=!1,s._show=!1,Ut(!1)));s._show||(t=!1,s._show=!0,Ut(!1));let o=s.side,i=o%2,{min:l,max:c}=r,[u,d]=function(e,t,s,a){let r,o=v[e];if(a<=0)r=[0,0];else{let i=o._space=o.space(n,e,t,s,a);r=function(e,t,s,n,a){let r=Ss(_s(e),_s(t)),o=t-e,i=es(a/n*o,s);do{let e=s[i],t=n*e/o;if(t>=a&&r+(e<5?qs.get(e):0)<=17)return[e,t]}while(++ist[e]):m,g=2==r.distr?st[m[1]]-st[m[0]]:u,p=s._values=s.values(n,s.filter(n,f,a,d,g),a,d,g);s._rotate=2==o?s.rotate(n,p,a,d):0;let b=s._size;s._size=vs(s.size(n,p,a,e)),null!=b&&s._size!=b&&(t=!1)}),t}function zt(e){let t=!0;return Oe.forEach((s,a)=>{let r=s(n,a,ze,e);r!=$e[a]&&(t=!1),$e[a]=r}),t}function Ut(e){y.forEach((t,s)=>{s>0&&(t._paths=null,e&&(1==a?(t.min=null,t.max=null):t.facets.forEach(e=>{e.min=null,e.max=null})))})}let Gt,Yt,Kt,Xt,ts,cs,us,ms,fs,gs,xs,js,Ms=!1,Is=!1,Bs=[];function Os(){Is=!1;for(let e=0;e0){y.forEach((s,r)=>{if(1==a){let a=s.scale,o=D[a];if(null==o)return;let i=e[a];if(0==r){let e=i.range(n,i.min,i.max,a);i.min=e[0],i.max=e[1],He=es(i.min,t[0]),Ue=es(i.max,t[0]),Ue-He>1&&(t[0][He]i.max&&Ue--),s.min=st[He],s.max=st[Ue]}else s.show&&s.auto&<(i,o,s,t[r],s.sorted);s.idxs[0]=He,s.idxs[1]=Ue}else if(r>0&&s.show&&s.auto){let[n,a]=s.facets,o=n.scale,i=a.scale,[l,c]=t[r],u=e[o],d=e[i];null!=u&<(u,D[o],n,l,n.sorted),null!=d&<(d,D[i],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=D[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==Ns?null:s.min,s.max==-Ns?null:s.max,t);s.min=e[0],s.max=e[1]}}}for(let t in e){let s=e[t];if(null!=s.from){let a=e[s.from];if(null==a.min)s.min=s.max=null;else{let e=s.range(n,a.min,a.max,t);s.min=e[0],s.max=e[1]}}}let s={},r=!1;for(let t in e){let n=e[t],a=k[t];if(a.min!=n.min||a.max!=n.max){a.min=n.min,a.max=n.max;let e=a.distr;a._min=3==e?Ts(a.min):4==e?Ls(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?Ts(a.max):4==e?Ls(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=r=!0}}if(r){y.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)ve=!0,na("setScale",e);H&&$.left>=0&&(ke=Ce=!0)}for(let t in D)D[t]=null}(),xe=!1),ve&&(function(){let e=!1,t=0;for(;!e;){t++;let s=At(t),a=zt(t);e=t==Me||s&&a,e||(Te(n.width,n.height),we=!0)}}(),ve=!1),we){if($t(m,wt,ce),$t(m,yt,ue),$t(m,pt,ie),$t(m,bt,le),$t(f,wt,ce),$t(f,yt,ue),$t(f,pt,ie),$t(f,bt,le),$t(h,pt,re),$t(h,bt,oe),u.width=ws(re*Rt),u.height=ws(oe*Rt),v.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;$t(e,t?"left":"top",n-(3===a||0===a?s:0)),$t(e,t?"width":"height",s),$t(e,t?"top":"left",t?ue:ce),$t(e,t?"height":"width",t?le:ie),Ot(e,ft)}else Bt(e,ft)}),Ge=Je=Ye=Ke=Xe=Qe=Ze=et=Ve=null,tt=1,_n(!0),ce!=de||ue!=he||ie!=me||le!=fe){Ut(!1);let e=ie/me,t=le/fe;if(H&&!ke&&$.left>=0){$.left*=e,$.top*=t,Kt&&qt(Kt,ws($.left),0,ie,le),Xt&&qt(Xt,0,ws($.top),ie,le);for(let s=0;s=0&&cn.width>0){cn.left*=e,cn.width*=e,cn.top*=t,cn.height*=t;for(let e in Dn)$t(un,e,cn[e])}de=ce,he=ue,me=ie,fe=le}na("setSize"),we=!1}re>0&&oe>0&&(d.clearRect(0,0,u.width,u.height),na("drawClear"),T.forEach(e=>e()),na("draw")),cn.show&&Se&&(dn(cn),Se=!1),H&&ke&&(Ln(null,!0,!1),ke=!1),O.show&&O.live&&Ce&&(Tn(),Ce=!1),l||(l=!0,n.status=1,na("ready")),nt=!1,Ms=!1}function Js(e,s){let a=k[e];if(null==a.from){if(0==We){let t=a.range(n,s.min,s.max,e);s.min=t[0],s.max=t[1]}if(s.min>s.max){let e=s.min;s.min=s.max,s.max=e}if(We>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==C&&2==a.distr&&We>0&&(s.min=es(s.min,t[0]),s.max=es(s.max,t[0]),s.min==s.max&&s.max++),D[e]=s,xe=!0,Ws()}}n.batch=function(e,t=!1){Ms=!0,Is=t,e(n),Hs(),t&&Bs.length>0&&queueMicrotask(Os)},n.redraw=(e,t)=>{ve=t||!1,!1!==e?hn(C,N.min,N.max):Ws()},n.setScale=Js;let Qs=!1;const sn=$.drag;let nn=sn.x,on=sn.y;H&&($.x&&(Gt=Ht("u-cursor-x",f)),$.y&&(Yt=Ht("u-cursor-y",f)),0==N.ori?(Kt=Gt,Xt=Yt):(Kt=Yt,Xt=Gt),xs=$.left,js=$.top);const cn=n.select=rn({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),un=cn.show?Ht("u-select",cn.over?f:m):null;function dn(e,t){if(cn.show){for(let t in e)cn[t]=e[t],t in Dn&&$t(un,t,e[t]);!1!==t&&na("setSelect")}}function hn(e,t,s){Js(e,{min:t,max:s})}function mn(e,t,s,r){null!=t.focus&&function(e){if(e!=pn){let t=null==e,s=1!=_e.alpha;y.forEach((n,r)=>{if(1==a||r>0){let a=t||0==r||r==e;n._focus=t?null:a,s&&function(e,t){y[e].alpha=t,H&&null!=De[e]&&(De[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(r,a?1:_e.alpha)}}),pn=e,s&&Ws()}}(e),null!=t.show&&y.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(y[e].show)W&&Ot(V[e],ft);else if(W&&Bt(V[e],ft),H){let t=Pe?De[0]:De[e];null!=t&&qt(t,-10,-10,ie,le)}}(n),2==a?(hn(s.facets[0].scale,null,null),hn(s.facets[1].scale,null,null)):hn(s.scale,null,null),Ws())}),!1!==s&&na("setSeries",e,t),r&&fa("setSeries",n,e,t)}let fn,gn,pn;n.setSelect=dn,n.setSeries=mn,n.addBand=function(e,t){e.fill=Ds(e.fill||null),e.dir=hs(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){rn(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const yn={focus:!0};function xn(e,t,s){let n=k[t];s&&(e=e/Rt-(1==n.ori?ue:ce));let a=ie;1==n.ori&&(a=le,e=a-e),-1==n.dir&&(e=a-e);let r=n._min,o=r+(n._max-r)*(e/a),i=n.distr;return 3==i?Cs(10,o):4==i?((e,t=1)=>ps.sinh(e)*t)(o,n.asinh):100==i?n.bwd(o):o}function wn(e,t){$t(un,wt,cn.left=e),$t(un,pt,cn.width=t)}function vn(e,t){$t(un,yt,cn.top=e),$t(un,bt,cn.height=t)}W&&Ee&&ne(Lt,q,e=>{$._lock||(Le(e),null!=pn&&mn(null,yn,!0,da.setSeries))}),n.valToIdx=e=>es(e,t[0]),n.posToIdx=function(e,s){return es(xn(e,C,s),t[0],He,Ue)},n.posToVal=xn,n.valToPos=(e,t,s)=>0==k[t].ori?r(e,k[t],s?be:ie,s?ge:0):o(e,k[t],s?ye:le,s?pe:0),n.setCursor=(e,t,s)=>{xs=e.left,js=e.top,Ln(null,t,s)};let kn=0==N.ori?wn:vn,jn=1==N.ori?wn:vn;function Tn(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{B[t]=e}):void 0!==e.idx&&B.fill(e.idx),O.idx=B[0]),W&&O.live){for(let e=0;e0||1==a&&!X)&&Mn(e,B[e]);!function(){if(W&&O.live)for(let e=2==a?1:0;eUe;fn=Ns,gn=null;let l=0==N.ori?ie:le,c=1==N.ori?ie:le;if(xs<0||0==We||i){o=$.idx=null;for(let e=0;e0&&e.show){let s=null==w?-10:w==o?r:E(1==a?t[0][w]:t[p][0][w],N,l,0),b=null==v?-10:P(v,1==a?k[e.scale]:k[e.facets[1].scale],c,0);if(Ee&&null!=v){let t=1==N.ori?xs:js,s=ys(_e.dist(n,p,w,b,t));if(s=0?1:-1;r==(v>=0?1:-1)&&(1==r?1==n?v>=a:v<=a:1==n?v<=a:v>=a)&&(fn=s,gn=p)}else fn=s,gn=p}}if(Ce||Pe){let e,t;0==N.ori?(e=s,t=b):(e=b,t=s);let a,r,o,l,c,y,x=!0,w=Ne.bbox;if(null!=w){x=!1;let e=w(n,p);o=e.left,l=e.top,a=e.width,r=e.height}else o=e,l=t,a=r=Ne.size(n,p);if(y=Ne.fill(n,p),c=Ne.stroke(n,p),Pe)p==gn&&fn<=_e.prox&&(i=o,u=l,d=a,h=r,m=x,f=y,g=c);else{let e=De[p];null!=e&&(Ie[p]=o,Fe[p]=l,Vt(e,a,r,x),Jt(e,y,c),qt(e,vs(o),vs(l),ie,le))}}}}if(Pe){let e=_e.prox;if(Ce||(null==pn?fn<=e:fn>e||gn!=pn)){let e=De[0];null!=e&&(Ie[0]=i,Fe[0]=u,Vt(e,d,h,m),Jt(e,f,g),qt(e,vs(i),vs(u),ie,le))}}}if(cn.show&&Qs)if(null!=e){let[t,s]=da.scales,[n,a]=da.match,[r,o]=e.cursor.sync.scales,i=e.cursor.drag;if(nn=i._x,on=i._y,nn||on){let i,u,d,h,m,{left:f,top:g,width:p,height:b}=e.select,y=e.scales[r].ori,x=e.posToVal,w=null!=t&&n(t,r),v=null!=s&&a(s,o);w&&nn?(0==y?(i=f,u=p):(i=g,u=b),d=k[t],h=E(x(i,r),d,l,0),m=E(x(i+u,r),d,l,0),kn(ks(h,m),ys(m-h))):kn(0,l),v&&on?(1==y?(i=f,u=p):(i=g,u=b),d=k[s],h=P(x(i,o),d,c,0),m=P(x(i+u,o),d,c,0),jn(ks(h,m),ys(m-h))):jn(0,c)}else In()}else{let e=ys(fs-ts),t=ys(gs-cs);if(1==N.ori){let s=e;e=t,t=s}nn=sn.x&&e>=sn.dist,on=sn.y&&t>=sn.dist;let s,n,a=sn.uni;null!=a?nn&&on&&(nn=e>=a,on=t>=a,nn||on||(t>e?on=!0:nn=!0)):sn.x&&sn.y&&(nn||on)&&(nn=on=!0),nn&&(0==N.ori?(s=us,n=xs):(s=ms,n=js),kn(ks(s,n),ys(n-s)),on||jn(0,c)),on&&(1==N.ori?(s=us,n=xs):(s=ms,n=js),jn(ks(s,n),ys(n-s)),nn||kn(0,l)),nn||on||(kn(0,0),jn(0,0))}if(sn._x=nn,sn._y=on,null==e){if(r){if(null!=ha){let[e,t]=da.scales;da.values[0]=null!=e?xn(0==N.ori?xs:js,e):null,da.values[1]=null!=t?xn(1==N.ori?xs:js,t):null}fa(Ct,n,xs,js,ie,le,o)}if(Ee){let e=r&&da.setSeries,t=_e.prox;null==pn?fn<=t&&mn(gn,yn,!0,e):fn>t?mn(null,yn,!0,e):gn!=pn&&mn(gn,yn,!0,e)}}Ce&&(O.idx=o,Tn()),!1!==s&&na("setCursor")}n.setLegend=Tn;let Nn=null;function _n(e=!1){e?Nn=null:(Nn=f.getBoundingClientRect(),na("syncRect",Nn))}function En(e,t,s,n,a,r,o){$._lock||Qs&&null!=e&&0==e.movementX&&0==e.movementY||(Pn(e,t,s,n,a,r,0,!1,null!=e),null!=e?Ln(null,!0,!0):Ln(t,!0,!1))}function Pn(e,t,s,a,r,o,l,c,u){if(null==Nn&&_n(!1),Le(e),null!=e)s=e.clientX-Nn.left,a=e.clientY-Nn.top;else{if(s<0||a<0)return xs=-10,void(js=-10);let[e,n]=da.scales,l=t.cursor.sync,[c,u]=l.values,[d,h]=l.scales,[m,f]=da.match,g=t.axes[0].side%2==1,p=0==N.ori?ie:le,b=1==N.ori?ie:le,y=g?o:r,x=g?r:o,w=g?a:s,v=g?s:a;if(s=null!=d?m(e,d)?i(c,k[e],p,0):-10:p*(w/y),a=null!=h?f(n,h)?i(u,k[n],b,0):-10:b*(v/x),1==N.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=Ct||((s<=1||s>=ie-1)&&(s=$s(s,ie)),(a<=1||a>=le-1)&&(a=$s(a,le))),c?(ts=s,cs=a,[us,ms]=$.move(n,s,a)):(xs=s,js=a)}Object.defineProperty(n,"rect",{get:()=>(null==Nn&&_n(!1),Nn)});const Dn={width:0,height:0,left:0,top:0};function In(){dn(Dn,!1)}let Fn,Un,Yn,Vn;function Kn(e,t,s,a,r,o,i){Qs=!0,nn=on=sn._x=sn._y=!1,Pn(e,t,s,a,r,o,0,!0,!1),null!=e&&(ne(Tt,It,Qn,!1),fa(jt,n,us,ms,ie,le,null));let{left:l,top:c,width:u,height:d}=cn;Fn=l,Un=c,Yn=u,Vn=d}function Qn(e,t,s,a,r,o,i){Qs=sn._x=sn._y=!1,Pn(e,t,s,a,r,o,0,!1,!0);let{left:l,top:c,width:u,height:d}=cn,h=u>0||d>0,m=Fn!=l||Un!=c||Yn!=u||Vn!=d;if(h&&m&&dn(cn),sn.setScale&&h&&m){let e=l,t=u,s=c,n=d;if(1==N.ori&&(e=c,t=d,s=l,n=u),nn&&hn(C,xn(e,C),xn(e+t,C)),on)for(let a in k){let e=k[a];a!=C&&null==e.from&&e.min!=Ns&&hn(a,xn(s+n,a),xn(s,a))}In()}else $.lock&&($._lock=!$._lock,Ln(t,!0,null!=e));null!=e&&(ae(Tt,It),fa(Tt,n,xs,js,ie,le,null))}function Zn(e,t,s,a,r,o,i){$._lock||(Le(e),rt(),In(),null!=e&&fa(Nt,n,xs,js,ie,le,null))}function ea(){v.forEach(mr),je(n.width,n.height,!0)}Qt(Et,Ft,ea);const ta={};ta.mousedown=Kn,ta.mousemove=En,ta.mouseup=Qn,ta.dblclick=Zn,ta.setSeries=(e,t,s,a)=>{-1!=(s=(0,da.match[2])(n,t,s))&&mn(s,a,!0,!1)},H&&(ne(jt,f,Kn),ne(Ct,f,En),ne(Mt,f,e=>{Le(e),_n(!1)}),ne(Lt,f,function(e,t,s,n,a,r,o){if($._lock)return;Le(e);let i=Qs;if(Qs){let e,t,s=!0,n=!0,a=10;0==N.ori?(e=nn,t=on):(e=on,t=nn),e&&t&&(s=xs<=a||xs>=ie-a,n=js<=a||js>=le-a),e&&s&&(xs=xs{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)sa[t]=(sa[t]||[]).concat(e.hooks[t])});const ua=(e,t,s)=>s,da=rn({key:null,setSeries:!1,filters:{pub:Rs,sub:Rs},scales:[C,y[1]?y[1].scale:null],match:[zs,zs,ua],values:[null,null]},$.sync);2==da.match.length&&da.match.push(ua),$.sync=da;const ha=da.key,ma=Ma(ha);function fa(e,t,s,n,a,r,o){da.filters.pub(e,t,s,n,a,r,o)&&ma.pub(e,t,s,n,a,r,o)}function xa(){na("init",e,t),at(t||e.data,!1),D[C]?Js(C,D[C]):rt(),Se=cn.show&&(cn.width>0||cn.height>0),ke=Ce=!0,je(e.width,e.height)}return ma.sub(n),n.pub=function(e,t,s,n,a,r,o){da.filters.sub(e,t,s,n,a,r,o)&&ta[e](null,t,s,n,a,r,o)},n.destroy=function(){ma.unsub(n),Za.delete(n),se.clear(),Zt(Et,Ft,ea),c.remove(),null==q||q.remove(),na("destroy")},y.forEach(Re),v.forEach(function(e,t){if(e._show=e.show,e.show){let s=e.side%2,a=k[e.scale];null==a&&(e.scale=s?y[1].scale:C,a=k[e.scale]);let r=a.time;e.size=Ds(e.size),e.space=Ds(e.space),e.rotate=Ds(e.rotate),Xs(e.incrs)&&e.incrs.forEach(e=>{!qs.has(e)&&qs.set(e,Gs(e))}),e.incrs=Ds(e.incrs||(2==a.distr?Sn:r?1==b?An:Bn:Cn)),e.splits=Ds(e.splits||(r&&1==a.distr?A:3==a.distr?la:4==a.distr?ca:ia)),e.stroke=Ds(e.stroke),e.grid.stroke=Ds(e.grid.stroke),e.ticks.stroke=Ds(e.ticks.stroke),e.border.stroke=Ds(e.border.stroke);let o=e.values;e.values=Xs(o)&&!Xs(o[0])?Ds(o):r?Xs(o)?Hn(I,Wn(o,F)):Zs(o)?function(e,t){let s=bn(t);return(t,n,a,r,o)=>n.map(t=>s(e(t)))}(I,o):o||R:o||oa,e.filter=Ds(e.filter||(a.distr>=3&&10==a.log?ga:3==a.distr&&2==a.log?pa:Fs)),e.font=hr(e.font),e.labelFont=hr(e.labelFont),e._size=e.size(n,null,t,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(ze[t]=!0,e._el=Ht("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),xa()):s(n,xa):xa(),n}fr.assign=rn,fr.fmtNum=gs,fr.rangeNum=ds,fr.rangeLog=os,fr.rangeAsinh=is,fr.orient=La,fr.pxRatio=Rt,fr.join=function(e,t){if(function(e){let t=e[0][0],s=t.length;for(let n=1;n=n&&null==e[a];)a--;if(a<=n)return!0;const r=Ss(1,xs((a-n+1)/t));for(let o=e[n],i=n+r;i<=a;i+=r){const t=e[i];if(null!=t){if(t<=o)return!1;o=t}}return!0}(t[0])||(t=function(e){let t=e[0],s=t.length,n=Array(s);for(let r=0;rt[e]-t[s]);let a=[];for(let r=0;re-t)],a=n[0].length,r=new Map;for(let o=0;oLa(e,r,(l,c,u,d,h,m,f,g,p,b,y)=>{[o,i]=as(u,o,i);let x=l.pxRound,{left:w,width:v}=e.bbox,k=e=>x(m(e,d,b,g)),S=e=>x(f(e,h,y,p)),C=0==d.ori?za:Ba;const j={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=j.stroke,M=d.dir*(0==d.ori?1:-1);let L=S(u[1==M?o:i]),N=k(c[1==M?o:i]),_=N,E=N;a&&-1==t&&(E=w,C(T,E,L)),C(T,N,L);for(let e=1==M?o:i;e>=o&&e<=i;e+=M){let s=u[e];if(null==s)continue;let n=k(c[e]),a=S(s);1==t?C(T,n,L):C(T,_,a),C(T,n,a),L=a,_=n}let P=_;a&&1==t&&(P=w+v,C(T,P,L));let[D,I]=Na(e,r);if(null!=l.fill||0!=D){let t=j.fill=new Path2D(T),s=S(l.fillTo(e,r,l.min,l.max,D));C(t,P,s),C(t,E,s)}if(!l.spanGaps){let a=[];a.push(...Da(c,u,o,i,M,k,n));let h=l.width*Rt/2,m=s||1==t?h:-h,f=s||-1==t?-h:h;a.forEach(e=>{e[0]+=m,e[1]+=f}),j.gaps=a=l.gaps(e,r,o,i,a),j.clip=Pa(a,d.ori,g,p,b,y)}return 0!=I&&(j.band=2==I?[Ea(e,r,o,i,T,-1),Ea(e,r,o,i,T,1)]:Ea(e,r,o,i,T,I)),j})},e.bars=function(e){const t=hs((e=e||Ys).size,[.6,Ns,1]),s=e.align||0,n=e.gap||0;let a=e.radius;a=null==a?[0,0]:"number"==typeof a?[a,0]:a;const r=Ds(a),o=1-t[0],i=hs(t[1],Ns),l=hs(t[2],1),c=hs(e.disp,Ys),u=hs(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,m)=>La(e,t,(f,g,p,b,y,x,w,v,k,S,C)=>{let j,T,M=f.pxRound,L=s,N=n*Rt,_=i*Rt,E=l*Rt;0==b.ori?[j,T]=r(e,t):[T,j]=r(e,t);const P=b.dir*(0==b.ori?1:-1);let D,I,F,A=0==b.ori?Oa:$a,R=0==b.ori?u:(e,t,s,n,a,r,o)=>{u(e,t,s,a,n,o,r)},z=hs(e.bands,Vs).find(e=>e.series[0]==t),B=null!=z?z.dir:0,O=f.fillTo(e,t,f.min,f.max,B),$=M(w(O,y,C,k)),W=S,H=M(f.width*Rt),U=!1,q=null,G=null,J=null,Y=null;null==d||0!=H&&null==h||(U=!0,q=d.values(e,t,a,m),G=new Map,new Set(q).forEach(e=>{null!=e&&G.set(e,new Path2D)}),H>0&&(J=h.values(e,t,a,m),Y=new Map,new Set(J).forEach(e=>{null!=e&&Y.set(e,new Path2D)})));let{x0:V,size:K}=c;if(null!=V&&null!=K){L=1,g=V.values(e,t,a,m),2==V.unit&&(g=g.map(t=>e.posToVal(v+t*S,b.key,!0)));let s=K.values(e,t,a,m);I=2==K.unit?s[0]*S:x(s[0],b,S,v)-x(0,b,S,v),W=Xa(g,p,x,b,S,v,W),F=W-I+N}else W=Xa(g,p,x,b,S,v,W),F=W*o+N,I=W-F;F<1&&(F=0),H>=I/2&&(H=0),F<5&&(M=Is);let X=F>0;I=M(Es(W-F-(X?H:0),E,_)),D=(0==L?I/2:L==P?0:I)-L*P*((0==L?N/2:0)+(X?H/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Z=U?null:new Path2D;let ee=null;if(null!=z)ee=e.data[z.series[1]];else{let{y0:s,y1:n}=c;null!=s&&null!=n&&(p=n.values(e,t,a,m),ee=s.values(e,t,a,m))}let te=j*I,se=T*I;for(let s=1==P?a:m;s>=a&&s<=m;s+=P){let n=p[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;$=w(e,y,C,k)}let a=x(2!=b.distr||null!=c?g[s]:s,b,S,v),r=w(hs(n,O),y,C,k),o=M(a-D),i=M(Ss(r,$)),l=M(ks(r,$)),u=i-l;if(null!=n){let a=n<0?se:te,r=n<0?te:se;U?(H>0&&null!=J[s]&&A(Y.get(J[s]),o,l+xs(H/2),I,Ss(0,u-H),a,r),null!=q[s]&&A(G.get(q[s]),o,l+xs(H/2),I,Ss(0,u-H),a,r)):A(Z,o,l+xs(H/2),I,Ss(0,u-H),a,r),R(e,t,s,o-H/2,l,I+H,u)}}return H>0?Q.stroke=U?Y:Z:U||(Q._fill=0==f.width?f._fill:f._stroke??f._fill,Q.width=0),Q.fill=U?G:Z,Q})},e.spline=function(e){return function(e,t){const s=hs(null==t?void 0:t.alignGaps,0);return(t,n,a,r)=>La(t,n,(o,i,l,c,u,d,h,m,f,g,p)=>{[a,r]=as(l,a,r);let b,y,x,w=o.pxRound,v=e=>w(d(e,c,g,m)),k=e=>w(h(e,u,p,f));0==c.ori?(b=Aa,x=za,y=Ua):(b=Ra,x=Ba,y=qa);const S=c.dir*(0==c.ori?1:-1);let C=v(i[1==S?a:r]),j=C,T=[],M=[];for(let e=1==S?a:r;e>=a&&e<=r;e+=S)if(null!=l[e]){let t=v(i[e]);T.push(j=t),M.push(k(l[e]))}const L={stroke:e(T,M,b,x,y,w),fill:null,clip:null,band:null,gaps:null,flags:1},N=L.stroke;let[_,E]=Na(t,n);if(null!=o.fill||0!=_){let e=L.fill=new Path2D(N),s=k(o.fillTo(t,n,o.min,o.max,_));x(e,j,s),x(e,C,s)}if(!o.spanGaps){let e=[];e.push(...Da(i,l,a,r,S,v,s)),L.gaps=e=o.gaps(t,n,a,r,e),L.clip=Pa(e,c.ori,m,f,g,p)}return 0!=E&&(L.band=2==E?[Ea(t,n,a,r,N,-1),Ea(t,n,a,r,N,1)]:Ea(t,n,a,r,N,E)),L})}(Qa,e)}}const gr=new Map;function pr(e){var t;if(!e.startsWith("var("))return e;const s=gr.get(e);if(s)return s;const n=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!n)return e;const a=n[1].trim(),r=(null==(t=n[2])?void 0:t.trim())||"#888888",o=getComputedStyle(document.documentElement).getPropertyValue(a).trim()||r;return gr.set(e,o),o}const br=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:r=null,cursorColor:o="rgba(255,255,255,0.5)"}){const i=s.useRef(null),l=s.useRef(null),c=s.useRef(t),u=s.useRef(r),d=s.useRef(a),h=s.useRef(e.length);s.useLayoutEffect(()=>{c.current=t,u.current=r,d.current=a});const m=s.useMemo(()=>{const t=new Array(e.length).fill(1);return[e,t]},[e]),f=s.useMemo(()=>({hooks:{draw:e=>{!function(e,t,s){if(0===t.length)return;const n=e.ctx,a=e.bbox,r=a.left,o=a.top,i=a.width,l=a.height;if(i<=0||l<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,m=e=>{const t=c[e];return r+(t-d)/h*i},f=e=>o+l*(1-e);for(let g=0;g=0;t--){const e=m(t),s=f(r[t]);if(t===u-1)n.lineTo(e,s);else{const a=m(t+1);n.lineTo(a,s),n.lineTo(e,s)}}n.closePath(),n.fill(),n.restore()}}(e,c.current,u.current),function(e){const t=e.ctx,{left:s,top:n,width:a,height:r}=e.bbox,o=window.devicePixelRatio||1,i=function(){const e=getComputedStyle(document.documentElement);return{fontFamily:e.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:e.getPropertyValue("--text-primary").trim()||"#FFFFFF"}}();t.save(),t.strokeStyle=i.textPrimary,t.globalAlpha=.15,t.lineWidth=1*o,t.setLineDash([4*o,4*o]);for(const c of[.2,.4,.6,.8]){const e=Math.round(n+r*(1-c))+.5;t.beginPath(),t.moveTo(Math.round(s),e),t.lineTo(Math.round(s+a),e),t.stroke()}t.restore(),t.save(),t.font=`bold ${10*o}px ${i.fontFamily}`,t.fillStyle=i.textPrimary,t.textBaseline="middle",t.textAlign="left";const l=8*o;for(const c of[0,20,40,60,80,100]){const e=n+r*(1-c/100),s=Math.max(n+l,Math.min(n+r-l,e));t.fillText(`${c}%`,0,s)}t.restore()}(e)}}}),[]),g=s.useMemo(()=>({width:400,height:200,padding:[8,0,0,32],cursor:{show:!0,x:!0,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!0},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],hooks:{setCursor:[e=>{var t,s;const n=e.cursor.idx;if(null!=n&&n>=0){const s=e.data[0][n];null==(t=d.current)||t.call(d,n,s)}else null==(s=d.current)||s.call(d,null,null)}]},plugins:[f]}),[f]);s.useEffect(()=>{const t=i.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!l.current||a>100||s>0&&a/s>.1)&&l.current)return l.current.setData(m),void(h.current=n);l.current&&l.current.destroy();const r=t.getBoundingClientRect(),o=Math.floor(r.width)||400,c=Math.floor(r.height)||200,u=new fr({...g,width:o,height:c},m,t);return l.current=u,h.current=n,()=>{u.destroy(),l.current=null}},[g,m,e.length]),s.useEffect(()=>{const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!l.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&l.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{l.current&&l.current.redraw()},[r,t]);const p=s.useCallback(()=>{null==a||a(null,null)},[a]);return 0===e.length?n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available"}):n.jsx("div",{ref:i,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:p})}),yr=s.createContext(null);function xr(e){const t=Oe(e);t&&function(e){if("undefined"==typeof document)return;const t=function(e){var t;const s={},n=e.surfaces.glass;s["--glass-tint"]=n.tint,s["--glass-light"]=n.light,s["--glass-dark"]=n.dark,s["--glass-reflex-light"]=String(n.reflexLight),s["--glass-reflex-dark"]=String(n.reflexDark),s["--glass-blur"]=`${n.blur}px`,s["--glass-blur-elevated"]=`${n.blurElevated}px`,s["--glass-brightness"]=String(n.brightness),s["--glass-bg-opacity"]=`${n.opacity}%`,s["--glass-bg-opacity-elevated"]=`${n.opacityElevated}%`,s["--glass-stroke-only"]=n.strokeOnly?"1":"0",s["--glass-stroke-width"]=n.strokeWidth?`${n.strokeWidth}px`:"0px",s["--glass-stroke-color"]=n.strokeColor||"transparent",s["--glass-ribbon-mode"]=n.ribbonMode?"1":"0",s["--glass-ribbon-border-width"]=n.ribbonBorderWidth?`${n.ribbonBorderWidth}px`:"0px",s["--glass-ribbon-border-color"]=n.ribbonBorderColor||"transparent",s["--sidebar-tint"]=e.surfaces.sidebar.tint,s["--tooltip-bg"]=e.colors.bg.surface,s["--hover-tint"]=`rgba(${ee(e.colors.accent.primary)}, 0.08)`,s["--shadow-tint"]=`rgba(${ee(e.colors.accent.primary)}, 0.35)`,s["--bg-body"]=e.colors.bg.body,s["--bg-surface"]=e.colors.bg.surface,s["--bg-elevated"]=e.colors.bg.elevated,s["--bg-subtle"]=e.colors.bg.subtle,s["--border-subtle"]=e.colors.border.subtle,s["--border-strong"]=e.colors.border.strong,s["--text-primary"]=e.colors.text.primary,s["--text-secondary"]=e.colors.text.secondary,s["--text-muted"]=e.colors.text.muted,s["--text-invert"]=e.colors.text.inverse,s["--accent-primary"]=e.colors.accent.primary,s["--accent-secondary"]=e.colors.accent.secondary,s["--accent-tertiary"]=e.colors.accent.tertiary,s["--accent-success"]=e.colors.accent.success,s["--accent-danger"]=e.colors.accent.danger,s["--signal-excellent"]=e.colors.signal.excellent,s["--signal-good"]=e.colors.signal.good,s["--signal-fair"]=e.colors.signal.fair,s["--signal-poor"]=e.colors.signal.poor,s["--signal-critical"]=e.colors.signal.critical,s["--signal-unknown"]=e.colors.signal.unknown,s["--sparkline-excellent"]=e.colors.signal.excellent,s["--sparkline-good"]=e.colors.signal.good,s["--sparkline-fair"]=e.colors.signal.fair,s["--sparkline-poor"]=e.colors.signal.poor,s["--sparkline-critical"]=e.colors.signal.critical,s["--status-success"]=e.colors.status.success,s["--status-warning"]=e.colors.status.warning,s["--status-danger"]=e.colors.status.danger,s["--status-info"]=e.colors.status.info,s["--status-muted"]=e.colors.status.muted;const a=e.colors.chart;s["--pkt-advert"]=e.colors.accent.secondary,s["--pkt-flood"]=e.colors.accent.tertiary,s["--pkt-txt-msg"]=e.colors.accent.success,s["--pkt-ack"]=a.c8,s["--pkt-trace"]=a.c3,s["--pkt-req"]=a.c2,s["--pkt-response"]=a.c5,s["--pkt-grp-txt"]=e.colors.map.room,s["--pkt-grp-data"]=e.colors.accent.danger,s["--pkt-path"]=a.c3,s["--pkt-anon"]=e.colors.accent.secondary,s["--pkt-unknown"]=e.colors.status.muted,s["--route-flood"]=e.colors.accent.primary,s["--route-direct"]=e.colors.accent.secondary,s["--route-transport"]=a.c8,s["--chart-1"]=a.c1,s["--chart-2"]=a.c2,s["--chart-3"]=a.c3,s["--chart-4"]=a.c4,s["--chart-5"]=a.c5,s["--chart-6"]=a.c6,s["--chart-7"]=a.c7,s["--chart-8"]=a.c8,s["--chart-grid"]=a.grid,s["--chart-axis-tick"]=a.axis,s["--chart-cursor"]=a.cursor,s["--metric-received"]=e.colors.metric.received,s["--metric-forwarded"]=e.colors.metric.forwarded,s["--metric-transmitted"]=e.colors.metric.transmitted,s["--metric-dropped"]=e.colors.metric.dropped,s["--metric-neutral"]=e.colors.text.secondary,s["--log-debug"]=e.colors.status.muted,s["--log-info"]=e.colors.status.info,s["--log-warning"]=e.colors.status.warning,s["--log-error"]=e.colors.accent.danger,s["--log-critical"]=e.colors.accent.danger;const r=e.colors.map;s["--map-node-fill"]="#3B82F6",s["--map-node-stroke"]="rgba(255,255,255,0.9)",s["--map-hub-color"]="#8E4EC6",s["--map-hub-stroke"]="rgba(255,255,255,0.9)",s["--map-gateway-color"]="#5B5BD6",s["--map-gateway-stroke"]="rgba(255,255,255,0.85)",s["--map-local-color"]="#FFB224",s["--map-neighbor-color"]="#FFB224",s["--map-neighbor-stroke"]="rgba(0,0,0,0.4)",s["--map-mobile-color"]="#F76B15",s["--map-room-color"]="#D6409F",s["--map-ghost-color"]="#00A2C7",s["--map-edge-rest"]=r.edge,s["--map-edge-rest-bright"]=e.colors.border.strong,s["--map-edge-rest-dim"]=e.colors.bg.subtle,s["--map-edge-hover-direct"]=r.edgeHover,s["--map-edge-hover-loop"]="#8E4EC6",s["--map-edge-hover-standard"]=e.colors.text.muted,s["--map-edge-hover-neighbor"]="#FFB224",s["--link-strong"]=e.colors.accent.success,s["--link-medium"]=e.colors.accent.secondary,s["--link-weak"]=e.colors.accent.danger,s["--hop-0"]=e.colors.accent.tertiary,s["--hop-1"]=e.colors.accent.success,s["--hop-2"]=a.c3,s["--hop-3"]=e.colors.accent.secondary,s["--hop-distant"]=e.colors.text.muted,s["--hop-hub"]=r.local;const o=e.colors.icon;s["--icon-page-title"]=(null==o?void 0:o.pageTitle)??e.colors.accent.primary,s["--icon-card-title"]=(null==o?void 0:o.cardTitle)??e.colors.accent.primary,s["--icon-widget"]=(null==o?void 0:o.widget)??e.colors.text.secondary,s["--icon-action"]=(null==o?void 0:o.action)??e.colors.text.secondary,s["--icon-nav"]=(null==o?void 0:o.nav)??e.colors.text.muted,s["--icon-nav-active"]=(null==o?void 0:o.navActive)??e.colors.accent.primary,s["--toggle-on"]=e.colors.accent.success,s["--toggle-off"]=e.colors.bg.elevated;const i=e.colors.sidebar;s["--sidebar-bg"]=(null==i?void 0:i.bg)??"transparent",s["--sidebar-nav-hover-bg"]=(null==i?void 0:i.navHoverBg)??"rgba(255, 255, 255, 0.05)",s["--sidebar-nav-active-bg"]=(null==i?void 0:i.navActiveBg)??`color-mix(in srgb, ${e.colors.accent.primary} 15%, transparent)`,s["--sidebar-nav-active-text"]=(null==i?void 0:i.navActiveText)??e.colors.accent.primary;const l=e.meta.isDark;s["--data-box-bg"]=l?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.03)",s["--data-box-border"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.08)",s["--subtle-fill"]=l?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.03)",s["--subtle-fill-hover"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.05)",s["--subtle-fill-strong"]=l?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",s["--color-pill-bg"]=l?"rgba(0, 0, 0, 0.3)":"rgba(255, 255, 255, 0.3)",s["--terminal-bg"]=l?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.03)",s["--terminal-bg-input"]=l?"rgba(0, 0, 0, 0.5)":"rgba(0, 0, 0, 0.05)",s["--terminal-bg-status"]=l?"rgba(0, 0, 0, 0.3)":"rgba(0, 0, 0, 0.02)",s["--terminal-border"]=l?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.08)",s["--terminal-autocomplete-bg"]=l?"rgba(0, 0, 0, 0.8)":"rgba(255, 255, 255, 0.95)",s["--terminal-autocomplete-border"]=l?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.15)",s["--terminal-autocomplete-hover"]=l?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.05)",s["--livedot-idle"]=l?"#666677":"#999999",s["--ctrl-panel-top"]=l?"rgba(30, 30, 30, 0.95)":"rgba(240, 240, 240, 0.95)",s["--ctrl-panel-mid"]=l?"rgba(25, 25, 25, 0.95)":"rgba(235, 235, 235, 0.95)",s["--ctrl-panel-bottom"]=l?"rgba(20, 20, 20, 0.95)":"rgba(230, 230, 230, 0.95)",s["--ctrl-panel-border"]=l?"rgba(60, 60, 60, 1)":"rgba(200, 200, 200, 1)",s["--chart-grid-line"]=l?"rgba(255, 255, 255, 0.06)":"rgba(0, 0, 0, 0.08)",s["--map-control-active-amber"]=l?"rgba(251, 191, 36, 0.15)":"rgba(217, 119, 6, 0.12)",s["--map-control-active-sky"]=l?"rgba(56, 189, 248, 0.15)":"rgba(14, 165, 233, 0.12)",s["--map-control-active-teal"]=l?"rgba(45, 212, 191, 0.15)":"rgba(20, 184, 166, 0.12)",s["--sidebar-action-active-green"]=l?"rgba(10, 26, 10, 1)":"rgba(220, 252, 231, 1)",s["--sidebar-action-active-teal"]=l?"rgba(10, 36, 32, 1)":"rgba(204, 251, 241, 1)",s["--sidebar-action-active-amber"]=l?"rgba(26, 20, 8, 1)":"rgba(254, 243, 199, 1)",s["--thumbnail-brightness"]=l?"1.5":"1.8",s["--font-title"]=e.typography.font.title,s["--font-display"]=e.typography.font.display,s["--font-data"]=e.typography.font.mono,s["--font-card-title"]=e.typography.font.cardTitle??e.typography.font.display,s["--font-badge"]=e.typography.font.badge??e.typography.font.display,s["--font-normal"]=String(e.typography.weight.normal),s["--font-medium"]=String(e.typography.weight.medium),s["--font-semibold"]=String(e.typography.weight.semibold),s["--font-bold"]=String(e.typography.weight.bold),s["--font-card-title-weight"]=String(e.typography.weight.cardTitle??e.typography.weight.semibold),s["--font-badge-weight"]=String(e.typography.weight.badge??e.typography.weight.medium),s["--badge-text-transform"]=(null==(t=e.typography.badge)?void 0:t.textTransform)??"none";const c=e.typography.size;c.xxl&&(s["--text-2xl"]=c.xxl),c.xl&&(s["--text-xl"]=c.xl),c.lg&&(s["--text-lg"]=c.lg),c.md&&(s["--text-md"]=c.md),c.base&&(s["--text-base"]=c.base),c.sm&&(s["--text-sm"]=c.sm),c.xs&&(s["--text-xs"]=c.xs),c.hero&&(s["--text-5xl"]=c.hero),c.cardTitle&&(s["--text-card-title"]=c.cardTitle);const u=e.typography.tracking;return u&&(s["--tracking-tight"]=u.tight,s["--tracking-normal"]=u.normal,s["--tracking-wide"]=u.wide),s["--theme-transition"]=`${e.motion.slow} ${e.motion.easing}`,function(e){if(!K())return e;const t={},s=/^#[0-9A-Fa-f]{3,6}$/;for(const[n,a]of Object.entries(e))t[n]=s.test(a)?V(a):a;return t}(s)}(e),s=document.documentElement;for(const[n,a]of Object.entries(t))s.style.setProperty(n,a);e.surfaces.glass.strokeOnly?s.classList.add("stroke-only"):s.classList.remove("stroke-only"),e.surfaces.glass.ribbonMode?s.classList.add("ribbon-mode"):s.classList.remove("ribbon-mode"),e.surfaces.glass.catalystMode?s.classList.add("catalyst-mode"):s.classList.remove("catalyst-mode")}(t),document.documentElement.dataset.colorScheme=e}function wr({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return Qe;try{let s=localStorage.getItem(Ze),n=localStorage.getItem(et);const a=localStorage.getItem(tt);if(!s&&!n){const e=localStorage.getItem(st);if(e){const t=Xe.find(t=>t.id===e);t&&(s=t.colorScheme,n=t.backgroundImage,localStorage.setItem(Ze,s),localStorage.setItem(et,n),localStorage.removeItem(st))}}const r=s&&"string"==typeof(t=s)&&Ve.some(e=>e.id===t)?s:Qe.colorScheme;let o=Qe.backgroundImage;""===n?o="":n&&"string"==typeof(e=n)&&Ke.some(t=>t.src===e)&&(o=n);let i=Qe.brightness;if(a){const e=parseInt(a,10);!isNaN(e)&&e>=0&&e<=100&&(i=e)}return{colorScheme:r,backgroundImage:o,brightness:i}}catch{return Qe}var e,t}()),r=s.useRef(!1),o=s.useRef(null),[i,l]=s.useState(null);s.useEffect(()=>{o.current&&(clearTimeout(o.current),o.current=null),r.current&&(l("#808080"),o.current=setTimeout(()=>{l(null),o.current=null},1800)),r.current=!0,xr(t.colorScheme),gr.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of ot){const e=ht(`--palette-${t}-bright`),s=ht(`--palette-${t}`),n=e||s;if(!n)continue;const a=dt(n);for(const r of rt)mt(`--palette-${t}-${r}`,a[r])}const e=ht("--palette-bg-4");if(e){const t=dt(e);for(const e of rt)mt(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(Ze,e.colorScheme),localStorage.setItem(et,e.backgroundImage),localStorage.setItem(tt,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{Ke.forEach(e=>{(new Image).src=e.src})},[]);const c=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),u=s.useCallback(e=>{const t=Ke.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),d=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),h=s.useCallback(e=>{const t=Xe.find(t=>t.id===e);if(t){const e=!t.backgroundImage,s=e?null:Ke.find(e=>e.src===t.backgroundImage);a(n=>({...n,colorScheme:t.colorScheme,backgroundImage:t.backgroundImage,brightness:e?100:(null==s?void 0:s.suggestedBrightness)??n.brightness}))}},[]),m=s.useMemo(()=>({theme:t,setColorScheme:c,setBackgroundImage:u,setBrightness:d,setThemePreset:h}),[t,c,u,d,h]);return n.jsxs(yr.Provider,{value:m,children:[e,i&&n.jsx("div",{className:"fixed inset-0 pointer-events-none z-[9999]",style:{backgroundColor:i,animation:"theme-crossfade 1.8s ease-out forwards"}},t.colorScheme),n.jsx("style",{children:"\n @keyframes theme-crossfade {\n from { opacity: 0.35; }\n to { opacity: 0; }\n }\n "})]})}function vr(){const e=s.useContext(yr);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const kr=s.forwardRef(function(e,t){const{href:s,...o}=e;return s.startsWith("http://")||s.startsWith("https://")||s.startsWith("//")?n.jsx(a,{children:n.jsx("a",{...o,href:s,ref:t})}):n.jsx(a,{children:n.jsx(r,{...o,to:s,ref:t})})}),Sr={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"},Cr={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},jr={REQ:0,RESPONSE:1,TXT_MSG:2,ACK:3,ADVERT:4,GRP_TXT:5,GRP_DATA:6,ANON_REQ:7,PATH:8,TRACE:9,MULTIPART:10,RAW_CUSTOM:15};function Tr(e){return 1===e||0===e}function Mr(e){return null==e?"UNKNOWN":Sr[e]||`TYPE_${e}`}function Lr(e){return null==e?"UNKNOWN":Cr[e]||`ROUTE_${e}`}function Nr(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function _r(e){const t=function(e){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255,r=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);return.2126*r(s)+.7152*r(n)+.0722*r(a)}(e);return Nr(t,1)>Nr(t,0)?"light":"dark"}function Er(e){return 1===e||!0===e}const Pr=J("inline-flex items-center gap-1","rounded-md px-1.5 py-0.5","text-xs"),Dr={fontFamily:"var(--font-badge)",fontWeight:"var(--font-badge-weight)",textTransform:"var(--badge-text-transform, none)"},Ir={red:"var(--sys-red)",orange:"var(--sys-orange)",amber:"var(--sys-amber)",yellow:"var(--sys-yellow)",lime:"var(--sys-green)",green:"var(--sys-green)",emerald:"var(--sys-green)",teal:"var(--sys-teal)",cyan:"var(--sys-cyan)",sky:"var(--sys-cyan)",blue:"var(--sys-blue)",indigo:"var(--sys-indigo)",violet:"var(--sys-indigo)",purple:"var(--sys-purple)",fuchsia:"var(--sys-pink)",pink:"var(--sys-pink)",rose:"var(--sys-red)",brown:"var(--sys-brown)",zinc:"var(--text-muted)"};function Fr(e){if(!e.startsWith("var("))return e;if("undefined"!=typeof window){const t=e.match(/var\((--[^,)]+)/);if(t){const e=getComputedStyle(document.documentElement).getPropertyValue(t[1]).trim();if(e&&e.startsWith("#"))return e}}return"#666666"}function Ar({color:e="zinc",customColor:t,filled:a=!1,compact:r=!1,className:o,title:i,children:l}){const c=s.useMemo(()=>{const s=t??Ir[e];if(a){if(t){const e=_r(Fr(t));return{backgroundColor:t,color:"light"===e?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.85)"}}return{backgroundColor:s,color:["amber","yellow","lime"].includes(e)?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"}}return{backgroundColor:`color-mix(in srgb, ${s} 15%, transparent)`,color:s}},[e,t,a]);return n.jsx("span",{className:J(Pr,r&&"!px-1 !py-0 !text-[10px]",o),style:{...Dr,...c},title:i,children:l})}const Rr=s.forwardRef(function({color:e="zinc",customColor:t,filled:a=!1,compact:r=!1,className:i,children:l,...c},u){const d=s.useMemo(()=>{const s=t??Ir[e];if(a){if(t){const e=_r(Fr(t));return{backgroundColor:t,color:"light"===e?"rgba(255,255,255,0.95)":"rgba(0,0,0,0.85)"}}return{backgroundColor:s,color:["amber","yellow","lime"].includes(e)?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.95)"}}return{backgroundColor:`color-mix(in srgb, ${s} 15%, transparent)`,color:s}},[e,t,a]),h=J(Pr,r&&"!px-1 !py-0 !text-[10px]","cursor-pointer transition-opacity hover:opacity-80",i);return"href"in c&&void 0!==c.href?n.jsx(kr,{...c,ref:u,className:h,style:{...Dr,...d},children:l}):n.jsx(o,{...c,ref:u,className:h,style:{...Dr,...d},children:l})}),zr=J("relative inline-flex items-center justify-center gap-2","text-sm font-medium whitespace-nowrap","rounded-lg px-3 py-1.5","focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 focus-visible:ring-offset-1 focus-visible:ring-offset-bg-body","disabled:opacity-50 disabled:cursor-not-allowed","transition-all duration-150","[&>[data-slot=icon]]:w-4 [&>[data-slot=icon]]:h-4 [&>[data-slot=icon]]:shrink-0"),Br={primary:J("bg-accent-primary text-white","hover:bg-accent-primary/90","active:bg-accent-primary/80","border border-accent-primary/20"),success:J("bg-accent-success text-white","hover:bg-accent-success/90","active:bg-accent-success/80","border border-accent-success/20"),danger:J("bg-accent-danger text-white","hover:bg-accent-danger/90","active:bg-accent-danger/80","border border-accent-danger/20"),warning:J("bg-accent-secondary text-bg-body","hover:bg-accent-secondary/90","active:bg-accent-secondary/80","border border-accent-secondary/20"),muted:J("bg-bg-elevated text-text-primary","hover:bg-bg-subtle","active:bg-bg-elevated","border border-border-subtle")},Or={primary:J("bg-transparent text-accent-primary","border border-accent-primary/30","hover:bg-accent-primary/10 hover:border-accent-primary/50","active:bg-accent-primary/20"),success:J("bg-transparent text-accent-success","border border-accent-success/30","hover:bg-accent-success/10 hover:border-accent-success/50","active:bg-accent-success/20"),danger:J("bg-transparent text-accent-danger","border border-accent-danger/30","hover:bg-accent-danger/10 hover:border-accent-danger/50","active:bg-accent-danger/20"),warning:J("bg-transparent text-accent-secondary","border border-accent-secondary/30","hover:bg-accent-secondary/10 hover:border-accent-secondary/50","active:bg-accent-secondary/20"),muted:J("bg-transparent text-text-muted","border border-border-subtle","hover:bg-bg-subtle hover:text-text-primary hover:border-border-strong","active:bg-bg-elevated")},$r={primary:J("bg-transparent text-accent-primary border-transparent","hover:bg-accent-primary/10","active:bg-accent-primary/20"),success:J("bg-transparent text-accent-success border-transparent","hover:bg-accent-success/10","active:bg-accent-success/20"),danger:J("bg-transparent text-accent-danger border-transparent","hover:bg-accent-danger/10","active:bg-accent-danger/20"),warning:J("bg-transparent text-accent-secondary border-transparent","hover:bg-accent-secondary/10","active:bg-accent-secondary/20"),muted:J("bg-transparent text-text-muted border-transparent","hover:bg-bg-subtle hover:text-text-primary","active:bg-bg-elevated")},Wr=s.forwardRef(function({color:e="muted",outline:t=!1,plain:s=!1,className:a,children:r,...i},l){const c=J(zr,s?$r[e]:t?Or[e]:Br[e],a);return"href"in i&&void 0!==i.href?n.jsx(kr,{...i,ref:l,className:c,children:r}):n.jsx(o,{...i,ref:l,className:c,children:r})}),Hr={duration:.15,ease:[.4,0,.2,1]},Ur={type:"tween",duration:.25,ease:[.4,0,.2,1]},qr={type:"tween",duration:.3,ease:[.4,0,.2,1]},Gr=s.createContext(!1);function Jr(){return s.useContext(Gr)}const Yr={xs:"sm:max-w-xs",sm:"sm:max-w-sm",md:"sm:max-w-md",lg:"sm:max-w-lg",xl:"sm:max-w-xl","2xl":"sm:max-w-2xl","3xl":"sm:max-w-3xl","4xl":"sm:max-w-4xl","5xl":"sm:max-w-5xl",full:"sm:max-w-[calc(100vw-2rem)]"};function Vr({open:e,onClose:t,size:a="md",className:r,children:o,bottomSheet:d=!0,motionPlus:h=!1}){const[m,f]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>(g.current&&(clearTimeout(g.current),g.current=null),e?g.current=setTimeout(()=>{f(!0)},350):queueMicrotask(()=>f(!1)),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[e]);const p=s.useCallback((e,s)=>{(s.offset.y>100||s.velocity.y>500)&&t()},[t]),b=h?qr:Ur,y=h?.98:.99,x=d?8:4;return n.jsx(i,{mode:"wait",children:e&&n.jsxs(l,{static:!0,open:e,onClose:t,className:"relative z-[10010]",children:[n.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:Hr,className:"fixed inset-0 bg-black/50 backdrop-blur-sm","aria-hidden":"true"}),n.jsx("div",{className:"fixed inset-0 overflow-y-auto",children:n.jsx("div",{className:J("flex min-h-full justify-center",d?"items-end sm:items-center sm:p-4":"items-center p-4"),children:n.jsx(c.div,{drag:!!d&&"y",dragConstraints:{top:0,bottom:0},dragElastic:{top:0,bottom:.4},onDragEnd:p,initial:{opacity:0,scale:y,y:x},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.99,y:d?40:4},transition:b,style:{willChange:"transform, opacity"},className:J(d&&"w-full sm:w-auto"),children:n.jsx(u,{className:J("w-full bg-bg-surface shadow-2xl flex flex-col","ring-1 ring-inset ring-white/10",Yr[a],d?"rounded-t-2xl rounded-b-none sm:rounded-2xl pb-safe":"rounded-2xl",r),children:n.jsx(Gr.Provider,{value:m,children:o})})})})})]})})}function Kr({className:e,...t}){return n.jsx(d,{...t,className:J("text-base font-semibold text-text-primary sm:text-lg",e)})}function Xr({icon:e,title:t,onClose:s,className:a}){return n.jsxs("div",{className:J("flex items-center justify-between p-4 border-b border-border-subtle",a),children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e&&n.jsx("div",{className:"p-2 rounded-lg bg-bg-subtle text-icon-card-title",children:e}),n.jsx(Kr,{children:t})]}),s&&n.jsx("button",{onClick:s,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors","aria-label":"Close",children:n.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}function Qr({className:e,...t}){return n.jsx("div",{...t,className:J("p-4",e)})}function Zr({className:e,...t}){return n.jsx("div",{...t,className:J("flex flex-col-reverse gap-3 p-4 pt-0","sm:flex-row sm:justify-end","*:w-full sm:*:w-auto",e)})}const eo={snappy:{type:"spring",stiffness:500,damping:30},smooth:{type:"spring",stiffness:300,damping:30},gentle:{type:"spring",stiffness:200,damping:25}},to={easeIn:[.4,0,1,1],cubicInOut:[.65,0,.35,1]},so={normal:.05};function no({className:e,...t}){return n.jsx("nav",{...t,className:J(e,"flex h-full min-h-0 flex-col")})}function ao({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex flex-col border-b border-border-subtle p-4","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function ro({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex flex-1 flex-col overflow-y-auto p-3","[&>[data-slot=section]+[data-slot=section]]:mt-6")})}function oo({className:e,...t}){return n.jsx("div",{...t,className:J(e,"mt-auto flex flex-col border-t border-border-subtle","[&>[data-slot=section]+[data-slot=section]]:mt-2.5")})}function io({className:e,...t}){const a=s.useId();return n.jsx(h,{id:a,children:n.jsx("div",{...t,"data-slot":"section",className:J(e,"flex flex-col gap-0.5")})})}const lo=s.forwardRef(function(e,t){const{current:s,className:a,children:i,...l}=e,u=J("flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left","min-h-[44px]","text-sm font-medium","[&>svg]:w-5 [&>svg]:h-5 [&>svg]:flex-shrink-0",s?"bg-accent-primary/15 text-accent-primary [&>svg]:text-accent-primary":"text-text-muted hover:text-text-primary hover:bg-subtle-fill [&>svg]:text-text-muted hover:[&>svg]:text-text-primary","transition-all duration-150");return n.jsxs("span",{className:J(a,"relative"),children:[s&&n.jsx(c.span,{layoutId:"sidebar-current-indicator",className:"absolute inset-y-2 -left-3 w-0.5 rounded-full bg-accent-primary"}),"string"==typeof l.href?n.jsx(r,{to:l.href,onClick:l.onClick,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,className:u,"data-current":s?"true":void 0,ref:t,children:i}):n.jsx(o,{...l,className:J("cursor-default",u),"data-current":s?"true":void 0,ref:t,children:i})]})});function co({className:e,...t}){return n.jsx("span",{...t,className:J(e,"truncate")})}function uo({className:e,variant:t="default",...s}){return n.jsx("span",{...s,className:J("ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full","text-xs font-medium",{default:"bg-bg-subtle text-text-muted",accent:"bg-accent-primary/20 text-accent-primary",success:"bg-accent-success/20 text-accent-success",warning:"bg-accent-secondary/20 text-accent-secondary",danger:"bg-accent-danger/20 text-accent-danger"}[t],e)})}const ho=s.createContext(null),mo={type:"spring",visualDuration:.35,bounce:.15};function fo({open:e,onClose:t,children:s}){return n.jsx(i,{children:e&&n.jsxs(l,{static:!0,open:e,onClose:t,className:"lg:hidden relative z-[10002]",children:[n.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:"easeOut"},className:"fixed inset-0 bg-black/60 backdrop-blur-sm","aria-hidden":"true"}),n.jsx(c.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:mo,className:"fixed inset-y-0 left-0 w-72 max-w-[85vw] z-[10003]",children:n.jsx(u,{className:"h-full",children:n.jsxs("div",{className:"flex h-full flex-col sidebar-panel",children:[n.jsx("div",{className:"absolute top-4 right-4 z-10",children:n.jsx(f,{className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-subtle-fill transition-colors","aria-label":"Close navigation",children:n.jsx(g,{className:"w-5 h-5"})})}),s]})})})]})})}function go({sidebar:e,navbar:t,children:a,className:r}){const[o,i]=s.useState(!1),l=()=>i(!0),c=()=>i(!1),u={isOpen:o,open:l,close:c,toggle:()=>i(e=>!e)};return n.jsx(ho.Provider,{value:u,children:n.jsxs("div",{className:"flex h-screen overflow-hidden bg-bg-body",children:[n.jsx("aside",{className:"hidden lg:flex flex-col w-64 flex-shrink-0 h-full relative sidebar-panel",children:e}),n.jsx(fo,{open:o,onClose:c,children:e}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsx("header",{className:"lg:hidden sticky top-0 z-[10001] h-14 mobile-header",children:n.jsxs("div",{className:"flex items-center h-full px-4",children:[n.jsx("button",{onClick:l,className:"w-10 h-10 flex items-center justify-center rounded-lg hover:bg-subtle-fill active:bg-subtle-fill transition-colors mr-2","aria-label":"Open navigation",children:n.jsx(m,{className:"w-5 h-5 text-text-primary"})}),n.jsx("div",{className:"flex-1 min-w-0",children:t})]})}),n.jsx("main",{className:J("flex-1 overflow-y-auto main-content",r),children:a})]})]})})}function po({className:e,...t}){return n.jsx("nav",{...t,className:J(e,"flex flex-1 items-center gap-3")})}function bo({className:e,...t}){return n.jsx("div",{...t,className:J(e,"flex items-center gap-3")})}function yo({className:e,...t}){return n.jsx("div",{"aria-hidden":"true",...t,className:J(e,"flex-1")})}function xo({defaultOpen:e=!1,className:t,children:s}){return n.jsx(y,{defaultOpen:e,children:n.jsx("div",{className:J("flex flex-col",t),children:s})})}s.forwardRef(function({children:e,elevated:t,compact:s,noPadding:a,className:r,...o},i){return n.jsx("div",{ref:i,className:J("rounded-lg","bg-bg-surface","ring-1 ring-inset ring-border-subtle","h-full flex flex-col",t&&"bg-bg-elevated",!a&&(s?"p-3 sm:p-4":"p-4 sm:p-5"),r),...o,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex items-center justify-between gap-4","pb-4 mb-4","border-b border-border-subtle",t),...s,children:e})}),s.forwardRef(function({children:e,icon:t,className:s,...a},r){return n.jsxs("h3",{ref:r,className:J("flex items-center gap-2","text-base font-semibold text-text-primary",s),...a,children:[t&&n.jsx("span",{className:"text-icon-card-title w-5 h-5 flex-shrink-0",children:t}),e]})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("p",{ref:a,className:J("text-sm text-text-muted",t),...s,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex-1 min-h-0",t),...s,children:e})}),s.forwardRef(function({children:e,className:t,...s},a){return n.jsx("div",{ref:a,className:J("flex items-center justify-end gap-3","pt-4 mt-4","border-t border-border-subtle",t),...s,children:e})}),s.forwardRef(function({children:e,border:t,className:s,...a},r){return n.jsx("div",{ref:r,className:J(t&&"pt-4 mt-4 border-t border-border-subtle",s),...a,children:e})});const wo=s.forwardRef(function({className:e,icon:t,children:s,...a},r){return n.jsx(p,{ref:r,className:J("flex w-full items-center justify-between gap-3","px-3 py-2 rounded-lg","text-sm font-medium text-text-muted","hover:bg-bg-surface hover:text-text-primary","transition-colors duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50",e),...a,children:({open:e})=>n.jsxs(n.Fragment,{children:[s,n.jsx("span",{className:J("transition-transform duration-200",e?"rotate-180":"rotate-0"),children:t||n.jsx(b,{className:"w-4 h-4"})})]})})});function vo({direction:e="down",className:t,children:s}){const a={hidden:{height:0,opacity:0,y:"up"===e?8:-8},visible:{height:"auto",opacity:1,y:0}};return n.jsx(x,{static:!0,children:({open:r})=>n.jsx(i,{initial:!1,children:r&&n.jsx(c.div,{initial:"hidden",animate:"visible",exit:"hidden",variants:a,transition:{height:{duration:.2,ease:[.4,0,.2,1]},opacity:{duration:.15},y:{duration:.15}},className:J("overflow-hidden",t),children:n.jsx("div",{className:J("up"===e?"pb-2":"pt-2"),children:s})})})})}function ko({label:e,icon:t,defaultOpen:s=!0,direction:a="down",className:r,dataId:o,children:i}){const l=o?{[`data-${o}-disclosure`]:!0}:{};return n.jsx(xo,{defaultOpen:s,className:r,children:"up"===a?n.jsxs(n.Fragment,{children:[n.jsx(vo,{direction:"up",children:i}),n.jsx(wo,{...l,children:n.jsxs("span",{className:"flex items-center gap-3",children:[t,n.jsx("span",{className:"text-xs uppercase tracking-wide",children:e})]})})]}):n.jsxs(n.Fragment,{children:[n.jsx(wo,{...l,children:n.jsxs("span",{className:"flex items-center gap-3",children:[t,n.jsx("span",{className:"text-xs uppercase tracking-wide",children:e})]})}),n.jsx(vo,{direction:"down",children:i})]})})}const So="0.9.195",Co="'JetBrains Mono', monospace",jo=s.memo(function({height:e=16,responsive:t=!1,className:s=""}){const a="var(--accent-primary)",r="var(--text-primary)";if(t){const e=145,t=24;return n.jsxs("svg",{className:s,viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"pyMC:Console",style:{display:"block",width:"80%",height:"auto"},children:[n.jsx("style",{children:`\n .logo-text {\n font-family: ${Co};\n }\n .logo-accent {\n fill: var(--accent-primary, #719CDF);\n }\n .logo-main {\n fill: var(--text-primary, #FFFFFF);\n }\n `}),n.jsxs("text",{x:"0",y:"18",className:"logo-text",fontSize:"20",fontWeight:"400",letterSpacing:"-0.02em",children:[n.jsx("tspan",{className:"logo-accent",children:"py"}),n.jsx("tspan",{className:"logo-main",children:"MC"}),n.jsx("tspan",{className:"logo-accent",children:":"}),n.jsx("tspan",{className:"logo-main",children:"Console"})]})]})}const o="string"==typeof e?parseFloat(e):e,i={fontFamily:Co,fontSize:.8*o+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:i,role:"img","aria-label":"pyMC:Console",children:[n.jsx("span",{style:{color:a},children:"py"}),n.jsx("span",{style:{color:r},children:"MC"}),n.jsx("span",{style:{color:a},children:":"}),n.jsx("span",{style:{color:r},children:"Console"})]})}),To="pymc_jwt_token",Mo="pymc_client_id",Lo="pymc_remember_me",No=new Set;function _o(e){return No.add(e),()=>No.delete(e)}function Eo(e){for(const s of No)try{s(e)}catch(t){}}function Po(){let e=localStorage.getItem(Mo);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(Mo,e)),e}function Do(){return"true"===localStorage.getItem(Lo)}function Io(e){e?localStorage.setItem(Lo,"true"):localStorage.removeItem(Lo)}function Fo(){return Do()?localStorage:sessionStorage}function Ao(){return Fo().getItem(To)||localStorage.getItem(To)||sessionStorage.getItem(To)}function Ro(e){Fo().setItem(To,e),Do()?sessionStorage.removeItem(To):localStorage.removeItem(To),Eo(e)}function zo(){localStorage.removeItem(To),sessionStorage.removeItem(To),Eo(null)}function Bo(){return!(!Ao()||$o()&&(zo(),1))}function Oo(e){try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(atob(t).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(s)}catch{return null}}function $o(){const e=Ao();if(!e)return!0;const t=Oo(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function Wo(){const e=Ao();if(!e)return 0;const t=Oo(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function Ho(){const e=Ao();if(!e)return!1;const t=Oo(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function Uo(){const e=Ao();if(!e)return null;const t=Oo(e);return t&&t.sub?t.sub:null}async function qo(e,t,s=!1){Io(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:Po()})}),n=s.headers.get("content-type");if(!n||!n.includes("application/json"))return{success:!1,error:`Server error: ${s.status}`};const a=await s.json();return a.success&&a.token?(Ro(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function Go(){const e=Ao();if(!e)return!1;const t=Oo(e);(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3);try{const t=await fetch("/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({client_id:Po()})});if(!t.ok){let e="";try{const s=await t.json();e=s.error||JSON.stringify(s)}catch{e=t.statusText}return!1}const s=await t.json();if(s.success&&s.token){Ro(s.token);const e=Oo(s.token);return(null==e?void 0:e.exp)&&Math.floor((1e3*e.exp-Date.now())/1e3),!0}return!1}catch(s){return!1}}let Jo=null;async function Yo(){const e=Ao();if(!e)return!1;const t=Oo(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!Ho()||Jo||(Jo=Go().finally(()=>{Jo=null}),Jo)}function Vo(){zo()}let Ko=!1;function Xo(){if(Ko)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!Ao())return;if($o())return zo(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=Wo();e>0&&e<300&&await Go()};document.addEventListener("visibilitychange",e),Ko=!0,"visible"===document.visibilityState&&e()}const Qo=Object.freeze(Object.defineProperty({__proto__:null,clearToken:zo,getClientId:Po,getRememberMe:Do,getToken:Ao,getTokenTimeRemaining:Wo,getUsername:Uo,isAuthenticated:Bo,isTokenExpired:$o,login:qo,logout:Vo,onTokenChange:_o,parseJWT:Oo,refreshToken:Go,refreshTokenIfNeeded:Yo,setRememberMe:Io,setToken:Ro,shouldRefreshToken:Ho,startVisibilityBasedRefresh:Xo},Symbol.toStringTag,{value:"Module"})),Zo=new Map;let ei=!1;async function ti(e,t,s=!1){const n=function(e,t){return(null==t?void 0:t.method)&&"GET"!==t.method?"":e}(e,t);if(n){const e=Zo.get(n);if(e)return e}const a=`${e}`;!s&&Ho()&&await Go();const r=Ao();if(!r&&!e.includes("/auth/"))throw window.location.href="/login",new Error("Not authenticated");const o=r?{Authorization:`Bearer ${r}`}:{};if(null==t?void 0:t.headers){const e=t.headers;e instanceof Headers?e.forEach((e,t)=>{o[t]=e}):Array.isArray(e)?e.forEach(([e,t])=>{o[e]=t}):Object.assign(o,e)}(null==t?void 0:t.body)&&(o["Content-Type"]="application/json");const i=(async()=>{const n=await fetch(a,{...t,headers:o});if(401===n.status){if(!s&&!ei&&await Go())return ti(e,t,!0);throw ei||(ei=!0,zo(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText} (${e})`);return n.json()})();return n&&(Zo.set(n,i),i.finally(()=>{Zo.delete(n)})),i}const si={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function ni(e){if(e.raw_packet){const t=e.raw_packet;if(/^[0-9a-fA-F]+$/.test(t)&&t.length%2==0)return t.length/2;if(/^[A-Za-z0-9+/=]+$/.test(t)){const e=(t.match(/=+$/)||[""])[0].length;return Math.floor(3*t.length/4)-e}return t.length}if(e.length&&e.length>0)return e.length;if(e.payload_length&&e.payload_length>0)return e.payload_length;if(e.payload){const t=e.payload;return/^[0-9a-fA-F]+$/.test(t)&&t.length%2==0?t.length/2:t.length}return 32}function ai(e,t={}){return void 0!==e.airtime_ms&&e.airtime_ms>0?e.airtime_ms:function(e,t={}){const s=t.spreadingFactor??si.spreadingFactor,n=t.bandwidthHz??si.bandwidthHz,a=t.codingRate??si.codingRate,r=t.preambleLength??si.preambleLength??8,o=t.crcEnabled??si.crcEnabled?1:0,i=t.explicitHeader??si.explicitHeader?0:1,l=s>=11&&n<=125e3?1:0,c=n/1e3,u=Math.pow(2,s)/c,d=(r+4.25)*u,h=Math.max(8*e-4*s+28+16*o-20*i,0),m=4*(s-2*l);return d+(8+Math.ceil(h/m)*a)*u}(ni(e),t)}function ri(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function oi(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=ri(t.contact_type);return e}(await ti("/api/stats"))}async function ii(){return ti("/api/logs")}async function li(e=24){return ti(`/api/noise_floor_history?hours=${e}`)}const ci=new Map;function ui(e=!1){if(e)ci.clear();else for(const[t]of ci)parseInt(t.split("-")[0],10)<=60&&ci.delete(t)}function di(e,t,s,n){const a=60*e/t,r=Math.floor(Date.now()/1e3),o=Math.floor(r/a)*a,i=o-60*e,l=s.filter(e=>e.timestamp>=i&&e.timestamp<=o),c=n?function(e){var t;const s=null==(t=null==e?void 0:e.config)?void 0:t.radio;return{spreadingFactor:(null==s?void 0:s.spreading_factor)??si.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??si.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??si.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??si.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):si,u=function(e,t,s,n,a){const r=new Array(t),o=new Array(t),i=new Array(t),l=new Array(t),c=new Array(t),u=new Array(t),d=new Array(t);for(let m=0;m=t)continue;const g=ai(h,a),p=h.packet_origin;if("tx_local"===p?(i[f].count++,i[f].airtime_ms+=g):"tx_forward"===p||h.transmitted?(l[f].count++,l[f].airtime_ms+=g):h.drop_reason&&(c[f].count++,c[f].airtime_ms+=g),"tx_local"!==p){r[f].count++,r[f].airtime_ms+=g,u[f].snr+=h.snr||0,u[f].rssi+=h.rssi||0,u[f].count++;const e=h.packet_hash;e&&!d[f].has(e)&&(d[f].add(e),o[f].count++,o[f].airtime_ms+=g)}}for(let m=0;m0&&(r[m].avg_snr=u[m].snr/u[m].count,r[m].avg_rssi=u[m].rssi/u[m].count);return{received:r,unique_received:o,transmitted:i,forwarded:l,dropped:c}}(l,t,i,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:i,end_time:o,...u}}async function hi(){return ti("/api/hardware_stats")}async function mi(){return ti("/api/hardware_processes")}async function fi(e){return ti("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function gi(){return ti("/api/send_advert",{method:"POST",body:"{}"})}async function pi(e){return ti("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function bi(e){return ti("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}async function yi(e){try{return await ti("/api/log_level",{method:"POST",body:JSON.stringify({level:e})})}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}const xi="pymc-packet-cache",wi="pymc-packet-cache-meta",vi=36e5,ki=2592e5,Si=6048e5,Ci=12096e5,ji=5e3,Ti=5e5,Mi=new class{constructor(){t(this,"packets",new Map),t(this,"sortedPackets",[]),t(this,"sortedDirty",!0),t(this,"meta",{oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1}),t(this,"isLoading",!1),t(this,"isBackgroundLoading",!1),t(this,"isTopologyLoading",!1),t(this,"listeners",new Set),t(this,"loadProgress",null),t(this,"statusMessage",""),this.loadFromStorage()}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getState(){return{isLoading:this.isLoading,isBackgroundLoading:this.isBackgroundLoading,isTopologyLoading:this.isTopologyLoading,backgroundLoadComplete:this.meta.backgroundLoadComplete,topologyLoadComplete:this.meta.topologyLoadComplete,packetCount:this.packets.size,statusMessage:this.statusMessage,loadProgress:this.loadProgress,dataTier:this.meta.dataTier,threeDayLoadComplete:this.meta.threeDayLoadComplete,sevenDayLoadComplete:this.meta.sevenDayLoadComplete,fourteenDayLoadComplete:this.meta.fourteenDayLoadComplete}}getDataTier(){return this.meta.dataTier}getPackets(){return this.sortedDirty&&(this.sortedPackets=Array.from(this.packets.values()).sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),this.sortedDirty=!1),this.sortedPackets}isStale(){return 0===this.packets.size||Date.now()-this.meta.lastUpdated>vi}isHeavyLoadInProgress(){return this.isBackgroundLoading||this.isTopologyLoading}async initialLoad(e){if(this.isStale()&&this.packets.size>0&&this.clear(),this.meta.backgroundLoadComplete&&this.packets.size>0)return this.getPackets();this.isLoading=!0;const t=Date.now(),s=Math.floor((t-864e5)/1e3),n=3e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 24h history...",this.notifyListeners();try{let t;this.packets.size>0&&(this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta.oldestTimestamp=0,this.meta.newestTimestamp=0);let a=0,r=0,o=0;const i=Math.ceil(100);for(let l=0;l0))break;{const n=this.packets.size;this.mergePackets(u.data);const o=this.packets.size-n;a+=o;const i=Math.min(...u.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===t||i=2)break}else r=0;if(u.data.length=Ti)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,this.meta.dataTier="24h",this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.saveToStorage()}catch(a){this.statusMessage="Load failed"}finally{this.isLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}return this.getPackets()}async quickLoad(){return this.initialLoad()}async backgroundLoad(){await this.initialLoad()}async loadThreeDays(e){this.meta.threeDayLoadComplete||this.isBackgroundLoading||await this.loadExtendedData("3d",ki,e)}async loadSevenDays(e){this.meta.sevenDayLoadComplete||this.isBackgroundLoading||(this.meta.threeDayLoadComplete||await this.loadThreeDays(e),await this.loadExtendedData("7d",Si,e))}async loadFourteenDays(e){this.meta.fourteenDayLoadComplete||this.isBackgroundLoading||(this.meta.sevenDayLoadComplete||await this.loadSevenDays(e),await this.loadExtendedData("14d",Ci,e))}async loadExtendedData(e,t,s){this.isBackgroundLoading=!0;const n=Date.now(),a=Math.floor((n-t)/1e3),r=3e4*("3d"===e?2:"7d"===e?4:7);this.loadProgress={loaded:0,target:r,percent:0},this.statusMessage=`Loading ${e} history...`,this.notifyListeners();try{let t=this.meta.oldestTimestamp||void 0,n=0,o=0,i=0;const l=Math.ceil(100);for(let u=0;u0))break;{const e=this.packets.size;this.mergePackets(d.data);const r=this.packets.size-e;n+=r;const i=Math.min(...d.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===t||i=2)break}else o=0;if(d.data.length=Ti)break}u=5)break;await this.delay(2e3)}}this.enforceMemoryCap();const c=Date.now()-1e3*this.meta.oldestTimestamp;"3d"===e?(this.meta.threeDayLoadComplete=c>=ki,this.meta.threeDayLoadComplete&&(this.meta.dataTier="3d")):"7d"===e?(this.meta.sevenDayLoadComplete=c>=Si,this.meta.sevenDayLoadComplete&&(this.meta.dataTier="7d")):(this.meta.fourteenDayLoadComplete=c>=Ci,this.meta.fourteenDayLoadComplete&&(this.meta.dataTier="14d")),this.loadProgress={loaded:n,target:n,percent:100},this.notifyListeners(),this.saveToStorage()}catch(o){this.statusMessage=`${e} load failed`}finally{this.isBackgroundLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}isDataTierAvailable(e){switch(e){case"24h":return this.meta.backgroundLoadComplete;case"3d":return this.meta.threeDayLoadComplete;case"7d":return this.meta.sevenDayLoadComplete;case"14d":return this.meta.fourteenDayLoadComplete;default:return!1}}async topologyLoad(){if(!this.meta.topologyLoadComplete&&!this.isTopologyLoading)return this.doTopologyLoad()}async forceTopologyLoad(){if(!this.isTopologyLoading)return this.meta.topologyLoadComplete=!1,this.doTopologyLoad()}async forceDeepLoad(){return this.forceTopologyLoad()}async doTopologyLoad(){this.isTopologyLoading=!0;const e=Date.now(),t=Math.floor((e-Ci)/1e3),s=42e4;this.statusMessage="Loading topology data...",this.loadProgress={loaded:this.packets.size,target:s,percent:0},this.notifyListeners();try{let e=this.meta.oldestTimestamp||void 0,n=0,a=0;const r=Math.ceil(100);for(let o=0;o0))break;{const s=this.packets.size;this.mergePackets(l.data);const a=this.packets.size-s,r=Math.min(...l.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===e||r=2)break}else n=0;if(this.packets.size>=Ti)break}o=5)break;await this.delay(2e3)}}this.enforceMemoryCap(),this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.meta.topologyLoadComplete=!0,this.meta.threeDayLoadComplete=!0,this.meta.sevenDayLoadComplete=!0,this.meta.fourteenDayLoadComplete=!0,this.meta.dataTier="14d",this.saveToStorage()}catch(n){this.statusMessage="Load failed"}finally{this.isTopologyLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}async poll(){try{const e=await this.fetchRecentPackets(100);if(e.success&&e.data){const t=this.packets.size;this.mergePackets(e.data),this.packets.size>t&&(this.saveToStorage(),this.notifyListeners())}}catch(e){}return this.getPackets()}clear(){this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta={oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1},this.clearStorage(),this.notifyListeners()}mergePacketsDirectly(e){const t=this.packets.size;this.mergePackets(e);const s=this.packets.size-t;return s>0&&(this.enforceMemoryCap(),this.saveToStorage(),this.notifyListeners()),s}mergePackets(e){let t=!1;for(const s of e){const e=s.packet_hash;if(!e)continue;const n=s.timestamp??0,a=`${e}:${n}`;this.packets.has(a)||(this.packets.set(a,s),t=!0),(0===this.meta.oldestTimestamp||nthis.meta.newestTimestamp&&(this.meta.newestTimestamp=n)}t&&(this.sortedDirty=!0),this.meta.lastUpdated=Date.now(),this.meta.packetCount=this.packets.size}notifyListeners(){const e=this.getState();for(const t of this.listeners)t(e)}delay(e){return new Promise(t=>setTimeout(t,e))}async fetchChunkWithRetry(e,t,s,n,a){for(let o=0;o<3;o++)try{return await this.fetchFilteredPackets(e,t,!1,a)}catch(r){const e=2===o,t=1e3*Math.pow(2,o);r instanceof Error&&r.name,e||(this.statusMessage=`Retry in ${Math.round(t/1e3)}s...`,this.notifyListeners(),await this.delay(t))}return null}enforceMemoryCap(){if(this.packets.size<=Ti)return;const e=this.getPackets(),t=e.length-Ti;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(wi);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(xi);if(t){const e=JSON.parse(t);for(const t of e)t.packet_hash&&this.packets.set(t.packet_hash,t)}if(this.meta.lastUpdated>0&&Date.now()-this.meta.lastUpdated>vi)return void this.clear();this.meta.backgroundLoadComplete=!1,this.meta.threeDayLoadComplete=!1,this.meta.sevenDayLoadComplete=!1,this.meta.fourteenDayLoadComplete=!1,this.meta.dataTier="24h";const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(xi,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(xi),localStorage.setItem(wi,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(xi),localStorage.removeItem(wi)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await G(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Qo);return{getToken:e}},void 0),a=n(),r={};a&&(r.Authorization=`Bearer ${a}`);const o=await fetch(s,{headers:r});if(401===o.status&&!t){const{refreshToken:t}=await G(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Qo);return{refreshToken:e}},void 0);if(await t())return this.fetchRecentPackets(e,!0)}if(!o.ok)throw new Error(`API error: ${o.status}`);return o.json()}async fetchFilteredPackets(e,t=5e3,s=!1,n){const a=new URLSearchParams;a.set("limit",String(t)),void 0!==e&&a.set("end_timestamp",String(e-.001)),void 0!==n&&a.set("start_timestamp",String(n));const r=`/api/filtered_packets?${a}`,{getToken:o}=await G(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Qo);return{getToken:e}},void 0),i=o(),l={};i&&(l.Authorization=`Bearer ${i}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(r,{headers:l,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await G(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Qo);return{refreshToken:e}},void 0);if(await s())return this.fetchFilteredPackets(e,t,!0)}if(!n.ok)throw new Error(`API error: ${n.status}`);return n.json()}finally{clearTimeout(u)}}};function Li(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Ni(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const _i=new class{constructor(){t(this,"worker",null),t(this,"listeners",new Set),t(this,"currentTopology",{edges:[],validatedEdges:[],weakEdges:[],certainEdges:[],uncertainEdges:[],edgeMap:new Map,maxPacketCount:0,maxCertainCount:0,neighborAffinity:new Map,fullAffinity:new Map,localPrefix:null,centrality:new Map,hubNodes:[],gatewayNodes:[],loops:[],loopEdgeKeys:new Set,txDelayRecommendations:new Map,pathRegistry:Ni(),edgeBetweenness:new Map,backboneEdges:[],nodeMobility:new Map,mobileNodes:[],pathHealth:[],lastHopNeighbors:[],disambiguationStats:{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:[],viterbiStats:{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map,communityCount:0,backboneNodes:[]}),t(this,"isComputing",!1),t(this,"pendingRequest",null),t(this,"debounceTimer",null),t(this,"debounceMs",100),this.initWorker()}initWorker(){if("undefined"!=typeof window)try{this.worker=new Worker(new URL("/assets/topology.worker-B6JO1dmH.js",import.meta.url),{type:"module"}),this.worker.onmessage=e=>{this.handleWorkerMessage(e.data)},this.worker.onerror=e=>{}}catch(e){}}handleWorkerMessage(e){if(this.isComputing=!1,"error"!==e.type){var t;this.currentTopology={edges:(t=e.payload).edges??[],validatedEdges:t.validatedEdges??[],weakEdges:t.weakEdges??[],certainEdges:t.certainEdges??[],uncertainEdges:t.uncertainEdges??[],maxPacketCount:t.maxPacketCount??0,maxCertainCount:t.maxCertainCount??0,localPrefix:t.localPrefix??null,hubNodes:t.hubNodes??[],gatewayNodes:t.gatewayNodes??[],edgeMap:new Map(t.edgeMapEntries??[]),neighborAffinity:new Map(t.neighborAffinityEntries??[]),fullAffinity:new Map(t.fullAffinityEntries??[]),centrality:new Map(t.centralityEntries??[]),loops:t.loops??[],loopEdgeKeys:new Set(t.loopEdgeKeyEntries??[]),txDelayRecommendations:new Map(t.txDelayRecommendationEntries??[]),pathRegistry:t.pathRegistry?Li(t.pathRegistry):Ni(),edgeBetweenness:new Map(t.edgeBetweennessEntries??[]),backboneEdges:t.backboneEdges??[],nodeMobility:new Map(t.nodeMobilityEntries??[]),mobileNodes:t.mobileNodes??[],pathHealth:t.pathHealth??[],lastHopNeighbors:t.lastHopNeighbors??[],disambiguationStats:t.disambiguationStats??{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:t.discoveredNodes??[],viterbiStats:t.viterbiStats??{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map(t.nodeMetricsEntries??[]),communityCount:t.communityCount??0,backboneNodes:t.backboneNodes??[]};for(const t of this.listeners)try{t(this.currentTopology,e.computeTimeMs)}catch(s){}if(this.pendingRequest){const e=this.pendingRequest;this.pendingRequest=null,this.computeInternal(e)}}}computeInternal(e){if(!this.worker)return;this.isComputing=!0;const t={type:"compute",payload:e};this.worker.postMessage(t)}compute(e,t,s,n,a,r,o,i){const l={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:r,zeroHopNeighbors:o,terrainGrid:i,enableTerrainAware:void 0!==i};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=l:this.computeInternal(l)},this.debounceMs)}subscribe(e){return this.listeners.add(e),this.currentTopology.edges.length>0&&e(this.currentTopology,0),()=>{this.listeners.delete(e)}}getTopology(){return this.currentTopology}isWorking(){return this.isComputing}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},Ei=new class{constructor(){t(this,"worker",null),t(this,"listeners",new Set),t(this,"sparklines",new Map),t(this,"isComputing",!1),t(this,"lastComputeTimeMs",0),t(this,"pendingRequest",null),t(this,"debounceTimer",null),t(this,"debounceMs",150),this.initWorker()}initWorker(){if("undefined"!=typeof window)try{this.worker=new Worker(new URL("/assets/sparkline.worker-CmKhBAy5.js",import.meta.url),{type:"module"}),this.worker.onmessage=e=>{this.handleWorkerMessage(e.data)},this.worker.onerror=e=>{this.isComputing=!1,this.notifyListeners()}}catch(e){}}handleWorkerMessage(e){if(this.isComputing=!1,"error"!==e.type){if(this.sparklines=new Map(e.payload.sparklineEntries),this.lastComputeTimeMs=e.computeTimeMs,this.notifyListeners(),this.pendingRequest){const e=this.pendingRequest;this.pendingRequest=null,this.computeInternal(e.packets,e.nodeHashes)}}else this.notifyListeners()}computeInternal(e,t){if(!this.worker)return;if(0===t.length)return this.isComputing=!1,void this.notifyListeners();this.isComputing=!0,this.notifyListeners();const s={type:"compute",payload:{packets:e,nodeHashes:t}};this.worker.postMessage(s)}notifyListeners(){for(const t of this.listeners)try{t(this.sparklines,this.isComputing)}catch(e){}}compute(e,t){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest={packets:e,nodeHashes:t}:this.computeInternal(e,t)},this.debounceMs)}getSparkline(e){return this.sparklines.get(e)??[]}getAllSparklines(){return this.sparklines}hasSparkline(e){return this.sparklines.has(e)}isWorking(){return this.isComputing}getLastComputeTime(){return this.lastComputeTimeMs}subscribe(e){return this.listeners.add(e),e(this.sparklines,this.isComputing),()=>{this.listeners.delete(e)}}clear(){this.sparklines.clear(),this.notifyListeners()}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},Pi=new class{constructor(){t(this,"worker",null),t(this,"isInitialized",!1),t(this,"statsListeners",new Set),t(this,"packetsListeners",new Set),t(this,"errorListeners",new Set),t(this,"readyResolve",null),t(this,"readyPromise",null),t(this,"unsubscribeTokenChange",null)}async init(e){if(!this.isInitialized&&"undefined"!=typeof window){this.readyPromise=new Promise(e=>{this.readyResolve=e});try{this.worker=new Worker(new URL("/assets/polling.worker-DFp1Qyu0.js",import.meta.url),{type:"module"}),this.worker.onmessage=this.handleMessage.bind(this),this.worker.onerror=e=>{};const t={type:"init",config:{apiBaseUrl:e.apiBaseUrl,authToken:e.authToken,statsIntervalMs:e.statsIntervalMs??3e3,packetsIntervalMs:e.packetsIntervalMs??3e3}};this.worker.postMessage(t),this.isInitialized=!0,this.unsubscribeTokenChange=_o(e=>{this.setAuthToken(e)}),await this.readyPromise}catch(t){throw t}}}handleMessage(e){var t;const s=e.data;switch(s.type){case"ready":null==(t=this.readyResolve)||t.call(this);break;case"stats":for(const e of this.statsListeners)try{e(s.data,s.timestamp)}catch(n){}break;case"packets":for(const e of this.packetsListeners)try{e(s.newPackets,s.totalCount,s.newestTimestamp)}catch(n){}break;case"packetsReset":for(const e of this.packetsListeners)try{e([],0,s.newestTimestamp)}catch(n){}break;case"error":for(const e of this.errorListeners)try{e(s.source,s.error)}catch(n){}}}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onPackets(e){return this.packetsListeners.add(e),()=>this.packetsListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}setAuthToken(e){if(!this.worker)return;const t={type:"setAuth",token:e};this.worker.postMessage(t)}setLiveMode(e){if(!this.worker)return;const t={type:"setLiveMode",enabled:e};this.worker.postMessage(t)}forceRefresh(){this.worker&&this.worker.postMessage({type:"forceRefresh"})}clearCache(){this.worker&&this.worker.postMessage({type:"clearCache"})}setTimeWindow(e){if(!this.worker)return;const t={type:"setTimeWindow",hours:e};this.worker.postMessage(t)}terminate(){if(this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.worker){const e={type:"stop"};this.worker.postMessage(e),this.worker.terminate(),this.worker=null}this.isInitialized=!1,this.statsListeners.clear(),this.packetsListeners.clear(),this.errorListeners.clear()}isReady(){return this.isInitialized}},Di=new class{constructor(){t(this,"ws",null),t(this,"connectionState","disconnected"),t(this,"reconnectAttempts",0),t(this,"pingIntervalId",null),t(this,"lastPongTime",Date.now()),t(this,"reconnectTimeoutId",null),t(this,"packetListeners",new Set),t(this,"statsListeners",new Set),t(this,"systemStatsListeners",new Set),t(this,"packetStatsListeners",new Set),t(this,"connectionListeners",new Set),t(this,"unsubscribeTokenChange",null),t(this,"wsSupported",!0)}buildWsUrl(){const e=Ao(),t=Po(),s=new URLSearchParams;e&&s.set("token",e),t&&s.set("client_id",t);const n=s.toString()?`?${s.toString()}`:"";return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws/packets${n}`}connect(){var e,t;if((null==(e=this.ws)?void 0:e.readyState)!==WebSocket.OPEN&&(null==(t=this.ws)?void 0:t.readyState)!==WebSocket.CONNECTING&&this.wsSupported){this.setConnectionState("connecting");try{const e=this.buildWsUrl();this.ws=new WebSocket(e),this.ws.onopen=this.handleOpen.bind(this),this.ws.onmessage=this.handleMessage.bind(this),this.ws.onerror=this.handleError.bind(this),this.ws.onclose=this.handleClose.bind(this),this.unsubscribeTokenChange||(this.unsubscribeTokenChange=_o(e=>{e&&"connected"===this.connectionState&&(this.disconnect(),this.connect())}))}catch(s){this.wsSupported=!1,this.setConnectionState("disconnected")}}}disconnect(){this.clearPingInterval(),this.clearReconnectTimeout(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING||this.ws.close(1e3,"Client disconnect"),this.ws=null),this.setConnectionState("disconnected"),this.reconnectAttempts=0}isConnected(){var e;return(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}isSupported(){return this.wsSupported}send(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return!1}}onPacket(e){return this.packetListeners.add(e),()=>this.packetListeners.delete(e)}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onSystemStats(e){return this.systemStatsListeners.add(e),()=>this.systemStatsListeners.delete(e)}onPacketStats(e){return this.packetStatsListeners.add(e),()=>this.packetStatsListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),e(this.connectionState,this.reconnectAttempts),()=>this.connectionListeners.delete(e)}handleOpen(){this.setConnectionState("connected"),this.reconnectAttempts=0,this.lastPongTime=Date.now();const e=Ao();e&&this.ws&&this.ws.send(JSON.stringify({type:"auth",token:e})),this.startPingInterval()}handleMessage(e){try{const t=JSON.parse(e.data);switch(t.type){case"packet":this.notifyPacketListeners(t.data);break;case"stats":{const e=t.data;e&&"noise_floor_dbm"in e&&this.notifyStatsListeners(e),(null==e?void 0:e.packet_stats)&&this.notifyPacketStatsListeners(e.packet_stats),(null==e?void 0:e.system_stats)&&this.notifySystemStatsListeners(e.system_stats);break}case"packet_stats":{const e=t.data;this.notifyPacketStatsListeners(e);break}case"system_stats":this.notifySystemStatsListeners(t.data);break;case"ping":this.lastPongTime=Date.now(),this.send({type:"pong"});break;case"pong":this.lastPongTime=Date.now()}}catch(t){}}handleError(e){}handleClose(e){this.clearPingInterval(),1e3!==e.code?(1006===e.code&&this.reconnectAttempts,this.scheduleReconnect()):this.setConnectionState("disconnected")}setConnectionState(e){if(this.connectionState!==e){this.connectionState=e;for(const s of this.connectionListeners)try{s(e,this.reconnectAttempts)}catch(t){}}}notifyPacketListeners(e){for(const s of this.packetListeners)try{s(e)}catch(t){}}notifyStatsListeners(e){for(const s of this.statsListeners)try{s(e)}catch(t){}}notifySystemStatsListeners(e){for(const s of this.systemStatsListeners)try{s(e)}catch(t){}}notifyPacketStatsListeners(e){for(const s of this.packetStatsListeners)try{s(e)}catch(t){}}startPingInterval(){this.clearPingInterval(),this.pingIntervalId=setInterval(()=>{var e;(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN&&(this.send({type:"ping"}),Date.now()-this.lastPongTime>6e4&&(this.disconnect(),this.connect()))},3e4)}clearPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null)}scheduleReconnect(){if(this.reconnectAttempts>=20)return this.wsSupported=!1,void this.setConnectionState("disconnected");this.setConnectionState("reconnecting");const e=Math.min(1e3*Math.pow(2,Math.min(this.reconnectAttempts,5)),3e4);this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout(()=>{this.reconnectTimeoutId=null,this.connect()},e)}clearReconnectTimeout(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)}terminate(){this.disconnect(),this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.packetListeners.clear(),this.statsListeners.clear(),this.systemStatsListeners.clear(),this.packetStatsListeners.clear(),this.connectionListeners.clear()}},Ii=3e4,Fi=new class{constructor(){t(this,"staged",new Map),t(this,"recentlyConfirmed",new Map),t(this,"listeners",new Set),t(this,"pruneIntervalId",null),this.startPruneInterval()}stage(e){const t=e.packet_hash;if(!t)return;if(this.staged.has(t))return;const s=this.recentlyConfirmed.get(t);s&&Date.now()-s=100&&this.removeOldest(),this.staged.set(t,{packet:e,stagedAt:Date.now()}),this.notifyListeners())}confirm(e){this.staged.delete(e)&&this.notifyListeners()}confirmBatch(e){let t=!1;const s=Date.now();for(const n of e)this.recentlyConfirmed.set(n,s),this.staged.delete(n)&&(t=!0);if(this.recentlyConfirmed.size>200){const e=s-Ii;for(const[t,s]of this.recentlyConfirmed)s(t.packet.timestamp??0)-(e.packet.timestamp??0))}isPending(e){return!!e&&this.staged.has(e)}getPendingCount(){return this.staged.size}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clear(){this.staged.size>0&&(this.staged.clear(),this.notifyListeners())}terminate(){this.stopPruneInterval(),this.staged.clear(),this.listeners.clear()}notifyListeners(){const e=this.getPendingPackets();for(const s of this.listeners)try{s(e)}catch(t){}}pruneExpired(){const e=Date.now();let t=!1;for(const[s,n]of this.staged)e-n.stagedAt>Ii&&(this.staged.delete(s),t=!0);t&&this.notifyListeners()}removeOldest(){let e=null,t=1/0;for(const[s,n]of this.staged)n.stagedAtthis.pruneExpired(),1e4))}stopPruneInterval(){this.pruneIntervalId&&(clearInterval(this.pruneIntervalId),this.pruneIntervalId=null)}},Ai=w(e=>({connectionState:"disconnected",isSupported:!0,reconnectAttempt:0,lastConnected:null,initialize:()=>{Di.onConnectionChange((t,s)=>{e(e=>({connectionState:t,reconnectAttempt:s??0,isSupported:Di.isSupported(),lastConnected:"connected"===t?Date.now():e.lastConnected}))}),Di.connect()}})),Ri=.05,zi=1e3,Bi="terrarium";function Oi(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const $i=w((e,t)=>({terrainGrid:null,isLoading:!1,error:null,lastLoadedAt:null,cachedBounds:null,terrainDisambiguationEnabled:!0,loadTerrain:async(s,n)=>{const a=t();if(!(a.isLoading||(r=a.cachedBounds,o=s,r&&r.minLat<=o.minLat&&r.maxLat>=o.maxLat&&r.minLng<=o.minLng&&r.maxLng>=o.maxLng))){var r,o;e({isLoading:!0,error:null});try{n.getTerrain()||(n.getSource(Bi)||(n.addSource(Bi,{type:"raster-dem",tiles:["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],encoding:"terrarium",tileSize:256}),await new Promise((e,t)=>{const s=setTimeout(()=>t(new Error("Terrain source load timeout")),1e4),a=t=>{t.sourceId===Bi&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:Bi}),await new Promise(e=>setTimeout(e,500)));const t=await async function(e,t){const{minLat:s,maxLat:n,minLng:a,maxLng:r}=t;let o=Math.ceil((r-a)/.001),i=Math.ceil((n-s)/.001);o>zi&&(o=zi),i>zi&&(i=zi);const l=(r-a)/o,c=(n-s)/i,u=Math.max(l,c),d=new Float32Array(o*i);let h=0;for(let m=0;msetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:o,height:i,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(i){const t=i instanceof Error?i.message:"Unknown error loading terrain";e({isLoading:!1,error:t})}}},preloadFromNodes:async(e,s)=>{const n=function(e){const t=e.filter(e=>void 0!==e.latitude&&void 0!==e.longitude&&(0!==e.latitude||0!==e.longitude));if(0===t.length)return null;let s=1/0,n=-1/0,a=1/0,r=-1/0;for(const o of t)s=Math.min(s,o.latitude),n=Math.max(n,o.latitude),a=Math.min(a,o.longitude),r=Math.max(r,o.longitude);return{minLat:s-Ri,maxLat:n+Ri,minLng:a-Ri,maxLng:r+Ri}}(e);n&&await t().loadTerrain(n,s)},clearTerrain:()=>{e({terrainGrid:null,cachedBounds:null,lastLoadedAt:null,error:null})},setTerrainDisambiguationEnabled:t=>{e({terrainDisambiguationEnabled:t})},getTerrainGridForDisambiguation:()=>{const e=t();return e.terrainDisambiguationEnabled?e.terrainGrid:null}})),Wi="pymc-stealth-location";function Hi(e){if("undefined"!=typeof window)try{localStorage.setItem(Wi,JSON.stringify(e))}catch{}}function Ui(e){return!isNaN(e)&&e>=-90&&e<=90}function qi(e){return!isNaN(e)&&e>=-180&&e<=180}const Gi=function(){if("undefined"==typeof window)return{};try{const e=localStorage.getItem(Wi);if(!e)return{};const t=JSON.parse(e);if("number"==typeof t.latitude&&"number"==typeof t.longitude&&"boolean"==typeof t.enabled&&Ui(t.latitude)&&qi(t.longitude))return t}catch{}return{}}(),Ji=w((e,t)=>({latitude:Gi.latitude??null,longitude:Gi.longitude??null,enabled:Gi.enabled??!1,setLocation:(s,n)=>{Ui(s)&&qi(n)&&(e({latitude:s,longitude:n}),Hi({latitude:s,longitude:n,enabled:t().enabled}))},enable:()=>{const{latitude:s,longitude:n}=t();null!==s&&null!==n&&(e({enabled:!0}),Hi({latitude:s,longitude:n,enabled:!0}))},disable:()=>{e({enabled:!1});const{latitude:s,longitude:n}=t();null!==s&&null!==n&&Hi({latitude:s,longitude:n,enabled:!1})},clear:()=>{e({latitude:null,longitude:null,enabled:!1}),function(){if("undefined"!=typeof window)try{localStorage.removeItem(Wi)}catch{}}()},getEffectiveLocation:()=>{const{latitude:e,longitude:s,enabled:n}=t();return n&&null!==e&&null!==s?{latitude:e,longitude:s}:null},isActive:()=>{const{latitude:e,longitude:s,enabled:n}=t();return n&&null!==e&&null!==s}}));function Yi(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function Vi(e,t){let s=e.forwarded_path??e.original_path;if("string"==typeof s)try{s=JSON.parse(s)}catch{return null}if(!s||!Array.isArray(s)||0===s.length)return null;const n=s.map(e=>String(e).toUpperCase()),a=t?Yi(t):null,r=n[n.length-1],o=null!==a&&r===a,i=o?n.slice(0,-1):[...n];return{effective:i,original:n,hadLocal:o,effectiveLength:i.length}}function Ki(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const Xi=[{label:"20m",minutes:20,buckets:80},{label:"1h",minutes:60,buckets:80},{label:"3h",minutes:180,buckets:80},{label:"12h",minutes:720,buckets:80},{label:"24h",minutes:1440,buckets:80},{label:"3d",minutes:4320,buckets:80},{label:"7d",minutes:10080,buckets:80},{label:"14d",minutes:20160,buckets:80}],Qi=[{label:"1h",hours:1},{label:"3h",hours:3},{label:"12h",hours:12},{label:"24h",hours:24},{label:"3d",hours:72},{label:"7d",hours:168},{label:"14d",hours:336}];function Zi(e,t=12){return Math.max(t,Math.round(e/15))}const el={hero:Zi(1200),statsCard:Zi(380)};function tl(e){switch(e){case 1:return 3600;case 3:case 12:return 5400;case 24:return 8640;case 72:case 168:case 336:return 720;default:{const t=3600*e,s=Math.round(t/10);return Math.min(Math.max(360,s),720)}}}const sl="'JetBrains Mono', 'SF Mono', Monaco, monospace",nl={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},al={DEBUG:"text-sys-brown",INFO:"text-sys-cyan",WARNING:"text-sys-amber",ERROR:"text-sys-red",CRITICAL:"text-sys-pink"};function rl(e){return al[e]??"text-text-muted border-border-subtle"}const ol="pymc-resource-history",il="pymc-resource-last-fetch",ll="pymc-hidden-contacts",cl="pymc-quick-neighbors",ul="pymc-local-hash",dl="pymc-global-time-range";let hl=null,ml=null;function fl(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function gl(e){return 4===(e.type??e.payload_type)&&!0!==e.transmitted&&function(e){const t=function(e){if(Array.isArray(e))return e;if("string"==typeof e&&e.startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}return[]}(e.original_path),s=e.route??e.route_type;return 2===(n=s)||3===n?0===t.length:Tr(s)?t.length<=1:0===t.length;var n}(e)}function pl(e,t,s,n){if(!e)return null;let a=e;if(e.length<=4){const n=e.replace(/^0x/i,"").toUpperCase();if(n===t)return null;const r=s.get(n);if(!r)return null;a=r}return n.has(a)?Yi(a)===t?null:a:null}function bl(e,t){e.count++,void 0!==t.rssi&&null!==t.rssi&&(e.rssiSum+=t.rssi,e.rssiCount++),void 0!==t.snr&&null!==t.snr&&(e.snrSum+=t.snr,e.snrCount++);const s=t.timestamp??0;s>e.lastSeen&&(e.lastSeen=s)}function yl(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function xl(e,t){const s=fl(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:Yi(e.hash),count:e.count,avgRssi:e.rssiCount>0?e.rssiSum/e.rssiCount:null,avgSnr:e.snrCount>0?e.snrSum/e.snrCount:null,lastSeen:e.lastSeen,status:s}}function wl(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(cl);if(e)return JSON.parse(e)}catch{}return[]}function vl(e){"undefined"!=typeof window&&(ml&&clearTimeout(ml),ml=setTimeout(()=>{try{localStorage.setItem(cl,JSON.stringify(e))}catch{}ml=null},1e3))}function kl(){if("undefined"!=typeof window)try{const e=localStorage.getItem(ul);if(e)return e}catch{}}function Sl(e){if("undefined"!=typeof window)try{localStorage.setItem(ul,e)}catch{}}function Cl(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(ol);if(e)return JSON.parse(e)}catch{}return[]}function jl(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(ll);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Tl(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(il);if(e)return parseInt(e,10)||0}catch{}return 0}function Ml(){if("undefined"==typeof window)return 4;try{const e=localStorage.getItem(dl);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<=7)return t}}catch{}return 4}const Ll=w((e,t)=>({stats:null,statsLoading:!1,statsError:null,packets:[],packetsLoading:!1,packetsError:null,lastPacketTimestamp:0,logs:[],logsLoading:!1,liveMode:!0,flashReceived:0,flashAdvert:0,pendingAdvertLocalHash:null,pendingAdvertTimestamp:null,resourceHistory:Cl(),lastResourceFetch:Tl(),hiddenContacts:jl(),quickNeighbors:wl(),cachedLocalHash:kl(),initialized:!1,packetCacheState:Mi.getState(),mutationsInFlight:new Set,globalTimeRangeIndex:Ml(),initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),Mi.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await oi(),a=n.neighbors??{},r=Date.now(),o=[];for(const[e,t]of Object.entries(a)){if(s.has(e))continue;if(!t.zero_hop)continue;const n=fl(t.last_seen??0,r);"expired"!==n&&o.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:n})}o.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const i=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:o,cachedLocalHash:i}),vl(o),i&&Sl(i);const l=()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},c=await Mi.initialLoad(l);if(c.length>0){const s=c.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...c],packetsLoading:!1,lastPacketTimestamp:s}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}else e({packetsLoading:!1})}catch(n){e({statsError:n instanceof Error?n.message:"Failed to initialize",statsLoading:!1,packetsLoading:!1})}Ai.getState().initialize(),Di.onPacket(s=>{const{lastPacketTimestamp:n,mutationsInFlight:a}=t();if(a.size>0)return;Fi.stage(s);const r=s.timestamp??0;r>n&&e({flashReceived:t().flashReceived+1,lastPacketTimestamp:r})}),Di.onStats(s=>{const{mutationsInFlight:n,hiddenContacts:a}=t();if(n.size>0)return;const r=s.neighbors??{},o=Date.now(),i=[];for(const[e,t]of Object.entries(r)){if(a.has(e))continue;if(!t.zero_hop)continue;const s=fl(t.last_seen??0,o);"expired"!==s&&i.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}i.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const l=s.local_hash;e({stats:s,statsLoading:!1,statsError:null,quickNeighbors:i,cachedLocalHash:l}),vl(i),l&&Sl(l)}),Di.onPacketStats(s=>{const{stats:n,mutationsInFlight:a}=t();if(!n||a.size>0)return;const r={...n,rx_count:s.rx_count??n.rx_count,tx_count:s.tx_count??n.tx_count,forwarded_count:s.forwarded_count??n.forwarded_count,dropped_count:s.dropped_count??n.dropped_count};e({stats:r})});try{await Pi.init({apiBaseUrl:"",authToken:Ao()??void 0,statsIntervalMs:nl.stats,packetsIntervalMs:nl.packets}),Pi.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:r}=t();if(a.size>0)return;const o=s.neighbors??{},i=Date.now(),l=[];for(const[e,t]of Object.entries(o)){if(r.has(e))continue;if(!t.zero_hop)continue;const s=fl(t.last_seen??0,i);"expired"!==s&&l.push({hash:e,prefix:Yi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const c=s.local_hash;e({stats:s,statsLoading:!1,statsError:null,quickNeighbors:l,cachedLocalHash:c}),vl(l),c&&Sl(c)}),Pi.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:r}=t(),o=s.map(e=>e.packet_hash).filter(e=>!!e);Fi.confirmBatch(o),Mi.mergePacketsDirectly(s);const i=a>r;i&&ui();const l=Mi.getPackets();e({packets:l,packetsLoading:!1,packetsError:null,lastPacketTimestamp:a}),i&&t().triggerTopologyCompute()}),Pi.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||Pi.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},nl.stats),setInterval(()=>{e().liveMode&&!Mi.isHeavyLoadInProgress()&&e().fetchPackets()},nl.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":ii().catch(()=>{});break;case"/system":hi().catch(()=>{});break;case"/statistics":(async function(e=24){return ti(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),li(3).catch(()=>{});break;case"/settings":(async function(){return ti("/api/radio_presets")})().catch(()=>{})}},fetchStats:async s=>{const{stats:n,mutationsInFlight:a,hiddenContacts:r}=t();if(!(a.size>0)||(null==s?void 0:s.force)){n||e({statsLoading:!0}),e({statsError:null});try{const t=await oi(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,i]of Object.entries(s)){if(r.has(e))continue;if(!i.zero_hop)continue;const t=fl(i.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:Yi(e),count:i.advert_count??0,avgRssi:i.rssi??null,avgSnr:i.snr??null,lastSeen:i.last_seen??0,status:t})}a.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const o=t.local_hash;e({stats:t,statsLoading:!1,quickNeighbors:a,cachedLocalHash:o}),vl(a),o&&Sl(o)}catch(o){e({statsError:o instanceof Error?o.message:"Failed to fetch stats",statsLoading:!1})}}},fetchPackets:async s=>{const{packets:n,lastPacketTimestamp:a}=t();0===n.length&&e({packetsLoading:!0}),e({packetsError:null});try{const s=await Mi.poll(),r=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,o=r>a&&a>0,i=s.length!==n.length||o;o&&(e({flashReceived:t().flashReceived+1}),ui()),e(i?{packets:s,packetsLoading:!1,lastPacketTimestamp:r||a}:{packetsLoading:!1}),o&&t().triggerTopologyCompute()}catch(r){e({packetsError:r instanceof Error?r.message:"Failed to fetch packets",packetsLoading:!1})}},fetchLogs:async()=>{const{logs:s}=t();0===s.length&&e({logsLoading:!0});try{const t=await ii();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),Pi.isReady()&&Pi.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),r=new Set(a);r.add(n),e({mutationsInFlight:r});try{if(!(await pi(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(o){const{mutationsInFlight:s}=t(),a=new Set(s);throw a.delete(n),e({mutationsInFlight:a}),o}},clearModeMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setMode"),e({mutationsInFlight:n})},setDutyCycle:async s=>{const n="setDutyCycle",{mutationsInFlight:a}=t(),r=new Set(a);r.add(n),e({mutationsInFlight:r});try{if(!(await bi(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}finally{const{mutationsInFlight:s}=t(),a=new Set(s);a.delete(n),e({mutationsInFlight:a})}},setDutyCycleConfig:async s=>{var n;const a="setDutyCycleConfig",{mutationsInFlight:r}=t(),o=new Set(r);o.add(a),e({mutationsInFlight:o});try{const e=await async function(e){return ti("/api/update_duty_cycle_config",{method:"POST",body:JSON.stringify(e)})}(s);if(!e.success&&!(null==(n=e.data)?void 0:n.persisted))throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(i){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),i}},clearDutyCycleMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setDutyCycleConfig"),e({mutationsInFlight:n})},startMutation:s=>{const{mutationsInFlight:n}=t(),a=new Set(n);a.add(s),e({mutationsInFlight:a})},clearMutation:s=>{const{mutationsInFlight:n}=t(),a=new Set(n);a.delete(s),e({mutationsInFlight:a})},sendAdvert:async()=>{try{const s=await gi();return s.success?(e({flashAdvert:t().flashAdvert+1}),{success:!0}):{success:!1,error:s.error||"Failed to send advert"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Unknown error"}}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const r=Date.now(),{lastResourceFetch:o,resourceHistory:i}=t();if(r-o<1e3)return;const l=[...i,{timestamp:r,time:new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=l.length>a?l.slice(-a):l;var u,d;e({resourceHistory:c,lastResourceFetch:r}),u=c,d=r,"undefined"!=typeof window&&(hl&&clearTimeout(hl),hl=setTimeout(()=>{try{localStorage.setItem(ol,JSON.stringify(u)),localStorage.setItem(il,d.toString())}catch{}hl=null},1e3))},hideContact:s=>{const{hiddenContacts:n}=t(),a=new Set(n);a.add(s),e({hiddenContacts:a}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(ll,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{Mi.clear(),e({packets:[],lastPacketTimestamp:0}),Mi.quickLoad().then(s=>{if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:s,lastPacketTimestamp:n}),t().triggerTopologyCompute()}})},triggerTopologyCompute:()=>{var e,s,n,a;const{packets:r,stats:o,hiddenContacts:i}=t();if(0===r.length||!o)return;const l=o.neighbors??{},c=Object.fromEntries(Object.entries(l).filter(([e])=>!i.has(e))),u=o.local_hash;let d=null==(s=null==(e=o.config)?void 0:e.repeater)?void 0:s.latitude,h=null==(a=null==(n=o.config)?void 0:n.repeater)?void 0:a.longitude;if(!d||!h||0===d&&0===h){const e=Ji.getState().getEffectiveLocation();e&&(d=e.latitude,h=e.longitude)}const m=[];for(const[t,g]of Object.entries(c))g.zero_hop&&m.push({hash:t,advertCount:g.advert_count??1,avgRssi:g.rssi??null,avgSnr:g.snr??null,lastSeen:g.last_seen??0,latitude:g.latitude,longitude:g.longitude});const f=$i.getState().getTerrainGridForDisambiguation();_i.compute(r,c,u,d,h,void 0,m,f??void 0)},triggerDeepAnalysis:async()=>{await Mi.forceDeepLoad();const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:s,lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},updateQuickNeighbors:()=>{const{packets:s,stats:n,hiddenContacts:a}=t();if(0===s.length||!n)return;const r=n.neighbors??{},o=function(e,t,s){if(!s||0===e.length||0===Object.keys(t).length)return[];const n=Date.now(),a=Yi(s),r=new Set(Object.keys(t)),o=function(e){var t,s;const n=new Map;for(const a of Object.keys(e)){const r=Yi(a),o=n.get(r);if(o){const i=null==(t=e[o])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!i&&n.set(r,a)}else n.set(r,a)}return n}(t),i=new Map;for(const c of e){if(!gl(c))continue;const e=pl(c.src_hash,a,o,r);if(!e)continue;let t=i.get(e);t||(t=yl(e),i.set(e,t)),bl(t,c)}for(const[c,u]of Object.entries(t))Yi(c)!==a&&u.zero_hop&&!i.has(c)&&i.set(c,{hash:c,count:u.advert_count??0,rssiSum:u.rssi??0,rssiCount:void 0!==u.rssi?1:0,snrSum:u.snr??0,snrCount:void 0!==u.snr?1:0,lastSeen:u.last_seen??0});const l=[];for(const c of i.values()){const e=xl(c,n);e&&l.push(e)}return l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),l}(s,Object.fromEntries(Object.entries(r).filter(([e])=>!a.has(e))),n.local_hash),i=t().quickNeighbors;(o.length!==i.length||o.some((e,t)=>{var s,n;return e.hash!==(null==(s=i[t])?void 0:s.hash)||e.count!==(null==(n=i[t])?void 0:n.count)}))&&(e({quickNeighbors:o}),vl(o))},triggerSparklineCompute:()=>{const{packets:e,stats:s,hiddenContacts:n}=t();if(0===e.length||!s)return;const a=s.neighbors??{},r=Object.keys(a).filter(e=>!n.has(e));0!==r.length&&Ei.compute(e,r)},requestSevenDayData:async()=>{await Mi.loadSevenDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestThreeDayData:async()=>{await Mi.loadThreeDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestFourteenDayData:async()=>{await Mi.loadFourteenDays(()=>{const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Mi.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},setGlobalTimeRange:s=>{e({globalTimeRangeIndex:s}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(dl,e.toString())}catch{}}(s);const n={0:1,1:1,2:3,3:12,4:24,5:72,6:168,7:336}[s]??24;Pi.setTimeWindow(n);const{packetCacheState:a,requestThreeDayData:r,requestSevenDayData:o,requestFourteenDayData:i,triggerTopologyCompute:l,triggerSparklineCompute:c}=t();let u=!1;5!==s||a.threeDayLoadComplete||a.isBackgroundLoading||(r(),u=!0),6!==s||a.sevenDayLoadComplete||a.isBackgroundLoading||(o(),u=!0),7!==s||a.fourteenDayLoadComplete||a.isBackgroundLoading||(i(),u=!0),!u&&s>=5&&(l(),c())}})),Nl=Ll,_l=()=>Ll(e=>e.stats),El=()=>Ll(e=>e.statsError),Pl=()=>Ll(e=>e.packets),Dl=()=>Ll(e=>e.packetsLoading),Il=()=>Ll(e=>e.logs),Fl=()=>Ll(e=>e.logsLoading),Al=()=>Ll(e=>e.liveMode),Rl=()=>Ll(e=>e.fetchLogs),zl=()=>Ll(e=>e.setLiveMode),Bl=()=>Ll(e=>e.resourceHistory),Ol=()=>Ll(e=>e.addResourceDataPoint),$l=()=>Ll(e=>e.hiddenContacts),Wl=()=>Ll(e=>e.hideContact),Hl=()=>Ll(e=>e.packetCacheState),Ul=()=>Ll(e=>e.triggerDeepAnalysis),ql=()=>Ll(e=>e.quickNeighbors),Gl=()=>Ll(e=>e.cachedLocalHash),Jl=()=>Ll(e=>e.lastPacketTimestamp),Yl=()=>Ll(e=>e.globalTimeRangeIndex),Vl=()=>Ll(e=>e.setGlobalTimeRange),Kl=()=>Ll(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete);function Xl(){const e=Ll(e=>{var t,s,n;return null==(n=null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.repeater)?void 0:n.latitude}),t=Ll(e=>{var t,s,n;return null==(n=null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.repeater)?void 0:n.longitude}),s=Ll(e=>{var t,s,n;return(null==(s=null==(t=e.stats)?void 0:t.config)?void 0:s.node_name)||(null==(n=e.stats)?void 0:n.node_name)||"Local Node"}),n=Ji(e=>e.latitude),a=Ji(e=>e.longitude),r=Ji(e=>e.enabled);return e&&t&&(0!==e||0!==t)?{latitude:e,longitude:t,name:s,isStealth:!1}:r&&null!==n&&null!==a?{latitude:n,longitude:a,name:s,isStealth:!0}:null}const Ql={rx:{p3:"color(display-p3 0.2 1 0.4)",fallback:"#00FF66"},tx:{p3:"color(display-p3 1 0.9 0.2)",fallback:"#FFDD00"}};function Zl({showLabel:e=!1,className:t}){var a;const r=Ll(e=>e.flashReceived),o=Ll(e=>e.flashAdvert),i=Ai(e=>"connected"===e.connectionState),[l,c]=s.useState("idle"),u=s.useRef(0),d=s.useRef(0);s.useEffect(()=>{if(r<=0)return;const e=Date.now();if(e-u.current<50)return;u.current=e,c("rx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[r]),s.useEffect(()=>{if(o<=0)return;const e=Date.now();if(e-d.current<50)return;d.current=e,c("tx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[o]);const h="rx"===l?Ql.rx:"tx"===l?Ql.tx:null;return n.jsxs("span",{className:J("inline-flex items-center gap-2",t),title:i?"Real-time (WebSocket)":"Database polling",children:[n.jsx("span",{className:"inline-flex rounded-full w-1.5 h-1.5",style:h?{backgroundColor:h.fallback,...(null==(a=CSS.supports)?void 0:a.call(CSS,"color","color(display-p3 1 1 1)"))&&{backgroundColor:h.p3}}:{backgroundColor:"var(--livedot-idle)"}}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:i?"Live":"DB"})]})}function ec({borderRadius:e}){return n.jsx(c.div,{initial:{opacity:0},animate:{opacity:.8,backgroundPosition:["200% 0%","-200% 0%"]},exit:{opacity:0},transition:{opacity:{duration:.2},backgroundPosition:{duration:2,ease:"easeInOut",repeat:1/0}},style:{position:"absolute",inset:0,zIndex:1,pointerEvents:"none",borderRadius:e,padding:2,background:"linear-gradient(\n 90deg,\n transparent 0%,\n transparent 25%,\n var(--accent-primary) 50%,\n transparent 75%,\n transparent 100%\n )",backgroundSize:"200% 100%",mask:"\n linear-gradient(#fff 0 0) content-box,\n linear-gradient(#fff 0 0)\n ",maskComposite:"exclude",WebkitMaskComposite:"xor"}})}function tc({children:e,isLoading:t=!0,className:s,borderRadius:a=12}){return n.jsxs("div",{className:J("relative overflow-hidden",s),style:{borderRadius:a},children:[n.jsx(i,{children:t&&n.jsx(ec,{borderRadius:a})}),n.jsx("div",{className:"relative z-10",children:e})]})}function sc({className:e}){return n.jsx("div",{className:J("relative w-10 h-1 rounded-sm overflow-hidden","bg-bg-elevated",e),children:n.jsx(c.div,{animate:{backgroundPosition:["200% 0%","-200% 0%"]},transition:{duration:1.5,ease:"easeInOut",repeat:1/0},className:"absolute inset-0",style:{background:"linear-gradient(\n 90deg,\n transparent 0%,\n var(--accent-primary) 50%,\n transparent 100%\n )",backgroundSize:"200% 100%"}})})}const nc=w(e=>({sparklines:new Map,isComputing:!1,lastUpdated:0,nodeCount:0,setSparklines:t=>e({sparklines:t,lastUpdated:Date.now(),nodeCount:t.size,isComputing:!1}),setComputing:t=>e({isComputing:t})}));"undefined"!=typeof window&&setTimeout(()=>{Ei.subscribe((e,t)=>{const s=nc.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const ac=()=>nc(e=>e.isComputing),rc=[],oc=new Map;function ic(e){return nc(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return rc;const n=oc.get(e);return n===s?n:(oc.set(e,s),s)})}const lc=w(e=>({topology:{edges:[],validatedEdges:[],weakEdges:[],certainEdges:[],uncertainEdges:[],edgeMap:new Map,maxPacketCount:0,maxCertainCount:0,neighborAffinity:new Map,fullAffinity:new Map,localPrefix:null,centrality:new Map,hubNodes:[],gatewayNodes:[],loops:[],loopEdgeKeys:new Set,txDelayRecommendations:new Map,pathRegistry:Ni(),edgeBetweenness:new Map,backboneEdges:[],nodeMobility:new Map,mobileNodes:[],pathHealth:[],lastHopNeighbors:[],disambiguationStats:{totalPrefixes:0,unambiguousPrefixes:0,collisionPrefixes:0,collisionRate:0,avgConfidence:0,lowConfidencePrefixes:[],highCollisionPrefixes:[],totalResolutions:0},discoveredNodes:[],viterbiStats:{totalPaths:0,pathsWithGhosts:0,avgPathCost:0,avgPathConfidence:0,observationOverrideCount:0,tracePacketsProcessed:0,pathPacketsProcessed:0,distantEdgesDiscovered:0,duplicateGroupsFound:0,duplicatePathsUnique:0,echolocationEdgesInferred:0},nodeMetrics:new Map,communityCount:0,backboneNodes:[]},isComputing:!1,lastComputeTimeMs:0,lastUpdated:0,setTopology:(t,s)=>e({topology:t,lastComputeTimeMs:s,lastUpdated:Date.now(),isComputing:!1}),setComputing:t=>e({isComputing:t})}));"undefined"!=typeof window&&_i.subscribe((e,t)=>{lc.getState().setTopology(e,t)});const cc=()=>lc(e=>e.topology),uc=()=>lc(e=>e.topology.hubNodes),dc=()=>lc(e=>e.topology.centrality),hc=()=>lc(e=>e.topology.fullAffinity);let mc=null,fc=null,gc=null,pc=null;const bc=()=>lc(e=>(e.topology.hubNodes!==fc&&(fc=e.topology.hubNodes,mc=new Set(e.topology.hubNodes)),mc)),yc=()=>lc(e=>e.topology.pathHealth),xc=()=>lc(e=>e.topology.disambiguationStats),wc=()=>lc(e=>e.topology.disambiguationStats.highCollisionPrefixes),vc=()=>lc(e=>e.topology.disambiguationStats.totalPrefixes>0),kc=()=>lc(e=>e.topology.discoveredNodes),Sc=()=>lc(e=>e.topology.viterbiStats),Cc=()=>lc(e=>(e.topology.discoveredNodes!==pc&&(pc=e.topology.discoveredNodes,gc=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),gc)),jc=()=>lc(e=>e.topology.nodeMetrics);let Tc=null,Mc=null;const Lc=()=>lc(e=>{if(e.topology.nodeMetrics!==Mc){Mc=e.topology.nodeMetrics,Tc={local:0,hub:0,gateway:0,backbone:0,neighbor:0,mobile:0,ghost:0,standard:0};for(const t of e.topology.nodeMetrics.values())Tc[t.nodeClass]++}return Tc});function Nc(e){if(e<60)return`${Math.floor(e)}s`;const t=Math.floor(e/86400),s=Math.floor(e%86400/3600),n=Math.floor(e%3600/60),a=[];return t>0&&a.push(`${t}d`),s>0&&a.push(`${s}h`),(n>0||0===a.length)&&a.push(`${n}m`),a.join(" ")}function _c(e){const t=Date.now()/1e3-e;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function Ec(e){return new Date(1e3*e).toLocaleString()}function Pc(e){const t=new Date(1e3*e);return`${t.toLocaleString("en-US",{month:"short"})} ${t.getDate()}, ${t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}`}function Dc(e){return new Date(1e3*e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ic(e){return`${(e/1e6).toFixed(3)} MHz`}function Fc(e){return`${(e/1e3).toFixed(1)} kHz`}function Ac(e){const t=e>1e12?e:1e3*e,s=Date.now(),n=Math.abs(s-t),a=Math.floor(n/1e3),r=Math.floor(a/60),o=Math.floor(r/60),i=Math.floor(o/24);return i>0?`${i} day${1!==i?"s":""}`:o>0?`${o} hour${1!==o?"s":""}`:r>0?`${r} minute${1!==r?"s":""}`:`${a} second${1!==a?"s":""}`}function Rc(e){e<0&&(e=0);const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60);if(n>0){const e=s%60;return e>0?`${n}h ${e}m`:`${n}h`}if(s>0){const e=t%60;return e>0?`${s}m ${e}s`:`${s}m`}if(t>0){const s=e%1e3;return s>0?`${t}.${Math.floor(s/100)}s`:`${t}s`}return`${e}ms`}const zc=[{name:"Dashboard",to:"/",icon:k},{name:"Contacts",to:"/contacts",icon:S},{name:"Packets",to:"/packets",icon:C},{name:"Statistics",to:"/statistics",icon:j},{name:"MeshGraph",to:"/meshgraph",icon:T},{name:"System",to:"/system",icon:M},{name:"Logs",to:"/logs",icon:L},{name:"Terminal",to:"/terminal",icon:N},{name:"Configuration",to:"/configuration",icon:_}],Bc="pymc-controls-expanded",Oc=()=>{if("undefined"==typeof window)return!0;const e=localStorage.getItem(Bc);return null===e||"true"===e};function $c(){var e,t,a,r,o,i;const{pathname:l}=v(),{stats:c,setMode:u,setDutyCycle:d,sendAdvert:h}=Nl(),m=Uo(),f=Ll(e=>e.prefetchForRoute),g=Hl(),p=Ll(e=>e.packetCacheState.dataTier),b=ac(),y=lc(e=>e.isComputing),x=Cc();let w=null;try{w=function(){const e=s.useContext(ho);if(!e)throw new Error("useSidebar must be used within a SidebarLayout");return e}()}catch{}const[k,S]=s.useState(!1),[C,j]=s.useState("idle"),[T,L]=s.useState(null),N=s.useRef(null),_=s.useCallback(e=>{e!==l&&(N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{f(e)},100))},[l,f]),B=s.useCallback(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]);s.useEffect(()=>{const e=new MutationObserver(()=>{const e=document.querySelector("[data-controls-disclosure]");if(e){const t="true"===e.getAttribute("aria-expanded");localStorage.setItem(Bc,String(t))}}),t=document.querySelector("[data-controls-disclosure]");return t&&e.observe(t,{attributes:!0,attributeFilter:["aria-expanded"]}),()=>e.disconnect()},[]);const O=null==c?void 0:c.noise_floor_dbm,$=(null==(t=null==(e=null==c?void 0:c.config)?void 0:e.repeater)?void 0:t.mode)??"forward",W=(null==(r=null==(a=null==c?void 0:c.config)?void 0:a.duty_cycle)?void 0:r.enforcement_enabled)??!1,H=(null==(i=null==(o=null==c?void 0:c.config)?void 0:o.duty_cycle)?void 0:i.max_airtime_percent)??10,U=g.isLoading||g.isBackgroundLoading||g.isTopologyLoading,q=U||b||y,G=g.loadProgress,Y=()=>{null==w||w.close()};return n.jsxs(no,{children:[n.jsxs(ao,{className:"px-5 py-6",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(jo,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",So]})]}),n.jsxs(ro,{className:"py-4",children:[n.jsx(io,{children:zc.map(e=>{const t=l===e.to;return n.jsxs(lo,{href:e.to,current:t,onClick:Y,onMouseEnter:()=>_(e.to),onMouseLeave:B,children:[n.jsx(e.icon,{}),n.jsx(co,{children:e.name}),"/contacts"===e.to&&x.length>0&&n.jsxs(uo,{variant:"accent",children:[n.jsx(E,{className:"w-3 h-3"}),n.jsx("span",{children:x.length})]}),"/meshgraph"===e.to&&n.jsx(uo,{variant:"default",children:"Beta"})]},e.name)})}),q&&n.jsx("div",{className:"px-0 py-3",children:n.jsx(tc,{isLoading:U,borderRadius:12,children:n.jsxs("div",{className:"bg-glass-surface/50 rounded-xl p-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[n.jsxs("div",{className:"relative flex h-2 w-2",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-accent-primary"})]}),n.jsx("span",{className:"type-data-xs text-text-muted flex-1 truncate",children:g.isLoading&&G?"Loading 24h history...":g.isBackgroundLoading&&G?g.statusMessage||`Loading ${p} history...`:g.isTopologyLoading?"Loading topology data...":b?"Computing sparklines":y?"Building topology":"Analyzing database"}),null!==(null==G?void 0:G.percent)&&void 0!==(null==G?void 0:G.percent)&&U&&n.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[G.percent,"%"]})]}),n.jsx("div",{className:"mt-1.5 h-1 bg-subtle-fill rounded-full overflow-hidden",children:null!==(null==G?void 0:G.percent)&&void 0!==(null==G?void 0:G.percent)&&U?n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full transition-all duration-300 ease-out",style:{width:`${G.percent}%`}}):n.jsx("div",{className:"h-full bg-accent-primary/40 rounded-full w-full"})}),!U&&n.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"type-micro text-text-muted",children:"Data:"}),n.jsx("span",{className:"type-data-xs text-accent-primary",children:(e=>{switch(e){case"24h":return"24 hours";case"3d":return"3 days";case"7d":return"7 days";case"14d":return"14 days";default:return e}})(p)})]})]})})}),n.jsx("div",{className:"flex-1"}),n.jsx(ko,{label:"Controls",icon:n.jsx(F,{className:"w-5 h-5 text-accent-primary"}),defaultOpen:Oc(),direction:"up",dataId:"controls",children:n.jsxs("div",{className:"flex flex-col gap-2 px-1",children:[n.jsx(Wr,{color:"success"===C?"success":"error"===C?"danger":"primary",onClick:async()=>{S(!0),j("idle"),L(null);const e=await h();S(!1),e.success?(j("success"),setTimeout(()=>j("idle"),1500)):(j("error"),L(e.error||"Failed to send"),setTimeout(()=>{j("idle"),L(null)},3e3))},disabled:k,className:"w-full justify-center",children:k?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{"data-slot":"icon",className:"animate-spin",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Sending..."]}):"success"===C?n.jsxs(n.Fragment,{children:[n.jsx("svg",{"data-slot":"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:n.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent!"]}):"error"===C?n.jsxs(n.Fragment,{children:[n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Failed"]}):n.jsxs(n.Fragment,{children:[n.jsx(P,{"data-slot":"icon"}),"Send Advert"]})}),T&&n.jsx("p",{className:"text-accent-danger text-xs text-center",children:T}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs text-text-muted",children:"Repeat"}),n.jsx("span",{className:J("text-xs font-medium","forward"===$?"text-accent-success":"text-accent-secondary"),children:"forward"===$?"ON":"OFF"})]}),n.jsx(Wr,{color:"forward"===$?"success":"warning",onClick:()=>{u("forward"===$?"monitor":"forward")},className:"w-full justify-center",children:"forward"===$?n.jsxs(n.Fragment,{children:[n.jsx(D,{"data-slot":"icon"}),"Repeating"]}):n.jsxs(n.Fragment,{children:[n.jsx(I,{"data-slot":"icon"}),"Monitor Only"]})}),n.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[n.jsx("span",{className:"text-xs text-text-muted",children:"Duty Cycle"}),n.jsx("span",{className:J("text-xs font-medium tabular-nums",W?"text-accent-secondary":"text-text-muted"),children:W?`${H}%`:"OFF"})]}),n.jsxs(Wr,{color:W?"warning":"muted",onClick:()=>{d(!W)},className:"w-full justify-center",children:[n.jsx(M,{"data-slot":"icon"}),W?`Limited to ${H}%`:"Disabled"]})]})})]}),n.jsxs(oo,{children:[void 0!==(null==c?void 0:c.uptime_seconds)&&n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3",children:[n.jsx(A,{className:"w-5 h-5 text-text-muted flex-shrink-0"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[Nc(c.uptime_seconds)," uptime"]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsx("div",{className:"bg-subtle-fill rounded-xl p-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(R,{className:"w-4 h-4 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted",children:"Noise Floor"})]}),n.jsx("span",{className:"type-data text-text-primary tabular-nums",children:null!=O?`${O.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3 border-t border-border-subtle",children:[n.jsx(Zl,{showLabel:!0}),(null==c?void 0:c.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted truncate max-w-[140px]",title:`v${c.version}`,children:["v",c.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:()=>{Vo(),window.location.href="/login"},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-text-muted hover:text-accent-danger hover:bg-accent-danger/10 transition-all duration-150",children:[n.jsx(z,{className:"w-4 h-4"}),n.jsx("span",{className:"type-body-sm",children:"Sign Out"}),m&&n.jsxs("span",{className:"ml-auto type-data-xs text-text-muted",children:["(",m,")"]})]})})]})]})}function Wc(){const e=Hl(),t=e.isLoading||e.isBackgroundLoading||e.isTopologyLoading;return n.jsxs(po,{children:[n.jsxs(bo,{children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(jo,{height:26,className:"block"}),t&&n.jsx(sc,{className:"ml-2"})]}),n.jsx(yo,{}),n.jsxs(bo,{children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",So]}),n.jsx(Zl,{})]})]})}const Hc=s.memo(function(){const{theme:e}=vr(),{backgroundImage:t,brightness:s,colorScheme:a}=e,r=Oe(a),o=(null==r?void 0:r.meta.backgroundImage)||null==r?void 0:r.meta.backgroundColor,i=(100-s)/100;return n.jsxs(n.Fragment,{children:[t?n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint"},"aria-hidden":"true",children:n.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat transition-opacity duration-300 ease-out",style:{backgroundImage:`url(${t})`}})}):o?n.jsx("div",{className:"fixed inset-0 -z-20 transition-colors duration-300 ease-out",style:{backgroundColor:o,contain:"paint"},"aria-hidden":"true"}):null,n.jsx("div",{className:"fixed inset-0 -z-10 bg-black pointer-events-none transition-opacity duration-200 ease-out",style:{opacity:i,contain:"paint"},"aria-hidden":"true"})]})}),Uc=20,qc=12,Gc=s.createContext(null);function Jc({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),r=s.useRef(null),[o,i]=s.useState({x:0,y:0}),l=s.useCallback((e,t,s)=>{a({content:e,mouseX:t,mouseY:s,visible:!0})},[]),c=s.useCallback(()=>{a(e=>({...e,visible:!1}))},[]),u=s.useCallback((e,t)=>{a(s=>s.visible?{...s,mouseX:e,mouseY:t}:s)},[]);s.useEffect(()=>{if(!t.visible||!r.current)return;const e=r.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,o=window.innerHeight;let l,c;l=s+Uc+e.width+qc>a?s-Uc-e.width:s+Uc,l=Math.max(qc,Math.min(l,a-e.width-qc)),c=n-Uc-e.height{c.current&&(clearTimeout(c.current),c.current=null)},h=s.useCallback(t=>{d(),c.current=setTimeout(()=>{u.current=!0,r(e,t.clientX,t.clientY)},a)},[r,e,a]),m=s.useCallback(e=>{u.current&&i(e.clientX,e.clientY)},[i]),f=s.useCallback(()=>{d(),u.current=!1,o()},[o]),g=s.useCallback(()=>{if(d(),!l.current)return;const t=l.current.getBoundingClientRect();c.current=setTimeout(()=>{u.current=!0,r(e,t.left+t.width/2,t.top)},a)},[r,e,a]),p=s.useCallback(()=>{d(),u.current=!1,o()},[o]);return s.useEffect(()=>()=>{d(),u.current&&(u.current=!1,o())},[o]),s.useEffect(()=>{const e=()=>{u.current&&(d(),u.current=!1,o())};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[o]),n.jsx("span",{ref:l,onMouseEnter:h,onMouseMove:m,onMouseLeave:f,onFocus:g,onBlur:p,className:"contents",children:t})}function Vc({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function Kc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-48"}),n.jsx(Vc,{className:"h-8 w-32"})]}),n.jsx(Vc,{className:"h-72"}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-3",children:Array.from({length:8}).map((e,t)=>n.jsx(Vc,{className:"h-24"},t))}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>n.jsx(Vc,{className:"h-44"},t))}),n.jsx(Vc,{className:"h-96"})]})}function Xc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-40"}),n.jsx(Vc,{className:"h-8 w-24"})]}),n.jsx(Vc,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(Vc,{className:"h-10 rounded-none"}),n.jsx("div",{className:"divide-y divide-border-subtle/30",children:Array.from({length:10}).map((e,t)=>n.jsx("div",{className:"px-4 py-3",children:n.jsx(Vc,{className:"h-6"})},t))})]})]})}function Qc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-32"}),n.jsx(Vc,{className:"h-6 w-48"})]}),n.jsx(Vc,{className:"h-[500px]"}),n.jsx(Vc,{className:"h-64"})]})}function Zc(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Vc,{className:"h-8 w-36"}),n.jsx(Vc,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(Vc,{className:"h-80"}),n.jsx(Vc,{className:"h-80"})]}),n.jsx(Vc,{className:"h-64"})]})}function eu(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(Vc,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(Vc,{className:"h-48"}),n.jsx(Vc,{className:"h-64"}),n.jsx(Vc,{className:"h-32"})]})]})}function tu(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(Vc,{className:"h-8 w-28"}),n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>n.jsx(Vc,{className:"h-28"},t))}),n.jsx(Vc,{className:"h-64"}),n.jsx(Vc,{className:"h-48"})]})}const su={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:.15}}},nu={initial:{opacity:0,y:8},animate:{opacity:1,y:0,transition:{duration:.3,ease:to.cubicInOut}},exit:{opacity:0,y:-8,transition:{duration:.15,ease:to.easeIn}}};function au({children:e,layoutKey:t}){return O()?n.jsx(n.Fragment,{children:e}):n.jsx(c.div,{initial:"initial",animate:"animate",exit:"exit",variants:nu,children:e},t)}const ru=s.lazy(()=>G(()=>import("./Login-CkRuF4n8.js"),__vite__mapDeps([0,1,2]))),ou=s.lazy(()=>G(()=>import("./Dashboard-DiETwG01.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12,13,14]))),iu=s.lazy(()=>G(()=>import("./Packets-BHJJxf8a.js"),__vite__mapDeps([15,1,2,6,7,8,9,4,5,13]))),lu=s.lazy(()=>G(()=>import("./Contacts-CyyU4xmf.js").then(e=>e.C),__vite__mapDeps([16,1,2,17,5,9,8,18,19,20,21]))),cu=s.lazy(()=>G(()=>import("./Statistics-sXHAGtEF.js"),__vite__mapDeps([22,1,2,23,4,10,5,9,18,19,13,14,21]))),uu=s.lazy(()=>G(()=>import("./MeshGraph-DfCwG9Nt.js"),__vite__mapDeps([24,1,2,25]))),du=s.lazy(()=>G(()=>import("./System-BPwbPFCW.js"),__vite__mapDeps([26,1,2,4,5,14,13]))),hu=s.lazy(()=>G(()=>import("./Logs-Cb5GXQFD.js"),__vite__mapDeps([27,1,2,23,5,13]))),mu=s.lazy(()=>G(()=>import("./Terminal-jVZnyeIH.js"),__vite__mapDeps([28,1,2,17,7,5]))),fu=s.lazy(()=>G(()=>import("./Configuration-BOsliPZn.js"),__vite__mapDeps([29,1,2,20,30,12,5,9,13,14])));function gu({children:e}){const t=v();return Bo()?n.jsx(n.Fragment,{children:e}):n.jsx(H,{to:"/login",state:{from:t},replace:!0})}class pu extends s.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){var e;return this.state.hasError?n.jsxs("div",{className:"glass-card p-8 text-center",children:[n.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Page failed to render"}),n.jsx("p",{className:"type-body text-white/50 mb-4",children:(null==(e=this.state.error)?void 0:e.message)||"Unknown error"}),n.jsx("button",{onClick:()=>this.setState({hasError:!1}),className:"px-4 py-2 bg-accent-primary/20 text-accent-primary rounded-lg hover:bg-accent-primary/30 transition-colors",children:"Try Again"})]}):this.props.children}}function bu(){const e=Ll(e=>e.initializeApp),t=Bo();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{Yo()},3e4);return Yo(),Xo(),()=>clearInterval(s)},[e,t]),n.jsxs(Jc,{children:[n.jsx(Hc,{}),n.jsxs($,{children:[n.jsx(W,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(ru,{})})}),n.jsx(W,{path:"/*",element:n.jsx(gu,{children:n.jsx(go,{sidebar:n.jsx($c,{}),navbar:n.jsx(Wc,{}),children:n.jsx("div",{className:"px-4 sm:px-6 lg:px-8 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:n.jsx(pu,{children:n.jsxs($,{children:[n.jsx(W,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(Kc,{}),children:n.jsx(au,{children:n.jsx(ou,{})})})}),n.jsx(W,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(iu,{})})})}),n.jsx(W,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(Qc,{}),children:n.jsx(au,{children:n.jsx(lu,{})})})}),n.jsx(W,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(Zc,{}),children:n.jsx(au,{children:n.jsx(cu,{})})})}),n.jsx(W,{path:"/meshgraph",element:n.jsx(s.Suspense,{fallback:n.jsx(Zc,{}),children:n.jsx(au,{children:n.jsx(uu,{})})})}),n.jsx(W,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(tu,{}),children:n.jsx(au,{children:n.jsx(du,{})})})}),n.jsx(W,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(hu,{})})})}),n.jsx(W,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(Xc,{}),children:n.jsx(au,{children:n.jsx(mu,{})})})}),n.jsx(W,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(eu,{}),children:n.jsx(au,{children:n.jsx(fu,{})})})})]})})})})})})]})]})}const yu=console.warn;console.warn=(...e)=>{const t=e[0];if("string"==typeof t){if(t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0"))return;if(t.includes("Unable to load glyph range"))return}yu.apply(console,e)},U.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx(wr,{children:n.jsx(q,{children:n.jsx(bu,{})})})}));export{ac as $,Dc as A,Ar as B,Mr as C,Xi as D,Lr as E,sl as F,Ki as G,Jr as H,Ec as I,bc as J,hc as K,Zl as L,kc as M,Vr as N,Qr as O,jo as P,Rr as Q,Cr as R,el as S,Yc as T,Rc as U,Pc as V,jr as W,yc as X,Sc as Y,Ac as Z,ic as _,so as a,wc as a0,Nl as a1,Wl as a2,uc as a3,dc as a4,Xl as a5,_c as a6,X as a7,K as a8,Oe as a9,gi as aA,pi as aB,bi as aC,fi as aD,yi as aE,ti as aF,Xe as aG,nt as aH,Ji as aI,Ic as aJ,Fc as aK,Xr as aL,Zr as aM,Mi as aN,Vi as aO,Tr as aP,Gl as aQ,$i as aR,tc as aS,su as aT,fr as aa,ni as ab,ai as ac,br as ad,vr as ae,xc as af,vc as ag,Cc as ah,Qi as ai,tl as aj,Ul as ak,cc as al,jc as am,Lc as an,Bl as ao,Ol as ap,hi as aq,mi as ar,nl as as,Nc as at,Il as au,Fl as av,Rl as aw,rl as ax,So as ay,oi as az,eo as b,Dl as c,Al as d,_l as e,ql as f,Do as g,$l as h,Bo as i,Yl as j,li as k,qo as l,Jl as m,Yi as n,El as o,Kl as p,Vl as q,Hl as r,Io as s,di as t,Pl as u,zl as v,Fi as w,Sr as x,Wr as y,Er as z}; diff --git a/frontend/dist/assets/link-scoring-BNnTohl3.js b/frontend/dist/assets/link-scoring-Cw0dJsWv.js similarity index 94% rename from frontend/dist/assets/link-scoring-BNnTohl3.js rename to frontend/dist/assets/link-scoring-Cw0dJsWv.js index 000ead42..d3e317f4 100644 --- a/frontend/dist/assets/link-scoring-BNnTohl3.js +++ b/frontend/dist/assets/link-scoring-Cw0dJsWv.js @@ -1 +1 @@ -import{n as t,aP as e}from"./index-CPdqYR4z.js";function n(t){if(Array.isArray(t))return t;if("string"==typeof t&&t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}return[]}function o(o,r,s){const a=new Map;for(const e of r){const n=t(e);a.has(n)||a.set(n,e)}const c=new Map,i=new Map;for(const t of o){const o=t.route??t.route_type;if(!e(o))continue;const r=n(t.original_path);if(0===r.length)continue;const f=r.map(t=>t.toUpperCase());if(!t.transmitted&&f.length>=2){const t=f[f.length-2];if(t){const e=a.get(t);e&&i.set(e,(i.get(e)??0)+1)}}if(f.includes(s))for(const t of f){if(t===s)continue;const e=a.get(t);e&&c.set(e,(c.get(e)??0)+1)}}let f=0,u=0;for(const t of r)f=Math.max(f,c.get(t)??0),u=Math.max(u,i.get(t)??0);const h=new Map;let g=0,l=0,p=0;for(const t of r){const e=c.get(t)??0,n=i.get(t)??0,o=f>0?Math.round(e/f*100):0,r=u>0?Math.round(n/u*100):0,s=o+r;h.set(t,{hash:t,listenerCount:e,loudCount:n,listenerScore:o,loudScore:r,blendedScore:s}),g=Math.max(g,o),l=Math.max(l,r),p=Math.max(p,s)}return{scores:h,maxListenerScore:g,maxLoudScore:l,maxBlendedScore:p}}const r={YELLOW:"#FFB224",GREEN:"#46A758",RED:"#E5484D",GRAY:"#505050"};export{r as L,o as c}; +import{n as t,aP as e}from"./index-BJEgt3tp.js";function n(t){if(Array.isArray(t))return t;if("string"==typeof t&&t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}return[]}function o(o,r,s){const a=new Map;for(const e of r){const n=t(e);a.has(n)||a.set(n,e)}const c=new Map,i=new Map;for(const t of o){const o=t.route??t.route_type;if(!e(o))continue;const r=n(t.original_path);if(0===r.length)continue;const f=r.map(t=>t.toUpperCase());if(!t.transmitted&&f.length>=2){const t=f[f.length-2];if(t){const e=a.get(t);e&&i.set(e,(i.get(e)??0)+1)}}if(f.includes(s))for(const t of f){if(t===s)continue;const e=a.get(t);e&&c.set(e,(c.get(e)??0)+1)}}let f=0,u=0;for(const t of r)f=Math.max(f,c.get(t)??0),u=Math.max(u,i.get(t)??0);const h=new Map;let g=0,l=0,p=0;for(const t of r){const e=c.get(t)??0,n=i.get(t)??0,o=f>0?Math.round(e/f*100):0,r=u>0?Math.round(n/u*100):0,s=o+r;h.set(t,{hash:t,listenerCount:e,loudCount:n,listenerScore:o,loudScore:r,blendedScore:s}),g=Math.max(g,o),l=Math.max(l,r),p=Math.max(p,s)}return{scores:h,maxListenerScore:g,maxLoudScore:l,maxBlendedScore:p}}const r={YELLOW:"#FFB224",GREEN:"#46A758",RED:"#E5484D",GRAY:"#505050"};export{r as L,o as c}; diff --git a/frontend/dist/assets/ping-BvkXSZG_.js b/frontend/dist/assets/ping-DvLgBqTv.js similarity index 94% rename from frontend/dist/assets/ping-BvkXSZG_.js rename to frontend/dist/assets/ping-DvLgBqTv.js index f3940151..90190331 100644 --- a/frontend/dist/assets/ping-BvkXSZG_.js +++ b/frontend/dist/assets/ping-DvLgBqTv.js @@ -1 +1 @@ -import{aF as t}from"./index-CPdqYR4z.js";async function e(e,r=10){return t("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:r})})}const r=["Chat Node","Repeater","Room Server","Hybrid Node","Unknown"];async function s(s,o=10){if(o<1||o>60)return{success:!1,error:"Timeout must be 1-60 seconds"};let n;const a=s.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(a)n=`0x${a[2].padStart(2,"0")}`;else{const e=await async function(e){const s=e.toLowerCase();for(const o of r)try{const e=await t(`/api/adverts_by_contact_type?contact_type=${encodeURIComponent(o)}&hours=168`),r=e.success&&e.data?e.data:e,n=(Array.isArray(r)?r:[]).find(t=>t.node_name&&t.node_name.toLowerCase()===s);if(n&&n.pubkey)return`0x${n.pubkey.substring(0,2)}`}catch{continue}return null}(s);if(!e)return{success:!1,error:`Node '${s}' not found`};n=e}const c=await e(n,o);if(!c.success||!c.data)return{success:!1,error:c.error||"Ping failed"};const i=(u=c.data).rtt_ms>500||u.rssi<-120?"Poor":u.rtt_ms>250||u.rssi<-100?"Fair":u.rtt_ms>100||u.rssi<-80?"Good":"Excellent";var u;return{success:!0,data:{...c.data,quality:i}}}export{s as a,e as p}; +import{aF as t}from"./index-BJEgt3tp.js";async function e(e,r=10){return t("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:r})})}const r=["Chat Node","Repeater","Room Server","Hybrid Node","Unknown"];async function s(s,o=10){if(o<1||o>60)return{success:!1,error:"Timeout must be 1-60 seconds"};let n;const a=s.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(a)n=`0x${a[2].padStart(2,"0")}`;else{const e=await async function(e){const s=e.toLowerCase();for(const o of r)try{const e=await t(`/api/adverts_by_contact_type?contact_type=${encodeURIComponent(o)}&hours=168`),r=e.success&&e.data?e.data:e,n=(Array.isArray(r)?r:[]).find(t=>t.node_name&&t.node_name.toLowerCase()===s);if(n&&n.pubkey)return`0x${n.pubkey.substring(0,2)}`}catch{continue}return null}(s);if(!e)return{success:!1,error:`Node '${s}' not found`};n=e}const c=await e(n,o);if(!c.success||!c.data)return{success:!1,error:c.error||"Ping failed"};const i=(u=c.data).rtt_ms>500||u.rssi<-120?"Poor":u.rtt_ms>250||u.rssi<-100?"Fair":u.rtt_ms>100||u.rssi<-80?"Good":"Excellent";var u;return{success:!0,data:{...c.data,quality:i}}}export{s as a,e as p}; diff --git a/frontend/dist/index.html b/frontend/dist/index.html index b5498853..cbdae6f3 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -39,7 +39,7 @@ --font-data: 'JetBrains Mono', 'SF Mono', Monaco, monospace; } - + diff --git a/frontend/package.json b/frontend/package.json index ecbd557b..186b8cbd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "pymc_console", - "version": "0.9.194", + "version": "0.9.195", "description": "Vite + React Dashboard for pyMC_Repeater", "private": true, "type": "module",