diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index d69a1f68..dda9943d 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.143 +0.9.144 diff --git a/frontend/dist/assets/CollisionExplorerModal-DEtEH0fD.js b/frontend/dist/assets/CollisionExplorerModal-dc7PClY6.js similarity index 98% rename from frontend/dist/assets/CollisionExplorerModal-DEtEH0fD.js rename to frontend/dist/assets/CollisionExplorerModal-dc7PClY6.js index 746d91b4..294bd1ee 100644 --- a/frontend/dist/assets/CollisionExplorerModal-DEtEH0fD.js +++ b/frontend/dist/assets/CollisionExplorerModal-dc7PClY6.js @@ -1 +1 @@ -import{r as e,b as t,j as o,a7 as s,X as n,a5 as r,ao as a,ap as l,aq as i,ar as c,aa as d,$ as u}from"./vendor-react-O8XH9yVn.js";import{L as m}from"./leaflet-D_ckmI2R.js";import{c as h}from"./recharts-BU7auunF.js";import{d as x,w as p,f}from"./index-Dp0UlTio.js";const b={DEFAULT:"#4338CA",AMBER:"#F59E0B",NEIGHBOR:"#39D98A",MUTED:"#6B7280",HIGHLIGHT:"#FBBF24"};function y(){if("undefined"==typeof document)return b;const e=document.documentElement,t=getComputedStyle(e);return{DEFAULT:t.getPropertyValue("--map-hub-color").trim()||b.DEFAULT,AMBER:t.getPropertyValue("--pkt-txt-msg").trim()||b.AMBER,NEIGHBOR:t.getPropertyValue("--accent-success").trim()||b.NEIGHBOR,MUTED:t.getPropertyValue("--text-muted").trim()||b.MUTED,HIGHLIGHT:t.getPropertyValue("--accent-secondary").trim()||b.HIGHLIGHT}}function v({hash:t,highlighted:s}){const[n,r]=e.useState(!1),a=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),function(e){if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const t=window.scrollX,o=window.scrollY,s=document.createElement("textarea");s.value=e,s.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",s.setAttribute("readonly",""),document.body.appendChild(s),s.focus({preventScroll:!0}),s.select(),s.setSelectionRange(0,e.length);const n=document.execCommand("copy");return document.body.removeChild(s),window.scrollTo(t,o),n}catch{return!1}}(t),r(!0),setTimeout(()=>r(!1),2e3)},[t]),l=t.length>12?`${t.slice(0,12)}…`:t;return o.jsxs("button",{type:"button",onClick:a,className:h("inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] font-mono rounded transition-all","border border-border-subtle hover:border-border-strong cursor-pointer select-none",s?"bg-accent-secondary/20 border-accent-secondary/50":"bg-bg-subtle/80 hover:bg-bg-elevated"),title:`Click to copy: ${t}`,children:[o.jsx("span",{className:h("transition-colors",n?"text-accent-success":"text-text-secondary"),children:l}),n?o.jsx(d,{className:"w-2.5 h-2.5 text-accent-success"}):o.jsx(u,{className:"w-2.5 h-2.5 opacity-40"})]})}function g({node:e,className:t}){const s=y(),n=e.contactType.toLowerCase(),r="room server"===n||"room_server"===n||"room"===n||"server"===n,d="companion"===n||"client"===n||"cli"===n;return r&&e.isRepeater?o.jsxs("div",{className:h("relative",t),children:[o.jsx(a,{className:"w-full h-full",style:{color:s.AMBER}}),o.jsx(l,{className:"w-1/2 h-1/2 absolute -bottom-0.5 -right-0.5",style:{color:s.DEFAULT}})]}):r?o.jsx(a,{className:t,style:{color:s.AMBER}}):d?o.jsx(i,{className:h(t,"text-text-muted")}):e.isRepeater?e.isNeighbor?o.jsx(c,{className:t,style:{color:s.NEIGHBOR}}):o.jsx(l,{className:t,style:{color:s.DEFAULT}}):o.jsx(i,{className:h(t,"text-text-muted")})}function w({node:e,isHovered:t,onMouseEnter:s,onMouseLeave:n,onTouchStart:r}){return o.jsxs("div",{className:h("flex items-center gap-3 px-3 py-2.5 transition-colors rounded-lg",t?"bg-accent-secondary/10":"hover:bg-white/[0.03]"),onMouseEnter:s,onMouseLeave:n,onTouchStart:r,children:[o.jsx("div",{className:"flex-shrink-0 w-5 h-5",children:o.jsx(g,{node:e,className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),e.isNeighbor&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-accent-success/20 text-accent-success",children:"NBR"}),e.isRepeater&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-text-muted font-medium",children:"RPT"})]}),o.jsx("div",{className:"mt-1",children:o.jsx(v,{hash:e.hash,highlighted:t})})]})]})}function N({nodes:t,hoveredHash:s,onNodeHover:n,onNodeLeave:a}){const l=e.useRef(null),i=e.useRef(null),c=e.useRef(new Map),d=e.useMemo(()=>t.filter(e=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude),[t]);return e.useEffect(()=>{if(!i.current||l.current)return;const e=m.map(i.current,{zoomControl:!0,attributionControl:!0});return m.tileLayer("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",{attribution:'© OSM © CARTO'}).addTo(e),l.current=e,()=>{e.remove(),l.current=null}},[]),e.useEffect(()=>{const e=l.current;if(!e)return;if(c.current.forEach(e=>e.remove()),c.current.clear(),0===d.length)return;const t=m.latLngBounds([]);for(const o of d){if(!o.latitude||!o.longitude)continue;const s=m.latLng(o.latitude,o.longitude);t.extend(s);const r=y(),l=o.isNeighbor?r.NEIGHBOR:r.DEFAULT,i=m.circleMarker(s,{radius:8,fillColor:l,fillOpacity:.8,color:"#fff",weight:2,opacity:.9});i.bindTooltip(o.name,{permanent:!1,direction:"top",offset:[0,-8],className:"collision-tooltip"}),i.on("mouseover",()=>n(o.hash)),i.on("mouseout",()=>a()),i.addTo(e),c.current.set(o.hash,i)}t.isValid()&&e.fitBounds(t,{padding:[40,40],maxZoom:12})},[d,n,a]),e.useEffect(()=>{c.current.forEach((e,t)=>{const o=d.find(e=>e.hash===t);if(!o)return;const n=y(),r=t===s,a=o.isNeighbor?n.NEIGHBOR:n.DEFAULT;e.setStyle({radius:r?12:8,fillColor:r?n.HIGHLIGHT:a,weight:r?3:2}),r?(e.openTooltip(),e.bringToFront()):e.closeTooltip()})},[s,d]),0===d.length?o.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 rounded-lg",children:o.jsxs("div",{className:"text-center text-text-muted p-4",children:[o.jsx(r,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),o.jsx("p",{className:"text-sm",children:"No location data available"}),o.jsx("p",{className:"text-xs opacity-70",children:"Nodes need GPS coordinates to appear on the map"})]})}):o.jsx("div",{ref:i,className:"h-full w-full rounded-lg overflow-hidden"})}const j=e.memo(function({isOpen:r,prefix:a,candidateHashes:l,onClose:i}){const c=x(),d=p(),u=f(),[m,b]=e.useState(null),y=e.useMemo(()=>new Set(u.map(e=>e.hash)),[u]),v=null==c?void 0:c.neighbors,g=e.useMemo(()=>v?l.map(e=>{var t,o;const s=v[e];return{hash:e,name:(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==s?void 0:s.contact_type)||"",isRepeater:(null==s?void 0:s.is_repeater)||"repeater"===(null==(t=null==s?void 0:s.contact_type)?void 0:t.toLowerCase())||"rep"===(null==(o=null==s?void 0:s.contact_type)?void 0:o.toLowerCase())||!1,isNeighbor:y.has(e),isHub:d.has(e),latitude:null==s?void 0:s.latitude,longitude:null==s?void 0:s.longitude,lastSeen:null==s?void 0:s.last_seen}}).sort((e,t)=>e.isNeighbor!==t.isNeighbor?e.isNeighbor?-1:1:e.name.localeCompare(t.name)):[],[l,v,y,d]),j=e.useCallback(e=>b(e),[]),E=e.useCallback(()=>b(null),[]);return e.useEffect(()=>{if(!r)return;const e=e=>{"Escape"===e.key&&i()};window.addEventListener("keydown",e);const t=window.scrollY,o={overflow:document.body.style.overflow,position:document.body.style.position,width:document.body.style.width,top:document.body.style.top};return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${t}px`,()=>{window.removeEventListener("keydown",e),document.body.style.overflow=o.overflow,document.body.style.position=o.position,document.body.style.width=o.width,document.body.style.top=o.top,window.scrollTo(0,t)}},[r,i]),r?t.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[10010] flex items-end sm:items-center justify-center",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"collision-modal-title",children:o.jsxs("div",{className:h("glass-card-elevated w-full flex flex-col","max-h-[85vh] rounded-t-2xl rounded-b-none","sm:max-w-2xl sm:mx-4 sm:rounded-xl sm:max-h-[80vh]","pb-safe"),onClick:e=>e.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-signal-fair/10",children:o.jsx(s,{className:"w-5 h-5 text-signal-fair"})}),o.jsxs("div",{children:[o.jsxs("h3",{id:"collision-modal-title",className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",o.jsx("span",{className:"font-mono text-accent-primary",children:a})]}),o.jsxs("p",{className:"text-xs text-text-muted",children:[g.length," nodes share this prefix"]})]})]}),o.jsx("button",{onClick:i,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:o.jsx(n,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-1 min-h-0 flex flex-col sm:flex-row overflow-hidden",children:[o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto sm:max-w-[280px] sm:border-r sm:border-border-subtle",children:o.jsx("div",{className:"p-2",children:g.map(e=>o.jsx(w,{node:e,isHovered:m===e.hash,onMouseEnter:()=>j(e.hash),onMouseLeave:E,onTouchStart:()=>j(e.hash)},e.hash))})}),o.jsx("div",{className:"h-48 sm:h-auto sm:flex-1 p-2 flex-shrink-0",children:o.jsx(N,{nodes:g,hoveredHash:m,onNodeHover:j,onNodeLeave:E})})]})]})}),document.body):null});export{j as C}; +import{r as e,b as t,j as o,a7 as s,X as n,a5 as r,ao as a,ap as l,aq as i,ar as c,aa as d,$ as u}from"./vendor-react-O8XH9yVn.js";import{L as m}from"./leaflet-D_ckmI2R.js";import{c as h}from"./recharts-BU7auunF.js";import{d as x,w as p,f}from"./index-DGrzd8xb.js";const b={DEFAULT:"#4338CA",AMBER:"#F59E0B",NEIGHBOR:"#39D98A",MUTED:"#6B7280",HIGHLIGHT:"#FBBF24"};function y(){if("undefined"==typeof document)return b;const e=document.documentElement,t=getComputedStyle(e);return{DEFAULT:t.getPropertyValue("--map-hub-color").trim()||b.DEFAULT,AMBER:t.getPropertyValue("--pkt-txt-msg").trim()||b.AMBER,NEIGHBOR:t.getPropertyValue("--accent-success").trim()||b.NEIGHBOR,MUTED:t.getPropertyValue("--text-muted").trim()||b.MUTED,HIGHLIGHT:t.getPropertyValue("--accent-secondary").trim()||b.HIGHLIGHT}}function v({hash:t,highlighted:s}){const[n,r]=e.useState(!1),a=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),function(e){if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const t=window.scrollX,o=window.scrollY,s=document.createElement("textarea");s.value=e,s.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",s.setAttribute("readonly",""),document.body.appendChild(s),s.focus({preventScroll:!0}),s.select(),s.setSelectionRange(0,e.length);const n=document.execCommand("copy");return document.body.removeChild(s),window.scrollTo(t,o),n}catch{return!1}}(t),r(!0),setTimeout(()=>r(!1),2e3)},[t]),l=t.length>12?`${t.slice(0,12)}…`:t;return o.jsxs("button",{type:"button",onClick:a,className:h("inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] font-mono rounded transition-all","border border-border-subtle hover:border-border-strong cursor-pointer select-none",s?"bg-accent-secondary/20 border-accent-secondary/50":"bg-bg-subtle/80 hover:bg-bg-elevated"),title:`Click to copy: ${t}`,children:[o.jsx("span",{className:h("transition-colors",n?"text-accent-success":"text-text-secondary"),children:l}),n?o.jsx(d,{className:"w-2.5 h-2.5 text-accent-success"}):o.jsx(u,{className:"w-2.5 h-2.5 opacity-40"})]})}function g({node:e,className:t}){const s=y(),n=e.contactType.toLowerCase(),r="room server"===n||"room_server"===n||"room"===n||"server"===n,d="companion"===n||"client"===n||"cli"===n;return r&&e.isRepeater?o.jsxs("div",{className:h("relative",t),children:[o.jsx(a,{className:"w-full h-full",style:{color:s.AMBER}}),o.jsx(l,{className:"w-1/2 h-1/2 absolute -bottom-0.5 -right-0.5",style:{color:s.DEFAULT}})]}):r?o.jsx(a,{className:t,style:{color:s.AMBER}}):d?o.jsx(i,{className:h(t,"text-text-muted")}):e.isRepeater?e.isNeighbor?o.jsx(c,{className:t,style:{color:s.NEIGHBOR}}):o.jsx(l,{className:t,style:{color:s.DEFAULT}}):o.jsx(i,{className:h(t,"text-text-muted")})}function w({node:e,isHovered:t,onMouseEnter:s,onMouseLeave:n,onTouchStart:r}){return o.jsxs("div",{className:h("flex items-center gap-3 px-3 py-2.5 transition-colors rounded-lg",t?"bg-accent-secondary/10":"hover:bg-white/[0.03]"),onMouseEnter:s,onMouseLeave:n,onTouchStart:r,children:[o.jsx("div",{className:"flex-shrink-0 w-5 h-5",children:o.jsx(g,{node:e,className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),e.isNeighbor&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-accent-success/20 text-accent-success",children:"NBR"}),e.isRepeater&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-white/10 text-text-muted font-medium",children:"RPT"})]}),o.jsx("div",{className:"mt-1",children:o.jsx(v,{hash:e.hash,highlighted:t})})]})]})}function N({nodes:t,hoveredHash:s,onNodeHover:n,onNodeLeave:a}){const l=e.useRef(null),i=e.useRef(null),c=e.useRef(new Map),d=e.useMemo(()=>t.filter(e=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude),[t]);return e.useEffect(()=>{if(!i.current||l.current)return;const e=m.map(i.current,{zoomControl:!0,attributionControl:!0});return m.tileLayer("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",{attribution:'© OSM © CARTO'}).addTo(e),l.current=e,()=>{e.remove(),l.current=null}},[]),e.useEffect(()=>{const e=l.current;if(!e)return;if(c.current.forEach(e=>e.remove()),c.current.clear(),0===d.length)return;const t=m.latLngBounds([]);for(const o of d){if(!o.latitude||!o.longitude)continue;const s=m.latLng(o.latitude,o.longitude);t.extend(s);const r=y(),l=o.isNeighbor?r.NEIGHBOR:r.DEFAULT,i=m.circleMarker(s,{radius:8,fillColor:l,fillOpacity:.8,color:"#fff",weight:2,opacity:.9});i.bindTooltip(o.name,{permanent:!1,direction:"top",offset:[0,-8],className:"collision-tooltip"}),i.on("mouseover",()=>n(o.hash)),i.on("mouseout",()=>a()),i.addTo(e),c.current.set(o.hash,i)}t.isValid()&&e.fitBounds(t,{padding:[40,40],maxZoom:12})},[d,n,a]),e.useEffect(()=>{c.current.forEach((e,t)=>{const o=d.find(e=>e.hash===t);if(!o)return;const n=y(),r=t===s,a=o.isNeighbor?n.NEIGHBOR:n.DEFAULT;e.setStyle({radius:r?12:8,fillColor:r?n.HIGHLIGHT:a,weight:r?3:2}),r?(e.openTooltip(),e.bringToFront()):e.closeTooltip()})},[s,d]),0===d.length?o.jsx("div",{className:"h-full flex items-center justify-center bg-bg-subtle/30 rounded-lg",children:o.jsxs("div",{className:"text-center text-text-muted p-4",children:[o.jsx(r,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),o.jsx("p",{className:"text-sm",children:"No location data available"}),o.jsx("p",{className:"text-xs opacity-70",children:"Nodes need GPS coordinates to appear on the map"})]})}):o.jsx("div",{ref:i,className:"h-full w-full rounded-lg overflow-hidden"})}const j=e.memo(function({isOpen:r,prefix:a,candidateHashes:l,onClose:i}){const c=x(),d=p(),u=f(),[m,b]=e.useState(null),y=e.useMemo(()=>new Set(u.map(e=>e.hash)),[u]),v=null==c?void 0:c.neighbors,g=e.useMemo(()=>v?l.map(e=>{var t,o;const s=v[e];return{hash:e,name:(null==s?void 0:s.node_name)||(null==s?void 0:s.name)||`Unknown (${e.slice(0,8)}…)`,contactType:(null==s?void 0:s.contact_type)||"",isRepeater:(null==s?void 0:s.is_repeater)||"repeater"===(null==(t=null==s?void 0:s.contact_type)?void 0:t.toLowerCase())||"rep"===(null==(o=null==s?void 0:s.contact_type)?void 0:o.toLowerCase())||!1,isNeighbor:y.has(e),isHub:d.has(e),latitude:null==s?void 0:s.latitude,longitude:null==s?void 0:s.longitude,lastSeen:null==s?void 0:s.last_seen}}).sort((e,t)=>e.isNeighbor!==t.isNeighbor?e.isNeighbor?-1:1:e.name.localeCompare(t.name)):[],[l,v,y,d]),j=e.useCallback(e=>b(e),[]),E=e.useCallback(()=>b(null),[]);return e.useEffect(()=>{if(!r)return;const e=e=>{"Escape"===e.key&&i()};window.addEventListener("keydown",e);const t=window.scrollY,o={overflow:document.body.style.overflow,position:document.body.style.position,width:document.body.style.width,top:document.body.style.top};return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${t}px`,()=>{window.removeEventListener("keydown",e),document.body.style.overflow=o.overflow,document.body.style.position=o.position,document.body.style.width=o.width,document.body.style.top=o.top,window.scrollTo(0,t)}},[r,i]),r?t.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[10010] flex items-end sm:items-center justify-center",onClick:i,role:"dialog","aria-modal":"true","aria-labelledby":"collision-modal-title",children:o.jsxs("div",{className:h("glass-card-elevated w-full flex flex-col","max-h-[85vh] rounded-t-2xl rounded-b-none","sm:max-w-2xl sm:mx-4 sm:rounded-xl sm:max-h-[80vh]","pb-safe"),onClick:e=>e.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-subtle flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-signal-fair/10",children:o.jsx(s,{className:"w-5 h-5 text-signal-fair"})}),o.jsxs("div",{children:[o.jsxs("h3",{id:"collision-modal-title",className:"text-base font-semibold text-text-primary",children:["Prefix Collision: ",o.jsx("span",{className:"font-mono text-accent-primary",children:a})]}),o.jsxs("p",{className:"text-xs text-text-muted",children:[g.length," nodes share this prefix"]})]})]}),o.jsx("button",{onClick:i,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:o.jsx(n,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-1 min-h-0 flex flex-col sm:flex-row overflow-hidden",children:[o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto sm:max-w-[280px] sm:border-r sm:border-border-subtle",children:o.jsx("div",{className:"p-2",children:g.map(e=>o.jsx(w,{node:e,isHovered:m===e.hash,onMouseEnter:()=>j(e.hash),onMouseLeave:E,onTouchStart:()=>j(e.hash)},e.hash))})}),o.jsx("div",{className:"h-48 sm:h-auto sm:flex-1 p-2 flex-shrink-0",children:o.jsx(N,{nodes:g,hoveredHash:m,onNodeHover:j,onNodeLeave:E})})]})]})}),document.body):null});export{j as C}; diff --git a/frontend/dist/assets/Configuration-Cq1_waCf.js b/frontend/dist/assets/Configuration-TGWiCMQL.js similarity index 99% rename from frontend/dist/assets/Configuration-Cq1_waCf.js rename to frontend/dist/assets/Configuration-TGWiCMQL.js index 78036c2b..7fb9be9e 100644 --- a/frontend/dist/assets/Configuration-Cq1_waCf.js +++ b/frontend/dist/assets/Configuration-TGWiCMQL.js @@ -1 +1 @@ -import{r as e,j as t,f as s,i as a,X as r,at as n,aa as l,aX as c,aY as i,k as d,p as o,aZ as u,af as m,a_ as x,a$ as p,b0 as h,aP as b,av as y,b1 as g,aj as f,b2 as j,a7 as v,a2 as N,$ as w,a9 as k,b3 as C}from"./vendor-react-O8XH9yVn.js";import{c as _}from"./recharts-BU7auunF.js";import{ad as S,ae as T,af as F,I as E,ag as L,ah as P,ai as R,aj as I,ac as A,ak as M,al as D,am as z,an as K,ao as O,ap as q,aq as H,ar as $,as as Y}from"./index-Dp0UlTio.js";import{H as V}from"./HashBadge-aS_UIcg2.js";import{C as X}from"./ConfirmModal-DYznouaT.js";import{P as B,b as U,a as G,c as W}from"./PageLayout-DE5PEtD2.js";import{R as Z,C as J}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const Q=e.memo(function({showLogoOnly:s=!1,showThumbnailsOnly:a=!1}){const{theme:r,setThemePreset:n,setBrightness:l}=S(),{backgroundImage:c,brightness:i}=r,[d,o]=e.useState(!1),[u,m]=e.useState(!1),x=e.useRef(null),p=e.useRef(null),h=T.find(e=>e.backgroundImage===c)??T[0],b=h.id,y=e.useCallback((e,t)=>{if(!p.current)return i;const s=(p.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,p.current.brightness+s)))},[i]),g=e.useCallback(e=>{n(e),o(!0)},[n]),f=e.useCallback(e=>{l(e)},[l]),j=e.useCallback(e=>{const t=T.find(t=>t.id===e);t&&F(t.backgroundImage)},[]);if(s){const e=h.displaySize,s=`clamp(${.8*e}rem, ${.6*e}rem + 1.5vw, ${1.4*e}rem)`;return t.jsx("span",{className:"font-medium transition-all duration-300 leading-none",style:{fontFamily:h.displayFont,color:h.displayColor,fontSize:s,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:h.displayName})}return t.jsx("div",{className:"flex gap-2 items-start flex-shrink-0",children:T.map(e=>{const s=b===e.id,a=s&&(d||u);return t.jsxs("div",{ref:s?x:void 0,title:e.displayName,className:_("flex flex-col items-center gap-1 p-0.5 rounded-sm transition-all duration-300 ease-out",s?"ring-2 ring-accent-primary scale-105 cursor-ns-resize":"cursor-pointer"),onMouseEnter:()=>{s?o(!0):j(e.id)},onMouseLeave:()=>!u&&o(!1),onClick:()=>!s&&g(e.id),onTouchStart:e=>{if(!s)return;e.preventDefault();const t=e.touches[0];p.current={y:t.clientY,brightness:i},m(!0),o(!0);const a=e=>{e.preventDefault();const t=e.touches[0];f(y(t.clientY,!0))},r=()=>{document.removeEventListener("touchmove",a),document.removeEventListener("touchend",r),p.current=null,m(!1),setTimeout(()=>o(!1),1500)};document.addEventListener("touchmove",a,{passive:!1}),document.addEventListener("touchend",r)},onMouseDown:e=>{if(!s)return;e.preventDefault(),p.current={y:e.clientY,brightness:i},m(!0),o(!0);const t=e=>{f(y(e.clientY,!1))},a=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",a),p.current=null,m(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",a)},children:[t.jsxs("div",{className:"glass-thumbnail w-10 h-10",children:[t.jsx("div",{className:"absolute bg-cover bg-center transition-opacity duration-200",style:{inset:0,backgroundImage:`url(${e.backgroundImage})`,opacity:a?.4:1}}),s&&t.jsxs("div",{className:_("absolute inset-0 transition-opacity duration-200",a?"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-i+"%"}}),t.jsx("div",{className:"absolute inset-x-1 h-0.5 bg-white rounded-full shadow-lg transition-all duration-100 ease-out",style:{top:100-i+"%"}}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsxs("span",{className:"text-[10px] font-mono font-bold text-white drop-shadow-lg",children:[i,"%"]})})]})]}),t.jsx("div",{className:"flex flex-col gap-0.5",children:e.paletteColors.map((e,s)=>t.jsx("div",{className:"flex gap-0.5 justify-center",children:e.map((e,s)=>t.jsx("div",{className:"w-1.5 h-1.5 rounded-xs",style:{backgroundColor:e}},s))},s))})]},e.id)})})}),ee=[{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"}],te=[5,6,7,8,9,10,11,12],se=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],ae="radioConfig",re="repeaterSettings",ne="operatingMode";function le({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c}){const i=a.has(e.id),d=r===e.id,o=e.children&&e.children.length>0,u="allow"===n;return t.jsxs("div",{children:[t.jsxs("div",{className:_("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",d?"bg-accent-primary/15":"hover:bg-white/[0.02]",u&&"opacity-50 cursor-not-allowed"),style:{marginLeft:16*s+"px"},onClick:()=>!u&&l(e.id),children:[o?t.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"p-1 hover:bg-white/[0.05] rounded-full transition-colors",children:t.jsx(k,{className:_("w-3.5 h-3.5 text-text-muted transition-transform",i&&"rotate-90")})}):t.jsx("span",{className:"w-5"}),t.jsx(C,{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"})]}),o&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(le,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c},e.id))})]})}function ce(){var k,C,S,T,F,ce;const{stats:ie,setMode:de,clearModeMutation:oe,setDutyCycleConfig:ue,clearDutyCycleMutation:me,fetchStats:xe,startMutation:pe,clearMutation:he}=E(),be=null==(k=null==ie?void 0:ie.config)?void 0:k.radio,ye=null==(C=null==ie?void 0:ie.config)?void 0:C.repeater,ge=null==(S=null==ie?void 0:ie.config)?void 0:S.duty_cycle,fe=(null==ie?void 0:ie.node_name)||(null==(T=null==ie?void 0:ie.config)?void 0:T.node_name)||"Unknown Node",je=(null==ye?void 0:ye.mode)??"forward",ve=(null==ge?void 0:ge.enforcement_enabled)??!1,Ne=null==(F=null==ie?void 0:ie.config)?void 0:F.delays,[we,ke]=e.useState(!1),[Ce,_e]=e.useState(""),[Se,Te]=e.useState(62.5),[Fe,Ee]=e.useState(7),[Le,Pe]=e.useState(5),[Re,Ie]=e.useState(""),[Ae,Me]=e.useState("idle"),[De,ze]=e.useState(null),Ke=e.useRef(null),Oe=e.useRef(null),[qe,He]=e.useState(!1),[$e,Ye]=e.useState(""),[Ve,Xe]=e.useState(""),[Be,Ue]=e.useState(""),[Ge,We]=e.useState("idle"),Ze=e.useRef(null),Je=e.useRef(null),[Qe,et]=e.useState(!1),[tt,st]=e.useState(""),[at,rt]=e.useState(""),[nt,lt]=e.useState(""),[ct,it]=e.useState(""),[dt,ot]=e.useState("idle"),[ut,mt]=e.useState(null),xt=e.useRef(null),pt=e.useRef(null),[ht,bt]=e.useState("idle"),[yt,gt]=e.useState("idle"),[ft,jt]=e.useState(null),[vt,Nt]=e.useState(null),wt=e.useRef(!0),kt=e.useRef(null),Ct=e.useRef(null),_t=e.useRef(null),St=e.useRef(null),Tt=e.useRef(!1),Ft=e.useRef(!1);e.useEffect(()=>(wt.current=!0,()=>{wt.current=!1,kt.current&&clearTimeout(kt.current),Ct.current&&clearTimeout(Ct.current),_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),At.current&&clearTimeout(At.current),Mt.current&&clearTimeout(Mt.current),Oe.current&&clearTimeout(Oe.current),Ze.current&&clearTimeout(Ze.current),pt.current&&clearTimeout(pt.current)}),[]),e.useEffect(()=>{const e=e=>{if(we||Qe||qe)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)},[we,Qe,qe]);const Et=null==(ce=null==ie?void 0:ie.config)?void 0:ce.web,[Lt,Pt]=e.useState("idle"),[Rt,It]=e.useState(null),At=e.useRef(null),Mt=e.useRef(null),Dt=e.useRef(!1),[zt,Kt]=e.useState([]),[Ot,qt]=e.useState(!1),[Ht,$t]=e.useState(null),[Yt,Vt]=e.useState(!1),[Xt,Bt]=e.useState(""),[Ut,Gt]=e.useState(null),[Wt,Zt]=e.useState(!1),[Jt,Qt]=e.useState(null),[es,ts]=e.useState(!1),[ss,as]=e.useState(!1),[rs,ns]=e.useState(!1),[ls,cs]=e.useState([]),[is,ds]=e.useState(!1),[os,us]=e.useState(null),[ms,xs]=e.useState("deny"),[ps,hs]=e.useState(!1),[bs,ys]=e.useState(null),[gs,fs]=e.useState(new Set),[js,vs]=e.useState(!1),[Ns,ws]=e.useState(!1),[ks,Cs]=e.useState(!1),[_s,Ss]=e.useState(null),[Ts,Fs]=e.useState(null),[Es,Ls]=e.useState(""),[Ps,Rs]=e.useState("deny"),[Is,As]=e.useState(!1),[Ms,Ds]=e.useState(!0),[zs,Ks]=e.useState(!1),[Os,qs]=e.useState(!0),[Hs,$s]=e.useState("idle"),[Ys,Vs]=e.useState(!1),[Xs,Bs]=e.useState(!1),Us=e.useRef(!1);e.useEffect(()=>{const e=we&&!Us.current;Us.current=we,be&&e&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power)))},[be,we]);const Gs=e.useMemo(()=>{if(!be||!we)return!1;const e=be.frequency/1e6,t=be.bandwidth/1e3,s=parseFloat(Ce)||0;return Math.abs(s-e)>1e-4||Se!==t||Fe!==be.spreading_factor||Le!==be.coding_rate||parseInt(Re)!==be.tx_power},[be,we,Ce,Se,Fe,Le,Re]),Ws=e.useCallback(()=>{ke(!1),ze(null),be&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power)))},[be]);e.useEffect(()=>{if(!we)return;const e=e=>{"loading"!==Ae&&Ke.current&&!Ke.current.contains(e.target)&&Ws()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[we,Ws,Ae]);const Zs=e.useCallback(()=>{const e=null==Ne?void 0:Ne.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[Ne]),Js=e.useCallback(()=>{const e=null==Ne?void 0:Ne.direct_tx_delay_factor;return"number"==typeof e?e:.5},[Ne]),Qs=e.useCallback(()=>{const e=null==ge?void 0:ge.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[ge]),ea=e.useCallback(()=>{Ye(Zs().toFixed(2)),Xe(Js().toFixed(2)),Ue(Qs().toFixed(1)),He(!0)},[Zs,Js,Qs]),ta=e.useCallback(()=>{He(!1)},[]);e.useEffect(()=>{if(!qe)return;const e=e=>{"loading"!==Ge&&Je.current&&!Je.current.contains(e.target)&&ta()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[qe,ta,Ge]);const sa=e.useCallback(()=>{var e,t,s;st(fe),rt((null==(e=null==ye?void 0:ye.latitude)?void 0:e.toString())||"0"),lt((null==(t=null==ye?void 0:ye.longitude)?void 0:t.toString())||"0"),it((null==(s=null==ye?void 0:ye.send_advert_interval_hours)?void 0:s.toString())||"0"),mt(null),et(!0)},[fe,ye]),aa=e.useCallback(()=>{et(!1),mt(null)},[]);e.useEffect(()=>{if(!Qe)return;const e=e=>{"loading"!==dt&&xt.current&&!xt.current.contains(e.target)&&aa()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Qe,aa,dt]);const ra=async()=>{var e;if("loading"===Lt)return;const t=(null==Et?void 0:Et.cors_enabled)??!1,s=!t,a=t;At.current&&clearTimeout(At.current),Mt.current&&clearTimeout(Mt.current),Dt.current=!1,It(s),Pt("loading"),At.current=setTimeout(()=>{Dt.current||wt.current&&(It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3))},1e4);try{const t=await M({web:{cors_enabled:s}});if(Dt.current=!0,At.current&&clearTimeout(At.current),!wt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await xe(),Pt("success"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3)):(It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3))}catch{if(Dt.current=!0,At.current&&clearTimeout(At.current),!wt.current)return;It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3)}};e.useEffect(()=>{(async()=>{qs(!0);try{const e=await D();e.success&&e.data?Ks(e.data.exists):Ks(!1);const t=null==Et?void 0:Et.web_path;Ds(!t||""===t)}catch{Ks(!1)}finally{qs(!1)}})()},[null==Et?void 0:Et.web_path]);const na=async e=>{var t;if("loading"!==Hs){$s("loading");try{const s=await M({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!wt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Ds(e),$s("success"),Vs(!0),setTimeout(()=>{wt.current&&$s("idle")},2e3)):($s("error"),setTimeout(()=>{wt.current&&$s("idle")},2e3))}catch{if(!wt.current)return;$s("error"),setTimeout(()=>{wt.current&&$s("idle")},2e3)}}},la=e.useCallback(async()=>{qt(!0),$t(null);try{const e=await L();Kt(e.tokens||[])}catch(e){$t(e instanceof Error?e.message:"Failed to fetch tokens")}finally{qt(!1)}},[]);e.useEffect(()=>{la()},[la]);const ca=async()=>{if(Xt.trim()){ts(!0),$t(null);try{const e=await K(Xt.trim());Gt(e.token||null),Vt(!1),Zt(!0),Bt(""),await la()}catch(e){$t(e instanceof Error?e.message:"Failed to create token")}finally{ts(!1)}}else $t("Token name is required")},ia=e=>e?new Date(1e3*e).toLocaleString():"Never",da=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},[]),oa=e.useCallback(async()=>{ds(!0),us(null);try{const e=await P();e.success&&e.data?cs(da(e.data)):us(e.error||"Failed to load transport keys")}catch(e){us(e instanceof Error?e.message:"Unknown error occurred")}finally{ds(!1)}},[da]);e.useEffect(()=>{oa()},[oa]);const ua=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=ua(s.children,t);if(e)return e}}return null},[]),ma=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);return null==e?void 0:e.name},[bs,ls,ua]),xa=e.useCallback(e=>{fs(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),pa=async e=>{hs(!0),us(null);try{const t=await q("allow"===e);t.success?xs(e):us(t.error||"Failed to update global flood policy")}catch(t){us(t instanceof Error?t.message:"Failed to update global flood policy")}finally{hs(!1)}},ha=async()=>{if(Es.trim()){As(!0),us(null);try{const e=await H({name:Es.trim(),flood_policy:Ps,parent_id:bs??void 0});e.success?(await oa(),vs(!1),Ls(""),Rs("deny")):us(e.error||"Failed to add transport key")}catch(e){us(e instanceof Error?e.message:"Failed to add transport key")}finally{As(!1)}}else us("Key name is required")},ba=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);e&&(Ss({...e}),ws(!0))},[bs,ls,ua]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(js&&(vs(!1),Ls(""),Rs("deny")),Ns&&(ws(!1),Ss(null)),ks&&(Cs(!1),Fs(null)),Yt&&(Vt(!1),Bt("")),Wt&&(Zt(!1),Gt(null)))};if(js||Ns||ks||Yt||Wt)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[js,Ns,ks,Yt,Wt]);const ya=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);e&&(Fs(e),Cs(!0))},[bs,ls,ua]);return t.jsxs(B,{children:[t.jsx(U,{title:"Configuration",icon:t.jsx(s,{})}),t.jsxs(Z,{template:"standard",children:[t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:xt,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(a,{className:"icon-md text-accent-primary"}),"Repeater Settings"]}),t.jsx("div",{className:"flex items-center gap-1",children:ye&&(Qe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:aa,disabled:"loading"===dt,className:_("p-2 rounded-lg transition-colors","loading"===dt?"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"!==dt){pt.current&&clearTimeout(pt.current),pe(re),ot("loading"),mt(null);try{const e={};tt&&tt!==fe&&(e.node_name=tt);const t=parseFloat(at);isNaN(t)||t===(null==ye?void 0:ye.latitude)||(e.latitude=t);const s=parseFloat(nt);isNaN(s)||s===(null==ye?void 0:ye.longitude)||(e.longitude=s);const a=parseInt(ct);if(isNaN(a)||a===(null==ye?void 0:ye.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return mt({success:!0,message:"No changes to save"}),ot("idle"),void he(re);const r=await A(e);if(!wt.current)return void he(re);if(r.success&&r.data){const e=r.data.applied.join(", ");mt({success:!0,message:`Updated: ${e}`}),await xe({force:!0}),ot("success"),pt.current=setTimeout(()=>{wt.current&&(ot("idle"),et(!1),mt(null),he(re))},1500)}else mt({success:!1,message:r.error||"Failed to save"}),ot("error"),he(re),pt.current=setTimeout(()=>{wt.current&&ot("idle")},2e3)}catch(e){if(!wt.current)return void he(re);mt({success:!1,message:String(e)}),ot("error"),he(re),pt.current=setTimeout(()=>{wt.current&&ot("idle")},2e3)}}},disabled:"loading"===dt,className:_("p-2 rounded-lg transition-colors","loading"===dt?"text-accent-primary cursor-wait":"success"===dt?"text-accent-success":"error"===dt?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===dt?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===dt?t.jsx(l,{className:"w-4 h-4"}):"error"===dt?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:sa,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"})}))})]}),ut&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",ut.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:ut.message}),ye?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",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"text",value:tt,onChange:e=>st(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:fe})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:at,onChange:e=>rt(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!==ye.latitude?ye.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:nt,onChange:e=>lt(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!==ye.longitude?ye.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:ct,onChange:e=>it(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:ye.send_advert_interval_hours>0?`${ye.send_advert_interval_hours}h`:"Disabled"})}),Qe&&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-white/[0.02]",children:t.jsx("span",{className:"type-data text-text-primary",children:ye.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:Ke,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(i,{className:"icon-md text-accent-primary"}),"Radio Configuration"]}),t.jsx("div",{className:"flex items-center gap-1",children:be&&(we?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Ws,disabled:"loading"===Ae,className:_("p-2 rounded-lg transition-colors","loading"===Ae?"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"!==Ae){Oe.current&&clearTimeout(Oe.current),pe(ae),Me("loading"),ze(null);try{const e={},t=parseFloat(Ce),s=be?be.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=be?be.bandwidth/1e3:0;Se!==a&&(e.bandwidth_khz=Se),Fe!==(null==be?void 0:be.spreading_factor)&&(e.spreading_factor=Fe),Le!==(null==be?void 0:be.coding_rate)&&(e.coding_rate=Le);const r=parseInt(Re);if(r!==(null==be?void 0:be.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return ze({success:!0,message:"No changes to save"}),Me("idle"),void he(ae);const n=await A(e);if(!wt.current)return void he(ae);if(n.success&&n.data){const e=n.data.applied.join(", "),t=n.data.live_update?" (applied live)":" (restart required)";ze({success:!0,message:`Updated: ${e}${t}`}),await xe({force:!0}),Me("success"),Oe.current=setTimeout(()=>{wt.current&&(Me("idle"),ke(!1),ze(null),he(ae))},1500)}else ze({success:!1,message:n.error||"Failed to save"}),Me("error"),he(ae),Oe.current=setTimeout(()=>{wt.current&&Me("idle")},2e3)}catch(e){if(!wt.current)return void he(ae);ze({success:!1,message:String(e)}),Me("error"),he(ae),Oe.current=setTimeout(()=>{wt.current&&Me("idle")},2e3)}}},disabled:"loading"===Ae||!Gs,className:_("p-2 rounded-lg transition-colors","loading"===Ae?"text-accent-primary cursor-wait":"success"===Ae?"text-accent-success":"error"===Ae?"text-accent-danger":Gs?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:Gs?"Save changes":"No changes to save",children:"loading"===Ae?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ae?t.jsx(l,{className:"w-4 h-4"}):"error"===Ae?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{be&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power))),ze(null),ke(!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"})}))})]}),De&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",De.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:De.message}),be?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:we?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsx("input",{type:"number",value:Ce,onChange:e=>_e(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:R(be.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:we?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsx("input",{type:"number",value:Re,onChange:e=>Ie(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:[be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Se,onChange:e=>Te(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:ee.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(d,{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(be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Fe,onChange:e=>Ee(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:te.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(d,{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",be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Le,onChange:e=>Pe(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:se.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(d,{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/",be.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-white/[0.02]",children:t.jsxs("span",{className:"type-data text-text-primary",children:[be.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(Z,{template:"standard",children:[t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:Je,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(o,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:qe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==Ge){Ze.current&&clearTimeout(Ze.current),pe(ne),We("loading");try{const e=await A({tx_delay_factor:parseFloat($e),direct_tx_delay_factor:parseFloat(Ve)});if(await ue({max_airtime_percent:parseFloat(Be),enforcement_enabled:ve}),!wt.current)return void he(ne);e.success&&e.data?(await xe({force:!0}),We("success"),Ze.current=setTimeout(()=>{wt.current&&(We("idle"),He(!1),he(ne))},1500)):(We("error"),he(ne),Ze.current=setTimeout(()=>{wt.current&&We("idle")},2e3))}catch{if(!wt.current)return void he(ne);We("error"),he(ne),Ze.current=setTimeout(()=>{wt.current&&We("idle")},2e3)}}},disabled:"loading"===Ge,className:_("p-2 rounded-lg transition-colors","loading"===Ge?"text-accent-primary cursor-wait":"success"===Ge?"text-accent-success":"error"===Ge?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===Ge?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ge?t.jsx(l,{className:"w-4 h-4"}):"error"===Ge?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})}),t.jsx("button",{onClick:ta,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:ea,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!==ft?ft:"forward"===je;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ht)return;const t=!e,s="forward"===je;kt.current&&clearTimeout(kt.current),Ct.current&&clearTimeout(Ct.current),Tt.current=!1,jt(t),bt("loading"),kt.current=setTimeout(()=>{Tt.current||wt.current&&(jt(s),bt("error"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null))},2e3))},1e4);try{if(await de(t?"forward":"monitor"),Tt.current=!0,kt.current&&clearTimeout(kt.current),!wt.current)return;bt("success"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null),oe())},2e3)}catch{if(Tt.current=!0,kt.current&&clearTimeout(kt.current),!wt.current)return;jt(s),bt("error"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null))},2e3)}},disabled:"loading"===ht,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"===ht&&"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"===ht&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ht&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===ht&&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!==vt?vt:ve;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===yt)return;const t=!e,s=ve;_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Ft.current=!1,Nt(t),gt("loading"),_t.current=setTimeout(()=>{Ft.current||wt.current&&(Nt(s),gt("error"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null))},2e3))},1e4);try{if(await ue({max_airtime_percent:Qs(),enforcement_enabled:t}),Ft.current=!0,_t.current&&clearTimeout(_t.current),!wt.current)return;gt("success"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null),me())},2e3)}catch{if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!wt.current)return;Nt(s),gt("error"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null))},2e3)}},disabled:"loading"===yt,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"===yt&&"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"===yt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===yt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===yt&&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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Be,onChange:e=>Ue(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:[Qs().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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:$e,onChange:e=>Ye(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:[Zs().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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ve,onChange:e=>Xe(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:[Js().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx(J,{span:12,md:6,children:t.jsxs(G,{children:[t.jsx(W,{icon:t.jsx(s,{}),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!==Rt?Rt:(null==Et?void 0:Et.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:ra,disabled:"loading"===Lt,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"===Lt&&"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"===Lt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===Lt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===Lt&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-body text-text-primary font-medium block mb-2",children:"Theme"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Q,{showLogoOnly:!0})}),t.jsx("div",{className:"flex-shrink-0",children:t.jsx(Q,{showThumbnailsOnly:!0})})]})]})]})]})})]}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{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(u,{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:()=>vs(!0),disabled:"allow"===ms,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===ms?"bg-white/[0.02] text-text-muted cursor-not-allowed":"bg-accent-success/10 hover:bg-accent-success/20 text-accent-success"),children:[t.jsx(m,{className:"w-3.5 h-3.5"}),"Add"]}),t.jsx("button",{onClick:ba,disabled:!bs||"allow"===ms,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",bs&&"allow"!==ms?"bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary":"bg-white/[0.02] text-text-muted cursor-not-allowed"),children:"Edit"}),t.jsx("button",{onClick:ya,disabled:!bs||"allow"===ms,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",bs&&"allow"!==ms?"bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger":"bg-white/[0.02] text-text-muted cursor-not-allowed"),children:"Delete"})]})]}),t.jsx("div",{className:"bg-white/[0.02] 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"===ms?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===ms?t.jsx(x,{className:"w-5 h-5 text-accent-success"}):t.jsx(p,{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-white/[0.02] rounded-full p-1",children:[t.jsx("button",{onClick:()=>pa("deny"),disabled:ps,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===ms?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ps&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>pa("allow"),disabled:ps,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===ms?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ps&&"opacity-50"),children:"Allow"})]}),ps&&t.jsx(n,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),os&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:os}),t.jsx("div",{className:"bg-white/[0.02] rounded-2xl p-4 min-h-[120px]",children:is?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(n,{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===ls.length?t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-white/[0.02] mx-auto mb-3 flex items-center justify-center",children:t.jsx(u,{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:ls.map(e=>t.jsx(le,{node:e,level:0,expandedKeys:gs,selectedKeyId:bs,globalFloodPolicy:ms,onSelect:ys,onToggle:xa},e.id))})})]})}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{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(h,{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:()=>Vt(!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(m,{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(b,{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."})]})]})}),Ht&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Ht}),Ot&&0===zt.length?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(n,{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..."})]}):zt.length>0?t.jsx("div",{className:"space-y-2",children:zt.map(e=>t.jsx("div",{className:"bg-white/[0.02] hover:bg-white/[0.04] 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(h,{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: ",ia(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",ia(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Qt({id:e.id,name:e.name}),disabled:ss,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(y,{className:"w-3.5 h-3.5"}),"Revoke"]})]})},e.id))}):t.jsxs("div",{className:"bg-white/[0.02] rounded-2xl p-6 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-white/[0.02] mx-auto mb-4 flex items-center justify-center",children:t.jsx(h,{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:()=>Vt(!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(Z,{template:"auto",children:t.jsxs(G,{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(g,{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-white/[0.02] rounded-2xl border-2 cursor-pointer transition-all",Ms?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Hs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ms,onChange:()=>na(!0),disabled:"loading"===Hs,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-white/[0.02] rounded-2xl border-2 cursor-pointer transition-all",Ms?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Hs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ms,onChange:()=>na(!1),disabled:"loading"===Hs,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"})]})]})]}),!Os&&t.jsx("div",{className:_("bg-white/[0.02] rounded-2xl p-4",zs?"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",zs?"bg-accent-success/20":"bg-accent-tertiary/20"),children:zs?t.jsx(f,{className:"w-4 h-4 text-accent-success"}):t.jsx(b,{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:zs?"PyMC Console has been detected":"PyMC Console Not Installed"}),zs?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(j,{className:"w-4 h-4"}),"PyMC Console Install Instructions"]})]})]})]})}),Ys&&t.jsx("div",{className:"bg-white/[0.02] 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(v,{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(!Xs){Bs(!0);try{await z(),Vs(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Vs(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:Xs,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:Xs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Restarting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(N,{className:"w-4 h-4"}),"Restart Now"]})})]})})]})]})}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{children:[t.jsx(W,{icon:t.jsx(o,{}),title:"Node Information",largeTitle:!0}),ie?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Node Name"}),t.jsx("p",{className:"type-body text-text-primary mt-1",children:fe})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Version"}),t.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",ie.version]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Core Version"}),t.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",ie.core_version]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Local Hash"}),t.jsx("div",{className:"mt-1",children:ie.local_hash?t.jsx(V,{hash:ie.local_hash,size:"sm"}):t.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),ie.public_key&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Public Key"}),t.jsx("div",{className:"mt-1",children:t.jsx(V,{hash:ie.public_key,prefixLength:12,suffixLength:8})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading node information..."})]})}),Yt&&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&&Vt(!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:Xt,onChange:e=>Bt(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&&ca(),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:()=>{Vt(!1),Bt(""),$t(null)},disabled:es,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:es||!Xt.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:es?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),Wt&&Ut&&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&&Zt(!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(v,{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:Ut,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:()=>{Ut&&(navigator.clipboard.writeText(Ut),ns(!0),setTimeout(()=>ns(!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:[rs?t.jsx(l,{className:"w-4 h-4 text-accent-success"}):t.jsx(w,{className:"w-4 h-4"}),rs?"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: ',Ut.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{Zt(!1),Gt(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(X,{isOpen:!!Jt,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Jt?void 0:Jt.name}'? This action cannot be undone.`,confirmLabel:ss?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Jt){as(!0),$t(null);try{await O(Jt.id),await la(),Qt(null)}catch(e){$t(e instanceof Error?e.message:"Failed to revoke token")}finally{as(!1)}}},onCancel:()=>Qt(null)}),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&&vs(!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:[bs&&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:ma()})]}),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:Es,onChange:e=>Ls(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&&ha(),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:()=>Rs("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===Ps?"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:()=>Rs("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===Ps?"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:()=>{vs(!1),Ls(""),Rs("deny")},disabled:Is,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:ha,disabled:Is||!Es.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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),Ns&&_s&&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&&ws(!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:_s.name,onChange:e=>Ss({..._s,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:()=>Ss({..._s,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===_s.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:()=>Ss({..._s,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===_s.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),_s.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:_s.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{ws(!1),Fs(_s),Cs(!0),Ss(null)},disabled:Is,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:()=>{ws(!1),Ss(null)},disabled:Is,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(_s){As(!0),us(null);try{const e=await $(_s.id,{name:_s.name,flood_policy:_s.floodPolicy});e.success?(await oa(),ws(!1),Ss(null)):us(e.error||"Failed to update transport key")}catch(e){us(e instanceof Error?e.message:"Failed to update transport key")}finally{As(!1)}}},disabled:Is||!_s.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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),ks&&Ts&&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&&Cs(!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:["'",Ts.name,"'"]}),"?"]}),Ts.children&&Ts.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(v,{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 ",Ts.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:()=>{Cs(!1),Fs(null)},disabled:Is,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(Ts){As(!0),us(null);try{const e=await Y(Ts.id);e.success?(await oa(),Cs(!1),Fs(null),ys(null)):us(e.error||"Failed to delete transport key")}catch(e){us(e instanceof Error?e.message:"Failed to delete transport key")}finally{As(!1)}}},disabled:Is,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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ce as default}; +import{r as e,j as t,f as s,i as a,X as r,at as n,aa as l,aX as c,aY as i,k as d,p as o,aZ as u,af as m,a_ as x,a$ as p,b0 as h,aP as b,av as y,b1 as g,aj as f,b2 as j,a7 as v,a2 as N,$ as w,a9 as k,b3 as C}from"./vendor-react-O8XH9yVn.js";import{c as _}from"./recharts-BU7auunF.js";import{ad as S,ae as T,af as F,I as E,ag as L,ah as P,ai as R,aj as I,ac as A,ak as M,al as D,am as z,an as K,ao as O,ap as q,aq as H,ar as $,as as Y}from"./index-DGrzd8xb.js";import{H as V}from"./HashBadge-aS_UIcg2.js";import{C as X}from"./ConfirmModal-DYznouaT.js";import{P as B,b as U,a as G,c as W}from"./PageLayout-DE5PEtD2.js";import{R as Z,C as J}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const Q=e.memo(function({showLogoOnly:s=!1,showThumbnailsOnly:a=!1}){const{theme:r,setThemePreset:n,setBrightness:l}=S(),{backgroundImage:c,brightness:i}=r,[d,o]=e.useState(!1),[u,m]=e.useState(!1),x=e.useRef(null),p=e.useRef(null),h=T.find(e=>e.backgroundImage===c)??T[0],b=h.id,y=e.useCallback((e,t)=>{if(!p.current)return i;const s=(p.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,p.current.brightness+s)))},[i]),g=e.useCallback(e=>{n(e),o(!0)},[n]),f=e.useCallback(e=>{l(e)},[l]),j=e.useCallback(e=>{const t=T.find(t=>t.id===e);t&&F(t.backgroundImage)},[]);if(s){const e=h.displaySize,s=`clamp(${.8*e}rem, ${.6*e}rem + 1.5vw, ${1.4*e}rem)`;return t.jsx("span",{className:"font-medium transition-all duration-300 leading-none",style:{fontFamily:h.displayFont,color:h.displayColor,fontSize:s,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:h.displayName})}return t.jsx("div",{className:"flex gap-2 items-start flex-shrink-0",children:T.map(e=>{const s=b===e.id,a=s&&(d||u);return t.jsxs("div",{ref:s?x:void 0,title:e.displayName,className:_("flex flex-col items-center gap-1 p-0.5 rounded-sm transition-all duration-300 ease-out",s?"ring-2 ring-accent-primary scale-105 cursor-ns-resize":"cursor-pointer"),onMouseEnter:()=>{s?o(!0):j(e.id)},onMouseLeave:()=>!u&&o(!1),onClick:()=>!s&&g(e.id),onTouchStart:e=>{if(!s)return;e.preventDefault();const t=e.touches[0];p.current={y:t.clientY,brightness:i},m(!0),o(!0);const a=e=>{e.preventDefault();const t=e.touches[0];f(y(t.clientY,!0))},r=()=>{document.removeEventListener("touchmove",a),document.removeEventListener("touchend",r),p.current=null,m(!1),setTimeout(()=>o(!1),1500)};document.addEventListener("touchmove",a,{passive:!1}),document.addEventListener("touchend",r)},onMouseDown:e=>{if(!s)return;e.preventDefault(),p.current={y:e.clientY,brightness:i},m(!0),o(!0);const t=e=>{f(y(e.clientY,!1))},a=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",a),p.current=null,m(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",a)},children:[t.jsxs("div",{className:"glass-thumbnail w-10 h-10",children:[t.jsx("div",{className:"absolute bg-cover bg-center transition-opacity duration-200",style:{inset:0,backgroundImage:`url(${e.backgroundImage})`,opacity:a?.4:1}}),s&&t.jsxs("div",{className:_("absolute inset-0 transition-opacity duration-200",a?"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-i+"%"}}),t.jsx("div",{className:"absolute inset-x-1 h-0.5 bg-white rounded-full shadow-lg transition-all duration-100 ease-out",style:{top:100-i+"%"}}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsxs("span",{className:"text-[10px] font-mono font-bold text-white drop-shadow-lg",children:[i,"%"]})})]})]}),t.jsx("div",{className:"flex flex-col gap-0.5",children:e.paletteColors.map((e,s)=>t.jsx("div",{className:"flex gap-0.5 justify-center",children:e.map((e,s)=>t.jsx("div",{className:"w-1.5 h-1.5 rounded-xs",style:{backgroundColor:e}},s))},s))})]},e.id)})})}),ee=[{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"}],te=[5,6,7,8,9,10,11,12],se=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],ae="radioConfig",re="repeaterSettings",ne="operatingMode";function le({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c}){const i=a.has(e.id),d=r===e.id,o=e.children&&e.children.length>0,u="allow"===n;return t.jsxs("div",{children:[t.jsxs("div",{className:_("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",d?"bg-accent-primary/15":"hover:bg-white/[0.02]",u&&"opacity-50 cursor-not-allowed"),style:{marginLeft:16*s+"px"},onClick:()=>!u&&l(e.id),children:[o?t.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"p-1 hover:bg-white/[0.05] rounded-full transition-colors",children:t.jsx(k,{className:_("w-3.5 h-3.5 text-text-muted transition-transform",i&&"rotate-90")})}):t.jsx("span",{className:"w-5"}),t.jsx(C,{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"})]}),o&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(le,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c},e.id))})]})}function ce(){var k,C,S,T,F,ce;const{stats:ie,setMode:de,clearModeMutation:oe,setDutyCycleConfig:ue,clearDutyCycleMutation:me,fetchStats:xe,startMutation:pe,clearMutation:he}=E(),be=null==(k=null==ie?void 0:ie.config)?void 0:k.radio,ye=null==(C=null==ie?void 0:ie.config)?void 0:C.repeater,ge=null==(S=null==ie?void 0:ie.config)?void 0:S.duty_cycle,fe=(null==ie?void 0:ie.node_name)||(null==(T=null==ie?void 0:ie.config)?void 0:T.node_name)||"Unknown Node",je=(null==ye?void 0:ye.mode)??"forward",ve=(null==ge?void 0:ge.enforcement_enabled)??!1,Ne=null==(F=null==ie?void 0:ie.config)?void 0:F.delays,[we,ke]=e.useState(!1),[Ce,_e]=e.useState(""),[Se,Te]=e.useState(62.5),[Fe,Ee]=e.useState(7),[Le,Pe]=e.useState(5),[Re,Ie]=e.useState(""),[Ae,Me]=e.useState("idle"),[De,ze]=e.useState(null),Ke=e.useRef(null),Oe=e.useRef(null),[qe,He]=e.useState(!1),[$e,Ye]=e.useState(""),[Ve,Xe]=e.useState(""),[Be,Ue]=e.useState(""),[Ge,We]=e.useState("idle"),Ze=e.useRef(null),Je=e.useRef(null),[Qe,et]=e.useState(!1),[tt,st]=e.useState(""),[at,rt]=e.useState(""),[nt,lt]=e.useState(""),[ct,it]=e.useState(""),[dt,ot]=e.useState("idle"),[ut,mt]=e.useState(null),xt=e.useRef(null),pt=e.useRef(null),[ht,bt]=e.useState("idle"),[yt,gt]=e.useState("idle"),[ft,jt]=e.useState(null),[vt,Nt]=e.useState(null),wt=e.useRef(!0),kt=e.useRef(null),Ct=e.useRef(null),_t=e.useRef(null),St=e.useRef(null),Tt=e.useRef(!1),Ft=e.useRef(!1);e.useEffect(()=>(wt.current=!0,()=>{wt.current=!1,kt.current&&clearTimeout(kt.current),Ct.current&&clearTimeout(Ct.current),_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),At.current&&clearTimeout(At.current),Mt.current&&clearTimeout(Mt.current),Oe.current&&clearTimeout(Oe.current),Ze.current&&clearTimeout(Ze.current),pt.current&&clearTimeout(pt.current)}),[]),e.useEffect(()=>{const e=e=>{if(we||Qe||qe)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)},[we,Qe,qe]);const Et=null==(ce=null==ie?void 0:ie.config)?void 0:ce.web,[Lt,Pt]=e.useState("idle"),[Rt,It]=e.useState(null),At=e.useRef(null),Mt=e.useRef(null),Dt=e.useRef(!1),[zt,Kt]=e.useState([]),[Ot,qt]=e.useState(!1),[Ht,$t]=e.useState(null),[Yt,Vt]=e.useState(!1),[Xt,Bt]=e.useState(""),[Ut,Gt]=e.useState(null),[Wt,Zt]=e.useState(!1),[Jt,Qt]=e.useState(null),[es,ts]=e.useState(!1),[ss,as]=e.useState(!1),[rs,ns]=e.useState(!1),[ls,cs]=e.useState([]),[is,ds]=e.useState(!1),[os,us]=e.useState(null),[ms,xs]=e.useState("deny"),[ps,hs]=e.useState(!1),[bs,ys]=e.useState(null),[gs,fs]=e.useState(new Set),[js,vs]=e.useState(!1),[Ns,ws]=e.useState(!1),[ks,Cs]=e.useState(!1),[_s,Ss]=e.useState(null),[Ts,Fs]=e.useState(null),[Es,Ls]=e.useState(""),[Ps,Rs]=e.useState("deny"),[Is,As]=e.useState(!1),[Ms,Ds]=e.useState(!0),[zs,Ks]=e.useState(!1),[Os,qs]=e.useState(!0),[Hs,$s]=e.useState("idle"),[Ys,Vs]=e.useState(!1),[Xs,Bs]=e.useState(!1),Us=e.useRef(!1);e.useEffect(()=>{const e=we&&!Us.current;Us.current=we,be&&e&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power)))},[be,we]);const Gs=e.useMemo(()=>{if(!be||!we)return!1;const e=be.frequency/1e6,t=be.bandwidth/1e3,s=parseFloat(Ce)||0;return Math.abs(s-e)>1e-4||Se!==t||Fe!==be.spreading_factor||Le!==be.coding_rate||parseInt(Re)!==be.tx_power},[be,we,Ce,Se,Fe,Le,Re]),Ws=e.useCallback(()=>{ke(!1),ze(null),be&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power)))},[be]);e.useEffect(()=>{if(!we)return;const e=e=>{"loading"!==Ae&&Ke.current&&!Ke.current.contains(e.target)&&Ws()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[we,Ws,Ae]);const Zs=e.useCallback(()=>{const e=null==Ne?void 0:Ne.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[Ne]),Js=e.useCallback(()=>{const e=null==Ne?void 0:Ne.direct_tx_delay_factor;return"number"==typeof e?e:.5},[Ne]),Qs=e.useCallback(()=>{const e=null==ge?void 0:ge.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[ge]),ea=e.useCallback(()=>{Ye(Zs().toFixed(2)),Xe(Js().toFixed(2)),Ue(Qs().toFixed(1)),He(!0)},[Zs,Js,Qs]),ta=e.useCallback(()=>{He(!1)},[]);e.useEffect(()=>{if(!qe)return;const e=e=>{"loading"!==Ge&&Je.current&&!Je.current.contains(e.target)&&ta()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[qe,ta,Ge]);const sa=e.useCallback(()=>{var e,t,s;st(fe),rt((null==(e=null==ye?void 0:ye.latitude)?void 0:e.toString())||"0"),lt((null==(t=null==ye?void 0:ye.longitude)?void 0:t.toString())||"0"),it((null==(s=null==ye?void 0:ye.send_advert_interval_hours)?void 0:s.toString())||"0"),mt(null),et(!0)},[fe,ye]),aa=e.useCallback(()=>{et(!1),mt(null)},[]);e.useEffect(()=>{if(!Qe)return;const e=e=>{"loading"!==dt&&xt.current&&!xt.current.contains(e.target)&&aa()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Qe,aa,dt]);const ra=async()=>{var e;if("loading"===Lt)return;const t=(null==Et?void 0:Et.cors_enabled)??!1,s=!t,a=t;At.current&&clearTimeout(At.current),Mt.current&&clearTimeout(Mt.current),Dt.current=!1,It(s),Pt("loading"),At.current=setTimeout(()=>{Dt.current||wt.current&&(It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3))},1e4);try{const t=await M({web:{cors_enabled:s}});if(Dt.current=!0,At.current&&clearTimeout(At.current),!wt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await xe(),Pt("success"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3)):(It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3))}catch{if(Dt.current=!0,At.current&&clearTimeout(At.current),!wt.current)return;It(a),Pt("error"),Mt.current=setTimeout(()=>{wt.current&&(Pt("idle"),It(null))},2e3)}};e.useEffect(()=>{(async()=>{qs(!0);try{const e=await D();e.success&&e.data?Ks(e.data.exists):Ks(!1);const t=null==Et?void 0:Et.web_path;Ds(!t||""===t)}catch{Ks(!1)}finally{qs(!1)}})()},[null==Et?void 0:Et.web_path]);const na=async e=>{var t;if("loading"!==Hs){$s("loading");try{const s=await M({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!wt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Ds(e),$s("success"),Vs(!0),setTimeout(()=>{wt.current&&$s("idle")},2e3)):($s("error"),setTimeout(()=>{wt.current&&$s("idle")},2e3))}catch{if(!wt.current)return;$s("error"),setTimeout(()=>{wt.current&&$s("idle")},2e3)}}},la=e.useCallback(async()=>{qt(!0),$t(null);try{const e=await L();Kt(e.tokens||[])}catch(e){$t(e instanceof Error?e.message:"Failed to fetch tokens")}finally{qt(!1)}},[]);e.useEffect(()=>{la()},[la]);const ca=async()=>{if(Xt.trim()){ts(!0),$t(null);try{const e=await K(Xt.trim());Gt(e.token||null),Vt(!1),Zt(!0),Bt(""),await la()}catch(e){$t(e instanceof Error?e.message:"Failed to create token")}finally{ts(!1)}}else $t("Token name is required")},ia=e=>e?new Date(1e3*e).toLocaleString():"Never",da=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},[]),oa=e.useCallback(async()=>{ds(!0),us(null);try{const e=await P();e.success&&e.data?cs(da(e.data)):us(e.error||"Failed to load transport keys")}catch(e){us(e instanceof Error?e.message:"Unknown error occurred")}finally{ds(!1)}},[da]);e.useEffect(()=>{oa()},[oa]);const ua=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=ua(s.children,t);if(e)return e}}return null},[]),ma=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);return null==e?void 0:e.name},[bs,ls,ua]),xa=e.useCallback(e=>{fs(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),pa=async e=>{hs(!0),us(null);try{const t=await q("allow"===e);t.success?xs(e):us(t.error||"Failed to update global flood policy")}catch(t){us(t instanceof Error?t.message:"Failed to update global flood policy")}finally{hs(!1)}},ha=async()=>{if(Es.trim()){As(!0),us(null);try{const e=await H({name:Es.trim(),flood_policy:Ps,parent_id:bs??void 0});e.success?(await oa(),vs(!1),Ls(""),Rs("deny")):us(e.error||"Failed to add transport key")}catch(e){us(e instanceof Error?e.message:"Failed to add transport key")}finally{As(!1)}}else us("Key name is required")},ba=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);e&&(Ss({...e}),ws(!0))},[bs,ls,ua]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(js&&(vs(!1),Ls(""),Rs("deny")),Ns&&(ws(!1),Ss(null)),ks&&(Cs(!1),Fs(null)),Yt&&(Vt(!1),Bt("")),Wt&&(Zt(!1),Gt(null)))};if(js||Ns||ks||Yt||Wt)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[js,Ns,ks,Yt,Wt]);const ya=e.useCallback(()=>{if(!bs)return;const e=ua(ls,bs);e&&(Fs(e),Cs(!0))},[bs,ls,ua]);return t.jsxs(B,{children:[t.jsx(U,{title:"Configuration",icon:t.jsx(s,{})}),t.jsxs(Z,{template:"standard",children:[t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:xt,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(a,{className:"icon-md text-accent-primary"}),"Repeater Settings"]}),t.jsx("div",{className:"flex items-center gap-1",children:ye&&(Qe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:aa,disabled:"loading"===dt,className:_("p-2 rounded-lg transition-colors","loading"===dt?"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"!==dt){pt.current&&clearTimeout(pt.current),pe(re),ot("loading"),mt(null);try{const e={};tt&&tt!==fe&&(e.node_name=tt);const t=parseFloat(at);isNaN(t)||t===(null==ye?void 0:ye.latitude)||(e.latitude=t);const s=parseFloat(nt);isNaN(s)||s===(null==ye?void 0:ye.longitude)||(e.longitude=s);const a=parseInt(ct);if(isNaN(a)||a===(null==ye?void 0:ye.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return mt({success:!0,message:"No changes to save"}),ot("idle"),void he(re);const r=await A(e);if(!wt.current)return void he(re);if(r.success&&r.data){const e=r.data.applied.join(", ");mt({success:!0,message:`Updated: ${e}`}),await xe({force:!0}),ot("success"),pt.current=setTimeout(()=>{wt.current&&(ot("idle"),et(!1),mt(null),he(re))},1500)}else mt({success:!1,message:r.error||"Failed to save"}),ot("error"),he(re),pt.current=setTimeout(()=>{wt.current&&ot("idle")},2e3)}catch(e){if(!wt.current)return void he(re);mt({success:!1,message:String(e)}),ot("error"),he(re),pt.current=setTimeout(()=>{wt.current&&ot("idle")},2e3)}}},disabled:"loading"===dt,className:_("p-2 rounded-lg transition-colors","loading"===dt?"text-accent-primary cursor-wait":"success"===dt?"text-accent-success":"error"===dt?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===dt?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===dt?t.jsx(l,{className:"w-4 h-4"}):"error"===dt?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:sa,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"})}))})]}),ut&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",ut.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:ut.message}),ye?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",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"text",value:tt,onChange:e=>st(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:fe})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:at,onChange:e=>rt(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!==ye.latitude?ye.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:nt,onChange:e=>lt(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!==ye.longitude?ye.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Qe?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Qe?"bg-white/5":"bg-white/[0.02]"),children:Qe?t.jsx("input",{type:"number",value:ct,onChange:e=>it(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:ye.send_advert_interval_hours>0?`${ye.send_advert_interval_hours}h`:"Disabled"})}),Qe&&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-white/[0.02]",children:t.jsx("span",{className:"type-data text-text-primary",children:ye.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:Ke,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(i,{className:"icon-md text-accent-primary"}),"Radio Configuration"]}),t.jsx("div",{className:"flex items-center gap-1",children:be&&(we?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Ws,disabled:"loading"===Ae,className:_("p-2 rounded-lg transition-colors","loading"===Ae?"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"!==Ae){Oe.current&&clearTimeout(Oe.current),pe(ae),Me("loading"),ze(null);try{const e={},t=parseFloat(Ce),s=be?be.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=be?be.bandwidth/1e3:0;Se!==a&&(e.bandwidth_khz=Se),Fe!==(null==be?void 0:be.spreading_factor)&&(e.spreading_factor=Fe),Le!==(null==be?void 0:be.coding_rate)&&(e.coding_rate=Le);const r=parseInt(Re);if(r!==(null==be?void 0:be.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return ze({success:!0,message:"No changes to save"}),Me("idle"),void he(ae);const n=await A(e);if(!wt.current)return void he(ae);if(n.success&&n.data){const e=n.data.applied.join(", "),t=n.data.live_update?" (applied live)":" (restart required)";ze({success:!0,message:`Updated: ${e}${t}`}),await xe({force:!0}),Me("success"),Oe.current=setTimeout(()=>{wt.current&&(Me("idle"),ke(!1),ze(null),he(ae))},1500)}else ze({success:!1,message:n.error||"Failed to save"}),Me("error"),he(ae),Oe.current=setTimeout(()=>{wt.current&&Me("idle")},2e3)}catch(e){if(!wt.current)return void he(ae);ze({success:!1,message:String(e)}),Me("error"),he(ae),Oe.current=setTimeout(()=>{wt.current&&Me("idle")},2e3)}}},disabled:"loading"===Ae||!Gs,className:_("p-2 rounded-lg transition-colors","loading"===Ae?"text-accent-primary cursor-wait":"success"===Ae?"text-accent-success":"error"===Ae?"text-accent-danger":Gs?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:Gs?"Save changes":"No changes to save",children:"loading"===Ae?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ae?t.jsx(l,{className:"w-4 h-4"}):"error"===Ae?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{be&&(_e((be.frequency/1e6).toFixed(3)),Te(be.bandwidth/1e3),Ee(be.spreading_factor),Pe(be.coding_rate),Ie(String(be.tx_power))),ze(null),ke(!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"})}))})]}),De&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",De.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:De.message}),be?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:we?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsx("input",{type:"number",value:Ce,onChange:e=>_e(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:R(be.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:we?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsx("input",{type:"number",value:Re,onChange:e=>Ie(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:[be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Se,onChange:e=>Te(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:ee.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(d,{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(be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Fe,onChange:e=>Ee(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:te.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(d,{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",be.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",we?"bg-white/5":"bg-white/[0.02]"),children:we?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Le,onChange:e=>Pe(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:se.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(d,{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/",be.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-white/[0.02]",children:t.jsxs("span",{className:"type-data text-text-primary",children:[be.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(Z,{template:"standard",children:[t.jsx(J,{span:12,md:6,children:t.jsx(G,{children:t.jsxs("div",{ref:Je,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(o,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:qe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==Ge){Ze.current&&clearTimeout(Ze.current),pe(ne),We("loading");try{const e=await A({tx_delay_factor:parseFloat($e),direct_tx_delay_factor:parseFloat(Ve)});if(await ue({max_airtime_percent:parseFloat(Be),enforcement_enabled:ve}),!wt.current)return void he(ne);e.success&&e.data?(await xe({force:!0}),We("success"),Ze.current=setTimeout(()=>{wt.current&&(We("idle"),He(!1),he(ne))},1500)):(We("error"),he(ne),Ze.current=setTimeout(()=>{wt.current&&We("idle")},2e3))}catch{if(!wt.current)return void he(ne);We("error"),he(ne),Ze.current=setTimeout(()=>{wt.current&&We("idle")},2e3)}}},disabled:"loading"===Ge,className:_("p-2 rounded-lg transition-colors","loading"===Ge?"text-accent-primary cursor-wait":"success"===Ge?"text-accent-success":"error"===Ge?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===Ge?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ge?t.jsx(l,{className:"w-4 h-4"}):"error"===Ge?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})}),t.jsx("button",{onClick:ta,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:ea,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!==ft?ft:"forward"===je;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===ht)return;const t=!e,s="forward"===je;kt.current&&clearTimeout(kt.current),Ct.current&&clearTimeout(Ct.current),Tt.current=!1,jt(t),bt("loading"),kt.current=setTimeout(()=>{Tt.current||wt.current&&(jt(s),bt("error"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null))},2e3))},1e4);try{if(await de(t?"forward":"monitor"),Tt.current=!0,kt.current&&clearTimeout(kt.current),!wt.current)return;bt("success"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null),oe())},2e3)}catch{if(Tt.current=!0,kt.current&&clearTimeout(kt.current),!wt.current)return;jt(s),bt("error"),Ct.current=setTimeout(()=>{wt.current&&(bt("idle"),jt(null))},2e3)}},disabled:"loading"===ht,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"===ht&&"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"===ht&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===ht&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===ht&&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!==vt?vt:ve;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===yt)return;const t=!e,s=ve;_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Ft.current=!1,Nt(t),gt("loading"),_t.current=setTimeout(()=>{Ft.current||wt.current&&(Nt(s),gt("error"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null))},2e3))},1e4);try{if(await ue({max_airtime_percent:Qs(),enforcement_enabled:t}),Ft.current=!0,_t.current&&clearTimeout(_t.current),!wt.current)return;gt("success"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null),me())},2e3)}catch{if(Ft.current=!0,_t.current&&clearTimeout(_t.current),!wt.current)return;Nt(s),gt("error"),St.current=setTimeout(()=>{wt.current&&(gt("idle"),Nt(null))},2e3)}},disabled:"loading"===yt,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"===yt&&"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"===yt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===yt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===yt&&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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Be,onChange:e=>Ue(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:[Qs().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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:$e,onChange:e=>Ye(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:[Zs().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]",qe?"bg-white/5":"bg-white/[0.02]"),children:qe?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ve,onChange:e=>Xe(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:[Js().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx(J,{span:12,md:6,children:t.jsxs(G,{children:[t.jsx(W,{icon:t.jsx(s,{}),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!==Rt?Rt:(null==Et?void 0:Et.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:ra,disabled:"loading"===Lt,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"===Lt&&"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"===Lt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===Lt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===Lt&&t.jsx(r,{className:"w-4 h-4 text-accent-danger"})]})})()})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-body text-text-primary font-medium block mb-2",children:"Theme"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Q,{showLogoOnly:!0})}),t.jsx("div",{className:"flex-shrink-0",children:t.jsx(Q,{showThumbnailsOnly:!0})})]})]})]})]})})]}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{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(u,{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:()=>vs(!0),disabled:"allow"===ms,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===ms?"bg-white/[0.02] text-text-muted cursor-not-allowed":"bg-accent-success/10 hover:bg-accent-success/20 text-accent-success"),children:[t.jsx(m,{className:"w-3.5 h-3.5"}),"Add"]}),t.jsx("button",{onClick:ba,disabled:!bs||"allow"===ms,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",bs&&"allow"!==ms?"bg-accent-primary/10 hover:bg-accent-primary/20 text-accent-primary":"bg-white/[0.02] text-text-muted cursor-not-allowed"),children:"Edit"}),t.jsx("button",{onClick:ya,disabled:!bs||"allow"===ms,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",bs&&"allow"!==ms?"bg-accent-danger/10 hover:bg-accent-danger/20 text-accent-danger":"bg-white/[0.02] text-text-muted cursor-not-allowed"),children:"Delete"})]})]}),t.jsx("div",{className:"bg-white/[0.02] 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"===ms?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===ms?t.jsx(x,{className:"w-5 h-5 text-accent-success"}):t.jsx(p,{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-white/[0.02] rounded-full p-1",children:[t.jsx("button",{onClick:()=>pa("deny"),disabled:ps,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===ms?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ps&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>pa("allow"),disabled:ps,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===ms?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ps&&"opacity-50"),children:"Allow"})]}),ps&&t.jsx(n,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),os&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:os}),t.jsx("div",{className:"bg-white/[0.02] rounded-2xl p-4 min-h-[120px]",children:is?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(n,{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===ls.length?t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-white/[0.02] mx-auto mb-3 flex items-center justify-center",children:t.jsx(u,{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:ls.map(e=>t.jsx(le,{node:e,level:0,expandedKeys:gs,selectedKeyId:bs,globalFloodPolicy:ms,onSelect:ys,onToggle:xa},e.id))})})]})}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{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(h,{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:()=>Vt(!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(m,{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(b,{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."})]})]})}),Ht&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Ht}),Ot&&0===zt.length?t.jsxs("div",{className:"flex items-center justify-center py-6",children:[t.jsx(n,{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..."})]}):zt.length>0?t.jsx("div",{className:"space-y-2",children:zt.map(e=>t.jsx("div",{className:"bg-white/[0.02] hover:bg-white/[0.04] 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(h,{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: ",ia(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",ia(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Qt({id:e.id,name:e.name}),disabled:ss,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(y,{className:"w-3.5 h-3.5"}),"Revoke"]})]})},e.id))}):t.jsxs("div",{className:"bg-white/[0.02] rounded-2xl p-6 text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-white/[0.02] mx-auto mb-4 flex items-center justify-center",children:t.jsx(h,{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:()=>Vt(!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(Z,{template:"auto",children:t.jsxs(G,{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(g,{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-white/[0.02] rounded-2xl border-2 cursor-pointer transition-all",Ms?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Hs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ms,onChange:()=>na(!0),disabled:"loading"===Hs,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-white/[0.02] rounded-2xl border-2 cursor-pointer transition-all",Ms?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Hs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ms,onChange:()=>na(!1),disabled:"loading"===Hs,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"})]})]})]}),!Os&&t.jsx("div",{className:_("bg-white/[0.02] rounded-2xl p-4",zs?"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",zs?"bg-accent-success/20":"bg-accent-tertiary/20"),children:zs?t.jsx(f,{className:"w-4 h-4 text-accent-success"}):t.jsx(b,{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:zs?"PyMC Console has been detected":"PyMC Console Not Installed"}),zs?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(j,{className:"w-4 h-4"}),"PyMC Console Install Instructions"]})]})]})]})}),Ys&&t.jsx("div",{className:"bg-white/[0.02] 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(v,{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(!Xs){Bs(!0);try{await z(),Vs(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Vs(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:Xs,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:Xs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Restarting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(N,{className:"w-4 h-4"}),"Restart Now"]})})]})})]})]})}),t.jsx(Z,{template:"auto",children:t.jsxs(G,{children:[t.jsx(W,{icon:t.jsx(o,{}),title:"Node Information",largeTitle:!0}),ie?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Node Name"}),t.jsx("p",{className:"type-body text-text-primary mt-1",children:fe})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Version"}),t.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",ie.version]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Core Version"}),t.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",ie.core_version]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"type-label text-text-muted",children:"Local Hash"}),t.jsx("div",{className:"mt-1",children:ie.local_hash?t.jsx(V,{hash:ie.local_hash,size:"sm"}):t.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),ie.public_key&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Public Key"}),t.jsx("div",{className:"mt-1",children:t.jsx(V,{hash:ie.public_key,prefixLength:12,suffixLength:8})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading node information..."})]})}),Yt&&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&&Vt(!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:Xt,onChange:e=>Bt(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&&ca(),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:()=>{Vt(!1),Bt(""),$t(null)},disabled:es,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:es||!Xt.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:es?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),Wt&&Ut&&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&&Zt(!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(v,{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:Ut,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:()=>{Ut&&(navigator.clipboard.writeText(Ut),ns(!0),setTimeout(()=>ns(!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:[rs?t.jsx(l,{className:"w-4 h-4 text-accent-success"}):t.jsx(w,{className:"w-4 h-4"}),rs?"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: ',Ut.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{Zt(!1),Gt(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(X,{isOpen:!!Jt,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Jt?void 0:Jt.name}'? This action cannot be undone.`,confirmLabel:ss?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Jt){as(!0),$t(null);try{await O(Jt.id),await la(),Qt(null)}catch(e){$t(e instanceof Error?e.message:"Failed to revoke token")}finally{as(!1)}}},onCancel:()=>Qt(null)}),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&&vs(!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:[bs&&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:ma()})]}),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:Es,onChange:e=>Ls(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&&ha(),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:()=>Rs("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===Ps?"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:()=>Rs("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===Ps?"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:()=>{vs(!1),Ls(""),Rs("deny")},disabled:Is,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:ha,disabled:Is||!Es.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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),Ns&&_s&&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&&ws(!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:_s.name,onChange:e=>Ss({..._s,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:()=>Ss({..._s,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===_s.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:()=>Ss({..._s,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===_s.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),_s.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:_s.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{ws(!1),Fs(_s),Cs(!0),Ss(null)},disabled:Is,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:()=>{ws(!1),Ss(null)},disabled:Is,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(_s){As(!0),us(null);try{const e=await $(_s.id,{name:_s.name,flood_policy:_s.floodPolicy});e.success?(await oa(),ws(!1),Ss(null)):us(e.error||"Failed to update transport key")}catch(e){us(e instanceof Error?e.message:"Failed to update transport key")}finally{As(!1)}}},disabled:Is||!_s.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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),ks&&Ts&&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&&Cs(!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:["'",Ts.name,"'"]}),"?"]}),Ts.children&&Ts.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(v,{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 ",Ts.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:()=>{Cs(!1),Fs(null)},disabled:Is,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(Ts){As(!0),us(null);try{const e=await Y(Ts.id);e.success?(await oa(),Cs(!1),Fs(null),ys(null)):us(e.error||"Failed to delete transport key")}catch(e){us(e instanceof Error?e.message:"Failed to delete transport key")}finally{As(!1)}}},disabled:Is,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:Is?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ce as default}; diff --git a/frontend/dist/assets/Contacts-au5gCj-N.js b/frontend/dist/assets/Contacts-DfRgoaov.js similarity index 99% rename from frontend/dist/assets/Contacts-au5gCj-N.js rename to frontend/dist/assets/Contacts-DfRgoaov.js index 28c806d0..b023458c 100644 --- a/frontend/dist/assets/Contacts-au5gCj-N.js +++ b/frontend/dist/assets/Contacts-DfRgoaov.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-C5vcx8J6.js","assets/vendor-react-O8XH9yVn.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-DacI-LFP.js","assets/index-Dp0UlTio.js","assets/ConfirmModal-DYznouaT.js","assets/useThemeColors-CD0TSU03.js","assets/PageLayout-DE5PEtD2.js","assets/HashBadge-aS_UIcg2.js","assets/SignalIndicator-BVAbF7xm.js","assets/CollisionExplorerModal-DEtEH0fD.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-DjRKexsi.css","assets/leaflet-CIGW-MKW.css"])))=>i.map(i=>d[i]); -import{j as e,r as s,ab as t,a7 as a,z as n,h as l,ac as c,k as i,ad as r,Z as o,ae as d,y as x,A as m,a1 as h,af as p,ag as u,aa as g,a6 as j,a0 as b,a5 as N,ah as v,o as f,ai as y,aj as w,Y as C,ak as k,p as S,al as M,X as L,am as H,an as P,ao as F,ap as E,aq as R,ar as $,as as T,at as _,au as A,av as O}from"./vendor-react-O8XH9yVn.js";import{A as D,B as z,y as G,C as W,E as I,F as K,G as U,H as B,e as V,I as q,h as J,J as Y,K as Z,L as Q,f as X,m as ee,M as se,N as te}from"./index-Dp0UlTio.js";import{P as ae,b as ne}from"./PageLayout-DE5PEtD2.js";import{_ as le}from"./deckgl-DTsmDcfs.js";import{c as ce,L as ie,T as re,a as oe}from"./recharts-BU7auunF.js";import{H as de}from"./HashBadge-aS_UIcg2.js";import{a as xe}from"./SignalIndicator-BVAbF7xm.js";import{C as me}from"./CollisionExplorerModal-DEtEH0fD.js";import{C as he}from"./ConfirmModal-DYznouaT.js";class pe 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 ue=s.lazy(()=>le(()=>import("./ContactsMapMapLibre-C5vcx8J6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function ge({neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o}){return e.jsx(pe,{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(ue,{neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o})})})}function je(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function be(e){return`${Math.round(100*e)}%`}function Ne(e,s){return s.has(e.toUpperCase())}const ve=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=>Ne(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 ${je(s.healthScore)}`,children:be(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=Ne(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]),b=s.useMemo(()=>m.slice(0,o),[m,o]),N=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:[N&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[e.jsxs("span",{className:`tabular-nums ${je(N.avgHealth)}`,children:["Avg: ",be(N.avgHealth)]}),N.weakLinks>0&&e.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[e.jsx(a,{className:"w-3 h-3"}),N.weakLinks," weak"]}),N.declining>0&&e.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}),N.declining," declining"]}),N.pathsWithGhosts>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),N.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:b.map(s=>e.jsx(ve,{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 ye(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 we={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 Ce({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=we[u],j="clusterId"in(w=t)&&"temporal"in w;var w;const C=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]),k=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,H=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-xs",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:ce("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:ce("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:ce("px-1.5 py-0.5 rounded text-xs font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:ce("text-xs 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-xs 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(b,{className:"w-3 h-3"}),t.commonNeighbors.size]}),t.estimatedLocation&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"}),k]}),S&&e.jsxs("span",{className:ce("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&&H&&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-xs",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:H.knownNodeName?e.jsxs("span",{children:["May match ",e.jsx("span",{className:"font-medium",children:H.knownNodeName})," ","(",(100*H.collisionProbability).toFixed(0),"% probability)"]}):e.jsxs("span",{children:["May match ",e.jsx(de,{hash:H.knownNodeHash,size:"sm",className:"inline"})," ","(",(100*H.collisionProbability).toFixed(0),"% probability)"]})}),H.evidence&&e.jsxs("div",{className:"text-text-muted mt-1 text-[10px]",children:[H.evidence.sharedEdgeCount>0&&e.jsxs("span",{className:"mr-2",children:[H.evidence.sharedEdgeCount," shared edges"]}),void 0!==H.evidence.distanceKm&&e.jsxs("span",{className:"mr-2",children:[H.evidence.distanceKm.toFixed(1),"km apart"]}),H.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(N,{className:"w-4 h-4 text-accent-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs",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: ",k]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",ye(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-xs 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-xs",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-xs",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",W(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",W(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-xs",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",W(t.firstSeen)," – ",W(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),C.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",C.length," known node",1!==C.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[C.slice(0,5).map(({hash:s})=>e.jsx(de,{hash:s,size:"sm"},s)),C.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",C.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(ke,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(ke,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(ke,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(ke,{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 ke({label:s,passed:t}){return e.jsxs("span",{className:ce("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(C,{className:"w-2.5 h-2.5"}),s]})}function Se({neighbors:t,className:n,onGhostSelect:r}){const o=G(),d=z(),[x,b]=s.useState(new Set),[N,v]=s.useState("actionable"),[f,y]=s.useState(!1),[w,C]=s.useState(!0),[k,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,k)),[o,k]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),H=s.useMemo(()=>L?M.find(e=>e.prefix===L)??null:null,[L,M]);s.useEffect(()=>{r&&r(H&&!w?{prefix:H.prefix,commonNeighbors:Array.from(H.commonNeighbors),estimatedLocation:H.estimatedLocation}:null)},[H,w,r]),s.useEffect(()=>{w&&b(new Set)},[w]);const{confirmed:P,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=>{b(s=>s.has(e)?new Set:new Set([e]))},_="all"===N,A=P.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:ce("flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors","all"===N?"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"===N?"Actionable":"All"]}),e.jsx("button",{onClick:()=>C(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:()=>C(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[P.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-success",children:[e.jsx(u,{className:"w-3 h-3"}),P.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:[P.length>0&&e.jsxs("span",{className:"text-accent-success",children:[P.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:[P.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 (",P.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:P.map(s=>e.jsx(Ce,{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(Ce,{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(Ce,{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"===N&&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(Ce,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===N&&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&&A>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 Me="var(--sparkline-critical)",Le="var(--sparkline-poor)",He="var(--sparkline-fair)",Pe="var(--sparkline-good)",Fe="var(--sparkline-excellent)";function Ee({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 Re=s.memo(function({nodeHash:s,width:t=60,height:a=20,color:n,showArea:l=!0,showTooltip:c=!1,className:i=""}){const r=I(s),o=K(),d=!U().backgroundLoadComplete||o,x=n??(r.length>0?function(e){if(0===e.length)return Me;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 Me;if(n>0){const e=a/n;return e>=1.2?Fe:e>=.8?Pe:e>=.4?He:e>=.1?Le:Me}return t>=10?Fe:t>=5?Pe:t>=2?He:t>=1?Le:Me}(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:Me},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(ie,{data:r,width:m,height:h,margin:{top:1,right:1,bottom:1,left:1},children:[c&&e.jsx(re,{content:e.jsx(Ee,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),e.jsx(oe,{type:"monotone",dataKey:"count",stroke:x,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),$e=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",b=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:b,"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(k,{className:u})}),e.jsx(me,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function Te(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 _e=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:t}=q(),a=J(),n=Y(),l=Z(),c=Q(),r=X(),o=G(),x=ee(),[m,h]=s.useState(null),[p,u]=s.useState("lastHeard"),[j,v]=s.useState("desc"),[y,w]=s.useState(""),[C,k]=s.useState(!1),[D,z]=s.useState(null),[W,I]=s.useState(null),[K,U]=s.useState(null),[B,V]=s.useState(null),[le,ce]=s.useState(new Map),[ie,re]=s.useState(new Map),[oe,me]=s.useState(25),[pe,ue]=s.useState(25),je=s.useRef(null),[be,Ne]=s.useState(!1),ve=s.useMemo(()=>(null==t?void 0:t.neighbors)??{},[null==t?void 0:t.neighbors]),ye=s.useMemo(()=>Object.fromEntries(Object.entries(ve).filter(([e])=>!a.has(e))),[ve,a]),we=s.useMemo(()=>{var e;return(null==(e=null==t?void 0:t.config)?void 0:e.repeater)?{latitude:t.config.repeater.latitude,longitude:t.config.repeater.longitude,name:t.config.node_name||"Local Node"}:void 0},[t]),Ce=null==t?void 0:t.local_hash,ke=s.useMemo(()=>{const e=new Map;if(!(null==we?void 0:we.latitude)||!(null==we?void 0:we.longitude))return e;for(const[s,t]of Object.entries(ye))t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude?e.set(s,Te(we.latitude,we.longitude,t.latitude,t.longitude)):e.set(s,null);return e},[ye,we]),{neighborHashSet:Me,neighborSignalMap:Le}=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]),He=s.useMemo(()=>{const e=y.toLowerCase().trim(),s="neighbor"===e||"neighbors"===e,t=C||s;return Object.fromEntries(Object.entries(ye).filter(([a,n])=>{if(t&&!Me.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)}))},[ye,y,C,Me]),Pe=s.useMemo(()=>Object.entries(He).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=ke.get(e)??null,a=ke.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}),[He,p,j,ke,c]),Fe=Pe.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,Ee=s.useMemo(()=>new Set(l),[l]),_e=s.useMemo(()=>0===oe?Pe:Pe.slice(0,pe),[Pe,pe,oe]);s.useEffect(()=>{ue(oe||Pe.length)},[p,j,y,C,oe,Pe.length]),s.useEffect(()=>{if(0===oe)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting&&peMath.min(e+oe,Pe.length))},{threshold:.1,rootMargin:"100px"});return je.current&&e.observe(je.current),()=>e.disconnect()},[oe,pe,Pe.length]);const Ae=s.useCallback(e=>{me(e),ue(e||Pe.length),Ne(!1)},[Pe.length]),Oe=s.useCallback(e=>{p===e?v(e=>"desc"===e?"asc":"desc"):(u(e),v("desc"))},[p]),De=s.useCallback(e=>{const s=ye[e];(null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&0!==s.latitude&&0!==s.longitude&&z(e)},[ye]),ze=s.useCallback(()=>{z(null)},[]),Ge=s.useCallback(async(e,s)=>{if(s.stopPropagation(),!B){V(e),ce(s=>{const t=new Map(s);return t.delete(e),t}),re(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 se(s,30);t.success&&t.data?(ce(s=>new Map(s).set(e,t.data)),setTimeout(()=>{ce(s=>{const t=new Map(s);return t.delete(e),t})},1e4)):(re(s=>new Map(s).set(e,t.error||"Ping failed")),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},5e3))}catch(t){const s=t instanceof Error?t.message:"Ping failed";re(t=>new Map(t).set(e,s)),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},5e3)}finally{V(null)}}},[B]);return e.jsxs(ae,{children:[e.jsx(ne,{title:"Contacts",icon:e.jsx(b,{}),controls:e.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[e.jsxs("span",{className:"roster-title tabular-nums",children:[Pe.length," node",1!==Pe.length?"s":""]}),Fe>0&&e.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[e.jsx(N,{className:"w-3.5 h-3.5 relative top-[2px]"}),Fe," with location"]})]})}),x?e.jsx(ge,{neighbors:ye,localNode:we,localHash:Ce,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:ze,highlightedEdgeKey:W,highlightedGhost:K}):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(fe,{maxPaths:10,highlightedEdge:W,onHighlightEdge:I}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Se,{neighbors:ye,onGhostSelect:U})}):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(b,{className:"chart-title-icon"}),"Discovered Contacts"]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[Me.size>0&&e.jsxs("button",{onClick:()=>k(!C),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-xs rounded-lg transition-colors "+(C?"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:C?"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:Me.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-xs 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()||k(!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:()=>Oe("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>Oe("distance"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(P,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===p&&e.jsx(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>Oe("centrality"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Ne(!be),className:"flex items-center gap-1 px-2 py-1.5 text-xs 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===oe?"All":oe}),e.jsx(i,{className:"w-3 h-3 transition-transform "+(be?"rotate-180":"")})]}),be&&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:()=>Ae(s),className:"w-full px-3 py-1.5 text-xs text-left hover:bg-white/5 transition-colors "+(oe===s?"text-accent-primary":"text-text-secondary"),children:0===s?"All":s},s))})]})]})]}),Pe.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:_e.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=Ee.has(s),r=Me.has(s),o=ke.get(s),x=c.get(s)||0,m=r?Le.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,b="companion"===u||"client"===u||"cli"===u,N=t.is_repeater||"repeater"===u||"rep"===u,v=r?"direct":"flood",f=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:()=>De(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 "+(w=m.avgSnr,void 0===w?"bg-[var(--signal-unknown)]":w>=5?"bg-[var(--signal-excellent)]":w>=0?"bg-[var(--signal-good)]":w>=-5?"bg-[var(--signal-fair)]":w>=-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:f,children:j&&N?e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(F,{className:"w-5 h-5 absolute inset-0 text-accent-secondary"}),e.jsx(E,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-accent-primary"})]}):j?e.jsx(F,{className:"w-5 h-5 text-accent-secondary"}):b?e.jsx(R,{className:"w-5 h-5 text-text-muted"}):N?"direct"===v?e.jsx($,{className:"w-5 h-5 text-accent-success"}):e.jsx(E,{className:"w-5 h-5 text-accent-tertiary"}):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("span",{className:"type-badge px-1.5 py-0.5 rounded flex-shrink-0",style:{backgroundColor:"rgba(113, 152, 114, 0.2)",color:"var(--accent-success)"},children:"NBR"}),i&&e.jsxs("span",{className:"type-badge px-1.5 py-0.5 rounded flex items-center gap-1 flex-shrink-0",style:{backgroundColor:"rgba(223, 188, 114, 0.2)",color:"var(--accent-secondary)"},children:[e.jsx(T,{className:"w-3 h-3"}),"HUB"]}),N&&e.jsx("span",{className:"pill-tag flex-shrink-0",children:"RPT"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(de,{hash:s,size:"xs",prefixLength:8,suffixLength:6}),e.jsx($e,{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(xe,{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(P,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs tabular-nums",children:(y=o,y<1e3?`${Math.round(y)}m`:`${(y/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(Re,{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?te(t.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[r&&e.jsx(e.Fragment,{children:le.has(s)?e.jsxs("div",{className:"flex items-center gap-1 text-accent-success",title:`RTT: ${le.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:[le.get(s).snr_db.toFixed(1),"dB"]})]}):ie.has(s)?e.jsx("span",{className:"text-red-400 text-[10px]",title:ie.get(s),children:"✗"}):e.jsx("button",{onClick:e=>Ge(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(A,{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(O,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]},s);var y,w})}),oe>0&&pe0&&peue(e=>Math.min(e+oe,Pe.length)),className:"text-accent-primary hover:text-accent-primary/80 transition-colors",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(b,{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(he,{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{_e as C,Re as N,$e as P}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-CEbwjfzP.js","assets/vendor-react-O8XH9yVn.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-Bg3LiwiV.js","assets/index-DGrzd8xb.js","assets/ConfirmModal-DYznouaT.js","assets/useThemeColors-CD0TSU03.js","assets/PageLayout-DE5PEtD2.js","assets/HashBadge-aS_UIcg2.js","assets/SignalIndicator-BVAbF7xm.js","assets/CollisionExplorerModal-dc7PClY6.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-DjRKexsi.css","assets/leaflet-CIGW-MKW.css"])))=>i.map(i=>d[i]); +import{j as e,r as s,ab as t,a7 as a,z as n,h as l,ac as c,k as i,ad as r,Z as o,ae as d,y as x,A as m,a1 as h,af as p,ag as u,aa as g,a6 as j,a0 as b,a5 as N,ah as v,o as f,ai as y,aj as w,Y as C,ak as k,p as S,al as M,X as L,am as H,an as P,ao as F,ap as E,aq as R,ar as $,as as T,at as _,au as A,av as O}from"./vendor-react-O8XH9yVn.js";import{A as D,B as z,y as G,C as W,E as I,F as K,G as U,H as B,e as V,I as q,h as J,J as Y,K as Z,L as Q,f as X,m as ee,M as se,N as te}from"./index-DGrzd8xb.js";import{P as ae,b as ne}from"./PageLayout-DE5PEtD2.js";import{_ as le}from"./deckgl-DTsmDcfs.js";import{c as ce,L as ie,T as re,a as oe}from"./recharts-BU7auunF.js";import{H as de}from"./HashBadge-aS_UIcg2.js";import{a as xe}from"./SignalIndicator-BVAbF7xm.js";import{C as me}from"./CollisionExplorerModal-dc7PClY6.js";import{C as he}from"./ConfirmModal-DYznouaT.js";class pe 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 ue=s.lazy(()=>le(()=>import("./ContactsMapMapLibre-CEbwjfzP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])));function ge({neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o}){return e.jsx(pe,{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(ue,{neighbors:t,localNode:a,localHash:n,onRemoveNode:l,selectedNodeHash:c,onNodeSelected:i,highlightedEdgeKey:r,highlightedGhost:o})})})}function je(e){return e>=.7?"text-accent-success":e>=.5?"text-accent-secondary":e>=.3?"text-signal-poor":"text-accent-danger"}function be(e){return`${Math.round(100*e)}%`}function Ne(e,s){return s.has(e.toUpperCase())}const ve=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=>Ne(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 ${je(s.healthScore)}`,children:be(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=Ne(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]),b=s.useMemo(()=>m.slice(0,o),[m,o]),N=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:[N&&e.jsxs("div",{className:"flex items-center gap-3 text-[10px]",children:[e.jsxs("span",{className:`tabular-nums ${je(N.avgHealth)}`,children:["Avg: ",be(N.avgHealth)]}),N.weakLinks>0&&e.jsxs("span",{className:"text-accent-danger flex items-center gap-1",children:[e.jsx(a,{className:"w-3 h-3"}),N.weakLinks," weak"]}),N.declining>0&&e.jsxs("span",{className:"text-signal-poor flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}),N.declining," declining"]}),N.pathsWithGhosts>0&&e.jsxs("span",{className:"text-accent-tertiary flex items-center gap-1",children:[e.jsx(l,{className:"w-3 h-3"}),N.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:b.map(s=>e.jsx(ve,{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 ye(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 we={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 Ce({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=we[u],j="clusterId"in(w=t)&&"temporal"in w;var w;const C=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]),k=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,H=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-xs",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:ce("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:ce("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:ce("px-1.5 py-0.5 rounded text-xs font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:ce("text-xs 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-xs 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(b,{className:"w-3 h-3"}),t.commonNeighbors.size]}),t.estimatedLocation&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"}),k]}),S&&e.jsxs("span",{className:ce("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&&H&&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-xs",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:H.knownNodeName?e.jsxs("span",{children:["May match ",e.jsx("span",{className:"font-medium",children:H.knownNodeName})," ","(",(100*H.collisionProbability).toFixed(0),"% probability)"]}):e.jsxs("span",{children:["May match ",e.jsx(de,{hash:H.knownNodeHash,size:"sm",className:"inline"})," ","(",(100*H.collisionProbability).toFixed(0),"% probability)"]})}),H.evidence&&e.jsxs("div",{className:"text-text-muted mt-1 text-[10px]",children:[H.evidence.sharedEdgeCount>0&&e.jsxs("span",{className:"mr-2",children:[H.evidence.sharedEdgeCount," shared edges"]}),void 0!==H.evidence.distanceKm&&e.jsxs("span",{className:"mr-2",children:[H.evidence.distanceKm.toFixed(1),"km apart"]}),H.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(N,{className:"w-4 h-4 text-accent-primary mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs",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: ",k]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",ye(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-xs 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-xs",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-xs",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",W(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",W(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-xs",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",W(t.firstSeen)," – ",W(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),C.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",C.length," known node",1!==C.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[C.slice(0,5).map(({hash:s})=>e.jsx(de,{hash:s,size:"sm"},s)),C.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",C.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(ke,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(ke,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(ke,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(ke,{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 ke({label:s,passed:t}){return e.jsxs("span",{className:ce("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(C,{className:"w-2.5 h-2.5"}),s]})}function Se({neighbors:t,className:n,onGhostSelect:r}){const o=G(),d=z(),[x,b]=s.useState(new Set),[N,v]=s.useState("actionable"),[f,y]=s.useState(!1),[w,C]=s.useState(!0),[k,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,k)),[o,k]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),H=s.useMemo(()=>L?M.find(e=>e.prefix===L)??null:null,[L,M]);s.useEffect(()=>{r&&r(H&&!w?{prefix:H.prefix,commonNeighbors:Array.from(H.commonNeighbors),estimatedLocation:H.estimatedLocation}:null)},[H,w,r]),s.useEffect(()=>{w&&b(new Set)},[w]);const{confirmed:P,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=>{b(s=>s.has(e)?new Set:new Set([e]))},_="all"===N,A=P.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:ce("flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors","all"===N?"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"===N?"Actionable":"All"]}),e.jsx("button",{onClick:()=>C(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:()=>C(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[P.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent-success",children:[e.jsx(u,{className:"w-3 h-3"}),P.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:[P.length>0&&e.jsxs("span",{className:"text-accent-success",children:[P.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:[P.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 (",P.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:P.map(s=>e.jsx(Ce,{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(Ce,{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(Ce,{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"===N&&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(Ce,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===N&&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&&A>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 Me="var(--sparkline-critical)",Le="var(--sparkline-poor)",He="var(--sparkline-fair)",Pe="var(--sparkline-good)",Fe="var(--sparkline-excellent)";function Ee({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 Re=s.memo(function({nodeHash:s,width:t=60,height:a=20,color:n,showArea:l=!0,showTooltip:c=!1,className:i=""}){const r=I(s),o=K(),d=!U().backgroundLoadComplete||o,x=n??(r.length>0?function(e){if(0===e.length)return Me;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 Me;if(n>0){const e=a/n;return e>=1.2?Fe:e>=.8?Pe:e>=.4?He:e>=.1?Le:Me}return t>=10?Fe:t>=5?Pe:t>=2?He:t>=1?Le:Me}(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:Me},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(ie,{data:r,width:m,height:h,margin:{top:1,right:1,bottom:1,left:1},children:[c&&e.jsx(re,{content:e.jsx(Ee,{}),cursor:{stroke:"rgba(255,255,255,0.2)",strokeWidth:1}}),e.jsx(oe,{type:"monotone",dataKey:"count",stroke:x,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})}),$e=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",b=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:b,"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(k,{className:u})}),e.jsx(me,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function Te(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 _e=Object.freeze(Object.defineProperty({__proto__:null,default:function(){const{stats:t}=q(),a=J(),n=Y(),l=Z(),c=Q(),r=X(),o=G(),x=ee(),[m,h]=s.useState(null),[p,u]=s.useState("lastHeard"),[j,v]=s.useState("desc"),[y,w]=s.useState(""),[C,k]=s.useState(!1),[D,z]=s.useState(null),[W,I]=s.useState(null),[K,U]=s.useState(null),[B,V]=s.useState(null),[le,ce]=s.useState(new Map),[ie,re]=s.useState(new Map),[oe,me]=s.useState(25),[pe,ue]=s.useState(25),je=s.useRef(null),[be,Ne]=s.useState(!1),ve=s.useMemo(()=>(null==t?void 0:t.neighbors)??{},[null==t?void 0:t.neighbors]),ye=s.useMemo(()=>Object.fromEntries(Object.entries(ve).filter(([e])=>!a.has(e))),[ve,a]),we=s.useMemo(()=>{var e;return(null==(e=null==t?void 0:t.config)?void 0:e.repeater)?{latitude:t.config.repeater.latitude,longitude:t.config.repeater.longitude,name:t.config.node_name||"Local Node"}:void 0},[t]),Ce=null==t?void 0:t.local_hash,ke=s.useMemo(()=>{const e=new Map;if(!(null==we?void 0:we.latitude)||!(null==we?void 0:we.longitude))return e;for(const[s,t]of Object.entries(ye))t.latitude&&t.longitude&&0!==t.latitude&&0!==t.longitude?e.set(s,Te(we.latitude,we.longitude,t.latitude,t.longitude)):e.set(s,null);return e},[ye,we]),{neighborHashSet:Me,neighborSignalMap:Le}=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]),He=s.useMemo(()=>{const e=y.toLowerCase().trim(),s="neighbor"===e||"neighbors"===e,t=C||s;return Object.fromEntries(Object.entries(ye).filter(([a,n])=>{if(t&&!Me.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)}))},[ye,y,C,Me]),Pe=s.useMemo(()=>Object.entries(He).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=ke.get(e)??null,a=ke.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}),[He,p,j,ke,c]),Fe=Pe.filter(([,e])=>e.latitude&&e.longitude&&0!==e.latitude&&0!==e.longitude).length,Ee=s.useMemo(()=>new Set(l),[l]),_e=s.useMemo(()=>0===oe?Pe:Pe.slice(0,pe),[Pe,pe,oe]);s.useEffect(()=>{ue(oe||Pe.length)},[p,j,y,C,oe,Pe.length]),s.useEffect(()=>{if(0===oe)return;const e=new IntersectionObserver(e=>{e[0].isIntersecting&&peMath.min(e+oe,Pe.length))},{threshold:.1,rootMargin:"100px"});return je.current&&e.observe(je.current),()=>e.disconnect()},[oe,pe,Pe.length]);const Ae=s.useCallback(e=>{me(e),ue(e||Pe.length),Ne(!1)},[Pe.length]),Oe=s.useCallback(e=>{p===e?v(e=>"desc"===e?"asc":"desc"):(u(e),v("desc"))},[p]),De=s.useCallback(e=>{const s=ye[e];(null==s?void 0:s.latitude)&&(null==s?void 0:s.longitude)&&0!==s.latitude&&0!==s.longitude&&z(e)},[ye]),ze=s.useCallback(()=>{z(null)},[]),Ge=s.useCallback(async(e,s)=>{if(s.stopPropagation(),!B){V(e),ce(s=>{const t=new Map(s);return t.delete(e),t}),re(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 se(s,30);t.success&&t.data?(ce(s=>new Map(s).set(e,t.data)),setTimeout(()=>{ce(s=>{const t=new Map(s);return t.delete(e),t})},1e4)):(re(s=>new Map(s).set(e,t.error||"Ping failed")),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},5e3))}catch(t){const s=t instanceof Error?t.message:"Ping failed";re(t=>new Map(t).set(e,s)),setTimeout(()=>{re(s=>{const t=new Map(s);return t.delete(e),t})},5e3)}finally{V(null)}}},[B]);return e.jsxs(ae,{children:[e.jsx(ne,{title:"Contacts",icon:e.jsx(b,{}),controls:e.jsxs("div",{className:"flex items-baseline gap-3 sm:gap-4",children:[e.jsxs("span",{className:"roster-title tabular-nums",children:[Pe.length," node",1!==Pe.length?"s":""]}),Fe>0&&e.jsxs("span",{className:"roster-title flex items-baseline gap-1.5 tabular-nums",children:[e.jsx(N,{className:"w-3.5 h-3.5 relative top-[2px]"}),Fe," with location"]})]})}),x?e.jsx(ge,{neighbors:ye,localNode:we,localHash:Ce,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:ze,highlightedEdgeKey:W,highlightedGhost:K}):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(fe,{maxPaths:10,highlightedEdge:W,onHighlightEdge:I}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Se,{neighbors:ye,onGhostSelect:U})}):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(b,{className:"chart-title-icon"}),"Discovered Contacts"]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[Me.size>0&&e.jsxs("button",{onClick:()=>k(!C),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-xs rounded-lg transition-colors "+(C?"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:C?"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:Me.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-xs 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()||k(!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:()=>Oe("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>Oe("distance"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(P,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Distance"}),"distance"===p&&e.jsx(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]}),e.jsxs("button",{onClick:()=>Oe("centrality"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-xs 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(H,{className:"w-3 h-3 "+("asc"===j?"rotate-180":"")})]})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>Ne(!be),className:"flex items-center gap-1 px-2 py-1.5 text-xs 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===oe?"All":oe}),e.jsx(i,{className:"w-3 h-3 transition-transform "+(be?"rotate-180":"")})]}),be&&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:()=>Ae(s),className:"w-full px-3 py-1.5 text-xs text-left hover:bg-white/5 transition-colors "+(oe===s?"text-accent-primary":"text-text-secondary"),children:0===s?"All":s},s))})]})]})]}),Pe.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:_e.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=Ee.has(s),r=Me.has(s),o=ke.get(s),x=c.get(s)||0,m=r?Le.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,b="companion"===u||"client"===u||"cli"===u,N=t.is_repeater||"repeater"===u||"rep"===u,v=r?"direct":"flood",f=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:()=>De(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 "+(w=m.avgSnr,void 0===w?"bg-[var(--signal-unknown)]":w>=5?"bg-[var(--signal-excellent)]":w>=0?"bg-[var(--signal-good)]":w>=-5?"bg-[var(--signal-fair)]":w>=-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:f,children:j&&N?e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(F,{className:"w-5 h-5 absolute inset-0 text-accent-secondary"}),e.jsx(E,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-accent-primary"})]}):j?e.jsx(F,{className:"w-5 h-5 text-accent-secondary"}):b?e.jsx(R,{className:"w-5 h-5 text-text-muted"}):N?"direct"===v?e.jsx($,{className:"w-5 h-5 text-accent-success"}):e.jsx(E,{className:"w-5 h-5 text-accent-tertiary"}):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("span",{className:"type-badge px-1.5 py-0.5 rounded flex-shrink-0",style:{backgroundColor:"rgba(113, 152, 114, 0.2)",color:"var(--accent-success)"},children:"NBR"}),i&&e.jsxs("span",{className:"type-badge px-1.5 py-0.5 rounded flex items-center gap-1 flex-shrink-0",style:{backgroundColor:"rgba(223, 188, 114, 0.2)",color:"var(--accent-secondary)"},children:[e.jsx(T,{className:"w-3 h-3"}),"HUB"]}),N&&e.jsx("span",{className:"pill-tag flex-shrink-0",children:"RPT"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(de,{hash:s,size:"xs",prefixLength:8,suffixLength:6}),e.jsx($e,{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(xe,{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(P,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs tabular-nums",children:(y=o,y<1e3?`${Math.round(y)}m`:`${(y/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(Re,{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?te(t.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[r&&e.jsx(e.Fragment,{children:le.has(s)?e.jsxs("div",{className:"flex items-center gap-1 text-accent-success",title:`RTT: ${le.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:[le.get(s).snr_db.toFixed(1),"dB"]})]}):ie.has(s)?e.jsx("span",{className:"text-red-400 text-[10px]",title:ie.get(s),children:"✗"}):e.jsx("button",{onClick:e=>Ge(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(A,{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(O,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]},s);var y,w})}),oe>0&&pe0&&peue(e=>Math.min(e+oe,Pe.length)),className:"text-accent-primary hover:text-accent-primary/80 transition-colors",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(b,{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(he,{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{_e as C,Re as N,$e as P}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-C5vcx8J6.js b/frontend/dist/assets/ContactsMapMapLibre-CEbwjfzP.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-C5vcx8J6.js rename to frontend/dist/assets/ContactsMapMapLibre-CEbwjfzP.js index 9efdafad..726e981d 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-C5vcx8J6.js +++ b/frontend/dist/assets/ContactsMapMapLibre-CEbwjfzP.js @@ -1 +1 @@ -import{r as A,b as e,j as t,aa as r,ab as n,b9 as o,ba as i,h as a,at as s,ao as l,V as c,a2 as u,ad as d,k as f,aP as g,bb as h,bc as m,bd as b,be as p,af as x,A as v,aL as w,Z as y,bf as k,bg as C,bh as B,c as M,bi as D,X as E,bj as N,a8 as Q,bk as j,av as P,b2 as F,bl as S,$ as L,o as I,an as R,a5 as T,bm as _,au as H,b5 as z,b6 as G,b8 as O,b4 as U,bn as Y}from"./vendor-react-O8XH9yVn.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as W,c as V}from"./link-scoring-DacI-LFP.js";import{y as Z,B as K,T as J,at as X,au as q,av as $,e as AA,aw as eA,M as tA,N as rA,ax as nA,ay as oA,f as iA,G as aA,az as sA,aA as lA}from"./index-Dp0UlTio.js";import{C as cA}from"./ConfirmModal-DYznouaT.js";import{c as uA}from"./recharts-BU7auunF.js";import{g as dA,f as fA,h as gA,i as hA}from"./useThemeColors-CD0TSU03.js";import{p as mA,a as bA}from"./vendor-core-WoOfkQwm.js";import{P as pA,N as xA}from"./Contacts-au5gCj-N.js";import"./deckgl-DTsmDcfs.js";import"./PageLayout-DE5PEtD2.js";import"./HashBadge-aS_UIcg2.js";import"./SignalIndicator-BVAbF7xm.js";import"./CollisionExplorerModal-DEtEH0fD.js";import"./leaflet-D_ckmI2R.js";function vA(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}function wA({label:A,icon:e,status:n,detail:o}){return t.jsxs("div",{className:uA("flex items-center gap-3 py-3 px-4 rounded-xl transition-all duration-300","active"===n&&"bg-accent-primary/10","complete"===n&&"bg-accent-success/10","pending"===n&&"opacity-40"),children:[t.jsx("div",{className:uA("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===n&&"bg-accent-primary/20","complete"===n&&"bg-accent-success/20","pending"===n&&"bg-white/5"),children:"complete"===n?t.jsx(r,{className:"w-4 h-4 text-accent-success"}):"active"===n?t.jsx(s,{className:"w-4 h-4 animate-spin text-accent-primary"}):t.jsx("span",{className:"text-text-muted",children:e})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:uA("text-sm font-medium transition-colors","active"===n&&"text-accent-primary","complete"===n&&"text-accent-success","pending"===n&&"text-text-muted"),children:A}),o&&"pending"!==n&&t.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:o})]})]})}const yA=A.memo(function({isOpen:s,currentStep:l,packetCount:c,onClose:u}){if(A.useEffect(()=>{if(!s)return;const A=A=>{"Escape"===A.key&&u&&u()};window.addEventListener("keydown",A);const e=document.body.style.overflow,t=document.body.style.position,r=document.body.style.width,n=document.body.style.top,o=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${o}px`,()=>{window.removeEventListener("keydown",A),document.body.style.overflow=e,document.body.style.position=t,document.body.style.width=r,document.body.style.top=n,window.scrollTo(0,o)}},[s,u]),!s)return null;const d="complete"===l,f=A=>{const e=["fetching","analyzing","building","discovering","complete"],t=e.indexOf(l),r=e.indexOf(A);return r0?`${c.toLocaleString()} packets`:"Loading database..."}),t.jsx(wA,{label:"Analyzing Database",icon:t.jsx(i,{className:"w-4 h-4"}),status:f("analyzing"),detail:"Processing packet paths"}),t.jsx(wA,{label:"Building Topology",icon:t.jsx(n,{className:"w-4 h-4"}),status:f("building"),detail:"Computing mesh edges"}),t.jsx(wA,{label:"Discovering Nodes",icon:t.jsx(a,{className:"w-4 h-4"}),status:f("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..."})]})})]}),document.body)}),kA={nodeFill:"#F5F5F0",nodeStroke:"#4A5568",localColor:"#FBBF24",hubColor:"#8B7BAD",mobileColor:"#F97316",roomServerColor:"#E17899",neighborColor:"#FBBF24",edges:{rest:"#4B4B4B",restBright:"#616161",restDim:"#3F3F3F",hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:"#8A8A8A",hoverNeighbor:"#FBBF24",neighborRest:"#6B7280",neighborHover:"#FBBF24",highlight:"#FFD700"},edgeOpacity:.82};function CA(){if("undefined"==typeof window)return kA;const A=dA(),e=fA();return{nodeFill:A.nodeFill,nodeStroke:A.nodeStroke,localColor:A.localColor,hubColor:A.hubColor,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:kA.edges.neighborRest,neighborHover:kA.edges.neighborHover,highlight:e.highlight},edgeOpacity:kA.edgeOpacity}}const BA=2e3;function MA({text:A}){return t.jsx(J,{content:A,delay:200,children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted cursor-help"})})}function DA({title:A,tooltip:e,isOpen:r,onToggle:n,hasBorder:o=!1}){return t.jsxs("button",{onClick:n,className:"w-full flex items-center justify-between text-text-secondary font-medium py-1 hover:text-text-primary transition-colors "+(o?"mt-2 pt-2 border-t border-white/10":""),children:[t.jsxs("span",{className:"flex items-center gap-1",children:[A,t.jsx(MA,{text:e})]}),t.jsx(f,{className:"w-3 h-3 text-text-muted transition-transform duration-200 "+(r?"":"-rotate-90")})]})}function EA({showTopology:e,validatedPolylineCount:r,filteredNeighborCount:n,hasLocalNode:o,meshTopology:i,zeroHopNeighbors:s,neighborsWithLocation:f}){const g=gA(),h=Z(),m=K(),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}(i),[x,v]=A.useState(!0),[w,y]=A.useState(!0),[k,C]=A.useState(!0);return t.jsxs("div",{className:"map-control-glass text-xs",style:{padding:"0.625rem"},children:[t.jsx(DA,{title:"Nodes",tooltip:"Node type shown by shape. Yellow = direct RF neighbor.",isOpen:x,onToggle:()=>v(!x)}),x&&t.jsxs("div",{className:"flex flex-col gap-1 mt-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.nodeFill}}),t.jsx("span",{className:"text-text-muted",children:"Node"}),t.jsx(MA,{text:"Standard mesh node. Can be a repeater, client, or companion device."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.hubColor}}),t.jsx("span",{className:"text-text-muted",children:"Hub"}),t.jsx(MA,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow."})]}),(B=f,B.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})&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(l,{className:"w-3 h-3 flex-shrink-0",style:{color:g.roomColor},strokeWidth:2.5}),t.jsx("span",{className:"text-text-muted",children:"Room"}),t.jsx(MA,{text:"Room Server identity. Hosts a chat room that clients can sync messages with."})]})),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(c,{className:"w-3 h-3 flex-shrink-0",style:{color:g.localColor},strokeWidth:2.5}),t.jsx("span",{className:"text-text-muted",children:"Local"}),t.jsx(MA,{text:"Your repeater. This is the node running pyMC_Repeater that you're connected to."})]}),s.size>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded flex-shrink-0",style:{width:"12px",height:"8px",backgroundColor:g.neighborColor}}),t.jsx("span",{className:"text-text-muted",children:"Neighbor"}),t.jsx(MA,{text:"Zero-hop direct RF contact. Color indicates we receive their ADVERTs directly."})]}),i.gatewayNodes.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.hubColor,opacity:.7}}),t.jsx("span",{className:"text-text-muted",children:"Gateway"}),t.jsx(MA,{text:"Significant traffic forwarder (7-10% of last-hop traffic). Gateways relay substantial traffic to the local node."})]}),p>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:"rgb(168, 85, 247)",opacity:.8}}),t.jsx("span",{className:"text-text-muted",children:"Backbone"}),t.jsx(MA,{text:"Critical relay with 4+ neighbors and high betweenness centrality. Backbone nodes carry the majority of mesh traffic."})]}),i.mobileNodes.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",background:"transparent",border:`4px solid ${g.mobileColor}`,boxSizing:"border-box"}}),t.jsx("span",{className:"text-text-muted",children:"Mobile"}),t.jsx(MA,{text:"Volatile node that frequently appears/disappears from paths. Likely a portable or vehicle-mounted device."})]}),b>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(a,{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--accent-tertiary)"},strokeWidth:2.5}),t.jsxs("span",{className:"text-text-muted",children:["Ghost (",b,")"]}),t.jsx(MA,{text:"Unknown repeater discovered via Viterbi HMM path analysis. These nodes appear in paths but aren't in our neighbor table."})]})]}),s.size>0&&t.jsxs(t.Fragment,{children:[t.jsx(DA,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional link balance. 2-Way = balanced. Listener = they hear us. Loud = they route to us.",isOpen:w,onToggle:()=>y(!w),hasBorder:!0}),w&&t.jsxs("div",{className:"flex flex-col gap-1 mt-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.YELLOW}}),t.jsx("span",{className:"text-text-muted",children:"2-Way"}),t.jsx(MA,{text:"33-67% balanced. Ideal bidirectional link - this neighbor both hears us and routes traffic to us equally well."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.GREEN}}),t.jsx("span",{className:"text-text-muted",children:"Listener"}),t.jsx(MA,{text:">67% listener score. This neighbor hears our transmissions well (good RX from us)."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.RED}}),t.jsx("span",{className:"text-text-muted",children:"Loud"}),t.jsx(MA,{text:"<33% listener score. This neighbor routes more traffic TO us than they hear from us."})]})]})]}),e&&r>0&&t.jsxs(t.Fragment,{children:[t.jsx(DA,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = relative strength.",isOpen:k,onToggle:()=>C(!k),hasBorder:!0}),k&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0.5 text-text-muted mt-1",children:[t.jsxs("div",{className:"flex justify-between tabular-nums",children:[t.jsx("span",{children:"Nodes"}),t.jsx("span",{className:"text-text-secondary",children:n+(o?1:0)})]}),i.hubNodes.length>0&&t.jsxs("div",{className:"flex justify-between tabular-nums",children:[t.jsx("span",{children:"Hubs"}),t.jsx("span",{style:{color:kA.hubColor},children:i.hubNodes.length})]})]}),i.loops.length>0&&t.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(u,{className:"w-3 h-3 flex-shrink-0",style:{color:kA.edges.hoverLoop}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:kA.edges.hoverLoop},className:"font-medium",children:[i.loops.length," ",1===i.loops.length?"Loop":"Loops"]}),t.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"Redundant paths"})]})]})}),m.totalPaths>0&&t.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(d,{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--accent-primary)"}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:"var(--accent-primary)"},className:"font-medium",children:[m.totalPaths.toLocaleString()," Viterbi"]}),t.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"HMM decoded paths"})]})]})})]})]})]});var B}function NA({options:A,value:e,onChange:r,size:n="sm",className:o=""}){const i={sm:"text-[10px] px-1.5 py-0.5",md:"text-xs px-2 py-1"};return t.jsx("div",{className:`inline-flex rounded-md bg-black/40 p-0.5 ${o}`,role:"radiogroup",children:A.map(A=>{const o=e===A.value;return t.jsx("button",{onClick:()=>r(A.value),className:`\n ${i[n]}\n rounded transition-all font-medium\n ${o?"bg-white/15 text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary hover:bg-white/5"}\n `,role:"radio","aria-checked":o,title:A.title,children:A.icon?t.jsxs("span",{className:"flex items-center gap-1",children:[A.icon,t.jsx("span",{className:"hidden sm:inline",children:A.label})]}):A.label},A.value)})})}function QA({mapRef:A,showNeighborLines:e,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:c,show3DTerrain:u,onToggle3DTerrain:d,isFullscreen:f,onToggleFullscreen:g}){const y=[{value:"all",label:"All",title:"Show all nodes"},...a?[{value:"hubs",label:"Hubs",title:"Show only hub nodes and their connections"}]:[],...s?[{value:"direct",label:"Direct",title:"Show only zero-hop (direct RF) neighbors"}]:[]];return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-3 right-3 z-[600] map-controls-container sm:top-4 sm:right-4",children:t.jsxs("div",{className:"map-controls-row",children:[n&&t.jsx("button",{onClick:r,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:e?{backgroundColor:"#1a1408"}:void 0,title:e?"Hide neighbor lines":"Show neighbor lines","aria-label":e?"Hide neighbor lines":"Show neighbor lines","aria-pressed":e,children:t.jsx(h,{className:"map-control-icon "+(e?"text-amber-400":"text-text-secondary")})}),y.length>1&&t.jsx(NA,{options:y,value:o,onChange:i,size:"sm"}),t.jsx("button",{onClick:d,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:u?{backgroundColor:"#0a1a1a"}:void 0,title:u?"Disable 3D terrain":"Enable 3D terrain","aria-label":u?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":u,children:t.jsx(m,{className:"map-control-icon "+(u?"text-teal-400":"text-text-secondary")})}),t.jsx("button",{onClick:g,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",title:f?"Exit fullscreen":"Fullscreen","aria-label":f?"Exit fullscreen":"Enter fullscreen","aria-pressed":f,children:f?t.jsx(b,{className:"map-control-icon text-text-secondary"}):t.jsx(p,{className:"map-control-icon text-text-secondary"})})]})}),t.jsx("div",{className:"absolute top-[3.5rem] right-3 z-[600] map-controls-container sm:top-[4rem] sm:right-4 lg:top-[4.5rem]",children:t.jsxs("div",{className:"flex flex-col items-stretch map-nav-module",children:[t.jsx("button",{onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomIn()},className:"map-control-btn hover:bg-white/5 flex items-center justify-center",title:"Zoom in","aria-label":"Zoom in",children:t.jsx(x,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomOut()},className:"map-control-btn hover:bg-white/5 border-t border-white/6 flex items-center justify-center",title:"Zoom out","aria-label":"Zoom out",children:t.jsx(v,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:()=>{var e;const t=null==(e=A.current)?void 0:e.getMap();t&&t.easeTo({bearing:0,pitch:0,duration:300})},className:"map-control-btn hover:bg-white/5 border-t border-white/6 flex items-center justify-center",title:"Reset bearing to north","aria-label":"Reset bearing to north",children:t.jsx(w,{className:"map-control-icon text-text-secondary"})})]})})]})}const jA="#4ADE80",PA="DeepAnalysis";function FA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function SA({isActive:e,hasAnalyzed:r,isLoading:o,onClick:i}){const[a,l]=A.useState(!1),[c,u]=A.useState(PA),d=A.useRef(!1),f=A.useRef(null),[g]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),h=a&&!e&&!o&&g;A.useEffect(()=>{if(a&&!e&&!o&&!d.current){d.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{f.current&&cancelAnimationFrame(f.current)}},[a,e,o]);const m=o?"Analyzing...":c;return t.jsxs("button",{onClick:i,onMouseEnter:()=>g&&l(!0),onMouseLeave:()=>g&&l(!1),onPointerEnter:()=>g&&l(!0),onPointerLeave:()=>g&&l(!1),disabled:o,className:`map-control-btn flex items-center gap-2 w-full text-left transition-colors ${e?"map-control-glass-active":"map-control-glass"} ${o?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#0a1a0a":"#050505"},title:o?"Analyzing packet history...":r?e?"Hide topology edges":"Show topology edges":"Load full packet history and build topology",children:[o?t.jsx(s,{className:"w-3.5 h-3.5 flex-shrink-0 text-green-400 animate-spin"}):t.jsx(n,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-green-400":"text-text-secondary"),style:h?{color:jA}:void 0}),t.jsx("span",{className:e?"text-green-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:e||h?700:500,letterSpacing:"-0.01em",lineHeight:1,...h?{color:jA}:{}},children:m})]})}const LA="#00FFFF";function IA({isActive:e,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),d=A.useRef(!1),[f]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!e&&f;A.useEffect(()=>{g&&!d.current&&(d.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(d.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!e&&!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,e]);const h=A=>{if(e)return;if(!g)return;const t=11*i;return A>=t-2&&Af&&o(!0),onMouseLeave:()=>f&&o(!1),onPointerEnter:()=>f&&o(!0),onPointerLeave:()=>f&&o(!1),className:"map-control-btn flex items-center gap-2 w-full text-left transition-colors "+(e?"map-control-glass-active":"map-control-glass"),style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#0a2a2a":"#050505"},title:e?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[t.jsx(y,{className:"w-3.5 h-3.5 flex-shrink-0 "+(e?"text-cyan-400":"text-text-secondary"),fill:1===c?"#FFFFFF":3===c?LA:"none",stroke:1===c||2===c?"#FFFFFF":g?LA:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),t.jsx("span",{className:e?"text-cyan-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:e||g?700:500,letterSpacing:"-0.01em",lineHeight:1},children:"LiveTrace".split("").map((A,e)=>t.jsx("span",{style:{color:h(e)||void 0},children:A},e))})]})}const RA="#fe8019";function TA({isActive:e,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(()=>{if(!i||e)return;const A=requestAnimationFrame(()=>l(!0)),t=setTimeout(()=>l(!1),80);return()=>{cancelAnimationFrame(A),clearTimeout(t)}},[i,e]);const u=Math.max(.01,Math.min(1,n)),d=u<.999,f=u>.011,g=i&&!e&&c;return t.jsxs("button",{onClick:r,onMouseEnter:()=>c&&a(!0),onMouseLeave:()=>c&&a(!1),onPointerEnter:()=>c&&a(!0),onPointerLeave:()=>c&&a(!1),className:"map-control-btn flex items-center gap-2 w-full text-left transition-colors "+(e?"map-control-glass-active":"map-control-glass"),style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#1a1408":"#050505"},title:e?"Configure wardriving coverage":"Show wardriving coverage",children:[t.jsx(k,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-amber-400":"text-text-secondary"),style:g?{color:RA}:void 0}),t.jsx("span",{className:e?"text-amber-400":"text-text-secondary",style:{fontFamily:e||g?"'Jacquard 12', serif":"ui-monospace, SFMono-Regular, monospace",fontSize:e||g?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:e?"scale(1.45)":g?`scale(${s?1.595:1.45})`:void 0,transformOrigin:"left center",...g?{color:RA}:{}},children:"Wardrive"}),e&&o&&t.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[t.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.max(.01,u-.2);null==o||o(e)},disabled:!f,className:"p-0.5 rounded transition-colors "+(f?"hover:bg-[#252525] text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:t.jsx(C,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.min(1,u+.2);null==o||o(e)},disabled:!d,className:"p-0.5 rounded transition-colors "+(d?"hover:bg-[#252525] text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:t.jsx(B,{className:"w-3.5 h-3.5"})})]})]})}function _A(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 HA(A){return Math.exp(-A*Math.LN2/7)}const zA="pymc-wardriving-url",GA="pymc-wardriving-enabled",OA="pymc-wardriving-brightness";function UA(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(zA,A):localStorage.removeItem(zA))}function YA(A){"undefined"!=typeof localStorage&&localStorage.setItem(GA,String(A))}function WA(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(OA);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function VA(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 ZA=M((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(GA),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(zA)||"",brightness:WA(),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(OA,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;YA(t),A({isVisible:t})},setVisible:e=>{YA(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}=_A(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=HA(i),s=VA(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()}),UA(e.trim()),YA(!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:""}),UA(""),YA(!1)}}));function KA({status:A}){if("connecting"!==A&&"loading"!==A&&"processing"!==A)return null;const e={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[A];return e?t.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[t.jsx("div",{className:"relative",children:t.jsx(s,{className:"w-5 h-5 text-amber-400 animate-spin"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-amber-400 font-medium",children:e}),t.jsx("div",{className:"mt-2 h-1 bg-amber-500/20 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-amber-400 rounded-full transition-all duration-300",style:{width:"connecting"===A?"30%":"loading"===A?"60%":"90%"}})})]})]}):null}function JA(){const{isModalOpen:e,closeModal:n,status:i,isVisible:a,stats:l,error:c,url:u,brightness:f,loadCoverage:g,clearCoverage:h,toggleVisibility:m,setUrl:b,setBrightness:p}=ZA(),x="connecting"===i||"loading"===i||"processing"===i,[v,w]=A.useState(u),y=A.useCallback(async()=>{await g(v)},[v,g]),k=A.useCallback(()=>{w(""),h()},[h]),C=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||x||(A.preventDefault(),y())},[y,x]),M=A.useCallback(A=>{const e=A.target.value;w(e),b(e)},[b]);if(!e)return null;const S=l.coverageCount>0,L=v.trim().length>0&&!x;return t.jsxs("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-md",onClick:x?void 0:n}),t.jsxs("div",{className:"relative glass-card-elevated w-full max-w-md mx-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-amber-500/20",children:t.jsx(D,{className:"w-5 h-5 text-amber-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),t.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),t.jsx("button",{onClick:n,disabled:x,className:"p-2 rounded-lg hover:bg-[#252525] transition-colors disabled:opacity-50",children:t.jsx(E,{className:"w-5 h-5 text-text-secondary"})})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),t.jsx("input",{type:"url",value:v,onChange:M,onKeyDown:C,placeholder:"https://coverage.wcmesh.com",className:"w-full px-4 py-3 bg-black/30 border border-border rounded-xl text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500/50 transition-all disabled:opacity-50",disabled:x}),t.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:"Enter the base URL of a wardriving coverage server (e.g., coverage.wcmesh.com)"})]}),t.jsx(KA,{status:i}),"error"===i&&c&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/30 rounded-xl",children:[t.jsx(N,{className:"w-5 h-5 text-red-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-red-400 font-medium",children:"Connection Failed"}),t.jsx("p",{className:"text-xs text-red-400/80 mt-0.5",children:c})]})]}),"success"===i&&S&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-500/10 border border-green-500/30 rounded-xl",children:[t.jsx(r,{className:"w-5 h-5 text-green-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-green-400 font-medium",children:"Data Loaded Successfully"}),t.jsxs("p",{className:"text-xs text-green-400/80 mt-0.5",children:[l.coverageCount.toLocaleString()," coverage points • ",l.repeaterCount.toLocaleString()," repeaters"]})]})]}),S&&!x&&"success"!==i&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[t.jsx(Q,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-amber-400 font-medium",children:"Coverage Data Loaded"}),t.jsxs("p",{className:"text-xs text-amber-400/80 mt-0.5",children:[l.coverageCount.toLocaleString()," points •",l.lastUpdated&&` Last updated ${l.lastUpdated.toLocaleTimeString()}`]})]})]}),S&&!x&&t.jsx("div",{className:"p-3 bg-black/20 border border-border-subtle rounded-xl",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(B,{className:"w-4 h-4 flex-shrink-0 "+(f>.5?"text-amber-400":"text-text-muted")}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Brightness"}),t.jsxs("span",{className:"text-xs text-text-muted font-mono",children:[Math.round(100*f),"%"]})]}),t.jsx("input",{type:"range",min:"1",max:"100",value:100*f,onChange:A=>p(Number(A.target.value)/100),className:"w-full h-1.5 cursor-pointer accent-amber-400"})]})]})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 border-t border-border-subtle",children:[t.jsx("div",{className:"flex items-center gap-2",children:S&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:m,disabled:x,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-text-secondary hover:text-text-primary hover:bg-[#202020] rounded-lg transition-colors disabled:opacity-50",title:a?"Hide heatmap":"Show heatmap",children:a?t.jsxs(t.Fragment,{children:[t.jsx(j,{className:"w-3.5 h-3.5"})," Hide"]}):t.jsxs(t.Fragment,{children:[t.jsx(d,{className:"w-3.5 h-3.5"})," Show"]})}),t.jsxs("button",{onClick:k,disabled:x,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-50",title:"Clear coverage data",children:[t.jsx(P,{className:"w-3.5 h-3.5"})," Clear"]})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:n,disabled:x,className:"px-4 py-2 text-sm font-medium text-text-secondary hover:bg-[#252525] rounded-lg transition-colors disabled:opacity-50",children:S?"Done":"Cancel"}),t.jsx("button",{onClick:y,disabled:!L,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium bg-amber-500 hover:bg-amber-400 text-black rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:x?t.jsxs(t.Fragment,{children:[t.jsx(s,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):S?t.jsxs(t.Fragment,{children:[t.jsx(o,{className:"w-4 h-4"}),"Refresh"]}):t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}const XA={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{}}},qA=M()(mA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:bA(()=>XA)}));var $A=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,d,f,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function x(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}(f,A,e):""}function v(A,e){return A%e>0&&(A+=e-A%e),A}function w(A){u=A,t.HEAP8=d=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=f=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,w(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function N(A){D.unshift(A)}var Q=Math.abs,j=Math.ceil,P=Math.floor,F=Math.min,S=0,L=null;t.preloadedImages={},t.preloadedAudios={};var I,R,T=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return d.length}T="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|I(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|I(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return P=i,0|a}function L(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,d=0,f=0,g=0,h=0,m=0;if(a=P,P=P+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return P=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 P=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(f=1,d=0,g=0,h=1,s=A;;){if(!(d|g)){if(0|(s=0|R(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|R(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+(f<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(f<<2)>>2]=h,l=(0|(A=d+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}f=f+1|0,d=l?0:A,g=l?u?0:c:g}else for(f=1,d=0,g=0,h=1,s=A;;){if(!(d|g)){if(0|(s=0|R(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|R(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+(f<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=d+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}f=f+1|0,d=l?0:A,g=l?u?0:c:g}else s=0}while(0);return P=a,0|s}function I(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,d=0,f=0,g=0,h=0,m=0,b=0,p=0;if(u=P,P=P+16|0,l=u+8|0,c=u,d=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(d<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(f=(0|p)==(0|A)&(0|b)==(0|e))))do{d=0|$e(0|(d=0|Ve(0|d,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),f=(0|(b=0|n[(p=h=r+(d<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|f));if(d=o+(d<<2)|0,f&&(0|n[d>>2])<=(0|s))return P=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[d>>2]=s,(0|s)>=(0|t))return P=u,0;switch(f=s+1|0,n[l>>2]=0,0|(d=0|R(A,e,2,l,c))){case 9:m=9;break;case 0:(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(d=0|R(A,e,3,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,1,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,5,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,4,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,6,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}return P=u,0}}while(0);return P=u,0|d}function R(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,d=0,f=0,g=0;if((t|=0)>>>0>6)return 1;if(d=(0|n[(r|=0)>>2])%6|0,n[r>>2]=d,(0|d)>0){s=0;do{t=0|xA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(d=0|tt(0|A,0|e,45),B(),(a=127&d)>>>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,f=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&~f,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&d){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 T(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,d=0,f=0,g=0,h=0;if(i=P,P=P+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return P=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,P=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|R(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[(f=r)>>2]=g,n[f+4>>2]=e,f=t+-1|0,d=0,A=1;do{if(a=26800+(d<<2)|0,5==(0|d))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|R(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|f)){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|R(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}d=d+1|0}while(d>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return P=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=P,P=P+16|0,o=a,i=a+8|0,s=(s=!(0|HA(A|=0,e|=0)))?1:2;;){if(n[i>>2]=0,!(0|R(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)?(P=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,d,f,g,h,m,b,p,x=0,v=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,N=0,Q=0,j=0,F=0,S=0,L=0,I=0,R=0,T=0,_=0;if(p=P,P=P+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(v=0|n[(A|=0)>>2]))<=0)return P=p,0;for(u=A+4|0,d=h+8|0,f=m+8|0,g=l+8|0,x=0,F=0;;){j=(w=0|n[u>>2])+(F<<4)|0,n[h>>2]=n[j>>2],n[h+4>>2]=n[j+4>>2],n[h+8>>2]=n[j+8>>2],n[h+12>>2]=n[j+12>>2],(0|F)==(v+-1|0)?(n[m>>2]=n[w>>2],n[m+4>>2]=n[w+4>>2],n[m+8>>2]=n[w+8>>2],n[m+12>>2]=n[w+12>>2]):(j=w+(F+1<<4)|0,n[m>>2]=n[j>>2],n[m+4>>2]=n[j+4>>2],n[m+8>>2]=n[j+8>>2],n[m+12>>2]=n[j+12>>2]),v=0|tA(h,m,r,b);A:do{if(v)w=0,x=v;else if(w=0|n[(v=b)>>2],(0|(v=0|n[v+4>>2]))>0|!(0|v)&w>>>0>0){Q=0,j=0;e:for(;;){if(R=1/(+(w>>>0)+4294967296*+(0|v)),_=+o[h>>3],T=+((v=0|Ze(0|w,0|v,0|Q,0|j))>>>0)+4294967296*+(0|B()),I=+(Q>>>0)+4294967296*+(0|j),o[l>>3]=R*(_*T)+R*(+o[m>>3]*I),o[g>>3]=R*(+o[d>>3]*T)+R*(+o[f>>3]*I),0|(v=0|KA(l,r,c))){x=v;break}C=0|At(0|(E=0|n[(N=c)>>2]),0|(N=0|n[N+4>>2]),0|e,0|t),y=0|B(),w=0|n[(k=v=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|w)&!(0|k))S=v,L=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){x=1;break e}if((0|w)==(0|E)&(0|k)==(0|N))break t;if(C=0|$e(0|(v=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|(w=0|n[(k=v=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){S=v,L=16;break}}}while(0);if(16!=(0|L)||(L=0,!(0|E)&!(0|N))||(n[(D=S)>>2]=E,n[D+4>>2]=N,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=N,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(N=i)>>2]=D,n[N+4>>2]=E),Q=0|Ve(0|Q,0|j,1,0),j=0|B(),w=0|n[(v=b)>>2],!((0|(v=0|n[v+4>>2]))>(0|j)|(0|v)==(0|j)&w>>>0>Q>>>0)){w=1;break A}}w=0}else w=1}while(0);if(F=F+1|0,!w){L=21;break}if((0|F)>=(0|(v=0|n[A>>2]))){x=0,L=21;break}}return 21==(0|L)?(P=p,0|x):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=P,P=P+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),P=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,d,f,g,h=0,m=0,b=0,p=0,v=0,y=0,k=0;f=P,P=P+288|0,d=f+264|0,p=f+96|0,m=(h=b=f)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(P=f,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],d),$A(b,m,p),u=+ae(d,p+8|0),o[d>>3]=+o[A>>3],o[(m=d+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(d,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[d>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+x(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,v=~~k>>>0,y=+l(k)>=1?k>0?~~+w(+s(k/4294967296),4294967295)>>>0:~~+x((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|v)&!(0|y),n[(e=t)>>2]=p?1:v,n[e+4>>2]=p?0:y,e=0):e=1,P=f,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,d,f=0,g=0,h=0;d=P,P=P+288|0,c=d+264|0,u=d+96|0,a=(f=g=d)+96|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|a));return 0|(t=0|Ae(t,g))?(P=d,0|(r=t)):(qA(f=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(f,t,u),h=+ae(c,u+8|0),h=+x(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,f=+l(h)>=1?h>0?~~+w(+s(h/4294967296),4294967295)>>>0:~~+x((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|f),n[r>>2]=g?1:t,n[r+4>>2]=g?0:f,P=d,0|(r=0)):(P=d,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|v(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|v(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|v(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 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*+((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 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*+(((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 xA(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 vA(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 wA(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|IA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=P,P=P+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=P,P=P+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return P=r,-1;if(1==(0|t)&(o=!!(0|o)))return P=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 P=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,P=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)?NA(r,e,i,2,t):FA(r,e,i,2,t),P=o,0|(a=0))):(P=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=+d(+t),t=+f(+t),e=s*+f(+e)+ +d(+a)*(t*+d(+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/+d(+e),a=t*+f(+a)*c,t=+o[A>>3],e=c*((s-+f(+e)*+f(+t))/+d(+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 NA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,d,f,g,h,m,b,p,x,v,w,y,k,C,B,D,E,N,Q=0,j=0,F=0,S=0,L=0,I=0;if(N=P,P=P+272|0,S=N+240|0,B=N,D=N+224|0,E=N+208|0,b=N+176|0,p=N+160|0,x=N+192|0,v=N+144|0,w=N+128|0,y=N+112|0,k=N+96|0,C=N+80|0,n[(Q=N+256|0)>>2]=e,n[S>>2]=n[A>>2],n[S+4>>2]=n[A+4>>2],n[S+8>>2]=n[A+8>>2],n[S+12>>2]=n[A+12>>2],QA(S,Q,B),n[i>>2]=0,(0|(S=r+t+(5==(0|r)&1)|0))<=(0|t))P=N;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[Q>>2])<<2)|0,d=16960+(a<<2)|0,f=w+8|0,g=y+8|0,h=k+8|0,m=E+4|0,F=t;A:for(;;){j=B+((0|F)%5<<4)|0,n[E>>2]=n[j>>2],n[E+4>>2]=n[j+4>>2],n[E+8>>2]=n[j+8>>2],n[E+12>>2]=n[j+12>>2];do{}while(2==(0|jA(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],Q=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*Q|0)>>2],(0|(j=0|n[18640+(80*r|0)+(20*Q|0)+16>>2]))>0){A=0;do{bA(l),A=A+1|0}while((0|A)<(0|j))}switch(j=18640+(80*r|0)+(20*Q|0)+4|0,n[x>>2]=n[j>>2],n[x+4>>2]=n[j+4>>2],n[x+8>>2]=n[j+8>>2],sA(x,3*(0|n[u>>2])|0),iA(l,x,l),nA(l),oA(l,v),L=+(0|n[d>>2]),o[w>>3]=3*L,o[f>>3]=0,I=-1.5*L,o[y>>3]=I,o[g>>3]=2.598076211353316*L,o[k>>3]=I,o[h>>3]=-2.598076211353316*L,0|n[17040+(80*(0|n[b>>2])|0)+(n[E>>2]<<2)>>2]){case 1:A=y,r=w;break;case 3:A=k,r=y;break;case 2:A=w,r=k;break;default:A=12;break A}Qe(p,v,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|S)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):P=N}}function QA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=P,P=P+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,wA(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),P=r}function jA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,d=0,f=0,g=0,h=0;if(c=P,P=P+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[(d=A+12|0)>>2])|0))==(0|g))return P=c,1;f=d}else u=o+u+(r=0|n[(f=A+12|0)>>2])|0;if((0|u)<=(0|g))return P=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){d=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),d=r,r=A):(d=r,r=A)}else d=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[d>>2],(0|n[(u=d+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=d+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[f>>2])|0)==(0|g)?1:2,P=c,0|r}function PA(A,e){A|=0,e|=0;var t=0;do{t=0|jA(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,d,f,g,h,m,b,p,x,v,w,y,k,C,B=0,D=0,E=0,N=0,Q=0;if(C=P,P=P+240|0,v=C+208|0,w=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,x=C+96|0,n[(B=C+224|0)>>2]=e,n[v>>2]=n[A>>2],n[v+4>>2]=n[A+4>>2],n[v+8>>2]=n[A+8>>2],n[v+12>>2]=n[A+12>>2],SA(v,B,w),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))P=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,d=p+8|0,f=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=w+((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|jA(y,a,0,1),(0|E)>(0|t)&!!(0|ZA(e))&&1!=(0|A)&&(0|n[y>>2])!=(0|r)){switch(oA(w+((B+5|0)%6<<4)+4|0,k),oA(w+(B<<4)+4|0,h),N=+(0|n[l>>2]),o[m>>3]=3*N,o[c>>3]=0,Q=-1.5*N,o[b>>3]=Q,o[u>>3]=2.598076211353316*N,o[p>>3]=Q,o[d>>3]=-2.598076211353316*N,B=0|n[v>>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}Qe(k,h,r,A,x),0|je(k,x)||0|je(h,x)||(EA(x,0|n[v>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(f,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):P=C}}function SA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=P,P=P+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,wA(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),P=r}function LA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function IA(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 RA(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 TA(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|xA(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|xA(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|xA(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|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(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|vA(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|vA(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=P,P=P+16|0,i=r,(e|=0)>>>0>15?(P=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=P,P=P+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=P,P=P+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=P,P=P+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+d(+n),n=+f(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+d(+n),o[e>>3]=r,n=t*+f(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Pe(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Pe(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Pe(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Pe(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Pe(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Pe(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Pe(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Pe(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Pe(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Pe(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Pe(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Pe(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Pe(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Pe(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Pe(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Pe(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Pe(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Pe(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Pe(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Pe(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,P=i):P=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(P=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=+d(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+f(+n),t=+o[A>>3],+ +p(+a,+(+f(+i)*+d(+t)-+d(+n)*(r*+f(+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=+d(+l)*a,o[r>>3]=s,l=+f(+l)*a,o[r+8>>3]=l,P=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,d=0,f=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],d=+l(+r),i=+o[A+8>>3],d+=.5*(f=1.1547005383792515*+l(+i)),d-=+(0|(s=~~d)),f-=+(0|(A=~~f));do{if(d<.5){if(d<.3333333333333333){if(n[e>>2]=s,f<.5*(d+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(f<(h=1-d)))+A|0,n[e+4>>2]=A,h<=f&f<2*d){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(d<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,f<.5*d){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(f<1-d){if(n[e+4>>2]=A,2*d-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),P=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=P,P=P+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)),P=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),P=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?(dA(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)):(fA(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|xA(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|vA(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|xA(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)),P=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),P=r,0|(i=0)):(P=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=P,P=P+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,P=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|vA(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 P=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|jA(t,s,i,0)){if(0|z(u))do{}while(0|jA(t,s,0,0));(0|s)!=(0|c)&&fA(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 P=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=P,P=P+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(P=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=P,P=P+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),P=r}(r,15&i,t),P=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=P,P=P+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return P=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 NA(i,o,0,5,t),P=r,0}}while(0);return FA(i,o,0,6,t),P=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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+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,x=0;return x=+o[(e|=0)>>3],i=+o[A>>3],m=+f(.5*(x-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+f(.5*(u-n)),r=+d(+i),a=+d(+x),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],x=+f(.5*(m-x)),s=+o[t+8>>3],u=+f(.5*(s-u)),l=+d(+m),u=2*+p(+ +c(+(u=x*x+u*(a*l*u))),+ +c(+(1-u))),m=+f(.5*(i-m)),s=+f(.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=P,P=P+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return P=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,P=a,0}function de(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 fe(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,d=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],d=0|n[(t=t+16|0)>>2],a=+o[(d=0|d?d:A)>>3],l=+o[d+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],d=0|n[(t=t+16|0)>>2],a=+o[(d=0|d?d:A)>>3],l=+o[d+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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(c=P,P=P+32|0,v=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 P=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 P=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(f=0|V(h,m))))return P=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=f,d=g)}else p=0,d=0;a=0|z(h),s=0|z(m),n[v>>2]=0,n[v+4>>2]=0,n[v+8>>2]=0,n[v+12>>2]=0;do{if(p){if(f=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(f){h=0,g=t,f=o;do{g=0|WA(g,f),f=0|B(),1==(0|(d=0|vA(d)))&&(d=0|vA(1)),h=h+1|0}while((0|h)!=(0|m));m=d,h=g,g=f}else m=d,h=t,g=o;else if(f){h=0,g=t,f=o;do{g=0|VA(g,f),f=0|B(),d=0|vA(d),h=h+1|0}while((0|h)!=(0|m));m=d,h=g,g=f}else m=d,h=t,g=o;if(JA(h,g,v),b||M(27563,27538,191,27548),(f=!!(0|a))&(d=!!(0|s))&&M(27590,27538,192,27548),f){if(7==(0|(d=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*d|0)+p|0]){u=1;break}h=g=0|n[21168+(28*d|0)+(p<<2)>>2]}else if(d){if(7==(0|(d=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*d|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(d<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){f=v+4|0,d=0;do{pA(f),d=d+1|0}while((0|d)!=(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(x=v+4|0,l,x),nA(x),x=51}}else if(JA(t,o,v),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(d=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*d|0)+u|0])u=1;else if((0|(d=0|n[21168+(28*d|0)+(u<<2)>>2]))>0){f=v+4|0,u=0;do{pA(f),u=u+1|0}while((0|u)!=(0|d));x=51}else x=51;else x=51}while(0);return 51==(0|x)&&(u=v+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),P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(a=P,P=P+48|0,o=a+36|0,c=a+24|0,u=a+12|0,d=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 P=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)))?(P=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,P=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,d),nA(d),x=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(v=3*(15-l|0)|0)),s&=~B(),v=0|rt(0|lA(d),0,0|v),s=0|B()|s,n[(b=r)>>2]=v|x&~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){d=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|xA(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,f=s)}else m=s,h=0,f=t;if((0|(u=0|n[4272+(28*g|0)+(f<<2)>>2]))<=-1&&M(27724,27538,419,27678),!d){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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=l,n[v+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|d)){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[(v=r)>>2]=c,n[v+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)&&d&&(t=59),59==(0|t)&&1==(0|OA(0|n[(v=r)>>2],0|n[v+4>>2]))){s=9;break}p=0|n[(v=r)>>2],v=-1040385&n[v+4>>2],x=0|rt(0|s,0,45),v=0|v|B(),n[(s=r)>>2]=p|x,n[s+4>>2]=v,s=0}else s=1}while(0);return P=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 xe(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,f=0;i=P,P=P+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/+d(+u),f=+o[25968+(l<<3)>>3],o[t>>3]=u+f,o[t+8>>3]=u-f,u=+o[s+8>>3],c*=f,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return P=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return P=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]?(P=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,P=i,0|(l=0))}function ve(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0;if(i=P,P=P+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))P=i;else{if(0|r[0|(a=A+28|0)]?(s=0|we(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(P=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))w=A+24|0;else{x=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,d=3==(2|c),f=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[x>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){v=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){v=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)){v=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){v=29;break}}if(h){if(0|(c=0|$A(s,l,e))){v=32;break}if(0|xe(s,l,t,0)){v=36;break}if(d&&0|De(0|n[o>>2],0|n[p>>2],e,t)){v=42;break}if(g&&0|Ne(0|n[o>>2],0|n[p>>2],e,t)){v=42;break}}if(b){if(a=0|xe(s,l,e,1),c=0|n[p>>2],0|a){v=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){v=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],f)){v=53;break}if(0|Ne(0|n[o>>2],0|n[p>>2],t,e)){v=53;break}}}}do{if((0|u)<(0|n[x>>2])){if(a=0|xe(s,l,e,1),c=0|n[p>>2],0|a){v=58;break e}if(!(0|q(c,e))){v=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){v=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){v=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else v=73}while(0);if(73==(0|v)&&(v=0,s=0|we(s,l),l=0|B()),!(0|s)&!(0|l)){w=p;break A}}switch(0|v){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,v=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,v=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(P=i);case 32:return 0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(P=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,v=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,v=55;break;case 58:0|c&&Ye(c),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,v=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,v=71;break;case 67:return 0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(P=i)}if(20==(0|v))return void(P=i);if(55==(0|v))return void(P=i);if(71==(0|v))return void(P=i)}}while(0);0|(a=0|n[w>>2])&&Ye(a),n[(v=A)>>2]=0,n[v+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[y>>2]=0,n[w>>2]=0,P=i}}function we(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,d=0;t=P,P=P+16|0,d=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 d=0|rt(((d=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,d|=A&~s,C(0|u),P=t,0|d}}while(0);return(r&=127)>>>0>120?(d=0,C(0|(u=0)),P=t,0|d):(RA(d,0,r+1|0,0),u=0|n[d+4>>2],d=0|n[d>>2],C(0|u),P=t,0|d)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,d=0,f=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,f=a,t=-1,A=0;A:for(;;){for(d=A;l=+o[r+(d<<4)>>3],a=+o[r+(d<<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=d+1|0))>=(0|g)){t=22;break A}A=d,d=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)>(f=c==f|l==f?f+-2220446049250313e-31:f)&&(e^=1),(0|(A=d+1|0))>=(0|g)){t=22;break}t=d}if(22==(0|t))return 0|e}else{e=0,f=a,t=-1,A=0;A:for(;;){for(d=A;l=+o[r+(d<<4)>>3],a=+o[r+(d<<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=d+1|0))>=(0|g)){t=22;break A}A=d,d=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(f=l==f|a==f?f+-2220446049250313e-31:f)&&(e^=1),(0|(A=d+1|0))>=(0|g)){t=22;break}t=d}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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=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,x=0,A=-1,f=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,v=0;c=+o[t+(v<<4)>>3],h=+o[t+(v<<4)+8>>3],d=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,f=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,x|=+l(+(h-d))>3.141592653589793,(0|(A=v+1|0))!=(0|r);)w=v,m=c,v=A,A=w;x&&(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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(x=e+8|0)>>3]=17976931348623157e292,o[(v=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(w=e+16|0)>>3]=-17976931348623157e292,(0|p)>0){for(a=0|n[A+4>>2],m=17976931348623157e292,b=-17976931348623157e292,i=0,r=-1,d=17976931348623157e292,f=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,d=s),g>3]=g,f=g),s>h?o[e>>3]=s:s=h,g>c&&(o[w>>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[w>>3]=b,o[v>>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,v=e+((C=C+1|0)<<5)|0,w=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[v>>3]=-17976931348623157e292,o[(k=e+(C<<5)+16|0)>>3]=-17976931348623157e292,(0|w)>0){for(p=0|n[a+(i<<3)+4>>2],m=17976931348623157e292,b=-17976931348623157e292,a=0,i=-1,x=0,d=17976931348623157e292,f=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(x<<4)>>3],h=+o[p+(x<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|w)?0:i)<<4)+8>>3],s>3]=s,d=s),h>3]=h,f=h),s>g?o[v>>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=x+1|0))!=(0|w);)M=x,x=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[v>>2]=0,n[v+4>>2]=0,n[v+8>>2]=0,n[v+12>>2]=0,n[v+16>>2]=0,n[v+20>>2]=0,n[v+24>>2]=0,n[v+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=P,P=P+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return P=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 P=i,0|a}}while(0);if(0|Ee(A,e,t,r))return P=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 P=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,M=0;if(u=P,P=P+176|0,l=u+172|0,d=u+168|0,c=u,!(0|q(e|=0,r|=0)))return P=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,d),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[d>>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[d>>2]),i=+ie(+o[r+24>>3],0|n[d>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(d=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],v=+o[e+(t<<4)>>3],w=+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,f=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(v>=a)|!(f>=a)&&!(v<=s)|!(f<=s)&&!(w<=i)|!(g<=i)&&!(w>=y)|!(g>=y)){x=f-v,b=g-w,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|d)?0:e,f=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-f,h=+o[c+8+(M<<4)>>3],!(0==(p=x*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=w-f,C=v-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(x*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|d))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return P=u,0|e}function Ne(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 Qe(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,d,f=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],f=((f=+o[r>>3]-u)*(a-(d=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-d))/(s*c-i*f),o[n>>3]=l+s*f,o[n+8>>3]=a+i*f}function je(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 Pe(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=P,P=P+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return P=a,0|s;r=0|LA(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,P=a,0}function Se(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(l=P,P=P+32|0,v=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 P=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 P=l,1;if(0|Fe(A,e,v))return P=l,1;if(u=(0|n[v>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return P=l,1;n[s>>2]=0,c=0|R(A,e,p,s,a);do{if(!c){if(h=0|n[(f=a)>>2],u=(d=(f=0|n[f+4>>2])>>>0>>0|(0|f)==(0|e)&h>>>0>>0)?h:A,d=d?f:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(f&(0|B())))c=t;else{if(f=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|f)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|f)&&M(27795,27797,248,27822),0|Fe(A,e,v)&&M(27795,27797,248,27822),c=(0|n[v>>2])+f|0,7==(0|(f=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|R(A,e,f,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|d)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(f<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,d=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,d=h;break}do{if(!(0|Fe(g,h,v))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[v>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[v>>2])|0)%6|0;break}c=-1}while(0);u=g,d=h}else c=t}while(0);h=0|n[(f=a)>>2],f=0|n[f+4>>2]}if((0|u)==(0|h)&(0|d)==(0|f)){if(A=(g=!!(0|HA(h,f)))?0|_(h,f,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,f),(A+-1|0)>>>0<=5&&!(1==(0|A)&(x=!!(0|c))))do{if(!(0|Fe(h,f,v))){if(x){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[v>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[v>>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=d,A=u;break A}}while(0);return P=l,0|c}}while(0);return x=0|rt(0|c,0,56),v=B()|-2130706433&e|536870912,n[r>>2]=x|A,n[r+4>>2]=v,P=l,0}function Le(A,e){A|=0;var t,r,o=0,i=0;return r=P,P=P+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|IA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Se(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,P=r,0|o):(P=r,0|(o=0))}function Ie(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 Re(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 Te(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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0;e=P,P=P+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(f=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]=f&~(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],P=e,0|i;if(u>>>0>(d=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=f&~(1<>2]=t,n[A>>2]=r,A=f),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|d&&(o=0|n[6986],r=27964+((t=d>>>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,P=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|d&&(o=0|n[6986],r=27964+((t=d>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|f,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),P=e,0|l+8}f=u}else f=u}else f=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<<(f=(A+1048320|0)>>>16&8))|0)>>>16&4)|f|(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=f>>>12&16)>>>5&8)|s|(l=(f>>>=a)>>>2&4)|(c=(f>>>=l)>>>1&2)|(r=(f>>>=c)>>>1&1))+(f>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(f=(-8&n[a+4>>2])-u|0)>>>0>>0)?f: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&&(d=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[d+4>>2]=1|s,n[d+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]=d,n[t+12>>2]=d,n[d+8>>2]=t,n[d+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(r=(245760+(y<<=v)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[d+28>>2]=r,n[4+(A=d+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=d,n[d+24>>2]=t,n[d+12>>2]=d,n[d+8>>2]=d;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]=d,n[d+24>>2]=t,n[d+12>>2]=d,n[d+8>>2]=d;break A}}while(0);y=0|n[(w=t+8|0)>>2],n[y+12>>2]=d,n[w>>2]=d,n[d+8>>2]=y,n[d+12>>2]=t,n[d+24>>2]=0}}while(0);return P=e,0|l+8}f=u}else f=u;else f=-1}while(0);if((r=0|n[6983])>>>0>=f>>>0)return t=r-f|0,A=0|n[6986],t>>>0>15?(y=A+f|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|f):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),P=e,0|A+8;if((s=0|n[6984])>>>0>f>>>0)return v=s-f|0,n[6984]=v,w=(y=0|n[6987])+f|0,n[6987]=w,n[w+4>>2]=1|v,n[y+4>>2]=3|f,P=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=f+48|0,(u=(a=A+(c=f+47|0)|0)&(i=0-A|0))>>>0<=f>>>0)return P=e,0;if(0|(A=0|n[7091])&&(g=(d=0|n[7089])+u|0)>>>0<=d>>>0|g>>>0>A>>>0)return P=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>f>>>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|(v=0|ut(0|u)))|1^(x=(p=(m=0|ut(0))-v|0)>>>0>(f+40|0)>>>0)|v>>>0>>0&-1!=(0|v)&-1!=(0|m)^1)&&(s=x?p:t,a=v,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)||(w=t+4|0,8&n[t+12>>2]))&&a>>>0>c>>>0&A>>>0<=c>>>0){n[w>>2]=r+s,w=c+(v=7&(v=c+8|0)?0-v&7:0)|0,v=(y=(0|n[6984])+s|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,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[(d=t+4|0)>>2]=(0|n[d>>2])+s,u=(d=a+(7&(d=a+8|0)?0-d&7:0)|0)+f|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-d-f|0,n[d+4>>2]=3|f;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-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=v)|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[(w=t+8|0)>>2],n[y+12>>2]=u,n[w>>2]=u,n[u+8>>2]=y,n[u+12>>2]=t,n[u+24>>2]=0}}while(0);return P=e,0|d+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,w=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(r=s+-40|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,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{w=t,n[(t=t+4|0)>>2]=7}while((w+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-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=v)|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[(w=t+8|0)>>2],n[y+12>>2]=c,n[w>>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,w=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(y=s+-40|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>f>>>0)return v=t-f|0,n[6984]=v,w=(y=0|n[6987])+f|0,n[6987]=w,n[w+4>>2]=1|v,n[y+4>>2]=3|f,P=e,0|y+8}return n[(y=27920)>>2]=12,P=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|v(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,d=0,f=0,g=0,h=0;if(u=A|=0,a=t|=0,s=f=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|(f=0)),o)):(o=0,0|(C(0|(f=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(f=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=d=i+1|0,A=u>>>(d>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(d>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(f=0)),o)):(o=0,0|(C(0|(f=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(d=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=d>>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|(d=0|t),0|(u=f|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|(f=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|f,g&d|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|v(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|v(o,r=A>>>16))|0,e=0|v(o=e>>>16,n),0|(C((A>>>16)+(0|v(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|v(e,o))+(0|v(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=P,P=P+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(),P=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=P,P=P+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),P=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):+x(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return N(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):+x(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?(j(0|e),D(12),-1):(0|e)>(0|r)&&!(0|Q(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,d=0;if(s=P,P=P+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return P=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,P=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,d=0|tt(0|t,0|r,52),B(),(0|c)!=(15&d))return P=s,12;if(l=c+-1|0,c>>>0>1){TA(A,e,l,a),TA(t,r,l,i),u=0|n[(d=a)>>2],d=0|n[d+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|d)==(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,d)){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 P=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,P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0;if(o=P,P=P+16|0,p=o,x=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return P=o,4;if((0|(x&=15))<(0|t))return P=o,12;if((0|x)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|x)>(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|x));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|x)>(0|t)){for(m=-15728641&e,h=x;;){if(g=h,(h=h+-1|0)>>>0>15|(0|x)<(0|h)){u=19;break}if((0|x)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|x)<(0|g))f=a;else{u=h;do{f=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=f,c=0|B()|c}while((0|u)<(0|x));f=a}else f=A,c=e;if(d=0|tt(0|f,0|c,45),B(),0|z(127&d)){d=0|tt(0|f,0|c,52),B(),d&=15;e:do{if(d)for(u=1;;){if(a=0|tt(0|f,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|(f=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=x-g|0,((0|u)<0)<<31>>31),d=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|d,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=d),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|d,0|(g=f+-1|0),((0|g)<0)<<31>>31)),0|B()),d=0|Ve(0|g,0|(f=0|B()),0|n[(d=r)>>2],0|n[d+4>>2]),f=0|B(),n[(g=r)>>2]=d,n[g+4>>2]=f),(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 P=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|x)>(0|t)){for(a=x;;){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=x-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 P=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,x,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(x=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[x>>2])>>>0>s>>>0:0))?(P=o,0|(x=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=P,P=P+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 P=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 P=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=P,P=P+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),P=s,0|A},_cellToParent:TA,_cellToVertex:Se,_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|Se(A,e,0,t))),i?r?0|(o=0|Se(A,e,1,t+8|0))||0|(o=0|Se(A,e,2,t+16|0))||0|(o=0|Se(A,e,3,t+24|0))||(o=0|Se(A,e,4,t+32|0))?0|(i=o):0|Se(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Se(A,e,1,t+8|0))||0|(o=0|Se(A,e,2,t+16|0))||0|(o=0|Se(A,e,3,t+24|0))||0|(o=0|Se(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=P,P=P+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=P,P=P+176|0,r=o,(0|(e|=0))<1)return Ie(t,0,0),P=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Ie(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)?(P=o,0|i):(Re(t),P=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return P=a,0|A;if(n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,0|(A=0|Te(i)))do{e=0|de(t);do{fe(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|Te(i)}while(0|A);return Re(i),(A=0|function(A){var e,t,r=0,i=0,a=0,s=0,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,D=0,E=0,N=0,Q=0,j=0,P=0,F=0,S=0,L=0,I=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,S=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(f=+o[u+8>>3],r=u,u=0|n[u+16>>2],d=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(f-d))>3.141592653589793){I=14;break}c+=(d-f)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|I)){I=0,c=0,r=h;do{B=+o[r+8>>3],P=0|n[(F=r+16|0)>>2],C=+o[(P=0|P?P:h)+8>>3],c+=(+o[r>>3]+ +o[P>>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+(S<<2)>>2]=a,S=S+1|0,s=D,r=m):I=19}else I=19;if(19==(0|I)){I=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){I=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){I=21;break A}if(!(i=0|We(1,12))){I=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,f=17976931348623157e292,v=17976931348623157e292,w=-17976931348623157e292,d=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((x=!(0|p))?g:p)+8>>3],c>3]=c,f=c),B>3]=B,v=B),c>w?o[u>>3]=c:c=w,B>d&&(o[b>>3]=B,d=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!x;)w=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){I=45;break}D=s,m=r}if(21==(0|I))M(27213,27235,35,27247);else if(23==(0|I))M(27267,27235,37,27247);else if(27==(0|I))M(27310,27235,61,27333);else if(45==(0|I)){A:do{if((0|S)>0){for(F=!(0|s),j=s<<2,P=!(0|A),Q=0,r=0;;){if(N=0|n[t+(Q<<2)>>2],F)I=73;else{if(!(D=0|Ue(j))){I=50;break}if(!(E=0|Ue(j))){I=52;break}e:do{if(P)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[N>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,x=i+1|0):x=i,u=0|n[u+8>>2];)s=s+1|0,i=x;if((0|x)>0)if(a=0|n[D>>2],1==(0|x))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|x);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|x))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]){I=70;break}n[i>>2]=N,n[s>>2]=N}else I=73}if(73==(0|I)){if(I=0,0|(r=0|n[N>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(N),r=1}if((0|(Q=Q+1|0))>=(0|S)){L=r;break A}}50==(0|I)?M(27452,27235,249,27471):52==(0|I)?M(27490,27235,252,27471):70==(0|I)&&M(27310,27235,61,27333)}else L=0}while(0);return Ye(t),Ye(e),0|L}return 0}(t))?(ge(t),P=a,0|(s=A)):(P=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,d=0,f=0,g=0,h=0,m=0;if(a=P,P=P+16|0,s=a,(o|=0)>>>0>15)return P=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return P=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[(d=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[d>>2])>>>0>A>>>0:0))))return P=a,2;d=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|d)<1)return P=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=d-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[(f=i)>>2],f=0|n[f+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),f&=~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),f=0|B()|f,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=f,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],f=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&~f,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|d)>(0|c))){e=0;break}r=~c,c=c+1|0}return P=a,0|e}}while(0);if((0|d)<1)return P=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=d-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|(f=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|f,0|g,0|h,0|m)),0|B()),e=0|B(),(0|d)<=(0|s)){e=0;break}s=s+1|0}return P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,D=0,E=0,N=0,Q=0,j=0,P=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[(P=e)>>2]=a,n[P+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{j=0|n[4+(Q=A+(i<<3)|0)>>2],n[(P=e+(i<<3)|0)>>2]=n[Q>>2],n[P+4>>2]=j,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(!(j=0|Ue(o=t<<3)))return 13;if(st(0|j,0|A,0|o),!(Q=0|We(t,8)))return Ye(j),13;A:for(;;){E=0|tt(0|(u=0|n[(i=j)>>2]),0|(i=0|n[i+4>>2]),52),B(),N=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(v=0|rt(0|N,0,52),w=0|B(),N>>>0>15){if(!(!(0|u)&!(0|i))){P=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=j+(a<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))){i=s,P=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){P=21;break A}if(d=0|tt(0|l,0|A,52),B(),(0|(d&=15))<(0|N)){i=12,P=27;break A}if((0|d)!=(0|N)&&(l|=v,A=-15728641&A|w,d>>>0>=E>>>0)){c=N;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|(f=0|n[(d=c=Q+(g<<3)|0)>>2]))&!(0|(d=0|n[d+4>>2])))){p=0,x=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&x>>>0>t>>>0){P=31;break A}if((0|f)==(0|l)&(-117440513&d)==(0|A)){m=0|tt(0|f,0|d,56),B(),b=1+(m&=7)|0,k=0|tt(0|f,0|d,45),B();t:do{if(0|z(127&k)){if(f=0|tt(0|f,0|d,52),B(),!(f&=15)){d=6;break}for(d=1;;){if(!(!((k=0|rt(7,0,3*(15-d|0)|0))&l)&!((0|B())&A))){d=7;break t}if(!(d>>>0>>0)){d=6;break}d=d+1|0}}else d=7}while(0);if((m+2|0)>>>0>d>>>0){P=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();x=0|Ve(0|x,0|p,1,0),p=0|B(),f=0|n[(d=c=Q+(g<<3)|0)>>2],d=0|n[d+4>>2]}while(!(!(0|f)&!(0|d)))}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=j+(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){P=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){P=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=d=Q+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{f=0|tt(0|a,0|s,56),B(),l=1+(f&=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=d)>>2]=a,n[l+4>>2]=s,l=f+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(x=N>>>0>15,v=0|rt(0|N,0,52),w=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(N=e+(a<<3)|0)>>2]=u,n[N+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=j+(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(),x|(0|(h&=15))<(0|N)){P=80;break A}if((0|h)!=(0|N)){if(d=u|v,f=-15728641&i|w,h>>>0>=E>>>0){g=N;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,d|=D,f=0|B()|f}while(g>>>0>>0)}}else d=u,f=i;m=0|At(0|d,0|f,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){P=81;break A}if((-117440513&(b=0|n[4+(D=Q+(m<<3)|0)>>2]))==(0|f)&&(0|n[D>>2])==(0|d)){P=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=Q+(m<<3)|0}while((0|n[D>>2])!=(0|d)||(0|n[D+4>>2])!=(0|f));if(65==(0|P)&&(P=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=j+(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|Q,0,0|o),st(0|j,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){P=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|P))!0&!(117440512&i)?(i=4,P=27):P=21;else if(31==(0|P))M(27795,27122,620,27132);else{if(41==(0|P))return Ye(j),Ye(Q),10;if(48==(0|P))return Ye(j),Ye(Q),13;80==(0|P)?M(27795,27122,711,27132):81==(0|P)?M(27795,27122,723,27132):85==(0|P)&&(st(0|e,0|j,t<<3),P=89)}return 21==(0|P)?(Ye(j),Ye(Q),0|(P=5)):27==(0|P)?(Ye(j),Ye(Q),0|(P=i)):89==(0|P)?(Ye(j),Ye(Q),0|(P=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=P,P=P+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|R(A,o,7&e,a,t+8|0),P=r,0|a):(P=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=P,P=P+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,P=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,P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+g)*+d(+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,P=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=P,P=P+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,P=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,P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+g)*+d(+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,P=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=P,P=P+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return P=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+i)*+d(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,P=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:LA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=P,P=P+16|0,n[(i=r)>>2]=0,!0&268435456==(2013265920&e)?(o=0|tt(0|A,0|e,56),B(),i=0|R(A,-2130706433&e|134217728,7&o,i,t),P=r,0|i):(P=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,d=0,f=0;o=P,P=P+128|0,d=o+112|0,s=o+96|0,f=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[d>>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),f=B()|-15728641&t,f=0|A((u|e)&~(d=0|rt(7,0,3*(14-c|0)|0)),f&~B(),r),P=o,0|f;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(QA(s,d,f),u=5):(SA(s,d,f),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(PA(l=f+(s<<4)|0,0|n[d>>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(jA(l=f+(s<<4)|0,0|n[d>>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 P=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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:F,_gridDiskDistances:S,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=P,P=P+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(P=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(P=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,D=0,E=0;if(a=P,P=P+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],x=g*+((0|n[c>>2])-t|0),r=0|n[(v=i+4|0)>>2],w=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=x*(d=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=w*d+ +(0|r),d=g*d+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+d),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),d=+l(+(+(0|s)-d));do{if(!(E>u&E>d)){if(f=0-t|0,u>d){r=f-s|0;break}r=c,s=f-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[v>>2],s=0|n[y>>2]}}while(0);return P=a,0|s}return P=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=P,P=P+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))?(P=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,P=i,0|(l=0))},_gridRing:function(A,e,t,r){return 0|T(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,d=0,f=0;if(o=P,P=P+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,P=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 d=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|d,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(d=s)>>2]=i,n[d+4>>2]=a;if(u=0|We(i,8)){if(!(d=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|I(A,e,t,u,d,i,a,0))){Ye(u),Ye(d);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[d+(l<<2)>>2])!=(0|t)||(n[(f=r+(i<<3)|0)>>2]=a,n[f+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(d),i=0}else i=13}else i=2}while(0);return P=o,0|i}(A,e,t,r))):0|(r=0)},_gridRingUnsafe:T,_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:IA,_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|Le(A,e)))},_isValidVertex:Le,_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=P,P=P+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)),P=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=P,P=P+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return P=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 P=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,f=0,g=0,h=0,m=0,b=0,p=0;if(s=P,P=P+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,P=s,0;RA(h,0,0,0),c=0|n[(f=h)>>2],f=0|n[f+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]=f,n[(f=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/+d(+ +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(ve(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,ve(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[f>>2]}}while(0);return P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,N=0,Q=0,j=0,F=0,S=0,R=0,T=0,_=0;if(s=P,P=P+112|0,o=s+80|0,f=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return P=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return P=s,13;if(Be(A,_),!(l=0|Ce(t))){if(T=0|n[(R=A)+4>>2],n[(l=f)>>2]=n[R>>2],n[l+4>>2]=T,ke(f,o),l=0|eA(o,e,i))R=0,T=0;else{if(l=0|n[f>>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,R=0|Ve(0|t,0|l,12,0),T=0|B(),n[(l=i)>>2]=R,n[l+4>>2]=T,l=0}if(!l){if(!(t=0|We(R,8)))return Ye(_),P=s,13;if(!(d=0|We(R,8)))return Ye(_),Ye(t),P=s,13;n[(F=o)>>2]=0,n[F+4>>2]=0,S=0|n[(F=A)+4>>2],n[(l=f)>>2]=n[F>>2],n[l+4>>2]=S,l=0|H(f,R,T,e,o,t,d);A:do{if(l)Ye(t),Ye(d),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,R,T,e,o,t,d),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(d),Ye(_);break A}}while(0);(0|T)>0|!(0|T)&R>>>0>0&<(0|d,0,R<<3),F=0|n[(S=o)+4>>2];e:do{if((0|F)>0|!(0|F)&(0|n[S>>2])>>>0>0){N=t,Q=d,j=t,F=d,S=t,l=t,M=t,D=d,E=d,t=d;t:for(;;){for(w=0,y=0,k=0,C=0,c=0,u=0;;){f=(d=i)+56|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|f));if(0|L(g=0|n[(e=N+(w<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){f=(d=i)+56|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|f));0|(d=0|We(7,4))&&(I(g,e,1,i,d,7,0,0),Ye(d))}for(v=0;;){p=0|n[(x=i+(v<<3)|0)>>2],x=0|n[x+4>>2];r:do{if(!(0|p)&!(0|x))d=c,f=u;else{if(h=0|At(0|p,0|x,0|R,0|T),g=0|B(),!(!(0|(f=0|n[(e=d=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|T)|(0|m)==(0|T)&b>>>0>R>>>0)break t;if((0|f)==(0|p)&(0|e)==(0|x)){d=c,f=u;break r}h=0|$e(0|(d=0|Ve(0|h,0|g,1,0)),0|B(),0|R,0|T),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),f=0|n[(e=d=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|f)&!(0|e)))}if(!(0|p)&!(0|x)){d=c,f=u;break}qA(p,x,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=d)>>2]=p,n[m+4>>2]=x,n[(c=Q+(c<<3)|0)>>2]=p,n[c+4>>2]=x,c=b),d=c,f=u}}while(0);if((v=v+1|0)>>>0>=7)break;c=d,u=f}if(w=0|Ve(0|w,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=d,u=f}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=N+(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]=d,n[C+4>>2]=f,!((0|f)>0|!(0|f)&d>>>0>0))break e;v=t,w=E,y=S,k=D,C=Q,t=M,E=l,D=j,M=v,l=w,S=F,F=y,j=k,Q=N,N=C}Ye(j),Ye(F),Ye(_),l=1;break A}l=d}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return P=s,0|l}}return Ye(_),P=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0;c=P,P=P+160|0,d=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,d=0;s=P,P=P+48|0,i=s+40|0,a=s,RA(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[(d=a)>>2]=u,n[d+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,d=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|d]=0|r[0|i],r[d+1|0]=0|r[i+1|0],r[d+2|0]=0|r[i+2|0]}while(0);ve(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],P=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(d,0|n[(f=g)>>2],0|n[f+4>>2],e),s=0|n[(f=d)>>2],f=0|n[f+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]=f,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[d>>2],n[h+4>>2]=n[d+4>>2],n[h+8>>2]=n[d+8>>2],n[h+12>>2]=n[d+12>>2],!(0|s)&!(0|f))return P=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,d=0,e=s,A=f;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&d>>>0>>0)){b=4;break}if(f=d,d=0|Ve(0|d,0|u,1,0),u=0|B(),n[(f=a+(f<<3)|0)>>2]=e,n[f+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(ve(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[(f=p)>>2]=e,n[f+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,P=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],P=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,d=0,f=0,g=0,h=0,m=0;if(s=P,P=P+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return P=s,0;if((0|(a|=0))>=16)return P=s,12;g=0,h=0,f=0,l=0;A:for(;;){if(d=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&d)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(d=m)>>2]))&!(0|(d=0|n[d+4>>2])))c=f;else{c=f;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(f=r+(c<<3)|0)>>2]=u,n[f+4>>2]=d,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(f=m)>>2],d=0|n[f+4>>2]}while(!(!(0|u)&!(0|d)))}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}f=c}return 10==(0|c)?(P=s,0|(m=14)):11==(0|c)?(P=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,d=0,f=0;a=P,P=P+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(d=0,l=0,s=0,f=0;;){if(!(!(0|(c=0|n[(u=A+(d<<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(d=0|Ve(0|d,0|f,1,0),!((0|(f=0|B()))<(0|t)|(0|f)==(0|t)&d>>>0>>0))break A}return P=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,P=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=P,P=P+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))?(P=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?NA(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],P=a,0|(l=0))},establishStackSpace:function(A,e){P=A|=0},stackAlloc:function(A){var e;return e=P,P=15+(P=P+(A|=0)|0)&-16,0|e},stackRestore:function(A){P=A|=0},stackSave:function(){return 0|P}}}({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: "+x(A)+", at: "+[e?x(e):"unknown filename",t,r?x(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){f.set(f.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,f,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,d.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":R=[e>>>0,(I=e,+Q(I)>=1?I>0?(0|F(+P(I/4294967296),4294967295))>>>0:~~+j((I-+(~~I>>>0))/4294967296)>>>0:0)],h[A>>2]=R[0],h[A+4>>2]=R[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 d[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},T){H(T)||(W=T,T=t.locateFile?t.locateFile(W,o):o+W),S++,t.monitorRunDependencies&&t.monitorRunDependencies(S);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),f.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(S--,t.monitorRunDependencies&&t.monitorRunDependencies(S),0==S&&L){var A=L;L=null,A()}}()},q=function(){n(T,X,function(){throw"could not load memory initializer "+T})},$=O(T);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;)N(t.postRun.shift());k(D)}()))}S>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),S>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(L=function A(){V||eA(),V||(L=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 $A?$A:{}),Ae="number",ee={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"},te={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function re(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 ne(A){if(0!==A)throw function(A,e){return re(ee,A,2===arguments.length?{value:e}:{})}(A)}var oe={};[["sizeOfH3Index",Ae],["sizeOfLatLng",Ae],["sizeOfCellBoundary",Ae],["sizeOfGeoLoop",Ae],["sizeOfGeoPolygon",Ae],["sizeOfLinkedGeoPolygon",Ae],["sizeOfCoordIJ",Ae],["readInt64AsDoubleFromPointer",Ae],["isValidCell",Ae,[Ae,Ae]],["isValidIndex",Ae,[Ae,Ae]],["latLngToCell",Ae,[Ae,Ae,Ae,Ae]],["cellToLatLng",Ae,[Ae,Ae,Ae]],["cellToBoundary",Ae,[Ae,Ae,Ae]],["maxGridDiskSize",Ae,[Ae,Ae]],["gridDisk",Ae,[Ae,Ae,Ae,Ae]],["gridDiskDistances",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridRing",Ae,[Ae,Ae,Ae,Ae]],["gridRingUnsafe",Ae,[Ae,Ae,Ae,Ae]],["maxPolygonToCellsSize",Ae,[Ae,Ae,Ae,Ae]],["polygonToCells",Ae,[Ae,Ae,Ae,Ae]],["maxPolygonToCellsSizeExperimental",Ae,[Ae,Ae,Ae,Ae]],["polygonToCellsExperimental",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["cellsToLinkedMultiPolygon",Ae,[Ae,Ae,Ae]],["destroyLinkedMultiPolygon",null,[Ae]],["compactCells",Ae,[Ae,Ae,Ae,Ae]],["uncompactCells",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["uncompactCellsSize",Ae,[Ae,Ae,Ae,Ae,Ae]],["isPentagon",Ae,[Ae,Ae]],["isResClassIII",Ae,[Ae,Ae]],["getBaseCellNumber",Ae,[Ae,Ae]],["getResolution",Ae,[Ae,Ae]],["getIndexDigit",Ae,[Ae,Ae,Ae]],["constructCell",Ae,[Ae,Ae,Ae,Ae]],["maxFaceCount",Ae,[Ae,Ae,Ae]],["getIcosahedronFaces",Ae,[Ae,Ae,Ae]],["cellToParent",Ae,[Ae,Ae,Ae,Ae]],["cellToChildren",Ae,[Ae,Ae,Ae,Ae]],["cellToCenterChild",Ae,[Ae,Ae,Ae,Ae]],["cellToChildrenSize",Ae,[Ae,Ae,Ae,Ae]],["cellToChildPos",Ae,[Ae,Ae,Ae,Ae]],["childPosToCell",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["areNeighborCells",Ae,[Ae,Ae,Ae,Ae,Ae]],["cellsToDirectedEdge",Ae,[Ae,Ae,Ae,Ae,Ae]],["getDirectedEdgeOrigin",Ae,[Ae,Ae,Ae]],["getDirectedEdgeDestination",Ae,[Ae,Ae,Ae]],["isValidDirectedEdge",Ae,[Ae,Ae]],["directedEdgeToCells",Ae,[Ae,Ae,Ae]],["originToDirectedEdges",Ae,[Ae,Ae,Ae]],["directedEdgeToBoundary",Ae,[Ae,Ae,Ae]],["gridDistance",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridPathCells",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridPathCellsSize",Ae,[Ae,Ae,Ae,Ae,Ae]],["cellToLocalIj",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["localIjToCell",Ae,[Ae,Ae,Ae,Ae,Ae]],["getHexagonAreaAvgM2",Ae,[Ae,Ae]],["getHexagonAreaAvgKm2",Ae,[Ae,Ae]],["getHexagonEdgeLengthAvgM",Ae,[Ae,Ae]],["getHexagonEdgeLengthAvgKm",Ae,[Ae,Ae]],["greatCircleDistanceM",Ae,[Ae,Ae]],["greatCircleDistanceKm",Ae,[Ae,Ae]],["greatCircleDistanceRads",Ae,[Ae,Ae]],["cellAreaM2",Ae,[Ae,Ae,Ae]],["cellAreaKm2",Ae,[Ae,Ae,Ae]],["cellAreaRads2",Ae,[Ae,Ae,Ae]],["edgeLengthM",Ae,[Ae,Ae,Ae]],["edgeLengthKm",Ae,[Ae,Ae,Ae]],["edgeLengthRads",Ae,[Ae,Ae,Ae]],["getNumCells",Ae,[Ae,Ae]],["getRes0Cells",Ae,[Ae]],["res0CellCount",Ae],["getPentagons",Ae,[Ae,Ae]],["pentagonCount",Ae],["cellToVertex",Ae,[Ae,Ae,Ae,Ae]],["cellToVertexes",Ae,[Ae,Ae,Ae]],["vertexToLatLng",Ae,[Ae,Ae,Ae]],["isValidVertex",Ae,[Ae,Ae]]].forEach(function(A){oe[A[0]]=$A.cwrap.apply($A,A)});var ie=16,ae=oe.sizeOfH3Index(),se=oe.sizeOfLatLng(),le=oe.sizeOfCellBoundary();oe.sizeOfGeoPolygon(),oe.sizeOfGeoLoop(),oe.sizeOfLinkedGeoPolygon(),oe.sizeOfCoordIJ();var ce=/[^0-9a-fA-F]/;function ue(A){if(A>=0)return A.toString(ie);var e=de(8,(A&=2147483647).toString(ie));return(parseInt(e[0],ie)+8).toString(ie)+e.substring(1)}function de(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 ke({coveragePoints:e,visible:r,terrainEnabled:n=!1,brightness:o=.7}){const{current:i}=S(),[a,s]=A.useState(null),[l,c]=A.useState(!1),u=A.useRef({aborted:!1}),d=A.useRef(0),f=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(e),g=A.useMemo(()=>function(){var A;const e=hA();return 24===e.length&&0!==(null==(A=e[0])?void 0:A[0])?e:ve}(),[]);A.useEffect(()=>{if(!f||!Array.isArray(f)||0===f.length)return void queueMicrotask(()=>{s(null),d.current=0});if(f.length===d.current&&a)return;d.current=f.length,u.current.aborted=!0,u.current={aborted:!1};const A=u.current;c(!0);const{cells:e,minQuality:t,maxQuality:r}=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=he(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}}(f);if(0===e.length)return s(null),void c(!1);if(e.length<500){const n=function(A,e,t,r){const n=[];for(const o of A){const A=me(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=ye(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}}(e,t,r,g);return void(A.aborted||(s(n),c(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=ye(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}}(e,t,r,g,A).then(e=>{!A.aborted&&e&&s(e)}).finally(()=>{A.aborted||c(!1)}),()=>{A.aborted=!0}},[f,g]),A.useEffect(()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(!e)return;const t=()=>{var A,t;try{const n=e.getLayer(xe),i=e.getSource(pe);if(r&&a&&a.features.length>0){if(i?e.getSource(pe).setData(a):e.addSource(pe,{type:"geojson",data:a}),!n){const r=e.getLayer("topology-weak-edges-native"),n=null==(t=null==(A=e.getStyle())?void 0:A.layers)?void 0:t.find(A=>"symbol"===A.type),i=r?"topology-weak-edges-native":null==n?void 0:n.id;e.addLayer({id:xe,type:"fill",source:pe,paint:{"fill-color":["get","color"],"fill-opacity":o}},i)}}else n&&e.removeLayer(xe),i&&e.removeSource(pe)}catch(n){}};e.isStyleLoaded()?t():e.once("style.load",t)},[i,r,a,n]),A.useEffect(()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(e&&r)try{e.getLayer(xe)&&e.setPaintProperty(xe,"fill-opacity",o)}catch{}},[i,o,r]),A.useEffect(()=>()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(e)try{e.getLayer(xe)&&e.removeLayer(xe),e.getSource(pe)&&e.removeSource(pe)}catch{}},[i]);const h=(null==a?void 0:a.features.length)??0;return h>0&&r?t.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==e?void 0:e.length)||0,"data-cell-count":h,"data-terrain-enabled":n,"data-is-processing":l,style:{display:"none"}}):null}const Ce="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Be="terrarium",Me="terrain-dem",De="hillshade-dem",Ee="terrain-hillshade";function Ne({enabled:e,exaggeration:t=4}){const{current:r}=S(),n=A.useRef(null);return A.useEffect(()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);if(!e)return;let t=!0;const n=()=>{var A,r;if(t)try{if(e.getSource(De)||e.addSource(De,{type:"raster-dem",tiles:[Ce],encoding:Be,tileSize:256,maxzoom:14}),!e.getLayer(Ee)){const t=null==(r=null==(A=e.getStyle())?void 0:A.layers)?void 0:r.find(A=>"symbol"===A.type);e.addLayer({id:Ee,type:"hillshade",source:De,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==t?void 0:t.id)}}catch(n){}};return e.isStyleLoaded()?n():e.once("style.load",n),()=>{t=!1}},[r]),A.useEffect(()=>{var A;const o=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);if(!o)return;let i=!0;const a=()=>{if(i)try{o.getSource(Me)||o.addSource(Me,{type:"raster-dem",tiles:[Ce],encoding:Be,tileSize:256,maxzoom:14}),e?(o.setCenterClampedToGround(!1),o.setTerrain({source:Me,exaggeration:t}),o.setMaxPitch(70),o.getPitch()<30&&!o.isMoving()&&(null!==n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{n.current=null,i&&!o.isMoving()&&o.getPitch()<30&&o.easeTo({pitch:45,duration:1e3})},200))):(o.setTerrain(null),o.setCenterClampedToGround(!0),o.getPitch()>0&&!o.isMoving()&&o.easeTo({pitch:0,duration:800}),o.setMaxPitch(60))}catch(A){}};return o.isStyleLoaded()?a():o.once("style.load",a),()=>{i=!1,null!==n.current&&(clearTimeout(n.current),n.current=null);try{o.getStyle()&&o.isStyleLoaded()&&o.setTerrain(null)}catch{}}},[r,e,t]),A.useEffect(()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);return()=>{var A;try{(null==(A=null==e?void 0:e.getStyle)?void 0:A.call(e))&&e.isStyleLoaded()&&(e.setTerrain(null),e.getLayer(Ee)&&e.removeLayer(Ee),e.getSource(De)&&e.removeSource(De),e.getSource(Me)&&e.removeSource(Me))}catch{}}},[r]),null}function Qe(A,e=!1,t=!1,r=!1,n=.7){const o=fA();return r?n>=.75?o.restBright:o.rest:n>=.85?o.rest:o.restDim}function je(A){return[A[1],A[0]]}function Pe(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 Fe(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Se(A,e,t,r,n,o,i,a,s,l,c){const u=CA(),d=[];let f=1/0,g=-1/0;const h=[];for(const b of A){const A=.7*(b.edge.avgConfidence??(e?.7:.5))+b.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);h.push({polyline:b,brightnessScore:A}),f=Math.min(f,A),g=Math.max(g,A)}if(0===h.length)return{type:"FeatureCollection",features:[]};const m=g-f||1;h.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:b,brightnessScore:p}of h){const{from:A,to:i,edge:g}=b,h=t.get(g.key)??0;if(h<=0)continue;const x=a.has(g.key),v=s.has(g.key),w=g.avgConfidence??(e?.7:.5),y=l===g.key,k=c[g.fromHash],C=c[g.toHash],B=(null==k?void 0:k.node_name)||(null==k?void 0:k.name)||g.fromHash.slice(0,8),M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||g.toHash.slice(0,8),D=[A[0]+(i[0]-A[0])*h,A[1]+(i[1]-A[1])*h];let E,N,Q,j;if(e){const A=o.get(g.key)??vA(g.certainCount),e=n.get(g.key)??A;E=e+(A-e)*r,y?E=Math.max(1.6*E,4.5):v&&(E*=1.3)}else E=1.5;if(N=y?u.edges.highlight:Qe(0,g.isDirectPathEdge??!1,x,v,w),Q=y?u.edges.highlight:g.isDirectPathEdge?u.edges.hoverDirect:x?u.edges.hoverLoop:u.edges.hoverStandard,e){const A=Math.min(1.5*h,1)*u.edgeOpacity;j=v?1.15*A:A}else j=(.3+.3*w)*h;y&&(j=.95);const P=(p-f)/m;d.push({type:"Feature",properties:{key:g.key,baseColor:N,hoverColor:Q,baseWidth:E,baseOpacity:j,brightnessScore:P,isLoopEdge:x,isBackbone:v,isDirectPath:g.isDirectPathEdge??!1,isHubConnection:g.isHubConnection??!1,isZeroHop:g.isZeroHop??!1,isValidated:e,certainCount:g.certainCount,confidence:w,symmetryRatio:g.symmetryRatio??1,dominantDirection:g.dominantDirection??"balanced",fromName:B,toName:M,fromHash:g.fromHash,toHash:g.toHash},geometry:{type:"LineString",coordinates:[je(A),je(D)]}})}return{type:"FeatureCollection",features:d}}function Le(A,e){const t=CA(),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,d=(null==l?void 0:l.avgSnr)??s.snr??null,f=(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,x=n>0?p/n:0,v=o.rxAdvertCount??0,w=o.txProxyCount??0,y=v+w,k=y>0?(w-v)/y:0,C=Pe(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:d,packetCount:f,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:x,linkAsymmetry:k,rxAdvertCount:v,txProxyCount:w},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Ie(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Re(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 Te(A,e,t){const r=t?AA(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 _e="edge-blink-source",He="edge-blink-layer",ze=1e3,Ge=1e3,Oe="node-markers-layer";function Ue(A){return A<0||A>=ze?0:1-A/ze}function Ye(A){if(A<0)return 0;if(A>=Ge)return 0;const e=A/Ge;return Math.pow(1-e,3)}function We(A){return[A[1],A[0]]}function Ve(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function Ze({hash:e,hashPrefix:n,name:o,isHub:i,isGateway:a,isBackbone:l,isZeroHop:c,isMobile:u,isRoomServer:d,isStale:f,lastSeenTimestamp:g,centrality:h,affinity:m,meanSnr:b,meanRssi:p,neighbor:x,onRemove:v,txDelayRec:w,onPingResult:y}){const k=gA(),[C,B]=A.useState(!1),[M,D]=A.useState(!1),[E,N]=A.useState(null),[Q,j]=A.useState(null),F=A.useCallback(async()=>{if(!M){D(!0),j(null),N(null);try{const A=e.startsWith("0x")?e.slice(0,4):`0x${e.slice(0,2)}`,t=await tA(A,30);t.success&&t.data?(N(t.data),null==y||y(t.data)):j(t.error||"Ping failed")}catch(A){j(A instanceof Error?A.message:"Ping failed")}finally{D(!1)}}},[e,M,y]),S=c?"Direct":(null==m?void 0:m.typicalHopPosition)?`${m.typicalHopPosition}-hop`:null,z=w&&!w.insufficientData,G={hub:{bg:"bg-amber-500/20",text:"text-amber-400",title:"Hub: High-connectivity node that bridges many paths"},backbone:{bg:"bg-purple-500/20",text:"text-purple-400",title:"Backbone: Critical relay with high traffic"},relay:{bg:"bg-cyan-500/20",text:"text-cyan-400",title:"Relay: Standard forwarding node"},edge:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Edge: Peripheral node"}},O={high:{bg:"bg-green-500/20",text:"text-green-400",title:"1000+ packets"},medium:{bg:"bg-amber-500/20",text:"text-amber-400",title:"500-999 packets"},low:{bg:"bg-red-500/20",text:"text-red-400",title:"100-499 packets"},insufficient:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Insufficient data"}};return t.jsxs("div",{className:"w-[240px] pr-2",children:[t.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-tight truncate mb-1",children:o}),t.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[t.jsx("code",{className:"font-mono text-[10px] text-text-secondary bg-[#1a1a1a] px-1 py-0.5 rounded",children:n}),t.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(e),B(!0),setTimeout(()=>B(!1),1500)}catch(A){const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),B(!0),setTimeout(()=>B(!1),1500)}catch{}document.body.removeChild(t)}},className:"p-0.5 hover:bg-[#252525] rounded transition-colors",title:"Copy full hash",children:C?t.jsx(r,{className:"w-3 h-3 text-accent-success"}):t.jsx(L,{className:"w-3 h-3 text-text-secondary"})}),t.jsx(pA,{hash:e,size:"sm"}),S&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded "+(c?"bg-amber-400 text-gray-900":"bg-[#2a2a2a] text-white"),children:S}),x.is_repeater&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-cyan-500/20 text-cyan-400",children:"Rptr"}),i&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded",style:{backgroundColor:k.hubColor,color:"#fff"},title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a&&!i&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded",style:{backgroundColor:k.hubColor,color:"#fff",opacity:.8},title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),l&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-purple-500/80 text-white",title:"Backbone",children:"Bone"}),u&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-orange-500/25 text-orange-300",children:"Mobile"}),d&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-amber-500/25 text-amber-400",children:"Room"}),f&&g&&t.jsxs("span",{className:"px-1 py-0.5 text-[9px] font-medium rounded bg-gray-500/30 text-gray-300",title:"Neighbor not heard in 7+ days",children:["Idle ",Ve(g)]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-secondary mb-1.5",children:[t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(I,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono",children:rA(x.last_seen)})]}),(null==m?void 0:m.distanceMeters)&&t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(R,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(U=m.distanceMeters,null===U?"—":U<1e3?`${Math.round(U)}m`:`${(U/1e3).toFixed(1)}km`)})]}),x.latitude&&x.longitude&&0!==x.latitude&&0!==x.longitude&&t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(T,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsxs("span",{className:"font-mono text-text-muted",children:[x.latitude.toFixed(2),", ",x.longitude.toFixed(2)]})]})]}),t.jsx("div",{className:"mb-1.5",style:{width:224},children:t.jsx(xA,{nodeHash:e,width:224,height:26,showArea:!0,showTooltip:!0})}),t.jsxs("div",{className:"flex gap-3 text-[10px] mb-1.5",children:[t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(null==m?void 0:m.frequency)||0})]}),c&&void 0!==b&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[b.toFixed(1)," dB"]})]}),z&&w.networkRole&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:`text-[9px] font-bold uppercase px-1 py-0.5 rounded ${G[w.networkRole].bg} ${G[w.networkRole].text}`,title:G[w.networkRole].title,children:w.networkRole})]})]}),t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Adverts"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:x.advert_count||0})]}),c&&void 0!==p&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[Math.round(p)," dBm"]})]}),z&&w.dataConfidence&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Data"}),t.jsx("span",{className:`text-[9px] font-bold uppercase px-1 py-0.5 rounded ${O[w.dataConfidence].bg} ${O[w.dataConfidence].text}`,title:O[w.dataConfidence].title,children:w.dataConfidence})]})]})]}),z&&t.jsxs("div",{className:"flex items-center gap-2 text-[10px] mb-1.5 py-1 px-1.5 bg-amber-400/5 rounded",children:[t.jsx(_,{className:"w-3 h-3 text-amber-400 shrink-0"}),t.jsx("span",{className:"text-text-muted",children:"TxDelay"}),t.jsxs("div",{className:"flex gap-3 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"F"}),t.jsxs("span",{className:"font-mono font-semibold text-amber-400",children:["×",(w.floodFactor??w.txDelayFactor).toFixed(1)]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"D"}),t.jsxs("span",{className:"font-mono font-semibold text-amber-400",children:["×",(w.directFactor??w.directTxDelayFactor).toFixed(1)]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-white/[0.08]",children:[c?t.jsxs("button",{onClick:F,disabled:M,className:"flex items-center gap-1 py-0.5 text-[10px] text-text-secondary hover:text-accent-primary hover:bg-accent-primary/10 rounded transition-colors disabled:opacity-50",title:"Ping neighbor",children:[M?t.jsx(s,{className:"w-3 h-3 animate-spin"}):t.jsx(H,{className:"w-3 h-3"}),t.jsx("span",{children:"Ping"})]}):t.jsx("div",{}),v&&t.jsx("button",{onClick:v,className:"p-1 text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:t.jsx(P,{className:"w-3.5 h-3.5"})})]}),E&&t.jsxs("div",{className:"mt-1 pt-1 border-t border-white/[0.08] text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-1 text-accent-success mb-0.5",children:[t.jsx(r,{className:"w-3 h-3"}),t.jsx("span",{className:"font-medium",children:"Ping OK"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RTT"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.rtt_ms.toFixed(0)," ms"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.rssi," dBm"]})]})]}),t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.snr_db.toFixed(1)," dB"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Hops"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:E.path.length})]})]})]})]}),Q&&t.jsxs("div",{className:"mt-1.5 pt-1.5 border-t border-white/[0.08] text-[10px] text-red-400",children:["⚠ ",Q]})]});var U}const Ke="node-markers-native",Je="node-markers-layer",Xe="node-markers-layer-local",qe="marker-standard",$e="marker-standard-neighbor",At="marker-hub",et="marker-hub-neighbor",tt="marker-gateway",rt="marker-gateway-neighbor",nt="marker-mobile",ot="marker-mobile-neighbor",it="marker-room-server",at="marker-room-server-neighbor",st="marker-local",lt="marker-blink-black",ct="marker-blink-black-local",ut="marker-blink",dt="marker-blink-local";function ft(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 gt(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function ht({neighborsWithLocation:e,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:d,openPopupId:f,onOpenPopup:g,onClosePopup:h,blinkingNodes:m}){const{current:b}=S(),p=A.useRef(!1),[x,v]=A.useState(!1);A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e)return;const t=()=>{if(!p.current)try{!function(A){const e=dA(),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={[qe]:t(e.nodeFill,e.nodeStroke,1.5),[$e]:t(e.neighborColor),[At]:t(e.hubColor),[et]:t(e.neighborColor),[tt]:t(e.hubColor+"B3"),[rt]:t(e.neighborColor),[nt]:t("transparent",e.mobileColor,2),[ot]:t(e.neighborColor),[it]:n(e.roomColor),[at]:n(e.neighborColor,"#1a1a1c"),[st]:r(e.localColor),[lt]:t("#000000"),[ct]:r("#000000"),[ut]:t(o,void 0,0,!0),[dt]: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),p.current=!0,v(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{p.current=!1,t()},n=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(r,100);break}});return n.observe(document.documentElement,{attributes:!0}),()=>{n.disconnect()}},[b]);const w=A.useMemo(()=>{var A;const t=[],r=[...e].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return ft(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[e,n]of r){if(!n.latitude||!n.longitude)continue;const r=u(e),s=c(e,r);if(s<=.01)continue;const l=o.has(e),d=a.hubNodes.includes(e),f=(null==(A=a.gatewayNodes)?void 0:A.includes(e))??!1,g=a.mobileNodes.includes(e),h=ft(n),m=a.centrality.get(e)||0,b=i.get(e),p="stale"===(null==b?void 0:b.status),x=p?Math.min(s,.5):s;let v="standard";h?v="roomServer":d?v="hub":f?v="gateway":g&&(v="mobile");const w=a.fullAffinity.get(e),y=a.txDelayRecommendations.get(e);t.push({type:"Feature",geometry:{type:"Point",coordinates:[n.longitude,n.latitude]},properties:{hash:e,name:n.node_name||n.name||"Unknown",hashPrefix:gt(e),iconType:v,isNeighbor:l,isHub:d,isGateway:f,isMobile:g,isRoomServer:h,isStale:p,isZeroHop:l,opacity:x,blinkIntensity:0,lastSeenTimestamp:null==b?void 0:b.lastSeen,centrality:m,neighborJson:JSON.stringify(n),affinityJson:w?JSON.stringify(w):void 0,txDelayRecJson:y?JSON.stringify(y):void 0,meanSnr:(null==b?void 0:b.avgSnr)??void 0,meanRssi:(null==b?void 0:b.avgRssi)??void 0}})}return{type:"FeatureCollection",features:t}},[e,o,i,a,c,u]),y=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?gt(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]),k=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)},[g]),C=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;const r=null==(e=null==b?void 0:b.getMap)?void 0:e.call(b);r&&(r.getCanvas().style.cursor="pointer");const n=null==(t=A.features[0].properties)?void 0:t.hash;n&&l(n)},[b,l]),B=A.useCallback(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);e&&(e.getCanvas().style.cursor=""),l(null)},[b,l]);A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e||!x)return;const t=[Je,Xe];for(const r of t)e.on("click",r,k),e.on("mouseenter",r,C),e.on("mouseleave",r,B);return()=>{for(const A of t)e.off("click",A,k),e.off("mouseenter",A,C),e.off("mouseleave",A,B)}},[b,x,k,C,B]);const M=A.useRef(w),D=A.useRef(y);A.useEffect(()=>{M.current=w,D.current=y},[w,y]),A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e||!x||!m||0===m.size)return;const t=e.getSource(Ke),r=e.getSource(`${Ke}-local`);if(t||r){if(t){const A=M.current;let e=!1;const r=A.features.map(A=>{const t=m.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=m.get(n)??0,e=D.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}}]})}}},[b,x,m,n]);const E=A.useMemo(()=>{if(!f)return null;if("local"===f&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=w.features.find(A=>A.properties.hash===f);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}},[f,r,n,w]);if(!x)return null;const N=dA(),Q=["case",[">",["get","blinkIntensity"],.66],ut,[">",["get","blinkIntensity"],.33],lt,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],at,it],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],et,At],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],rt,tt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],ot,nt],["case",["get","isNeighbor"],$e,qe]],j=["interpolate",["linear"],["zoom"],6,.25,10,1];return t.jsxs(t.Fragment,{children:[t.jsx(z,{id:Ke,type:"geojson",data:w,children:t.jsx(G,{id:Je,type:"symbol",layout:{"icon-image":Q,"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),t.jsx(z,{id:`${Ke}-local`,type:"geojson",data:y,children:t.jsx(G,{id:Xe,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],dt,[">",["get","blinkIntensity"],.33],ct,st],"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),E&&h&&t.jsx(O,{longitude:E.longitude,latitude:E.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:E.isLocal?t.jsxs("div",{className:"text-sm",children:[t.jsx("strong",{className:"text-base",children:E.name}),E.hash&&t.jsx("span",{className:"ml-2 font-mono text-xs text-text-muted bg-surface-elevated px-1.5 py-0.5 rounded",children:gt(E.hash)}),t.jsx("br",{}),t.jsx("span",{style:{color:N.localColor},className:"font-medium",children:"This Node (Local)"}),t.jsx("br",{}),r&&t.jsxs("span",{className:"text-xs text-text-muted",children:[r.latitude.toFixed(5),", ",r.longitude.toFixed(5)]})]}):E.neighbor&&E.hash?t.jsx(Ze,{hash:E.hash,hashPrefix:E.hashPrefix,name:E.name,isHub:E.isHub,isGateway:E.isGateway,isBackbone:E.isBackbone,isZeroHop:E.isZeroHop,isMobile:E.isMobile,isRoomServer:E.isRoomServer,isStale:E.isStale,lastSeenTimestamp:E.lastSeenTimestamp,centrality:E.centrality,affinity:E.affinity,meanSnr:E.meanSnr,meanRssi:E.meanRssi,neighbor:E.neighbor,txDelayRec:E.txDelayRec,onRemove:d?()=>d(E.hash,E.name):void 0}):null})]})}const mt=[Je,Xe];A.createContext(null);const bt="topology-validated-edges-native",pt="topology-weak-edges-native",xt="neighbor-edges-native",vt="topology-weak-edges-native",wt="topology-validated-edges-native",yt="neighbor-edges-native",kt={type:"FeatureCollection",features:[]},Ct={"line-cap":"round","line-join":"round"},Bt={"line-color":"transparent","line-width":16,"line-opacity":0};function Mt({showTopology:e,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,onEdgeHover:i,onLoopHover:a,loops:s=[],neighborNames:l={},opacityBias:c=.5,widthMultiplier:u=1,trafficFilter:d=0,showNeighborLines:f=!0,disableHover:g=!1}){const{current:h}=S(),m=e||r,b=!0,p=f?"visible":"none",x=g||r,v=A.useRef(null),w=A.useRef(x),y=A.useRef(new Map),k=A.useRef(l),C=A.useRef(a);A.useLayoutEffect(()=>{w.current=x,k.current=l,C.current=a});const B=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}(s),[s]);A.useLayoutEffect(()=>{y.current=B},[B]);const M=A.useCallback(A=>{var e,t;if(w.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!==v.current){v.current=n;const o=!0===r.isNeighborEdge||"true"===r.isNeighborEdge,a=!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};i(n,[A.lngLat.lng,A.lngLat.lat],t),null==(e=C.current)||e.call(C,null)}else if(a&&C.current){const e=y.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=>k.current[A]||A.substring(0,4))};C.current(r,[A.lngLat.lng,A.lngLat.lat]),i(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};i(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:a,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};i(n,[A.lngLat.lng,A.lngLat.lat],e),null==(t=C.current)||t.call(C,null)}}},[i]),D=A.useCallback(()=>{var A;null!==v.current&&(v.current=null,i(null),null==(A=C.current)||A.call(C,null))},[i]);A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);if(!e||!m)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,M),e.on("mouseleave",t,D),!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,M),e.off("mouseleave",t,D))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,M),e.off("mouseleave",t,D))}catch{}}},[h,m,M,D]),A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);if(!e||!f)return;const t="neighbor-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,M),e.on("mouseleave",t,D),!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,M),e.off("mouseleave",t,D))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,M),e.off("mouseleave",t,D))}catch{}}},[h,b,f,M,D]),A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);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(yt,"node-markers-layer"),r("neighbor-edges-hitarea-native",yt),(r(wt,"neighbor-edges-hitarea-native")||r(wt,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",wt),r(vt,"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===bt||A.sourceId===pt||A.sourceId===xt)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[h,m,b,f]);const E=x?null:n,N=function(A,e,t,r,n){const o=CA(),i=null!==A,a=n&&n.size>0,s=a?Array.from(n):[],l=e<=0?["get","baseColor"]:["case",[">=",["get","brightnessScore"],1-.5*e],"#FFFFFF",["get","baseColor"]],c=e<=0?1:["max",.1,["+",1,["*",e,3,["-",["get","brightnessScore"],.5]]]],u=a?["in",["get","key"],["literal",s]]:!!i&&["==",["get","key"],A],d=i||a,f=o.edges.hoverLoop??"#A78BFA";return{"line-color":d?["case",u,a?f:["get","hoverColor"],l]:l,"line-width":d?["case",u,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,d?["case",u,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],c,.35]]:["*",["get","baseOpacity"],c]]}}(E,c,u,d,x?null:o),Q=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=W,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}}(E);return t.jsxs(t.Fragment,{children:[m&&t.jsx(z,{id:pt,type:"geojson",data:kt,children:t.jsx(G,{id:vt,type:"line",paint:N,layout:Ct})}),m&&t.jsxs(z,{id:bt,type:"geojson",data:kt,children:[t.jsx(G,{id:"topology-validated-edges-hitarea-native",type:"line",paint:Bt,layout:Ct}),t.jsx(G,{id:wt,type:"line",paint:N,layout:Ct})]}),t.jsxs(z,{id:xt,type:"geojson",data:kt,children:[t.jsx(G,{id:"neighbor-edges-hitarea-native",type:"line",paint:Bt,layout:{...Ct,visibility:p}}),t.jsx(G,{id:yt,type:"line",paint:Q,layout:{...Ct,visibility:p}})]})]})}const Dt=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function Et({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=S(),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 Nt({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=S(),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 Qt(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 jt(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 Pt({ghost:e,neighborCoordinates:r,onHighlightedNeighborsChange:n}){const{current:o}=S(),i=A.useRef(null),a=A.useRef(null),s=A.useMemo(()=>e?new Set(e.commonNeighbors):new Set,[e]);A.useEffect(()=>{null==n||n(s)},[s,n]);const l=A.useMemo(()=>{if(!(null==e?void 0:e.commonNeighbors)||e.commonNeighbors.length<2)return 8e3;let A=0;const t=[];for(const n of e.commonNeighbors){const A=r.get(n);A&&t.push(A)}e.estimatedLocation&&t.push([e.estimatedLocation.lat,e.estimatedLocation.lon]);for(let e=0;eA&&(A=n)}return Math.max(A,2e3)},[e,r]),c=A.useMemo(()=>{if(!(null==e?void 0:e.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:A,lon:t,uncertaintyM:r}=e.estimatedLocation,n=.5*l,o=r>0?r:2e3;return{type:"FeatureCollection",features:[jt(t,A,Math.max(500,Math.min(o,n)))]}},[e,l]);if(A.useEffect(()=>{if(!o)return;const A=o.getMap();if(e&&e.prefix!==a.current){if(a.current=e.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 t=[];for(const A of e.commonNeighbors){const e=r.get(A);e&&t.push([e[1],e[0]])}if(e.estimatedLocation&&t.push([e.estimatedLocation.lon,e.estimatedLocation.lat]),t.length>0){const r=()=>{var n;if(A.isMoving())setTimeout(r,100);else if(1===t.length)o.flyTo({center:t[0],zoom:13,duration:1500});else{let A=1/0,r=-1/0,i=1/0,a=-1/0;for(const[e,n]of t)A=Math.min(A,e),r=Math.max(r,e),i=Math.min(i,n),a=Math.max(a,n);if(null==(n=e.estimatedLocation)?void 0:n.uncertaintyM){const t=e.estimatedLocation.uncertaintyM/111e3;A-=t,r+=t,i-=t,a+=t}o.fitBounds([[A,i],[r,a]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:1500})}};setTimeout(r,50)}}if(!e&&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)}},[e,o,r]),!(null==e?void 0:e.estimatedLocation))return null;return t.jsx(z,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:t.jsx(G,{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))}(kA.edges.neighborHover);const Ft={longitude:0,latitude:0,zoom:2};function St(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))*6371}function Lt({data:A}){const e=A.subtitle&&"loop"===A.type,r=A.subtitle&&"loop"!==A.type;return t.jsxs("div",{className:"w-[540px]",children:[t.jsxs("div",{className:"flex items-center justify-between h-5",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[A.title.icon&&t.jsx("span",{className:`${A.title.color} text-base leading-none flex-shrink-0`,children:A.title.icon}),t.jsx("span",{className:`${A.title.color} font-semibold text-[13px] truncate`,children:A.title.text}),r&&t.jsx("span",{className:`${A.subtitle.color} text-[11px] flex-shrink-0`,children:A.subtitle.text})]}),A.badges.length>0&&t.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:A.badges.map((A,e)=>t.jsx("span",{className:`${A.color} text-[11px] font-medium`,children:A.text},e))})]}),e&&t.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:t.jsx("span",{className:"font-mono text-[10px] text-text-muted truncate block",children:A.subtitle.text})}),t.jsx("div",{className:`flex items-center gap-4 h-4 ${e?"mt-1":"mt-1.5"} text-[11px]`,children:A.stats.map((A,e)=>t.jsxs("span",{className:"whitespace-nowrap",children:[t.jsx("span",{className:`font-mono tabular-nums font-semibold ${A.color??"text-text-primary"}`,children:A.value}),t.jsx("span",{className:"text-text-muted ml-1",children:A.label}),A.unit&&t.jsx("span",{className:"text-text-muted/50 ml-0.5",children:A.unit})]},e))})]})}function It({neighbors:e,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=nA(),d=oA(),f=iA(),g=aA(),h=sA(),[m,b]=A.useState(!1),p=lA(A=>A.preloadFromNodes),x=lA(A=>A.isLoading),v=lA(A=>A.terrainGrid),w=n??h,y=A.useMemo(()=>{const A=[];for(const[,t]of Object.entries(e))t.latitude&&t.longitude&&A.push([t.latitude,t.longitude]);return A},[e]),k=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])=>({pos:[A,e],dist:St(t,r,A,e)}));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[f,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,f),i=Math.max(i,f);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let d=16;return u>0&&(d=Math.floor(Math.log2(360/u*1.2)),d=Math.max(1,Math.min(14,d))),d=Math.min(d+1,12),{longitude:a,latitude:s,zoom:d}}(y,r),[y,r]),[C,B]=A.useState(()=>k??Ft),M=A.useRef(!1);A.useEffect(()=>{!M.current&&k&&(B(k),M.current=!0,setTimeout(()=>b(!0),50))},[k]);const[D,E]=A.useState(!1),[N,Q]=A.useState(!1),[j,P]=A.useState(!0),[F,S]=A.useState(!1),[L,I]=A.useState(!1),[R,T]=A.useState("all"),[_,H]=A.useState(null),[z,G]=A.useState(null),[O]=A.useState(0),[W]=A.useState(.5),[Z]=A.useState(0),[K,J]=A.useState(null),[tA,rA]=A.useState(""),[uA,dA]=A.useState(!1),[fA,gA]=A.useState("fetching"),[hA,mA]=A.useState(!1),[bA,pA]=A.useState(0),[xA,wA]=A.useState(!1),[kA,CA]=A.useState(null),MA=A.useCallback(A=>CA(A),[]),DA=A.useCallback(()=>CA(null),[]),[,NA]=A.useState(new Set),jA=ZA(A=>A.coveragePoints),PA=ZA(A=>A.isVisible),FA=ZA(A=>A.brightness),LA=ZA(A=>A.openModal),RA=qA(A=>A.isEnabled),_A=qA(A=>A.toggle),HA=A.useRef(!1);A.useEffect(()=>{jA.length>0&&PA&&!HA.current&&(P(!1),HA.current=!0)},[jA.length,PA]);const zA=A.useRef(null);A.useEffect(()=>{if(i&&i!==zA.current){zA.current=i;const A=setTimeout(()=>{CA(i)},1250);return()=>clearTimeout(A)}},[i]);const[GA,OA]=A.useState(null),[UA,YA]=A.useState(null),WA=A.useCallback((A,e,t)=>{G(A),A&&e&&t?OA({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,color:"",width:0,opacity:0,symmetryRatio:t.symmetryRatio,dominantDirection:t.dominantDirection}}):A||OA(null)},[]),VA=A.useCallback((A,e)=>{YA(A),A&&OA(null)},[]),KA=A.useMemo(()=>{const A={};for(const[t,r]of Object.entries(e))A[t]=r.node_name||r.name||t.substring(0,4);return w&&(A[w]="You"),A},[e,w]),XA=A.useMemo(()=>Object.entries(e).filter(([,A])=>A.latitude&&A.longitude),[e]),$A=A.useMemo(()=>{const A=new Map;w&&(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&A.set(w,[r.latitude,r.longitude]);for(const[e,t]of XA)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[w,r,XA]),Ae=A.useMemo(()=>{const A=new Map;for(const e of f)"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},[f]),ee=A.useMemo(()=>{var A,t;const r=new Set;for(const n of Ae.keys())(null==(A=e[n])?void 0:A.latitude)&&(null==(t=e[n])?void 0:t.longitude)&&r.add(n);return r},[Ae,e]),te=A.useMemo(()=>{if(0===ee.size||!w)return new Map;const A=q.getPackets();if(0===A.length)return new Map;const e=AA(w);return V(A,ee,e).scores},[ee,w,g.packetCount]),re=A.useCallback(A=>!!(w&&(A.fromHash===w&&ee.has(A.toHash)||A.toHash===w&&ee.has(A.fromHash))),[w,ee]),ne=A.useMemo(()=>{var A,t;if(0===f.length||!w)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of f){if("expired"===n.status)continue;if(!(null==(A=e[n.hash])?void 0:A.latitude)||!(null==(t=e[n.hash])?void 0:t.longitude))continue;const o=[w,n.hash].sort(),i=`${o[0]}~${o[1]}`;r.push({fromHash:w,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},[f,w,g.backgroundLoadComplete,e]),oe=A.useMemo(()=>{const A=[];if(ne.length>0&&!g.backgroundLoadComplete){for(const e of ne){const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(re(e))continue;const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,$A,re,ne,g.backgroundLoadComplete]),ie=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(re(e))continue;const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,$A,re]),ae=A.useMemo(()=>{if(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude))return[];const A=[],t=[r.latitude,r.longitude],n=new Map;for(const e of u.lastHopNeighbors)n.set(e.hash,e.count);const o=new Map;for(const e of f)o.set(e.hash,e.count);for(const r of ee){const i=e[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:t,to:[i.latitude,i.longitude],hash:r,neighbor:i,lastHopData:Ae.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,ee,e,Ae,u.lastHopNeighbors,f]),se=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),le=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),ce=A.useMemo(()=>{let A=0;if(ne.length>0&&!g.backgroundLoadComplete){for(const e of ne)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,ne,g.backgroundLoadComplete]),ue=A.useRef(null);A.useLayoutEffect(()=>{var A,e;ue.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const de=X(),fe=A.useMemo(()=>q.getPackets(),[de]);!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),d=A.useRef([]),f=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),x=A.useRef(new Map),v=A.useRef(t);A.useEffect(()=>{v.current=t},[t]),A.useEffect(()=>{x.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=AA(r);t.has(A)||t.set(A,r)}if(e){const A=AA(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),d.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(_e);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,f.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(He)&&A.removeLayer(He),A.getSource(_e)&&A.removeSource(_e),A.addSource(_e,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Oe)?Oe:void 0;A.addLayer({id:He,type:"line",source:_e,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],"#8B7BAD","#00FFFF"],"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(He)&&A.removeLayer(He),A.getSource(_e)&&A.removeSource(_e)}catch{}c.current=!1,m(!1)}}},[l]);const w=A.useRef(()=>{});A.useEffect(()=>{w.current=()=>{const A=s.current;if(!A)return;const e=A.getSource(_e);if(!e)return;const t=performance.now(),r=d.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ge:ze)){o.push(i);const e=i.isSpeculative?Ye(A):Ue(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}),d.current=o,o.length>0?u.current=requestAnimationFrame(()=>w.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(He))return;const e=A.getLayer(Oe)?Oe:void 0;try{A.moveLayer(He,e)}catch{}}(A),null===u.current&&(u.current=requestAnimationFrame(()=>w.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=x.current,t=v.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=$(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,f=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(f),n=t.get(o);d.current.push({edgeKey:A,fromCoord:We(e),toCoord:We(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=f.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A),n=Math.max(...r.map(A=>A.timestamp??0));if(f.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);0!==n.length&&(f.current=Math.max(...n.map(A=>A.timestamp??0)),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:ue,nodeCoordinates:$A,packets:fe,localHash:w,neighbors:e,meshTopology:u,enabled:RA});const{isExiting:ge,isAnimating:he,resetAnimationState:me}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:d=[],showNeighborLines:f=!0,neighborSourceId:g,neighborLinkScores:h=new Map}){const m=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;m.current=A});const b=A.useRef(new Map),p=A.useRef(1),x=A.useRef(new Map),v=A.useRef(new Map),w=A.useRef(!1),y=A.useRef(null),k=A.useRef(t),C=A.useRef(new Set),B=A.useRef(""),M=A.useRef(new Map),D=A.useRef(""),E=A.useRef(""),N=A.useRef(""),Q=A.useRef(r),j=A.useRef(n),P=A.useRef(o),F=A.useRef(i),S=A.useRef(a),L=A.useRef(s),I=A.useRef(l),R=A.useRef(d),T=A.useRef(f),_=A.useRef(h);A.useEffect(()=>{Q.current=r,j.current=n,P.current=o,F.current=i,S.current=a,L.current=s,I.current=l,R.current=d,T.current=f,_.current=h},[r,n,o,i,a,s,l,d,f,h]);const H=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,d;const f=m.current;if(!f)return;const h=f.getSource(c),w=f.getSource(u),y=f.getSource(g);if(h){const o=Se(Q.current,!0,b.current,p.current,x.current,v.current,P.current,F.current,S.current,L.current,I.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(b.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==D.current)&&(h.setData(o),D.current=i)}if(w){const e=Se(j.current,!1,b.current,p.current,x.current,v.current,P.current,F.current,S.current,L.current,I.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!==E.current)&&(w.setData(e),E.current=t)}if(y&&R.current.length>0){const e=Le(R.current,_.current),t=`${e.features.length}:${(null==(d=null==(l=e.features[0])?void 0:l.properties)?void 0:d.hash)??""}`;(A||t!==N.current)&&(y.setData(e),N.current=t)}},[c,u,g]),z=A.useCallback(()=>{y.current&&(cancelAnimationFrame(y.current),y.current=null),b.current=new Map,p.current=1,x.current=new Map,v.current=new Map,w.current=!1,C.current=new Set,B.current="",M.current=new Map},[]);return A.useEffect(()=>{const A=k.current,e=t;if(k.current=t,m.current){if(y.current&&(cancelAnimationFrame(y.current),y.current=null),A&&!e&&!w.current){w.current=!0;const A=new Map(b.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)b.current.set(e,t*(1-i));H(!0),o<1?y.current=requestAnimationFrame(t):(w.current=!1,b.current=new Map,C.current=new Set,B.current="",x.current=new Map,v.current=new Map,y.current=null,H(!0))};y.current=requestAnimationFrame(t)}!A&&e&&(b.current=new Map,C.current=new Set,B.current="")}},[t,H]),A.useEffect(()=>{const A=m.current;if(!t||w.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===C.current.size,a=""!==B.current&&B.current!==o;if(!i&&!a)return void H();const s=[],l=[];for(const{edge:t}of e)C.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(x.current=new Map(M.current),p.current=0),v.current=new Map;for(const{edge:t}of r){const A=vA(t.certainCount);v.current.set(t.key,A)}for(const t of s)b.current.set(t,0);for(const t of l)b.current.has(t)||b.current.set(t,1);if(s.length>0||a&&l.length>0){y.current&&(cancelAnimationFrame(y.current),y.current=null);let A=null;const e=Math.min(100,BA/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/BA,1);p.current=Fe(A)}H(!0);const o=BA+(s.length-1)*e;y.current=n{const A=m.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(d.length>0){const A=Le(d,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,d,h]),A.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=null)},[]),{isExiting:w.current,isAnimating:null!==y.current,resetAnimationState:z,weightAnimProgress:p.current,animStartWeights:x.current,animTargetWeights:v.current}}({map:ue,showTopology:N,validatedPolylines:oe,weakPolylines:ie,maxCertainCount:ce,loopEdgeKeys:se,backboneEdgeKeys:le,highlightedEdgeKey:s,neighbors:e,validatedSourceId:bt,weakSourceId:pt,neighborPolylines:ae,showNeighborLines:j,neighborSourceId:xt,neighborLinkScores:te}),be=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]),pe=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),d=A.useRef(new Map),f=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;f.current&&(cancelAnimationFrame(f.current),f.current=null);const a=g.current,s=h.current,p=m.current,x=b.current;for(const e of r)d.current.has(e)||d.current.set(e,Math.random());const v=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=x&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},w=[];for(const e of r){const t=v(e,A,n),r=v(e,o,i);t!==r&&w.push({hash:e,startOpacity:t?1:0,targetOpacity:r?1:0})}if(0===w.length)return;l(A=>{const e=new Map(A);for(const{hash:t,startOpacity:r}of w)e.set(t,r);return e});const y=w;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*(d.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Ie(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?f.current=requestAnimationFrame(C):(f.current=null,l(new Map))};return f.current=requestAnimationFrame(C),()=>{f.current&&(cancelAnimationFrame(f.current),f.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===R,soloHubs:"hubs"===R,neighborHashes:XA.map(([A])=>A),hubConnectedNodes:be,directNodeSet:ee,localConnectedNodes:pe,showTopology:N}),{blinkingNodes:ve,blinkColor:we}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=X(),a=A.useRef(q.getPackets());A.useEffect(()=>{a.current=q.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=AA(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const d=A.useRef(null);return A.useEffect(()=>{d.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=Re(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&d.current?l.current=requestAnimationFrame(d.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 f=0;for(const r of n){const A=$(r,t);if(!A||0===A.original.length)continue;const e=Te(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:e,localHash:n,enabled:RA}),ye=A.useCallback(A=>{if("all"===R)return!0;if("direct"===R)return ee.has(A);if("hubs"===R){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},[R,ee,u.hubNodes,u.validatedEdges]),Ce=A.useCallback(async()=>{mA(!0),dA(!0),gA("fetching"),pA(0),await d(),pA(g.packetCount),gA("analyzing"),await new Promise(A=>setTimeout(A,200)),gA("building");const A=Date.now(),e=Date.now()-A;e<1700&&await new Promise(A=>setTimeout(A,1700-e)),gA("complete"),await new Promise(A=>setTimeout(A,1e3)),dA(!1),mA(!1),me(),wA(!0),setTimeout(()=>{Q(!0)},150)},[d,me,g.packetCount]),Be=A.useCallback(()=>{xA?Q(A=>!A):Ce()},[xA,Ce]),Me=A.useCallback(A=>{B(A.viewState)},[]),De=A.useCallback(()=>{E(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})},[]),Ee=A.useCallback(A=>{T(A)},[]),Qe=A.useCallback(()=>{P(A=>!A)},[]),je=A.useCallback(()=>{S(A=>!A)},[]),Pe=A.useCallback(()=>{I(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})},[]),Ve=A.useCallback(()=>{N||Q(!0)},[N]),Ze=A.useCallback((A,e)=>{J(A),rA(e)},[]),Ke=A.useCallback(()=>{K&&o&&o(K),J(null),rA("")},[K,o]),Je=A.useMemo(()=>[...Dt,...mt],[]),Xe=A.useRef(!1);A.useEffect(()=>{Xe.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const qe=A.useCallback(A=>{!Xe.current||!GA||A.features&&0!==A.features.length||(OA(null),G(null))},[GA]),$e=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(z&&(G(null),OA(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]$/,"");G(e),A.lngLat&&OA({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{}},[z]),At=A.useCallback(()=>{var A;G(null),OA(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),et=D?"map-container-fullscreen":"map-container-16-9",tt=y.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),rt=!m||!tt,nt=tt;return t.jsxs("div",{className:`relative ${et}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions",children:[t.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."}),rt&&t.jsx("div",{className:"absolute inset-0 z-50 glass-card flex items-center justify-center","aria-hidden":"true",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),t.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),nt&&t.jsx("div",{className:`relative w-full h-full ${D?"":"rounded-[1.125rem] overflow-hidden"} ${rt?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:t.jsxs(U,{ref:c,...C,onMove:Me,mapStyle:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:Je,onMouseMove:$e,onMouseLeave:At,onClick:qe,onLoad:A=>{const e=A.target;try{const A=e.getStyle();if(null==A?void 0:A.layers){const t=["road","highway","tunnel","bridge","motorway","trunk","primary","secondary","tertiary","street","path","track"],r=A=>t.some(e=>A.toLowerCase().includes(e));for(const n of A.layers)"fill"===n.type&&n.id.toLowerCase().includes("water")&&e.setPaintProperty(n.id,"fill-color","rgba(22, 26, 32, 1)"),"line"===n.type&&r(n.id)&&e.setPaintProperty(n.id,"line-color","rgba(25, 26, 29, 1)"),"symbol"===n.type&&(e.setPaintProperty(n.id,"text-color","rgba(108, 110, 120, 0.85)"),e.setPaintProperty(n.id,"text-halo-color","rgba(8, 9, 11, 0.9)"),e.setPaintProperty(n.id,"text-halo-width",1),e.setLayoutProperty(n.id,"text-font",["Inter","Open Sans Regular","Arial Unicode MS Regular"]))}}catch(t){}},onError:A=>{},onIdle:()=>{if(!v&&!x&&c.current){const A=c.current.getMap();if(A){const t=Object.values(e).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)&&t.push({latitude:r.latitude,longitude:r.longitude}),t.length>0&&p(t,A)}}},children:[t.jsx(Y,{position:"bottom-right"}),t.jsx(Ne,{enabled:L,exaggeration:4}),t.jsx(ke,{coveragePoints:jA,visible:jA.length>0&&PA,terrainEnabled:L,brightness:FA}),t.jsx(Mt,{showTopology:N,isExiting:ge,hoveredEdgeKey:z,highlightedLoopEdges:null==UA?void 0:UA.highlightedEdgeKeys,onEdgeHover:WA,onLoopHover:VA,loops:u.loops,neighborNames:KA,opacityBias:O,widthMultiplier:W,trafficFilter:Z,showNeighborLines:j,disableHover:he||hA}),i&&t.jsx(Et,{targetHash:i,nodeCoordinates:$A,onComplete:a}),s&&t.jsx(Nt,{highlightedEdgeKey:s,validatedPolylines:oe,weakPolylines:ie,onEnsureTopology:Ve}),t.jsx(Pt,{ghost:l??null,neighborCoordinates:$A,onHighlightedNeighborsChange:NA}),t.jsx(ht,{neighborsWithLocation:XA,localNode:r,localHash:n,zeroHopNeighbors:ee,lastHopNeighborMap:Ae,meshTopology:u,hoveredMarker:_,onMarkerHover:H,getNodeOpacity:xe,shouldShowNode:ye,onRequestRemove:o?Ze:void 0,openPopupId:kA,onOpenPopup:MA,onClosePopup:DA,blinkingNodes:ve,blinkColor:we})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"edges in loop",value:A.size},{label:"strength",value:`${Math.round(100*A.strength)}%`,unit:"(weakest link)"}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`Part of ${t} overlapping loops`,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}(GA?{type:GA.type,properties:GA.properties}:null,UA,ce);return A&&t.jsx("div",{className:"map-edge-tooltip",children:t.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:t.jsx(Lt,{data:A})})})})(),t.jsx(QA,{mapRef:c,showNeighborLines:j,onToggleNeighborLines:Qe,hasNeighborPolylines:ae.length>0,nodeFilter:R,onNodeFilterChange:Ee,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:ee.size>0,showCoverage:F,onToggleCoverage:je,show3DTerrain:L,onToggle3DTerrain:Pe,isFullscreen:D,onToggleFullscreen:De}),t.jsxs("div",{className:"map-legend-stack",children:[t.jsx(SA,{isActive:N,hasAnalyzed:xA,isLoading:hA,onClick:Be}),t.jsx(IA,{isActive:RA,onClick:_A}),t.jsx(TA,{isActive:jA.length>0&&PA,onClick:LA}),t.jsx(EA,{showTopology:N,validatedPolylineCount:oe.length,filteredNeighborCount:XA.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:ee,neighborsWithLocation:XA})]}),!D&&t.jsx("div",{className:"glass-card-frame absolute inset-0 pointer-events-none rounded-[1.125rem]",style:{zIndex:9999},"aria-hidden":"true"}),t.jsx(cA,{isOpen:null!==K,onCancel:()=>J(null),onConfirm:Ke,title:"Remove Node?",message:`Remove "${tA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),t.jsx(yA,{isOpen:uA,currentStep:fA,packetCount:bA}),t.jsx(JA,{})]})}export{It as default}; +import{r as A,b as e,j as t,aa as r,ab as n,b9 as o,ba as i,h as a,at as s,ao as l,V as c,a2 as u,ad as d,k as f,aP as g,bb as h,bc as m,bd as b,be as p,af as x,A as v,aL as w,Z as y,bf as k,bg as C,bh as B,c as M,bi as D,X as E,bj as N,a8 as Q,bk as j,av as P,b2 as F,bl as S,$ as L,o as I,an as R,a5 as T,bm as _,au as H,b5 as z,b6 as G,b8 as O,b4 as U,bn as Y}from"./vendor-react-O8XH9yVn.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as W,c as V}from"./link-scoring-Bg3LiwiV.js";import{y as Z,B as K,T as J,at as X,au as q,av as $,e as AA,aw as eA,M as tA,N as rA,ax as nA,ay as oA,f as iA,G as aA,az as sA,aA as lA}from"./index-DGrzd8xb.js";import{C as cA}from"./ConfirmModal-DYznouaT.js";import{c as uA}from"./recharts-BU7auunF.js";import{g as dA,f as fA,h as gA,i as hA}from"./useThemeColors-CD0TSU03.js";import{p as mA,a as bA}from"./vendor-core-WoOfkQwm.js";import{P as pA,N as xA}from"./Contacts-DfRgoaov.js";import"./deckgl-DTsmDcfs.js";import"./PageLayout-DE5PEtD2.js";import"./HashBadge-aS_UIcg2.js";import"./SignalIndicator-BVAbF7xm.js";import"./CollisionExplorerModal-dc7PClY6.js";import"./leaflet-D_ckmI2R.js";function vA(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}function wA({label:A,icon:e,status:n,detail:o}){return t.jsxs("div",{className:uA("flex items-center gap-3 py-3 px-4 rounded-xl transition-all duration-300","active"===n&&"bg-accent-primary/10","complete"===n&&"bg-accent-success/10","pending"===n&&"opacity-40"),children:[t.jsx("div",{className:uA("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300","active"===n&&"bg-accent-primary/20","complete"===n&&"bg-accent-success/20","pending"===n&&"bg-white/5"),children:"complete"===n?t.jsx(r,{className:"w-4 h-4 text-accent-success"}):"active"===n?t.jsx(s,{className:"w-4 h-4 animate-spin text-accent-primary"}):t.jsx("span",{className:"text-text-muted",children:e})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:uA("text-sm font-medium transition-colors","active"===n&&"text-accent-primary","complete"===n&&"text-accent-success","pending"===n&&"text-text-muted"),children:A}),o&&"pending"!==n&&t.jsx("div",{className:"text-xs text-text-muted mt-0.5 truncate",children:o})]})]})}const yA=A.memo(function({isOpen:s,currentStep:l,packetCount:c,onClose:u}){if(A.useEffect(()=>{if(!s)return;const A=A=>{"Escape"===A.key&&u&&u()};window.addEventListener("keydown",A);const e=document.body.style.overflow,t=document.body.style.position,r=document.body.style.width,n=document.body.style.top,o=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${o}px`,()=>{window.removeEventListener("keydown",A),document.body.style.overflow=e,document.body.style.position=t,document.body.style.width=r,document.body.style.top=n,window.scrollTo(0,o)}},[s,u]),!s)return null;const d="complete"===l,f=A=>{const e=["fetching","analyzing","building","discovering","complete"],t=e.indexOf(l),r=e.indexOf(A);return r0?`${c.toLocaleString()} packets`:"Loading database..."}),t.jsx(wA,{label:"Analyzing Database",icon:t.jsx(i,{className:"w-4 h-4"}),status:f("analyzing"),detail:"Processing packet paths"}),t.jsx(wA,{label:"Building Topology",icon:t.jsx(n,{className:"w-4 h-4"}),status:f("building"),detail:"Computing mesh edges"}),t.jsx(wA,{label:"Discovering Nodes",icon:t.jsx(a,{className:"w-4 h-4"}),status:f("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..."})]})})]}),document.body)}),kA={nodeFill:"#F5F5F0",nodeStroke:"#4A5568",localColor:"#FBBF24",hubColor:"#8B7BAD",mobileColor:"#F97316",roomServerColor:"#E17899",neighborColor:"#FBBF24",edges:{rest:"#4B4B4B",restBright:"#616161",restDim:"#3F3F3F",hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:"#8A8A8A",hoverNeighbor:"#FBBF24",neighborRest:"#6B7280",neighborHover:"#FBBF24",highlight:"#FFD700"},edgeOpacity:.82};function CA(){if("undefined"==typeof window)return kA;const A=dA(),e=fA();return{nodeFill:A.nodeFill,nodeStroke:A.nodeStroke,localColor:A.localColor,hubColor:A.hubColor,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:kA.edges.neighborRest,neighborHover:kA.edges.neighborHover,highlight:e.highlight},edgeOpacity:kA.edgeOpacity}}const BA=2e3;function MA({text:A}){return t.jsx(J,{content:A,delay:200,children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted cursor-help"})})}function DA({title:A,tooltip:e,isOpen:r,onToggle:n,hasBorder:o=!1}){return t.jsxs("button",{onClick:n,className:"w-full flex items-center justify-between text-text-secondary font-medium py-1 hover:text-text-primary transition-colors "+(o?"mt-2 pt-2 border-t border-white/10":""),children:[t.jsxs("span",{className:"flex items-center gap-1",children:[A,t.jsx(MA,{text:e})]}),t.jsx(f,{className:"w-3 h-3 text-text-muted transition-transform duration-200 "+(r?"":"-rotate-90")})]})}function EA({showTopology:e,validatedPolylineCount:r,filteredNeighborCount:n,hasLocalNode:o,meshTopology:i,zeroHopNeighbors:s,neighborsWithLocation:f}){const g=gA(),h=Z(),m=K(),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}(i),[x,v]=A.useState(!0),[w,y]=A.useState(!0),[k,C]=A.useState(!0);return t.jsxs("div",{className:"map-control-glass text-xs",style:{padding:"0.625rem"},children:[t.jsx(DA,{title:"Nodes",tooltip:"Node type shown by shape. Yellow = direct RF neighbor.",isOpen:x,onToggle:()=>v(!x)}),x&&t.jsxs("div",{className:"flex flex-col gap-1 mt-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.nodeFill}}),t.jsx("span",{className:"text-text-muted",children:"Node"}),t.jsx(MA,{text:"Standard mesh node. Can be a repeater, client, or companion device."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.hubColor}}),t.jsx("span",{className:"text-text-muted",children:"Hub"}),t.jsx(MA,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow."})]}),(B=f,B.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})&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(l,{className:"w-3 h-3 flex-shrink-0",style:{color:g.roomColor},strokeWidth:2.5}),t.jsx("span",{className:"text-text-muted",children:"Room"}),t.jsx(MA,{text:"Room Server identity. Hosts a chat room that clients can sync messages with."})]})),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(c,{className:"w-3 h-3 flex-shrink-0",style:{color:g.localColor},strokeWidth:2.5}),t.jsx("span",{className:"text-text-muted",children:"Local"}),t.jsx(MA,{text:"Your repeater. This is the node running pyMC_Repeater that you're connected to."})]}),s.size>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded flex-shrink-0",style:{width:"12px",height:"8px",backgroundColor:g.neighborColor}}),t.jsx("span",{className:"text-text-muted",children:"Neighbor"}),t.jsx(MA,{text:"Zero-hop direct RF contact. Color indicates we receive their ADVERTs directly."})]}),i.gatewayNodes.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:g.hubColor,opacity:.7}}),t.jsx("span",{className:"text-text-muted",children:"Gateway"}),t.jsx(MA,{text:"Significant traffic forwarder (7-10% of last-hop traffic). Gateways relay substantial traffic to the local node."})]}),p>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",backgroundColor:"rgb(168, 85, 247)",opacity:.8}}),t.jsx("span",{className:"text-text-muted",children:"Backbone"}),t.jsx(MA,{text:"Critical relay with 4+ neighbors and high betweenness centrality. Backbone nodes carry the majority of mesh traffic."})]}),i.mobileNodes.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:"14px",height:"14px",background:"transparent",border:`4px solid ${g.mobileColor}`,boxSizing:"border-box"}}),t.jsx("span",{className:"text-text-muted",children:"Mobile"}),t.jsx(MA,{text:"Volatile node that frequently appears/disappears from paths. Likely a portable or vehicle-mounted device."})]}),b>0&&t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(a,{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--accent-tertiary)"},strokeWidth:2.5}),t.jsxs("span",{className:"text-text-muted",children:["Ghost (",b,")"]}),t.jsx(MA,{text:"Unknown repeater discovered via Viterbi HMM path analysis. These nodes appear in paths but aren't in our neighbor table."})]})]}),s.size>0&&t.jsxs(t.Fragment,{children:[t.jsx(DA,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional link balance. 2-Way = balanced. Listener = they hear us. Loud = they route to us.",isOpen:w,onToggle:()=>y(!w),hasBorder:!0}),w&&t.jsxs("div",{className:"flex flex-col gap-1 mt-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.YELLOW}}),t.jsx("span",{className:"text-text-muted",children:"2-Way"}),t.jsx(MA,{text:"33-67% balanced. Ideal bidirectional link - this neighbor both hears us and routes traffic to us equally well."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.GREEN}}),t.jsx("span",{className:"text-text-muted",children:"Listener"}),t.jsx(MA,{text:">67% listener score. This neighbor hears our transmissions well (good RX from us)."})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"flex-shrink-0 rounded-sm",style:{width:"16px",height:"3px",backgroundColor:W.RED}}),t.jsx("span",{className:"text-text-muted",children:"Loud"}),t.jsx(MA,{text:"<33% listener score. This neighbor routes more traffic TO us than they hear from us."})]})]})]}),e&&r>0&&t.jsxs(t.Fragment,{children:[t.jsx(DA,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = relative strength.",isOpen:k,onToggle:()=>C(!k),hasBorder:!0}),k&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col gap-0.5 text-text-muted mt-1",children:[t.jsxs("div",{className:"flex justify-between tabular-nums",children:[t.jsx("span",{children:"Nodes"}),t.jsx("span",{className:"text-text-secondary",children:n+(o?1:0)})]}),i.hubNodes.length>0&&t.jsxs("div",{className:"flex justify-between tabular-nums",children:[t.jsx("span",{children:"Hubs"}),t.jsx("span",{style:{color:kA.hubColor},children:i.hubNodes.length})]})]}),i.loops.length>0&&t.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(u,{className:"w-3 h-3 flex-shrink-0",style:{color:kA.edges.hoverLoop}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:kA.edges.hoverLoop},className:"font-medium",children:[i.loops.length," ",1===i.loops.length?"Loop":"Loops"]}),t.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"Redundant paths"})]})]})}),m.totalPaths>0&&t.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-white/10",children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(d,{className:"w-3 h-3 flex-shrink-0",style:{color:"var(--accent-primary)"}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:"var(--accent-primary)"},className:"font-medium",children:[m.totalPaths.toLocaleString()," Viterbi"]}),t.jsx("span",{className:"text-text-muted text-[10px] leading-tight",children:"HMM decoded paths"})]})]})})]})]})]});var B}function NA({options:A,value:e,onChange:r,size:n="sm",className:o=""}){const i={sm:"text-[10px] px-1.5 py-0.5",md:"text-xs px-2 py-1"};return t.jsx("div",{className:`inline-flex rounded-md bg-black/40 p-0.5 ${o}`,role:"radiogroup",children:A.map(A=>{const o=e===A.value;return t.jsx("button",{onClick:()=>r(A.value),className:`\n ${i[n]}\n rounded transition-all font-medium\n ${o?"bg-white/15 text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary hover:bg-white/5"}\n `,role:"radio","aria-checked":o,title:A.title,children:A.icon?t.jsxs("span",{className:"flex items-center gap-1",children:[A.icon,t.jsx("span",{className:"hidden sm:inline",children:A.label})]}):A.label},A.value)})})}function QA({mapRef:A,showNeighborLines:e,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:c,show3DTerrain:u,onToggle3DTerrain:d,isFullscreen:f,onToggleFullscreen:g}){const y=[{value:"all",label:"All",title:"Show all nodes"},...a?[{value:"hubs",label:"Hubs",title:"Show only hub nodes and their connections"}]:[],...s?[{value:"direct",label:"Direct",title:"Show only zero-hop (direct RF) neighbors"}]:[]];return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"absolute top-3 right-3 z-[600] map-controls-container sm:top-4 sm:right-4",children:t.jsxs("div",{className:"map-controls-row",children:[n&&t.jsx("button",{onClick:r,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:e?{backgroundColor:"#1a1408"}:void 0,title:e?"Hide neighbor lines":"Show neighbor lines","aria-label":e?"Hide neighbor lines":"Show neighbor lines","aria-pressed":e,children:t.jsx(h,{className:"map-control-icon "+(e?"text-amber-400":"text-text-secondary")})}),y.length>1&&t.jsx(NA,{options:y,value:o,onChange:i,size:"sm"}),t.jsx("button",{onClick:d,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:u?{backgroundColor:"#0a1a1a"}:void 0,title:u?"Disable 3D terrain":"Enable 3D terrain","aria-label":u?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":u,children:t.jsx(m,{className:"map-control-icon "+(u?"text-teal-400":"text-text-secondary")})}),t.jsx("button",{onClick:g,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",title:f?"Exit fullscreen":"Fullscreen","aria-label":f?"Exit fullscreen":"Enter fullscreen","aria-pressed":f,children:f?t.jsx(b,{className:"map-control-icon text-text-secondary"}):t.jsx(p,{className:"map-control-icon text-text-secondary"})})]})}),t.jsx("div",{className:"absolute top-[3.5rem] right-3 z-[600] map-controls-container sm:top-[4rem] sm:right-4 lg:top-[4.5rem]",children:t.jsxs("div",{className:"flex flex-col items-stretch map-nav-module",children:[t.jsx("button",{onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomIn()},className:"map-control-btn hover:bg-white/5 flex items-center justify-center",title:"Zoom in","aria-label":"Zoom in",children:t.jsx(x,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:()=>{var e,t;null==(t=null==(e=A.current)?void 0:e.getMap())||t.zoomOut()},className:"map-control-btn hover:bg-white/5 border-t border-white/6 flex items-center justify-center",title:"Zoom out","aria-label":"Zoom out",children:t.jsx(v,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:()=>{var e;const t=null==(e=A.current)?void 0:e.getMap();t&&t.easeTo({bearing:0,pitch:0,duration:300})},className:"map-control-btn hover:bg-white/5 border-t border-white/6 flex items-center justify-center",title:"Reset bearing to north","aria-label":"Reset bearing to north",children:t.jsx(w,{className:"map-control-icon text-text-secondary"})})]})})]})}const jA="#4ADE80",PA="DeepAnalysis";function FA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function SA({isActive:e,hasAnalyzed:r,isLoading:o,onClick:i}){const[a,l]=A.useState(!1),[c,u]=A.useState(PA),d=A.useRef(!1),f=A.useRef(null),[g]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),h=a&&!e&&!o&&g;A.useEffect(()=>{if(a&&!e&&!o&&!d.current){d.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{f.current&&cancelAnimationFrame(f.current)}},[a,e,o]);const m=o?"Analyzing...":c;return t.jsxs("button",{onClick:i,onMouseEnter:()=>g&&l(!0),onMouseLeave:()=>g&&l(!1),onPointerEnter:()=>g&&l(!0),onPointerLeave:()=>g&&l(!1),disabled:o,className:`map-control-btn flex items-center gap-2 w-full text-left transition-colors ${e?"map-control-glass-active":"map-control-glass"} ${o?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#0a1a0a":"#050505"},title:o?"Analyzing packet history...":r?e?"Hide topology edges":"Show topology edges":"Load full packet history and build topology",children:[o?t.jsx(s,{className:"w-3.5 h-3.5 flex-shrink-0 text-green-400 animate-spin"}):t.jsx(n,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-green-400":"text-text-secondary"),style:h?{color:jA}:void 0}),t.jsx("span",{className:e?"text-green-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:e||h?700:500,letterSpacing:"-0.01em",lineHeight:1,...h?{color:jA}:{}},children:m})]})}const LA="#00FFFF";function IA({isActive:e,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),d=A.useRef(!1),[f]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!e&&f;A.useEffect(()=>{g&&!d.current&&(d.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(d.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!e&&!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,e]);const h=A=>{if(e)return;if(!g)return;const t=11*i;return A>=t-2&&Af&&o(!0),onMouseLeave:()=>f&&o(!1),onPointerEnter:()=>f&&o(!0),onPointerLeave:()=>f&&o(!1),className:"map-control-btn flex items-center gap-2 w-full text-left transition-colors "+(e?"map-control-glass-active":"map-control-glass"),style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#0a2a2a":"#050505"},title:e?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[t.jsx(y,{className:"w-3.5 h-3.5 flex-shrink-0 "+(e?"text-cyan-400":"text-text-secondary"),fill:1===c?"#FFFFFF":3===c?LA:"none",stroke:1===c||2===c?"#FFFFFF":g?LA:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),t.jsx("span",{className:e?"text-cyan-400":"text-text-secondary",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:e||g?700:500,letterSpacing:"-0.01em",lineHeight:1},children:"LiveTrace".split("").map((A,e)=>t.jsx("span",{style:{color:h(e)||void 0},children:A},e))})]})}const RA="#fe8019";function TA({isActive:e,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(()=>{if(!i||e)return;const A=requestAnimationFrame(()=>l(!0)),t=setTimeout(()=>l(!1),80);return()=>{cancelAnimationFrame(A),clearTimeout(t)}},[i,e]);const u=Math.max(.01,Math.min(1,n)),d=u<.999,f=u>.011,g=i&&!e&&c;return t.jsxs("button",{onClick:r,onMouseEnter:()=>c&&a(!0),onMouseLeave:()=>c&&a(!1),onPointerEnter:()=>c&&a(!0),onPointerLeave:()=>c&&a(!1),className:"map-control-btn flex items-center gap-2 w-full text-left transition-colors "+(e?"map-control-glass-active":"map-control-glass"),style:{padding:"0.5rem 0.625rem",backgroundColor:e?"#1a1408":"#050505"},title:e?"Configure wardriving coverage":"Show wardriving coverage",children:[t.jsx(k,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-amber-400":"text-text-secondary"),style:g?{color:RA}:void 0}),t.jsx("span",{className:e?"text-amber-400":"text-text-secondary",style:{fontFamily:e||g?"'Jacquard 12', serif":"ui-monospace, SFMono-Regular, monospace",fontSize:e||g?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:e?"scale(1.45)":g?`scale(${s?1.595:1.45})`:void 0,transformOrigin:"left center",...g?{color:RA}:{}},children:"Wardrive"}),e&&o&&t.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[t.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.max(.01,u-.2);null==o||o(e)},disabled:!f,className:"p-0.5 rounded transition-colors "+(f?"hover:bg-[#252525] text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:t.jsx(C,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:A=>{A.stopPropagation();const e=Math.min(1,u+.2);null==o||o(e)},disabled:!d,className:"p-0.5 rounded transition-colors "+(d?"hover:bg-[#252525] text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:t.jsx(B,{className:"w-3.5 h-3.5"})})]})]})}function _A(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 HA(A){return Math.exp(-A*Math.LN2/7)}const zA="pymc-wardriving-url",GA="pymc-wardriving-enabled",OA="pymc-wardriving-brightness";function UA(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(zA,A):localStorage.removeItem(zA))}function YA(A){"undefined"!=typeof localStorage&&localStorage.setItem(GA,String(A))}function WA(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(OA);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function VA(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 ZA=M((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(GA),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(zA)||"",brightness:WA(),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(OA,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;YA(t),A({isVisible:t})},setVisible:e=>{YA(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}=_A(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=HA(i),s=VA(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()}),UA(e.trim()),YA(!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:""}),UA(""),YA(!1)}}));function KA({status:A}){if("connecting"!==A&&"loading"!==A&&"processing"!==A)return null;const e={idle:"",connecting:"Connecting to server...",loading:"Fetching coverage data...",processing:"Processing coverage points...",success:"",error:""}[A];return e?t.jsxs("div",{className:"flex items-center gap-3 p-4 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[t.jsx("div",{className:"relative",children:t.jsx(s,{className:"w-5 h-5 text-amber-400 animate-spin"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-amber-400 font-medium",children:e}),t.jsx("div",{className:"mt-2 h-1 bg-amber-500/20 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-amber-400 rounded-full transition-all duration-300",style:{width:"connecting"===A?"30%":"loading"===A?"60%":"90%"}})})]})]}):null}function JA(){const{isModalOpen:e,closeModal:n,status:i,isVisible:a,stats:l,error:c,url:u,brightness:f,loadCoverage:g,clearCoverage:h,toggleVisibility:m,setUrl:b,setBrightness:p}=ZA(),x="connecting"===i||"loading"===i||"processing"===i,[v,w]=A.useState(u),y=A.useCallback(async()=>{await g(v)},[v,g]),k=A.useCallback(()=>{w(""),h()},[h]),C=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||x||(A.preventDefault(),y())},[y,x]),M=A.useCallback(A=>{const e=A.target.value;w(e),b(e)},[b]);if(!e)return null;const S=l.coverageCount>0,L=v.trim().length>0&&!x;return t.jsxs("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center",children:[t.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-md",onClick:x?void 0:n}),t.jsxs("div",{className:"relative glass-card-elevated w-full max-w-md mx-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-amber-500/20",children:t.jsx(D,{className:"w-5 h-5 text-amber-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:"Wardriving Coverage"}),t.jsx("p",{className:"text-xs text-text-muted",children:"Overlay RF coverage heatmap"})]})]}),t.jsx("button",{onClick:n,disabled:x,className:"p-2 rounded-lg hover:bg-[#252525] transition-colors disabled:opacity-50",children:t.jsx(E,{className:"w-5 h-5 text-text-secondary"})})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Coverage Server URL"}),t.jsx("input",{type:"url",value:v,onChange:M,onKeyDown:C,placeholder:"https://coverage.wcmesh.com",className:"w-full px-4 py-3 bg-black/30 border border-border rounded-xl text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-amber-500/50 focus:border-amber-500/50 transition-all disabled:opacity-50",disabled:x}),t.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:"Enter the base URL of a wardriving coverage server (e.g., coverage.wcmesh.com)"})]}),t.jsx(KA,{status:i}),"error"===i&&c&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/30 rounded-xl",children:[t.jsx(N,{className:"w-5 h-5 text-red-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-red-400 font-medium",children:"Connection Failed"}),t.jsx("p",{className:"text-xs text-red-400/80 mt-0.5",children:c})]})]}),"success"===i&&S&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-500/10 border border-green-500/30 rounded-xl",children:[t.jsx(r,{className:"w-5 h-5 text-green-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-green-400 font-medium",children:"Data Loaded Successfully"}),t.jsxs("p",{className:"text-xs text-green-400/80 mt-0.5",children:[l.coverageCount.toLocaleString()," coverage points • ",l.repeaterCount.toLocaleString()," repeaters"]})]})]}),S&&!x&&"success"!==i&&t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl",children:[t.jsx(Q,{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm text-amber-400 font-medium",children:"Coverage Data Loaded"}),t.jsxs("p",{className:"text-xs text-amber-400/80 mt-0.5",children:[l.coverageCount.toLocaleString()," points •",l.lastUpdated&&` Last updated ${l.lastUpdated.toLocaleTimeString()}`]})]})]}),S&&!x&&t.jsx("div",{className:"p-3 bg-black/20 border border-border-subtle rounded-xl",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(B,{className:"w-4 h-4 flex-shrink-0 "+(f>.5?"text-amber-400":"text-text-muted")}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-xs text-text-secondary",children:"Brightness"}),t.jsxs("span",{className:"text-xs text-text-muted font-mono",children:[Math.round(100*f),"%"]})]}),t.jsx("input",{type:"range",min:"1",max:"100",value:100*f,onChange:A=>p(Number(A.target.value)/100),className:"w-full h-1.5 cursor-pointer accent-amber-400"})]})]})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 border-t border-border-subtle",children:[t.jsx("div",{className:"flex items-center gap-2",children:S&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:m,disabled:x,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-text-secondary hover:text-text-primary hover:bg-[#202020] rounded-lg transition-colors disabled:opacity-50",title:a?"Hide heatmap":"Show heatmap",children:a?t.jsxs(t.Fragment,{children:[t.jsx(j,{className:"w-3.5 h-3.5"})," Hide"]}):t.jsxs(t.Fragment,{children:[t.jsx(d,{className:"w-3.5 h-3.5"})," Show"]})}),t.jsxs("button",{onClick:k,disabled:x,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-colors disabled:opacity-50",title:"Clear coverage data",children:[t.jsx(P,{className:"w-3.5 h-3.5"})," Clear"]})]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:n,disabled:x,className:"px-4 py-2 text-sm font-medium text-text-secondary hover:bg-[#252525] rounded-lg transition-colors disabled:opacity-50",children:S?"Done":"Cancel"}),t.jsx("button",{onClick:y,disabled:!L,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium bg-amber-500 hover:bg-amber-400 text-black rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:x?t.jsxs(t.Fragment,{children:[t.jsx(s,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):S?t.jsxs(t.Fragment,{children:[t.jsx(o,{className:"w-4 h-4"}),"Refresh"]}):t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}const XA={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{}}},qA=M()(mA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:bA(()=>XA)}));var $A=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,d,f,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function x(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}(f,A,e):""}function v(A,e){return A%e>0&&(A+=e-A%e),A}function w(A){u=A,t.HEAP8=d=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=f=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,w(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function N(A){D.unshift(A)}var Q=Math.abs,j=Math.ceil,P=Math.floor,F=Math.min,S=0,L=null;t.preloadedImages={},t.preloadedAudios={};var I,R,T=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return d.length}T="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|I(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|I(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return P=i,0|a}function L(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,d=0,f=0,g=0,h=0,m=0;if(a=P,P=P+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return P=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 P=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(f=1,d=0,g=0,h=1,s=A;;){if(!(d|g)){if(0|(s=0|R(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|R(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+(f<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(f<<2)>>2]=h,l=(0|(A=d+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}f=f+1|0,d=l?0:A,g=l?u?0:c:g}else for(f=1,d=0,g=0,h=1,s=A;;){if(!(d|g)){if(0|(s=0|R(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|R(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+(f<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=d+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}f=f+1|0,d=l?0:A,g=l?u?0:c:g}else s=0}while(0);return P=a,0|s}function I(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,d=0,f=0,g=0,h=0,m=0,b=0,p=0;if(u=P,P=P+16|0,l=u+8|0,c=u,d=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(d<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(f=(0|p)==(0|A)&(0|b)==(0|e))))do{d=0|$e(0|(d=0|Ve(0|d,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),f=(0|(b=0|n[(p=h=r+(d<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|f));if(d=o+(d<<2)|0,f&&(0|n[d>>2])<=(0|s))return P=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[d>>2]=s,(0|s)>=(0|t))return P=u,0;switch(f=s+1|0,n[l>>2]=0,0|(d=0|R(A,e,2,l,c))){case 9:m=9;break;case 0:(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(d=0|R(A,e,3,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,1,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,5,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,4,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}switch(n[l>>2]=0,0|(d=0|R(A,e,6,l,c))){case 9:break;case 0:if(0|(d=0|I(0|n[(d=c)>>2],0|n[d+4>>2],t,r,o,i,a,f)))break A;break;default:break A}return P=u,0}}while(0);return P=u,0|d}function R(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,d=0,f=0,g=0;if((t|=0)>>>0>6)return 1;if(d=(0|n[(r|=0)>>2])%6|0,n[r>>2]=d,(0|d)>0){s=0;do{t=0|xA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(d=0|tt(0|A,0|e,45),B(),(a=127&d)>>>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,f=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&~f,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&d){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 T(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,d=0,f=0,g=0,h=0;if(i=P,P=P+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return P=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,P=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|R(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[(f=r)>>2]=g,n[f+4>>2]=e,f=t+-1|0,d=0,A=1;do{if(a=26800+(d<<2)|0,5==(0|d))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|R(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|f)){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|R(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}d=d+1|0}while(d>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return P=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=P,P=P+16|0,o=a,i=a+8|0,s=(s=!(0|HA(A|=0,e|=0)))?1:2;;){if(n[i>>2]=0,!(0|R(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)?(P=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,d,f,g,h,m,b,p,x=0,v=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,N=0,Q=0,j=0,F=0,S=0,L=0,I=0,R=0,T=0,_=0;if(p=P,P=P+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(v=0|n[(A|=0)>>2]))<=0)return P=p,0;for(u=A+4|0,d=h+8|0,f=m+8|0,g=l+8|0,x=0,F=0;;){j=(w=0|n[u>>2])+(F<<4)|0,n[h>>2]=n[j>>2],n[h+4>>2]=n[j+4>>2],n[h+8>>2]=n[j+8>>2],n[h+12>>2]=n[j+12>>2],(0|F)==(v+-1|0)?(n[m>>2]=n[w>>2],n[m+4>>2]=n[w+4>>2],n[m+8>>2]=n[w+8>>2],n[m+12>>2]=n[w+12>>2]):(j=w+(F+1<<4)|0,n[m>>2]=n[j>>2],n[m+4>>2]=n[j+4>>2],n[m+8>>2]=n[j+8>>2],n[m+12>>2]=n[j+12>>2]),v=0|tA(h,m,r,b);A:do{if(v)w=0,x=v;else if(w=0|n[(v=b)>>2],(0|(v=0|n[v+4>>2]))>0|!(0|v)&w>>>0>0){Q=0,j=0;e:for(;;){if(R=1/(+(w>>>0)+4294967296*+(0|v)),_=+o[h>>3],T=+((v=0|Ze(0|w,0|v,0|Q,0|j))>>>0)+4294967296*+(0|B()),I=+(Q>>>0)+4294967296*+(0|j),o[l>>3]=R*(_*T)+R*(+o[m>>3]*I),o[g>>3]=R*(+o[d>>3]*T)+R*(+o[f>>3]*I),0|(v=0|KA(l,r,c))){x=v;break}C=0|At(0|(E=0|n[(N=c)>>2]),0|(N=0|n[N+4>>2]),0|e,0|t),y=0|B(),w=0|n[(k=v=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|w)&!(0|k))S=v,L=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){x=1;break e}if((0|w)==(0|E)&(0|k)==(0|N))break t;if(C=0|$e(0|(v=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|(w=0|n[(k=v=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){S=v,L=16;break}}}while(0);if(16!=(0|L)||(L=0,!(0|E)&!(0|N))||(n[(D=S)>>2]=E,n[D+4>>2]=N,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=N,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(N=i)>>2]=D,n[N+4>>2]=E),Q=0|Ve(0|Q,0|j,1,0),j=0|B(),w=0|n[(v=b)>>2],!((0|(v=0|n[v+4>>2]))>(0|j)|(0|v)==(0|j)&w>>>0>Q>>>0)){w=1;break A}}w=0}else w=1}while(0);if(F=F+1|0,!w){L=21;break}if((0|F)>=(0|(v=0|n[A>>2]))){x=0,L=21;break}}return 21==(0|L)?(P=p,0|x):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=P,P=P+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),P=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,d,f,g,h=0,m=0,b=0,p=0,v=0,y=0,k=0;f=P,P=P+288|0,d=f+264|0,p=f+96|0,m=(h=b=f)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(P=f,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],d),$A(b,m,p),u=+ae(d,p+8|0),o[d>>3]=+o[A>>3],o[(m=d+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(d,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[d>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+x(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,v=~~k>>>0,y=+l(k)>=1?k>0?~~+w(+s(k/4294967296),4294967295)>>>0:~~+x((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|v)&!(0|y),n[(e=t)>>2]=p?1:v,n[e+4>>2]=p?0:y,e=0):e=1,P=f,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,d,f=0,g=0,h=0;d=P,P=P+288|0,c=d+264|0,u=d+96|0,a=(f=g=d)+96|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|a));return 0|(t=0|Ae(t,g))?(P=d,0|(r=t)):(qA(f=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(f,t,u),h=+ae(c,u+8|0),h=+x(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,f=+l(h)>=1?h>0?~~+w(+s(h/4294967296),4294967295)>>>0:~~+x((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|f),n[r>>2]=g?1:t,n[r+4>>2]=g?0:f,P=d,0|(r=0)):(P=d,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|v(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|v(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|v(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 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*+((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 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*+(((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 xA(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 vA(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 wA(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|IA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=P,P=P+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=P,P=P+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return P=r,-1;if(1==(0|t)&(o=!!(0|o)))return P=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 P=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,P=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)?NA(r,e,i,2,t):FA(r,e,i,2,t),P=o,0|(a=0))):(P=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=+d(+t),t=+f(+t),e=s*+f(+e)+ +d(+a)*(t*+d(+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/+d(+e),a=t*+f(+a)*c,t=+o[A>>3],e=c*((s-+f(+e)*+f(+t))/+d(+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 NA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,d,f,g,h,m,b,p,x,v,w,y,k,C,B,D,E,N,Q=0,j=0,F=0,S=0,L=0,I=0;if(N=P,P=P+272|0,S=N+240|0,B=N,D=N+224|0,E=N+208|0,b=N+176|0,p=N+160|0,x=N+192|0,v=N+144|0,w=N+128|0,y=N+112|0,k=N+96|0,C=N+80|0,n[(Q=N+256|0)>>2]=e,n[S>>2]=n[A>>2],n[S+4>>2]=n[A+4>>2],n[S+8>>2]=n[A+8>>2],n[S+12>>2]=n[A+12>>2],QA(S,Q,B),n[i>>2]=0,(0|(S=r+t+(5==(0|r)&1)|0))<=(0|t))P=N;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[Q>>2])<<2)|0,d=16960+(a<<2)|0,f=w+8|0,g=y+8|0,h=k+8|0,m=E+4|0,F=t;A:for(;;){j=B+((0|F)%5<<4)|0,n[E>>2]=n[j>>2],n[E+4>>2]=n[j+4>>2],n[E+8>>2]=n[j+8>>2],n[E+12>>2]=n[j+12>>2];do{}while(2==(0|jA(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],Q=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*Q|0)>>2],(0|(j=0|n[18640+(80*r|0)+(20*Q|0)+16>>2]))>0){A=0;do{bA(l),A=A+1|0}while((0|A)<(0|j))}switch(j=18640+(80*r|0)+(20*Q|0)+4|0,n[x>>2]=n[j>>2],n[x+4>>2]=n[j+4>>2],n[x+8>>2]=n[j+8>>2],sA(x,3*(0|n[u>>2])|0),iA(l,x,l),nA(l),oA(l,v),L=+(0|n[d>>2]),o[w>>3]=3*L,o[f>>3]=0,I=-1.5*L,o[y>>3]=I,o[g>>3]=2.598076211353316*L,o[k>>3]=I,o[h>>3]=-2.598076211353316*L,0|n[17040+(80*(0|n[b>>2])|0)+(n[E>>2]<<2)>>2]){case 1:A=y,r=w;break;case 3:A=k,r=y;break;case 2:A=w,r=k;break;default:A=12;break A}Qe(p,v,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|S)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):P=N}}function QA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=P,P=P+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,wA(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),P=r}function jA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,d=0,f=0,g=0,h=0;if(c=P,P=P+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[(d=A+12|0)>>2])|0))==(0|g))return P=c,1;f=d}else u=o+u+(r=0|n[(f=A+12|0)>>2])|0;if((0|u)<=(0|g))return P=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){d=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),d=r,r=A):(d=r,r=A)}else d=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[d>>2],(0|n[(u=d+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=d+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[f>>2])|0)==(0|g)?1:2,P=c,0|r}function PA(A,e){A|=0,e|=0;var t=0;do{t=0|jA(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,d,f,g,h,m,b,p,x,v,w,y,k,C,B=0,D=0,E=0,N=0,Q=0;if(C=P,P=P+240|0,v=C+208|0,w=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,x=C+96|0,n[(B=C+224|0)>>2]=e,n[v>>2]=n[A>>2],n[v+4>>2]=n[A+4>>2],n[v+8>>2]=n[A+8>>2],n[v+12>>2]=n[A+12>>2],SA(v,B,w),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))P=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,d=p+8|0,f=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=w+((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|jA(y,a,0,1),(0|E)>(0|t)&!!(0|ZA(e))&&1!=(0|A)&&(0|n[y>>2])!=(0|r)){switch(oA(w+((B+5|0)%6<<4)+4|0,k),oA(w+(B<<4)+4|0,h),N=+(0|n[l>>2]),o[m>>3]=3*N,o[c>>3]=0,Q=-1.5*N,o[b>>3]=Q,o[u>>3]=2.598076211353316*N,o[p>>3]=Q,o[d>>3]=-2.598076211353316*N,B=0|n[v>>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}Qe(k,h,r,A,x),0|je(k,x)||0|je(h,x)||(EA(x,0|n[v>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(f,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):P=C}}function SA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=P,P=P+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,wA(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),P=r}function LA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function IA(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 RA(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 TA(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|xA(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|xA(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|xA(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|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(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|vA(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|vA(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=P,P=P+16|0,i=r,(e|=0)>>>0>15?(P=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=P,P=P+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=P,P=P+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=P,P=P+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+d(+n),n=+f(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+d(+n),o[e>>3]=r,n=t*+f(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Pe(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Pe(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Pe(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Pe(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Pe(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Pe(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Pe(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Pe(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Pe(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Pe(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Pe(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Pe(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Pe(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Pe(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Pe(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Pe(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Pe(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Pe(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Pe(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Pe(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,P=i):P=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(P=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=+d(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+f(+n),t=+o[A>>3],+ +p(+a,+(+f(+i)*+d(+t)-+d(+n)*(r*+f(+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=+d(+l)*a,o[r>>3]=s,l=+f(+l)*a,o[r+8>>3]=l,P=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,d=0,f=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],d=+l(+r),i=+o[A+8>>3],d+=.5*(f=1.1547005383792515*+l(+i)),d-=+(0|(s=~~d)),f-=+(0|(A=~~f));do{if(d<.5){if(d<.3333333333333333){if(n[e>>2]=s,f<.5*(d+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(f<(h=1-d)))+A|0,n[e+4>>2]=A,h<=f&f<2*d){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(d<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,f<.5*d){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(f<1-d){if(n[e+4>>2]=A,2*d-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),P=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=P,P=P+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)),P=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),P=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?(dA(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)):(fA(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|xA(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|vA(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|xA(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)),P=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),P=r,0|(i=0)):(P=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=P,P=P+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,P=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|vA(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 P=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|jA(t,s,i,0)){if(0|z(u))do{}while(0|jA(t,s,0,0));(0|s)!=(0|c)&&fA(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 P=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=P,P=P+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(P=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=P,P=P+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),P=r}(r,15&i,t),P=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=P,P=P+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return P=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 NA(i,o,0,5,t),P=r,0}}while(0);return FA(i,o,0,6,t),P=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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+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,x=0;return x=+o[(e|=0)>>3],i=+o[A>>3],m=+f(.5*(x-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+f(.5*(u-n)),r=+d(+i),a=+d(+x),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],x=+f(.5*(m-x)),s=+o[t+8>>3],u=+f(.5*(s-u)),l=+d(+m),u=2*+p(+ +c(+(u=x*x+u*(a*l*u))),+ +c(+(1-u))),m=+f(.5*(i-m)),s=+f(.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=P,P=P+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return P=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,P=a,0}function de(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 fe(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,d=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],d=0|n[(t=t+16|0)>>2],a=+o[(d=0|d?d:A)>>3],l=+o[d+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],d=0|n[(t=t+16|0)>>2],a=+o[(d=0|d?d:A)>>3],l=+o[d+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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(c=P,P=P+32|0,v=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 P=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 P=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(f=0|V(h,m))))return P=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=f,d=g)}else p=0,d=0;a=0|z(h),s=0|z(m),n[v>>2]=0,n[v+4>>2]=0,n[v+8>>2]=0,n[v+12>>2]=0;do{if(p){if(f=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(f){h=0,g=t,f=o;do{g=0|WA(g,f),f=0|B(),1==(0|(d=0|vA(d)))&&(d=0|vA(1)),h=h+1|0}while((0|h)!=(0|m));m=d,h=g,g=f}else m=d,h=t,g=o;else if(f){h=0,g=t,f=o;do{g=0|VA(g,f),f=0|B(),d=0|vA(d),h=h+1|0}while((0|h)!=(0|m));m=d,h=g,g=f}else m=d,h=t,g=o;if(JA(h,g,v),b||M(27563,27538,191,27548),(f=!!(0|a))&(d=!!(0|s))&&M(27590,27538,192,27548),f){if(7==(0|(d=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*d|0)+p|0]){u=1;break}h=g=0|n[21168+(28*d|0)+(p<<2)>>2]}else if(d){if(7==(0|(d=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*d|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(d<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){f=v+4|0,d=0;do{pA(f),d=d+1|0}while((0|d)!=(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(x=v+4|0,l,x),nA(x),x=51}}else if(JA(t,o,v),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(d=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*d|0)+u|0])u=1;else if((0|(d=0|n[21168+(28*d|0)+(u<<2)>>2]))>0){f=v+4|0,u=0;do{pA(f),u=u+1|0}while((0|u)!=(0|d));x=51}else x=51;else x=51}while(0);return 51==(0|x)&&(u=v+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),P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(a=P,P=P+48|0,o=a+36|0,c=a+24|0,u=a+12|0,d=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 P=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)))?(P=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,P=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,d),nA(d),x=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(v=3*(15-l|0)|0)),s&=~B(),v=0|rt(0|lA(d),0,0|v),s=0|B()|s,n[(b=r)>>2]=v|x&~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){d=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|xA(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,f=s)}else m=s,h=0,f=t;if((0|(u=0|n[4272+(28*g|0)+(f<<2)>>2]))<=-1&&M(27724,27538,419,27678),!d){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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=t,n[v+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[(v=r)>>2]=l,n[v+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|d)){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[(v=r)>>2]=c,n[v+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)&&d&&(t=59),59==(0|t)&&1==(0|OA(0|n[(v=r)>>2],0|n[v+4>>2]))){s=9;break}p=0|n[(v=r)>>2],v=-1040385&n[v+4>>2],x=0|rt(0|s,0,45),v=0|v|B(),n[(s=r)>>2]=p|x,n[s+4>>2]=v,s=0}else s=1}while(0);return P=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 xe(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,f=0;i=P,P=P+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/+d(+u),f=+o[25968+(l<<3)>>3],o[t>>3]=u+f,o[t+8>>3]=u-f,u=+o[s+8>>3],c*=f,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return P=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return P=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]?(P=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,P=i,0|(l=0))}function ve(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0;if(i=P,P=P+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))P=i;else{if(0|r[0|(a=A+28|0)]?(s=0|we(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(P=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))w=A+24|0;else{x=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,d=3==(2|c),f=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[x>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){v=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){v=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)){v=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){v=29;break}}if(h){if(0|(c=0|$A(s,l,e))){v=32;break}if(0|xe(s,l,t,0)){v=36;break}if(d&&0|De(0|n[o>>2],0|n[p>>2],e,t)){v=42;break}if(g&&0|Ne(0|n[o>>2],0|n[p>>2],e,t)){v=42;break}}if(b){if(a=0|xe(s,l,e,1),c=0|n[p>>2],0|a){v=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){v=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],f)){v=53;break}if(0|Ne(0|n[o>>2],0|n[p>>2],t,e)){v=53;break}}}}do{if((0|u)<(0|n[x>>2])){if(a=0|xe(s,l,e,1),c=0|n[p>>2],0|a){v=58;break e}if(!(0|q(c,e))){v=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){v=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){v=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else v=73}while(0);if(73==(0|v)&&(v=0,s=0|we(s,l),l=0|B()),!(0|s)&!(0|l)){w=p;break A}}switch(0|v){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,v=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,v=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(P=i);case 32:return 0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(P=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,v=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,v=55;break;case 58:0|c&&Ye(c),n[(v=A)>>2]=0,n[v+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,v=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,v=71;break;case 67:return 0|(a=0|n[p>>2])&&Ye(a),n[(w=A)>>2]=0,n[w+4>>2]=0,n[o>>2]=0,n[x>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(P=i)}if(20==(0|v))return void(P=i);if(55==(0|v))return void(P=i);if(71==(0|v))return void(P=i)}}while(0);0|(a=0|n[w>>2])&&Ye(a),n[(v=A)>>2]=0,n[v+4>>2]=0,n[A+8>>2]=0,n[o>>2]=0,n[A+12>>2]=-1,n[y>>2]=0,n[w>>2]=0,P=i}}function we(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,d=0;t=P,P=P+16|0,d=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 d=0|rt(((d=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,d|=A&~s,C(0|u),P=t,0|d}}while(0);return(r&=127)>>>0>120?(d=0,C(0|(u=0)),P=t,0|d):(RA(d,0,r+1|0,0),u=0|n[d+4>>2],d=0|n[d>>2],C(0|u),P=t,0|d)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,d=0,f=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,f=a,t=-1,A=0;A:for(;;){for(d=A;l=+o[r+(d<<4)>>3],a=+o[r+(d<<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=d+1|0))>=(0|g)){t=22;break A}A=d,d=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)>(f=c==f|l==f?f+-2220446049250313e-31:f)&&(e^=1),(0|(A=d+1|0))>=(0|g)){t=22;break}t=d}if(22==(0|t))return 0|e}else{e=0,f=a,t=-1,A=0;A:for(;;){for(d=A;l=+o[r+(d<<4)>>3],a=+o[r+(d<<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=d+1|0))>=(0|g)){t=22;break A}A=d,d=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(f=l==f|a==f?f+-2220446049250313e-31:f)&&(e^=1),(0|(A=d+1|0))>=(0|g)){t=22;break}t=d}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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=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,x=0,A=-1,f=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,v=0;c=+o[t+(v<<4)>>3],h=+o[t+(v<<4)+8>>3],d=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,f=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,x|=+l(+(h-d))>3.141592653589793,(0|(A=v+1|0))!=(0|r);)w=v,m=c,v=A,A=w;x&&(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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(x=e+8|0)>>3]=17976931348623157e292,o[(v=e+24|0)>>3]=17976931348623157e292,o[e>>3]=-17976931348623157e292,o[(w=e+16|0)>>3]=-17976931348623157e292,(0|p)>0){for(a=0|n[A+4>>2],m=17976931348623157e292,b=-17976931348623157e292,i=0,r=-1,d=17976931348623157e292,f=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,d=s),g>3]=g,f=g),s>h?o[e>>3]=s:s=h,g>c&&(o[w>>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[w>>3]=b,o[v>>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,v=e+((C=C+1|0)<<5)|0,w=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[v>>3]=-17976931348623157e292,o[(k=e+(C<<5)+16|0)>>3]=-17976931348623157e292,(0|w)>0){for(p=0|n[a+(i<<3)+4>>2],m=17976931348623157e292,b=-17976931348623157e292,a=0,i=-1,x=0,d=17976931348623157e292,f=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(x<<4)>>3],h=+o[p+(x<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|w)?0:i)<<4)+8>>3],s>3]=s,d=s),h>3]=h,f=h),s>g?o[v>>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=x+1|0))!=(0|w);)M=x,x=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[v>>2]=0,n[v+4>>2]=0,n[v+8>>2]=0,n[v+12>>2]=0,n[v+16>>2]=0,n[v+20>>2]=0,n[v+24>>2]=0,n[v+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=P,P=P+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return P=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 P=i,0|a}}while(0);if(0|Ee(A,e,t,r))return P=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 P=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,M=0;if(u=P,P=P+176|0,l=u+172|0,d=u+168|0,c=u,!(0|q(e|=0,r|=0)))return P=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,d),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[d>>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[d>>2]),i=+ie(+o[r+24>>3],0|n[d>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(d=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],v=+o[e+(t<<4)>>3],w=+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,f=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(v>=a)|!(f>=a)&&!(v<=s)|!(f<=s)&&!(w<=i)|!(g<=i)&&!(w>=y)|!(g>=y)){x=f-v,b=g-w,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|d)?0:e,f=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-f,h=+o[c+8+(M<<4)>>3],!(0==(p=x*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=w-f,C=v-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(x*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|d))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return P=u,0|e}function Ne(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 Qe(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,d,f=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],f=((f=+o[r>>3]-u)*(a-(d=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-d))/(s*c-i*f),o[n>>3]=l+s*f,o[n+8>>3]=a+i*f}function je(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 Pe(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=P,P=P+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return P=a,0|s;r=0|LA(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,P=a,0}function Se(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0;if(l=P,P=P+32|0,v=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 P=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 P=l,1;if(0|Fe(A,e,v))return P=l,1;if(u=(0|n[v>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return P=l,1;n[s>>2]=0,c=0|R(A,e,p,s,a);do{if(!c){if(h=0|n[(f=a)>>2],u=(d=(f=0|n[f+4>>2])>>>0>>0|(0|f)==(0|e)&h>>>0>>0)?h:A,d=d?f:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(f&(0|B())))c=t;else{if(f=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|f)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|f)&&M(27795,27797,248,27822),0|Fe(A,e,v)&&M(27795,27797,248,27822),c=(0|n[v>>2])+f|0,7==(0|(f=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|R(A,e,f,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|d)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(f<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,d=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,d=h;break}do{if(!(0|Fe(g,h,v))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[v>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[v>>2])|0)%6|0;break}c=-1}while(0);u=g,d=h}else c=t}while(0);h=0|n[(f=a)>>2],f=0|n[f+4>>2]}if((0|u)==(0|h)&(0|d)==(0|f)){if(A=(g=!!(0|HA(h,f)))?0|_(h,f,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,f),(A+-1|0)>>>0<=5&&!(1==(0|A)&(x=!!(0|c))))do{if(!(0|Fe(h,f,v))){if(x){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[v>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[v>>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=d,A=u;break A}}while(0);return P=l,0|c}}while(0);return x=0|rt(0|c,0,56),v=B()|-2130706433&e|536870912,n[r>>2]=x|A,n[r+4>>2]=v,P=l,0}function Le(A,e){A|=0;var t,r,o=0,i=0;return r=P,P=P+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|IA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Se(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,P=r,0|o):(P=r,0|(o=0))}function Ie(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 Re(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 Te(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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0;e=P,P=P+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(f=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]=f&~(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],P=e,0|i;if(u>>>0>(d=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=f&~(1<>2]=t,n[A>>2]=r,A=f),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|d&&(o=0|n[6986],r=27964+((t=d>>>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,P=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|d&&(o=0|n[6986],r=27964+((t=d>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|f,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),P=e,0|l+8}f=u}else f=u}else f=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<<(f=(A+1048320|0)>>>16&8))|0)>>>16&4)|f|(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=f>>>12&16)>>>5&8)|s|(l=(f>>>=a)>>>2&4)|(c=(f>>>=l)>>>1&2)|(r=(f>>>=c)>>>1&1))+(f>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(f=(-8&n[a+4>>2])-u|0)>>>0>>0)?f: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&&(d=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[d+4>>2]=1|s,n[d+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]=d,n[t+12>>2]=d,n[d+8>>2]=t,n[d+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(r=(245760+(y<<=v)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[d+28>>2]=r,n[4+(A=d+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=d,n[d+24>>2]=t,n[d+12>>2]=d,n[d+8>>2]=d;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]=d,n[d+24>>2]=t,n[d+12>>2]=d,n[d+8>>2]=d;break A}}while(0);y=0|n[(w=t+8|0)>>2],n[y+12>>2]=d,n[w>>2]=d,n[d+8>>2]=y,n[d+12>>2]=t,n[d+24>>2]=0}}while(0);return P=e,0|l+8}f=u}else f=u;else f=-1}while(0);if((r=0|n[6983])>>>0>=f>>>0)return t=r-f|0,A=0|n[6986],t>>>0>15?(y=A+f|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|f):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),P=e,0|A+8;if((s=0|n[6984])>>>0>f>>>0)return v=s-f|0,n[6984]=v,w=(y=0|n[6987])+f|0,n[6987]=w,n[w+4>>2]=1|v,n[y+4>>2]=3|f,P=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=f+48|0,(u=(a=A+(c=f+47|0)|0)&(i=0-A|0))>>>0<=f>>>0)return P=e,0;if(0|(A=0|n[7091])&&(g=(d=0|n[7089])+u|0)>>>0<=d>>>0|g>>>0>A>>>0)return P=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>f>>>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|(v=0|ut(0|u)))|1^(x=(p=(m=0|ut(0))-v|0)>>>0>(f+40|0)>>>0)|v>>>0>>0&-1!=(0|v)&-1!=(0|m)^1)&&(s=x?p:t,a=v,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)||(w=t+4|0,8&n[t+12>>2]))&&a>>>0>c>>>0&A>>>0<=c>>>0){n[w>>2]=r+s,w=c+(v=7&(v=c+8|0)?0-v&7:0)|0,v=(y=(0|n[6984])+s|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,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[(d=t+4|0)>>2]=(0|n[d>>2])+s,u=(d=a+(7&(d=a+8|0)?0-d&7:0)|0)+f|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-d-f|0,n[d+4>>2]=3|f;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-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=v)|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[(w=t+8|0)>>2],n[y+12>>2]=u,n[w>>2]=u,n[u+8>>2]=y,n[u+12>>2]=t,n[u+24>>2]=0}}while(0);return P=e,0|d+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,w=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(r=s+-40|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,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{w=t,n[(t=t+4|0)>>2]=7}while((w+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-((v=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=v)|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[(w=t+8|0)>>2],n[y+12>>2]=c,n[w>>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,w=a+(v=7&(v=a+8|0)?0-v&7:0)|0,v=(y=s+-40|0)-v|0,n[6987]=w,n[6984]=v,n[w+4>>2]=1|v,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>f>>>0)return v=t-f|0,n[6984]=v,w=(y=0|n[6987])+f|0,n[6987]=w,n[w+4>>2]=1|v,n[y+4>>2]=3|f,P=e,0|y+8}return n[(y=27920)>>2]=12,P=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|v(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,d=0,f=0,g=0,h=0;if(u=A|=0,a=t|=0,s=f=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|(f=0)),o)):(o=0,0|(C(0|(f=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(f=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=d=i+1|0,A=u>>>(d>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(d>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(f=0)),o)):(o=0,0|(C(0|(f=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(d=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=d>>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|(d=0|t),0|(u=f|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|(f=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|f,g&d|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|v(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|v(o,r=A>>>16))|0,e=0|v(o=e>>>16,n),0|(C((A>>>16)+(0|v(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|v(e,o))+(0|v(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=P,P=P+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(),P=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=P,P=P+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),P=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):+x(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return N(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):+x(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?(j(0|e),D(12),-1):(0|e)>(0|r)&&!(0|Q(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,d=0;if(s=P,P=P+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return P=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,P=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,d=0|tt(0|t,0|r,52),B(),(0|c)!=(15&d))return P=s,12;if(l=c+-1|0,c>>>0>1){TA(A,e,l,a),TA(t,r,l,i),u=0|n[(d=a)>>2],d=0|n[d+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|d)==(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,d)){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 P=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,P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0;if(o=P,P=P+16|0,p=o,x=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return P=o,4;if((0|(x&=15))<(0|t))return P=o,12;if((0|x)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|x)>(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|x));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|x)>(0|t)){for(m=-15728641&e,h=x;;){if(g=h,(h=h+-1|0)>>>0>15|(0|x)<(0|h)){u=19;break}if((0|x)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|x)<(0|g))f=a;else{u=h;do{f=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=f,c=0|B()|c}while((0|u)<(0|x));f=a}else f=A,c=e;if(d=0|tt(0|f,0|c,45),B(),0|z(127&d)){d=0|tt(0|f,0|c,52),B(),d&=15;e:do{if(d)for(u=1;;){if(a=0|tt(0|f,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|(f=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=x-g|0,((0|u)<0)<<31>>31),d=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|d,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=d),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|d,0|(g=f+-1|0),((0|g)<0)<<31>>31)),0|B()),d=0|Ve(0|g,0|(f=0|B()),0|n[(d=r)>>2],0|n[d+4>>2]),f=0|B(),n[(g=r)>>2]=d,n[g+4>>2]=f),(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 P=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|x)>(0|t)){for(a=x;;){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=x-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 P=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,x,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(x=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[x>>2])>>>0>s>>>0:0))?(P=o,0|(x=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=P,P=P+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 P=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 P=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=P,P=P+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),P=s,0|A},_cellToParent:TA,_cellToVertex:Se,_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|Se(A,e,0,t))),i?r?0|(o=0|Se(A,e,1,t+8|0))||0|(o=0|Se(A,e,2,t+16|0))||0|(o=0|Se(A,e,3,t+24|0))||(o=0|Se(A,e,4,t+32|0))?0|(i=o):0|Se(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Se(A,e,1,t+8|0))||0|(o=0|Se(A,e,2,t+16|0))||0|(o=0|Se(A,e,3,t+24|0))||0|(o=0|Se(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=P,P=P+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=P,P=P+176|0,r=o,(0|(e|=0))<1)return Ie(t,0,0),P=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Ie(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)?(P=o,0|i):(Re(t),P=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return P=a,0|A;if(n[t>>2]=0,n[t+4>>2]=0,n[t+8>>2]=0,0|(A=0|Te(i)))do{e=0|de(t);do{fe(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|Te(i)}while(0|A);return Re(i),(A=0|function(A){var e,t,r=0,i=0,a=0,s=0,c=0,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,B=0,D=0,E=0,N=0,Q=0,j=0,P=0,F=0,S=0,L=0,I=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,S=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(f=+o[u+8>>3],r=u,u=0|n[u+16>>2],d=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(f-d))>3.141592653589793){I=14;break}c+=(d-f)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|I)){I=0,c=0,r=h;do{B=+o[r+8>>3],P=0|n[(F=r+16|0)>>2],C=+o[(P=0|P?P:h)+8>>3],c+=(+o[r>>3]+ +o[P>>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+(S<<2)>>2]=a,S=S+1|0,s=D,r=m):I=19}else I=19;if(19==(0|I)){I=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){I=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){I=21;break A}if(!(i=0|We(1,12))){I=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,f=17976931348623157e292,v=17976931348623157e292,w=-17976931348623157e292,d=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((x=!(0|p))?g:p)+8>>3],c>3]=c,f=c),B>3]=B,v=B),c>w?o[u>>3]=c:c=w,B>d&&(o[b>>3]=B,d=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!x;)w=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){I=45;break}D=s,m=r}if(21==(0|I))M(27213,27235,35,27247);else if(23==(0|I))M(27267,27235,37,27247);else if(27==(0|I))M(27310,27235,61,27333);else if(45==(0|I)){A:do{if((0|S)>0){for(F=!(0|s),j=s<<2,P=!(0|A),Q=0,r=0;;){if(N=0|n[t+(Q<<2)>>2],F)I=73;else{if(!(D=0|Ue(j))){I=50;break}if(!(E=0|Ue(j))){I=52;break}e:do{if(P)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[N>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,x=i+1|0):x=i,u=0|n[u+8>>2];)s=s+1|0,i=x;if((0|x)>0)if(a=0|n[D>>2],1==(0|x))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|x);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|x))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]){I=70;break}n[i>>2]=N,n[s>>2]=N}else I=73}if(73==(0|I)){if(I=0,0|(r=0|n[N>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(N),r=1}if((0|(Q=Q+1|0))>=(0|S)){L=r;break A}}50==(0|I)?M(27452,27235,249,27471):52==(0|I)?M(27490,27235,252,27471):70==(0|I)&&M(27310,27235,61,27333)}else L=0}while(0);return Ye(t),Ye(e),0|L}return 0}(t))?(ge(t),P=a,0|(s=A)):(P=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,d=0,f=0,g=0,h=0,m=0;if(a=P,P=P+16|0,s=a,(o|=0)>>>0>15)return P=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return P=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[(d=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[d>>2])>>>0>A>>>0:0))))return P=a,2;d=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|d)<1)return P=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=d-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[(f=i)>>2],f=0|n[f+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),f&=~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),f=0|B()|f,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=f,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],f=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&~f,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|d)>(0|c))){e=0;break}r=~c,c=c+1|0}return P=a,0|e}}while(0);if((0|d)<1)return P=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=d-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|(f=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|f,0|g,0|h,0|m)),0|B()),e=0|B(),(0|d)<=(0|s)){e=0;break}s=s+1|0}return P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,D=0,E=0,N=0,Q=0,j=0,P=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[(P=e)>>2]=a,n[P+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{j=0|n[4+(Q=A+(i<<3)|0)>>2],n[(P=e+(i<<3)|0)>>2]=n[Q>>2],n[P+4>>2]=j,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(!(j=0|Ue(o=t<<3)))return 13;if(st(0|j,0|A,0|o),!(Q=0|We(t,8)))return Ye(j),13;A:for(;;){E=0|tt(0|(u=0|n[(i=j)>>2]),0|(i=0|n[i+4>>2]),52),B(),N=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(v=0|rt(0|N,0,52),w=0|B(),N>>>0>15){if(!(!(0|u)&!(0|i))){P=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=j+(a<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))){i=s,P=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){P=21;break A}if(d=0|tt(0|l,0|A,52),B(),(0|(d&=15))<(0|N)){i=12,P=27;break A}if((0|d)!=(0|N)&&(l|=v,A=-15728641&A|w,d>>>0>=E>>>0)){c=N;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|(f=0|n[(d=c=Q+(g<<3)|0)>>2]))&!(0|(d=0|n[d+4>>2])))){p=0,x=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&x>>>0>t>>>0){P=31;break A}if((0|f)==(0|l)&(-117440513&d)==(0|A)){m=0|tt(0|f,0|d,56),B(),b=1+(m&=7)|0,k=0|tt(0|f,0|d,45),B();t:do{if(0|z(127&k)){if(f=0|tt(0|f,0|d,52),B(),!(f&=15)){d=6;break}for(d=1;;){if(!(!((k=0|rt(7,0,3*(15-d|0)|0))&l)&!((0|B())&A))){d=7;break t}if(!(d>>>0>>0)){d=6;break}d=d+1|0}}else d=7}while(0);if((m+2|0)>>>0>d>>>0){P=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();x=0|Ve(0|x,0|p,1,0),p=0|B(),f=0|n[(d=c=Q+(g<<3)|0)>>2],d=0|n[d+4>>2]}while(!(!(0|f)&!(0|d)))}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=j+(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){P=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){P=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=d=Q+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{f=0|tt(0|a,0|s,56),B(),l=1+(f&=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=d)>>2]=a,n[l+4>>2]=s,l=f+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(x=N>>>0>15,v=0|rt(0|N,0,52),w=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(N=e+(a<<3)|0)>>2]=u,n[N+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=j+(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(),x|(0|(h&=15))<(0|N)){P=80;break A}if((0|h)!=(0|N)){if(d=u|v,f=-15728641&i|w,h>>>0>=E>>>0){g=N;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,d|=D,f=0|B()|f}while(g>>>0>>0)}}else d=u,f=i;m=0|At(0|d,0|f,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){P=81;break A}if((-117440513&(b=0|n[4+(D=Q+(m<<3)|0)>>2]))==(0|f)&&(0|n[D>>2])==(0|d)){P=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=Q+(m<<3)|0}while((0|n[D>>2])!=(0|d)||(0|n[D+4>>2])!=(0|f));if(65==(0|P)&&(P=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=j+(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|Q,0,0|o),st(0|j,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){P=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|P))!0&!(117440512&i)?(i=4,P=27):P=21;else if(31==(0|P))M(27795,27122,620,27132);else{if(41==(0|P))return Ye(j),Ye(Q),10;if(48==(0|P))return Ye(j),Ye(Q),13;80==(0|P)?M(27795,27122,711,27132):81==(0|P)?M(27795,27122,723,27132):85==(0|P)&&(st(0|e,0|j,t<<3),P=89)}return 21==(0|P)?(Ye(j),Ye(Q),0|(P=5)):27==(0|P)?(Ye(j),Ye(Q),0|(P=i)):89==(0|P)?(Ye(j),Ye(Q),0|(P=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=P,P=P+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|R(A,o,7&e,a,t+8|0),P=r,0|a):(P=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=P,P=P+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,P=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,P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+g)*+d(+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,P=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=P,P=P+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,P=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,P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+g)*+d(+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,P=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=P,P=P+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return P=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return P=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=+f(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+f(.5*(a-u)))*(+d(+i)*+d(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,P=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:LA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=P,P=P+16|0,n[(i=r)>>2]=0,!0&268435456==(2013265920&e)?(o=0|tt(0|A,0|e,56),B(),i=0|R(A,-2130706433&e|134217728,7&o,i,t),P=r,0|i):(P=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,d=0,f=0;o=P,P=P+128|0,d=o+112|0,s=o+96|0,f=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[d>>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),f=B()|-15728641&t,f=0|A((u|e)&~(d=0|rt(7,0,3*(14-c|0)|0)),f&~B(),r),P=o,0|f;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(QA(s,d,f),u=5):(SA(s,d,f),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(PA(l=f+(s<<4)|0,0|n[d>>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(jA(l=f+(s<<4)|0,0|n[d>>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 P=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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+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=+f(.5*(r-t)))*n+(i=+f(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+d(+r)*+d(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:F,_gridDiskDistances:S,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=P,P=P+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(P=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(P=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,D=0,E=0;if(a=P,P=P+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],x=g*+((0|n[c>>2])-t|0),r=0|n[(v=i+4|0)>>2],w=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=x*(d=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=w*d+ +(0|r),d=g*d+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+d),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),d=+l(+(+(0|s)-d));do{if(!(E>u&E>d)){if(f=0-t|0,u>d){r=f-s|0;break}r=c,s=f-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[v>>2],s=0|n[y>>2]}}while(0);return P=a,0|s}return P=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=P,P=P+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))?(P=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,P=i,0|(l=0))},_gridRing:function(A,e,t,r){return 0|T(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,d=0,f=0;if(o=P,P=P+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,P=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 d=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|d,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(d=s)>>2]=i,n[d+4>>2]=a;if(u=0|We(i,8)){if(!(d=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|I(A,e,t,u,d,i,a,0))){Ye(u),Ye(d);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[d+(l<<2)>>2])!=(0|t)||(n[(f=r+(i<<3)|0)>>2]=a,n[f+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(d),i=0}else i=13}else i=2}while(0);return P=o,0|i}(A,e,t,r))):0|(r=0)},_gridRingUnsafe:T,_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:IA,_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|Le(A,e)))},_isValidVertex:Le,_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=P,P=P+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)),P=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=P,P=P+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return P=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 P=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,f=0,g=0,h=0,m=0,b=0,p=0;if(s=P,P=P+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,P=s,0;RA(h,0,0,0),c=0|n[(f=h)>>2],f=0|n[f+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]=f,n[(f=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/+d(+ +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(ve(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,ve(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[f>>2]}}while(0);return P=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,d=0,f=0,g=0,h=0,m=0,b=0,p=0,x=0,v=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,N=0,Q=0,j=0,F=0,S=0,R=0,T=0,_=0;if(s=P,P=P+112|0,o=s+80|0,f=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return P=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return P=s,13;if(Be(A,_),!(l=0|Ce(t))){if(T=0|n[(R=A)+4>>2],n[(l=f)>>2]=n[R>>2],n[l+4>>2]=T,ke(f,o),l=0|eA(o,e,i))R=0,T=0;else{if(l=0|n[f>>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,R=0|Ve(0|t,0|l,12,0),T=0|B(),n[(l=i)>>2]=R,n[l+4>>2]=T,l=0}if(!l){if(!(t=0|We(R,8)))return Ye(_),P=s,13;if(!(d=0|We(R,8)))return Ye(_),Ye(t),P=s,13;n[(F=o)>>2]=0,n[F+4>>2]=0,S=0|n[(F=A)+4>>2],n[(l=f)>>2]=n[F>>2],n[l+4>>2]=S,l=0|H(f,R,T,e,o,t,d);A:do{if(l)Ye(t),Ye(d),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,R,T,e,o,t,d),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(d),Ye(_);break A}}while(0);(0|T)>0|!(0|T)&R>>>0>0&<(0|d,0,R<<3),F=0|n[(S=o)+4>>2];e:do{if((0|F)>0|!(0|F)&(0|n[S>>2])>>>0>0){N=t,Q=d,j=t,F=d,S=t,l=t,M=t,D=d,E=d,t=d;t:for(;;){for(w=0,y=0,k=0,C=0,c=0,u=0;;){f=(d=i)+56|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|f));if(0|L(g=0|n[(e=N+(w<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){f=(d=i)+56|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|f));0|(d=0|We(7,4))&&(I(g,e,1,i,d,7,0,0),Ye(d))}for(v=0;;){p=0|n[(x=i+(v<<3)|0)>>2],x=0|n[x+4>>2];r:do{if(!(0|p)&!(0|x))d=c,f=u;else{if(h=0|At(0|p,0|x,0|R,0|T),g=0|B(),!(!(0|(f=0|n[(e=d=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|T)|(0|m)==(0|T)&b>>>0>R>>>0)break t;if((0|f)==(0|p)&(0|e)==(0|x)){d=c,f=u;break r}h=0|$e(0|(d=0|Ve(0|h,0|g,1,0)),0|B(),0|R,0|T),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),f=0|n[(e=d=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|f)&!(0|e)))}if(!(0|p)&!(0|x)){d=c,f=u;break}qA(p,x,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=d)>>2]=p,n[m+4>>2]=x,n[(c=Q+(c<<3)|0)>>2]=p,n[c+4>>2]=x,c=b),d=c,f=u}}while(0);if((v=v+1|0)>>>0>=7)break;c=d,u=f}if(w=0|Ve(0|w,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=d,u=f}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=N+(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]=d,n[C+4>>2]=f,!((0|f)>0|!(0|f)&d>>>0>0))break e;v=t,w=E,y=S,k=D,C=Q,t=M,E=l,D=j,M=v,l=w,S=F,F=y,j=k,Q=N,N=C}Ye(j),Ye(F),Ye(_),l=1;break A}l=d}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return P=s,0|l}}return Ye(_),P=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,d=0,f=0,g=0,h=0,m=0,b=0,p=0;c=P,P=P+160|0,d=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,d=0;s=P,P=P+48|0,i=s+40|0,a=s,RA(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[(d=a)>>2]=u,n[d+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,d=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|d]=0|r[0|i],r[d+1|0]=0|r[i+1|0],r[d+2|0]=0|r[i+2|0]}while(0);ve(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],P=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(d,0|n[(f=g)>>2],0|n[f+4>>2],e),s=0|n[(f=d)>>2],f=0|n[f+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]=f,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[d>>2],n[h+4>>2]=n[d+4>>2],n[h+8>>2]=n[d+8>>2],n[h+12>>2]=n[d+12>>2],!(0|s)&!(0|f))return P=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,d=0,e=s,A=f;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&d>>>0>>0)){b=4;break}if(f=d,d=0|Ve(0|d,0|u,1,0),u=0|B(),n[(f=a+(f<<3)|0)>>2]=e,n[f+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(ve(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[(f=p)>>2]=e,n[f+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,P=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],P=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,d=0,f=0,g=0,h=0,m=0;if(s=P,P=P+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return P=s,0;if((0|(a|=0))>=16)return P=s,12;g=0,h=0,f=0,l=0;A:for(;;){if(d=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&d)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(d=m)>>2]))&!(0|(d=0|n[d+4>>2])))c=f;else{c=f;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(f=r+(c<<3)|0)>>2]=u,n[f+4>>2]=d,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(f=m)>>2],d=0|n[f+4>>2]}while(!(!(0|u)&!(0|d)))}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}f=c}return 10==(0|c)?(P=s,0|(m=14)):11==(0|c)?(P=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,d=0,f=0;a=P,P=P+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(d=0,l=0,s=0,f=0;;){if(!(!(0|(c=0|n[(u=A+(d<<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(d=0|Ve(0|d,0|f,1,0),!((0|(f=0|B()))<(0|t)|(0|f)==(0|t)&d>>>0>>0))break A}return P=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,P=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=P,P=P+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))?(P=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?NA(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],P=a,0|(l=0))},establishStackSpace:function(A,e){P=A|=0},stackAlloc:function(A){var e;return e=P,P=15+(P=P+(A|=0)|0)&-16,0|e},stackRestore:function(A){P=A|=0},stackSave:function(){return 0|P}}}({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: "+x(A)+", at: "+[e?x(e):"unknown filename",t,r?x(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){f.set(f.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,f,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,d.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":R=[e>>>0,(I=e,+Q(I)>=1?I>0?(0|F(+P(I/4294967296),4294967295))>>>0:~~+j((I-+(~~I>>>0))/4294967296)>>>0:0)],h[A>>2]=R[0],h[A+4>>2]=R[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 d[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},T){H(T)||(W=T,T=t.locateFile?t.locateFile(W,o):o+W),S++,t.monitorRunDependencies&&t.monitorRunDependencies(S);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),f.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(S--,t.monitorRunDependencies&&t.monitorRunDependencies(S),0==S&&L){var A=L;L=null,A()}}()},q=function(){n(T,X,function(){throw"could not load memory initializer "+T})},$=O(T);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;)N(t.postRun.shift());k(D)}()))}S>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),S>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(L=function A(){V||eA(),V||(L=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 $A?$A:{}),Ae="number",ee={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"},te={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function re(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 ne(A){if(0!==A)throw function(A,e){return re(ee,A,2===arguments.length?{value:e}:{})}(A)}var oe={};[["sizeOfH3Index",Ae],["sizeOfLatLng",Ae],["sizeOfCellBoundary",Ae],["sizeOfGeoLoop",Ae],["sizeOfGeoPolygon",Ae],["sizeOfLinkedGeoPolygon",Ae],["sizeOfCoordIJ",Ae],["readInt64AsDoubleFromPointer",Ae],["isValidCell",Ae,[Ae,Ae]],["isValidIndex",Ae,[Ae,Ae]],["latLngToCell",Ae,[Ae,Ae,Ae,Ae]],["cellToLatLng",Ae,[Ae,Ae,Ae]],["cellToBoundary",Ae,[Ae,Ae,Ae]],["maxGridDiskSize",Ae,[Ae,Ae]],["gridDisk",Ae,[Ae,Ae,Ae,Ae]],["gridDiskDistances",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridRing",Ae,[Ae,Ae,Ae,Ae]],["gridRingUnsafe",Ae,[Ae,Ae,Ae,Ae]],["maxPolygonToCellsSize",Ae,[Ae,Ae,Ae,Ae]],["polygonToCells",Ae,[Ae,Ae,Ae,Ae]],["maxPolygonToCellsSizeExperimental",Ae,[Ae,Ae,Ae,Ae]],["polygonToCellsExperimental",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["cellsToLinkedMultiPolygon",Ae,[Ae,Ae,Ae]],["destroyLinkedMultiPolygon",null,[Ae]],["compactCells",Ae,[Ae,Ae,Ae,Ae]],["uncompactCells",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["uncompactCellsSize",Ae,[Ae,Ae,Ae,Ae,Ae]],["isPentagon",Ae,[Ae,Ae]],["isResClassIII",Ae,[Ae,Ae]],["getBaseCellNumber",Ae,[Ae,Ae]],["getResolution",Ae,[Ae,Ae]],["getIndexDigit",Ae,[Ae,Ae,Ae]],["constructCell",Ae,[Ae,Ae,Ae,Ae]],["maxFaceCount",Ae,[Ae,Ae,Ae]],["getIcosahedronFaces",Ae,[Ae,Ae,Ae]],["cellToParent",Ae,[Ae,Ae,Ae,Ae]],["cellToChildren",Ae,[Ae,Ae,Ae,Ae]],["cellToCenterChild",Ae,[Ae,Ae,Ae,Ae]],["cellToChildrenSize",Ae,[Ae,Ae,Ae,Ae]],["cellToChildPos",Ae,[Ae,Ae,Ae,Ae]],["childPosToCell",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["areNeighborCells",Ae,[Ae,Ae,Ae,Ae,Ae]],["cellsToDirectedEdge",Ae,[Ae,Ae,Ae,Ae,Ae]],["getDirectedEdgeOrigin",Ae,[Ae,Ae,Ae]],["getDirectedEdgeDestination",Ae,[Ae,Ae,Ae]],["isValidDirectedEdge",Ae,[Ae,Ae]],["directedEdgeToCells",Ae,[Ae,Ae,Ae]],["originToDirectedEdges",Ae,[Ae,Ae,Ae]],["directedEdgeToBoundary",Ae,[Ae,Ae,Ae]],["gridDistance",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridPathCells",Ae,[Ae,Ae,Ae,Ae,Ae]],["gridPathCellsSize",Ae,[Ae,Ae,Ae,Ae,Ae]],["cellToLocalIj",Ae,[Ae,Ae,Ae,Ae,Ae,Ae]],["localIjToCell",Ae,[Ae,Ae,Ae,Ae,Ae]],["getHexagonAreaAvgM2",Ae,[Ae,Ae]],["getHexagonAreaAvgKm2",Ae,[Ae,Ae]],["getHexagonEdgeLengthAvgM",Ae,[Ae,Ae]],["getHexagonEdgeLengthAvgKm",Ae,[Ae,Ae]],["greatCircleDistanceM",Ae,[Ae,Ae]],["greatCircleDistanceKm",Ae,[Ae,Ae]],["greatCircleDistanceRads",Ae,[Ae,Ae]],["cellAreaM2",Ae,[Ae,Ae,Ae]],["cellAreaKm2",Ae,[Ae,Ae,Ae]],["cellAreaRads2",Ae,[Ae,Ae,Ae]],["edgeLengthM",Ae,[Ae,Ae,Ae]],["edgeLengthKm",Ae,[Ae,Ae,Ae]],["edgeLengthRads",Ae,[Ae,Ae,Ae]],["getNumCells",Ae,[Ae,Ae]],["getRes0Cells",Ae,[Ae]],["res0CellCount",Ae],["getPentagons",Ae,[Ae,Ae]],["pentagonCount",Ae],["cellToVertex",Ae,[Ae,Ae,Ae,Ae]],["cellToVertexes",Ae,[Ae,Ae,Ae]],["vertexToLatLng",Ae,[Ae,Ae,Ae]],["isValidVertex",Ae,[Ae,Ae]]].forEach(function(A){oe[A[0]]=$A.cwrap.apply($A,A)});var ie=16,ae=oe.sizeOfH3Index(),se=oe.sizeOfLatLng(),le=oe.sizeOfCellBoundary();oe.sizeOfGeoPolygon(),oe.sizeOfGeoLoop(),oe.sizeOfLinkedGeoPolygon(),oe.sizeOfCoordIJ();var ce=/[^0-9a-fA-F]/;function ue(A){if(A>=0)return A.toString(ie);var e=de(8,(A&=2147483647).toString(ie));return(parseInt(e[0],ie)+8).toString(ie)+e.substring(1)}function de(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 ke({coveragePoints:e,visible:r,terrainEnabled:n=!1,brightness:o=.7}){const{current:i}=S(),[a,s]=A.useState(null),[l,c]=A.useState(!1),u=A.useRef({aborted:!1}),d=A.useRef(0),f=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(e),g=A.useMemo(()=>function(){var A;const e=hA();return 24===e.length&&0!==(null==(A=e[0])?void 0:A[0])?e:ve}(),[]);A.useEffect(()=>{if(!f||!Array.isArray(f)||0===f.length)return void queueMicrotask(()=>{s(null),d.current=0});if(f.length===d.current&&a)return;d.current=f.length,u.current.aborted=!0,u.current={aborted:!1};const A=u.current;c(!0);const{cells:e,minQuality:t,maxQuality:r}=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=he(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}}(f);if(0===e.length)return s(null),void c(!1);if(e.length<500){const n=function(A,e,t,r){const n=[];for(const o of A){const A=me(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=ye(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}}(e,t,r,g);return void(A.aborted||(s(n),c(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=ye(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}}(e,t,r,g,A).then(e=>{!A.aborted&&e&&s(e)}).finally(()=>{A.aborted||c(!1)}),()=>{A.aborted=!0}},[f,g]),A.useEffect(()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(!e)return;const t=()=>{var A,t;try{const n=e.getLayer(xe),i=e.getSource(pe);if(r&&a&&a.features.length>0){if(i?e.getSource(pe).setData(a):e.addSource(pe,{type:"geojson",data:a}),!n){const r=e.getLayer("topology-weak-edges-native"),n=null==(t=null==(A=e.getStyle())?void 0:A.layers)?void 0:t.find(A=>"symbol"===A.type),i=r?"topology-weak-edges-native":null==n?void 0:n.id;e.addLayer({id:xe,type:"fill",source:pe,paint:{"fill-color":["get","color"],"fill-opacity":o}},i)}}else n&&e.removeLayer(xe),i&&e.removeSource(pe)}catch(n){}};e.isStyleLoaded()?t():e.once("style.load",t)},[i,r,a,n]),A.useEffect(()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(e&&r)try{e.getLayer(xe)&&e.setPaintProperty(xe,"fill-opacity",o)}catch{}},[i,o,r]),A.useEffect(()=>()=>{var A;const e=null==(A=null==i?void 0:i.getMap)?void 0:A.call(i);if(e)try{e.getLayer(xe)&&e.removeLayer(xe),e.getSource(pe)&&e.removeSource(pe)}catch{}},[i]);const h=(null==a?void 0:a.features.length)??0;return h>0&&r?t.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==e?void 0:e.length)||0,"data-cell-count":h,"data-terrain-enabled":n,"data-is-processing":l,style:{display:"none"}}):null}const Ce="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Be="terrarium",Me="terrain-dem",De="hillshade-dem",Ee="terrain-hillshade";function Ne({enabled:e,exaggeration:t=4}){const{current:r}=S(),n=A.useRef(null);return A.useEffect(()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);if(!e)return;let t=!0;const n=()=>{var A,r;if(t)try{if(e.getSource(De)||e.addSource(De,{type:"raster-dem",tiles:[Ce],encoding:Be,tileSize:256,maxzoom:14}),!e.getLayer(Ee)){const t=null==(r=null==(A=e.getStyle())?void 0:A.layers)?void 0:r.find(A=>"symbol"===A.type);e.addLayer({id:Ee,type:"hillshade",source:De,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==t?void 0:t.id)}}catch(n){}};return e.isStyleLoaded()?n():e.once("style.load",n),()=>{t=!1}},[r]),A.useEffect(()=>{var A;const o=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);if(!o)return;let i=!0;const a=()=>{if(i)try{o.getSource(Me)||o.addSource(Me,{type:"raster-dem",tiles:[Ce],encoding:Be,tileSize:256,maxzoom:14}),e?(o.setCenterClampedToGround(!1),o.setTerrain({source:Me,exaggeration:t}),o.setMaxPitch(70),o.getPitch()<30&&!o.isMoving()&&(null!==n.current&&clearTimeout(n.current),n.current=window.setTimeout(()=>{n.current=null,i&&!o.isMoving()&&o.getPitch()<30&&o.easeTo({pitch:45,duration:1e3})},200))):(o.setTerrain(null),o.setCenterClampedToGround(!0),o.getPitch()>0&&!o.isMoving()&&o.easeTo({pitch:0,duration:800}),o.setMaxPitch(60))}catch(A){}};return o.isStyleLoaded()?a():o.once("style.load",a),()=>{i=!1,null!==n.current&&(clearTimeout(n.current),n.current=null);try{o.getStyle()&&o.isStyleLoaded()&&o.setTerrain(null)}catch{}}},[r,e,t]),A.useEffect(()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);return()=>{var A;try{(null==(A=null==e?void 0:e.getStyle)?void 0:A.call(e))&&e.isStyleLoaded()&&(e.setTerrain(null),e.getLayer(Ee)&&e.removeLayer(Ee),e.getSource(De)&&e.removeSource(De),e.getSource(Me)&&e.removeSource(Me))}catch{}}},[r]),null}function Qe(A,e=!1,t=!1,r=!1,n=.7){const o=fA();return r?n>=.75?o.restBright:o.rest:n>=.85?o.rest:o.restDim}function je(A){return[A[1],A[0]]}function Pe(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 Fe(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Se(A,e,t,r,n,o,i,a,s,l,c){const u=CA(),d=[];let f=1/0,g=-1/0;const h=[];for(const b of A){const A=.7*(b.edge.avgConfidence??(e?.7:.5))+b.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);h.push({polyline:b,brightnessScore:A}),f=Math.min(f,A),g=Math.max(g,A)}if(0===h.length)return{type:"FeatureCollection",features:[]};const m=g-f||1;h.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:b,brightnessScore:p}of h){const{from:A,to:i,edge:g}=b,h=t.get(g.key)??0;if(h<=0)continue;const x=a.has(g.key),v=s.has(g.key),w=g.avgConfidence??(e?.7:.5),y=l===g.key,k=c[g.fromHash],C=c[g.toHash],B=(null==k?void 0:k.node_name)||(null==k?void 0:k.name)||g.fromHash.slice(0,8),M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||g.toHash.slice(0,8),D=[A[0]+(i[0]-A[0])*h,A[1]+(i[1]-A[1])*h];let E,N,Q,j;if(e){const A=o.get(g.key)??vA(g.certainCount),e=n.get(g.key)??A;E=e+(A-e)*r,y?E=Math.max(1.6*E,4.5):v&&(E*=1.3)}else E=1.5;if(N=y?u.edges.highlight:Qe(0,g.isDirectPathEdge??!1,x,v,w),Q=y?u.edges.highlight:g.isDirectPathEdge?u.edges.hoverDirect:x?u.edges.hoverLoop:u.edges.hoverStandard,e){const A=Math.min(1.5*h,1)*u.edgeOpacity;j=v?1.15*A:A}else j=(.3+.3*w)*h;y&&(j=.95);const P=(p-f)/m;d.push({type:"Feature",properties:{key:g.key,baseColor:N,hoverColor:Q,baseWidth:E,baseOpacity:j,brightnessScore:P,isLoopEdge:x,isBackbone:v,isDirectPath:g.isDirectPathEdge??!1,isHubConnection:g.isHubConnection??!1,isZeroHop:g.isZeroHop??!1,isValidated:e,certainCount:g.certainCount,confidence:w,symmetryRatio:g.symmetryRatio??1,dominantDirection:g.dominantDirection??"balanced",fromName:B,toName:M,fromHash:g.fromHash,toHash:g.toHash},geometry:{type:"LineString",coordinates:[je(A),je(D)]}})}return{type:"FeatureCollection",features:d}}function Le(A,e){const t=CA(),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,d=(null==l?void 0:l.avgSnr)??s.snr??null,f=(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,x=n>0?p/n:0,v=o.rxAdvertCount??0,w=o.txProxyCount??0,y=v+w,k=y>0?(w-v)/y:0,C=Pe(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:d,packetCount:f,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:x,linkAsymmetry:k,rxAdvertCount:v,txProxyCount:w},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Ie(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Re(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 Te(A,e,t){const r=t?AA(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 _e="edge-blink-source",He="edge-blink-layer",ze=1e3,Ge=1e3,Oe="node-markers-layer";function Ue(A){return A<0||A>=ze?0:1-A/ze}function Ye(A){if(A<0)return 0;if(A>=Ge)return 0;const e=A/Ge;return Math.pow(1-e,3)}function We(A){return[A[1],A[0]]}function Ve(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function Ze({hash:e,hashPrefix:n,name:o,isHub:i,isGateway:a,isBackbone:l,isZeroHop:c,isMobile:u,isRoomServer:d,isStale:f,lastSeenTimestamp:g,centrality:h,affinity:m,meanSnr:b,meanRssi:p,neighbor:x,onRemove:v,txDelayRec:w,onPingResult:y}){const k=gA(),[C,B]=A.useState(!1),[M,D]=A.useState(!1),[E,N]=A.useState(null),[Q,j]=A.useState(null),F=A.useCallback(async()=>{if(!M){D(!0),j(null),N(null);try{const A=e.startsWith("0x")?e.slice(0,4):`0x${e.slice(0,2)}`,t=await tA(A,30);t.success&&t.data?(N(t.data),null==y||y(t.data)):j(t.error||"Ping failed")}catch(A){j(A instanceof Error?A.message:"Ping failed")}finally{D(!1)}}},[e,M,y]),S=c?"Direct":(null==m?void 0:m.typicalHopPosition)?`${m.typicalHopPosition}-hop`:null,z=w&&!w.insufficientData,G={hub:{bg:"bg-amber-500/20",text:"text-amber-400",title:"Hub: High-connectivity node that bridges many paths"},backbone:{bg:"bg-purple-500/20",text:"text-purple-400",title:"Backbone: Critical relay with high traffic"},relay:{bg:"bg-cyan-500/20",text:"text-cyan-400",title:"Relay: Standard forwarding node"},edge:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Edge: Peripheral node"}},O={high:{bg:"bg-green-500/20",text:"text-green-400",title:"1000+ packets"},medium:{bg:"bg-amber-500/20",text:"text-amber-400",title:"500-999 packets"},low:{bg:"bg-red-500/20",text:"text-red-400",title:"100-499 packets"},insufficient:{bg:"bg-gray-500/20",text:"text-gray-400",title:"Insufficient data"}};return t.jsxs("div",{className:"w-[240px] pr-2",children:[t.jsx("div",{className:"text-[14px] font-semibold text-text-primary leading-tight truncate mb-1",children:o}),t.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[t.jsx("code",{className:"font-mono text-[10px] text-text-secondary bg-[#1a1a1a] px-1 py-0.5 rounded",children:n}),t.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(e),B(!0),setTimeout(()=>B(!1),1500)}catch(A){const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),B(!0),setTimeout(()=>B(!1),1500)}catch{}document.body.removeChild(t)}},className:"p-0.5 hover:bg-[#252525] rounded transition-colors",title:"Copy full hash",children:C?t.jsx(r,{className:"w-3 h-3 text-accent-success"}):t.jsx(L,{className:"w-3 h-3 text-text-secondary"})}),t.jsx(pA,{hash:e,size:"sm"}),S&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded "+(c?"bg-amber-400 text-gray-900":"bg-[#2a2a2a] text-white"),children:S}),x.is_repeater&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-cyan-500/20 text-cyan-400",children:"Rptr"}),i&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded",style:{backgroundColor:k.hubColor,color:"#fff"},title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a&&!i&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded",style:{backgroundColor:k.hubColor,color:"#fff",opacity:.8},title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),l&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-purple-500/80 text-white",title:"Backbone",children:"Bone"}),u&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-orange-500/25 text-orange-300",children:"Mobile"}),d&&t.jsx("span",{className:"px-1 py-0.5 text-[9px] font-bold uppercase rounded bg-amber-500/25 text-amber-400",children:"Room"}),f&&g&&t.jsxs("span",{className:"px-1 py-0.5 text-[9px] font-medium rounded bg-gray-500/30 text-gray-300",title:"Neighbor not heard in 7+ days",children:["Idle ",Ve(g)]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-secondary mb-1.5",children:[t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(I,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono",children:rA(x.last_seen)})]}),(null==m?void 0:m.distanceMeters)&&t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(R,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(U=m.distanceMeters,null===U?"—":U<1e3?`${Math.round(U)}m`:`${(U/1e3).toFixed(1)}km`)})]}),x.latitude&&x.longitude&&0!==x.latitude&&0!==x.longitude&&t.jsxs("span",{className:"flex items-center gap-0.5",children:[t.jsx(T,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsxs("span",{className:"font-mono text-text-muted",children:[x.latitude.toFixed(2),", ",x.longitude.toFixed(2)]})]})]}),t.jsx("div",{className:"mb-1.5",style:{width:224},children:t.jsx(xA,{nodeHash:e,width:224,height:26,showArea:!0,showTooltip:!0})}),t.jsxs("div",{className:"flex gap-3 text-[10px] mb-1.5",children:[t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:(null==m?void 0:m.frequency)||0})]}),c&&void 0!==b&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[b.toFixed(1)," dB"]})]}),z&&w.networkRole&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:`text-[9px] font-bold uppercase px-1 py-0.5 rounded ${G[w.networkRole].bg} ${G[w.networkRole].text}`,title:G[w.networkRole].title,children:w.networkRole})]})]}),t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Adverts"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:x.advert_count||0})]}),c&&void 0!==p&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[Math.round(p)," dBm"]})]}),z&&w.dataConfidence&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-text-muted",children:"Data"}),t.jsx("span",{className:`text-[9px] font-bold uppercase px-1 py-0.5 rounded ${O[w.dataConfidence].bg} ${O[w.dataConfidence].text}`,title:O[w.dataConfidence].title,children:w.dataConfidence})]})]})]}),z&&t.jsxs("div",{className:"flex items-center gap-2 text-[10px] mb-1.5 py-1 px-1.5 bg-amber-400/5 rounded",children:[t.jsx(_,{className:"w-3 h-3 text-amber-400 shrink-0"}),t.jsx("span",{className:"text-text-muted",children:"TxDelay"}),t.jsxs("div",{className:"flex gap-3 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"F"}),t.jsxs("span",{className:"font-mono font-semibold text-amber-400",children:["×",(w.floodFactor??w.txDelayFactor).toFixed(1)]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"D"}),t.jsxs("span",{className:"font-mono font-semibold text-amber-400",children:["×",(w.directFactor??w.directTxDelayFactor).toFixed(1)]})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-white/[0.08]",children:[c?t.jsxs("button",{onClick:F,disabled:M,className:"flex items-center gap-1 py-0.5 text-[10px] text-text-secondary hover:text-accent-primary hover:bg-accent-primary/10 rounded transition-colors disabled:opacity-50",title:"Ping neighbor",children:[M?t.jsx(s,{className:"w-3 h-3 animate-spin"}):t.jsx(H,{className:"w-3 h-3"}),t.jsx("span",{children:"Ping"})]}):t.jsx("div",{}),v&&t.jsx("button",{onClick:v,className:"p-1 text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:t.jsx(P,{className:"w-3.5 h-3.5"})})]}),E&&t.jsxs("div",{className:"mt-1 pt-1 border-t border-white/[0.08] text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-1 text-accent-success mb-0.5",children:[t.jsx(r,{className:"w-3 h-3"}),t.jsx("span",{className:"font-medium",children:"Ping OK"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RTT"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.rtt_ms.toFixed(0)," ms"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.rssi," dBm"]})]})]}),t.jsxs("div",{className:"flex-1 space-y-0.5",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"font-mono font-semibold text-text-primary",children:[E.snr_db.toFixed(1)," dB"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-text-muted",children:"Hops"}),t.jsx("span",{className:"font-mono font-semibold text-text-primary",children:E.path.length})]})]})]})]}),Q&&t.jsxs("div",{className:"mt-1.5 pt-1.5 border-t border-white/[0.08] text-[10px] text-red-400",children:["⚠ ",Q]})]});var U}const Ke="node-markers-native",Je="node-markers-layer",Xe="node-markers-layer-local",qe="marker-standard",$e="marker-standard-neighbor",At="marker-hub",et="marker-hub-neighbor",tt="marker-gateway",rt="marker-gateway-neighbor",nt="marker-mobile",ot="marker-mobile-neighbor",it="marker-room-server",at="marker-room-server-neighbor",st="marker-local",lt="marker-blink-black",ct="marker-blink-black-local",ut="marker-blink",dt="marker-blink-local";function ft(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 gt(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function ht({neighborsWithLocation:e,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:d,openPopupId:f,onOpenPopup:g,onClosePopup:h,blinkingNodes:m}){const{current:b}=S(),p=A.useRef(!1),[x,v]=A.useState(!1);A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e)return;const t=()=>{if(!p.current)try{!function(A){const e=dA(),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={[qe]:t(e.nodeFill,e.nodeStroke,1.5),[$e]:t(e.neighborColor),[At]:t(e.hubColor),[et]:t(e.neighborColor),[tt]:t(e.hubColor+"B3"),[rt]:t(e.neighborColor),[nt]:t("transparent",e.mobileColor,2),[ot]:t(e.neighborColor),[it]:n(e.roomColor),[at]:n(e.neighborColor,"#1a1a1c"),[st]:r(e.localColor),[lt]:t("#000000"),[ct]:r("#000000"),[ut]:t(o,void 0,0,!0),[dt]: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),p.current=!0,v(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{p.current=!1,t()},n=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(r,100);break}});return n.observe(document.documentElement,{attributes:!0}),()=>{n.disconnect()}},[b]);const w=A.useMemo(()=>{var A;const t=[],r=[...e].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return ft(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[e,n]of r){if(!n.latitude||!n.longitude)continue;const r=u(e),s=c(e,r);if(s<=.01)continue;const l=o.has(e),d=a.hubNodes.includes(e),f=(null==(A=a.gatewayNodes)?void 0:A.includes(e))??!1,g=a.mobileNodes.includes(e),h=ft(n),m=a.centrality.get(e)||0,b=i.get(e),p="stale"===(null==b?void 0:b.status),x=p?Math.min(s,.5):s;let v="standard";h?v="roomServer":d?v="hub":f?v="gateway":g&&(v="mobile");const w=a.fullAffinity.get(e),y=a.txDelayRecommendations.get(e);t.push({type:"Feature",geometry:{type:"Point",coordinates:[n.longitude,n.latitude]},properties:{hash:e,name:n.node_name||n.name||"Unknown",hashPrefix:gt(e),iconType:v,isNeighbor:l,isHub:d,isGateway:f,isMobile:g,isRoomServer:h,isStale:p,isZeroHop:l,opacity:x,blinkIntensity:0,lastSeenTimestamp:null==b?void 0:b.lastSeen,centrality:m,neighborJson:JSON.stringify(n),affinityJson:w?JSON.stringify(w):void 0,txDelayRecJson:y?JSON.stringify(y):void 0,meanSnr:(null==b?void 0:b.avgSnr)??void 0,meanRssi:(null==b?void 0:b.avgRssi)??void 0}})}return{type:"FeatureCollection",features:t}},[e,o,i,a,c,u]),y=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?gt(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]),k=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)},[g]),C=A.useCallback(A=>{var e,t;if(!A.features||0===A.features.length)return;const r=null==(e=null==b?void 0:b.getMap)?void 0:e.call(b);r&&(r.getCanvas().style.cursor="pointer");const n=null==(t=A.features[0].properties)?void 0:t.hash;n&&l(n)},[b,l]),B=A.useCallback(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);e&&(e.getCanvas().style.cursor=""),l(null)},[b,l]);A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e||!x)return;const t=[Je,Xe];for(const r of t)e.on("click",r,k),e.on("mouseenter",r,C),e.on("mouseleave",r,B);return()=>{for(const A of t)e.off("click",A,k),e.off("mouseenter",A,C),e.off("mouseleave",A,B)}},[b,x,k,C,B]);const M=A.useRef(w),D=A.useRef(y);A.useEffect(()=>{M.current=w,D.current=y},[w,y]),A.useEffect(()=>{var A;const e=null==(A=null==b?void 0:b.getMap)?void 0:A.call(b);if(!e||!x||!m||0===m.size)return;const t=e.getSource(Ke),r=e.getSource(`${Ke}-local`);if(t||r){if(t){const A=M.current;let e=!1;const r=A.features.map(A=>{const t=m.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=m.get(n)??0,e=D.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}}]})}}},[b,x,m,n]);const E=A.useMemo(()=>{if(!f)return null;if("local"===f&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=w.features.find(A=>A.properties.hash===f);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}},[f,r,n,w]);if(!x)return null;const N=dA(),Q=["case",[">",["get","blinkIntensity"],.66],ut,[">",["get","blinkIntensity"],.33],lt,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],at,it],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],et,At],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],rt,tt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],ot,nt],["case",["get","isNeighbor"],$e,qe]],j=["interpolate",["linear"],["zoom"],6,.25,10,1];return t.jsxs(t.Fragment,{children:[t.jsx(z,{id:Ke,type:"geojson",data:w,children:t.jsx(G,{id:Je,type:"symbol",layout:{"icon-image":Q,"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),t.jsx(z,{id:`${Ke}-local`,type:"geojson",data:y,children:t.jsx(G,{id:Xe,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],dt,[">",["get","blinkIntensity"],.33],ct,st],"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),E&&h&&t.jsx(O,{longitude:E.longitude,latitude:E.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:E.isLocal?t.jsxs("div",{className:"text-sm",children:[t.jsx("strong",{className:"text-base",children:E.name}),E.hash&&t.jsx("span",{className:"ml-2 font-mono text-xs text-text-muted bg-surface-elevated px-1.5 py-0.5 rounded",children:gt(E.hash)}),t.jsx("br",{}),t.jsx("span",{style:{color:N.localColor},className:"font-medium",children:"This Node (Local)"}),t.jsx("br",{}),r&&t.jsxs("span",{className:"text-xs text-text-muted",children:[r.latitude.toFixed(5),", ",r.longitude.toFixed(5)]})]}):E.neighbor&&E.hash?t.jsx(Ze,{hash:E.hash,hashPrefix:E.hashPrefix,name:E.name,isHub:E.isHub,isGateway:E.isGateway,isBackbone:E.isBackbone,isZeroHop:E.isZeroHop,isMobile:E.isMobile,isRoomServer:E.isRoomServer,isStale:E.isStale,lastSeenTimestamp:E.lastSeenTimestamp,centrality:E.centrality,affinity:E.affinity,meanSnr:E.meanSnr,meanRssi:E.meanRssi,neighbor:E.neighbor,txDelayRec:E.txDelayRec,onRemove:d?()=>d(E.hash,E.name):void 0}):null})]})}const mt=[Je,Xe];A.createContext(null);const bt="topology-validated-edges-native",pt="topology-weak-edges-native",xt="neighbor-edges-native",vt="topology-weak-edges-native",wt="topology-validated-edges-native",yt="neighbor-edges-native",kt={type:"FeatureCollection",features:[]},Ct={"line-cap":"round","line-join":"round"},Bt={"line-color":"transparent","line-width":16,"line-opacity":0};function Mt({showTopology:e,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,onEdgeHover:i,onLoopHover:a,loops:s=[],neighborNames:l={},opacityBias:c=.5,widthMultiplier:u=1,trafficFilter:d=0,showNeighborLines:f=!0,disableHover:g=!1}){const{current:h}=S(),m=e||r,b=!0,p=f?"visible":"none",x=g||r,v=A.useRef(null),w=A.useRef(x),y=A.useRef(new Map),k=A.useRef(l),C=A.useRef(a);A.useLayoutEffect(()=>{w.current=x,k.current=l,C.current=a});const B=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}(s),[s]);A.useLayoutEffect(()=>{y.current=B},[B]);const M=A.useCallback(A=>{var e,t;if(w.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!==v.current){v.current=n;const o=!0===r.isNeighborEdge||"true"===r.isNeighborEdge,a=!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};i(n,[A.lngLat.lng,A.lngLat.lat],t),null==(e=C.current)||e.call(C,null)}else if(a&&C.current){const e=y.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=>k.current[A]||A.substring(0,4))};C.current(r,[A.lngLat.lng,A.lngLat.lat]),i(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};i(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:a,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};i(n,[A.lngLat.lng,A.lngLat.lat],e),null==(t=C.current)||t.call(C,null)}}},[i]),D=A.useCallback(()=>{var A;null!==v.current&&(v.current=null,i(null),null==(A=C.current)||A.call(C,null))},[i]);A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);if(!e||!m)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,M),e.on("mouseleave",t,D),!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,M),e.off("mouseleave",t,D))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,M),e.off("mouseleave",t,D))}catch{}}},[h,m,M,D]),A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);if(!e||!f)return;const t="neighbor-edges-hitarea-native",r=()=>{try{return e.getStyle()&&e.getLayer(t)}catch{return!1}},n=()=>!!r()&&(e.on("mousemove",t,M),e.on("mouseleave",t,D),!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,M),e.off("mouseleave",t,D))}catch{}}}return()=>{try{r()&&(e.off("mousemove",t,M),e.off("mouseleave",t,D))}catch{}}},[h,b,f,M,D]),A.useEffect(()=>{var A;const e=null==(A=null==h?void 0:h.getMap)?void 0:A.call(h);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(yt,"node-markers-layer"),r("neighbor-edges-hitarea-native",yt),(r(wt,"neighbor-edges-hitarea-native")||r(wt,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",wt),r(vt,"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===bt||A.sourceId===pt||A.sourceId===xt)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[h,m,b,f]);const E=x?null:n,N=function(A,e,t,r,n){const o=CA(),i=null!==A,a=n&&n.size>0,s=a?Array.from(n):[],l=e<=0?["get","baseColor"]:["case",[">=",["get","brightnessScore"],1-.5*e],"#FFFFFF",["get","baseColor"]],c=e<=0?1:["max",.1,["+",1,["*",e,3,["-",["get","brightnessScore"],.5]]]],u=a?["in",["get","key"],["literal",s]]:!!i&&["==",["get","key"],A],d=i||a,f=o.edges.hoverLoop??"#A78BFA";return{"line-color":d?["case",u,a?f:["get","hoverColor"],l]:l,"line-width":d?["case",u,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,d?["case",u,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],c,.35]]:["*",["get","baseOpacity"],c]]}}(E,c,u,d,x?null:o),Q=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=W,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}}(E);return t.jsxs(t.Fragment,{children:[m&&t.jsx(z,{id:pt,type:"geojson",data:kt,children:t.jsx(G,{id:vt,type:"line",paint:N,layout:Ct})}),m&&t.jsxs(z,{id:bt,type:"geojson",data:kt,children:[t.jsx(G,{id:"topology-validated-edges-hitarea-native",type:"line",paint:Bt,layout:Ct}),t.jsx(G,{id:wt,type:"line",paint:N,layout:Ct})]}),t.jsxs(z,{id:xt,type:"geojson",data:kt,children:[t.jsx(G,{id:"neighbor-edges-hitarea-native",type:"line",paint:Bt,layout:{...Ct,visibility:p}}),t.jsx(G,{id:yt,type:"line",paint:Q,layout:{...Ct,visibility:p}})]})]})}const Dt=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function Et({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=S(),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 Nt({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=S(),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 Qt(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 jt(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 Pt({ghost:e,neighborCoordinates:r,onHighlightedNeighborsChange:n}){const{current:o}=S(),i=A.useRef(null),a=A.useRef(null),s=A.useMemo(()=>e?new Set(e.commonNeighbors):new Set,[e]);A.useEffect(()=>{null==n||n(s)},[s,n]);const l=A.useMemo(()=>{if(!(null==e?void 0:e.commonNeighbors)||e.commonNeighbors.length<2)return 8e3;let A=0;const t=[];for(const n of e.commonNeighbors){const A=r.get(n);A&&t.push(A)}e.estimatedLocation&&t.push([e.estimatedLocation.lat,e.estimatedLocation.lon]);for(let e=0;eA&&(A=n)}return Math.max(A,2e3)},[e,r]),c=A.useMemo(()=>{if(!(null==e?void 0:e.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:A,lon:t,uncertaintyM:r}=e.estimatedLocation,n=.5*l,o=r>0?r:2e3;return{type:"FeatureCollection",features:[jt(t,A,Math.max(500,Math.min(o,n)))]}},[e,l]);if(A.useEffect(()=>{if(!o)return;const A=o.getMap();if(e&&e.prefix!==a.current){if(a.current=e.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 t=[];for(const A of e.commonNeighbors){const e=r.get(A);e&&t.push([e[1],e[0]])}if(e.estimatedLocation&&t.push([e.estimatedLocation.lon,e.estimatedLocation.lat]),t.length>0){const r=()=>{var n;if(A.isMoving())setTimeout(r,100);else if(1===t.length)o.flyTo({center:t[0],zoom:13,duration:1500});else{let A=1/0,r=-1/0,i=1/0,a=-1/0;for(const[e,n]of t)A=Math.min(A,e),r=Math.max(r,e),i=Math.min(i,n),a=Math.max(a,n);if(null==(n=e.estimatedLocation)?void 0:n.uncertaintyM){const t=e.estimatedLocation.uncertaintyM/111e3;A-=t,r+=t,i-=t,a+=t}o.fitBounds([[A,i],[r,a]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:1500})}};setTimeout(r,50)}}if(!e&&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)}},[e,o,r]),!(null==e?void 0:e.estimatedLocation))return null;return t.jsx(z,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:t.jsx(G,{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))}(kA.edges.neighborHover);const Ft={longitude:0,latitude:0,zoom:2};function St(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))*6371}function Lt({data:A}){const e=A.subtitle&&"loop"===A.type,r=A.subtitle&&"loop"!==A.type;return t.jsxs("div",{className:"w-[540px]",children:[t.jsxs("div",{className:"flex items-center justify-between h-5",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[A.title.icon&&t.jsx("span",{className:`${A.title.color} text-base leading-none flex-shrink-0`,children:A.title.icon}),t.jsx("span",{className:`${A.title.color} font-semibold text-[13px] truncate`,children:A.title.text}),r&&t.jsx("span",{className:`${A.subtitle.color} text-[11px] flex-shrink-0`,children:A.subtitle.text})]}),A.badges.length>0&&t.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:A.badges.map((A,e)=>t.jsx("span",{className:`${A.color} text-[11px] font-medium`,children:A.text},e))})]}),e&&t.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:t.jsx("span",{className:"font-mono text-[10px] text-text-muted truncate block",children:A.subtitle.text})}),t.jsx("div",{className:`flex items-center gap-4 h-4 ${e?"mt-1":"mt-1.5"} text-[11px]`,children:A.stats.map((A,e)=>t.jsxs("span",{className:"whitespace-nowrap",children:[t.jsx("span",{className:`font-mono tabular-nums font-semibold ${A.color??"text-text-primary"}`,children:A.value}),t.jsx("span",{className:"text-text-muted ml-1",children:A.label}),A.unit&&t.jsx("span",{className:"text-text-muted/50 ml-0.5",children:A.unit})]},e))})]})}function It({neighbors:e,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=nA(),d=oA(),f=iA(),g=aA(),h=sA(),[m,b]=A.useState(!1),p=lA(A=>A.preloadFromNodes),x=lA(A=>A.isLoading),v=lA(A=>A.terrainGrid),w=n??h,y=A.useMemo(()=>{const A=[];for(const[,t]of Object.entries(e))t.latitude&&t.longitude&&A.push([t.latitude,t.longitude]);return A},[e]),k=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])=>({pos:[A,e],dist:St(t,r,A,e)}));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[f,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,f),i=Math.max(i,f);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let d=16;return u>0&&(d=Math.floor(Math.log2(360/u*1.2)),d=Math.max(1,Math.min(14,d))),d=Math.min(d+1,12),{longitude:a,latitude:s,zoom:d}}(y,r),[y,r]),[C,B]=A.useState(()=>k??Ft),M=A.useRef(!1);A.useEffect(()=>{!M.current&&k&&(B(k),M.current=!0,setTimeout(()=>b(!0),50))},[k]);const[D,E]=A.useState(!1),[N,Q]=A.useState(!1),[j,P]=A.useState(!0),[F,S]=A.useState(!1),[L,I]=A.useState(!1),[R,T]=A.useState("all"),[_,H]=A.useState(null),[z,G]=A.useState(null),[O]=A.useState(0),[W]=A.useState(.5),[Z]=A.useState(0),[K,J]=A.useState(null),[tA,rA]=A.useState(""),[uA,dA]=A.useState(!1),[fA,gA]=A.useState("fetching"),[hA,mA]=A.useState(!1),[bA,pA]=A.useState(0),[xA,wA]=A.useState(!1),[kA,CA]=A.useState(null),MA=A.useCallback(A=>CA(A),[]),DA=A.useCallback(()=>CA(null),[]),[,NA]=A.useState(new Set),jA=ZA(A=>A.coveragePoints),PA=ZA(A=>A.isVisible),FA=ZA(A=>A.brightness),LA=ZA(A=>A.openModal),RA=qA(A=>A.isEnabled),_A=qA(A=>A.toggle),HA=A.useRef(!1);A.useEffect(()=>{jA.length>0&&PA&&!HA.current&&(P(!1),HA.current=!0)},[jA.length,PA]);const zA=A.useRef(null);A.useEffect(()=>{if(i&&i!==zA.current){zA.current=i;const A=setTimeout(()=>{CA(i)},1250);return()=>clearTimeout(A)}},[i]);const[GA,OA]=A.useState(null),[UA,YA]=A.useState(null),WA=A.useCallback((A,e,t)=>{G(A),A&&e&&t?OA({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,color:"",width:0,opacity:0,symmetryRatio:t.symmetryRatio,dominantDirection:t.dominantDirection}}):A||OA(null)},[]),VA=A.useCallback((A,e)=>{YA(A),A&&OA(null)},[]),KA=A.useMemo(()=>{const A={};for(const[t,r]of Object.entries(e))A[t]=r.node_name||r.name||t.substring(0,4);return w&&(A[w]="You"),A},[e,w]),XA=A.useMemo(()=>Object.entries(e).filter(([,A])=>A.latitude&&A.longitude),[e]),$A=A.useMemo(()=>{const A=new Map;w&&(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude)&&A.set(w,[r.latitude,r.longitude]);for(const[e,t]of XA)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[w,r,XA]),Ae=A.useMemo(()=>{const A=new Map;for(const e of f)"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},[f]),ee=A.useMemo(()=>{var A,t;const r=new Set;for(const n of Ae.keys())(null==(A=e[n])?void 0:A.latitude)&&(null==(t=e[n])?void 0:t.longitude)&&r.add(n);return r},[Ae,e]),te=A.useMemo(()=>{if(0===ee.size||!w)return new Map;const A=q.getPackets();if(0===A.length)return new Map;const e=AA(w);return V(A,ee,e).scores},[ee,w,g.packetCount]),re=A.useCallback(A=>!!(w&&(A.fromHash===w&&ee.has(A.toHash)||A.toHash===w&&ee.has(A.fromHash))),[w,ee]),ne=A.useMemo(()=>{var A,t;if(0===f.length||!w)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of f){if("expired"===n.status)continue;if(!(null==(A=e[n.hash])?void 0:A.latitude)||!(null==(t=e[n.hash])?void 0:t.longitude))continue;const o=[w,n.hash].sort(),i=`${o[0]}~${o[1]}`;r.push({fromHash:w,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},[f,w,g.backgroundLoadComplete,e]),oe=A.useMemo(()=>{const A=[];if(ne.length>0&&!g.backgroundLoadComplete){for(const e of ne){const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(re(e))continue;const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,$A,re,ne,g.backgroundLoadComplete]),ie=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(re(e))continue;const t=$A.get(e.fromHash),r=$A.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,$A,re]),ae=A.useMemo(()=>{if(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude))return[];const A=[],t=[r.latitude,r.longitude],n=new Map;for(const e of u.lastHopNeighbors)n.set(e.hash,e.count);const o=new Map;for(const e of f)o.set(e.hash,e.count);for(const r of ee){const i=e[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:t,to:[i.latitude,i.longitude],hash:r,neighbor:i,lastHopData:Ae.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,ee,e,Ae,u.lastHopNeighbors,f]),se=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),le=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),ce=A.useMemo(()=>{let A=0;if(ne.length>0&&!g.backgroundLoadComplete){for(const e of ne)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,ne,g.backgroundLoadComplete]),ue=A.useRef(null);A.useLayoutEffect(()=>{var A,e;ue.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const de=X(),fe=A.useMemo(()=>q.getPackets(),[de]);!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),d=A.useRef([]),f=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),x=A.useRef(new Map),v=A.useRef(t);A.useEffect(()=>{v.current=t},[t]),A.useEffect(()=>{x.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=AA(r);t.has(A)||t.set(A,r)}if(e){const A=AA(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),d.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(_e);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,f.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(He)&&A.removeLayer(He),A.getSource(_e)&&A.removeSource(_e),A.addSource(_e,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Oe)?Oe:void 0;A.addLayer({id:He,type:"line",source:_e,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],"#8B7BAD","#00FFFF"],"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(He)&&A.removeLayer(He),A.getSource(_e)&&A.removeSource(_e)}catch{}c.current=!1,m(!1)}}},[l]);const w=A.useRef(()=>{});A.useEffect(()=>{w.current=()=>{const A=s.current;if(!A)return;const e=A.getSource(_e);if(!e)return;const t=performance.now(),r=d.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ge:ze)){o.push(i);const e=i.isSpeculative?Ye(A):Ue(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}),d.current=o,o.length>0?u.current=requestAnimationFrame(()=>w.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(He))return;const e=A.getLayer(Oe)?Oe:void 0;try{A.moveLayer(He,e)}catch{}}(A),null===u.current&&(u.current=requestAnimationFrame(()=>w.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=x.current,t=v.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=$(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,f=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(f),n=t.get(o);d.current.push({edgeKey:A,fromCoord:We(e),toCoord:We(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=f.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A),n=Math.max(...r.map(A=>A.timestamp??0));if(f.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);0!==n.length&&(f.current=Math.max(...n.map(A=>A.timestamp??0)),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:ue,nodeCoordinates:$A,packets:fe,localHash:w,neighbors:e,meshTopology:u,enabled:RA});const{isExiting:ge,isAnimating:he,resetAnimationState:me}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:d=[],showNeighborLines:f=!0,neighborSourceId:g,neighborLinkScores:h=new Map}){const m=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;m.current=A});const b=A.useRef(new Map),p=A.useRef(1),x=A.useRef(new Map),v=A.useRef(new Map),w=A.useRef(!1),y=A.useRef(null),k=A.useRef(t),C=A.useRef(new Set),B=A.useRef(""),M=A.useRef(new Map),D=A.useRef(""),E=A.useRef(""),N=A.useRef(""),Q=A.useRef(r),j=A.useRef(n),P=A.useRef(o),F=A.useRef(i),S=A.useRef(a),L=A.useRef(s),I=A.useRef(l),R=A.useRef(d),T=A.useRef(f),_=A.useRef(h);A.useEffect(()=>{Q.current=r,j.current=n,P.current=o,F.current=i,S.current=a,L.current=s,I.current=l,R.current=d,T.current=f,_.current=h},[r,n,o,i,a,s,l,d,f,h]);const H=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,d;const f=m.current;if(!f)return;const h=f.getSource(c),w=f.getSource(u),y=f.getSource(g);if(h){const o=Se(Q.current,!0,b.current,p.current,x.current,v.current,P.current,F.current,S.current,L.current,I.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(b.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==D.current)&&(h.setData(o),D.current=i)}if(w){const e=Se(j.current,!1,b.current,p.current,x.current,v.current,P.current,F.current,S.current,L.current,I.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!==E.current)&&(w.setData(e),E.current=t)}if(y&&R.current.length>0){const e=Le(R.current,_.current),t=`${e.features.length}:${(null==(d=null==(l=e.features[0])?void 0:l.properties)?void 0:d.hash)??""}`;(A||t!==N.current)&&(y.setData(e),N.current=t)}},[c,u,g]),z=A.useCallback(()=>{y.current&&(cancelAnimationFrame(y.current),y.current=null),b.current=new Map,p.current=1,x.current=new Map,v.current=new Map,w.current=!1,C.current=new Set,B.current="",M.current=new Map},[]);return A.useEffect(()=>{const A=k.current,e=t;if(k.current=t,m.current){if(y.current&&(cancelAnimationFrame(y.current),y.current=null),A&&!e&&!w.current){w.current=!0;const A=new Map(b.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)b.current.set(e,t*(1-i));H(!0),o<1?y.current=requestAnimationFrame(t):(w.current=!1,b.current=new Map,C.current=new Set,B.current="",x.current=new Map,v.current=new Map,y.current=null,H(!0))};y.current=requestAnimationFrame(t)}!A&&e&&(b.current=new Map,C.current=new Set,B.current="")}},[t,H]),A.useEffect(()=>{const A=m.current;if(!t||w.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===C.current.size,a=""!==B.current&&B.current!==o;if(!i&&!a)return void H();const s=[],l=[];for(const{edge:t}of e)C.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(x.current=new Map(M.current),p.current=0),v.current=new Map;for(const{edge:t}of r){const A=vA(t.certainCount);v.current.set(t.key,A)}for(const t of s)b.current.set(t,0);for(const t of l)b.current.has(t)||b.current.set(t,1);if(s.length>0||a&&l.length>0){y.current&&(cancelAnimationFrame(y.current),y.current=null);let A=null;const e=Math.min(100,BA/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/BA,1);p.current=Fe(A)}H(!0);const o=BA+(s.length-1)*e;y.current=n{const A=m.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(d.length>0){const A=Le(d,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,d,h]),A.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=null)},[]),{isExiting:w.current,isAnimating:null!==y.current,resetAnimationState:z,weightAnimProgress:p.current,animStartWeights:x.current,animTargetWeights:v.current}}({map:ue,showTopology:N,validatedPolylines:oe,weakPolylines:ie,maxCertainCount:ce,loopEdgeKeys:se,backboneEdgeKeys:le,highlightedEdgeKey:s,neighbors:e,validatedSourceId:bt,weakSourceId:pt,neighborPolylines:ae,showNeighborLines:j,neighborSourceId:xt,neighborLinkScores:te}),be=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]),pe=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),d=A.useRef(new Map),f=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;f.current&&(cancelAnimationFrame(f.current),f.current=null);const a=g.current,s=h.current,p=m.current,x=b.current;for(const e of r)d.current.has(e)||d.current.set(e,Math.random());const v=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=x&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},w=[];for(const e of r){const t=v(e,A,n),r=v(e,o,i);t!==r&&w.push({hash:e,startOpacity:t?1:0,targetOpacity:r?1:0})}if(0===w.length)return;l(A=>{const e=new Map(A);for(const{hash:t,startOpacity:r}of w)e.set(t,r);return e});const y=w;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*(d.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Ie(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?f.current=requestAnimationFrame(C):(f.current=null,l(new Map))};return f.current=requestAnimationFrame(C),()=>{f.current&&(cancelAnimationFrame(f.current),f.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===R,soloHubs:"hubs"===R,neighborHashes:XA.map(([A])=>A),hubConnectedNodes:be,directNodeSet:ee,localConnectedNodes:pe,showTopology:N}),{blinkingNodes:ve,blinkColor:we}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=X(),a=A.useRef(q.getPackets());A.useEffect(()=>{a.current=q.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=AA(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const d=A.useRef(null);return A.useEffect(()=>{d.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=Re(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&d.current?l.current=requestAnimationFrame(d.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 f=0;for(const r of n){const A=$(r,t);if(!A||0===A.original.length)continue;const e=Te(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:e,localHash:n,enabled:RA}),ye=A.useCallback(A=>{if("all"===R)return!0;if("direct"===R)return ee.has(A);if("hubs"===R){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},[R,ee,u.hubNodes,u.validatedEdges]),Ce=A.useCallback(async()=>{mA(!0),dA(!0),gA("fetching"),pA(0),await d(),pA(g.packetCount),gA("analyzing"),await new Promise(A=>setTimeout(A,200)),gA("building");const A=Date.now(),e=Date.now()-A;e<1700&&await new Promise(A=>setTimeout(A,1700-e)),gA("complete"),await new Promise(A=>setTimeout(A,1e3)),dA(!1),mA(!1),me(),wA(!0),setTimeout(()=>{Q(!0)},150)},[d,me,g.packetCount]),Be=A.useCallback(()=>{xA?Q(A=>!A):Ce()},[xA,Ce]),Me=A.useCallback(A=>{B(A.viewState)},[]),De=A.useCallback(()=>{E(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})},[]),Ee=A.useCallback(A=>{T(A)},[]),Qe=A.useCallback(()=>{P(A=>!A)},[]),je=A.useCallback(()=>{S(A=>!A)},[]),Pe=A.useCallback(()=>{I(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})},[]),Ve=A.useCallback(()=>{N||Q(!0)},[N]),Ze=A.useCallback((A,e)=>{J(A),rA(e)},[]),Ke=A.useCallback(()=>{K&&o&&o(K),J(null),rA("")},[K,o]),Je=A.useMemo(()=>[...Dt,...mt],[]),Xe=A.useRef(!1);A.useEffect(()=>{Xe.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const qe=A.useCallback(A=>{!Xe.current||!GA||A.features&&0!==A.features.length||(OA(null),G(null))},[GA]),$e=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(z&&(G(null),OA(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]$/,"");G(e),A.lngLat&&OA({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{}},[z]),At=A.useCallback(()=>{var A;G(null),OA(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),et=D?"map-container-fullscreen":"map-container-16-9",tt=y.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),rt=!m||!tt,nt=tt;return t.jsxs("div",{className:`relative ${et}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions",children:[t.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."}),rt&&t.jsx("div",{className:"absolute inset-0 z-50 glass-card flex items-center justify-center","aria-hidden":"true",children:t.jsxs("div",{className:"flex flex-col items-center gap-3",children:[t.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),t.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),nt&&t.jsx("div",{className:`relative w-full h-full ${D?"":"rounded-[1.125rem] overflow-hidden"} ${rt?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:t.jsxs(U,{ref:c,...C,onMove:Me,mapStyle:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:Je,onMouseMove:$e,onMouseLeave:At,onClick:qe,onLoad:A=>{const e=A.target;try{const A=e.getStyle();if(null==A?void 0:A.layers){const t=["road","highway","tunnel","bridge","motorway","trunk","primary","secondary","tertiary","street","path","track"],r=A=>t.some(e=>A.toLowerCase().includes(e));for(const n of A.layers)"fill"===n.type&&n.id.toLowerCase().includes("water")&&e.setPaintProperty(n.id,"fill-color","rgba(22, 26, 32, 1)"),"line"===n.type&&r(n.id)&&e.setPaintProperty(n.id,"line-color","rgba(25, 26, 29, 1)"),"symbol"===n.type&&(e.setPaintProperty(n.id,"text-color","rgba(108, 110, 120, 0.85)"),e.setPaintProperty(n.id,"text-halo-color","rgba(8, 9, 11, 0.9)"),e.setPaintProperty(n.id,"text-halo-width",1),e.setLayoutProperty(n.id,"text-font",["Inter","Open Sans Regular","Arial Unicode MS Regular"]))}}catch(t){}},onError:A=>{},onIdle:()=>{if(!v&&!x&&c.current){const A=c.current.getMap();if(A){const t=Object.values(e).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)&&t.push({latitude:r.latitude,longitude:r.longitude}),t.length>0&&p(t,A)}}},children:[t.jsx(Y,{position:"bottom-right"}),t.jsx(Ne,{enabled:L,exaggeration:4}),t.jsx(ke,{coveragePoints:jA,visible:jA.length>0&&PA,terrainEnabled:L,brightness:FA}),t.jsx(Mt,{showTopology:N,isExiting:ge,hoveredEdgeKey:z,highlightedLoopEdges:null==UA?void 0:UA.highlightedEdgeKeys,onEdgeHover:WA,onLoopHover:VA,loops:u.loops,neighborNames:KA,opacityBias:O,widthMultiplier:W,trafficFilter:Z,showNeighborLines:j,disableHover:he||hA}),i&&t.jsx(Et,{targetHash:i,nodeCoordinates:$A,onComplete:a}),s&&t.jsx(Nt,{highlightedEdgeKey:s,validatedPolylines:oe,weakPolylines:ie,onEnsureTopology:Ve}),t.jsx(Pt,{ghost:l??null,neighborCoordinates:$A,onHighlightedNeighborsChange:NA}),t.jsx(ht,{neighborsWithLocation:XA,localNode:r,localHash:n,zeroHopNeighbors:ee,lastHopNeighborMap:Ae,meshTopology:u,hoveredMarker:_,onMarkerHover:H,getNodeOpacity:xe,shouldShowNode:ye,onRequestRemove:o?Ze:void 0,openPopupId:kA,onOpenPopup:MA,onClosePopup:DA,blinkingNodes:ve,blinkColor:we})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"edges in loop",value:A.size},{label:"strength",value:`${Math.round(100*A.strength)}%`,unit:"(weakest link)"}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`Part of ${t} overlapping loops`,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}(GA?{type:GA.type,properties:GA.properties}:null,UA,ce);return A&&t.jsx("div",{className:"map-edge-tooltip",children:t.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:t.jsx(Lt,{data:A})})})})(),t.jsx(QA,{mapRef:c,showNeighborLines:j,onToggleNeighborLines:Qe,hasNeighborPolylines:ae.length>0,nodeFilter:R,onNodeFilterChange:Ee,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:ee.size>0,showCoverage:F,onToggleCoverage:je,show3DTerrain:L,onToggle3DTerrain:Pe,isFullscreen:D,onToggleFullscreen:De}),t.jsxs("div",{className:"map-legend-stack",children:[t.jsx(SA,{isActive:N,hasAnalyzed:xA,isLoading:hA,onClick:Be}),t.jsx(IA,{isActive:RA,onClick:_A}),t.jsx(TA,{isActive:jA.length>0&&PA,onClick:LA}),t.jsx(EA,{showTopology:N,validatedPolylineCount:oe.length,filteredNeighborCount:XA.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:ee,neighborsWithLocation:XA})]}),!D&&t.jsx("div",{className:"glass-card-frame absolute inset-0 pointer-events-none rounded-[1.125rem]",style:{zIndex:9999},"aria-hidden":"true"}),t.jsx(cA,{isOpen:null!==K,onCancel:()=>J(null),onConfirm:Ke,title:"Remove Node?",message:`Remove "${tA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),t.jsx(yA,{isOpen:uA,currentStep:fA,packetCount:bA}),t.jsx(JA,{})]})}export{It as default}; diff --git a/frontend/dist/assets/Dashboard-D_Tfd9l2.js b/frontend/dist/assets/Dashboard-Bb03OXu_.js similarity index 99% rename from frontend/dist/assets/Dashboard-D_Tfd9l2.js rename to frontend/dist/assets/Dashboard-Bb03OXu_.js index ce011391..103150ec 100644 --- a/frontend/dist/assets/Dashboard-D_Tfd9l2.js +++ b/frontend/dist/assets/Dashboard-Bb03OXu_.js @@ -1 +1 @@ -import{j as e,r as t,T as s,y as n,z as a,A as l,p as r,D as i,g as o,E as c,x as d,H as u,I as m,J as h,K as x,O as p,Q as f,Z as g,U as v,V as j,W as b,Y as N,o as y}from"./vendor-react-O8XH9yVn.js";import{u as w,a as k,b as M,c as _,d as L,e as S,f as C,h as R,j as T,T as B,k as F,m as A,n as I,D as P,o as D}from"./index-Dp0UlTio.js";import{u as $,a as E}from"./useThemeColors-CD0TSU03.js";import{C as H,S as W,a as z,P as O,b as G,c as K}from"./PageLayout-DE5PEtD2.js";import{P as J,a as V,b as U,g as q}from"./PacketDetailModal-CR1FHEH5.js";import{T as X}from"./TimeRangeSelector-9pGCd7oa.js";import{H as Q}from"./HashBadge-aS_UIcg2.js";import{s as Y}from"./SignalIndicator-BVAbF7xm.js";import{R as Z,L as ee,a as te,A as se,C as ne,X as ae,Y as le,T as re,b as ie}from"./recharts-BU7auunF.js";import{c as oe}from"./link-scoring-DacI-LFP.js";import{R as ce}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const de={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)"}},ue={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function me({buckets:s,colorType:n,height:a=64}){const l=de[n].barBase,r=t.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=s.length/60,t=e<=1?s:Array.from({length:60},(t,n)=>{var a,l;const r=s.slice(Math.floor(n*e),Math.floor((n+1)*e)),i=r.reduce((e,t)=>e+t.count,0),o=r.length?r.reduce((e,t)=>e+t.avg_snr,0)/r.length:0;return{bucket:n,start:(null==(a=r[0])?void 0:a.start)??0,end:(null==(l=r.at(-1))?void 0:l.end)??0,count:i,airtime_ms:r.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),n=Math.max(...t.map(e=>e.count),1);return t.map(e=>({height:e.count>0?Math.max(e.count/n*100,8):0,color:e.count>0?l:"transparent",count:e.count,snr:e.avg_snr}))},[s,l]);return(null==s?void 0:s.length)?e.jsx("div",{className:"w-full flex items-end gap-[1px]",style:{height:a},children:r.map((t,s)=>{var n;return e.jsx("div",{className:"flex-1 rounded-t-sm",style:{height:`${t.height}%`,backgroundColor:t.color,opacity:t.count>0?.8:.1,minHeight:t.count>0?"4px":"2px",maxWidth:"4px"},title:t.count>0?`${t.count} packets, SNR: ${null==(n=t.snr)?void 0:n.toFixed(1)}dB`:"No packets"},s)})}):e.jsx("div",{className:"w-full flex items-end justify-center gap-[2px] opacity-20",style:{height:a},children:e.jsx("span",{className:"type-data-xs text-text-muted",children:"No data"})})}function he({title:t,value:s,color:n="neutral",subtitle:a,buckets:l,timeRangeLabel:r,icon:i,size:o="md",isLoaded:c=!0}){const{barBase:d}=de[n],u="string"==typeof s?s:s.toLocaleString();return c?e.jsxs("div",{className:`data-card flex flex-col relative ${ue[o]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-text-secondary",children:i}),e.jsx("span",{className:"type-micro",children:t}),r&&e.jsx("span",{className:"pill-tag",children:r})]}),e.jsx("div",{className:"data-card-value",children:u}),e.jsx("div",{className:"flex-1 py-2 mt-2",children:l?e.jsx(me,{buckets:l,colorType:n,height:64}):e.jsx("div",{className:"w-full h-16 flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full",style:{backgroundColor:d,opacity:.15}})})}),e.jsx("div",{className:"type-label text-text-muted border-t border-border-subtle pt-3 mt-2",children:a??`Total ${t.toLowerCase()}`})]}):e.jsx("div",{className:`data-card flex flex-col relative ${ue[o]}`,children:e.jsx(H,{})})}const xe=.2;function pe(e,t=1){return Math.floor(5*t*e)}function fe(e){const t=Math.round(e/xe)*xe;return Math.max(0,Math.min(5,t))}function ge({stats:t,receivedBuckets:r,droppedBuckets:i,forwardedBuckets:o,bucketDurationSeconds:c,timeRangeLabel:d,isLoaded:u=!0}){var m,h,x,p;if(!u)return e.jsx("div",{className:"data-card flex flex-col relative",children:e.jsx(H,{})});const f=function(e,t,s,n,a){var l,r;const i=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=i(t),c=i(s),d=i(n),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==n?void 0:n.length)&&a)x=100*d/(n.length*a*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 p=(null==e?void 0:e.neighbors)??{},f=Object.values(p).filter(e=>e.zero_hop).length;let g=1;h<3?g-=xe:h>15?g+=.4:h>10&&(g+=xe),x>5&&(g+=xe),f>10&&(g+=xe);const v=fe(g),j=fe(.28*v),b=pe(v),N=pe(j),y=pe((null==(r=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:r.tx_delay_factor)??1);return{floodFactor:v,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b10?"text-accent-warning":"text-text-secondary"),children:[f.duplicateRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-muted",children:"TX Util"}),e.jsxs("span",{className:"tabular-nums text-text-secondary",children:[f.txUtilization.toFixed(2),"%"]})]})]}),e.jsx("div",{className:"type-label text-text-muted border-t border-border-subtle pt-3 mt-2 truncate",children:null!==g?e.jsxs("span",{children:["Current: ×",g.toFixed(1)," / ×",(null==v?void 0:v.toFixed(1))??"—"]}):e.jsx("span",{children:"Slot-aligned factors"})})]})}function ve(e){return(e.payload_type_name||q(e.payload_type??e.type)).toLowerCase().includes("advert")}function je(){const s=w(),n=k(),a=M(),l=_(),d=L(),[u,m]=t.useState(null),[h,x]=t.useState(null),p=t.useRef(0),f=t.useRef(0),g=t.useMemo(()=>[...s.length<=100?s:s.slice(-100)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0)),[s]),v=t.useMemo(()=>{const e=new Map;if(!(null==d?void 0:d.neighbors))return e;d.local_hash&&e.set(S(d.local_hash),d.local_hash);for(const t of Object.keys(d.neighbors)){const s=S(t);e.has(s)||e.set(s,t)}return e},[d]),j=t.useMemo(()=>g.slice(0,15).map(e=>{if(e.src_hash&&e.src_hash.length<=4){const t=v.get(e.src_hash.toUpperCase());if(t)return{...e,src_hash_full:t}}return e}),[g,v]);t.useEffect(()=>{var e;if(!g.length)return;const t=(null==(e=g[0])?void 0:e.timestamp)??0,s=t>f.current&&f.current>0;if(f.current=t,!s)return;const n=g.find(ve);if(!n||(n.timestamp??0)<=f.current)return;const a=requestAnimationFrame(()=>m(n.packet_hash)),l=setTimeout(()=>m(null),600);return()=>{cancelAnimationFrame(a),clearTimeout(l)}},[g]),t.useEffect(()=>{if(l>0&&l!==p.current&&g.length>0){p.current=l;const e=g.find(ve);if(e){const t=requestAnimationFrame(()=>m(e.packet_hash)),s=setTimeout(()=>m(null),600);return()=>{cancelAnimationFrame(t),clearTimeout(s)}}}},[l,g]);const b=()=>e.jsxs(e.Fragment,{children:[e.jsx(r,{className:"w-6 h-6 text-text-muted mx-auto mb-2"}),e.jsx("div",{className:"text-sm text-text-primary",children:"No packets received"}),e.jsx("div",{className:"text-xs text-text-muted",children:"Packets will appear here"})]});return e.jsxs("div",{className:"chart-container h-full flex flex-col",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(r,{className:"chart-title-icon"}),"Recent Packets"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[a&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{className:"w-2 h-2 fill-accent-success text-accent-success animate-pulse"}),e.jsx("span",{className:"type-data-xs text-text-muted",children:"LIVE"})]}),e.jsxs(o,{to:"/packets",className:"pill-subtle",children:["View all ",e.jsx(c,{className:"w-3 h-3"})]})]})]}),e.jsxs("div",{className:"sm:hidden flex items-center gap-1.5 px-3 py-1.5 border-b border-border-subtle/50 bg-bg-elevated/20",children:[e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-14 flex-shrink-0",children:"Dir"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-7 flex-shrink-0",children:"Time"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-9 flex-shrink-0",children:"Src"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-1 min-w-0",children:"Type"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-14 flex-shrink-0",children:"Route"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-12 flex-shrink-0",children:"Signal"})]}),e.jsx("div",{className:"hidden sm:block flex-1 overflow-hidden",children:e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elevated/95 backdrop-blur-sm",children:e.jsxs("tr",{className:"border-b border-border-subtle/50",children:[e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider w-16",children:"Dir"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Time"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Source"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Route"}),e.jsx("th",{className:"text-right py-1.5 px-3 pr-4 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Signal"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:n&&0===g.length?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-8 text-text-muted",children:"Loading packets..."})}):0===j.length?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-8",children:b()})}):j.map((t,s)=>e.jsx(J,{packet:t,onClick:x,isFlashing:ve(t)&&u===t.packet_hash},`${t.packet_hash}_${t.timestamp}_${s}`))})]})})}),e.jsx("div",{className:"sm:hidden flex-1 overflow-y-auto divide-y divide-border-subtle/30",children:n&&0===g.length?e.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===j.length?e.jsx("div",{className:"p-8 text-center",children:b()}):j.map((t,s)=>e.jsx(V,{packet:t,onClick:x,isFlashing:ve(t)&&u===t.packet_hash},`${t.packet_hash}_${t.timestamp}_${s}`))}),e.jsxs("div",{className:"px-3 py-1.5 border-t border-border-subtle/50 text-[10px] text-text-muted bg-bg-elevated/20 text-center",children:["Showing ",j.length," of ",g.length," packets"]}),h&&e.jsx(U,{packet:h,onClose:()=>x(null)})]})}t.memo(function({active:t,payload:s,label:n,formatValue:a,labelKey:l}){var r;if(!t||!(null==s?void 0:s.length))return null;const i=l&&(null==(r=s[0])?void 0:r.payload)?s[0].payload[l]:n;return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[i&&e.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:i}),e.jsx("div",{className:"space-y-1.5",children:s.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:t.color}}),e.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:t.name}),e.jsx("span",{className:"type-data-sm text-white tabular-nums",children:a?a(t.value,t.name):t.value.toLocaleString()})]},s))})]})});const be=t.memo(function({active:t,payload:s,color:n,labelKey:a,unit:l=""}){var r,i;if(!t||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(r=null==o?void 0:o.payload)?void 0:r[a];return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[e.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n}}),e.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(i=null==o?void 0:o.value)?void 0:i.toLocaleString(),l]})]})]})});t.memo(function({payload:t}){return(null==t?void 0:t.length)?e.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:t.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.color}}),e.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:t.value})]},s))}):null});const Ne={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function ye({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Ne[t]})})})}function we(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function ke({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function Me({title:t,icon:s,value:n,unit:a,valueSize:l="md",status:r,subtitle:i,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(" "),p=["mini-widget",h&&"cursor-pointer",m].filter(Boolean).join(" ");return e.jsxs("div",{className:p,onClick:h,role:h?"button":void 0,children:[e.jsxs("div",{className:"mini-widget-header",children:[s,e.jsx("span",{className:"mini-widget-title",children:t}),r&&"unknown"!==r&&e.jsx("div",{className:`mini-widget-status-dot ${r}`}),o&&e.jsx(ye,{trend:o})]}),d?e.jsx(we,{}):u?e.jsx(ke,{message:u}):e.jsxs(e.Fragment,{children:[void 0!==n&&e.jsxs("div",{className:x,children:[n,a&&e.jsx("span",{className:"mini-widget-unit",children:a})]}),i&&e.jsx("div",{className:"mini-widget-subtitle",children:i}),c]})]})}const _e={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Le={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 Se(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),n=t/100*(s.length-1),a=Math.floor(n),l=Math.ceil(n);return a===l?s[a]:s[a]+(s[l]-s[a])*(n-a)}function Ce(e){return Se(e,50)}const Re={lbtStats:null,noiseFloor:null,hourlyNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:Le,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Te=t.createContext(Re);function Be(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 Fe(e,t,s=2,n=!1){if(null===t)return"stable";const a=e-t;return(0!==t?100*Math.abs(a/t):Math.abs(a))0?"up":"down":a>0?"down":"up"}function Ae({children:s}){var n;const a=L(),l=w(),r=C(),i=R(),o=null===a,c=t.useMemo(()=>function(e){const t=Math.floor(Date.now()/1e3),s=t-86400,n=e.filter(e=>e.timestamp>=s&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),a=n.length,l=n.filter(e=>(e.lbt_attempts??0)>1).length,r=a>0?l/a*100:0,i=n.filter(e=>(e.lbt_attempts??0)>1),o=i.length>0?i.reduce((e,t)=>e+(t.lbt_attempts??0),0)/i.length:0,c=n.filter(e=>!0===e.lbt_channel_busy||1===e.lbt_channel_busy).length,d=a>0?c/a*100:0,u=[];for(const v of n){const e=Be(v.lbt_backoff_delays_ms);u.push(...e)}const m=u.reduce((e,t)=>e+t,0),h=u.length>0?m/u.length:0,x=u.length>0?Math.max(...u):0,p=[],f=[],g=[];for(let v=0;v<24;v++){const e=t-3600*(24-v),s=e+3600,a=n.filter(t=>t.timestamp>=e&&t.timestamp(e.lbt_attempts??0)>1).length,r=a.length>0?l/a.length*100:0;p.push(r);const i=[];for(const t of a){const e=Be(t.lbt_backoff_delays_ms);i.push(...e)}const o=i.length>0?i.reduce((e,t)=>e+t,0)/i.length:0;if(g.push(o),0===a.length)f.push(0);else{const e=a.filter(e=>!0===e.lbt_channel_busy||1===e.lbt_channel_busy).length,t=i.length>0?Math.max(...i):0,s=Math.min(a.length/5,1),n=.15,l=Math.log(1+r*n)/Math.log(1+100*n)*40,c=e/a.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;f.push(Math.min(h*s,85))}}return{totalPacketsWithLBT:a,packetsWithRetries:l,retryRate:r,avgRetries:o,channelBusyCount:c,channelBusyRate:d,avgBackoffMs:h,maxBackoffMs:x,totalBackoffMs:m,hourlyRetryRates:p,hourlyCollisionRisk:f,hourlyAvgBackoffMs:g,windowHours:24,packetCount:e.length}}(l),[l]),d=(null==a?void 0:a.noise_floor_dbm)??null,u=t.useMemo(()=>{var e;const t=null==(e=null==a?void 0:a.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(n=null==a?void 0:a.config)?void 0:n.radio]),[m,h]=t.useState([]),x=t.useRef(0);t.useEffect(()=>{const e=async()=>{var e;const t=Date.now();if(!(t-x.current<6e4)){x.current=t;try{const t=await T(24);if(t.success&&(null==(e=t.data)?void 0:e.history)){const e=Math.floor(Date.now()/1e3),s=[];for(let n=0;n<24;n++){const a=e-3600*(24-n),l=a+3600,r=t.data.history.filter(e=>e.timestamp>=a&&e.timestamp0){const e=r.reduce((e,t)=>e+t.noise_floor_dbm,0)/r.length;s.push(e)}else s.push(s.length>0?s[s.length-1]:-100)}h(s)}}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[]);const p=null==a?void 0:a.neighbors,f=t.useMemo(()=>{const e=p??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!i.has(e)))},[p,i]),g=t.useMemo(()=>r.filter(e=>!i.has(e.hash)),[r,i]),v=t.useMemo(()=>function(e){if(0===e.length)return{...Le,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),n=e.length>0?[e[e.length-1]]:[],a=e.slice(-4).filter(e=>Number.isFinite(e)),l=Ce(s),r=Se(s,10),i=Se(s,90),o=Ce(n),c=null!==o&&null!==r?o-r:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,n=0,a=0,l=0;const r=e[0].timestamp;for(const o of e){const e=(o.timestamp-r)/3600,t=o.value;s+=e,n+=t,a+=e*t,l+=e*e}const i=t*l-s*s;return Math.abs(i)<1e-4?0:(t*a-s*n)/i}(a.map((e,s)=>({timestamp:t-3600*(a.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)}(a),m=s.length>=12,[h,x]=m?function(e,t,s){const n=_e;return e>=n.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=n.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=n.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=n.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=n.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=n.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:r,baselineP90:i,currentMedian:o,currentSampleCount:n.length,delta:c,slope:d,jitter:u,penalty:h,penaltyReason:x,computedAt:t,isReliable:m}}(m),[m]),j=t.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const n=e.map(e=>{const n=function(e,t,s){const n=Y(e,t,s,0);if(n)switch(n.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const a=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*a+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),a=t[e.hash];return{name:(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:n,advertCount:e.count}});n.sort((e,t)=>t.score-e.score);const a=n.length>0?n.reduce((e,t)=>e+t.score,0)/n.length:0;return{neighbors:n,networkScore:Math.round(a),neighborCount:n.length,bestLink:n.length>0?{name:n[0].name,score:n[0].score}:null,worstLink:n.length>0?{name:n[n.length-1].name,score:n[n.length-1].score}:null}}(g,f,u),[g,f,u]),b=t.useMemo(()=>function(e,t,s){const n=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let a=50;null!==t&&(a=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,r=Math.round(.35*n+.25*a+.4*l);let i;return i=r>=85?"excellent":r>=70?"good":r>=50?"fair":r>=30?"congested":"critical",{score:r,status:i,components:{lbtHealth:Math.round(n),noiseHealth:Math.round(a),linkHealth:Math.round(l)}}}(c,d,j),[c,d,j]),[N,y]=t.useState({noiseFloor:null,networkScore:null,channelHealth:null}),k=t.useRef(0);t.useEffect(()=>{const e=()=>{const e=Date.now();e-k.current>3e4&&(k.current=e,y({noiseFloor:d,networkScore:(null==j?void 0:j.networkScore)??null,channelHealth:(null==b?void 0:b.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[d,null==j?void 0:j.networkScore,null==b?void 0:b.score]);const M=t.useMemo(()=>({noiseFloor:{current:d,previous:N.noiseFloor,trend:null!==d?Fe(d,N.noiseFloor,2,!0):"stable"},networkScore:{current:(null==j?void 0:j.networkScore)??0,previous:N.networkScore,trend:Fe((null==j?void 0:j.networkScore)??0,N.networkScore,3,!1)},channelHealth:{current:(null==b?void 0:b.score)??0,previous:N.channelHealth,trend:Fe((null==b?void 0:b.score)??0,N.channelHealth,3,!1)}}),[d,null==j?void 0:j.networkScore,null==b?void 0:b.score,N]),_={lbtStats:c,noiseFloor:d,hourlyNoiseFloor:m,linkQuality:j,channelHealth:b,nfTrend:v,radioConfig:u,trends:M,stats:a,recentPackets:l,quickNeighbors:r,isLoading:o,error:null,refresh:async()=>{}};return e.jsx(Te.Provider,{value:_,children:s})}function Ie(){const e=t.useContext(Te);if(void 0===e)throw new Error("useLBTData must be used within an LBTDataProvider");return e}const Pe={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function De(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function $e(){const{lbtStats:n,isLoading:a,error:l}=Ie(),r=d(),i=(null==n?void 0:n.avgBackoffMs)??0,o=(null==n?void 0:n.retryRate)??0,c=n?(u=i)<100?"excellent":u<250?"good":u<500?"fair":u<1e3?"congested":"critical":"unknown";var u;const m=null==n?void 0:n.hourlyAvgBackoffMs,h=t.useMemo(()=>!m||m.length<2?[]:m.map(e=>({value:e})),[m]),x=Pe[c];return e.jsx(Me,{title:"LBT Backoff",icon:e.jsx(s,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:c,subtitle:n?De(i,o):void 0,isLoading:a,error:l,onClick:()=>r("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline",children:h.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:h,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:x,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Ee(){const{lbtStats:t,isLoading:s,error:n}=Ie(),a=d(),l=(null==t?void 0:t.channelBusyCount)??0,r=(null==t?void 0:t.totalPacketsWithLBT)??0,i=(null==t?void 0:t.channelBusyRate)??0,o=t?(c=i)<.5?"excellent":c<1?"good":c<2?"fair":c<5?"congested":"critical":"unknown";var c;return e.jsx(Me,{title:"Ch. Busy",icon:e.jsx(u,{className:"mini-widget-icon"}),value:l,status:o,subtitle:t?`${i.toFixed(2)}% of ${r} TX`:void 0,isLoading:s,error:n,onClick:()=>a("/packets")})}function He(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}const We={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function ze(){const{noiseFloor:s,hourlyNoiseFloor:n,trends:a,isLoading:l,error:r}=Ie(),i=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==a?void 0:a.noiseFloor.trend,d=t.useMemo(()=>!n||n.length<2?[]:n.map(e=>({value:e})),[n]),u=We[i];return e.jsx(Me,{title:"Noise Floor",icon:e.jsx(m,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:i,trend:c,subtitle:He(s),isLoading:l,error:r,children:e.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:u,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Oe(){const s=d(),n=C(),a=w(),l=L(),r=null===l,i=(null==l?void 0:l.local_hash)?S(l.local_hash):"",o=(null==l?void 0:l.neighbors)??{},{neighborHashes:c,neighborNames:u}=t.useMemo(()=>{const e=new Set,t=new Map;for(const s of n){e.add(s.hash);const n=o[s.hash],a=(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||s.prefix;t.set(s.hash,a)}return{neighborHashes:e,neighborNames:t}},[n,o]),m=t.useMemo(()=>{if(0===c.size||0===a.length||!i)return{champion:null,listener:null,loudest:null};const{scores:e}=oe(a,c,i),t=[];for(const[a,r]of e)0!==r.blendedScore&&t.push({...r,name:u.get(a)??S(a)});let s=null,n=null,l=null;for(const a of t)(!s||a.blendedScore>s.blendedScore)&&(s=a),(!n||a.listenerScore>n.listenerScore)&&(n=a),(!l||a.loudScore>l.loudScore)&&(l=a);return{champion:s,listener:n,loudest:l}},[a,c,i,u]),{champion:g,listener:v,loudest:j}=m,b=g||v||j?e.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[g&&e.jsx(B,{content:(N=g,e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",N.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",N.blendedScore,e.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",N.listenerScore,"/100 (",N.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",N.loudScore,"/100 (",N.loudCount," packets relayed)"]})]})]})),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(h,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:g.name}),e.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:g.blendedScore})]})}),v&&v.hash!==(null==g?void 0:g.hash)&&e.jsx(B,{content:(t=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",t.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",t.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:e.jsxs("div",{children:[t.listenerCount," packets where they heard your transmissions"]})})]}))(v),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(x,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:v.name}),e.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:v.blendedScore})]})}),j&&j.hash!==(null==g?void 0:g.hash)&&j.hash!==(null==v?void 0:v.hash)&&e.jsx(B,{content:(t=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",t.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",t.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:e.jsxs("div",{children:[t.loudCount," packets they relayed directly to you"]})})]}))(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:j.blendedScore})]})})]}):0===n.length?e.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var N;return e.jsx(Me,{title:"Link Leaders",icon:e.jsx(f,{className:"mini-widget-icon"}),isLoading:r,onClick:()=>s("/contacts"),children:b})}const Ge={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function Ke(){const{lbtStats:s,isLoading:n,error:a}=Ie(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:n,avgBackoffMs:a,maxBackoffMs:l}=e;if(0===n)return 0;const r=Math.min(n/10,1),i=Math.log(1+.15*t)/Math.log(16)*40,o=s/n*100,c=Math.min(.5*o,25);let d=0;a>100&&(d=Math.min(8*Math.log10(a/100),15));let u=0;l>500&&a>0&&l>2*a&&(u=Math.min((l-500)/200,5));const m=(i+c+d+u)*r;return Math.min(m,85)}(s):0,r=s?(i=l)<15?"excellent":i<30?"good":i<45?"fair":i<60?"congested":"critical":"unknown";var i;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.hourlyCollisionRisk,u=t.useMemo(()=>!d||d.length<2?[]:d.map(e=>({value:e})),[d]),m=Ge[r];return e.jsx(Me,{title:"Collision Risk",icon:e.jsx(g,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:r,subtitle:c,isLoading:n,error:a,children:e.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:m,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Je(){const[s,n]=t.useState(!1),[a]=t.useState(0),{stats:l,lbtStats:i,isLoading:o}=Ie(),c=t.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=t.useMemo(()=>{if(!i||0===i.totalPacketsWithLBT)return 100;const e=i.channelBusyCount,t=i.totalPacketsWithLBT;return(t-e)/t*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,p=d<99?`${d.toFixed(0)}% TX success`:((f=x)<1e3?`${Math.round(f)}ms`:f<6e4?`${(f/1e3).toFixed(1)}s`:`${(f/6e4).toFixed(1)}m`)+" remaining";var f;const g=c?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return e.jsx(Me,{title:"Duty Cycle",icon:e.jsx(r,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:p,isLoading:o,children:g})}function Ve(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx(W,{className:"h-3 w-16"})]}),e.jsx(W,{className:"h-7 w-12 mt-2"}),e.jsx(W,{className:"h-3 w-20 mt-2"})]})}function Ue(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,s)=>e.jsx(Ve,{},s))})}function qe({className:t="",isLoaded:s=!0}){return e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(v,{className:"w-4 h-4 text-accent-primary"}),e.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?e.jsx(Ae,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx($e,{}),e.jsx(Ke,{}),e.jsx(ze,{}),e.jsx(Je,{}),e.jsx(Ee,{}),e.jsx(Oe,{})]})}):e.jsx(Ue,{})]})}function Xe(){var s,a;const l=L(),i=F(),o=w(),c=A(),d=$(),u=E(),[m,h]=t.useState(4),x=P[m],p=null==(s=null==l?void 0:l.config)?void 0:s.radio,f=t.useMemo(()=>p?{sf:p.spreading_factor??10,bw:p.bandwidth??25e4,cr:p.coding_rate??5,preamble:p.preamble_length??8}:null,[p]),g=o.length,v=t.useMemo(()=>g?I(x.minutes,x.buckets,o,l):null,[g,x.minutes,x.buckets,f]),k=t.useMemo(()=>function(e,t){if(!(null==e?void 0:e.length))return[];const s=t>1440?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{hour:"2-digit",minute:"2-digit",hour12:!1};return e.map(e=>({time:new Date(1e3*e.start).toLocaleString([],s),received:e.count}))}(null==v?void 0:v.received,x.minutes),[null==v?void 0:v.received,x.minutes]),M=t.useMemo(()=>function(e){if(!e.length)return[0,"auto"];const t=e.map(e=>e.received),s=Math.min(...t),n=Math.max(...t);if(s===n)return[Math.max(0,s-1),n+1];const a=.1*(n-s);return[Math.max(0,Math.floor(s-a)),Math.ceil(n+a)]}(k),[k]),_=t.useMemo(()=>{return(e=k.length)<=12?0:e<=24?2:e<=48?5:e<=72?8:Math.floor(e/7);var e},[k.length]),S=t.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==v?void 0:v.received),s=e(null==v?void 0:v.forwarded),n=e(null==v?void 0:v.dropped),a=e(null==v?void 0:v.transmitted),l=((null==v?void 0:v.time_range_minutes)??x.minutes)/60;return{received:t,forwarded:s,dropped:n,transmitted:a,rxPerHour:l>0?Math.round(t/l):0,fwdPerHour:l>0?Math.round(s/l):0}},[v,x.minutes]),C=(null==l?void 0:l.uptime_seconds)?D(l.uptime_seconds):"0m",R=(null==l?void 0:l.node_name)??(null==(a=null==l?void 0:l.config)?void 0:a.node_name)??"Unknown Node";return i?e.jsxs(z,{className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-white/50",children:i}),e.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(O,{children:[e.jsx(G,{title:R,icon:e.jsx(j,{}),controls:e.jsx(X,{ranges:P,selectedIndex:m,onSelect:h})}),e.jsx(ce,{template:"hero",children:e.jsx(z,{isLoaded:c,skeletonType:"chart",children:c&&e.jsxs(e.Fragment,{children:[e.jsx(K,{icon:e.jsx(n,{}),title:"RECEIVED",badge:x.label,iconColor:"text-accent-success"}),e.jsx("div",{className:"type-hero font-semibold min-h-[3rem]",style:{color:d.received},children:S.received.toLocaleString()}),e.jsxs("div",{className:"type-body-sm text-text-secondary mt-1",children:[S.rxPerHour,"/hr rate"]}),e.jsx("div",{className:"mt-4",children:k.length>0?e.jsx(Z,{width:"100%",height:180,children:e.jsxs(se,{data:k,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gradient-received",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:d.received,stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:d.received,stopOpacity:0})]})}),e.jsx(ne,{strokeDasharray:"3 3",stroke:u.grid,vertical:!1}),e.jsx(ae,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:u.axisTick,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dy:8,interval:_,minTickGap:20}),e.jsx(le,{domain:M,axisLine:!1,tickLine:!1,tick:{fill:u.axisTick,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dx:-8,width:40}),e.jsx(re,{content:e.jsx(be,{color:d.received,labelKey:"time",unit:" packets"}),cursor:{stroke:u.cursor,strokeWidth:1}}),e.jsx(ie,{type:"stepAfter",dataKey:"received",stroke:d.received,fill:"url(#gradient-received)",strokeWidth:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:d.received},isAnimationActive:!1})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),e.jsxs(ce,{template:"compact",children:[e.jsx(he,{title:"FORWARDED",value:S.forwarded,subtitle:`${S.fwdPerHour}/hr rate`,color:"forwarded",buckets:null==v?void 0:v.forwarded,timeRangeLabel:x.label,icon:e.jsx(b,{className:"w-4 h-4"}),isLoaded:c}),e.jsx(he,{title:"DROPPED",value:S.dropped,subtitle:"Filtered or duplicate",color:"dropped",buckets:null==v?void 0:v.dropped,timeRangeLabel:x.label,icon:e.jsx(N,{className:"w-4 h-4"}),isLoaded:c}),e.jsx(ge,{stats:l,receivedBuckets:null==v?void 0:v.received,droppedBuckets:null==v?void 0:v.dropped,forwardedBuckets:null==v?void 0:v.forwarded,bucketDurationSeconds:null==v?void 0:v.bucket_duration_seconds,timeRangeLabel:x.label,isLoaded:c}),e.jsx(he,{title:"UPTIME",value:C,subtitle:"Since last restart",color:"neutral",icon:e.jsx(y,{className:"w-4 h-4"}),isLoaded:c})]}),e.jsx(qe,{isLoaded:c}),e.jsx(je,{}),l&&e.jsx(ce,{template:"auto",children:e.jsxs(z,{children:[e.jsx(K,{icon:e.jsx(r,{}),title:"Node Information",largeTitle:!0}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Node Name"}),e.jsx("p",{className:"type-body text-text-primary mt-1",children:R})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Version"}),e.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",l.version]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Core Version"}),e.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",l.core_version]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Local Hash"}),e.jsx("div",{className:"mt-1",children:l.local_hash?e.jsx(Q,{hash:l.local_hash,size:"sm"}):e.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),l.public_key&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[e.jsx("span",{className:"type-label text-text-muted",children:"Public Key"}),e.jsx("div",{className:"mt-1",children:e.jsx(Q,{hash:l.public_key,prefixLength:12,suffixLength:8})})]})]})})]})}export{Xe as default}; +import{j as e,r as t,T as s,y as n,z as a,A as l,p as r,D as i,g as o,E as c,x as d,H as u,I as m,J as h,K as x,O as p,Q as f,Z as g,U as v,V as j,W as b,Y as N,o as y}from"./vendor-react-O8XH9yVn.js";import{u as w,a as k,b as M,c as _,d as L,e as S,f as C,h as R,j as T,T as B,k as F,m as A,n as I,D as P,o as D}from"./index-DGrzd8xb.js";import{u as $,a as E}from"./useThemeColors-CD0TSU03.js";import{C as H,S as W,a as z,P as O,b as G,c as K}from"./PageLayout-DE5PEtD2.js";import{P as J,a as V,b as U,g as q}from"./PacketDetailModal-wjwmQ-9h.js";import{T as X}from"./TimeRangeSelector-9pGCd7oa.js";import{H as Q}from"./HashBadge-aS_UIcg2.js";import{s as Y}from"./SignalIndicator-BVAbF7xm.js";import{R as Z,L as ee,a as te,A as se,C as ne,X as ae,Y as le,T as re,b as ie}from"./recharts-BU7auunF.js";import{c as oe}from"./link-scoring-Bg3LiwiV.js";import{R as ce}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const de={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)"}},ue={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function me({buckets:s,colorType:n,height:a=64}){const l=de[n].barBase,r=t.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=s.length/60,t=e<=1?s:Array.from({length:60},(t,n)=>{var a,l;const r=s.slice(Math.floor(n*e),Math.floor((n+1)*e)),i=r.reduce((e,t)=>e+t.count,0),o=r.length?r.reduce((e,t)=>e+t.avg_snr,0)/r.length:0;return{bucket:n,start:(null==(a=r[0])?void 0:a.start)??0,end:(null==(l=r.at(-1))?void 0:l.end)??0,count:i,airtime_ms:r.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),n=Math.max(...t.map(e=>e.count),1);return t.map(e=>({height:e.count>0?Math.max(e.count/n*100,8):0,color:e.count>0?l:"transparent",count:e.count,snr:e.avg_snr}))},[s,l]);return(null==s?void 0:s.length)?e.jsx("div",{className:"w-full flex items-end gap-[1px]",style:{height:a},children:r.map((t,s)=>{var n;return e.jsx("div",{className:"flex-1 rounded-t-sm",style:{height:`${t.height}%`,backgroundColor:t.color,opacity:t.count>0?.8:.1,minHeight:t.count>0?"4px":"2px",maxWidth:"4px"},title:t.count>0?`${t.count} packets, SNR: ${null==(n=t.snr)?void 0:n.toFixed(1)}dB`:"No packets"},s)})}):e.jsx("div",{className:"w-full flex items-end justify-center gap-[2px] opacity-20",style:{height:a},children:e.jsx("span",{className:"type-data-xs text-text-muted",children:"No data"})})}function he({title:t,value:s,color:n="neutral",subtitle:a,buckets:l,timeRangeLabel:r,icon:i,size:o="md",isLoaded:c=!0}){const{barBase:d}=de[n],u="string"==typeof s?s:s.toLocaleString();return c?e.jsxs("div",{className:`data-card flex flex-col relative ${ue[o]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-text-secondary",children:i}),e.jsx("span",{className:"type-micro",children:t}),r&&e.jsx("span",{className:"pill-tag",children:r})]}),e.jsx("div",{className:"data-card-value",children:u}),e.jsx("div",{className:"flex-1 py-2 mt-2",children:l?e.jsx(me,{buckets:l,colorType:n,height:64}):e.jsx("div",{className:"w-full h-16 flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full",style:{backgroundColor:d,opacity:.15}})})}),e.jsx("div",{className:"type-label text-text-muted border-t border-border-subtle pt-3 mt-2",children:a??`Total ${t.toLowerCase()}`})]}):e.jsx("div",{className:`data-card flex flex-col relative ${ue[o]}`,children:e.jsx(H,{})})}const xe=.2;function pe(e,t=1){return Math.floor(5*t*e)}function fe(e){const t=Math.round(e/xe)*xe;return Math.max(0,Math.min(5,t))}function ge({stats:t,receivedBuckets:r,droppedBuckets:i,forwardedBuckets:o,bucketDurationSeconds:c,timeRangeLabel:d,isLoaded:u=!0}){var m,h,x,p;if(!u)return e.jsx("div",{className:"data-card flex flex-col relative",children:e.jsx(H,{})});const f=function(e,t,s,n,a){var l,r;const i=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=i(t),c=i(s),d=i(n),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==n?void 0:n.length)&&a)x=100*d/(n.length*a*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 p=(null==e?void 0:e.neighbors)??{},f=Object.values(p).filter(e=>e.zero_hop).length;let g=1;h<3?g-=xe:h>15?g+=.4:h>10&&(g+=xe),x>5&&(g+=xe),f>10&&(g+=xe);const v=fe(g),j=fe(.28*v),b=pe(v),N=pe(j),y=pe((null==(r=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:r.tx_delay_factor)??1);return{floodFactor:v,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b10?"text-accent-warning":"text-text-secondary"),children:[f.duplicateRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-text-muted",children:"TX Util"}),e.jsxs("span",{className:"tabular-nums text-text-secondary",children:[f.txUtilization.toFixed(2),"%"]})]})]}),e.jsx("div",{className:"type-label text-text-muted border-t border-border-subtle pt-3 mt-2 truncate",children:null!==g?e.jsxs("span",{children:["Current: ×",g.toFixed(1)," / ×",(null==v?void 0:v.toFixed(1))??"—"]}):e.jsx("span",{children:"Slot-aligned factors"})})]})}function ve(e){return(e.payload_type_name||q(e.payload_type??e.type)).toLowerCase().includes("advert")}function je(){const s=w(),n=k(),a=M(),l=_(),d=L(),[u,m]=t.useState(null),[h,x]=t.useState(null),p=t.useRef(0),f=t.useRef(0),g=t.useMemo(()=>[...s.length<=100?s:s.slice(-100)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0)),[s]),v=t.useMemo(()=>{const e=new Map;if(!(null==d?void 0:d.neighbors))return e;d.local_hash&&e.set(S(d.local_hash),d.local_hash);for(const t of Object.keys(d.neighbors)){const s=S(t);e.has(s)||e.set(s,t)}return e},[d]),j=t.useMemo(()=>g.slice(0,15).map(e=>{if(e.src_hash&&e.src_hash.length<=4){const t=v.get(e.src_hash.toUpperCase());if(t)return{...e,src_hash_full:t}}return e}),[g,v]);t.useEffect(()=>{var e;if(!g.length)return;const t=(null==(e=g[0])?void 0:e.timestamp)??0,s=t>f.current&&f.current>0;if(f.current=t,!s)return;const n=g.find(ve);if(!n||(n.timestamp??0)<=f.current)return;const a=requestAnimationFrame(()=>m(n.packet_hash)),l=setTimeout(()=>m(null),600);return()=>{cancelAnimationFrame(a),clearTimeout(l)}},[g]),t.useEffect(()=>{if(l>0&&l!==p.current&&g.length>0){p.current=l;const e=g.find(ve);if(e){const t=requestAnimationFrame(()=>m(e.packet_hash)),s=setTimeout(()=>m(null),600);return()=>{cancelAnimationFrame(t),clearTimeout(s)}}}},[l,g]);const b=()=>e.jsxs(e.Fragment,{children:[e.jsx(r,{className:"w-6 h-6 text-text-muted mx-auto mb-2"}),e.jsx("div",{className:"text-sm text-text-primary",children:"No packets received"}),e.jsx("div",{className:"text-xs text-text-muted",children:"Packets will appear here"})]});return e.jsxs("div",{className:"chart-container h-full flex flex-col",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(r,{className:"chart-title-icon"}),"Recent Packets"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[a&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{className:"w-2 h-2 fill-accent-success text-accent-success animate-pulse"}),e.jsx("span",{className:"type-data-xs text-text-muted",children:"LIVE"})]}),e.jsxs(o,{to:"/packets",className:"pill-subtle",children:["View all ",e.jsx(c,{className:"w-3 h-3"})]})]})]}),e.jsxs("div",{className:"sm:hidden flex items-center gap-1.5 px-3 py-1.5 border-b border-border-subtle/50 bg-bg-elevated/20",children:[e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-14 flex-shrink-0",children:"Dir"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-7 flex-shrink-0",children:"Time"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-9 flex-shrink-0",children:"Src"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-1 min-w-0",children:"Type"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-14 flex-shrink-0",children:"Route"}),e.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider w-12 flex-shrink-0",children:"Signal"})]}),e.jsx("div",{className:"hidden sm:block flex-1 overflow-hidden",children:e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elevated/95 backdrop-blur-sm",children:e.jsxs("tr",{className:"border-b border-border-subtle/50",children:[e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider w-16",children:"Dir"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Time"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Source"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Type"}),e.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Route"}),e.jsx("th",{className:"text-right py-1.5 px-3 pr-4 text-[9px] font-semibold text-text-muted uppercase tracking-wider",children:"Signal"})]})}),e.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:n&&0===g.length?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-8 text-text-muted",children:"Loading packets..."})}):0===j.length?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"text-center py-8",children:b()})}):j.map((t,s)=>e.jsx(J,{packet:t,onClick:x,isFlashing:ve(t)&&u===t.packet_hash},`${t.packet_hash}_${t.timestamp}_${s}`))})]})})}),e.jsx("div",{className:"sm:hidden flex-1 overflow-y-auto divide-y divide-border-subtle/30",children:n&&0===g.length?e.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===j.length?e.jsx("div",{className:"p-8 text-center",children:b()}):j.map((t,s)=>e.jsx(V,{packet:t,onClick:x,isFlashing:ve(t)&&u===t.packet_hash},`${t.packet_hash}_${t.timestamp}_${s}`))}),e.jsxs("div",{className:"px-3 py-1.5 border-t border-border-subtle/50 text-[10px] text-text-muted bg-bg-elevated/20 text-center",children:["Showing ",j.length," of ",g.length," packets"]}),h&&e.jsx(U,{packet:h,onClose:()=>x(null)})]})}t.memo(function({active:t,payload:s,label:n,formatValue:a,labelKey:l}){var r;if(!t||!(null==s?void 0:s.length))return null;const i=l&&(null==(r=s[0])?void 0:r.payload)?s[0].payload[l]:n;return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[i&&e.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:i}),e.jsx("div",{className:"space-y-1.5",children:s.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:t.color}}),e.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:t.name}),e.jsx("span",{className:"type-data-sm text-white tabular-nums",children:a?a(t.value,t.name):t.value.toLocaleString()})]},s))})]})});const be=t.memo(function({active:t,payload:s,color:n,labelKey:a,unit:l=""}){var r,i;if(!t||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(r=null==o?void 0:o.payload)?void 0:r[a];return e.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[e.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:n}}),e.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(i=null==o?void 0:o.value)?void 0:i.toLocaleString(),l]})]})]})});t.memo(function({payload:t}){return(null==t?void 0:t.length)?e.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:t.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.color}}),e.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:t.value})]},s))}):null});const Ne={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function ye({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Ne[t]})})})}function we(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function ke({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function Me({title:t,icon:s,value:n,unit:a,valueSize:l="md",status:r,subtitle:i,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(" "),p=["mini-widget",h&&"cursor-pointer",m].filter(Boolean).join(" ");return e.jsxs("div",{className:p,onClick:h,role:h?"button":void 0,children:[e.jsxs("div",{className:"mini-widget-header",children:[s,e.jsx("span",{className:"mini-widget-title",children:t}),r&&"unknown"!==r&&e.jsx("div",{className:`mini-widget-status-dot ${r}`}),o&&e.jsx(ye,{trend:o})]}),d?e.jsx(we,{}):u?e.jsx(ke,{message:u}):e.jsxs(e.Fragment,{children:[void 0!==n&&e.jsxs("div",{className:x,children:[n,a&&e.jsx("span",{className:"mini-widget-unit",children:a})]}),i&&e.jsx("div",{className:"mini-widget-subtitle",children:i}),c]})]})}const _e={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Le={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 Se(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),n=t/100*(s.length-1),a=Math.floor(n),l=Math.ceil(n);return a===l?s[a]:s[a]+(s[l]-s[a])*(n-a)}function Ce(e){return Se(e,50)}const Re={lbtStats:null,noiseFloor:null,hourlyNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:Le,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Te=t.createContext(Re);function Be(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 Fe(e,t,s=2,n=!1){if(null===t)return"stable";const a=e-t;return(0!==t?100*Math.abs(a/t):Math.abs(a))0?"up":"down":a>0?"down":"up"}function Ae({children:s}){var n;const a=L(),l=w(),r=C(),i=R(),o=null===a,c=t.useMemo(()=>function(e){const t=Math.floor(Date.now()/1e3),s=t-86400,n=e.filter(e=>e.timestamp>=s&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),a=n.length,l=n.filter(e=>(e.lbt_attempts??0)>1).length,r=a>0?l/a*100:0,i=n.filter(e=>(e.lbt_attempts??0)>1),o=i.length>0?i.reduce((e,t)=>e+(t.lbt_attempts??0),0)/i.length:0,c=n.filter(e=>!0===e.lbt_channel_busy||1===e.lbt_channel_busy).length,d=a>0?c/a*100:0,u=[];for(const v of n){const e=Be(v.lbt_backoff_delays_ms);u.push(...e)}const m=u.reduce((e,t)=>e+t,0),h=u.length>0?m/u.length:0,x=u.length>0?Math.max(...u):0,p=[],f=[],g=[];for(let v=0;v<24;v++){const e=t-3600*(24-v),s=e+3600,a=n.filter(t=>t.timestamp>=e&&t.timestamp(e.lbt_attempts??0)>1).length,r=a.length>0?l/a.length*100:0;p.push(r);const i=[];for(const t of a){const e=Be(t.lbt_backoff_delays_ms);i.push(...e)}const o=i.length>0?i.reduce((e,t)=>e+t,0)/i.length:0;if(g.push(o),0===a.length)f.push(0);else{const e=a.filter(e=>!0===e.lbt_channel_busy||1===e.lbt_channel_busy).length,t=i.length>0?Math.max(...i):0,s=Math.min(a.length/5,1),n=.15,l=Math.log(1+r*n)/Math.log(1+100*n)*40,c=e/a.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;f.push(Math.min(h*s,85))}}return{totalPacketsWithLBT:a,packetsWithRetries:l,retryRate:r,avgRetries:o,channelBusyCount:c,channelBusyRate:d,avgBackoffMs:h,maxBackoffMs:x,totalBackoffMs:m,hourlyRetryRates:p,hourlyCollisionRisk:f,hourlyAvgBackoffMs:g,windowHours:24,packetCount:e.length}}(l),[l]),d=(null==a?void 0:a.noise_floor_dbm)??null,u=t.useMemo(()=>{var e;const t=null==(e=null==a?void 0:a.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(n=null==a?void 0:a.config)?void 0:n.radio]),[m,h]=t.useState([]),x=t.useRef(0);t.useEffect(()=>{const e=async()=>{var e;const t=Date.now();if(!(t-x.current<6e4)){x.current=t;try{const t=await T(24);if(t.success&&(null==(e=t.data)?void 0:e.history)){const e=Math.floor(Date.now()/1e3),s=[];for(let n=0;n<24;n++){const a=e-3600*(24-n),l=a+3600,r=t.data.history.filter(e=>e.timestamp>=a&&e.timestamp0){const e=r.reduce((e,t)=>e+t.noise_floor_dbm,0)/r.length;s.push(e)}else s.push(s.length>0?s[s.length-1]:-100)}h(s)}}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[]);const p=null==a?void 0:a.neighbors,f=t.useMemo(()=>{const e=p??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!i.has(e)))},[p,i]),g=t.useMemo(()=>r.filter(e=>!i.has(e.hash)),[r,i]),v=t.useMemo(()=>function(e){if(0===e.length)return{...Le,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),n=e.length>0?[e[e.length-1]]:[],a=e.slice(-4).filter(e=>Number.isFinite(e)),l=Ce(s),r=Se(s,10),i=Se(s,90),o=Ce(n),c=null!==o&&null!==r?o-r:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,n=0,a=0,l=0;const r=e[0].timestamp;for(const o of e){const e=(o.timestamp-r)/3600,t=o.value;s+=e,n+=t,a+=e*t,l+=e*e}const i=t*l-s*s;return Math.abs(i)<1e-4?0:(t*a-s*n)/i}(a.map((e,s)=>({timestamp:t-3600*(a.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)}(a),m=s.length>=12,[h,x]=m?function(e,t,s){const n=_e;return e>=n.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=n.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=n.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=n.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=n.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=n.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:r,baselineP90:i,currentMedian:o,currentSampleCount:n.length,delta:c,slope:d,jitter:u,penalty:h,penaltyReason:x,computedAt:t,isReliable:m}}(m),[m]),j=t.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const n=e.map(e=>{const n=function(e,t,s){const n=Y(e,t,s,0);if(n)switch(n.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const a=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*a+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),a=t[e.hash];return{name:(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:n,advertCount:e.count}});n.sort((e,t)=>t.score-e.score);const a=n.length>0?n.reduce((e,t)=>e+t.score,0)/n.length:0;return{neighbors:n,networkScore:Math.round(a),neighborCount:n.length,bestLink:n.length>0?{name:n[0].name,score:n[0].score}:null,worstLink:n.length>0?{name:n[n.length-1].name,score:n[n.length-1].score}:null}}(g,f,u),[g,f,u]),b=t.useMemo(()=>function(e,t,s){const n=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let a=50;null!==t&&(a=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,r=Math.round(.35*n+.25*a+.4*l);let i;return i=r>=85?"excellent":r>=70?"good":r>=50?"fair":r>=30?"congested":"critical",{score:r,status:i,components:{lbtHealth:Math.round(n),noiseHealth:Math.round(a),linkHealth:Math.round(l)}}}(c,d,j),[c,d,j]),[N,y]=t.useState({noiseFloor:null,networkScore:null,channelHealth:null}),k=t.useRef(0);t.useEffect(()=>{const e=()=>{const e=Date.now();e-k.current>3e4&&(k.current=e,y({noiseFloor:d,networkScore:(null==j?void 0:j.networkScore)??null,channelHealth:(null==b?void 0:b.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[d,null==j?void 0:j.networkScore,null==b?void 0:b.score]);const M=t.useMemo(()=>({noiseFloor:{current:d,previous:N.noiseFloor,trend:null!==d?Fe(d,N.noiseFloor,2,!0):"stable"},networkScore:{current:(null==j?void 0:j.networkScore)??0,previous:N.networkScore,trend:Fe((null==j?void 0:j.networkScore)??0,N.networkScore,3,!1)},channelHealth:{current:(null==b?void 0:b.score)??0,previous:N.channelHealth,trend:Fe((null==b?void 0:b.score)??0,N.channelHealth,3,!1)}}),[d,null==j?void 0:j.networkScore,null==b?void 0:b.score,N]),_={lbtStats:c,noiseFloor:d,hourlyNoiseFloor:m,linkQuality:j,channelHealth:b,nfTrend:v,radioConfig:u,trends:M,stats:a,recentPackets:l,quickNeighbors:r,isLoading:o,error:null,refresh:async()=>{}};return e.jsx(Te.Provider,{value:_,children:s})}function Ie(){const e=t.useContext(Te);if(void 0===e)throw new Error("useLBTData must be used within an LBTDataProvider");return e}const Pe={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function De(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function $e(){const{lbtStats:n,isLoading:a,error:l}=Ie(),r=d(),i=(null==n?void 0:n.avgBackoffMs)??0,o=(null==n?void 0:n.retryRate)??0,c=n?(u=i)<100?"excellent":u<250?"good":u<500?"fair":u<1e3?"congested":"critical":"unknown";var u;const m=null==n?void 0:n.hourlyAvgBackoffMs,h=t.useMemo(()=>!m||m.length<2?[]:m.map(e=>({value:e})),[m]),x=Pe[c];return e.jsx(Me,{title:"LBT Backoff",icon:e.jsx(s,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:c,subtitle:n?De(i,o):void 0,isLoading:a,error:l,onClick:()=>r("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline",children:h.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:h,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:x,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Ee(){const{lbtStats:t,isLoading:s,error:n}=Ie(),a=d(),l=(null==t?void 0:t.channelBusyCount)??0,r=(null==t?void 0:t.totalPacketsWithLBT)??0,i=(null==t?void 0:t.channelBusyRate)??0,o=t?(c=i)<.5?"excellent":c<1?"good":c<2?"fair":c<5?"congested":"critical":"unknown";var c;return e.jsx(Me,{title:"Ch. Busy",icon:e.jsx(u,{className:"mini-widget-icon"}),value:l,status:o,subtitle:t?`${i.toFixed(2)}% of ${r} TX`:void 0,isLoading:s,error:n,onClick:()=>a("/packets")})}function He(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}const We={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function ze(){const{noiseFloor:s,hourlyNoiseFloor:n,trends:a,isLoading:l,error:r}=Ie(),i=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==a?void 0:a.noiseFloor.trend,d=t.useMemo(()=>!n||n.length<2?[]:n.map(e=>({value:e})),[n]),u=We[i];return e.jsx(Me,{title:"Noise Floor",icon:e.jsx(m,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:i,trend:c,subtitle:He(s),isLoading:l,error:r,children:e.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:u,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Oe(){const s=d(),n=C(),a=w(),l=L(),r=null===l,i=(null==l?void 0:l.local_hash)?S(l.local_hash):"",o=(null==l?void 0:l.neighbors)??{},{neighborHashes:c,neighborNames:u}=t.useMemo(()=>{const e=new Set,t=new Map;for(const s of n){e.add(s.hash);const n=o[s.hash],a=(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||s.prefix;t.set(s.hash,a)}return{neighborHashes:e,neighborNames:t}},[n,o]),m=t.useMemo(()=>{if(0===c.size||0===a.length||!i)return{champion:null,listener:null,loudest:null};const{scores:e}=oe(a,c,i),t=[];for(const[a,r]of e)0!==r.blendedScore&&t.push({...r,name:u.get(a)??S(a)});let s=null,n=null,l=null;for(const a of t)(!s||a.blendedScore>s.blendedScore)&&(s=a),(!n||a.listenerScore>n.listenerScore)&&(n=a),(!l||a.loudScore>l.loudScore)&&(l=a);return{champion:s,listener:n,loudest:l}},[a,c,i,u]),{champion:g,listener:v,loudest:j}=m,b=g||v||j?e.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[g&&e.jsx(B,{content:(N=g,e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",N.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",N.blendedScore,e.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",N.listenerScore,"/100 (",N.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",N.loudScore,"/100 (",N.loudCount," packets relayed)"]})]})]})),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(h,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:g.name}),e.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:g.blendedScore})]})}),v&&v.hash!==(null==g?void 0:g.hash)&&e.jsx(B,{content:(t=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",t.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",t.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:e.jsxs("div",{children:[t.listenerCount," packets where they heard your transmissions"]})})]}))(v),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(x,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:v.name}),e.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:v.blendedScore})]})}),j&&j.hash!==(null==g?void 0:g.hash)&&j.hash!==(null==v?void 0:v.hash)&&e.jsx(B,{content:(t=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",t.name]}),e.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",t.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:e.jsxs("div",{children:[t.loudCount," packets they relayed directly to you"]})})]}))(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[e.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),e.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:j.blendedScore})]})})]}):0===n.length?e.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var N;return e.jsx(Me,{title:"Link Leaders",icon:e.jsx(f,{className:"mini-widget-icon"}),isLoading:r,onClick:()=>s("/contacts"),children:b})}const Ge={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",congested:"var(--signal-poor)",critical:"var(--signal-critical)",unknown:"var(--text-muted)"};function Ke(){const{lbtStats:s,isLoading:n,error:a}=Ie(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:n,avgBackoffMs:a,maxBackoffMs:l}=e;if(0===n)return 0;const r=Math.min(n/10,1),i=Math.log(1+.15*t)/Math.log(16)*40,o=s/n*100,c=Math.min(.5*o,25);let d=0;a>100&&(d=Math.min(8*Math.log10(a/100),15));let u=0;l>500&&a>0&&l>2*a&&(u=Math.min((l-500)/200,5));const m=(i+c+d+u)*r;return Math.min(m,85)}(s):0,r=s?(i=l)<15?"excellent":i<30?"good":i<45?"fair":i<60?"congested":"critical":"unknown";var i;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.hourlyCollisionRisk,u=t.useMemo(()=>!d||d.length<2?[]:d.map(e=>({value:e})),[d]),m=Ge[r];return e.jsx(Me,{title:"Collision Risk",icon:e.jsx(g,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:r,subtitle:c,isLoading:n,error:a,children:e.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?e.jsx(Z,{width:"100%",height:24,children:e.jsx(ee,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:e.jsx(te,{type:"monotone",dataKey:"value",stroke:m,strokeWidth:1,dot:!1,isAnimationActive:!1})})}):e.jsx("div",{className:"h-full"})})})}function Je(){const[s,n]=t.useState(!1),[a]=t.useState(0),{stats:l,lbtStats:i,isLoading:o}=Ie(),c=t.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=t.useMemo(()=>{if(!i||0===i.totalPacketsWithLBT)return 100;const e=i.channelBusyCount,t=i.totalPacketsWithLBT;return(t-e)/t*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,p=d<99?`${d.toFixed(0)}% TX success`:((f=x)<1e3?`${Math.round(f)}ms`:f<6e4?`${(f/1e3).toFixed(1)}s`:`${(f/6e4).toFixed(1)}m`)+" remaining";var f;const g=c?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return e.jsx(Me,{title:"Duty Cycle",icon:e.jsx(r,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:p,isLoading:o,children:g})}function Ve(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx(W,{className:"h-3 w-16"})]}),e.jsx(W,{className:"h-7 w-12 mt-2"}),e.jsx(W,{className:"h-3 w-20 mt-2"})]})}function Ue(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,s)=>e.jsx(Ve,{},s))})}function qe({className:t="",isLoaded:s=!0}){return e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(v,{className:"w-4 h-4 text-accent-primary"}),e.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?e.jsx(Ae,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx($e,{}),e.jsx(Ke,{}),e.jsx(ze,{}),e.jsx(Je,{}),e.jsx(Ee,{}),e.jsx(Oe,{})]})}):e.jsx(Ue,{})]})}function Xe(){var s,a;const l=L(),i=F(),o=w(),c=A(),d=$(),u=E(),[m,h]=t.useState(4),x=P[m],p=null==(s=null==l?void 0:l.config)?void 0:s.radio,f=t.useMemo(()=>p?{sf:p.spreading_factor??10,bw:p.bandwidth??25e4,cr:p.coding_rate??5,preamble:p.preamble_length??8}:null,[p]),g=o.length,v=t.useMemo(()=>g?I(x.minutes,x.buckets,o,l):null,[g,x.minutes,x.buckets,f]),k=t.useMemo(()=>function(e,t){if(!(null==e?void 0:e.length))return[];const s=t>1440?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{hour:"2-digit",minute:"2-digit",hour12:!1};return e.map(e=>({time:new Date(1e3*e.start).toLocaleString([],s),received:e.count}))}(null==v?void 0:v.received,x.minutes),[null==v?void 0:v.received,x.minutes]),M=t.useMemo(()=>function(e){if(!e.length)return[0,"auto"];const t=e.map(e=>e.received),s=Math.min(...t),n=Math.max(...t);if(s===n)return[Math.max(0,s-1),n+1];const a=.1*(n-s);return[Math.max(0,Math.floor(s-a)),Math.ceil(n+a)]}(k),[k]),_=t.useMemo(()=>{return(e=k.length)<=12?0:e<=24?2:e<=48?5:e<=72?8:Math.floor(e/7);var e},[k.length]),S=t.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==v?void 0:v.received),s=e(null==v?void 0:v.forwarded),n=e(null==v?void 0:v.dropped),a=e(null==v?void 0:v.transmitted),l=((null==v?void 0:v.time_range_minutes)??x.minutes)/60;return{received:t,forwarded:s,dropped:n,transmitted:a,rxPerHour:l>0?Math.round(t/l):0,fwdPerHour:l>0?Math.round(s/l):0}},[v,x.minutes]),C=(null==l?void 0:l.uptime_seconds)?D(l.uptime_seconds):"0m",R=(null==l?void 0:l.node_name)??(null==(a=null==l?void 0:l.config)?void 0:a.node_name)??"Unknown Node";return i?e.jsxs(z,{className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-white/50",children:i}),e.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(O,{children:[e.jsx(G,{title:R,icon:e.jsx(j,{}),controls:e.jsx(X,{ranges:P,selectedIndex:m,onSelect:h})}),e.jsx(ce,{template:"hero",children:e.jsx(z,{isLoaded:c,skeletonType:"chart",children:c&&e.jsxs(e.Fragment,{children:[e.jsx(K,{icon:e.jsx(n,{}),title:"RECEIVED",badge:x.label,iconColor:"text-accent-success"}),e.jsx("div",{className:"type-hero font-semibold min-h-[3rem]",style:{color:d.received},children:S.received.toLocaleString()}),e.jsxs("div",{className:"type-body-sm text-text-secondary mt-1",children:[S.rxPerHour,"/hr rate"]}),e.jsx("div",{className:"mt-4",children:k.length>0?e.jsx(Z,{width:"100%",height:180,children:e.jsxs(se,{data:k,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gradient-received",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:d.received,stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:d.received,stopOpacity:0})]})}),e.jsx(ne,{strokeDasharray:"3 3",stroke:u.grid,vertical:!1}),e.jsx(ae,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:u.axisTick,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dy:8,interval:_,minTickGap:20}),e.jsx(le,{domain:M,axisLine:!1,tickLine:!1,tick:{fill:u.axisTick,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dx:-8,width:40}),e.jsx(re,{content:e.jsx(be,{color:d.received,labelKey:"time",unit:" packets"}),cursor:{stroke:u.cursor,strokeWidth:1}}),e.jsx(ie,{type:"stepAfter",dataKey:"received",stroke:d.received,fill:"url(#gradient-received)",strokeWidth:1,dot:!1,activeDot:{r:4,strokeWidth:0,fill:d.received},isAnimationActive:!1})]})}):e.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),e.jsxs(ce,{template:"compact",children:[e.jsx(he,{title:"FORWARDED",value:S.forwarded,subtitle:`${S.fwdPerHour}/hr rate`,color:"forwarded",buckets:null==v?void 0:v.forwarded,timeRangeLabel:x.label,icon:e.jsx(b,{className:"w-4 h-4"}),isLoaded:c}),e.jsx(he,{title:"DROPPED",value:S.dropped,subtitle:"Filtered or duplicate",color:"dropped",buckets:null==v?void 0:v.dropped,timeRangeLabel:x.label,icon:e.jsx(N,{className:"w-4 h-4"}),isLoaded:c}),e.jsx(ge,{stats:l,receivedBuckets:null==v?void 0:v.received,droppedBuckets:null==v?void 0:v.dropped,forwardedBuckets:null==v?void 0:v.forwarded,bucketDurationSeconds:null==v?void 0:v.bucket_duration_seconds,timeRangeLabel:x.label,isLoaded:c}),e.jsx(he,{title:"UPTIME",value:C,subtitle:"Since last restart",color:"neutral",icon:e.jsx(y,{className:"w-4 h-4"}),isLoaded:c})]}),e.jsx(qe,{isLoaded:c}),e.jsx(je,{}),l&&e.jsx(ce,{template:"auto",children:e.jsxs(z,{children:[e.jsx(K,{icon:e.jsx(r,{}),title:"Node Information",largeTitle:!0}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Node Name"}),e.jsx("p",{className:"type-body text-text-primary mt-1",children:R})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Version"}),e.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",l.version]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Core Version"}),e.jsxs("p",{className:"type-data text-text-primary mt-1",children:["v",l.core_version]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"type-label text-text-muted",children:"Local Hash"}),e.jsx("div",{className:"mt-1",children:l.local_hash?e.jsx(Q,{hash:l.local_hash,size:"sm"}):e.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),l.public_key&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[e.jsx("span",{className:"type-label text-text-muted",children:"Public Key"}),e.jsx("div",{className:"mt-1",children:e.jsx(Q,{hash:l.public_key,prefixLength:12,suffixLength:8})})]})]})})]})}export{Xe as default}; diff --git a/frontend/dist/assets/Login-BF2bENkR.js b/frontend/dist/assets/Login-Cn28b737.js similarity index 99% rename from frontend/dist/assets/Login-BF2bENkR.js rename to frontend/dist/assets/Login-Cn28b737.js index 11b5418d..8ba54cc3 100644 --- a/frontend/dist/assets/Login-BF2bENkR.js +++ b/frontend/dist/assets/Login-Cn28b737.js @@ -1 +1 @@ -import{r as e,j as s,x as t}from"./vendor-react-O8XH9yVn.js";import{g as r,i as a,P as n,s as l,l as o}from"./index-Dp0UlTio.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./recharts-BU7auunF.js";const i=e.memo(function({width:e,height:t,className:r="",fill:a="currentColor"}){return s.jsxs("svg",{viewBox:"0 0 134 15",width:e,height:t,className:r,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"})]})}),c="/assets/WCM_Waves-RN-_ocPH.gif",d="#9cf15b";function m(){const m=t(),[x,p]=e.useState("admin"),[h,u]=e.useState(""),[f,C]=e.useState(()=>r()),[b,g]=e.useState(!1),[j,L]=e.useState(null);e.useEffect(()=>{a()&&m("/",{replace:!0})},[m]);const y=async e=>{e.preventDefault(),g(!0),L(null);const s=await o(x,h,f);g(!1),s.success?window.location.href="/":L(s.error||"Login failed")};return s.jsxs("div",{className:"min-h-screen min-h-[100dvh] flex flex-col bg-black",children:[s.jsx("div",{className:"fixed inset-0 -z-20 bg-cover bg-center bg-no-repeat",style:{backgroundImage:"url(/assets/water.webp)"},"aria-hidden":"true"}),s.jsx("div",{className:"fixed inset-0 -z-10 bg-black/40 pointer-events-none","aria-hidden":"true"}),s.jsx("div",{className:"fixed inset-0 bg-gradient-to-br from-[#9cf15b]/5 via-transparent to-[#9cf15b]/3 pointer-events-none z-0"}),s.jsx("div",{className:"flex-1 flex items-center justify-center px-4 py-6 sm:px-6 sm:py-8",children:s.jsxs("div",{className:"w-full max-w-sm sm:max-w-md",children:[s.jsxs("div",{className:"text-center mb-6 sm:mb-8",children:[s.jsx("h1",{className:"sr-only",children:"pyMC Console"}),s.jsx(n,{height:28,className:"mx-auto mb-2 sm:mb-3 sm:h-8"}),s.jsxs("p",{className:"font-mono text-text-muted text-xs sm:text-sm flex items-center justify-center gap-1.5 sm:gap-2",children:[s.jsx(i,{height:10,fill:"#6B7280",className:"sm:h-3"}),s.jsx("span",{children:"Network Management"})]})]}),s.jsxs("div",{className:"glass-card p-5 sm:p-8 rounded-xl sm:rounded-2xl border border-border-subtle bg-bg-surface/80 backdrop-blur-xl shadow-2xl",children:[s.jsxs("div",{className:"text-center mb-5 sm:mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 sm:w-16 sm:h-16 rounded-full bg-accent-primary/10 mb-3 sm:mb-4",children:s.jsx("svg",{className:"w-6 h-6 sm:w-8 sm:h-8 text-accent-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),s.jsx("h2",{className:"font-display text-lg sm:text-xl font-semibold text-text-primary",children:"Authentication Required"}),s.jsx("p",{className:"font-mono text-text-muted text-xs sm:text-sm mt-1",children:"Sign in to access the console"})]}),s.jsxs("form",{onSubmit:y,className:"space-y-4 sm:space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block font-display text-sm font-medium text-text-secondary mb-1.5 sm:mb-2",children:"Username"}),s.jsx("input",{id:"username",type:"text",value:x,onChange:e=>{p(e.target.value),j&&L(null)},className:"w-full px-3 sm:px-4 py-2.5 sm:py-3 rounded-lg bg-bg-elevated border border-border-subtle \n font-mono text-sm sm:text-base text-text-primary placeholder-text-muted\n focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary\n transition-all duration-200",placeholder:"admin",autoComplete:"username",autoFocus:!0,required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block font-display text-sm font-medium text-text-secondary mb-1.5 sm:mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",value:h,onChange:e=>{u(e.target.value),j&&L(null)},onKeyDown:e=>{"Enter"===e.key&&x&&h&&!b&&(e.preventDefault(),y(e))},className:"w-full px-3 sm:px-4 py-2.5 sm:py-3 rounded-lg bg-bg-elevated border border-border-subtle \n font-mono text-sm sm:text-base text-text-primary placeholder-text-muted\n focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary\n transition-all duration-200",placeholder:"••••••••",autoComplete:"current-password",required:!0})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("input",{id:"remember-me",type:"checkbox",checked:f,onChange:e=>{return s=e.target.checked,C(s),void l(s);var s},className:"w-4 h-4 mt-0.5 rounded border-border-subtle bg-bg-elevated text-accent-primary \n focus:ring-2 focus:ring-accent-primary/50 focus:ring-offset-0\n cursor-pointer transition-colors"}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"remember-me",className:"text-sm text-text-secondary cursor-pointer select-none",children:"Keep me signed in"}),s.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Stay logged in after closing browser"})]})]}),j&&s.jsx("div",{className:"p-2.5 sm:p-3 rounded-lg bg-accent-danger/10 border border-accent-danger/30",children:s.jsxs("p",{className:"font-mono text-xs sm:text-sm text-accent-danger flex items-center gap-2",children:[s.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),j]})}),s.jsx("button",{type:"submit",disabled:b||!x||!h,className:"w-full py-2.5 sm:py-3 px-4 rounded-lg font-display font-semibold text-sm sm:text-base text-bg-body\n bg-gradient-to-r from-[#9cf15b] to-[#8de04a]\n hover:from-[#8de04a] hover:to-[#7dd03a]\n focus:outline-none focus:ring-2 focus:ring-[#9cf15b]/50 focus:ring-offset-2 focus:ring-offset-bg-surface\n disabled:opacity-50 disabled:cursor-not-allowed\n transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98]",children:b?s.jsxs("span",{className:"flex items-center justify-center gap-2",children:[s.jsxs("svg",{className:"animate-spin h-4 w-4 sm:h-5 sm:w-5",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),s.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"})]}),"Authenticating..."]}):"Sign In"})]})]}),s.jsx("div",{className:"mt-5 sm:mt-8 text-center",children:s.jsxs("p",{className:"font-mono text-xs sm:text-sm text-text-muted",children:["A ",s.jsx("span",{style:{color:d},children:"@RightUp"})," X ",s.jsx("span",{style:{color:d},children:"@Treehouse⚡"})," Collab"]})})]})}),s.jsx("footer",{className:"py-4 sm:py-6 md:py-8 px-4",children:s.jsxs("div",{className:"max-w-sm sm:max-w-md mx-auto",children:[s.jsx("p",{className:"font-mono text-[10px] sm:text-xs text-text-muted text-center mb-2 sm:mb-3 uppercase tracking-wider",children:"Powered By"}),s.jsxs("div",{className:"glass-card p-3 sm:p-4 rounded-lg sm:rounded-xl border border-border-subtle bg-bg-surface/60 backdrop-blur-xl",children:[s.jsxs("div",{className:"hidden sm:flex items-center justify-center gap-4 sm:gap-6",children:[s.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 hover:opacity-80 transition-opacity group",title:"pyMC Repeater",children:s.jsxs("span",{className:"font-display font-bold text-base sm:text-lg tracking-tight",children:[s.jsx("span",{style:{color:d},children:"py"}),s.jsx("span",{className:"text-text-primary",children:"MC"})]})}),s.jsx("span",{className:"text-border-subtle",children:"•"}),s.jsx("a",{href:"https://meshcore.co.uk",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity group",title:"MeshCore",children:s.jsx(i,{height:12,className:"text-text-primary sm:h-3.5"})}),s.jsx("span",{className:"text-border-subtle",children:"•"}),s.jsxs("a",{href:"https://wcmesh.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 sm:gap-2 hover:opacity-80 transition-opacity group",title:"West Coast Mesh",children:[s.jsx("div",{className:"w-7 h-7 sm:w-9 sm:h-9 rounded-md sm:rounded-lg overflow-hidden border border-white/10 group-hover:border-white/20 transition-all",children:s.jsx("img",{src:c,alt:"West Coast Mesh",className:"w-full h-full object-cover"})}),s.jsx("span",{className:"font-display font-bold text-base sm:text-lg tracking-tight text-text-primary",children:"WCM"})]})]}),s.jsxs("div",{className:"flex sm:hidden items-center justify-center gap-3",children:[s.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity",title:"pyMC Repeater",children:s.jsxs("span",{className:"font-display font-bold text-sm tracking-tight",children:[s.jsx("span",{style:{color:d},children:"py"}),s.jsx("span",{className:"text-text-primary",children:"MC"})]})}),s.jsx("span",{className:"text-border-subtle text-xs",children:"•"}),s.jsx("a",{href:"https://meshcore.co.uk",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity",title:"MeshCore",children:s.jsx(i,{height:10,className:"text-text-primary"})}),s.jsx("span",{className:"text-border-subtle text-xs",children:"•"}),s.jsxs("a",{href:"https://wcmesh.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 hover:opacity-80 transition-opacity",title:"West Coast Mesh",children:[s.jsx("div",{className:"w-6 h-6 rounded overflow-hidden border border-white/10",children:s.jsx("img",{src:c,alt:"West Coast Mesh",className:"w-full h-full object-cover"})}),s.jsx("span",{className:"font-display font-bold text-sm tracking-tight text-text-primary",children:"WCM"})]})]})]})]})})]})}export{m as default}; +import{r as e,j as s,x as t}from"./vendor-react-O8XH9yVn.js";import{g as r,i as a,P as n,s as l,l as o}from"./index-DGrzd8xb.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./recharts-BU7auunF.js";const i=e.memo(function({width:e,height:t,className:r="",fill:a="currentColor"}){return s.jsxs("svg",{viewBox:"0 0 134 15",width:e,height:t,className:r,role:"img","aria-label":"MeshCore",style:{fillRule:"evenodd",clipRule:"evenodd"},children:[s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"}),s.jsx("path",{fill:a,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"})]})}),c="/assets/WCM_Waves-RN-_ocPH.gif",d="#9cf15b";function m(){const m=t(),[x,p]=e.useState("admin"),[h,u]=e.useState(""),[f,C]=e.useState(()=>r()),[b,g]=e.useState(!1),[j,L]=e.useState(null);e.useEffect(()=>{a()&&m("/",{replace:!0})},[m]);const y=async e=>{e.preventDefault(),g(!0),L(null);const s=await o(x,h,f);g(!1),s.success?window.location.href="/":L(s.error||"Login failed")};return s.jsxs("div",{className:"min-h-screen min-h-[100dvh] flex flex-col bg-black",children:[s.jsx("div",{className:"fixed inset-0 -z-20 bg-cover bg-center bg-no-repeat",style:{backgroundImage:"url(/assets/water.webp)"},"aria-hidden":"true"}),s.jsx("div",{className:"fixed inset-0 -z-10 bg-black/40 pointer-events-none","aria-hidden":"true"}),s.jsx("div",{className:"fixed inset-0 bg-gradient-to-br from-[#9cf15b]/5 via-transparent to-[#9cf15b]/3 pointer-events-none z-0"}),s.jsx("div",{className:"flex-1 flex items-center justify-center px-4 py-6 sm:px-6 sm:py-8",children:s.jsxs("div",{className:"w-full max-w-sm sm:max-w-md",children:[s.jsxs("div",{className:"text-center mb-6 sm:mb-8",children:[s.jsx("h1",{className:"sr-only",children:"pyMC Console"}),s.jsx(n,{height:28,className:"mx-auto mb-2 sm:mb-3 sm:h-8"}),s.jsxs("p",{className:"font-mono text-text-muted text-xs sm:text-sm flex items-center justify-center gap-1.5 sm:gap-2",children:[s.jsx(i,{height:10,fill:"#6B7280",className:"sm:h-3"}),s.jsx("span",{children:"Network Management"})]})]}),s.jsxs("div",{className:"glass-card p-5 sm:p-8 rounded-xl sm:rounded-2xl border border-border-subtle bg-bg-surface/80 backdrop-blur-xl shadow-2xl",children:[s.jsxs("div",{className:"text-center mb-5 sm:mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 sm:w-16 sm:h-16 rounded-full bg-accent-primary/10 mb-3 sm:mb-4",children:s.jsx("svg",{className:"w-6 h-6 sm:w-8 sm:h-8 text-accent-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),s.jsx("h2",{className:"font-display text-lg sm:text-xl font-semibold text-text-primary",children:"Authentication Required"}),s.jsx("p",{className:"font-mono text-text-muted text-xs sm:text-sm mt-1",children:"Sign in to access the console"})]}),s.jsxs("form",{onSubmit:y,className:"space-y-4 sm:space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block font-display text-sm font-medium text-text-secondary mb-1.5 sm:mb-2",children:"Username"}),s.jsx("input",{id:"username",type:"text",value:x,onChange:e=>{p(e.target.value),j&&L(null)},className:"w-full px-3 sm:px-4 py-2.5 sm:py-3 rounded-lg bg-bg-elevated border border-border-subtle \n font-mono text-sm sm:text-base text-text-primary placeholder-text-muted\n focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary\n transition-all duration-200",placeholder:"admin",autoComplete:"username",autoFocus:!0,required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block font-display text-sm font-medium text-text-secondary mb-1.5 sm:mb-2",children:"Password"}),s.jsx("input",{id:"password",type:"password",value:h,onChange:e=>{u(e.target.value),j&&L(null)},onKeyDown:e=>{"Enter"===e.key&&x&&h&&!b&&(e.preventDefault(),y(e))},className:"w-full px-3 sm:px-4 py-2.5 sm:py-3 rounded-lg bg-bg-elevated border border-border-subtle \n font-mono text-sm sm:text-base text-text-primary placeholder-text-muted\n focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary\n transition-all duration-200",placeholder:"••••••••",autoComplete:"current-password",required:!0})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("input",{id:"remember-me",type:"checkbox",checked:f,onChange:e=>{return s=e.target.checked,C(s),void l(s);var s},className:"w-4 h-4 mt-0.5 rounded border-border-subtle bg-bg-elevated text-accent-primary \n focus:ring-2 focus:ring-accent-primary/50 focus:ring-offset-0\n cursor-pointer transition-colors"}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"remember-me",className:"text-sm text-text-secondary cursor-pointer select-none",children:"Keep me signed in"}),s.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Stay logged in after closing browser"})]})]}),j&&s.jsx("div",{className:"p-2.5 sm:p-3 rounded-lg bg-accent-danger/10 border border-accent-danger/30",children:s.jsxs("p",{className:"font-mono text-xs sm:text-sm text-accent-danger flex items-center gap-2",children:[s.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:s.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),j]})}),s.jsx("button",{type:"submit",disabled:b||!x||!h,className:"w-full py-2.5 sm:py-3 px-4 rounded-lg font-display font-semibold text-sm sm:text-base text-bg-body\n bg-gradient-to-r from-[#9cf15b] to-[#8de04a]\n hover:from-[#8de04a] hover:to-[#7dd03a]\n focus:outline-none focus:ring-2 focus:ring-[#9cf15b]/50 focus:ring-offset-2 focus:ring-offset-bg-surface\n disabled:opacity-50 disabled:cursor-not-allowed\n transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98]",children:b?s.jsxs("span",{className:"flex items-center justify-center gap-2",children:[s.jsxs("svg",{className:"animate-spin h-4 w-4 sm:h-5 sm:w-5",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),s.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"})]}),"Authenticating..."]}):"Sign In"})]})]}),s.jsx("div",{className:"mt-5 sm:mt-8 text-center",children:s.jsxs("p",{className:"font-mono text-xs sm:text-sm text-text-muted",children:["A ",s.jsx("span",{style:{color:d},children:"@RightUp"})," X ",s.jsx("span",{style:{color:d},children:"@Treehouse⚡"})," Collab"]})})]})}),s.jsx("footer",{className:"py-4 sm:py-6 md:py-8 px-4",children:s.jsxs("div",{className:"max-w-sm sm:max-w-md mx-auto",children:[s.jsx("p",{className:"font-mono text-[10px] sm:text-xs text-text-muted text-center mb-2 sm:mb-3 uppercase tracking-wider",children:"Powered By"}),s.jsxs("div",{className:"glass-card p-3 sm:p-4 rounded-lg sm:rounded-xl border border-border-subtle bg-bg-surface/60 backdrop-blur-xl",children:[s.jsxs("div",{className:"hidden sm:flex items-center justify-center gap-4 sm:gap-6",children:[s.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 hover:opacity-80 transition-opacity group",title:"pyMC Repeater",children:s.jsxs("span",{className:"font-display font-bold text-base sm:text-lg tracking-tight",children:[s.jsx("span",{style:{color:d},children:"py"}),s.jsx("span",{className:"text-text-primary",children:"MC"})]})}),s.jsx("span",{className:"text-border-subtle",children:"•"}),s.jsx("a",{href:"https://meshcore.co.uk",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity group",title:"MeshCore",children:s.jsx(i,{height:12,className:"text-text-primary sm:h-3.5"})}),s.jsx("span",{className:"text-border-subtle",children:"•"}),s.jsxs("a",{href:"https://wcmesh.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 sm:gap-2 hover:opacity-80 transition-opacity group",title:"West Coast Mesh",children:[s.jsx("div",{className:"w-7 h-7 sm:w-9 sm:h-9 rounded-md sm:rounded-lg overflow-hidden border border-white/10 group-hover:border-white/20 transition-all",children:s.jsx("img",{src:c,alt:"West Coast Mesh",className:"w-full h-full object-cover"})}),s.jsx("span",{className:"font-display font-bold text-base sm:text-lg tracking-tight text-text-primary",children:"WCM"})]})]}),s.jsxs("div",{className:"flex sm:hidden items-center justify-center gap-3",children:[s.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity",title:"pyMC Repeater",children:s.jsxs("span",{className:"font-display font-bold text-sm tracking-tight",children:[s.jsx("span",{style:{color:d},children:"py"}),s.jsx("span",{className:"text-text-primary",children:"MC"})]})}),s.jsx("span",{className:"text-border-subtle text-xs",children:"•"}),s.jsx("a",{href:"https://meshcore.co.uk",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center hover:opacity-80 transition-opacity",title:"MeshCore",children:s.jsx(i,{height:10,className:"text-text-primary"})}),s.jsx("span",{className:"text-border-subtle text-xs",children:"•"}),s.jsxs("a",{href:"https://wcmesh.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 hover:opacity-80 transition-opacity",title:"West Coast Mesh",children:[s.jsx("div",{className:"w-6 h-6 rounded overflow-hidden border border-white/10",children:s.jsx("img",{src:c,alt:"West Coast Mesh",className:"w-full h-full object-cover"})}),s.jsx("span",{className:"font-display font-bold text-sm tracking-tight text-text-primary",children:"WCM"})]})]})]})]})})]})}export{m as default}; diff --git a/frontend/dist/assets/Logs-l6s0ar29.js b/frontend/dist/assets/Logs-CYFnASCG.js similarity index 98% rename from frontend/dist/assets/Logs-l6s0ar29.js rename to frontend/dist/assets/Logs-CYFnASCG.js index 9dfd44e7..69a1883c 100644 --- a/frontend/dist/assets/Logs-l6s0ar29.js +++ b/frontend/dist/assets/Logs-CYFnASCG.js @@ -1 +1 @@ -import{j as e,D as s,a2 as t,F as a,r as l,aP as c,at as n,aW as i}from"./vendor-react-O8XH9yVn.js";import{c as r}from"./recharts-BU7auunF.js";import{a3 as o,a4 as x,b as m,a5 as d,p as u,a2 as p,a6 as h,a7 as j}from"./index-Dp0UlTio.js";import{u as g}from"./usePolling-UdPi_fKb.js";import{P as N,b as f,a as v,c as b,L as y}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const w=l.memo(function({log:s}){return e.jsx("div",{className:"p-3 rounded-2xl bg-white/[0.02] hover:bg-white/[0.04] 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",j(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 F(){const s=o(),[t,a]=l.useState("INFO"),[x,m]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{if(s.length>0){const e=s.some(e=>"DEBUG"===e.level);a(e?"DEBUG":"INFO")}},[s]);const p=l.useCallback(async e=>{if(e!==t&&!x){m(!0),u(null);try{const s=await h(e);s.success&&s.data?(a(e),u(s.data.message),setTimeout(()=>u(null),5e3)):(u(s.error??"Failed to change log level"),setTimeout(()=>u(null),3e3))}catch{u("Failed to change log level"),setTimeout(()=>u(null),3e3)}finally{m(!1)}}},[t,x]),j="h-[32px] px-4 rounded-full type-data flex items-center gap-2 transition-colors",g=x&&"opacity-50 cursor-not-allowed";return e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:d}),e.jsxs("div",{className:"flex bg-white/[0.02] rounded-full p-1",children:[e.jsxs("button",{onClick:()=>p("INFO"),disabled:x,className:r(j,"INFO"===t?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary",g),children:[e.jsx(c,{className:"w-4 h-4"}),"Info"]}),e.jsxs("button",{onClick:()=>p("DEBUG"),disabled:x,className:r(j,"DEBUG"===t?"bg-amber-500/20 text-amber-400":"text-text-muted hover:text-text-secondary",g),children:[x?e.jsx(n,{className:"w-4 h-4 animate-spin"}):e.jsx(i,{className:"w-4 h-4"}),"Debug"]})]})]})}function k(){const l=o(),c=x(),n=m(),i=d(),h=u();return g(i,p.logs,n),e.jsxs(N,{children:[e.jsx(f,{title:"System Logs",icon:e.jsx(a,{}),controls:e.jsxs(e.Fragment,{children:[e.jsx(F,{}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(s,{className:"w-2 h-2 fill-accent-success text-accent-success animate-pulse"}),e.jsx("span",{className:"text-text-muted",children:"Live"})]}),e.jsxs("button",{onClick:()=>h(!n),className:r("h-[32px] px-4 rounded-full type-data transition-colors","flex items-center gap-2",n?"bg-accent-success/20 text-accent-success":"bg-white/[0.02] text-text-muted hover:text-text-secondary"),children:[e.jsx(t,{className:r("w-4 h-4",n&&"animate-spin")}),e.jsx("span",{className:"hidden xs:inline",children:n?"Live":"Paused"})]})]})}),e.jsxs(v,{noPadding:!0,children:[e.jsx(b,{listHeader:!0,icon:e.jsx(a,{className:"icon-sm"}),title:"Log Entries"}),e.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:c&&0===l.length?e.jsx(y,{count:10}):0===l.length?e.jsx("div",{className:"text-center py-12 text-text-muted",children:"No logs available"}):l.map((s,t)=>e.jsx(w,{log:s},`${s.timestamp}-${t}`))})]})]})}export{k as default}; +import{j as e,D as s,a2 as t,F as a,r as l,aP as c,at as n,aW as i}from"./vendor-react-O8XH9yVn.js";import{c as r}from"./recharts-BU7auunF.js";import{a3 as o,a4 as x,b as m,a5 as d,p as u,a2 as p,a6 as h,a7 as j}from"./index-DGrzd8xb.js";import{u as g}from"./usePolling-UdPi_fKb.js";import{P as N,b as f,a as v,c as b,L as y}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const w=l.memo(function({log:s}){return e.jsx("div",{className:"p-3 rounded-2xl bg-white/[0.02] hover:bg-white/[0.04] 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",j(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 F(){const s=o(),[t,a]=l.useState("INFO"),[x,m]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{if(s.length>0){const e=s.some(e=>"DEBUG"===e.level);a(e?"DEBUG":"INFO")}},[s]);const p=l.useCallback(async e=>{if(e!==t&&!x){m(!0),u(null);try{const s=await h(e);s.success&&s.data?(a(e),u(s.data.message),setTimeout(()=>u(null),5e3)):(u(s.error??"Failed to change log level"),setTimeout(()=>u(null),3e3))}catch{u("Failed to change log level"),setTimeout(()=>u(null),3e3)}finally{m(!1)}}},[t,x]),j="h-[32px] px-4 rounded-full type-data flex items-center gap-2 transition-colors",g=x&&"opacity-50 cursor-not-allowed";return e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:d}),e.jsxs("div",{className:"flex bg-white/[0.02] rounded-full p-1",children:[e.jsxs("button",{onClick:()=>p("INFO"),disabled:x,className:r(j,"INFO"===t?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary",g),children:[e.jsx(c,{className:"w-4 h-4"}),"Info"]}),e.jsxs("button",{onClick:()=>p("DEBUG"),disabled:x,className:r(j,"DEBUG"===t?"bg-amber-500/20 text-amber-400":"text-text-muted hover:text-text-secondary",g),children:[x?e.jsx(n,{className:"w-4 h-4 animate-spin"}):e.jsx(i,{className:"w-4 h-4"}),"Debug"]})]})]})}function k(){const l=o(),c=x(),n=m(),i=d(),h=u();return g(i,p.logs,n),e.jsxs(N,{children:[e.jsx(f,{title:"System Logs",icon:e.jsx(a,{}),controls:e.jsxs(e.Fragment,{children:[e.jsx(F,{}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(s,{className:"w-2 h-2 fill-accent-success text-accent-success animate-pulse"}),e.jsx("span",{className:"text-text-muted",children:"Live"})]}),e.jsxs("button",{onClick:()=>h(!n),className:r("h-[32px] px-4 rounded-full type-data transition-colors","flex items-center gap-2",n?"bg-accent-success/20 text-accent-success":"bg-white/[0.02] text-text-muted hover:text-text-secondary"),children:[e.jsx(t,{className:r("w-4 h-4",n&&"animate-spin")}),e.jsx("span",{className:"hidden xs:inline",children:n?"Live":"Paused"})]})]})}),e.jsxs(v,{noPadding:!0,children:[e.jsx(b,{listHeader:!0,icon:e.jsx(a,{className:"icon-sm"}),title:"Log Entries"}),e.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:c&&0===l.length?e.jsx(y,{count:10}):0===l.length?e.jsx("div",{className:"text-center py-12 text-text-muted",children:"No logs available"}):l.map((s,t)=>e.jsx(w,{log:s},`${s.timestamp}-${t}`))})]})]})}export{k as default}; diff --git a/frontend/dist/assets/PacketDetailModal-CR1FHEH5.js b/frontend/dist/assets/PacketDetailModal-wjwmQ-9h.js similarity index 99% rename from frontend/dist/assets/PacketDetailModal-CR1FHEH5.js rename to frontend/dist/assets/PacketDetailModal-wjwmQ-9h.js index 3537364e..9a724d44 100644 --- a/frontend/dist/assets/PacketDetailModal-CR1FHEH5.js +++ b/frontend/dist/assets/PacketDetailModal-wjwmQ-9h.js @@ -1,2 +1,2 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-XwxmBUnL.js","assets/vendor-react-O8XH9yVn.js","assets/vendor-core-WoOfkQwm.js","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]); -import{r as e,_ as t,a3 as s,E as a,a4 as n,j as r,a5 as o,a6 as c,a7 as i,b as l,X as d,h as x,a8 as h,k as u,a9 as p,aa as m,$ as f}from"./vendor-react-O8XH9yVn.js";import{c as b}from"./recharts-BU7auunF.js";import{q as g,R as j,r as y,t as v,v as N,e as w,d as _,w as k,x as M,y as C,z as P}from"./index-Dp0UlTio.js";import{S as T,g as S}from"./SignalIndicator-BVAbF7xm.js";import{H as D}from"./HashBadge-aS_UIcg2.js";import{_ as E}from"./deckgl-DTsmDcfs.js";function L(e){return null==e?"UNKNOWN":g[e]||`TYPE_${e}`}function F(e){return null==e?"UNKNOWN":j[e]||`ROUTE_${e}`}function A(e){return{ADVERT:"text-[var(--pkt-advert)]",FLOOD:"text-[var(--pkt-flood)]",TXT_MSG:"text-[var(--pkt-txt-msg)]",ACK:"text-[var(--pkt-ack)]",TRACE:"text-[var(--pkt-trace)]",REQ:"text-[var(--pkt-req)]",RESPONSE:"text-[var(--pkt-response)]",GRP_TXT:"text-[var(--pkt-grp-txt)]",GRP_DATA:"text-[var(--pkt-grp-data)]",PATH:"text-[var(--pkt-path)]",ANON_REQ:"text-[var(--pkt-anon)]"}[e]||"text-[var(--pkt-unknown)]"}function O(e){return{FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30",TRANSPORT:"bg-[var(--route-transport)]/20 text-[var(--route-transport)] border-[var(--route-transport)]/30",T_FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",T_DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30"}[e]||"bg-bg-subtle text-text-muted border-border-subtle"}function R(e){return 1===e||!0===e}const z={rx:{icon:t,label:"RX",color:"text-accent-primary",bgColor:"bg-accent-primary/10"},tx:{icon:n,label:"TX",color:"text-[#F9D26F]",bgColor:"bg-[#F9D26F]/10"},forward:{icon:a,label:"FWD",color:"text-accent-success",bgColor:"bg-accent-success/10"},dropped:{icon:s,label:"DROP",color:"text-accent-danger",bgColor:"bg-accent-danger/10"},duplicate:{icon:t,label:"DUP",color:"text-text-muted",bgColor:"bg-white/5"}},U={sm:"w-3.5 h-3.5",md:"w-4 h-4"};function H(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 V=e.memo(function({packet:e,showLabel:t=!0,size:s="sm"}){const a=H(e),n=z[a],o=n.icon;return r.jsxs("div",{className:b("inline-flex items-center gap-1 rounded-md",t&&"px-1.5 py-0.5",t&&n.bgColor),children:[r.jsx(o,{className:b(U[s],n.color)}),t&&r.jsx("span",{className:b("text-[10px] font-semibold tracking-wide",n.color),children:n.label})]})});function $(e){return"tx_local"===e.packet_origin?"Transmitted":"tx_forward"===e.packet_origin||e.transmitted?"Forwarded":e.is_duplicate?"Duplicate":"No transport keys configured"===e.drop_reason?"Monitor Only":e.drop_reason?e.drop_reason:"Received"}function I(e){return z[H(e)].color}function q(e){return{payloadType:e.payload_type_name||L(e.payload_type??e.type),routeType:e.route_type_name||F(e.route_type??e.route)}}function X({packet:e,onClick:t,isFlashing:s=!1}){const{payloadType:a,routeType:n}=q(e);return r.jsxs("tr",{onClick:()=>t(e),className:b("cursor-pointer","hover:bg-bg-subtle",R(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:[r.jsx("td",{className:"py-2.5 px-3",children:r.jsx(V,{packet:e,showLabel:!0})}),r.jsx("td",{className:"py-2.5 px-3 text-xs font-mono text-text-secondary whitespace-nowrap",children:v(e.timestamp)}),r.jsx("td",{className:"py-2.5 px-3",children:e.src_hash?r.jsx(D,{hash:e.src_hash,copyValue:e.src_hash_full,size:"xs"}):r.jsx("span",{className:"text-xs text-text-muted",children:"—"})}),r.jsx("td",{className:"py-2.5 px-3",children:r.jsx("span",{className:b("text-xs font-semibold",A(a)),children:a})}),r.jsx("td",{className:"py-2.5 px-3",children:r.jsx("span",{className:b("px-1.5 py-0.5 rounded text-[10px] border font-medium",O(n)),children:n})}),r.jsx("td",{className:"py-2.5 px-3 pr-4",children:r.jsx("div",{className:"flex justify-end",children:r.jsx(T,{rssi:e.rssi,snr:e.snr,compact:!0,showValues:!0})})})]})}const G=e.memo(function(e){return r.jsx(X,{...e})}),W=e.memo(function({packet:e,onClick:t,isFlashing:s=!1}){const{payloadType:a,routeType:n}=q(e);return r.jsx("div",{onClick:()=>t(e),className:b("packet-row px-3 py-2.5 cursor-pointer","hover:bg-bg-subtle","active:bg-bg-elevated",R(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-14 flex-shrink-0",children:r.jsx(V,{packet:e,showLabel:!0,size:"sm"})}),r.jsx("span",{className:"text-[10px] font-mono text-text-muted w-7 flex-shrink-0",children:y(e.timestamp)}),r.jsx("div",{className:"w-9 flex-shrink-0",children:e.src_hash?r.jsx(D,{hash:e.src_hash,copyValue:e.src_hash_full,size:"xs"}):r.jsx("span",{className:"text-[10px] text-text-muted",children:"—"})}),r.jsx("span",{className:b("text-xs font-semibold truncate flex-1 min-w-0",A(a)),children:a}),r.jsx("div",{className:"w-14 flex-shrink-0",children:r.jsx("span",{className:b("px-1 py-0.5 rounded text-[9px] border font-medium",O(n)),children:n})}),r.jsx("div",{className:"w-12 flex-shrink-0 flex justify-end",children:r.jsx(T,{rssi:e.rssi,compact:!0,showValues:!0})})]})})});function K(e){if(e.contact_type){const t=e.contact_type.toLowerCase();if("repeater"===t||"rep"===t)return!0;if("companion"===t||"client"===t||"cli"===t)return!1;if("room server"===t||"room_server"===t||"room"===t||"server"===t)return!1}return!0===e.is_repeater||(e.is_repeater,!1)}const Q=e.lazy(()=>E(()=>import("./PathMapMapLibre-XwxmBUnL.js"),__vite__mapDeps([0,1,2,3])));function B(e){return`${(100*e).toFixed(0)}%`}function Y(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 J extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?r.jsxs("div",{className:"h-[200px] flex items-center justify-center text-text-muted",children:[r.jsx(i,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Z({path:t,neighbors:s,localNode:a,localHash:n,srcHash:i,dstHash:l,neighborAffinity:d,prefixLookup:x,hubNodes:h}){const[u,p]=e.useState(null),m=e.useMemo(()=>{if(!i)return null;const e=w(i),t=s[i];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:i,name:t.node_name||t.name||"Source",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isSource:!0};const a=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||i.slice(0,8);return{prefix:e,candidates:[{hash:i,name:a,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[i,s]),f=e.useMemo(()=>{if(!l)return null;const e=w(l);if(n&&l===n&&a){const t=0!==a.latitude||0!==a.longitude;return{prefix:e,candidates:[{hash:l,name:a.name||"Local Node",latitude:t?a.latitude:0,longitude:t?a.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const t=s[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||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const r=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||l.slice(0,8);return{prefix:e,candidates:[{hash:l,name:r,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[l,s,a,n]),g=e.useMemo(()=>function(e,t,s,a,n,r){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const o=e.length-1,c=e.map((c,i)=>{const l=i===o,d=e.length-i,{candidates:x,totalMatches:h}=function(e,t,s,a,n=!1,r,o,c){const i=function(e){const t={};for(const[s,a]of Object.entries(e))K(a)&&(t[s]=a);return t}(t);let l;if(o){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}}(o,e,{position:c,isLastHop:n});l=t.confidence}const{matches:d,probability:x}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),o=[],c=s&&N(r,s);c&&o.push(s);for(const u of Object.keys(t))N(r,u)&&o.push(u);if(n&&c&&s&&1===o.length)return{matches:o,probability:1,bestMatch:s};if(n&&c&&o.length>1){const e=o.filter(e=>e!==s);if(1===e.length)return{matches:o,probability:1,bestMatch:e[0]}}const i=o.length>0?1/o.length:0,l=[...o].sort();let d=null,x=-1;if(1===l.length)d=l[0];else if(l.length>1&&a){for(const e of l){const t=a.get(e),s=t?"number"==typeof t?t:t.combinedScore:0;s>x&&(x=s,d=e)}d||(d=l[0])}else l.length>0&&(d=l[0]);let h=i;if(o.length>1&&a&&x>0){let e=0;for(const t of o){const s=a.get(t);e+=s?"number"==typeof s?s:s.combinedScore:0}e>0&&(h=Math.min(.95,x/e))}return{matches:o,probability:h,bestMatch:d}}(e,i,a,r,n),h=d.length,u=[],p=e.toUpperCase(),m=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const b of d){if(a&&N(p,a)&&b===a&&m&&s){u.push({hash:b,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:x,isLocal:!0});continue}const e=i[b];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&u.push({hash:b,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:x,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const f=u.length;if(1===f)u[0].probability=l??1;else if(f>1)if(void 0!==l&&l>0){u[0].probability=l;const e=1-l,t=f-1;u.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=u.map(t=>{if(t.isLocal)return{candidate:t,score:1};const a=null==r?void 0:r.get(t.hash);let n=.5;var o;let c;return m&&s&&(n=(o=function(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,o=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(o),Math.sqrt(1-o))*6371e3}(s.latitude,s.longitude,t.latitude,t.longitude))<100?1:o<500?.9:o<1e3?.7:o<5e3?.5:o<1e4?.3:.1),a?c=.3*n+.3*a.hopConsistencyScore+.4*a.frequencyScore:(c=n,t.isDirectNeighbor&&(c=Math.max(c,.8))),e+=c,{candidate:t,score:c}});if(e>0)t.forEach(({candidate:t,score:s})=>{t.probability=Math.min(.95,s/e)});else{const e=1/f;u.forEach(t=>t.probability=e)}}return{candidates:u,totalMatches:h}}(c,t,s,a,l,n,r,d),u=x.length>0?Math.max(...x.map(e=>e.probability)):0;return{prefix:c,candidates:x,confidence:u,totalMatches:h}}),i=c.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),l=c.some(e=>e.candidates.length>0);return{hops:c,overallConfidence:i,hasValidPath:l}}(t,s,a,n,d,x),[t,s,a,n,d,x]),j=e.useMemo(()=>{const e=[];m&&e.push(m),e.push(...g.hops),f&&e.push(f);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}},[m,g,f]);return j.hasValidPath?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-text-muted",children:"Path Confidence:"}),r.jsx("span",{className:(y=j.overallConfidence,y>=1?"text-accent-success":y>=.5?"text-accent-secondary":y>=.25?"text-signal-poor":y>0?"text-accent-danger":"text-text-muted"),children:B(j.overallConfidence)}),r.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:r.jsx(c,{className:"w-3 h-3"})})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),r.jsx("span",{className:"text-text-muted",children:"Exact"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),r.jsx("span",{className:"text-text-muted",children:"Multi"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),r.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),r.jsx("div",{className:"rounded-lg overflow-hidden border border-border-subtle",children:r.jsx(J,{children:r.jsx(e.Suspense,{fallback:r.jsx("div",{className:"h-[200px] bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:r.jsx(Q,{resolvedPath:j,localNode:a,hubNodes:h,hoveredHopIndex:u,onHoverHop:p})})})}),r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:j.hops.map((e,t)=>{var s,a,n;const o=!0===e.isSource,c=!0===e.isDestination,i=u===t;let l;return l=o?`Source: ${(null==(s=e.candidates[0])?void 0:s.name)||"Unknown"}`:c?`Destination: ${(null==(a=e.candidates[0])?void 0:a.name)||"Unknown"}`:0===e.totalMatches?"No matching nodes found":1===e.totalMatches?`Exact match: ${(null==(n=e.candidates[0])?void 0:n.name)||"Unknown"}`:`${e.totalMatches} possible matches (${(100*e.confidence).toFixed(0)}% confidence)`,r.jsxs("div",{className:b("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono cursor-pointer transition-all",i?"bg-accent-primary/20 ring-1 ring-accent-primary/50":"bg-bg-elevated hover:bg-bg-subtle",o&&"border border-accent-success/30",c&&"border border-accent-primary/30"),title:l,onMouseEnter:()=>p(t),onMouseLeave:()=>p(null),children:[o&&r.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),c&&r.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),r.jsx("span",{style:Y(e.confidence,e.totalMatches),children:e.prefix}),!o&&!c&&e.totalMatches>1&&r.jsxs("span",{className:"text-text-muted",children:["×",e.totalMatches]}),!o&&!c&&0===e.totalMatches&&r.jsx("span",{className:"text-text-muted",children:"?"})]},t)})})]}):r.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[r.jsx(o,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var y}function ee(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function te({label:e,children:t,compact:s=!1}){return r.jsxs("div",{className:b("flex flex-col",s?"gap-0.5":"gap-1"),children:[r.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:e}),r.jsx("span",{className:b("text-text-primary",s?"text-xs":"text-sm"),children:t})]})}function se({onClick:e,copied:t}){return r.jsx("button",{onClick:t=>{t.stopPropagation(),e()},className:"p-1 rounded hover:bg-bg-subtle transition-colors",children:t?r.jsx(m,{className:"w-3 h-3 text-accent-success"}):r.jsx(f,{className:"w-3 h-3 text-text-muted"})})}function ae({originalPath:e,forwardedPath:t,ghostPrefixes:s}){const n=t.length>0?t:e;if(0===n.length)return r.jsx("span",{className:"text-xs text-text-muted",children:"No path data"});const o=e=>null==s?void 0:s.has(e.toUpperCase());return r.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n.map((e,t)=>r.jsxs("div",{className:"flex items-center gap-1",children:[o(e)?r.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-accent-tertiary/20 text-accent-tertiary font-mono text-xs",children:[r.jsx(x,{className:"w-3 h-3"}),e.toUpperCase()]}):r.jsx(D,{hash:e,size:"xs"}),t{const e=e=>{"Escape"===e.key&&s()};window.addEventListener("keydown",e);const t=document.body.style.overflow,a=document.body.style.position,n=document.body.style.width,r=document.body.style.top,o=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${o}px`,()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t,document.body.style.position=a,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,o)}},[s]);const y=_(),v=k(),N=M(),w=C(),E=e.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),R=t.payload_type_name||L(t.payload_type??t.type),z=t.route_type_name||F(t.route_type??t.route),U=t.payload_length??t.length??0,H=t.tx_delay_ms??0,q=ee(t.original_path),X=ee(t.forwarded_path),G=q.length>0||X.length>0,W=X.length>0?X:q,K=e.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]),Q=(null==y?void 0:y.neighbors)??{},B=N.size>0?N:void 0,Y=function(e){var t;if(!e)return{text:null,isText:!1};try{if(/^[0-9a-fA-F]+$/.test(e)){const s=(null==(t=e.match(/.{1,2}/g))?void 0:t.map(e=>parseInt(e,16)))??[],a=String.fromCharCode(...s),n=a.replace(/[^\x20-\x7E]/g,"");if(n.length>.7*a.length)return{text:n,isText:!0}}if(/^[\x20-\x7E\s]+$/.test(e))return{text:e,isText:!0}}catch{}return{text:null,isText:!1}}(t.payload),J=t.payload&&t.payload.length>0,ne=t.raw_packet&&t.raw_packet.length>0,re=e.useCallback(async(e,t)=>{try{await navigator.clipboard.writeText(e),j(t),setTimeout(()=>j(null),2e3)}catch{}},[]);return l.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:s,role:"dialog","aria-modal":"true","aria-labelledby":"packet-modal-title",children:r.jsxs("div",{className:b("glass-card-elevated w-full max-h-[90vh] flex flex-col","sm:max-w-xl sm:mx-4 sm:rounded-xl","rounded-t-2xl rounded-b-none sm:rounded-b-xl","pb-safe"),onClick:e=>e.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(V,{packet:t,showLabel:!0,size:"md"}),r.jsxs("div",{children:[r.jsx("h3",{id:"packet-modal-title",className:b("text-base font-semibold",A(R)),children:R}),r.jsx("p",{className:"text-xs text-text-muted",children:P(t.timestamp)})]})]}),r.jsx("button",{onClick:s,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:r.jsx(d,{className:"w-5 h-5"})})]}),r.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4 overscroll-contain",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(te,{label:"Packet Hash",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.packet_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.packet_hash,"hash"),copied:"hash"===g})]})}),r.jsx(te,{label:"Route",children:r.jsx("span",{className:b("px-2 py-0.5 rounded text-xs border font-medium",O(z)),children:z})})]}),r.jsx("div",{className:"glass-card-inner p-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-text-muted mb-1",children:"Signal Quality"}),r.jsx("p",{className:"text-sm font-medium text-text-primary",children:S(t.rssi)})]}),r.jsx(T,{rssi:t.rssi,snr:t.snr,showValues:!0})]})}),(t.src_hash||t.dst_hash)&&r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.src_hash&&r.jsx(te,{label:"Source",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.src_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.src_hash,"src"),copied:"src"===g})]})}),t.dst_hash&&r.jsx(te,{label:"Destination",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.dst_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.dst_hash,"dst"),copied:"dst"===g})]})})]}),G&&r.jsxs("div",{className:"glass-card-inner p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-text-muted",children:"Packet Path"}),W.some(e=>E.has(e.toUpperCase()))&&r.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-accent-tertiary/20 text-accent-tertiary text-[10px]",children:[r.jsx(x,{className:"w-3 h-3"}),r.jsx("span",{children:"Ghost Detected"})]})]}),r.jsx(ae,{originalPath:q,forwardedPath:X,ghostPrefixes:E})]}),G&&W.length>0&&r.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[r.jsxs("button",{onClick:()=>i(!c),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(h,{className:"w-4 h-4 text-accent-primary"}),r.jsx("span",{className:"text-xs text-text-secondary font-medium",children:"Path Map"})]}),c?r.jsx(u,{className:"w-4 h-4 text-text-muted"}):r.jsx(p,{className:"w-4 h-4 text-text-muted"})]}),c&&r.jsx("div",{className:"px-3 pb-3",children:r.jsx(Z,{path:W,neighbors:Q,localNode:K,localHash:null==y?void 0:y.local_hash,srcHash:t.src_hash,dstHash:t.dst_hash,neighborAffinity:B,hubNodes:[...v]})})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsx(te,{label:"Size",compact:!0,children:r.jsxs("span",{className:"font-mono",children:[U,"B"]})}),r.jsx(te,{label:"TX Delay",compact:!0,children:r.jsxs("span",{className:"font-mono",children:[H.toFixed(1),"ms"]})}),r.jsx(te,{label:"Score",compact:!0,children:r.jsx("span",{className:"font-mono",children:void 0!==t.score?t.score.toFixed(3):"—"})})]}),r.jsx(te,{label:"Status",children:r.jsx("span",{className:I(t),children:$(t)})}),J&&r.jsxs("div",{className:"glass-card-inner p-3",children:[r.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Payload"}),Y.isText&&Y.text?r.jsx("div",{className:"bg-bg-base rounded p-2",children:r.jsx("p",{className:"text-sm text-text-primary font-mono break-all",children:Y.text})}):r.jsxs("p",{className:"text-xs text-text-muted font-mono break-all",children:[null==(a=t.payload)?void 0:a.slice(0,100),t.payload&&t.payload.length>100&&"..."]})]}),ne&&r.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[r.jsxs("button",{onClick:()=>o(!n),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[r.jsx("span",{className:"text-xs text-text-muted",children:"Raw Packet Hex"}),n?r.jsx(u,{className:"w-4 h-4 text-text-muted"}):r.jsx(p,{className:"w-4 h-4 text-text-muted"})]}),n&&r.jsx("div",{className:"px-3 pb-3",children:r.jsxs("div",{className:"bg-bg-base rounded p-2 relative",children:[r.jsx("pre",{className:"text-[10px] text-text-secondary font-mono break-all whitespace-pre-wrap",children:t.raw_packet}),r.jsx("button",{onClick:()=>re(t.raw_packet,"raw"),className:"absolute top-2 right-2 p-1 rounded bg-bg-elevated hover:bg-bg-subtle transition-colors",children:"raw"===g?r.jsx(m,{className:"w-3 h-3 text-accent-success"}):r.jsx(f,{className:"w-3 h-3 text-text-muted"})})]})})]})]})]})}),document.body)});export{G as P,W as a,ne as b,H as c,L as g}; +import{r as e,_ as t,a3 as s,E as a,a4 as n,j as r,a5 as o,a6 as c,a7 as i,b as l,X as d,h as x,a8 as h,k as u,a9 as p,aa as m,$ as f}from"./vendor-react-O8XH9yVn.js";import{c as b}from"./recharts-BU7auunF.js";import{q as g,R as j,r as y,t as v,v as N,e as w,d as _,w as k,x as M,y as C,z as P}from"./index-DGrzd8xb.js";import{S as T,g as S}from"./SignalIndicator-BVAbF7xm.js";import{H as D}from"./HashBadge-aS_UIcg2.js";import{_ as E}from"./deckgl-DTsmDcfs.js";function L(e){return null==e?"UNKNOWN":g[e]||`TYPE_${e}`}function F(e){return null==e?"UNKNOWN":j[e]||`ROUTE_${e}`}function A(e){return{ADVERT:"text-[var(--pkt-advert)]",FLOOD:"text-[var(--pkt-flood)]",TXT_MSG:"text-[var(--pkt-txt-msg)]",ACK:"text-[var(--pkt-ack)]",TRACE:"text-[var(--pkt-trace)]",REQ:"text-[var(--pkt-req)]",RESPONSE:"text-[var(--pkt-response)]",GRP_TXT:"text-[var(--pkt-grp-txt)]",GRP_DATA:"text-[var(--pkt-grp-data)]",PATH:"text-[var(--pkt-path)]",ANON_REQ:"text-[var(--pkt-anon)]"}[e]||"text-[var(--pkt-unknown)]"}function O(e){return{FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30",TRANSPORT:"bg-[var(--route-transport)]/20 text-[var(--route-transport)] border-[var(--route-transport)]/30",T_FLOOD:"bg-[var(--route-flood)]/20 text-[var(--route-flood)] border-[var(--route-flood)]/30",T_DIRECT:"bg-[var(--route-direct)]/20 text-[var(--route-direct)] border-[var(--route-direct)]/30"}[e]||"bg-bg-subtle text-text-muted border-border-subtle"}function R(e){return 1===e||!0===e}const z={rx:{icon:t,label:"RX",color:"text-accent-primary",bgColor:"bg-accent-primary/10"},tx:{icon:n,label:"TX",color:"text-[#F9D26F]",bgColor:"bg-[#F9D26F]/10"},forward:{icon:a,label:"FWD",color:"text-accent-success",bgColor:"bg-accent-success/10"},dropped:{icon:s,label:"DROP",color:"text-accent-danger",bgColor:"bg-accent-danger/10"},duplicate:{icon:t,label:"DUP",color:"text-text-muted",bgColor:"bg-white/5"}},U={sm:"w-3.5 h-3.5",md:"w-4 h-4"};function H(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 V=e.memo(function({packet:e,showLabel:t=!0,size:s="sm"}){const a=H(e),n=z[a],o=n.icon;return r.jsxs("div",{className:b("inline-flex items-center gap-1 rounded-md",t&&"px-1.5 py-0.5",t&&n.bgColor),children:[r.jsx(o,{className:b(U[s],n.color)}),t&&r.jsx("span",{className:b("text-[10px] font-semibold tracking-wide",n.color),children:n.label})]})});function $(e){return"tx_local"===e.packet_origin?"Transmitted":"tx_forward"===e.packet_origin||e.transmitted?"Forwarded":e.is_duplicate?"Duplicate":"No transport keys configured"===e.drop_reason?"Monitor Only":e.drop_reason?e.drop_reason:"Received"}function I(e){return z[H(e)].color}function q(e){return{payloadType:e.payload_type_name||L(e.payload_type??e.type),routeType:e.route_type_name||F(e.route_type??e.route)}}function X({packet:e,onClick:t,isFlashing:s=!1}){const{payloadType:a,routeType:n}=q(e);return r.jsxs("tr",{onClick:()=>t(e),className:b("cursor-pointer","hover:bg-bg-subtle",R(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:[r.jsx("td",{className:"py-2.5 px-3",children:r.jsx(V,{packet:e,showLabel:!0})}),r.jsx("td",{className:"py-2.5 px-3 text-xs font-mono text-text-secondary whitespace-nowrap",children:v(e.timestamp)}),r.jsx("td",{className:"py-2.5 px-3",children:e.src_hash?r.jsx(D,{hash:e.src_hash,copyValue:e.src_hash_full,size:"xs"}):r.jsx("span",{className:"text-xs text-text-muted",children:"—"})}),r.jsx("td",{className:"py-2.5 px-3",children:r.jsx("span",{className:b("text-xs font-semibold",A(a)),children:a})}),r.jsx("td",{className:"py-2.5 px-3",children:r.jsx("span",{className:b("px-1.5 py-0.5 rounded text-[10px] border font-medium",O(n)),children:n})}),r.jsx("td",{className:"py-2.5 px-3 pr-4",children:r.jsx("div",{className:"flex justify-end",children:r.jsx(T,{rssi:e.rssi,snr:e.snr,compact:!0,showValues:!0})})})]})}const G=e.memo(function(e){return r.jsx(X,{...e})}),W=e.memo(function({packet:e,onClick:t,isFlashing:s=!1}){const{payloadType:a,routeType:n}=q(e);return r.jsx("div",{onClick:()=>t(e),className:b("packet-row px-3 py-2.5 cursor-pointer","hover:bg-bg-subtle","active:bg-bg-elevated",R(e.is_duplicate)&&"opacity-50",s&&"flash-row"),children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-14 flex-shrink-0",children:r.jsx(V,{packet:e,showLabel:!0,size:"sm"})}),r.jsx("span",{className:"text-[10px] font-mono text-text-muted w-7 flex-shrink-0",children:y(e.timestamp)}),r.jsx("div",{className:"w-9 flex-shrink-0",children:e.src_hash?r.jsx(D,{hash:e.src_hash,copyValue:e.src_hash_full,size:"xs"}):r.jsx("span",{className:"text-[10px] text-text-muted",children:"—"})}),r.jsx("span",{className:b("text-xs font-semibold truncate flex-1 min-w-0",A(a)),children:a}),r.jsx("div",{className:"w-14 flex-shrink-0",children:r.jsx("span",{className:b("px-1 py-0.5 rounded text-[9px] border font-medium",O(n)),children:n})}),r.jsx("div",{className:"w-12 flex-shrink-0 flex justify-end",children:r.jsx(T,{rssi:e.rssi,compact:!0,showValues:!0})})]})})});function K(e){if(e.contact_type){const t=e.contact_type.toLowerCase();if("repeater"===t||"rep"===t)return!0;if("companion"===t||"client"===t||"cli"===t)return!1;if("room server"===t||"room_server"===t||"room"===t||"server"===t)return!1}return!0===e.is_repeater||(e.is_repeater,!1)}const Q=e.lazy(()=>E(()=>import("./PathMapMapLibre-XwxmBUnL.js"),__vite__mapDeps([0,1,2,3])));function B(e){return`${(100*e).toFixed(0)}%`}function Y(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 J extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?r.jsxs("div",{className:"h-[200px] flex items-center justify-center text-text-muted",children:[r.jsx(i,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Z({path:t,neighbors:s,localNode:a,localHash:n,srcHash:i,dstHash:l,neighborAffinity:d,prefixLookup:x,hubNodes:h}){const[u,p]=e.useState(null),m=e.useMemo(()=>{if(!i)return null;const e=w(i),t=s[i];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:i,name:t.node_name||t.name||"Source",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isSource:!0};const a=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||i.slice(0,8);return{prefix:e,candidates:[{hash:i,name:a,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[i,s]),f=e.useMemo(()=>{if(!l)return null;const e=w(l);if(n&&l===n&&a){const t=0!==a.latitude||0!==a.longitude;return{prefix:e,candidates:[{hash:l,name:a.name||"Local Node",latitude:t?a.latitude:0,longitude:t?a.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const t=s[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||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const r=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||l.slice(0,8);return{prefix:e,candidates:[{hash:l,name:r,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[l,s,a,n]),g=e.useMemo(()=>function(e,t,s,a,n,r){if(!e||0===e.length)return{hops:[],overallConfidence:0,hasValidPath:!1};const o=e.length-1,c=e.map((c,i)=>{const l=i===o,d=e.length-i,{candidates:x,totalMatches:h}=function(e,t,s,a,n=!1,r,o,c){const i=function(e){const t={};for(const[s,a]of Object.entries(e))K(a)&&(t[s]=a);return t}(t);let l;if(o){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}}(o,e,{position:c,isLastHop:n});l=t.confidence}const{matches:d,probability:x}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),o=[],c=s&&N(r,s);c&&o.push(s);for(const u of Object.keys(t))N(r,u)&&o.push(u);if(n&&c&&s&&1===o.length)return{matches:o,probability:1,bestMatch:s};if(n&&c&&o.length>1){const e=o.filter(e=>e!==s);if(1===e.length)return{matches:o,probability:1,bestMatch:e[0]}}const i=o.length>0?1/o.length:0,l=[...o].sort();let d=null,x=-1;if(1===l.length)d=l[0];else if(l.length>1&&a){for(const e of l){const t=a.get(e),s=t?"number"==typeof t?t:t.combinedScore:0;s>x&&(x=s,d=e)}d||(d=l[0])}else l.length>0&&(d=l[0]);let h=i;if(o.length>1&&a&&x>0){let e=0;for(const t of o){const s=a.get(t);e+=s?"number"==typeof s?s:s.combinedScore:0}e>0&&(h=Math.min(.95,x/e))}return{matches:o,probability:h,bestMatch:d}}(e,i,a,r,n),h=d.length,u=[],p=e.toUpperCase(),m=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const b of d){if(a&&N(p,a)&&b===a&&m&&s){u.push({hash:b,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:x,isLocal:!0});continue}const e=i[b];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&u.push({hash:b,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:x,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const f=u.length;if(1===f)u[0].probability=l??1;else if(f>1)if(void 0!==l&&l>0){u[0].probability=l;const e=1-l,t=f-1;u.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=u.map(t=>{if(t.isLocal)return{candidate:t,score:1};const a=null==r?void 0:r.get(t.hash);let n=.5;var o;let c;return m&&s&&(n=(o=function(e,t,s,a){const n=(s-e)*Math.PI/180,r=(a-t)*Math.PI/180,o=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(o),Math.sqrt(1-o))*6371e3}(s.latitude,s.longitude,t.latitude,t.longitude))<100?1:o<500?.9:o<1e3?.7:o<5e3?.5:o<1e4?.3:.1),a?c=.3*n+.3*a.hopConsistencyScore+.4*a.frequencyScore:(c=n,t.isDirectNeighbor&&(c=Math.max(c,.8))),e+=c,{candidate:t,score:c}});if(e>0)t.forEach(({candidate:t,score:s})=>{t.probability=Math.min(.95,s/e)});else{const e=1/f;u.forEach(t=>t.probability=e)}}return{candidates:u,totalMatches:h}}(c,t,s,a,l,n,r,d),u=x.length>0?Math.max(...x.map(e=>e.probability)):0;return{prefix:c,candidates:x,confidence:u,totalMatches:h}}),i=c.reduce((e,t)=>0===t.confidence?0:e*t.confidence,1),l=c.some(e=>e.candidates.length>0);return{hops:c,overallConfidence:i,hasValidPath:l}}(t,s,a,n,d,x),[t,s,a,n,d,x]),j=e.useMemo(()=>{const e=[];m&&e.push(m),e.push(...g.hops),f&&e.push(f);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}},[m,g,f]);return j.hasValidPath?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-text-muted",children:"Path Confidence:"}),r.jsx("span",{className:(y=j.overallConfidence,y>=1?"text-accent-success":y>=.5?"text-accent-secondary":y>=.25?"text-signal-poor":y>0?"text-accent-danger":"text-text-muted"),children:B(j.overallConfidence)}),r.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:r.jsx(c,{className:"w-3 h-3"})})]}),r.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),r.jsx("span",{className:"text-text-muted",children:"Exact"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),r.jsx("span",{className:"text-text-muted",children:"Multi"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),r.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),r.jsx("div",{className:"rounded-lg overflow-hidden border border-border-subtle",children:r.jsx(J,{children:r.jsx(e.Suspense,{fallback:r.jsx("div",{className:"h-[200px] bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:r.jsx(Q,{resolvedPath:j,localNode:a,hubNodes:h,hoveredHopIndex:u,onHoverHop:p})})})}),r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:j.hops.map((e,t)=>{var s,a,n;const o=!0===e.isSource,c=!0===e.isDestination,i=u===t;let l;return l=o?`Source: ${(null==(s=e.candidates[0])?void 0:s.name)||"Unknown"}`:c?`Destination: ${(null==(a=e.candidates[0])?void 0:a.name)||"Unknown"}`:0===e.totalMatches?"No matching nodes found":1===e.totalMatches?`Exact match: ${(null==(n=e.candidates[0])?void 0:n.name)||"Unknown"}`:`${e.totalMatches} possible matches (${(100*e.confidence).toFixed(0)}% confidence)`,r.jsxs("div",{className:b("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-mono cursor-pointer transition-all",i?"bg-accent-primary/20 ring-1 ring-accent-primary/50":"bg-bg-elevated hover:bg-bg-subtle",o&&"border border-accent-success/30",c&&"border border-accent-primary/30"),title:l,onMouseEnter:()=>p(t),onMouseLeave:()=>p(null),children:[o&&r.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),c&&r.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),r.jsx("span",{style:Y(e.confidence,e.totalMatches),children:e.prefix}),!o&&!c&&e.totalMatches>1&&r.jsxs("span",{className:"text-text-muted",children:["×",e.totalMatches]}),!o&&!c&&0===e.totalMatches&&r.jsx("span",{className:"text-text-muted",children:"?"})]},t)})})]}):r.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[r.jsx(o,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var y}function ee(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function te({label:e,children:t,compact:s=!1}){return r.jsxs("div",{className:b("flex flex-col",s?"gap-0.5":"gap-1"),children:[r.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:e}),r.jsx("span",{className:b("text-text-primary",s?"text-xs":"text-sm"),children:t})]})}function se({onClick:e,copied:t}){return r.jsx("button",{onClick:t=>{t.stopPropagation(),e()},className:"p-1 rounded hover:bg-bg-subtle transition-colors",children:t?r.jsx(m,{className:"w-3 h-3 text-accent-success"}):r.jsx(f,{className:"w-3 h-3 text-text-muted"})})}function ae({originalPath:e,forwardedPath:t,ghostPrefixes:s}){const n=t.length>0?t:e;if(0===n.length)return r.jsx("span",{className:"text-xs text-text-muted",children:"No path data"});const o=e=>null==s?void 0:s.has(e.toUpperCase());return r.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n.map((e,t)=>r.jsxs("div",{className:"flex items-center gap-1",children:[o(e)?r.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-accent-tertiary/20 text-accent-tertiary font-mono text-xs",children:[r.jsx(x,{className:"w-3 h-3"}),e.toUpperCase()]}):r.jsx(D,{hash:e,size:"xs"}),t{const e=e=>{"Escape"===e.key&&s()};window.addEventListener("keydown",e);const t=document.body.style.overflow,a=document.body.style.position,n=document.body.style.width,r=document.body.style.top,o=window.scrollY;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.top=`-${o}px`,()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t,document.body.style.position=a,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,o)}},[s]);const y=_(),v=k(),N=M(),w=C(),E=e.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),R=t.payload_type_name||L(t.payload_type??t.type),z=t.route_type_name||F(t.route_type??t.route),U=t.payload_length??t.length??0,H=t.tx_delay_ms??0,q=ee(t.original_path),X=ee(t.forwarded_path),G=q.length>0||X.length>0,W=X.length>0?X:q,K=e.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]),Q=(null==y?void 0:y.neighbors)??{},B=N.size>0?N:void 0,Y=function(e){var t;if(!e)return{text:null,isText:!1};try{if(/^[0-9a-fA-F]+$/.test(e)){const s=(null==(t=e.match(/.{1,2}/g))?void 0:t.map(e=>parseInt(e,16)))??[],a=String.fromCharCode(...s),n=a.replace(/[^\x20-\x7E]/g,"");if(n.length>.7*a.length)return{text:n,isText:!0}}if(/^[\x20-\x7E\s]+$/.test(e))return{text:e,isText:!0}}catch{}return{text:null,isText:!1}}(t.payload),J=t.payload&&t.payload.length>0,ne=t.raw_packet&&t.raw_packet.length>0,re=e.useCallback(async(e,t)=>{try{await navigator.clipboard.writeText(e),j(t),setTimeout(()=>j(null),2e3)}catch{}},[]);return l.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:s,role:"dialog","aria-modal":"true","aria-labelledby":"packet-modal-title",children:r.jsxs("div",{className:b("glass-card-elevated w-full max-h-[90vh] flex flex-col","sm:max-w-xl sm:mx-4 sm:rounded-xl","rounded-t-2xl rounded-b-none sm:rounded-b-xl","pb-safe"),onClick:e=>e.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(V,{packet:t,showLabel:!0,size:"md"}),r.jsxs("div",{children:[r.jsx("h3",{id:"packet-modal-title",className:b("text-base font-semibold",A(R)),children:R}),r.jsx("p",{className:"text-xs text-text-muted",children:P(t.timestamp)})]})]}),r.jsx("button",{onClick:s,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:r.jsx(d,{className:"w-5 h-5"})})]}),r.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4 overscroll-contain",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(te,{label:"Packet Hash",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.packet_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.packet_hash,"hash"),copied:"hash"===g})]})}),r.jsx(te,{label:"Route",children:r.jsx("span",{className:b("px-2 py-0.5 rounded text-xs border font-medium",O(z)),children:z})})]}),r.jsx("div",{className:"glass-card-inner p-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-text-muted mb-1",children:"Signal Quality"}),r.jsx("p",{className:"text-sm font-medium text-text-primary",children:S(t.rssi)})]}),r.jsx(T,{rssi:t.rssi,snr:t.snr,showValues:!0})]})}),(t.src_hash||t.dst_hash)&&r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.src_hash&&r.jsx(te,{label:"Source",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.src_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.src_hash,"src"),copied:"src"===g})]})}),t.dst_hash&&r.jsx(te,{label:"Destination",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(D,{hash:t.dst_hash,size:"sm"}),r.jsx(se,{onClick:()=>re(t.dst_hash,"dst"),copied:"dst"===g})]})})]}),G&&r.jsxs("div",{className:"glass-card-inner p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-text-muted",children:"Packet Path"}),W.some(e=>E.has(e.toUpperCase()))&&r.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-accent-tertiary/20 text-accent-tertiary text-[10px]",children:[r.jsx(x,{className:"w-3 h-3"}),r.jsx("span",{children:"Ghost Detected"})]})]}),r.jsx(ae,{originalPath:q,forwardedPath:X,ghostPrefixes:E})]}),G&&W.length>0&&r.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[r.jsxs("button",{onClick:()=>i(!c),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(h,{className:"w-4 h-4 text-accent-primary"}),r.jsx("span",{className:"text-xs text-text-secondary font-medium",children:"Path Map"})]}),c?r.jsx(u,{className:"w-4 h-4 text-text-muted"}):r.jsx(p,{className:"w-4 h-4 text-text-muted"})]}),c&&r.jsx("div",{className:"px-3 pb-3",children:r.jsx(Z,{path:W,neighbors:Q,localNode:K,localHash:null==y?void 0:y.local_hash,srcHash:t.src_hash,dstHash:t.dst_hash,neighborAffinity:B,hubNodes:[...v]})})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsx(te,{label:"Size",compact:!0,children:r.jsxs("span",{className:"font-mono",children:[U,"B"]})}),r.jsx(te,{label:"TX Delay",compact:!0,children:r.jsxs("span",{className:"font-mono",children:[H.toFixed(1),"ms"]})}),r.jsx(te,{label:"Score",compact:!0,children:r.jsx("span",{className:"font-mono",children:void 0!==t.score?t.score.toFixed(3):"—"})})]}),r.jsx(te,{label:"Status",children:r.jsx("span",{className:I(t),children:$(t)})}),J&&r.jsxs("div",{className:"glass-card-inner p-3",children:[r.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Payload"}),Y.isText&&Y.text?r.jsx("div",{className:"bg-bg-base rounded p-2",children:r.jsx("p",{className:"text-sm text-text-primary font-mono break-all",children:Y.text})}):r.jsxs("p",{className:"text-xs text-text-muted font-mono break-all",children:[null==(a=t.payload)?void 0:a.slice(0,100),t.payload&&t.payload.length>100&&"..."]})]}),ne&&r.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[r.jsxs("button",{onClick:()=>o(!n),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[r.jsx("span",{className:"text-xs text-text-muted",children:"Raw Packet Hex"}),n?r.jsx(u,{className:"w-4 h-4 text-text-muted"}):r.jsx(p,{className:"w-4 h-4 text-text-muted"})]}),n&&r.jsx("div",{className:"px-3 pb-3",children:r.jsxs("div",{className:"bg-bg-base rounded p-2 relative",children:[r.jsx("pre",{className:"text-[10px] text-text-secondary font-mono break-all whitespace-pre-wrap",children:t.raw_packet}),r.jsx("button",{onClick:()=>re(t.raw_packet,"raw"),className:"absolute top-2 right-2 p-1 rounded bg-bg-elevated hover:bg-bg-subtle transition-colors",children:"raw"===g?r.jsx(m,{className:"w-3 h-3 text-accent-success"}):r.jsx(f,{className:"w-3 h-3 text-text-muted"})})]})})]})]})]})}),document.body)});export{G as P,W as a,ne as b,H as c,L as g}; diff --git a/frontend/dist/assets/Packets-Cn-iDbXq.js b/frontend/dist/assets/Packets-Dipyssg1.js similarity index 98% rename from frontend/dist/assets/Packets-Cn-iDbXq.js rename to frontend/dist/assets/Packets-Dipyssg1.js index f96fa84e..f08d472e 100644 --- a/frontend/dist/assets/Packets-Cn-iDbXq.js +++ b/frontend/dist/assets/Packets-Dipyssg1.js @@ -1 +1 @@ -import{r as e,j as t,_ as s,E as a,Y as l,$ as r,a0 as i,D as c,a1 as n,a2 as o,p as d,X as m}from"./vendor-react-O8XH9yVn.js";import{c as x}from"./recharts-BU7auunF.js";import{u as p,b as u,p as h,c as b,q as g,R as j}from"./index-Dp0UlTio.js";import{c as v,P as f,a as y,b as N,g as w}from"./PacketDetailModal-CR1FHEH5.js";import{P as k,b as S,a as R,c as _}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./SignalIndicator-BVAbF7xm.js";import"./HashBadge-aS_UIcg2.js";function C({icon:e,label:s,value:a,color:l,percentage:r}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:x("p-1.5 rounded-md",l),children:e}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm font-semibold text-text-primary",children:a.toLocaleString()}),t.jsxs("span",{className:"text-[10px] text-text-muted leading-tight",children:[s,void 0!==r&&t.jsxs("span",{className:"ml-1 opacity-70",children:["(",r,"%)"]})]})]})]})}const M=e.memo(function({packets:c}){const n=e.useMemo(()=>{let e=0,t=0,s=0;const a=new Set;let l=0,r=0;for(const o of c){switch(v(o)){case"forward":e++;break;case"dropped":t++;break;case"duplicate":s++}o.src_hash&&a.add(o.src_hash),o.rssi&&(l+=o.rssi,r++)}const i=c.length,n=r>0?Math.round(l/r):0;return{total:i,rx:i,fwd:e,dropped:t,duplicate:s,uniqueSources:a.size,avgRssi:n,rxPercent:100,fwdPercent:i>0?Math.round(e/i*100):0,droppedPercent:i>0?Math.round(t/i*100):0}},[c]);return 0===c.length?null:t.jsx("div",{className:"glass-card p-3 pr-4",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[t.jsx(C,{icon:t.jsx(s,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Received",value:n.rx,color:"bg-accent-primary/10",percentage:n.rxPercent}),t.jsx(C,{icon:t.jsx(a,{className:"w-3.5 h-3.5 text-accent-success"}),label:"Forwarded",value:n.fwd,color:"bg-accent-success/10",percentage:n.fwdPercent}),t.jsx(C,{icon:t.jsx(l,{className:"w-3.5 h-3.5 text-accent-danger"}),label:"Dropped",value:n.dropped,color:"bg-accent-danger/10",percentage:n.droppedPercent}),t.jsx(C,{icon:t.jsx(r,{className:"w-3.5 h-3.5 text-text-muted"}),label:"Duplicates",value:n.duplicate,color:"bg-white/5"}),t.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[t.jsx(C,{icon:t.jsx(i,{className:"w-3.5 h-3.5 text-accent-secondary"}),label:"Sources",value:n.uniqueSources,color:"bg-accent-secondary/10"}),t.jsxs("div",{className:"flex flex-col items-end pr-1",children:[t.jsxs("span",{className:"text-sm font-mono text-text-secondary",children:[n.avgRssi," dBm"]}),t.jsx("span",{className:"text-[10px] text-text-muted",children:"Avg Signal"})]})]})]})})});function P(e){return(e.payload_type_name||w(e.payload_type??e.type)).toLowerCase().includes("advert")}function L(){const s=p(),a=u(),l=h(),[r,i]=e.useState(null),[w,C]=e.useState(!1),[L,D]=e.useState({limit:100,status:"all"}),T=b(),[F,A]=e.useState(null),$=e.useRef(0),[q,E]=e.useState(Date.now);e.useEffect(()=>{L.timeRange&&L.timeRange>0&&queueMicrotask(()=>E(Date.now()))},[L.timeRange,s]);const H=e.useMemo(()=>{const e=L.limit??100;return[...s.length<=e?s:s.slice(-e)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,L.limit]),B=0===s.length,O=e.useMemo(()=>{let e=H;if(void 0!==L.type){const t=g[L.type];e=e.filter(e=>{const s=e.type??e.payload_type,a=e.payload_type_name;return s===L.type||a===t})}if(void 0!==L.route){const t=j[L.route];e=e.filter(e=>{const s=e.route??e.route_type,a=e.route_type_name;return s===L.route||a===t})}if(L.status&&"all"!==L.status&&(e=e.filter(e=>v(e)===L.status)),void 0!==L.signalMin&&(e=e.filter(e=>e.rssi>=L.signalMin)),L.timeRange&&L.timeRange>0){const t=q/1e3-3600*L.timeRange;e=e.filter(e=>e.timestamp>=t)}return e},[H,L.type,L.route,L.status,L.signalMin,L.timeRange,q]);e.useEffect(()=>{if(T>0&&T!==$.current&&H.length>0){$.current=T;const e=H.find(P);if(e){const t=requestAnimationFrame(()=>A(e.packet_hash)),s=setTimeout(()=>A(null),600);return()=>{cancelAnimationFrame(t),clearTimeout(s)}}}},[T,H]);const z=(e,t)=>D(s=>({...s,[e]:t})),G=void 0!==L.type||void 0!==L.route||L.status&&"all"!==L.status||void 0!==L.signalMin||L.timeRange&&L.timeRange>0;return t.jsxs(k,{children:[t.jsx(S,{title:"Packet History",icon:t.jsx(d,{}),controls:t.jsxs(t.Fragment,{children:[a&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[t.jsx(c,{className:"w-1.5 h-1.5 fill-accent-success text-accent-success animate-pulse"}),t.jsx("span",{className:"text-text-muted hidden xs:inline",children:"Live"})]}),t.jsxs("button",{onClick:()=>C(!w),className:x("sm:hidden px-3 py-1.5 rounded-lg text-sm font-medium transition-all","flex items-center gap-1.5 border",G?"bg-accent-primary/20 text-accent-primary border-accent-primary/30":"bg-bg-subtle text-text-muted border-border-subtle"),children:[t.jsx(n,{className:"w-4 h-4"}),G&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),t.jsxs("button",{onClick:()=>l(!a),className:x("px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200","flex items-center gap-1.5 border",a?"bg-accent-success/20 text-accent-success border-accent-success/30":"bg-bg-subtle text-text-muted border-border-subtle hover:bg-bg-elevated"),children:[t.jsx(o,{className:x("w-4 h-4",a&&"animate-spin")}),t.jsx("span",{className:"hidden xs:inline",children:a?"Live":"Paused"})]})]})}),t.jsxs(R,{noPadding:!0,className:x("overflow-hidden transition-all duration-200",w?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[t.jsx(_,{listHeader:!0,icon:t.jsx(n,{className:"icon-sm"}),title:"Filters",actions:G?t.jsxs("button",{onClick:()=>D({limit:L.limit,status:"all"}),className:"type-data-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[t.jsx(m,{className:"w-3 h-3"})," Clear"]}):void 0}),t.jsx("div",{className:"p-3 sm:p-4",children:t.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Type"}),t.jsxs("select",{value:L.type??"",onChange:e=>z("type",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"All Types"}),Object.entries(g).map(([e,s])=>t.jsx("option",{value:e,children:s},e))]})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Route"}),t.jsxs("select",{value:L.route??"",onChange:e=>z("route",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"All Routes"}),Object.entries(j).map(([e,s])=>t.jsx("option",{value:e,children:s},e))]})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Status"}),t.jsxs("select",{value:L.status??"all",onChange:e=>z("status",e.target.value),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"all",children:"All Status"}),t.jsx("option",{value:"rx",children:"Received"}),t.jsx("option",{value:"forward",children:"Forwarded"}),t.jsx("option",{value:"dropped",children:"Dropped"}),t.jsx("option",{value:"duplicate",children:"Duplicate"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[100px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Time"}),t.jsxs("select",{value:L.timeRange??0,onChange:e=>z("timeRange",Number(e.target.value)||void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:0,children:"All Time"}),t.jsx("option",{value:1,children:"Last 1h"}),t.jsx("option",{value:6,children:"Last 6h"}),t.jsx("option",{value:24,children:"Last 24h"}),t.jsx("option",{value:168,children:"Last 7d"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[100px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),t.jsxs("select",{value:L.signalMin??"",onChange:e=>z("signalMin",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"Any Signal"}),t.jsx("option",{value:-90,children:"Strong (≥-90)"}),t.jsx("option",{value:-100,children:"Good (≥-100)"}),t.jsx("option",{value:-110,children:"Fair (≥-110)"}),t.jsx("option",{value:-120,children:"Weak (≥-120)"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[80px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),t.jsxs("select",{value:L.limit??100,onChange:e=>z("limit",Number(e.target.value)),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:50,children:"50"}),t.jsx("option",{value:100,children:"100"}),t.jsx("option",{value:200,children:"200"}),t.jsx("option",{value:500,children:"500"})]})]})]})})]}),t.jsx(M,{packets:O}),t.jsxs(R,{noPadding:!0,children:[t.jsxs("div",{className:"sm:hidden flex items-center gap-1.5 px-3 py-2 border-b border-border-subtle bg-bg-elevated/30",children:[t.jsx("span",{className:"type-micro w-14 flex-shrink-0",children:"Dir"}),t.jsx("span",{className:"type-micro w-7 flex-shrink-0",children:"Time"}),t.jsx("span",{className:"type-micro w-9 flex-shrink-0",children:"Src"}),t.jsx("span",{className:"type-micro flex-1 min-w-0",children:"Type"}),t.jsx("span",{className:"type-micro w-14 flex-shrink-0",children:"Route"}),t.jsx("span",{className:"type-micro w-12 flex-shrink-0",children:"Signal"})]}),t.jsx("div",{className:"hidden sm:block overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-subtle bg-bg-elevated/30",children:[t.jsx("th",{className:"text-left py-2.5 px-3 type-micro w-16",children:"Dir"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Time"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Source"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Type"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Route"}),t.jsx("th",{className:"text-right py-2.5 px-3 pr-4 type-micro",children:"Signal"})]})}),t.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:B&&0===H.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"Loading packets..."})}):0===O.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"No packets found"})}):O.map((e,s)=>t.jsx(f,{packet:e,onClick:i,isFlashing:P(e)&&F===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))})]})}),t.jsx("div",{className:"sm:hidden divide-y divide-border-subtle/30",children:B&&0===H.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===O.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"No packets found"}):O.map((e,s)=>t.jsx(y,{packet:e,onClick:i,isFlashing:P(e)&&F===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))}),t.jsxs("div",{className:"px-3 py-2 border-t border-border-subtle type-data-xs text-text-muted bg-bg-elevated/20 sm:text-left text-center",children:["Showing ",O.length," of ",H.length," packets"]})]}),r&&t.jsx(N,{packet:r,onClose:()=>i(null)})]})}export{L as default}; +import{r as e,j as t,_ as s,E as a,Y as l,$ as r,a0 as i,D as c,a1 as n,a2 as o,p as d,X as m}from"./vendor-react-O8XH9yVn.js";import{c as x}from"./recharts-BU7auunF.js";import{u as p,b as u,p as h,c as b,q as g,R as j}from"./index-DGrzd8xb.js";import{c as v,P as f,a as y,b as N,g as w}from"./PacketDetailModal-wjwmQ-9h.js";import{P as k,b as S,a as R,c as _}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./SignalIndicator-BVAbF7xm.js";import"./HashBadge-aS_UIcg2.js";function C({icon:e,label:s,value:a,color:l,percentage:r}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:x("p-1.5 rounded-md",l),children:e}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm font-semibold text-text-primary",children:a.toLocaleString()}),t.jsxs("span",{className:"text-[10px] text-text-muted leading-tight",children:[s,void 0!==r&&t.jsxs("span",{className:"ml-1 opacity-70",children:["(",r,"%)"]})]})]})]})}const M=e.memo(function({packets:c}){const n=e.useMemo(()=>{let e=0,t=0,s=0;const a=new Set;let l=0,r=0;for(const o of c){switch(v(o)){case"forward":e++;break;case"dropped":t++;break;case"duplicate":s++}o.src_hash&&a.add(o.src_hash),o.rssi&&(l+=o.rssi,r++)}const i=c.length,n=r>0?Math.round(l/r):0;return{total:i,rx:i,fwd:e,dropped:t,duplicate:s,uniqueSources:a.size,avgRssi:n,rxPercent:100,fwdPercent:i>0?Math.round(e/i*100):0,droppedPercent:i>0?Math.round(t/i*100):0}},[c]);return 0===c.length?null:t.jsx("div",{className:"glass-card p-3 pr-4",children:t.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[t.jsx(C,{icon:t.jsx(s,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Received",value:n.rx,color:"bg-accent-primary/10",percentage:n.rxPercent}),t.jsx(C,{icon:t.jsx(a,{className:"w-3.5 h-3.5 text-accent-success"}),label:"Forwarded",value:n.fwd,color:"bg-accent-success/10",percentage:n.fwdPercent}),t.jsx(C,{icon:t.jsx(l,{className:"w-3.5 h-3.5 text-accent-danger"}),label:"Dropped",value:n.dropped,color:"bg-accent-danger/10",percentage:n.droppedPercent}),t.jsx(C,{icon:t.jsx(r,{className:"w-3.5 h-3.5 text-text-muted"}),label:"Duplicates",value:n.duplicate,color:"bg-white/5"}),t.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[t.jsx(C,{icon:t.jsx(i,{className:"w-3.5 h-3.5 text-accent-secondary"}),label:"Sources",value:n.uniqueSources,color:"bg-accent-secondary/10"}),t.jsxs("div",{className:"flex flex-col items-end pr-1",children:[t.jsxs("span",{className:"text-sm font-mono text-text-secondary",children:[n.avgRssi," dBm"]}),t.jsx("span",{className:"text-[10px] text-text-muted",children:"Avg Signal"})]})]})]})})});function P(e){return(e.payload_type_name||w(e.payload_type??e.type)).toLowerCase().includes("advert")}function L(){const s=p(),a=u(),l=h(),[r,i]=e.useState(null),[w,C]=e.useState(!1),[L,D]=e.useState({limit:100,status:"all"}),T=b(),[F,A]=e.useState(null),$=e.useRef(0),[q,E]=e.useState(Date.now);e.useEffect(()=>{L.timeRange&&L.timeRange>0&&queueMicrotask(()=>E(Date.now()))},[L.timeRange,s]);const H=e.useMemo(()=>{const e=L.limit??100;return[...s.length<=e?s:s.slice(-e)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,L.limit]),B=0===s.length,O=e.useMemo(()=>{let e=H;if(void 0!==L.type){const t=g[L.type];e=e.filter(e=>{const s=e.type??e.payload_type,a=e.payload_type_name;return s===L.type||a===t})}if(void 0!==L.route){const t=j[L.route];e=e.filter(e=>{const s=e.route??e.route_type,a=e.route_type_name;return s===L.route||a===t})}if(L.status&&"all"!==L.status&&(e=e.filter(e=>v(e)===L.status)),void 0!==L.signalMin&&(e=e.filter(e=>e.rssi>=L.signalMin)),L.timeRange&&L.timeRange>0){const t=q/1e3-3600*L.timeRange;e=e.filter(e=>e.timestamp>=t)}return e},[H,L.type,L.route,L.status,L.signalMin,L.timeRange,q]);e.useEffect(()=>{if(T>0&&T!==$.current&&H.length>0){$.current=T;const e=H.find(P);if(e){const t=requestAnimationFrame(()=>A(e.packet_hash)),s=setTimeout(()=>A(null),600);return()=>{cancelAnimationFrame(t),clearTimeout(s)}}}},[T,H]);const z=(e,t)=>D(s=>({...s,[e]:t})),G=void 0!==L.type||void 0!==L.route||L.status&&"all"!==L.status||void 0!==L.signalMin||L.timeRange&&L.timeRange>0;return t.jsxs(k,{children:[t.jsx(S,{title:"Packet History",icon:t.jsx(d,{}),controls:t.jsxs(t.Fragment,{children:[a&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[t.jsx(c,{className:"w-1.5 h-1.5 fill-accent-success text-accent-success animate-pulse"}),t.jsx("span",{className:"text-text-muted hidden xs:inline",children:"Live"})]}),t.jsxs("button",{onClick:()=>C(!w),className:x("sm:hidden px-3 py-1.5 rounded-lg text-sm font-medium transition-all","flex items-center gap-1.5 border",G?"bg-accent-primary/20 text-accent-primary border-accent-primary/30":"bg-bg-subtle text-text-muted border-border-subtle"),children:[t.jsx(n,{className:"w-4 h-4"}),G&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),t.jsxs("button",{onClick:()=>l(!a),className:x("px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200","flex items-center gap-1.5 border",a?"bg-accent-success/20 text-accent-success border-accent-success/30":"bg-bg-subtle text-text-muted border-border-subtle hover:bg-bg-elevated"),children:[t.jsx(o,{className:x("w-4 h-4",a&&"animate-spin")}),t.jsx("span",{className:"hidden xs:inline",children:a?"Live":"Paused"})]})]})}),t.jsxs(R,{noPadding:!0,className:x("overflow-hidden transition-all duration-200",w?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[t.jsx(_,{listHeader:!0,icon:t.jsx(n,{className:"icon-sm"}),title:"Filters",actions:G?t.jsxs("button",{onClick:()=>D({limit:L.limit,status:"all"}),className:"type-data-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[t.jsx(m,{className:"w-3 h-3"})," Clear"]}):void 0}),t.jsx("div",{className:"p-3 sm:p-4",children:t.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Type"}),t.jsxs("select",{value:L.type??"",onChange:e=>z("type",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"All Types"}),Object.entries(g).map(([e,s])=>t.jsx("option",{value:e,children:s},e))]})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Route"}),t.jsxs("select",{value:L.route??"",onChange:e=>z("route",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"All Routes"}),Object.entries(j).map(([e,s])=>t.jsx("option",{value:e,children:s},e))]})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Status"}),t.jsxs("select",{value:L.status??"all",onChange:e=>z("status",e.target.value),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"all",children:"All Status"}),t.jsx("option",{value:"rx",children:"Received"}),t.jsx("option",{value:"forward",children:"Forwarded"}),t.jsx("option",{value:"dropped",children:"Dropped"}),t.jsx("option",{value:"duplicate",children:"Duplicate"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[100px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Time"}),t.jsxs("select",{value:L.timeRange??0,onChange:e=>z("timeRange",Number(e.target.value)||void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:0,children:"All Time"}),t.jsx("option",{value:1,children:"Last 1h"}),t.jsx("option",{value:6,children:"Last 6h"}),t.jsx("option",{value:24,children:"Last 24h"}),t.jsx("option",{value:168,children:"Last 7d"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[100px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),t.jsxs("select",{value:L.signalMin??"",onChange:e=>z("signalMin",e.target.value?Number(e.target.value):void 0),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:"",children:"Any Signal"}),t.jsx("option",{value:-90,children:"Strong (≥-90)"}),t.jsx("option",{value:-100,children:"Good (≥-100)"}),t.jsx("option",{value:-110,children:"Fair (≥-110)"}),t.jsx("option",{value:-120,children:"Weak (≥-120)"})]})]}),t.jsxs("div",{className:"flex-1 min-w-[80px]",children:[t.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),t.jsxs("select",{value:L.limit??100,onChange:e=>z("limit",Number(e.target.value)),className:"w-full bg-bg-subtle border border-border-subtle rounded-lg px-2.5 py-1.5 text-sm text-text-primary focus:outline-none focus:border-accent-primary/50",children:[t.jsx("option",{value:50,children:"50"}),t.jsx("option",{value:100,children:"100"}),t.jsx("option",{value:200,children:"200"}),t.jsx("option",{value:500,children:"500"})]})]})]})})]}),t.jsx(M,{packets:O}),t.jsxs(R,{noPadding:!0,children:[t.jsxs("div",{className:"sm:hidden flex items-center gap-1.5 px-3 py-2 border-b border-border-subtle bg-bg-elevated/30",children:[t.jsx("span",{className:"type-micro w-14 flex-shrink-0",children:"Dir"}),t.jsx("span",{className:"type-micro w-7 flex-shrink-0",children:"Time"}),t.jsx("span",{className:"type-micro w-9 flex-shrink-0",children:"Src"}),t.jsx("span",{className:"type-micro flex-1 min-w-0",children:"Type"}),t.jsx("span",{className:"type-micro w-14 flex-shrink-0",children:"Route"}),t.jsx("span",{className:"type-micro w-12 flex-shrink-0",children:"Signal"})]}),t.jsx("div",{className:"hidden sm:block overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-subtle bg-bg-elevated/30",children:[t.jsx("th",{className:"text-left py-2.5 px-3 type-micro w-16",children:"Dir"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Time"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Source"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Type"}),t.jsx("th",{className:"text-left py-2.5 px-3 type-micro",children:"Route"}),t.jsx("th",{className:"text-right py-2.5 px-3 pr-4 type-micro",children:"Signal"})]})}),t.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:B&&0===H.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"Loading packets..."})}):0===O.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"No packets found"})}):O.map((e,s)=>t.jsx(f,{packet:e,onClick:i,isFlashing:P(e)&&F===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))})]})}),t.jsx("div",{className:"sm:hidden divide-y divide-border-subtle/30",children:B&&0===H.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===O.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"No packets found"}):O.map((e,s)=>t.jsx(y,{packet:e,onClick:i,isFlashing:P(e)&&F===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))}),t.jsxs("div",{className:"px-3 py-2 border-t border-border-subtle type-data-xs text-text-muted bg-bg-elevated/20 sm:text-left text-center",children:["Showing ",O.length," of ",H.length," packets"]})]}),r&&t.jsx(N,{packet:r,onClose:()=>i(null)})]})}export{L as default}; diff --git a/frontend/dist/assets/Statistics-BHA07L60.js b/frontend/dist/assets/Statistics-BAtu1fRK.js similarity index 99% rename from frontend/dist/assets/Statistics-BHA07L60.js rename to frontend/dist/assets/Statistics-BAtu1fRK.js index 8adc4aa5..40dbc264 100644 --- a/frontend/dist/assets/Statistics-BHA07L60.js +++ b/frontend/dist/assets/Statistics-BAtu1fRK.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{j as n,r,aB as l,H as i,aC as o,aD as c,aE as d,aF as u,aG as m,aH as h,aI as x,aJ as p,aK as g,o as f,aL as b,aM as y,aN as v,aO as j,aP as N,aQ as w,a7 as k,aR as M,aj as C,h as S,ad as T,aS as P,ab as $,p as F,C as R,as as A}from"./vendor-react-O8XH9yVn.js";import{O as L,Q as D,S as E,U as B,V as _,q as H,W as z,X as O,B as W,Y as V,d as q,h as G,f as I,u as X,m as K,Z as Y,j as Q,_ as U}from"./index-Dp0UlTio.js";import{u as J}from"./usePolling-UdPi_fKb.js";import{a as Z,u as ee,b as te,c as se,d as ae,e as ne,s as re,p as le}from"./useThemeColors-CD0TSU03.js";import{c as ie,R as oe,d as ce,L as de,C as ue,X as me,Y as he,T as xe,a as pe}from"./recharts-BU7auunF.js";import{T as ge}from"./TimeRangeSelector-9pGCd7oa.js";import{a as fe,c as be,P as ye,b as ve}from"./PageLayout-DE5PEtD2.js";import{C as je}from"./CollisionExplorerModal-DEtEH0fD.js";import{R as Ne,C as we}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./leaflet-D_ckmI2R.js";function ke({children:e,centered:t,className:s}){return n.jsx("div",{className:ie("flex-1 min-h-0",t&&"flex items-center justify-center",s),children:e})}const Me={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Ce(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 Se(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:Ce(t,50),p90:Ce(t,90),p95:Ce(t,95),p99:Ce(t,99),max:t[t.length-1],min:t[0]}}function Te(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"}r.memo(function({options:e,data:t,className:s="",onCreate:a}){const l=r.useRef(null),i=r.useRef(null);return r.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({...e,width:r,height:o},t,s);return i.current=c,null==a||a(c),()=>{c.destroy(),i.current=null}},[e]),r.useEffect(()=>{i.current&&t&&i.current.setData(t)},[t]),r.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()}},[]),n.jsx("div",{ref:l,className:`w-full h-full ${s}`,style:{minHeight:100}})});const Pe=new Map;function $e(e){var t;if(!e.startsWith("var("))return e;const s=Pe.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 Pe.set(e,l),l}function Fe(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{x.current=e,p.current=t,g.current=a,f.current=s});const y=r.useRef({band:l,innerBand:i,mean:o,median:c,average:d,cursor:u});r.useLayoutEffect(()=>{y.current={band:l,innerBand:i,mean:o,median:c,average:d,cursor:u}});const v=r.useMemo(()=>[e.map(e=>e.timestamp),e.map(e=>e.max)],[e]),j=r.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,d=n.bbox,u=d.left,m=d.top,h=d.width,x=d.height;if(h<=0||x<=0)return;const p=n.data[0],g=p.length;if(0===g)return;const f=p[0],b=p[g-1]-f||1,y=e=>u+(e-f)/b*h,v=e=>m+x*(1-e/l),j={min:r.map(e=>({x:y(e.timestamp),y:v(e.min)})),max:r.map(e=>({x:y(e.timestamp),y:v(e.max)})),p5:r.map(e=>({x:y(e.timestamp),y:v(e.p5)})),p95:r.map(e=>({x:y(e.timestamp),y:v(e.p95)})),p25:r.map(e=>({x:y(e.timestamp),y:v(e.p25)})),p75:r.map(e=>({x:y(e.timestamp),y:v(e.p75)})),mean:r.map(e=>({x:y(e.timestamp),y:v(e.mean)})),median:r.map(e=>({x:y(e.timestamp),y:v(e.median)})),average:r.map(e=>({x:y(e.timestamp),y:v(e.average)}))},N=(e,t)=>i?i===e?Math.min(1,1.5*t):"minMax"===i||"p5p95"===i||"p25p75"===i?.3*t:t:t,w=e=>i?i===e?1:"mean"===i||"median"===i||"average"===i?.3:1:1,k={band:$e(o.band),innerBand:$e(o.innerBand),mean:$e(o.mean),median:$e(o.median),average:$e(o.average)};c.save(),c.strokeStyle=k.average,c.lineWidth=4,c.globalAlpha=w("average"),Fe(c,j.average),c.stroke(),c.globalAlpha=N("minMax",.15),c.fillStyle=k.band,c.beginPath(),Fe(c,j.max);const M=[...j.min].reverse();for(const e of M)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p5p95",.3),c.fillStyle=k.band,c.beginPath(),Fe(c,j.p95);const C=[...j.p5].reverse();for(const e of C)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p25p75",.55),c.fillStyle=k.innerBand,c.beginPath(),Fe(c,j.p75);const S=[...j.p25].reverse();for(const e of S)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=k.median,c.lineWidth=1.5,c.globalAlpha=w("median"),c.setLineDash([4,4]),Fe(c,j.median),c.stroke(),c.strokeStyle=k.mean,c.lineWidth=1.5,c.globalAlpha=w("mean"),c.setLineDash([]),Fe(c,j.mean),c.stroke(),c.restore()}}}}(x,p,g,y);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=f.current)||t.call(f,a):null==(s=f.current)||s.call(f,null)}]},plugins:[e]}},[t]);r.useEffect(()=>{const t=m.current;if(!t||0===e.length)return;const s=b.current,a=e.length,n=Math.abs(a-s);if(!(!h.current||n>100||s>0&&n/s>.1)&&h.current)return h.current.setData(v),void(b.current=a);h.current&&h.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new E({...j,width:l,height:i},v,t);return h.current=o,b.current=a,()=>{o.destroy(),h.current=null}},[j,v,e.length]),r.useEffect(()=>{const e=m.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!h.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&h.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.useEffect(()=>{h.current&&h.current.redraw()},[a,e]);const N=r.useCallback(()=>{null==s||s(null)},[s]);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:m,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:N})});const Re="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Ae(){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 Le=["min","max","p75","p95","p99","mean","median","average","midpoint"];let De=null,Ee=0;const Be={0:{r:0,g:144,b:255},7:{r:0,g:102,b:204},1:{r:102,g:204,b:255},3:{r:0,g:230,b:153},4:{r:255,g:242,b:0},2:{r:255,g:179,b:0},5:{r:255,g:128,b:192},6:{r:255,g:102,b:0},10:{r:179,g:179,b:179},15:{r:230,g:102,b:204},8:{r:102,g:179,b:255},9:{r:51,g:255,b:179},255:{r:128,g:128,b:128}};function _e(e){return Be[e]??Be[255]}function He(e){const t=Date.now();(!De||t-Ee>1e3)&&(De={green:{r:34,g:197,b:94,p3:"color(display-p3 0.13 0.77 0.37)"},good:{r:132,g:204,b:22,p3:"color(display-p3 0.52 0.80 0.09)"},fair:{r:250,g:204,b:21,p3:"color(display-p3 0.98 0.80 0.08)"},poor:{r:249,g:115,b:22,p3:"color(display-p3 0.98 0.45 0.09)"},critical:{r:239,g:68,b:68,p3:"color(display-p3 0.94 0.27 0.27)"}},Ee=t);const s=De;return e>=1?s.critical:e>=.75?s.poor:e>=.5?s.fair:e>=.25?s.good:s.green}function ze(e,t,s,a,n,r,l,i,o,c=null,d=null,u=1,m=null,h="airtime",x=.5){if(0===t.length)return;const p=e.ctx,{left:g,top:f,width:b,height:y}=e.bbox,v=window.devicePixelRatio||1;if(b<=0||y<=0)return;const j=e.data[0],N=j.length;if(0===N)return;const w=j[0],k=j[N-1],M=s,C="share"===h,S=C?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)}(M):5,T=getComputedStyle(document.documentElement),P=T.getPropertyValue("--signal-critical").trim()||"#EF4444",$=T.getPropertyValue("--bg-elevated").trim()||"#333233";p.save(),p.fillStyle="rgba(0, 0, 0, 0.4)";const F=8*v;if(p.beginPath(),p.roundRect(g,f,b,y,F),p.fill(),p.restore(),!C&&M>=20){p.save();const e=f+y*(1-20/M);p.fillStyle=$,p.globalAlpha=.5,p.fillRect(g,f,b,e-f),p.restore()}p.save(),p.lineWidth=1*v,p.setLineDash([4*v,4*v]);for(let A=S;As+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()}(p,m,g,f,b,y,v),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:d,rawValues:u,count:m,packetTypes:h,timestamps:x}=t,p=1*o*(window.devicePixelRatio||1);e.globalCompositeOperation="source-over";const g=l?parseInt(l.replace("TYPE_",""),10):null;for(let f=0;f=i.start&&e0&&function(e,t,s,a,n,r,l,i,o,c,d=.5){if(0===t.length)return;const u=o-i||1,m=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=d,e.fillStyle=Re?`color(display-p3 ${m.p3r} ${m.p3g} ${m.p3b})`:`rgb(${m.r}, ${m.g}, ${m.b})`;for(const h of t){if(h.endTso)continue;const t=a+(Math.max(h.startTs,i)-i)/u*r,s=a+(Math.min(h.endTs,o)-i)/u*r,d=Math.max(s-t,2*c);e.fillRect(t,n,d,l)}e.restore()}(p,i,0,g,f,b,y,w,k,v,d?Math.max(.03,.03*x):x)}const Oe=r.memo(function({data:e,maxValue:t,visibleLines:s=Le,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:d=.5,highlightedType:u=null,hoveredTimeRange:m=null,timeRangeHours:h=24,yAxisMode:x="airtime"}){const p=r.useRef(null),g=r.useRef(null),f=r.useRef(e),b=r.useRef(t),y=r.useRef(s),v=r.useRef(a),j=r.useRef(l),N=r.useRef(i),w=r.useRef(o),k=r.useRef(c),M=r.useRef(u),C=r.useRef(m),S=r.useRef(null),T=r.useRef(null),P=r.useRef(x),$=r.useRef(d),F=h<=12?1.2:1,R=r.useRef(F),A=r.useRef(e.length);r.useLayoutEffect(()=>{f.current=e,b.current=t,y.current=s,v.current=a,j.current=l,N.current=i,w.current=o,k.current=c,M.current=u,C.current=m,R.current=F,P.current=x,$.current=d}),r.useEffect(()=>{S.current=Ae()},[]);const L=r.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),D=r.useMemo(()=>({hooks:{draw:e=>{const t=S.current||Ae();ze(e,f.current,b.current,y.current,v.current,t,N.current,w.current,k.current,M.current,C.current,R.current,T.current,P.current,$.current)}}}),[]),B=r.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:[D]}),[D]);r.useEffect(()=>{const t=p.current;if(!t||0===e.length)return;const s=A.current,a=e.length,n=Math.abs(a-s);if(!(!g.current||n>100||s>0&&n/s>.1)&&g.current)return g.current.setData(L),void(A.current=a);g.current&&g.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new E({...B,width:l,height:i},L,t);return g.current=o,A.current=a,()=>{o.destroy(),g.current=null}},[B,L,e.length]),r.useEffect(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!g.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&g.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.useEffect(()=>{g.current&&g.current.redraw()},[a,s,e,i,o,c,d,u,m,F]);const _=r.useCallback(t=>{var s,a;const n=p.current,r=g.current;if(!n||!r||0===e.length)return;const l=n.getBoundingClientRect(),i=t.clientX-l.left,o=window.devicePixelRatio||1,c=r.bbox,d=c.left/o,u=c.width/o;if(id+u)return T.current=null,r.redraw(),void(null==(s=j.current)||s.call(j,null));T.current=i*o;const m=(i-d)/u,h=e.length,x=Math.floor(m*h),f=Math.max(0,Math.min(h-1,x));r.redraw(),null==(a=j.current)||a.call(j,f)},[e.length]),H=r.useCallback(()=>{var e;T.current=null,g.current&&g.current.redraw(),null==(e=j.current)||e.call(j,null)},[]);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:p,className:"w-full h-full rounded-lg overflow-hidden",onMouseMove:_,onMouseLeave:H})}),We={[B.REQ]:"var(--pkt-science-req)",[B.ANON_REQ]:"var(--pkt-science-anon-req)",[B.RESPONSE]:"var(--pkt-science-response)",[B.ACK]:"var(--pkt-science-ack)",[B.ADVERT]:"var(--pkt-science-advert)",[B.TXT_MSG]:"var(--pkt-science-txt-msg)",[B.GRP_TXT]:"var(--pkt-science-grp-txt)",[B.GRP_DATA]:"var(--pkt-science-grp-data)",[B.PATH]:"var(--pkt-science-path)",[B.TRACE]:"var(--pkt-science-trace)",[B.MULTIPART]:"var(--pkt-science-multipart)",[B.RAW_CUSTOM]:"var(--pkt-science-raw-custom)"},Ve="var(--pkt-science-unknown)";function qe(e){return"number"!=typeof e?Ve:We[e]??Ve}const Ge=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;const d=L(i);c.totalAirtime+=D(d,{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 Ie(e){return H[e]??`TYPE_${e.toString(16).toUpperCase()}`}const Xe={sf:10,bw:25e4,cr:5,preamble:8};function Ke(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{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 n.jsx("div",{className:"flex-shrink-0 pt-3 mt-2",children:n.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 r=qe(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,d=o?l:c,u=d>1e-4,m=t===e.key,h=t&&t!==e.key;let x="legend-item";return m?x+=" legend-item-active":h?x+=" legend-item-dimmed":o&&l>1e-4?x+=" legend-item-chart-active":o&&l<=1e-4&&(x+=" legend-item-dimmed"),n.jsxs("div",{className:x,onMouseEnter:()=>s(e.key),children:[n.jsx("div",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:r}}),n.jsx("span",{className:"legend-label",children:e.label}),u&&n.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*d).toFixed(1),"%"]})]},e.key)})})})}function Qe({x:e,y:t,width:s,height:a,name:r,size:l,index:i,depth:o,hoveredIndex:c,onHover:d,total:u,typeNum:m}){if(1!==o)return null;const h=null!==c&&!(c===i),x=qe(m),p=u>0?l/u*100:0,g=s>36&&a>20,f=s>36&&a>32;return n.jsxs("g",{onMouseEnter:e=>d(i,e),onMouseLeave:()=>d(null),style:{cursor:"default"},children:[n.jsx("rect",{x:e,y:t,width:s,height:a,fill:x,opacity:h?.4:1,stroke:"rgba(0,0,0,0.2)",strokeWidth:1,rx:3,style:{transition:"opacity 150ms ease"}}),g&&n.jsxs(n.Fragment,{children:[f&&n.jsxs("text",{x:e+4,y:t+a-4-11,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.6)",fontSize:8,fontFamily:"'JetBrains Mono', monospace",fontWeight:500,style:{pointerEvents:"none"},children:[p.toFixed(1),"%"]}),n.jsx("text",{x:e+4,y:t+a-4,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.85)",fontSize:9,fontFamily:"'JetBrains Mono', monospace",fontWeight:600,style:{pointerEvents:"none"},children:r})]})]})}function Ue({data:e,total:t,color:s,position:a,containerWidth:r}){if(!e||!a)return null;const l=(e.value/t*100).toFixed(1),i=r-a.x<184?Math.max(8,a.x-160-8):a.x+16;return n.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:i,top:Math.max(8,a.y-60)},children:n.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl min-w-[140px]",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:s}}),n.jsx("span",{className:"type-data-sm font-semibold text-text-primary",children:e.name})]}),n.jsxs("div",{className:"space-y-0.5 type-data-xs text-text-muted",children:[n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Count"}),n.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:e.value.toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Share"}),n.jsxs("span",{className:"text-text-primary tabular-nums font-medium",children:[l,"%"]})]}),n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Total"}),n.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:t.toLocaleString()})]})]})]})})}function Je({sortedTypes:e,aggregateShares:t}){var s,a,l;const[i,o]=r.useState(null),[c,d]=r.useState(null),[u,m]=r.useState(0),[h,x]=r.useState(null),p=r.useRef(null),f=r.useMemo(()=>e.reduce((e,t)=>e+t.totalCount,0),[e]),b=r.useMemo(()=>e.map((e,t)=>({name:e.label,size:e.totalCount,index:t,typeNum:e.typeNum,key:e.key})),[e]),y=r.useCallback((e,t)=>{if(o(e),t&&null!==e){const e=p.current;if(e){const s=e.getBoundingClientRect();m(s.width),d({x:t.clientX-s.left,y:t.clientY-s.top})}}else d(null)},[]),v=r.useCallback(e=>{if(x(e),e){const t=b.findIndex(t=>t.key===e);o(t>=0?t:null)}else o(null)},[b]),j=null!==i?{name:(null==(s=b[i])?void 0:s.name)??"",value:(null==(a=b[i])?void 0:a.size)??0}:null,N=null!==i?qe(null==(l=b[i])?void 0:l.typeNum):"";return 0===e.length||0===f?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet type data available"})]}):n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",ref:p,children:[n.jsx(oe,{width:"100%",height:"100%",children:n.jsx(ce,{data:b,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:n.jsx(Qe,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:i,onHover:y,total:f,typeNum:0})})}),n.jsx(Ue,{data:j,total:f,color:N,position:c,containerWidth:u})]}),n.jsx(Ye,{sortedTypes:e,highlightedType:h,onTypeHover:v,aggregateShares:t})]})}function Ze(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 et({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:l,radioConfig:i,sortedTypes:o,aggregateShares:c,noiseFloorAnomalies:d,showNoiseFloorOverlay:u,overlayOpacity:m=.5}){const[h,x]=r.useState(null),[p,f]=r.useState(null),b=r.useMemo(()=>(l-a)/3600,[a,l]),y=r.useCallback(e=>{f(e)},[]),v=function(e,t,s,a,n){return r.useMemo(()=>{if(0===e.length||!n)return null;const r=e.filter(e=>e.timestamp>=t&&e.timestamp<=s);if(0===r.length)return null;const l=[],i=new Map;for(const e of r){const s=e.type??e.payload_type??-1,r=L(e);let o;if(o="airtime"===a?D(r,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}):1,r<=0)continue;const c=Math.floor((e.timestamp-t)/300),d={timestamp:e.timestamp,airtimeMs:o,byteSize:r,packetType:s,bucketIndex:c};l.push(d),i.has(c)||i.set(c,[]),i.get(c).push(d)}if(0===l.length)return null;const o=[],c=[],d=[],u=new Map;if("share"===a)for(const[,e]of i)for(const t of e)u.set(t,t.byteSize);else for(const[,e]of i){const t=e.reduce((e,t)=>e+t.airtimeMs,0)/3e5*100,s=Math.max(...e.map(e=>e.airtimeMs));for(const a of e){const e=a.airtimeMs/s*t;u.set(a,e)}}for(const e of l){const t=u.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),d.push(e.packetType))}const m=Math.min(...c),h=Math.max(...c),x=h-m||1,p=[...o].sort((e,t)=>e-t),g=p[0],f=p[p.length-1],b=Math.floor(.05*p.length),y=Math.floor(.5*p.length),v=Math.min(Math.ceil(.95*p.length),p.length-1),j=p[b],N=p[y],w=p[v],k=new Map;for(const e of o){const t=Math.round(100*e)/100;k.set(t,(k.get(t)??0)+1)}const M=k.size,C=[...k.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let S;if("share"===a)S=200;else{const e=5,t=Math.ceil(f/e)*e;S=t<=10?10:t+e}const T=new Float32Array(2*o.length),P=new Float32Array(o.length),$=new Uint8Array(o.length),F=new Float32Array(o.length);for(let e=0;e=0?d[e]:255,F[e]=c[e]}return{points:T,rawValues:P,packetTypes:$,timestamps:F,count:o.length,minTime:m,maxTime:h,minValue:0,maxValue:S,rawMinValue:g,rawMaxValue:f,unit:"%",stats:{p5:j,p50:N,p95:w,uniqueValues:M,topValues:C}}},[e,t,s,a,n])}(s,a,l,"share"===t?"share":"airtime",i),{data:j}=r.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 d=0;dj.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})),[j]),w=r.useMemo(()=>(null==v?void 0:v.maxValue)?v.maxValue:"share"===t?200:10,[v,t]),k=r.useCallback(e=>{x(e)},[]),M=r.useMemo(()=>{if(null===h||!j[h])return null;const e=j[h];let t;t=b>=168?75:b>=72?35:b>=24?15:b>=3?10:5;const s=60*t/2,a=e.timestamp;return{start:a-s,end:a+s}},[h,j,b]),C=r.useMemo(()=>{if(null===h||!j[h]||!M)return null;const e=j[h].time,{start:a,end:n}=M,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:qe(e.typeNum)}))};const l=new Map,c=new Map;let d=0,u=0;for(const t of r){const e=`TYPE_${t.type??t.payload_type??-1}`;if(l.set(e,(l.get(e)??0)+1),d++,i){const s=L(t),a=D(s,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});c.set(e,(c.get(e)??0)+a),u+=a}}const m=o.map(e=>{let s;return s="airtime"===t?u>0?(c.get(e.key)??0)/u:0:d>0?(l.get(e.key)??0)/d:0,{key:e.key,label:e.label,value:s,color:qe(e.typeNum)}});return{timestamp:j[h].timestamp,timeLabel:e,items:m}},[h,j,M,s,o,t,i]);if(0===j.length)return n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]});const S=(null==C?void 0:C.timeLabel)??null;return n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",children:[n.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:n.jsx(Oe,{data:N,maxValue:w,onHover:k,scatterData:v,noiseFloorAnomalies:d,showNoiseFloorOverlay:u,overlayOpacity:m,highlightedType:p,hoveredTimeRange:M,timeRangeHours:b,yAxisMode:"share"===t?"share":"airtime"})}),S&&n.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:S})]}),n.jsx(Ye,{sortedTypes:o,highlightedType:p,onTypeHover:y,aggregateShares:c,hoverData:C})]})}function tt({active:e,payload:t,label:s,mode:a}){if(!e||!t||0===t.length)return null;const r=t.filter(e=>null!==e.value&&void 0!==e.value);if(0===r.length)return null;const l=s?new Date(1e3*s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):"";return n.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[n.jsx("div",{className:"font-medium text-text-primary mb-1 font-mono",children:l}),r.map((e,t)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-0.5",style:{backgroundColor:e.color}}),n.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),n.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 st(e){return e>=1e9?`${(e/1e9).toFixed(1)}G`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function at({packets:e,mode:t,startTs:s,endTs:a,radioConfig:l,bucketCount:i}){const o=ee(),c=te(),d=se(),u=c.critical,m=o.neutral,[h,x]=r.useState(null),{trendData:p,totals:b}=r.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0},actualBucketCount:0};const n=a-s,r=Math.min(Math.ceil(n/300),i),o=n/r,c=1e3*o,d=[];for(let e=0;e=a)continue;const n=Math.min(Math.floor((e-s)/o),r-1),i=L(t),c=D(i,{spreadingFactor:l.sf,bandwidthHz:l.bw,codingRate:l.cr,preambleLength:l.preamble});t.transmitted?(d[n].txBytes+=i,d[n].txAirtime+=c,m+=i,x+=c):(d[n].rxBytes+=i,d[n].rxAirtime+=c,u+=i,h+=c)}return{trendData:d.map(e=>{if("share"===t)return{timestamp:e.timestamp,rx:e.rxBytes>0?e.rxBytes:null,tx:e.txBytes>0?e.txBytes:null};{const t=c>0?e.rxAirtime/c*100:0,s=c>0?e.txAirtime/c*100:0;return{timestamp:e.timestamp,rx:t>0?t:null,tx:s>0?s:null}}}),totals:{rxBytes:u,txBytes:m,rxAirtime:h,txAirtime:x}}},[e,s,a,i,t,l,300]),y=r.useMemo(()=>{if(0===p.length)return"share"===t?100:10;let e=0;for(const t of p){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))},[p,t]),v=r.useMemo(()=>{if(null!==h&&p[h]){const e=p[h],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:st(s),tx:st(a),total:st(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:st(b.rxBytes),tx:st(b.txBytes),total:st(b.rxBytes+b.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of p)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}}},[h,p,b,t]),j=r.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}})},[s,a]),N=r.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;x("number"==typeof t?t:null)},[]),w=r.useMemo(()=>{const e=a-s,t=Math.round(e/3600);return t>=24?`${Math.round(t/24)}d`:`${t}h`},[s,a]),k=r.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===p.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsx("div",{className:"flex items-center flex-shrink-0 text-text-muted",style:{height:20,paddingLeft:44,paddingRight:8},children:n.jsx("div",{className:"relative w-full h-full flex items-center",children:j.map((e,t)=>n.jsxs("div",{className:"absolute flex items-center gap-1 type-data-xs",style:{left:100*e.pct+"%",transform:0===e.pct?"translateX(0)":1===e.pct?"translateX(-100%)":"translateX(-50%)"},children:[n.jsx(f,{className:"w-2.5 h-2.5 opacity-60"}),n.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),n.jsxs("div",{className:"flex-1 min-h-0 relative",children:[n.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 type-data-xs text-text-muted font-mono",style:{width:44},children:n.jsx("div",{className:"text-center",children:w})}),n.jsx(oe,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:n.jsxs(de,{data:p,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:N,onMouseLeave:()=>x(null),children:[n.jsx(ue,{strokeDasharray:"3 3",stroke:d.primary,strokeOpacity:.15,vertical:!1}),n.jsx(me,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),n.jsx(he,{axisLine:!1,tickLine:!1,tick:{fill:d.primary,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dx:-8,width:44,tickFormatter:k,domain:[0,y]}),n.jsx(xe,{content:n.jsx(tt,{mode:t})}),n.jsx(pe,{type:"linear",dataKey:"rx",name:"RX",stroke:u,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(pe,{type:"linear",dataKey:"tx",name:"TX",stroke:m,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1})]})})]}),n.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2",children:[n.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono pl-11",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:u}}),n.jsx("span",{className:"text-text-muted",children:"RX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:m}}),n.jsx("span",{className:"text-text-muted",children:"TX"})]}),n.jsx("span",{className:"text-text-muted",children:"share"===t?"Bytes":"Utilization"})]}),n.jsxs("div",{className:"text-right pr-2",children:[n.jsx("span",{className:"font-mono font-bold text-xl text-text-primary",children:v.total}),n.jsx("span",{className:"text-xs text-text-muted ml-2",children:v.isHovered?"bucket":"total"})]})]})]})}function nt({mode:e,onChange:t}){return n.jsxs("div",{className:"toggle-group toggle-group-sm",children:[n.jsx("button",{onClick:()=>t("share"),className:"toggle-group-item "+("share"===e?"active":""),children:"Total"}),n.jsx("button",{onClick:()=>t("airtime"),className:"toggle-group-item "+("airtime"===e?"active":""),children:"Airtime"})]})}function rt({enabled:e,onChange:t,anomalyCount:s=0,showTuning:a=!1,onTuningChange:r}){return n.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[e&&r&&n.jsx("button",{onClick:()=>r(!a),className:"toggle-group toggle-group-sm "+(a?"active":""),title:a?"Hide tuning panel":"Show tuning panel",children:n.jsx("span",{className:"toggle-group-item "+(a?"active":""),children:n.jsx(l,{className:"w-3.5 h-3.5"})})}),n.jsx("button",{onClick:()=>t(!e),className:"toggle-group toggle-group-sm "+(e?"active":""),title:e?"Hide noise floor anomalies":"Show noise floor anomalies",children:n.jsx("span",{className:"toggle-group-item "+(e?"active":""),children:n.jsx(i,{className:"w-3.5 h-3.5"})})}),s>0&&n.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})]})}function lt({smoothing:e,onChange:t}){return n.jsxs("div",{className:"toggle-group toggle-group-sm",children:[n.jsx("button",{onClick:()=>t("stats"),className:"toggle-group-item "+("stats"===e?"active":""),title:"Statistics view (scatter plot)",children:n.jsx(o,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("trend"),className:"toggle-group-item "+("trend"===e?"active":""),title:"Trend line chart",children:n.jsx(c,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("raw"),className:"toggle-group-item "+("raw"===e?"active":""),title:"No smoothing (raw values)",children:n.jsx(d,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("zlema"),className:"toggle-group-item "+("zlema"===e?"active":""),title:"6-period Zero-Lag EMA (light smoothing)",children:n.jsx(u,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"12-period Zero-Lag EMA (moderate smoothing)",children:n.jsx(m,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"24-period Zero-Lag EMA (heavy smoothing)",children:n.jsx(h,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"96-period Zero-Lag EMA (ultra smoothing)",children:n.jsx(x,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap chart)",children:n.jsx(p,{className:"w-3.5 h-3.5"})})]})}const it=r.memo(function({packets:e,startTs:t,endTs:s,bucketCount:a,radioConfig:l=Xe,mode:i="share",smoothing:o="raw",noiseFloorAnomalies:c=null,showNoiseFloorOverlay:d=!1,overlayOpacity:u=.5}){const m=Z(),[h,x]=r.useState(null),[p,f]=r.useState([]),b=r.useRef(null),y=r.useRef(0);r.useEffect(()=>{const t=Math.abs(e.length-y.current);if(0===t&&p.length>0)return;b.current&&clearTimeout(b.current);const s=t>100?50:500;return b.current=setTimeout(()=>{y.current=e.length,f(e)},s),()=>{b.current&&clearTimeout(b.current)}},[e,p.length]);const v=r.useMemo(()=>function(e){const t=new Map;for(const a of e){const e=a.type??a.payload_type??-1;t.set(e,(t.get(e)??0)+1)}const s=[];for(const[a,n]of t)s.push({typeNum:a,key:`TYPE_${a}`,label:Ie(a),totalCount:n});return s.sort((e,t)=>t.totalCount-e.totalCount)}(p),[p]),j=r.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=[];for(let d=0;d24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});c.push({timestamp:e,time:a,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o});for(const t of r)c[d].counts[t.key]=0,c[d].airtimes[t.key]=0}for(const d of e){const e=d.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${d.type??d.payload_type??-1}`;c[r].counts[l]=(c[r].counts[l]??0)+1,c[r].total++;const o=L(d),u=D(o,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});c[r].airtimes[l]=(c[r].airtimes[l]??0)+u,c[r].totalAirtime+=u}for(const d of c)for(const e of r)d.total>0?d.shares[e.key]=d.counts[e.key]/d.total*100:d.shares[e.key]=0;return c}(p,t,s,a,l,v),[p,t,s,a,l,v]),N=r.useMemo(()=>Ge.getBuckets(p,t,s,l),[p,t,s,l]),w=r.useMemo(()=>v.reduce((e,t)=>e+t.totalCount,0),[v]),{sortedTypes:k,aggregateShares:M}=r.useMemo(()=>{const e=new Map;if("share"===i){if(w>0)for(const t of v)e.set(t.key,t.totalCount/w)}else{let t=0;const s=new Map;for(const e of j){t+=e.totalAirtime;for(const t of v){const a=s.get(t.key)??0;s.set(t.key,a+(e.airtimes[t.key]??0))}}if(t>0)for(const a of v)e.set(a.key,(s.get(a.key)??0)/t)}return{sortedTypes:[...v].sort((t,s)=>{const a=e.get(t.key)??0;return(e.get(s.key)??0)-a}),aggregateShares:e}},[v,w,i,j]),C=r.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 m=0;m0?(e.counts[a]??0)/e.total:0}else{let t=0;for(let a=0;a0?r/t:0}}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let m=0;mfunction(e,t){switch(t){case"zlema":return Ke(e,6);case"ema":return Ke(e,12);case"smooth":return Ke(e,24);case"ultra":return Ke(e,96);default:return e}}(e,a)),d=Array.from({length:l},()=>new Array(r).fill(0));for(let m=0;m0?c[m-1][e]:0;let s=c[m][e]-t;s<0&&(s=0),s>1&&(s=1),d[m][e]=s}for(let m=0;m0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;e{x(e)},[]),[T,P]=r.useState(null),$=r.useCallback(e=>{P(e)},[]),F=r.useMemo(()=>{if(null===T||!C[T])return null;const e=C[T];return{timestamp:e.timestamp,timeLabel:e.time,items:k.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:qe(t.typeNum)}))}},[T,C,k]),R=r.useMemo(()=>({timestamps:C.map(e=>e.timestamp),series:k.map(e=>({key:e.key,label:e.label,color:qe(e.typeNum),values:C.map(t=>t[e.key]??0)}))}),[C,k]);return 0===p.length?0===e.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===o?n.jsx(Je,{sortedTypes:k,aggregateShares:M}):"stats"===o?n.jsx(et,{statsBuckets:N,mode:i,packets:p,startTs:t,endTs:s,radioConfig:l,sortedTypes:k,aggregateShares:M,noiseFloorAnomalies:c,showNoiseFloorOverlay:d,overlayOpacity:u}):"trend"===o?n.jsx(at,{packets:p,mode:i,startTs:t,endTs:s,radioConfig:l,bucketCount:a}):n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:"analyzer-chart-height relative flex-shrink-0",children:n.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:n.jsx(_,{timestamps:R.timestamps,series:R.series,highlightedKey:h,cursorColor:m.cursor,onHover:$})})}),n.jsx(Ye,{sortedTypes:k,highlightedType:h,onTypeHover:S,aggregateShares:M,hoverData:F})]})}),ot={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},ct=[1,5,10,25,50,100,150];function dt(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 ut(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 mt=[{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 ht(e,t){return t[re(e)]||"#808080"}const xt=r.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=r.useState(null),[c,d]=r.useState(new Set),[u,m]=r.useState({width:0,height:0}),[h,x]=r.useState("1x"),[p,g]=r.useState(1),f=r.useRef(null),y=r.useRef({}),v=r.useRef(null),j=r.useRef(null),N=r.useRef(p);N.current=p;const w=ae(),k=te(),M=ne(),C=se();r.useEffect(()=>{const e=j.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&&m({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&m({width:s.width,height:s.height}),()=>t.disconnect()},[]);const S=r.useMemo(()=>{const e=new Set;if(t)for(const s of t)e.add(s.hash);return e},[t]),T=r.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:P,maxDistance:$,totalNeighbors:F,zeroHopCount:R}=r.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=dt(s,a,l.latitude,l.longitude),n=ut(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]);r.useEffect(()=>{null==l||l({zeroHopCount:R,totalCount:F,maxDistanceKm:$})},[R,F,$]),r.useEffect(()=>{const e=ot[h],t=N.current;f.current&&cancelAnimationFrame(f.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;g(t+(e-t)*i),f.current=l<1?requestAnimationFrame(a):null};return f.current=requestAnimationFrame(a),()=>{f.current&&cancelAnimationFrame(f.current)}},[h]);const A=$/p,L=r.useMemo(()=>ct.filter(e=>e<=1.1*A),[A]);r.useEffect(()=>{const e=[];for(const s of P){const t=y.current[s.hash];void 0!==t&&t!==s.lastSeen&&e.push(s.hash),y.current[s.hash]=s.lastSeen}if(0===e.length)return;queueMicrotask(()=>{d(t=>new Set([...t,...e]))});const t=setTimeout(()=>{d(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[P]);const D=0!==s&&0!==a,E=r.useMemo(()=>{const{width:e,height:t}=u,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)}},[u]),{width:B,height:_,centerX:H,centerY:z,maxRadiusX:O,maxRadiusY:W,labelRadiusX:V,labelRadiusY:q,cornerRadius:G}=E,I=r.useCallback((e,t=1)=>{const s=O*t,a=W*t,n=Math.min(G*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(H-s+n,Math.min(H+s-n,H+a*e*(s/a))),c=z-a}else if(r>45-i&&r<=45+i)o=H+s-n+n*Math.sin(l),c=z-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(z-a+n,Math.min(z+a-n,z-s*e*(a/s))),o=H+s}else if(r>135-i&&r<=135+i)o=H+s-n+n*Math.sin(l),c=z+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(H-s+n,Math.min(H+s-n,H-a*e*(s/a))),c=z+a}else if(r>225-i&&r<=225+i)o=H-s+n+n*Math.sin(l),c=z+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(z-a+n,Math.min(z+a-n,z-s*e*(a/s))),o=H-s}else o=H-s+n+n*Math.sin(l),c=z-a+n-n*Math.cos(l);return{x:o,y:c}},[H,z,O,W,G]),X=r.useCallback((e,t)=>{const s=I(e,1);return{x:H+(s.x-H)*t,y:z+(s.y-z)*t}},[I,H,z]),K=r.useCallback(e=>({N:{x:H,y:z-q},S:{x:H,y:z+q},E:{x:H+V,y:z},W:{x:H-V,y:z},NE:{x:H+V,y:z-q},SE:{x:H+V,y:z+q},SW:{x:H-V,y:z+q},NW:{x:H-V,y:z-q}}[e]),[H,z,V,q]),Y=r.useCallback(e=>{const t=O*e,s=W*e,a=Math.min(G*e,t,s),n=H-t,r=H+t,l=z-s,i=z+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(" ")},[H,z,O,W,G]),Q=r.useCallback(e=>{o(e)},[]),U=r.useCallback(e=>{x(e)},[]),J=r.useCallback(e=>$<=0?0:e/$*p,[$,p]),Z=e=>`${e}km`,ee=r.useMemo(()=>{const e=L.map(e=>{const t=e/$*p;return{km:e,scale:t,labelY:z-W*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},[L,$,p,z,W]),re=u.width>0&&u.height>0;return D?0===F?n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-muted",children:[n.jsx(b,{className:"w-8 h-8 mb-2 opacity-50"}),n.jsx("p",{children:"No nodes with location data"})]}):n.jsxs("div",{ref:v,className:"relative h-full w-full flex overflow-hidden",children:[n.jsx("div",{ref:j,className:"relative flex-1 min-w-0 h-full",children:re&&n.jsxs("svg",{width:B,height:_,className:"absolute inset-0 z-0",children:[n.jsxs("defs",{children:[n.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 "}),n.jsx("clipPath",{id:"radar-clip",children:n.jsx("path",{d:Y(1)})})]}),L.map(e=>{const t=J(e);if(t>1.05||t<.02)return null;const s=ee.some(t=>t.km===e),a=H+O*t*.71,r=z-W*t*.71;return n.jsxs("g",{children:[n.jsx("path",{d:Y(t),fill:"none",stroke:C.primary,strokeOpacity:.15,strokeWidth:1}),s&&n.jsx("text",{x:a+4,y:r-2,textAnchor:"start",dominantBaseline:"auto",className:"fill-text-secondary",fontSize:10,fontFamily:"'JetBrains Mono', monospace",children:Z(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?H:"E"===e?H+O:H-O,a=t?"N"===e?z-W:z+W:z;return n.jsx("line",{x1:H,y1:z,x2:s,y2:a,stroke:C.primary,strokeOpacity:.15,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=K(e);return n.jsx("line",{x1:H,y1:z,x2:t.x,y2:t.y,stroke:C.primary,strokeOpacity:.08,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=K(e),s="E"===e?"end":"W"===e?"start":"middle",a="N"===e?"hanging":"S"===e?"auto":"middle";return n.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:k.critical,fontSize:16,fontWeight:600,fontFamily:"'JetBrains Mono', monospace","aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=K(e),s="NE"===e||"SE"===e?"end":"start",a="NE"===e||"NW"===e?"hanging":"auto";return n.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:k.critical,fontSize:16,fontWeight:600,fontFamily:"'JetBrains Mono', monospace","aria-hidden":"true",children:e},e)}),n.jsx("circle",{cx:H,cy:z,r:5,fill:M.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),n.jsx("g",{clipPath:"url(#radar-clip)",children:P.map(e=>{const t=$>0?e.distance/$*p:0;if(t>1)return null;const{x:s,y:a}=X(e.bearing,t),r=null!==e.snr?ht(e.snr,w):"#808080",l=(null==i?void 0:i.hash)===e.hash,o=c.has(e.hash);return n.jsxs("g",{role:"img","aria-label":`${e.name}: ${e.distance.toFixed(1)}km ${e.bearing.toFixed(0)}°`,children:[o&&n.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&&n.jsx("circle",{cx:s,cy:a,r:10.5,fill:r,opacity:.3}),n.jsx("circle",{cx:s,cy:a,r:l?7:5,fill:r,stroke:"rgba(0,0,0,0.5)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>Q(e),onMouseLeave:()=>Q(null)})]},e.hash)})})]})}),n.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=>n.jsx("button",{onClick:()=>U(e),"aria-pressed":h===e,className:"flex flex-1 items-center justify-center px-1.5 text-xs font-medium rounded transition-colors "+(h===e?"bg-accent-primary/20 text-accent-primary":"bg-white/5 text-text-muted hover:bg-white/10 hover:text-text-secondary"),children:e},e))}),i&&n.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:[n.jsx("div",{className:"font-medium text-text-primary",children:i.name}),n.jsx("div",{className:"text-text-muted text-xs font-mono",children:i.hash}),null!==i.snr?n.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"SNR:"})," ",n.jsxs("span",{className:"tabular-nums",style:{color:ht(i.snr,w)},children:[i.snr.toFixed(1)," dB"]}),n.jsxs("span",{className:"text-text-muted ml-1",children:["(",(le=i.snr,(null==(ie=mt.find(e=>le>=e.min))?void 0:ie.label)??"Critical"),")"]})]})}):n.jsx("div",{className:"text-xs text-text-muted mt-1",children:"No SNR data"}),n.jsxs("div",{className:"flex gap-3 text-xs",children:[n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"Distance:"})," ",n.jsxs("span",{className:"tabular-nums text-text-secondary",children:[i.distance.toFixed(2)," km"]})]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"Bearing:"})," ",n.jsxs("span",{className:"tabular-nums text-text-secondary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-muted",children:[n.jsx(b,{className:"w-8 h-8 mb-2 opacity-50"}),n.jsx("p",{children:"Local node coordinates not configured"}),n.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]});var le,ie});function pt(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 gt=r.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const i=te(),[o,c]=r.useState(!0),d=r.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:pt(n,5),p95:pt(n,95)}},[t]);r.useEffect(()=>{null==s||s(d)},[d]);const u=r.useCallback(()=>{c(e=>!e)},[]),{heatmapData:m,xLabels:h,yLabels:x}=r.useMemo(()=>{if(0===e.length||0===t.length||!d)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(d.p95-d.p5||1);s=d.p5-e,a=d.p95+e}else{const e=.1*(d.max-d.min||1);s=d.min-e,a=d.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;ole(j)??{r:225,g:38,b:114},[j]);return r.useEffect(()=>{const e=g.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&&b({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&b({width:s.width,height:s.height}),()=>t.disconnect()},[]),r.useEffect(()=>{const e=p.current;if(!e||!m||0===f.width)return;const t=e.getContext("2d");if(!t)return;const{width:s,height:a}=f,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{points:r,count:l}=m,{r:i,g:o,b:c}=N,d=Math.max(3,Math.min(8,s/l*4));t.globalCompositeOperation="source-over";for(let u=0;un.jsx("span",{className:"type-data-xs text-text-muted tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),n.jsxs("div",{ref:g,className:"absolute overflow-hidden",style:{left:32,right:0,top:0,bottom:20},children:[n.jsx("svg",{className:"absolute inset-0 w-full h-full",preserveAspectRatio:"none","aria-hidden":"true",children:[0,25,50,75,100].map(e=>n.jsx("line",{x1:"0",y1:`${e}%`,x2:"100%",y2:`${e}%`,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"3 3"},e))}),n.jsx("canvas",{ref:p,className:"absolute inset-0 w-full h-full","aria-hidden":"true"}),n.jsx("button",{type:"button",onClick:u,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?n.jsx(y,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"}):n.jsx(v,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"})})]}),n.jsx("div",{className:"absolute left-0 right-0 bottom-0",style:{left:32,height:20},"aria-hidden":"true",children:h.map((e,t)=>n.jsx("span",{className:"type-data-xs text-text-muted tabular-nums absolute top-1",style:{left:`${e.pos}%`,transform:"translateX(-50%)"},children:e.label},t))})]}):n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No noise floor data available"})}),ft={repeater:"var(--signal-critical)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function bt(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 yt=r.memo(function({neighbors:e}){const t=r.useMemo(()=>{const t={repeater:0,companion:0,room_server:0};for(const a of Object.values(e)){const e=bt(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:ft.repeater},{label:"Companions",count:t.companion,percent:0,color:ft.companion},{label:"Room Servers",count:t.room_server,percent:0,color:ft.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?n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted type-body-sm",children:"No neighbors discovered yet"}):n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:t.items.map(e=>n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"type-data-sm text-text-secondary",children:e.label}),n.jsxs("span",{className:"type-data-sm text-text-muted tabular-nums",children:[e.count," ",n.jsxs("span",{className:"text-text-muted/60",children:["(",e.percent.toFixed(0),"%)"]})]})]}),n.jsx("div",{className:"h-2.5 bg-bg-elevated rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${e.percent}%`,backgroundColor:e.color,minWidth:e.count>0?"4px":"0"}})})]},e.label))}),n.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border-subtle",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Total Nodes"}),n.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function vt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=r.useRef(null),[o,c]=r.useState(!1),[d,u]=r.useState(!1);r.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{const t=e.isIntersecting;u(t),t&&c(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>{t.disconnect()}},[s]);const m=d||a&&o;return n.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:m?e:n.jsx("div",{className:"h-full w-full flex items-center justify-center text-text-muted/50",children:n.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const jt={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-critical"},Nt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-signal-critical/10"},wt={excellent:"bg-signal-excellent",good:"bg-signal-good",fair:"bg-signal-fair",poor:"bg-signal-critical"};function kt({value:e,status:t}){return n.jsx("div",{className:"w-full h-2 bg-surface-elevated rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${wt[t]} transition-all duration-300`,style:{width:`${Math.min(100,Math.max(0,e))}%`}})})}function Mt(){const e=z(),t=O(),[s,a]=r.useState(null),l=r.useCallback((e,t)=>{a({prefix:e,candidateHashes:t})},[]),i=r.useCallback(()=>{a(null)},[]);if(!t)return n.jsxs(fe,{children:[n.jsx(be,{icon:n.jsx(j,{}),title:"Prefix Conflicts",largeTitle:!0}),n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-text-muted",children:[n.jsx(N,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{className:"type-data-xs",children:"No topology data available"}),n.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 d=(u=e.collisionRate)<=10?"excellent":u<=25?"good":"poor";var u;const m="poor"===o||"poor"===d?"poor":"fair"===o||"fair"===d?"fair":"good"===o||"good"===d?"good":"excellent",h="excellent"===m||"good"===m?w:k;return n.jsxs(fe,{className:"flex flex-col overflow-hidden",children:[n.jsx(be,{icon:n.jsx(j,{}),title:"Prefix Conflicts",largeTitle:!0,actions:n.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Nt[m]}`,children:[n.jsx(h,{className:`w-3.5 h-3.5 ${jt[m]}`}),n.jsx("span",{className:`type-data-xs font-medium ${jt[m]}`,children:"excellent"===m?"Excellent":"good"===m?"Good":"fair"===m?"Fair":"Needs Attention"})]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[n.jsxs("div",{className:"cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification. Based on geographic proximity, co-occurrence patterns, and observation recency.",children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Avg Confidence"}),n.jsxs("span",{className:`type-data-lg font-semibold ${jt[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),n.jsx(kt,{value:100*e.avgConfidence,status:o})]}),n.jsxs("div",{className:"cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better. Collisions require disambiguation to determine the correct node.",children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Collision Rate"}),n.jsxs("span",{className:`type-data-lg font-semibold ${jt[d]}`,children:[e.collisionRate.toFixed(1),"%"]})]}),n.jsx(kt,{value:e.collisionRate,status:d})]})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3",children:[n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Total unique 2-character prefixes observed in packet paths. Each prefix represents the first 2 hex digits of a node's full hash.",children:[n.jsx("div",{className:"type-data-lg font-semibold text-text-primary",children:e.totalPrefixes}),n.jsx("div",{className:"type-data-xs text-text-muted",children:"Prefixes"})]}),n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Prefixes that map to exactly one known node. No disambiguation needed—these are definitive identifications.",children:[n.jsx("div",{className:"type-data-lg font-semibold text-signal-good",children:e.unambiguousPrefixes}),n.jsx("div",{className:"type-data-xs text-text-muted",children:"Unique"})]}),n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates and see how disambiguation scores them.",children:[n.jsx("div",{className:"type-data-lg font-semibold "+(e.collisionPrefixes>0?"text-signal-critical":"text-text-primary"),children:e.collisionPrefixes}),n.jsx("div",{className:"type-data-xs "+(e.collisionPrefixes>0?"text-signal-critical":"text-text-muted"),children:"Collisions"})]})]}),e.highCollisionPrefixes.length>0&&n.jsxs("div",{className:"mb-2",children:[n.jsx("div",{className:"type-data-xs text-text-muted mb-1.5",children:"Highest Collisions"}),n.jsx("div",{className:"flex flex-wrap gap-1",children:e.highCollisionPrefixes.map(({prefix:e,candidateCount:t,candidateHashes:s})=>n.jsxs("button",{type:"button",onClick:()=>l(e,s),className:"inline-flex items-center gap-1 px-1.5 py-0.5 min-h-[24px] rounded bg-surface-elevated text-text-secondary type-data-xs font-mono hover:bg-signal-critical/20 hover:text-signal-critical focus:outline-none focus:ring-2 focus:ring-signal-critical/50 transition-colors cursor-pointer touch-manipulation",title:`Click to explore ${t} candidates matching this prefix`,"aria-label":`Explore prefix ${e} with ${t} colliding candidates`,children:[e,n.jsxs("span",{className:"text-signal-critical",children:["×",t]})]},e))})]}),e.lowConfidencePrefixes.length>0&&n.jsx("div",{className:"mt-auto pt-2",children:n.jsxs("div",{className:"flex items-start gap-1.5",children:[n.jsx(k,{className:"w-3.5 h-3.5 text-signal-critical mt-0.5 flex-shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"type-data-xs text-signal-critical font-medium",children:[n.jsx("span",{className:"text-signal-critical",children:e.lowConfidencePrefixes.length})," prefix",1!==e.lowConfidencePrefixes.length?"es":""," with low confidence"]}),n.jsxs("div",{className:"type-data-xs text-text-muted font-mono truncate",children:[e.lowConfidencePrefixes.slice(0,5).join(", "),e.lowConfidencePrefixes.length>5&&n.jsxs("span",{className:"text-signal-critical",children:[" +",e.lowConfidencePrefixes.length-5," more"]})]})]})]})}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&n.jsx("div",{className:"mt-auto pt-2",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(w,{className:"w-3.5 h-3.5 text-signal-excellent"}),n.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})})]}),n.jsx(je,{isOpen:!!s,prefix:(null==s?void 0:s.prefix)||"",candidateHashes:(null==s?void 0:s.candidateHashes)||[],onClose:i})]})}function Ct({icon:e,label:t,value:s,sublabel:a,highlight:r,tooltip:l}){return n.jsxs("div",{className:"flex items-center justify-between py-2 "+(l?"cursor-help":""),title:l,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"icon-xs text-icon-widget",children:e}),n.jsx("span",{className:"type-label text-text-secondary",children:t})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("span",{className:"type-data-sm "+(r?"text-accent-tertiary":"text-text-primary"),children:s}),a&&n.jsx("span",{className:"type-data-xs text-text-muted ml-1",children:a})]})]})}function St(){const e=W(),t=V().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:r,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:d,echolocationEdgesInferred:u}=e,m=s>0?((s-a)/s*100).toFixed(1):"0",h=s>0?(a/s*100).toFixed(1):"0",p=s>0?(r/s*100).toFixed(1):"0",g=l+i,f=g>0||o>0,b=c>0||u>0;return n.jsxs(fe,{children:[n.jsx(be,{title:"Path Decoder",icon:n.jsx(M,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),n.jsxs(ke,{children:[n.jsx("p",{className:"type-data-xs text-text-muted mb-3",children:"Decodes packet routes to map your mesh topology and discover hidden repeaters."}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(C,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${m}%`,sublabel:`of ${s.toLocaleString()} paths`,highlight:parseFloat(m)>=90,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),n.jsx(Ct,{icon:n.jsx(S,{className:"w-3.5 h-3.5"}),label:"Hidden Nodes",value:a.toLocaleString(),sublabel:`paths (${h}%)`,highlight:a>0,tooltip:"Paths containing unidentified repeaters. These 'ghost' nodes forward traffic but haven't announced themselves via ADVERT — possibly distant or newly added nodes."}),n.jsx(Ct,{icon:n.jsx(T,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${p}%`,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."})]}),f&&n.jsxs("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[n.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(P,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:g.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."}),n.jsx(Ct,{icon:n.jsx($,{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."})]})]}),b&&n.jsxs("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[n.jsx("p",{className:"type-micro mb-2",children:"Echo Analysis"}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(F,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:d>0?`(${d} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),n.jsx(Ct,{icon:n.jsx(x,{className:"w-3.5 h-3.5"}),label:"Inferred Links",value:u.toLocaleString(),highlight:u>0,tooltip:"Connections discovered from echo patterns. When the same packet arrives via different forwarders nearly simultaneously, those forwarders likely hear each other."})]})]}),t>0&&n.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle cursor-help",title:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map.",children:n.jsxs("p",{className:"type-label text-text-muted",children:[n.jsx("span",{className:"text-accent-tertiary type-data-sm",children:t})," ","likely repeater",1!==t?"s":""," discovered from traffic patterns"]})})]})]})}function Tt(){var e,t,s,a,l,i,o,c,d,u,m,h,x,p,f,y,v;const j=q(),N=G(),w=I(),k=X(),M=K(),[C,S]=r.useState([]),[T,P]=r.useState(null),[$,L]=r.useState(null),[D,E]=r.useState(!0),[B,_]=r.useState(null),[H,z]=r.useState(5),[O,W]=r.useState("share"),[V,Z]=r.useState("stats"),[ee,te]=r.useState(!1),[se,ae]=r.useState(!1),[ne,re]=r.useState(Me),[le,ie]=r.useState(.5),oe=Y[H].hours,ce=60*oe,de=Y[H],ue=U(oe),me=r.useCallback(e=>{r.startTransition(()=>z(e))},[]),he=r.useMemo(()=>{var e;if(!(null==(e=null==j?void 0:j.config)?void 0:e.radio))return null;const t=j.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==j?void 0:j.config)?void 0:e.radio)?void 0:t.spreading_factor,null==(a=null==(s=null==j?void 0:j.config)?void 0:s.radio)?void 0:a.bandwidth,null==(i=null==(l=null==j?void 0:j.config)?void 0:l.radio)?void 0:i.coding_rate,null==(c=null==(o=null==j?void 0:j.config)?void 0:o.radio)?void 0:c.preamble_length]);r.useEffect(()=>{!async function(){var e;_(null);try{const t=await Q(oe);t.success&&(null==(e=t.data)?void 0:e.history)&&S(t.data.history)}catch(t){_(t instanceof Error?t.message:"Failed to load chart data")}finally{E(!1)}}()},[oe]);const xe=r.useMemo(()=>72===oe?6e5:168===oe?18e5:336===oe?36e5:3e5,[oe]),pe=r.useCallback(async()=>{var e;try{const t=await Q(oe);t.success&&(null==(e=t.data)?void 0:e.history)&&S(t.data.history)}catch{}},[oe]);J(pe,xe,!0,!0);const je=r.useMemo(()=>0===C.length?{timestamps:[],values:[]}:{timestamps:C.map(e=>e.timestamp),values:C.map(e=>e.noise_floor_dbm)},[C]),ke=r.useMemo(()=>{if(C.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Me,...t};if(e.length<10)return{anomalies:[],thresholds:Se([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=Se(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=Ce(r,s.baselinePercentile),i=Ce(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let d=null,u=0;for(const m of o)if(m.noise_floor_dbm>l&&m.noise_floor_dbme+t,0)/d.values.length):(d.values.length>=s.minSequenceLength&&c.push(d),d={startTs:m.timestamp,endTs:m.timestamp,values:[m.noise_floor_dbm],timestamps:[m.timestamp],rollingAvg:m.noise_floor_dbm})}else d={startTs:m.timestamp,endTs:m.timestamp,values:[m.noise_floor_dbm],timestamps:[m.timestamp],rollingAvg:m.noise_floor_dbm};else d&&d.values.length>=s.minSequenceLength&&c.push(d),d=null;return d&&d.values.length>=s.minSequenceLength&&c.push(d),0===c.length?{anomalies:[],thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}:{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:Te(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}}(C,ne);return{anomalies:e.anomalies,debug:e.debug}},[C,ne]),Pe=ke.anomalies,$e=r.useMemo(()=>{const e=(null==j?void 0:j.neighbors)??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!N.has(e)))},[null==j?void 0:j.neighbors,N]),Fe=r.useMemo(()=>{const e=Date.now()/1e3-3600*oe;return Object.fromEntries(Object.entries($e).filter(([,t])=>t.last_seen>=e))},[$e,oe]),Re=r.useMemo(()=>{const e=60*ce/ue,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*ce,end:s}},[ce,ue]);return n.jsxs(ye,{children:[n.jsx(ve,{title:"Statistics",icon:n.jsx(R,{}),controls:n.jsx(ge,{ranges:Y,selectedIndex:H,onSelect:me})}),B&&n.jsx(fe,{className:"border border-accent-red/50 bg-accent-red/10",children:n.jsx("p",{className:"text-accent-red",children:B})}),ee&&se&&n.jsxs(fe,{className:"border border-accent-purple/30 bg-glass-surface/50",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),n.jsxs("span",{className:"type-data-xs text-text-muted",children:["(",de.label,")"]})]}),n.jsx("button",{onClick:()=>re(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(ne.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:ne.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Baseline"}),n.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(u=null==(d=ke.debug)?void 0:d.baselineCutoff)?void 0:u.toFixed(1))??"—"," dBm"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Spike"}),n.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(h=null==(m=ke.debug)?void 0:m.spikeCutoff)?void 0:h.toFixed(1))??"—"," dBm"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Mid-band"}),n.jsx("span",{className:"ml-2 type-data-sm text-accent-purple",children:(null==(x=ke.debug)?void 0:x.midBandSamples)??0})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Anomalies"}),n.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:Pe.length})]})]}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[ne.useAbsoluteThresholds?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",ne.baselineDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-120",max:"-60",value:ne.baselineDbm,onChange:e=>re(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",ne.spikeDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-100",max:"-20",value:ne.spikeDbm,onChange:e=>re(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",ne.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:ne.mergeGapSeconds,onChange:e=>re(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",ne.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:ne.minSequenceLength,onChange:e=>re(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",ne.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:ne.similarityToleranceDbm,onChange:e=>re(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*le),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:le,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",ne.baselinePercentile,")"]}),n.jsx("input",{type:"range",min:"1",max:"50",value:ne.baselinePercentile,onChange:e=>re(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",ne.spikePercentile,")"]}),n.jsx("input",{type:"range",min:"50",max:"99",value:ne.spikePercentile,onChange:e=>re(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",ne.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:ne.mergeGapSeconds,onChange:e=>re(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",ne.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:ne.minSequenceLength,onChange:e=>re(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",ne.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:ne.similarityToleranceDbm,onChange:e=>re(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*le),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:le,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}),n.jsxs("div",{className:"mt-4 p-3 bg-glass-elevated rounded-lg",children:[n.jsx("div",{className:"type-micro mb-1",children:"Config output"}),n.jsxs("div",{className:"type-data-sm text-status-success",children:[ne.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${ne.baselineDbm}, spikeDbm: ${ne.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${ne.baselinePercentile}, spikePercentile: ${ne.spikePercentile}`,", mergeGapSeconds: ",ne.mergeGapSeconds,", minSequenceLength: ",ne.minSequenceLength,", similarityToleranceDbm: ",ne.similarityToleranceDbm]})]})]})]}),D?n.jsx(Ne,{template:"auto",children:n.jsx(fe,{className:"text-center py-12",children:n.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading statistics..."})})}):n.jsxs(n.Fragment,{children:[n.jsx(Ne,{template:"hero-auto",children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(g,{}),title:"Packet Analyzer",badge:de.label,largeTitle:!0,actions:n.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&n.jsx(rt,{enabled:ee,onChange:te,anomalyCount:Pe.length,showTuning:se,onTuningChange:ae}),n.jsx(lt,{smoothing:V,onChange:Z}),n.jsx(nt,{mode:O,onChange:W})]})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(it,{packets:k,startTs:Re.start,endTs:Re.end,bucketCount:ue,radioConfig:he??void 0,mode:O,smoothing:V,noiseFloorAnomalies:Pe,showNoiseFloorOverlay:ee,overlayOpacity:le})})]})})}),n.jsxs(Ne,{template:"panel",children:[n.jsx(we,{span:12,md:6,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(b,{}),title:"Link Quality",badge:de.label,largeTitle:!0,actions:$?n.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 type-data-xs text-text-muted",children:[n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.zeroHopCount})," nbr"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.totalCount})," obs"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.maxDistanceKm.toFixed(0)})," km"]})]}):null}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(xt,{neighbors:Fe,quickNeighbors:w,localLat:(null==(f=null==(p=null==j?void 0:j.config)?void 0:p.repeater)?void 0:f.latitude)??0,localLon:(null==(v=null==(y=null==j?void 0:j.config)?void 0:y.repeater)?void 0:v.longitude)??0,onStatsChange:L})})})]})})}),n.jsx(we,{span:12,md:6,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(A,{}),title:"Network Composition",badge:de.label,largeTitle:!0}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(yt,{neighbors:Fe})})})]})})})]}),n.jsxs(Ne,{template:"panel",children:[n.jsx(we,{span:12,md:6,children:n.jsx(Mt,{})}),n.jsx(we,{span:12,md:6,children:n.jsx(St,{})})]}),n.jsx(Ne,{template:"panel",children:n.jsx(we,{span:12,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(F,{}),title:"RF Noise Floor",largeTitle:!0,actions:T?n.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 md:gap-3",children:[n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["min ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.min.toFixed(0)})]}),n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["avg ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.avg.toFixed(0)})]}),n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["max ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.max.toFixed(0)})]}),n.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})]}):n.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(gt,{timestamps:je.timestamps,values:je.values,onStatsChange:P})})})]})})})})]})]})}export{Tt 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{j as n,r,aB as l,H as i,aC as o,aD as c,aE as d,aF as u,aG as m,aH as h,aI as x,aJ as p,aK as g,o as f,aL as b,aM as y,aN as v,aO as j,aP as N,aQ as w,a7 as k,aR as M,aj as C,h as S,ad as T,aS as P,ab as $,p as F,C as R,as as A}from"./vendor-react-O8XH9yVn.js";import{O as L,Q as D,S as E,U as B,V as _,q as H,W as z,X as O,B as W,Y as V,d as q,h as G,f as I,u as X,m as K,Z as Y,j as Q,_ as U}from"./index-DGrzd8xb.js";import{u as J}from"./usePolling-UdPi_fKb.js";import{a as Z,u as ee,b as te,c as se,d as ae,e as ne,s as re,p as le}from"./useThemeColors-CD0TSU03.js";import{c as ie,R as oe,d as ce,L as de,C as ue,X as me,Y as he,T as xe,a as pe}from"./recharts-BU7auunF.js";import{T as ge}from"./TimeRangeSelector-9pGCd7oa.js";import{a as fe,c as be,P as ye,b as ve}from"./PageLayout-DE5PEtD2.js";import{C as je}from"./CollisionExplorerModal-dc7PClY6.js";import{R as Ne,C as we}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./leaflet-D_ckmI2R.js";function ke({children:e,centered:t,className:s}){return n.jsx("div",{className:ie("flex-1 min-h-0",t&&"flex items-center justify-center",s),children:e})}const Me={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Ce(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 Se(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:Ce(t,50),p90:Ce(t,90),p95:Ce(t,95),p99:Ce(t,99),max:t[t.length-1],min:t[0]}}function Te(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"}r.memo(function({options:e,data:t,className:s="",onCreate:a}){const l=r.useRef(null),i=r.useRef(null);return r.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({...e,width:r,height:o},t,s);return i.current=c,null==a||a(c),()=>{c.destroy(),i.current=null}},[e]),r.useEffect(()=>{i.current&&t&&i.current.setData(t)},[t]),r.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()}},[]),n.jsx("div",{ref:l,className:`w-full h-full ${s}`,style:{minHeight:100}})});const Pe=new Map;function $e(e){var t;if(!e.startsWith("var("))return e;const s=Pe.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 Pe.set(e,l),l}function Fe(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{x.current=e,p.current=t,g.current=a,f.current=s});const y=r.useRef({band:l,innerBand:i,mean:o,median:c,average:d,cursor:u});r.useLayoutEffect(()=>{y.current={band:l,innerBand:i,mean:o,median:c,average:d,cursor:u}});const v=r.useMemo(()=>[e.map(e=>e.timestamp),e.map(e=>e.max)],[e]),j=r.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,d=n.bbox,u=d.left,m=d.top,h=d.width,x=d.height;if(h<=0||x<=0)return;const p=n.data[0],g=p.length;if(0===g)return;const f=p[0],b=p[g-1]-f||1,y=e=>u+(e-f)/b*h,v=e=>m+x*(1-e/l),j={min:r.map(e=>({x:y(e.timestamp),y:v(e.min)})),max:r.map(e=>({x:y(e.timestamp),y:v(e.max)})),p5:r.map(e=>({x:y(e.timestamp),y:v(e.p5)})),p95:r.map(e=>({x:y(e.timestamp),y:v(e.p95)})),p25:r.map(e=>({x:y(e.timestamp),y:v(e.p25)})),p75:r.map(e=>({x:y(e.timestamp),y:v(e.p75)})),mean:r.map(e=>({x:y(e.timestamp),y:v(e.mean)})),median:r.map(e=>({x:y(e.timestamp),y:v(e.median)})),average:r.map(e=>({x:y(e.timestamp),y:v(e.average)}))},N=(e,t)=>i?i===e?Math.min(1,1.5*t):"minMax"===i||"p5p95"===i||"p25p75"===i?.3*t:t:t,w=e=>i?i===e?1:"mean"===i||"median"===i||"average"===i?.3:1:1,k={band:$e(o.band),innerBand:$e(o.innerBand),mean:$e(o.mean),median:$e(o.median),average:$e(o.average)};c.save(),c.strokeStyle=k.average,c.lineWidth=4,c.globalAlpha=w("average"),Fe(c,j.average),c.stroke(),c.globalAlpha=N("minMax",.15),c.fillStyle=k.band,c.beginPath(),Fe(c,j.max);const M=[...j.min].reverse();for(const e of M)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p5p95",.3),c.fillStyle=k.band,c.beginPath(),Fe(c,j.p95);const C=[...j.p5].reverse();for(const e of C)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p25p75",.55),c.fillStyle=k.innerBand,c.beginPath(),Fe(c,j.p75);const S=[...j.p25].reverse();for(const e of S)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=k.median,c.lineWidth=1.5,c.globalAlpha=w("median"),c.setLineDash([4,4]),Fe(c,j.median),c.stroke(),c.strokeStyle=k.mean,c.lineWidth=1.5,c.globalAlpha=w("mean"),c.setLineDash([]),Fe(c,j.mean),c.stroke(),c.restore()}}}}(x,p,g,y);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=f.current)||t.call(f,a):null==(s=f.current)||s.call(f,null)}]},plugins:[e]}},[t]);r.useEffect(()=>{const t=m.current;if(!t||0===e.length)return;const s=b.current,a=e.length,n=Math.abs(a-s);if(!(!h.current||n>100||s>0&&n/s>.1)&&h.current)return h.current.setData(v),void(b.current=a);h.current&&h.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new E({...j,width:l,height:i},v,t);return h.current=o,b.current=a,()=>{o.destroy(),h.current=null}},[j,v,e.length]),r.useEffect(()=>{const e=m.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!h.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&h.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.useEffect(()=>{h.current&&h.current.redraw()},[a,e]);const N=r.useCallback(()=>{null==s||s(null)},[s]);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:m,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:N})});const Re="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Ae(){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 Le=["min","max","p75","p95","p99","mean","median","average","midpoint"];let De=null,Ee=0;const Be={0:{r:0,g:144,b:255},7:{r:0,g:102,b:204},1:{r:102,g:204,b:255},3:{r:0,g:230,b:153},4:{r:255,g:242,b:0},2:{r:255,g:179,b:0},5:{r:255,g:128,b:192},6:{r:255,g:102,b:0},10:{r:179,g:179,b:179},15:{r:230,g:102,b:204},8:{r:102,g:179,b:255},9:{r:51,g:255,b:179},255:{r:128,g:128,b:128}};function _e(e){return Be[e]??Be[255]}function He(e){const t=Date.now();(!De||t-Ee>1e3)&&(De={green:{r:34,g:197,b:94,p3:"color(display-p3 0.13 0.77 0.37)"},good:{r:132,g:204,b:22,p3:"color(display-p3 0.52 0.80 0.09)"},fair:{r:250,g:204,b:21,p3:"color(display-p3 0.98 0.80 0.08)"},poor:{r:249,g:115,b:22,p3:"color(display-p3 0.98 0.45 0.09)"},critical:{r:239,g:68,b:68,p3:"color(display-p3 0.94 0.27 0.27)"}},Ee=t);const s=De;return e>=1?s.critical:e>=.75?s.poor:e>=.5?s.fair:e>=.25?s.good:s.green}function ze(e,t,s,a,n,r,l,i,o,c=null,d=null,u=1,m=null,h="airtime",x=.5){if(0===t.length)return;const p=e.ctx,{left:g,top:f,width:b,height:y}=e.bbox,v=window.devicePixelRatio||1;if(b<=0||y<=0)return;const j=e.data[0],N=j.length;if(0===N)return;const w=j[0],k=j[N-1],M=s,C="share"===h,S=C?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)}(M):5,T=getComputedStyle(document.documentElement),P=T.getPropertyValue("--signal-critical").trim()||"#EF4444",$=T.getPropertyValue("--bg-elevated").trim()||"#333233";p.save(),p.fillStyle="rgba(0, 0, 0, 0.4)";const F=8*v;if(p.beginPath(),p.roundRect(g,f,b,y,F),p.fill(),p.restore(),!C&&M>=20){p.save();const e=f+y*(1-20/M);p.fillStyle=$,p.globalAlpha=.5,p.fillRect(g,f,b,e-f),p.restore()}p.save(),p.lineWidth=1*v,p.setLineDash([4*v,4*v]);for(let A=S;As+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()}(p,m,g,f,b,y,v),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:d,rawValues:u,count:m,packetTypes:h,timestamps:x}=t,p=1*o*(window.devicePixelRatio||1);e.globalCompositeOperation="source-over";const g=l?parseInt(l.replace("TYPE_",""),10):null;for(let f=0;f=i.start&&e0&&function(e,t,s,a,n,r,l,i,o,c,d=.5){if(0===t.length)return;const u=o-i||1,m=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=d,e.fillStyle=Re?`color(display-p3 ${m.p3r} ${m.p3g} ${m.p3b})`:`rgb(${m.r}, ${m.g}, ${m.b})`;for(const h of t){if(h.endTso)continue;const t=a+(Math.max(h.startTs,i)-i)/u*r,s=a+(Math.min(h.endTs,o)-i)/u*r,d=Math.max(s-t,2*c);e.fillRect(t,n,d,l)}e.restore()}(p,i,0,g,f,b,y,w,k,v,d?Math.max(.03,.03*x):x)}const Oe=r.memo(function({data:e,maxValue:t,visibleLines:s=Le,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:d=.5,highlightedType:u=null,hoveredTimeRange:m=null,timeRangeHours:h=24,yAxisMode:x="airtime"}){const p=r.useRef(null),g=r.useRef(null),f=r.useRef(e),b=r.useRef(t),y=r.useRef(s),v=r.useRef(a),j=r.useRef(l),N=r.useRef(i),w=r.useRef(o),k=r.useRef(c),M=r.useRef(u),C=r.useRef(m),S=r.useRef(null),T=r.useRef(null),P=r.useRef(x),$=r.useRef(d),F=h<=12?1.2:1,R=r.useRef(F),A=r.useRef(e.length);r.useLayoutEffect(()=>{f.current=e,b.current=t,y.current=s,v.current=a,j.current=l,N.current=i,w.current=o,k.current=c,M.current=u,C.current=m,R.current=F,P.current=x,$.current=d}),r.useEffect(()=>{S.current=Ae()},[]);const L=r.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),D=r.useMemo(()=>({hooks:{draw:e=>{const t=S.current||Ae();ze(e,f.current,b.current,y.current,v.current,t,N.current,w.current,k.current,M.current,C.current,R.current,T.current,P.current,$.current)}}}),[]),B=r.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:[D]}),[D]);r.useEffect(()=>{const t=p.current;if(!t||0===e.length)return;const s=A.current,a=e.length,n=Math.abs(a-s);if(!(!g.current||n>100||s>0&&n/s>.1)&&g.current)return g.current.setData(L),void(A.current=a);g.current&&g.current.destroy();const r=t.getBoundingClientRect(),l=Math.floor(r.width)||400,i=Math.floor(r.height)||200,o=new E({...B,width:l,height:i},L,t);return g.current=o,A.current=a,()=>{o.destroy(),g.current=null}},[B,L,e.length]),r.useEffect(()=>{const e=p.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!g.current)return;const{width:s,height:a}=t.contentRect;s>0&&a>0&&g.current.setSize({width:Math.floor(s),height:Math.floor(a)})});return t.observe(e),()=>{t.disconnect()}},[]),r.useEffect(()=>{g.current&&g.current.redraw()},[a,s,e,i,o,c,d,u,m,F]);const _=r.useCallback(t=>{var s,a;const n=p.current,r=g.current;if(!n||!r||0===e.length)return;const l=n.getBoundingClientRect(),i=t.clientX-l.left,o=window.devicePixelRatio||1,c=r.bbox,d=c.left/o,u=c.width/o;if(id+u)return T.current=null,r.redraw(),void(null==(s=j.current)||s.call(j,null));T.current=i*o;const m=(i-d)/u,h=e.length,x=Math.floor(m*h),f=Math.max(0,Math.min(h-1,x));r.redraw(),null==(a=j.current)||a.call(j,f)},[e.length]),H=r.useCallback(()=>{var e;T.current=null,g.current&&g.current.redraw(),null==(e=j.current)||e.call(j,null)},[]);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:p,className:"w-full h-full rounded-lg overflow-hidden",onMouseMove:_,onMouseLeave:H})}),We={[B.REQ]:"var(--pkt-science-req)",[B.ANON_REQ]:"var(--pkt-science-anon-req)",[B.RESPONSE]:"var(--pkt-science-response)",[B.ACK]:"var(--pkt-science-ack)",[B.ADVERT]:"var(--pkt-science-advert)",[B.TXT_MSG]:"var(--pkt-science-txt-msg)",[B.GRP_TXT]:"var(--pkt-science-grp-txt)",[B.GRP_DATA]:"var(--pkt-science-grp-data)",[B.PATH]:"var(--pkt-science-path)",[B.TRACE]:"var(--pkt-science-trace)",[B.MULTIPART]:"var(--pkt-science-multipart)",[B.RAW_CUSTOM]:"var(--pkt-science-raw-custom)"},Ve="var(--pkt-science-unknown)";function qe(e){return"number"!=typeof e?Ve:We[e]??Ve}const Ge=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;const d=L(i);c.totalAirtime+=D(d,{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 Ie(e){return H[e]??`TYPE_${e.toString(16).toUpperCase()}`}const Xe={sf:10,bw:25e4,cr:5,preamble:8};function Ke(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{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 n.jsx("div",{className:"flex-shrink-0 pt-3 mt-2",children:n.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 r=qe(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,d=o?l:c,u=d>1e-4,m=t===e.key,h=t&&t!==e.key;let x="legend-item";return m?x+=" legend-item-active":h?x+=" legend-item-dimmed":o&&l>1e-4?x+=" legend-item-chart-active":o&&l<=1e-4&&(x+=" legend-item-dimmed"),n.jsxs("div",{className:x,onMouseEnter:()=>s(e.key),children:[n.jsx("div",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:r}}),n.jsx("span",{className:"legend-label",children:e.label}),u&&n.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*d).toFixed(1),"%"]})]},e.key)})})})}function Qe({x:e,y:t,width:s,height:a,name:r,size:l,index:i,depth:o,hoveredIndex:c,onHover:d,total:u,typeNum:m}){if(1!==o)return null;const h=null!==c&&!(c===i),x=qe(m),p=u>0?l/u*100:0,g=s>36&&a>20,f=s>36&&a>32;return n.jsxs("g",{onMouseEnter:e=>d(i,e),onMouseLeave:()=>d(null),style:{cursor:"default"},children:[n.jsx("rect",{x:e,y:t,width:s,height:a,fill:x,opacity:h?.4:1,stroke:"rgba(0,0,0,0.2)",strokeWidth:1,rx:3,style:{transition:"opacity 150ms ease"}}),g&&n.jsxs(n.Fragment,{children:[f&&n.jsxs("text",{x:e+4,y:t+a-4-11,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.6)",fontSize:8,fontFamily:"'JetBrains Mono', monospace",fontWeight:500,style:{pointerEvents:"none"},children:[p.toFixed(1),"%"]}),n.jsx("text",{x:e+4,y:t+a-4,textAnchor:"start",dominantBaseline:"auto",fill:"rgba(0,0,0,0.85)",fontSize:9,fontFamily:"'JetBrains Mono', monospace",fontWeight:600,style:{pointerEvents:"none"},children:r})]})]})}function Ue({data:e,total:t,color:s,position:a,containerWidth:r}){if(!e||!a)return null;const l=(e.value/t*100).toFixed(1),i=r-a.x<184?Math.max(8,a.x-160-8):a.x+16;return n.jsx("div",{className:"absolute z-50 pointer-events-none",style:{left:i,top:Math.max(8,a.y-60)},children:n.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl min-w-[140px]",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:s}}),n.jsx("span",{className:"type-data-sm font-semibold text-text-primary",children:e.name})]}),n.jsxs("div",{className:"space-y-0.5 type-data-xs text-text-muted",children:[n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Count"}),n.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:e.value.toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Share"}),n.jsxs("span",{className:"text-text-primary tabular-nums font-medium",children:[l,"%"]})]}),n.jsxs("div",{className:"flex justify-between gap-4",children:[n.jsx("span",{children:"Total"}),n.jsx("span",{className:"text-text-primary tabular-nums font-medium",children:t.toLocaleString()})]})]})]})})}function Je({sortedTypes:e,aggregateShares:t}){var s,a,l;const[i,o]=r.useState(null),[c,d]=r.useState(null),[u,m]=r.useState(0),[h,x]=r.useState(null),p=r.useRef(null),f=r.useMemo(()=>e.reduce((e,t)=>e+t.totalCount,0),[e]),b=r.useMemo(()=>e.map((e,t)=>({name:e.label,size:e.totalCount,index:t,typeNum:e.typeNum,key:e.key})),[e]),y=r.useCallback((e,t)=>{if(o(e),t&&null!==e){const e=p.current;if(e){const s=e.getBoundingClientRect();m(s.width),d({x:t.clientX-s.left,y:t.clientY-s.top})}}else d(null)},[]),v=r.useCallback(e=>{if(x(e),e){const t=b.findIndex(t=>t.key===e);o(t>=0?t:null)}else o(null)},[b]),j=null!==i?{name:(null==(s=b[i])?void 0:s.name)??"",value:(null==(a=b[i])?void 0:a.size)??0}:null,N=null!==i?qe(null==(l=b[i])?void 0:l.typeNum):"";return 0===e.length||0===f?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet type data available"})]}):n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",ref:p,children:[n.jsx(oe,{width:"100%",height:"100%",children:n.jsx(ce,{data:b,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:n.jsx(Qe,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:i,onHover:y,total:f,typeNum:0})})}),n.jsx(Ue,{data:j,total:f,color:N,position:c,containerWidth:u})]}),n.jsx(Ye,{sortedTypes:e,highlightedType:h,onTypeHover:v,aggregateShares:t})]})}function Ze(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 et({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:l,radioConfig:i,sortedTypes:o,aggregateShares:c,noiseFloorAnomalies:d,showNoiseFloorOverlay:u,overlayOpacity:m=.5}){const[h,x]=r.useState(null),[p,f]=r.useState(null),b=r.useMemo(()=>(l-a)/3600,[a,l]),y=r.useCallback(e=>{f(e)},[]),v=function(e,t,s,a,n){return r.useMemo(()=>{if(0===e.length||!n)return null;const r=e.filter(e=>e.timestamp>=t&&e.timestamp<=s);if(0===r.length)return null;const l=[],i=new Map;for(const e of r){const s=e.type??e.payload_type??-1,r=L(e);let o;if(o="airtime"===a?D(r,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}):1,r<=0)continue;const c=Math.floor((e.timestamp-t)/300),d={timestamp:e.timestamp,airtimeMs:o,byteSize:r,packetType:s,bucketIndex:c};l.push(d),i.has(c)||i.set(c,[]),i.get(c).push(d)}if(0===l.length)return null;const o=[],c=[],d=[],u=new Map;if("share"===a)for(const[,e]of i)for(const t of e)u.set(t,t.byteSize);else for(const[,e]of i){const t=e.reduce((e,t)=>e+t.airtimeMs,0)/3e5*100,s=Math.max(...e.map(e=>e.airtimeMs));for(const a of e){const e=a.airtimeMs/s*t;u.set(a,e)}}for(const e of l){const t=u.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),d.push(e.packetType))}const m=Math.min(...c),h=Math.max(...c),x=h-m||1,p=[...o].sort((e,t)=>e-t),g=p[0],f=p[p.length-1],b=Math.floor(.05*p.length),y=Math.floor(.5*p.length),v=Math.min(Math.ceil(.95*p.length),p.length-1),j=p[b],N=p[y],w=p[v],k=new Map;for(const e of o){const t=Math.round(100*e)/100;k.set(t,(k.get(t)??0)+1)}const M=k.size,C=[...k.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let S;if("share"===a)S=200;else{const e=5,t=Math.ceil(f/e)*e;S=t<=10?10:t+e}const T=new Float32Array(2*o.length),P=new Float32Array(o.length),$=new Uint8Array(o.length),F=new Float32Array(o.length);for(let e=0;e=0?d[e]:255,F[e]=c[e]}return{points:T,rawValues:P,packetTypes:$,timestamps:F,count:o.length,minTime:m,maxTime:h,minValue:0,maxValue:S,rawMinValue:g,rawMaxValue:f,unit:"%",stats:{p5:j,p50:N,p95:w,uniqueValues:M,topValues:C}}},[e,t,s,a,n])}(s,a,l,"share"===t?"share":"airtime",i),{data:j}=r.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 d=0;dj.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})),[j]),w=r.useMemo(()=>(null==v?void 0:v.maxValue)?v.maxValue:"share"===t?200:10,[v,t]),k=r.useCallback(e=>{x(e)},[]),M=r.useMemo(()=>{if(null===h||!j[h])return null;const e=j[h];let t;t=b>=168?75:b>=72?35:b>=24?15:b>=3?10:5;const s=60*t/2,a=e.timestamp;return{start:a-s,end:a+s}},[h,j,b]),C=r.useMemo(()=>{if(null===h||!j[h]||!M)return null;const e=j[h].time,{start:a,end:n}=M,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:qe(e.typeNum)}))};const l=new Map,c=new Map;let d=0,u=0;for(const t of r){const e=`TYPE_${t.type??t.payload_type??-1}`;if(l.set(e,(l.get(e)??0)+1),d++,i){const s=L(t),a=D(s,{spreadingFactor:i.sf,bandwidthHz:i.bw,codingRate:i.cr,preambleLength:i.preamble});c.set(e,(c.get(e)??0)+a),u+=a}}const m=o.map(e=>{let s;return s="airtime"===t?u>0?(c.get(e.key)??0)/u:0:d>0?(l.get(e.key)??0)/d:0,{key:e.key,label:e.label,value:s,color:qe(e.typeNum)}});return{timestamp:j[h].timestamp,timeLabel:e,items:m}},[h,j,M,s,o,t,i]);if(0===j.length)return n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]});const S=(null==C?void 0:C.timeLabel)??null;return n.jsxs("div",{className:"flex flex-col",children:[n.jsxs("div",{className:"analyzer-chart-height relative flex-shrink-0",children:[n.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:n.jsx(Oe,{data:N,maxValue:w,onHover:k,scatterData:v,noiseFloorAnomalies:d,showNoiseFloorOverlay:u,overlayOpacity:m,highlightedType:p,hoveredTimeRange:M,timeRangeHours:b,yAxisMode:"share"===t?"share":"airtime"})}),S&&n.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:S})]}),n.jsx(Ye,{sortedTypes:o,highlightedType:p,onTypeHover:y,aggregateShares:c,hoverData:C})]})}function tt({active:e,payload:t,label:s,mode:a}){if(!e||!t||0===t.length)return null;const r=t.filter(e=>null!==e.value&&void 0!==e.value);if(0===r.length)return null;const l=s?new Date(1e3*s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}):"";return n.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 text-sm shadow-xl",children:[n.jsx("div",{className:"font-medium text-text-primary mb-1 font-mono",children:l}),r.map((e,t)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-0.5",style:{backgroundColor:e.color}}),n.jsxs("span",{className:"text-text-muted",children:[e.name,":"]}),n.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 st(e){return e>=1e9?`${(e/1e9).toFixed(1)}G`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function at({packets:e,mode:t,startTs:s,endTs:a,radioConfig:l,bucketCount:i}){const o=ee(),c=te(),d=se(),u=c.critical,m=o.neutral,[h,x]=r.useState(null),{trendData:p,totals:b}=r.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0},actualBucketCount:0};const n=a-s,r=Math.min(Math.ceil(n/300),i),o=n/r,c=1e3*o,d=[];for(let e=0;e=a)continue;const n=Math.min(Math.floor((e-s)/o),r-1),i=L(t),c=D(i,{spreadingFactor:l.sf,bandwidthHz:l.bw,codingRate:l.cr,preambleLength:l.preamble});t.transmitted?(d[n].txBytes+=i,d[n].txAirtime+=c,m+=i,x+=c):(d[n].rxBytes+=i,d[n].rxAirtime+=c,u+=i,h+=c)}return{trendData:d.map(e=>{if("share"===t)return{timestamp:e.timestamp,rx:e.rxBytes>0?e.rxBytes:null,tx:e.txBytes>0?e.txBytes:null};{const t=c>0?e.rxAirtime/c*100:0,s=c>0?e.txAirtime/c*100:0;return{timestamp:e.timestamp,rx:t>0?t:null,tx:s>0?s:null}}}),totals:{rxBytes:u,txBytes:m,rxAirtime:h,txAirtime:x}}},[e,s,a,i,t,l,300]),y=r.useMemo(()=>{if(0===p.length)return"share"===t?100:10;let e=0;for(const t of p){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))},[p,t]),v=r.useMemo(()=>{if(null!==h&&p[h]){const e=p[h],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:st(s),tx:st(a),total:st(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:st(b.rxBytes),tx:st(b.txBytes),total:st(b.rxBytes+b.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of p)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}}},[h,p,b,t]),j=r.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}})},[s,a]),N=r.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;x("number"==typeof t?t:null)},[]),w=r.useMemo(()=>{const e=a-s,t=Math.round(e/3600);return t>=24?`${Math.round(t/24)}d`:`${t}h`},[s,a]),k=r.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===p.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsx("div",{className:"flex items-center flex-shrink-0 text-text-muted",style:{height:20,paddingLeft:44,paddingRight:8},children:n.jsx("div",{className:"relative w-full h-full flex items-center",children:j.map((e,t)=>n.jsxs("div",{className:"absolute flex items-center gap-1 type-data-xs",style:{left:100*e.pct+"%",transform:0===e.pct?"translateX(0)":1===e.pct?"translateX(-100%)":"translateX(-50%)"},children:[n.jsx(f,{className:"w-2.5 h-2.5 opacity-60"}),n.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),n.jsxs("div",{className:"flex-1 min-h-0 relative",children:[n.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 type-data-xs text-text-muted font-mono",style:{width:44},children:n.jsx("div",{className:"text-center",children:w})}),n.jsx(oe,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:n.jsxs(de,{data:p,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:N,onMouseLeave:()=>x(null),children:[n.jsx(ue,{strokeDasharray:"3 3",stroke:d.primary,strokeOpacity:.15,vertical:!1}),n.jsx(me,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),n.jsx(he,{axisLine:!1,tickLine:!1,tick:{fill:d.primary,fontSize:10,fontFamily:"'JetBrains Mono', monospace"},dx:-8,width:44,tickFormatter:k,domain:[0,y]}),n.jsx(xe,{content:n.jsx(tt,{mode:t})}),n.jsx(pe,{type:"linear",dataKey:"rx",name:"RX",stroke:u,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(pe,{type:"linear",dataKey:"tx",name:"TX",stroke:m,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1})]})})]}),n.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2",children:[n.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono pl-11",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:u}}),n.jsx("span",{className:"text-text-muted",children:"RX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:m}}),n.jsx("span",{className:"text-text-muted",children:"TX"})]}),n.jsx("span",{className:"text-text-muted",children:"share"===t?"Bytes":"Utilization"})]}),n.jsxs("div",{className:"text-right pr-2",children:[n.jsx("span",{className:"font-mono font-bold text-xl text-text-primary",children:v.total}),n.jsx("span",{className:"text-xs text-text-muted ml-2",children:v.isHovered?"bucket":"total"})]})]})]})}function nt({mode:e,onChange:t}){return n.jsxs("div",{className:"toggle-group toggle-group-sm",children:[n.jsx("button",{onClick:()=>t("share"),className:"toggle-group-item "+("share"===e?"active":""),children:"Total"}),n.jsx("button",{onClick:()=>t("airtime"),className:"toggle-group-item "+("airtime"===e?"active":""),children:"Airtime"})]})}function rt({enabled:e,onChange:t,anomalyCount:s=0,showTuning:a=!1,onTuningChange:r}){return n.jsxs("div",{className:"relative inline-flex items-center gap-1",children:[e&&r&&n.jsx("button",{onClick:()=>r(!a),className:"toggle-group toggle-group-sm "+(a?"active":""),title:a?"Hide tuning panel":"Show tuning panel",children:n.jsx("span",{className:"toggle-group-item "+(a?"active":""),children:n.jsx(l,{className:"w-3.5 h-3.5"})})}),n.jsx("button",{onClick:()=>t(!e),className:"toggle-group toggle-group-sm "+(e?"active":""),title:e?"Hide noise floor anomalies":"Show noise floor anomalies",children:n.jsx("span",{className:"toggle-group-item "+(e?"active":""),children:n.jsx(i,{className:"w-3.5 h-3.5"})})}),s>0&&n.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})]})}function lt({smoothing:e,onChange:t}){return n.jsxs("div",{className:"toggle-group toggle-group-sm",children:[n.jsx("button",{onClick:()=>t("stats"),className:"toggle-group-item "+("stats"===e?"active":""),title:"Statistics view (scatter plot)",children:n.jsx(o,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("trend"),className:"toggle-group-item "+("trend"===e?"active":""),title:"Trend line chart",children:n.jsx(c,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("raw"),className:"toggle-group-item "+("raw"===e?"active":""),title:"No smoothing (raw values)",children:n.jsx(d,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("zlema"),className:"toggle-group-item "+("zlema"===e?"active":""),title:"6-period Zero-Lag EMA (light smoothing)",children:n.jsx(u,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"12-period Zero-Lag EMA (moderate smoothing)",children:n.jsx(m,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"24-period Zero-Lag EMA (heavy smoothing)",children:n.jsx(h,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"96-period Zero-Lag EMA (ultra smoothing)",children:n.jsx(x,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap chart)",children:n.jsx(p,{className:"w-3.5 h-3.5"})})]})}const it=r.memo(function({packets:e,startTs:t,endTs:s,bucketCount:a,radioConfig:l=Xe,mode:i="share",smoothing:o="raw",noiseFloorAnomalies:c=null,showNoiseFloorOverlay:d=!1,overlayOpacity:u=.5}){const m=Z(),[h,x]=r.useState(null),[p,f]=r.useState([]),b=r.useRef(null),y=r.useRef(0);r.useEffect(()=>{const t=Math.abs(e.length-y.current);if(0===t&&p.length>0)return;b.current&&clearTimeout(b.current);const s=t>100?50:500;return b.current=setTimeout(()=>{y.current=e.length,f(e)},s),()=>{b.current&&clearTimeout(b.current)}},[e,p.length]);const v=r.useMemo(()=>function(e){const t=new Map;for(const a of e){const e=a.type??a.payload_type??-1;t.set(e,(t.get(e)??0)+1)}const s=[];for(const[a,n]of t)s.push({typeNum:a,key:`TYPE_${a}`,label:Ie(a),totalCount:n});return s.sort((e,t)=>t.totalCount-e.totalCount)}(p),[p]),j=r.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=[];for(let d=0;d24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});c.push({timestamp:e,time:a,counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o});for(const t of r)c[d].counts[t.key]=0,c[d].airtimes[t.key]=0}for(const d of e){const e=d.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${d.type??d.payload_type??-1}`;c[r].counts[l]=(c[r].counts[l]??0)+1,c[r].total++;const o=L(d),u=D(o,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});c[r].airtimes[l]=(c[r].airtimes[l]??0)+u,c[r].totalAirtime+=u}for(const d of c)for(const e of r)d.total>0?d.shares[e.key]=d.counts[e.key]/d.total*100:d.shares[e.key]=0;return c}(p,t,s,a,l,v),[p,t,s,a,l,v]),N=r.useMemo(()=>Ge.getBuckets(p,t,s,l),[p,t,s,l]),w=r.useMemo(()=>v.reduce((e,t)=>e+t.totalCount,0),[v]),{sortedTypes:k,aggregateShares:M}=r.useMemo(()=>{const e=new Map;if("share"===i){if(w>0)for(const t of v)e.set(t.key,t.totalCount/w)}else{let t=0;const s=new Map;for(const e of j){t+=e.totalAirtime;for(const t of v){const a=s.get(t.key)??0;s.set(t.key,a+(e.airtimes[t.key]??0))}}if(t>0)for(const a of v)e.set(a.key,(s.get(a.key)??0)/t)}return{sortedTypes:[...v].sort((t,s)=>{const a=e.get(t.key)??0;return(e.get(s.key)??0)-a}),aggregateShares:e}},[v,w,i,j]),C=r.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 m=0;m0?(e.counts[a]??0)/e.total:0}else{let t=0;for(let a=0;a0?r/t:0}}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let m=0;mfunction(e,t){switch(t){case"zlema":return Ke(e,6);case"ema":return Ke(e,12);case"smooth":return Ke(e,24);case"ultra":return Ke(e,96);default:return e}}(e,a)),d=Array.from({length:l},()=>new Array(r).fill(0));for(let m=0;m0?c[m-1][e]:0;let s=c[m][e]-t;s<0&&(s=0),s>1&&(s=1),d[m][e]=s}for(let m=0;m0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;e{x(e)},[]),[T,P]=r.useState(null),$=r.useCallback(e=>{P(e)},[]),F=r.useMemo(()=>{if(null===T||!C[T])return null;const e=C[T];return{timestamp:e.timestamp,timeLabel:e.time,items:k.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:qe(t.typeNum)}))}},[T,C,k]),R=r.useMemo(()=>({timestamps:C.map(e=>e.timestamp),series:k.map(e=>({key:e.key,label:e.label,color:qe(e.typeNum),values:C.map(t=>t[e.key]??0)}))}),[C,k]);return 0===p.length?0===e.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(g,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===o?n.jsx(Je,{sortedTypes:k,aggregateShares:M}):"stats"===o?n.jsx(et,{statsBuckets:N,mode:i,packets:p,startTs:t,endTs:s,radioConfig:l,sortedTypes:k,aggregateShares:M,noiseFloorAnomalies:c,showNoiseFloorOverlay:d,overlayOpacity:u}):"trend"===o?n.jsx(at,{packets:p,mode:i,startTs:t,endTs:s,radioConfig:l,bucketCount:a}):n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:"analyzer-chart-height relative flex-shrink-0",children:n.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:n.jsx(_,{timestamps:R.timestamps,series:R.series,highlightedKey:h,cursorColor:m.cursor,onHover:$})})}),n.jsx(Ye,{sortedTypes:k,highlightedType:h,onTypeHover:S,aggregateShares:M,hoverData:F})]})}),ot={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},ct=[1,5,10,25,50,100,150];function dt(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 ut(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 mt=[{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 ht(e,t){return t[re(e)]||"#808080"}const xt=r.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=r.useState(null),[c,d]=r.useState(new Set),[u,m]=r.useState({width:0,height:0}),[h,x]=r.useState("1x"),[p,g]=r.useState(1),f=r.useRef(null),y=r.useRef({}),v=r.useRef(null),j=r.useRef(null),N=r.useRef(p);N.current=p;const w=ae(),k=te(),M=ne(),C=se();r.useEffect(()=>{const e=j.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&&m({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&m({width:s.width,height:s.height}),()=>t.disconnect()},[]);const S=r.useMemo(()=>{const e=new Set;if(t)for(const s of t)e.add(s.hash);return e},[t]),T=r.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:P,maxDistance:$,totalNeighbors:F,zeroHopCount:R}=r.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=dt(s,a,l.latitude,l.longitude),n=ut(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]);r.useEffect(()=>{null==l||l({zeroHopCount:R,totalCount:F,maxDistanceKm:$})},[R,F,$]),r.useEffect(()=>{const e=ot[h],t=N.current;f.current&&cancelAnimationFrame(f.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;g(t+(e-t)*i),f.current=l<1?requestAnimationFrame(a):null};return f.current=requestAnimationFrame(a),()=>{f.current&&cancelAnimationFrame(f.current)}},[h]);const A=$/p,L=r.useMemo(()=>ct.filter(e=>e<=1.1*A),[A]);r.useEffect(()=>{const e=[];for(const s of P){const t=y.current[s.hash];void 0!==t&&t!==s.lastSeen&&e.push(s.hash),y.current[s.hash]=s.lastSeen}if(0===e.length)return;queueMicrotask(()=>{d(t=>new Set([...t,...e]))});const t=setTimeout(()=>{d(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[P]);const D=0!==s&&0!==a,E=r.useMemo(()=>{const{width:e,height:t}=u,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)}},[u]),{width:B,height:_,centerX:H,centerY:z,maxRadiusX:O,maxRadiusY:W,labelRadiusX:V,labelRadiusY:q,cornerRadius:G}=E,I=r.useCallback((e,t=1)=>{const s=O*t,a=W*t,n=Math.min(G*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(H-s+n,Math.min(H+s-n,H+a*e*(s/a))),c=z-a}else if(r>45-i&&r<=45+i)o=H+s-n+n*Math.sin(l),c=z-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(z-a+n,Math.min(z+a-n,z-s*e*(a/s))),o=H+s}else if(r>135-i&&r<=135+i)o=H+s-n+n*Math.sin(l),c=z+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(H-s+n,Math.min(H+s-n,H-a*e*(s/a))),c=z+a}else if(r>225-i&&r<=225+i)o=H-s+n+n*Math.sin(l),c=z+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(z-a+n,Math.min(z+a-n,z-s*e*(a/s))),o=H-s}else o=H-s+n+n*Math.sin(l),c=z-a+n-n*Math.cos(l);return{x:o,y:c}},[H,z,O,W,G]),X=r.useCallback((e,t)=>{const s=I(e,1);return{x:H+(s.x-H)*t,y:z+(s.y-z)*t}},[I,H,z]),K=r.useCallback(e=>({N:{x:H,y:z-q},S:{x:H,y:z+q},E:{x:H+V,y:z},W:{x:H-V,y:z},NE:{x:H+V,y:z-q},SE:{x:H+V,y:z+q},SW:{x:H-V,y:z+q},NW:{x:H-V,y:z-q}}[e]),[H,z,V,q]),Y=r.useCallback(e=>{const t=O*e,s=W*e,a=Math.min(G*e,t,s),n=H-t,r=H+t,l=z-s,i=z+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(" ")},[H,z,O,W,G]),Q=r.useCallback(e=>{o(e)},[]),U=r.useCallback(e=>{x(e)},[]),J=r.useCallback(e=>$<=0?0:e/$*p,[$,p]),Z=e=>`${e}km`,ee=r.useMemo(()=>{const e=L.map(e=>{const t=e/$*p;return{km:e,scale:t,labelY:z-W*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},[L,$,p,z,W]),re=u.width>0&&u.height>0;return D?0===F?n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-muted",children:[n.jsx(b,{className:"w-8 h-8 mb-2 opacity-50"}),n.jsx("p",{children:"No nodes with location data"})]}):n.jsxs("div",{ref:v,className:"relative h-full w-full flex overflow-hidden",children:[n.jsx("div",{ref:j,className:"relative flex-1 min-w-0 h-full",children:re&&n.jsxs("svg",{width:B,height:_,className:"absolute inset-0 z-0",children:[n.jsxs("defs",{children:[n.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 "}),n.jsx("clipPath",{id:"radar-clip",children:n.jsx("path",{d:Y(1)})})]}),L.map(e=>{const t=J(e);if(t>1.05||t<.02)return null;const s=ee.some(t=>t.km===e),a=H+O*t*.71,r=z-W*t*.71;return n.jsxs("g",{children:[n.jsx("path",{d:Y(t),fill:"none",stroke:C.primary,strokeOpacity:.15,strokeWidth:1}),s&&n.jsx("text",{x:a+4,y:r-2,textAnchor:"start",dominantBaseline:"auto",className:"fill-text-secondary",fontSize:10,fontFamily:"'JetBrains Mono', monospace",children:Z(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?H:"E"===e?H+O:H-O,a=t?"N"===e?z-W:z+W:z;return n.jsx("line",{x1:H,y1:z,x2:s,y2:a,stroke:C.primary,strokeOpacity:.15,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=K(e);return n.jsx("line",{x1:H,y1:z,x2:t.x,y2:t.y,stroke:C.primary,strokeOpacity:.08,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=K(e),s="E"===e?"end":"W"===e?"start":"middle",a="N"===e?"hanging":"S"===e?"auto":"middle";return n.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:k.critical,fontSize:16,fontWeight:600,fontFamily:"'JetBrains Mono', monospace","aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=K(e),s="NE"===e||"SE"===e?"end":"start",a="NE"===e||"NW"===e?"hanging":"auto";return n.jsx("text",{x:t.x,y:t.y,textAnchor:s,dominantBaseline:a,fill:k.critical,fontSize:16,fontWeight:600,fontFamily:"'JetBrains Mono', monospace","aria-hidden":"true",children:e},e)}),n.jsx("circle",{cx:H,cy:z,r:5,fill:M.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),n.jsx("g",{clipPath:"url(#radar-clip)",children:P.map(e=>{const t=$>0?e.distance/$*p:0;if(t>1)return null;const{x:s,y:a}=X(e.bearing,t),r=null!==e.snr?ht(e.snr,w):"#808080",l=(null==i?void 0:i.hash)===e.hash,o=c.has(e.hash);return n.jsxs("g",{role:"img","aria-label":`${e.name}: ${e.distance.toFixed(1)}km ${e.bearing.toFixed(0)}°`,children:[o&&n.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&&n.jsx("circle",{cx:s,cy:a,r:10.5,fill:r,opacity:.3}),n.jsx("circle",{cx:s,cy:a,r:l?7:5,fill:r,stroke:"rgba(0,0,0,0.5)",strokeWidth:1,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>Q(e),onMouseLeave:()=>Q(null)})]},e.hash)})})]})}),n.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=>n.jsx("button",{onClick:()=>U(e),"aria-pressed":h===e,className:"flex flex-1 items-center justify-center px-1.5 text-xs font-medium rounded transition-colors "+(h===e?"bg-accent-primary/20 text-accent-primary":"bg-white/5 text-text-muted hover:bg-white/10 hover:text-text-secondary"),children:e},e))}),i&&n.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:[n.jsx("div",{className:"font-medium text-text-primary",children:i.name}),n.jsx("div",{className:"text-text-muted text-xs font-mono",children:i.hash}),null!==i.snr?n.jsx("div",{className:"flex gap-3 mt-1 text-xs",children:n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"SNR:"})," ",n.jsxs("span",{className:"tabular-nums",style:{color:ht(i.snr,w)},children:[i.snr.toFixed(1)," dB"]}),n.jsxs("span",{className:"text-text-muted ml-1",children:["(",(le=i.snr,(null==(ie=mt.find(e=>le>=e.min))?void 0:ie.label)??"Critical"),")"]})]})}):n.jsx("div",{className:"text-xs text-text-muted mt-1",children:"No SNR data"}),n.jsxs("div",{className:"flex gap-3 text-xs",children:[n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"Distance:"})," ",n.jsxs("span",{className:"tabular-nums text-text-secondary",children:[i.distance.toFixed(2)," km"]})]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-muted",children:"Bearing:"})," ",n.jsxs("span",{className:"tabular-nums text-text-secondary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-muted",children:[n.jsx(b,{className:"w-8 h-8 mb-2 opacity-50"}),n.jsx("p",{children:"Local node coordinates not configured"}),n.jsx("p",{className:"text-xs mt-1",children:"Set latitude/longitude in config to enable"})]});var le,ie});function pt(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 gt=r.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const i=te(),[o,c]=r.useState(!0),d=r.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:pt(n,5),p95:pt(n,95)}},[t]);r.useEffect(()=>{null==s||s(d)},[d]);const u=r.useCallback(()=>{c(e=>!e)},[]),{heatmapData:m,xLabels:h,yLabels:x}=r.useMemo(()=>{if(0===e.length||0===t.length||!d)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(d.p95-d.p5||1);s=d.p5-e,a=d.p95+e}else{const e=.1*(d.max-d.min||1);s=d.min-e,a=d.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;ole(j)??{r:225,g:38,b:114},[j]);return r.useEffect(()=>{const e=g.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&&b({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&b({width:s.width,height:s.height}),()=>t.disconnect()},[]),r.useEffect(()=>{const e=p.current;if(!e||!m||0===f.width)return;const t=e.getContext("2d");if(!t)return;const{width:s,height:a}=f,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{points:r,count:l}=m,{r:i,g:o,b:c}=N,d=Math.max(3,Math.min(8,s/l*4));t.globalCompositeOperation="source-over";for(let u=0;un.jsx("span",{className:"type-data-xs text-text-muted tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),n.jsxs("div",{ref:g,className:"absolute overflow-hidden",style:{left:32,right:0,top:0,bottom:20},children:[n.jsx("svg",{className:"absolute inset-0 w-full h-full",preserveAspectRatio:"none","aria-hidden":"true",children:[0,25,50,75,100].map(e=>n.jsx("line",{x1:"0",y1:`${e}%`,x2:"100%",y2:`${e}%`,stroke:"rgba(255,255,255,0.06)",strokeDasharray:"3 3"},e))}),n.jsx("canvas",{ref:p,className:"absolute inset-0 w-full h-full","aria-hidden":"true"}),n.jsx("button",{type:"button",onClick:u,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?n.jsx(y,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"}):n.jsx(v,{className:"w-3.5 h-3.5 text-text-muted","aria-hidden":"true"})})]}),n.jsx("div",{className:"absolute left-0 right-0 bottom-0",style:{left:32,height:20},"aria-hidden":"true",children:h.map((e,t)=>n.jsx("span",{className:"type-data-xs text-text-muted tabular-nums absolute top-1",style:{left:`${e.pos}%`,transform:"translateX(-50%)"},children:e.label},t))})]}):n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No noise floor data available"})}),ft={repeater:"var(--signal-critical)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function bt(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 yt=r.memo(function({neighbors:e}){const t=r.useMemo(()=>{const t={repeater:0,companion:0,room_server:0};for(const a of Object.values(e)){const e=bt(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:ft.repeater},{label:"Companions",count:t.companion,percent:0,color:ft.companion},{label:"Room Servers",count:t.room_server,percent:0,color:ft.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?n.jsx("div",{className:"h-full flex items-center justify-center text-text-muted type-body-sm",children:"No neighbors discovered yet"}):n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsx("div",{className:"flex-1 flex flex-col justify-evenly",children:t.items.map(e=>n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"type-data-sm text-text-secondary",children:e.label}),n.jsxs("span",{className:"type-data-sm text-text-muted tabular-nums",children:[e.count," ",n.jsxs("span",{className:"text-text-muted/60",children:["(",e.percent.toFixed(0),"%)"]})]})]}),n.jsx("div",{className:"h-2.5 bg-bg-elevated rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${e.percent}%`,backgroundColor:e.color,minWidth:e.count>0?"4px":"0"}})})]},e.label))}),n.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border-subtle",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Total Nodes"}),n.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function vt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=r.useRef(null),[o,c]=r.useState(!1),[d,u]=r.useState(!1);r.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{const t=e.isIntersecting;u(t),t&&c(!0)},{rootMargin:s,threshold:0});return t.observe(e),()=>{t.disconnect()}},[s]);const m=d||a&&o;return n.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:m?e:n.jsx("div",{className:"h-full w-full flex items-center justify-center text-text-muted/50",children:n.jsx("div",{className:"animate-pulse text-xs",children:"Loading chart..."})})})}const jt={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-critical"},Nt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-signal-critical/10"},wt={excellent:"bg-signal-excellent",good:"bg-signal-good",fair:"bg-signal-fair",poor:"bg-signal-critical"};function kt({value:e,status:t}){return n.jsx("div",{className:"w-full h-2 bg-surface-elevated rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${wt[t]} transition-all duration-300`,style:{width:`${Math.min(100,Math.max(0,e))}%`}})})}function Mt(){const e=z(),t=O(),[s,a]=r.useState(null),l=r.useCallback((e,t)=>{a({prefix:e,candidateHashes:t})},[]),i=r.useCallback(()=>{a(null)},[]);if(!t)return n.jsxs(fe,{children:[n.jsx(be,{icon:n.jsx(j,{}),title:"Prefix Conflicts",largeTitle:!0}),n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-text-muted",children:[n.jsx(N,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{className:"type-data-xs",children:"No topology data available"}),n.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 d=(u=e.collisionRate)<=10?"excellent":u<=25?"good":"poor";var u;const m="poor"===o||"poor"===d?"poor":"fair"===o||"fair"===d?"fair":"good"===o||"good"===d?"good":"excellent",h="excellent"===m||"good"===m?w:k;return n.jsxs(fe,{className:"flex flex-col overflow-hidden",children:[n.jsx(be,{icon:n.jsx(j,{}),title:"Prefix Conflicts",largeTitle:!0,actions:n.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${Nt[m]}`,children:[n.jsx(h,{className:`w-3.5 h-3.5 ${jt[m]}`}),n.jsx("span",{className:`type-data-xs font-medium ${jt[m]}`,children:"excellent"===m?"Excellent":"good"===m?"Good":"fair"===m?"Fair":"Needs Attention"})]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[n.jsxs("div",{className:"cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification. Based on geographic proximity, co-occurrence patterns, and observation recency.",children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Avg Confidence"}),n.jsxs("span",{className:`type-data-lg font-semibold ${jt[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),n.jsx(kt,{value:100*e.avgConfidence,status:o})]}),n.jsxs("div",{className:"cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better. Collisions require disambiguation to determine the correct node.",children:[n.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[n.jsx("span",{className:"type-data-xs text-text-muted",children:"Collision Rate"}),n.jsxs("span",{className:`type-data-lg font-semibold ${jt[d]}`,children:[e.collisionRate.toFixed(1),"%"]})]}),n.jsx(kt,{value:e.collisionRate,status:d})]})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3",children:[n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Total unique 2-character prefixes observed in packet paths. Each prefix represents the first 2 hex digits of a node's full hash.",children:[n.jsx("div",{className:"type-data-lg font-semibold text-text-primary",children:e.totalPrefixes}),n.jsx("div",{className:"type-data-xs text-text-muted",children:"Prefixes"})]}),n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Prefixes that map to exactly one known node. No disambiguation needed—these are definitive identifications.",children:[n.jsx("div",{className:"type-data-lg font-semibold text-signal-good",children:e.unambiguousPrefixes}),n.jsx("div",{className:"type-data-xs text-text-muted",children:"Unique"})]}),n.jsxs("div",{className:"text-center cursor-help px-2 py-1.5 rounded",style:{backgroundColor:"var(--hover-tint)"},title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates and see how disambiguation scores them.",children:[n.jsx("div",{className:"type-data-lg font-semibold "+(e.collisionPrefixes>0?"text-signal-critical":"text-text-primary"),children:e.collisionPrefixes}),n.jsx("div",{className:"type-data-xs "+(e.collisionPrefixes>0?"text-signal-critical":"text-text-muted"),children:"Collisions"})]})]}),e.highCollisionPrefixes.length>0&&n.jsxs("div",{className:"mb-2",children:[n.jsx("div",{className:"type-data-xs text-text-muted mb-1.5",children:"Highest Collisions"}),n.jsx("div",{className:"flex flex-wrap gap-1",children:e.highCollisionPrefixes.map(({prefix:e,candidateCount:t,candidateHashes:s})=>n.jsxs("button",{type:"button",onClick:()=>l(e,s),className:"inline-flex items-center gap-1 px-1.5 py-0.5 min-h-[24px] rounded bg-surface-elevated text-text-secondary type-data-xs font-mono hover:bg-signal-critical/20 hover:text-signal-critical focus:outline-none focus:ring-2 focus:ring-signal-critical/50 transition-colors cursor-pointer touch-manipulation",title:`Click to explore ${t} candidates matching this prefix`,"aria-label":`Explore prefix ${e} with ${t} colliding candidates`,children:[e,n.jsxs("span",{className:"text-signal-critical",children:["×",t]})]},e))})]}),e.lowConfidencePrefixes.length>0&&n.jsx("div",{className:"mt-auto pt-2",children:n.jsxs("div",{className:"flex items-start gap-1.5",children:[n.jsx(k,{className:"w-3.5 h-3.5 text-signal-critical mt-0.5 flex-shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"type-data-xs text-signal-critical font-medium",children:[n.jsx("span",{className:"text-signal-critical",children:e.lowConfidencePrefixes.length})," prefix",1!==e.lowConfidencePrefixes.length?"es":""," with low confidence"]}),n.jsxs("div",{className:"type-data-xs text-text-muted font-mono truncate",children:[e.lowConfidencePrefixes.slice(0,5).join(", "),e.lowConfidencePrefixes.length>5&&n.jsxs("span",{className:"text-signal-critical",children:[" +",e.lowConfidencePrefixes.length-5," more"]})]})]})]})}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&n.jsx("div",{className:"mt-auto pt-2",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(w,{className:"w-3.5 h-3.5 text-signal-excellent"}),n.jsx("span",{className:"type-data-xs text-signal-excellent",children:"All prefixes uniquely identified"})]})})]}),n.jsx(je,{isOpen:!!s,prefix:(null==s?void 0:s.prefix)||"",candidateHashes:(null==s?void 0:s.candidateHashes)||[],onClose:i})]})}function Ct({icon:e,label:t,value:s,sublabel:a,highlight:r,tooltip:l}){return n.jsxs("div",{className:"flex items-center justify-between py-2 "+(l?"cursor-help":""),title:l,children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"icon-xs text-icon-widget",children:e}),n.jsx("span",{className:"type-label text-text-secondary",children:t})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("span",{className:"type-data-sm "+(r?"text-accent-tertiary":"text-text-primary"),children:s}),a&&n.jsx("span",{className:"type-data-xs text-text-muted ml-1",children:a})]})]})}function St(){const e=W(),t=V().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:r,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:d,echolocationEdgesInferred:u}=e,m=s>0?((s-a)/s*100).toFixed(1):"0",h=s>0?(a/s*100).toFixed(1):"0",p=s>0?(r/s*100).toFixed(1):"0",g=l+i,f=g>0||o>0,b=c>0||u>0;return n.jsxs(fe,{children:[n.jsx(be,{title:"Path Decoder",icon:n.jsx(M,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),n.jsxs(ke,{children:[n.jsx("p",{className:"type-data-xs text-text-muted mb-3",children:"Decodes packet routes to map your mesh topology and discover hidden repeaters."}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(C,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${m}%`,sublabel:`of ${s.toLocaleString()} paths`,highlight:parseFloat(m)>=90,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),n.jsx(Ct,{icon:n.jsx(S,{className:"w-3.5 h-3.5"}),label:"Hidden Nodes",value:a.toLocaleString(),sublabel:`paths (${h}%)`,highlight:a>0,tooltip:"Paths containing unidentified repeaters. These 'ghost' nodes forward traffic but haven't announced themselves via ADVERT — possibly distant or newly added nodes."}),n.jsx(Ct,{icon:n.jsx(T,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${p}%`,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."})]}),f&&n.jsxs("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[n.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(P,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:g.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."}),n.jsx(Ct,{icon:n.jsx($,{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."})]})]}),b&&n.jsxs("div",{className:"mt-3 pt-3 border-t border-border-subtle",children:[n.jsx("p",{className:"type-micro mb-2",children:"Echo Analysis"}),n.jsxs("div",{className:"divide-y divide-white/5",children:[n.jsx(Ct,{icon:n.jsx(F,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:d>0?`(${d} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),n.jsx(Ct,{icon:n.jsx(x,{className:"w-3.5 h-3.5"}),label:"Inferred Links",value:u.toLocaleString(),highlight:u>0,tooltip:"Connections discovered from echo patterns. When the same packet arrives via different forwarders nearly simultaneously, those forwarders likely hear each other."})]})]}),t>0&&n.jsx("div",{className:"mt-3 pt-3 border-t border-border-subtle cursor-help",title:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map.",children:n.jsxs("p",{className:"type-label text-text-muted",children:[n.jsx("span",{className:"text-accent-tertiary type-data-sm",children:t})," ","likely repeater",1!==t?"s":""," discovered from traffic patterns"]})})]})]})}function Tt(){var e,t,s,a,l,i,o,c,d,u,m,h,x,p,f,y,v;const j=q(),N=G(),w=I(),k=X(),M=K(),[C,S]=r.useState([]),[T,P]=r.useState(null),[$,L]=r.useState(null),[D,E]=r.useState(!0),[B,_]=r.useState(null),[H,z]=r.useState(5),[O,W]=r.useState("share"),[V,Z]=r.useState("stats"),[ee,te]=r.useState(!1),[se,ae]=r.useState(!1),[ne,re]=r.useState(Me),[le,ie]=r.useState(.5),oe=Y[H].hours,ce=60*oe,de=Y[H],ue=U(oe),me=r.useCallback(e=>{r.startTransition(()=>z(e))},[]),he=r.useMemo(()=>{var e;if(!(null==(e=null==j?void 0:j.config)?void 0:e.radio))return null;const t=j.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==j?void 0:j.config)?void 0:e.radio)?void 0:t.spreading_factor,null==(a=null==(s=null==j?void 0:j.config)?void 0:s.radio)?void 0:a.bandwidth,null==(i=null==(l=null==j?void 0:j.config)?void 0:l.radio)?void 0:i.coding_rate,null==(c=null==(o=null==j?void 0:j.config)?void 0:o.radio)?void 0:c.preamble_length]);r.useEffect(()=>{!async function(){var e;_(null);try{const t=await Q(oe);t.success&&(null==(e=t.data)?void 0:e.history)&&S(t.data.history)}catch(t){_(t instanceof Error?t.message:"Failed to load chart data")}finally{E(!1)}}()},[oe]);const xe=r.useMemo(()=>72===oe?6e5:168===oe?18e5:336===oe?36e5:3e5,[oe]),pe=r.useCallback(async()=>{var e;try{const t=await Q(oe);t.success&&(null==(e=t.data)?void 0:e.history)&&S(t.data.history)}catch{}},[oe]);J(pe,xe,!0,!0);const je=r.useMemo(()=>0===C.length?{timestamps:[],values:[]}:{timestamps:C.map(e=>e.timestamp),values:C.map(e=>e.noise_floor_dbm)},[C]),ke=r.useMemo(()=>{if(C.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Me,...t};if(e.length<10)return{anomalies:[],thresholds:Se([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=Se(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=Ce(r,s.baselinePercentile),i=Ce(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let d=null,u=0;for(const m of o)if(m.noise_floor_dbm>l&&m.noise_floor_dbme+t,0)/d.values.length):(d.values.length>=s.minSequenceLength&&c.push(d),d={startTs:m.timestamp,endTs:m.timestamp,values:[m.noise_floor_dbm],timestamps:[m.timestamp],rollingAvg:m.noise_floor_dbm})}else d={startTs:m.timestamp,endTs:m.timestamp,values:[m.noise_floor_dbm],timestamps:[m.timestamp],rollingAvg:m.noise_floor_dbm};else d&&d.values.length>=s.minSequenceLength&&c.push(d),d=null;return d&&d.values.length>=s.minSequenceLength&&c.push(d),0===c.length?{anomalies:[],thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}:{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:Te(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}}(C,ne);return{anomalies:e.anomalies,debug:e.debug}},[C,ne]),Pe=ke.anomalies,$e=r.useMemo(()=>{const e=(null==j?void 0:j.neighbors)??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!N.has(e)))},[null==j?void 0:j.neighbors,N]),Fe=r.useMemo(()=>{const e=Date.now()/1e3-3600*oe;return Object.fromEntries(Object.entries($e).filter(([,t])=>t.last_seen>=e))},[$e,oe]),Re=r.useMemo(()=>{const e=60*ce/ue,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*ce,end:s}},[ce,ue]);return n.jsxs(ye,{children:[n.jsx(ve,{title:"Statistics",icon:n.jsx(R,{}),controls:n.jsx(ge,{ranges:Y,selectedIndex:H,onSelect:me})}),B&&n.jsx(fe,{className:"border border-accent-red/50 bg-accent-red/10",children:n.jsx("p",{className:"text-accent-red",children:B})}),ee&&se&&n.jsxs(fe,{className:"border border-accent-purple/30 bg-glass-surface/50",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"type-label",children:"Anomaly Detection Tuning"}),n.jsxs("span",{className:"type-data-xs text-text-muted",children:["(",de.label,")"]})]}),n.jsx("button",{onClick:()=>re(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(ne.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:ne.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Baseline"}),n.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(u=null==(d=ke.debug)?void 0:d.baselineCutoff)?void 0:u.toFixed(1))??"—"," dBm"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Spike"}),n.jsxs("span",{className:"ml-2 type-data-sm text-status-warning",children:[(null==(h=null==(m=ke.debug)?void 0:m.spikeCutoff)?void 0:h.toFixed(1))??"—"," dBm"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Mid-band"}),n.jsx("span",{className:"ml-2 type-data-sm text-accent-purple",children:(null==(x=ke.debug)?void 0:x.midBandSamples)??0})]}),n.jsxs("div",{children:[n.jsx("span",{className:"type-micro",children:"Anomalies"}),n.jsx("span",{className:"ml-2 type-data-sm text-status-danger",children:Pe.length})]})]}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[ne.useAbsoluteThresholds?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (",ne.baselineDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-120",max:"-60",value:ne.baselineDbm,onChange:e=>re(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",ne.spikeDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-100",max:"-20",value:ne.spikeDbm,onChange:e=>re(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",ne.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:ne.mergeGapSeconds,onChange:e=>re(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",ne.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:ne.minSequenceLength,onChange:e=>re(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",ne.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:ne.similarityToleranceDbm,onChange:e=>re(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*le),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:le,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Baseline (P",ne.baselinePercentile,")"]}),n.jsx("input",{type:"range",min:"1",max:"50",value:ne.baselinePercentile,onChange:e=>re(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",ne.spikePercentile,")"]}),n.jsx("input",{type:"range",min:"50",max:"99",value:ne.spikePercentile,onChange:e=>re(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",ne.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:ne.mergeGapSeconds,onChange:e=>re(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Min Sequence (",ne.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:ne.minSequenceLength,onChange:e=>re(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",ne.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:ne.similarityToleranceDbm,onChange:e=>re(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*le),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:le,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-accent-purple"})]})]})]}),n.jsxs("div",{className:"mt-4 p-3 bg-glass-elevated rounded-lg",children:[n.jsx("div",{className:"type-micro mb-1",children:"Config output"}),n.jsxs("div",{className:"type-data-sm text-status-success",children:[ne.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${ne.baselineDbm}, spikeDbm: ${ne.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${ne.baselinePercentile}, spikePercentile: ${ne.spikePercentile}`,", mergeGapSeconds: ",ne.mergeGapSeconds,", minSequenceLength: ",ne.minSequenceLength,", similarityToleranceDbm: ",ne.similarityToleranceDbm]})]})]})]}),D?n.jsx(Ne,{template:"auto",children:n.jsx(fe,{className:"text-center py-12",children:n.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading statistics..."})})}):n.jsxs(n.Fragment,{children:[n.jsx(Ne,{template:"hero-auto",children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(g,{}),title:"Packet Analyzer",badge:de.label,largeTitle:!0,actions:n.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&n.jsx(rt,{enabled:ee,onChange:te,anomalyCount:Pe.length,showTuning:se,onTuningChange:ae}),n.jsx(lt,{smoothing:V,onChange:Z}),n.jsx(nt,{mode:O,onChange:W})]})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(it,{packets:k,startTs:Re.start,endTs:Re.end,bucketCount:ue,radioConfig:he??void 0,mode:O,smoothing:V,noiseFloorAnomalies:Pe,showNoiseFloorOverlay:ee,overlayOpacity:le})})]})})}),n.jsxs(Ne,{template:"panel",children:[n.jsx(we,{span:12,md:6,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(b,{}),title:"Link Quality",badge:de.label,largeTitle:!0,actions:$?n.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 type-data-xs text-text-muted",children:[n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.zeroHopCount})," nbr"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.totalCount})," obs"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:$.maxDistanceKm.toFixed(0)})," km"]})]}):null}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(xt,{neighbors:Fe,quickNeighbors:w,localLat:(null==(f=null==(p=null==j?void 0:j.config)?void 0:p.repeater)?void 0:f.latitude)??0,localLon:(null==(v=null==(y=null==j?void 0:j.config)?void 0:y.repeater)?void 0:v.longitude)??0,onStatsChange:L})})})]})})}),n.jsx(we,{span:12,md:6,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(A,{}),title:"Network Composition",badge:de.label,largeTitle:!0}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(yt,{neighbors:Fe})})})]})})})]}),n.jsxs(Ne,{template:"panel",children:[n.jsx(we,{span:12,md:6,children:n.jsx(Mt,{})}),n.jsx(we,{span:12,md:6,children:n.jsx(St,{})})]}),n.jsx(Ne,{template:"panel",children:n.jsx(we,{span:12,children:n.jsx(fe,{isLoaded:M,skeletonType:"chart",children:M&&n.jsxs(n.Fragment,{children:[n.jsx(be,{icon:n.jsx(F,{}),title:"RF Noise Floor",largeTitle:!0,actions:T?n.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 md:gap-3",children:[n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["min ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.min.toFixed(0)})]}),n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["avg ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.avg.toFixed(0)})]}),n.jsxs("span",{className:"type-data-xs text-text-muted whitespace-nowrap",children:["max ",n.jsx("span",{className:"text-text-secondary tabular-nums",children:T.max.toFixed(0)})]}),n.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})]}):n.jsx("span",{className:"type-data-xs text-text-muted",children:"dBm"})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(vt,{children:n.jsx(gt,{timestamps:je.timestamps,values:je.values,onStatsChange:P})})})]})})})})]})]})}export{Tt as default}; diff --git a/frontend/dist/assets/System-CMjUiDHD.js b/frontend/dist/assets/System-CvdQ6ugY.js similarity index 99% rename from frontend/dist/assets/System-CMjUiDHD.js rename to frontend/dist/assets/System-CvdQ6ugY.js index d5390f85..50e9d0ab 100644 --- a/frontend/dist/assets/System-CMjUiDHD.js +++ b/frontend/dist/assets/System-CvdQ6ugY.js @@ -1 +1 @@ -import{r as e,j as t,a2 as s,aT as a,ae as r,aU as l,aV as n}from"./vendor-react-O8XH9yVn.js";import{c,R as o,A as i,C as d,X as m,Y as x,T as u,e as p,b as h}from"./recharts-BU7auunF.js";import{$ as j,a0 as y,a1 as f,a2 as g}from"./index-Dp0UlTio.js";import{e as v,a as b}from"./useThemeColors-CD0TSU03.js";import{P as N,b as w,a as k,c as C}from"./PageLayout-DE5PEtD2.js";import{R as F,C as _}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const M=Math.floor(12e5/g.system),S={primary:"bg-accent-tertiary",secondary:"bg-accent-secondary",green:"bg-accent-success",red:"bg-accent-danger",yellow:"bg-accent-secondary"},G=[{threshold:30,color:"var(--accent-tertiary)",next:"var(--accent-success)"},{threshold:50,color:"var(--accent-success)",next:"var(--accent-secondary)"},{threshold:65,color:"var(--accent-secondary)",next:"var(--signal-poor)"},{threshold:80,color:"var(--signal-poor)",next:"var(--accent-danger)"}];function L(e,t,s){const a=s-t,r={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:r.cold,color:"var(--accent-tertiary)"},{pos:r.cold,color:"var(--accent-success)"},{pos:r.normal,color:"var(--accent-success)"},{pos:r.normal,color:"var(--accent-secondary)"},{pos:r.warm,color:"var(--accent-secondary)"},{pos:r.warm,color:"var(--signal-poor)"},{pos:r.hot,color:"var(--signal-poor)"},{pos:r.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(", ")})`}const T=e.memo(function({value:e,max:s=100,color:a="primary"}){const r=Math.min(e/s*100,100),l=r>90?"bg-accent-danger":r>70?"bg-accent-secondary":S[a];return t.jsx("div",{className:"h-2.5 bg-white/[0.02] rounded-full overflow-hidden",children:t.jsx("div",{className:c("h-full rounded-full",l),style:{width:`${r}%`}})})}),U=e.memo(function({value:e,label:s,min:a=20,max:r=100}){const l=Math.min(Math.max((e-a)/(r-a)*100,0),100),n=function(e){return e<30?{text:"Cool",color:"text-accent-tertiary"}:e<50?{text:"Normal",color:"text-accent-success"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=r-a;return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between items-baseline",children:[t.jsx("span",{className:"text-sm text-text-muted",children:s}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-xs text-text-muted",children:n.text}),t.jsxs("span",{className:"text-sm font-mono tabular-nums",children:[t.jsx("span",{className:n.color,children:e.toFixed(1)}),t.jsx("span",{className:"text-text-primary",children:"°"})]})]})]}),t.jsxs("div",{className:"relative h-2 bg-white/[0.02] rounded-full overflow-hidden",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:L(l,a,r),width:`${l}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:G.map(({threshold:e,color:s})=>{const r=(e-a)/c*100;return r<0||r>100?null:t.jsx("div",{className:"absolute w-px h-full",style:{left:`${r}%`,backgroundColor:s}},e)})})]})]})});function O({payload:e}){return e?t.jsx("div",{className:"flex items-center gap-4 justify-center text-xs font-mono",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"text-text-muted",children:e.value})]},s))}):null}function $({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 A=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:r}){const l=function(e){const t=[],s=Math.max(0,M-e.length),a=Date.now(),r=g.system;for(let n=0;n`${e}%`}),t.jsx(u,{content:t.jsx($,{})}),t.jsx(p,{content:t.jsx(O,{})}),t.jsx(h,{type:"stepAfter",dataKey:"cpu",name:"CPU",stroke:s,strokeWidth:2,fill:"url(#cpuGradient)",fillOpacity:.85,isAnimationActive:!1,connectNulls:!1}),t.jsx(h,{type:"stepAfter",dataKey:"memory",name:"Memory",stroke:a,strokeWidth:2,fill:"url(#memoryGradient)",fillOpacity:.85,isAnimationActive:!1,connectNulls:!1})]})})})});function P(){const[o,i]=e.useState(null),[d,m]=e.useState(!0),[x,u]=e.useState(null),[p,h]=e.useState(!1),S=j(),G=y(),L=v(),O=b(),$=L.chart3,P=L.chart4,R=e.useCallback(async()=>{try{const e=await f();e.success&&e.data?(i(e.data),u(null),G(e.data.cpu.usage_percent,e.data.memory.usage_percent,M)):u(e.error??"Failed to fetch hardware stats")}catch(e){u(e instanceof Error?e.message:"Failed to fetch hardware stats")}},[G]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await R(),e&&m(!1))})(),"undefined"==typeof Worker){const t=setInterval(R,g.system);return()=>{e=!1,clearInterval(t)}}{const s=`setInterval(() => postMessage('tick'), ${g.system});`,a=new Blob([s],{type:"application/javascript"});t=new Worker(URL.createObjectURL(a)),t.onmessage=()=>{e&&R()}}return()=>{e=!1,null==t||t.terminate()}},[R]),t.jsxs(N,{children:[t.jsx(w,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{h(!0),await R(),h(!1)},disabled:p,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:c("w-4 h-4",p&&"animate-spin")}),"Refresh"]})}),x&&t.jsx(k,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:x})}),d?t.jsx(k,{className:"p-12 text-center",children:t.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading system stats..."})}):o?t.jsxs(t.Fragment,{children:[t.jsx(F,{template:"hero",children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(r,{}),title:"System Resources",subtitle:"20 minute rolling window",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"type-micro",children:"CPU"}),t.jsxs("span",{className:"type-data font-semibold tabular-nums",style:{color:$},children:[o.cpu.usage_percent.toFixed(0),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"type-micro",children:"MEM"}),t.jsxs("span",{className:"type-data font-semibold tabular-nums",style:{color:P},children:[o.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(A,{data:S,cpuColor:$,memoryColor:P,chartGridColors:O})}),t.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-border-subtle text-xs text-text-muted flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("span",{children:[o.cpu.count," CPU cores"]}),o.cpu.load_avg&&t.jsxs("span",{className:"tabular-nums",children:["Load: ",o.cpu.load_avg["1min"].toFixed(2)," / ",o.cpu.load_avg["5min"].toFixed(2)," / ",o.cpu.load_avg["15min"].toFixed(2)]})]}),t.jsxs("span",{className:"tabular-nums",children:[(o.memory.used/1048576).toFixed(0)," / ",(o.memory.total/1048576).toFixed(0)," MB"]})]})]})}),t.jsxs(F,{template:"compact",children:[t.jsx(_,{span:12,md:6,children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(l,{}),title:"Disk Usage",subtitle:"Storage utilization",largeTitle:!0}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-text-muted",children:"Usage"}),t.jsxs("span",{className:"text-text-primary font-medium",children:[o.disk.usage_percent.toFixed(1),"%"]})]}),t.jsx(T,{value:o.disk.usage_percent,color:"green"}),t.jsxs("div",{className:"flex justify-between text-sm mt-2",children:[t.jsxs("span",{className:"text-text-muted",children:[(o.disk.used/1073741824).toFixed(1)," GB used"]}),t.jsxs("span",{className:"text-text-muted",children:[(o.disk.total/1073741824).toFixed(1)," GB total"]})]})]})]})}),t.jsx(_,{span:12,md:6,children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(n,{}),title:"Temperature",subtitle:"System sensors",largeTitle:!0}),o.temperatures&&Object.keys(o.temperatures).length>0?t.jsxs("div",{className:"space-y-2.5",children:[void 0!==o.temperatures.cpu_thermal&&t.jsx(U,{value:o.temperatures.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(o.temperatures).filter(([e])=>"cpu_thermal"!==e).slice(0,3).map(([e,s])=>t.jsx(U,{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 h-20 text-text-muted text-sm",children:[t.jsx(r,{className:"w-4 h-4 mr-2"}),"No sensors available"]})]})})]})]}):null]})}export{P as default}; +import{r as e,j as t,a2 as s,aT as a,ae as r,aU as l,aV as n}from"./vendor-react-O8XH9yVn.js";import{c,R as o,A as i,C as d,X as m,Y as x,T as u,e as p,b as h}from"./recharts-BU7auunF.js";import{$ as j,a0 as y,a1 as f,a2 as g}from"./index-DGrzd8xb.js";import{e as v,a as b}from"./useThemeColors-CD0TSU03.js";import{P as N,b as w,a as k,c as C}from"./PageLayout-DE5PEtD2.js";import{R as F,C as _}from"./Grid-CIZAny_R.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const M=Math.floor(12e5/g.system),S={primary:"bg-accent-tertiary",secondary:"bg-accent-secondary",green:"bg-accent-success",red:"bg-accent-danger",yellow:"bg-accent-secondary"},G=[{threshold:30,color:"var(--accent-tertiary)",next:"var(--accent-success)"},{threshold:50,color:"var(--accent-success)",next:"var(--accent-secondary)"},{threshold:65,color:"var(--accent-secondary)",next:"var(--signal-poor)"},{threshold:80,color:"var(--signal-poor)",next:"var(--accent-danger)"}];function L(e,t,s){const a=s-t,r={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:r.cold,color:"var(--accent-tertiary)"},{pos:r.cold,color:"var(--accent-success)"},{pos:r.normal,color:"var(--accent-success)"},{pos:r.normal,color:"var(--accent-secondary)"},{pos:r.warm,color:"var(--accent-secondary)"},{pos:r.warm,color:"var(--signal-poor)"},{pos:r.hot,color:"var(--signal-poor)"},{pos:r.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(", ")})`}const T=e.memo(function({value:e,max:s=100,color:a="primary"}){const r=Math.min(e/s*100,100),l=r>90?"bg-accent-danger":r>70?"bg-accent-secondary":S[a];return t.jsx("div",{className:"h-2.5 bg-white/[0.02] rounded-full overflow-hidden",children:t.jsx("div",{className:c("h-full rounded-full",l),style:{width:`${r}%`}})})}),U=e.memo(function({value:e,label:s,min:a=20,max:r=100}){const l=Math.min(Math.max((e-a)/(r-a)*100,0),100),n=function(e){return e<30?{text:"Cool",color:"text-accent-tertiary"}:e<50?{text:"Normal",color:"text-accent-success"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=r-a;return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex justify-between items-baseline",children:[t.jsx("span",{className:"text-sm text-text-muted",children:s}),t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-xs text-text-muted",children:n.text}),t.jsxs("span",{className:"text-sm font-mono tabular-nums",children:[t.jsx("span",{className:n.color,children:e.toFixed(1)}),t.jsx("span",{className:"text-text-primary",children:"°"})]})]})]}),t.jsxs("div",{className:"relative h-2 bg-white/[0.02] rounded-full overflow-hidden",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:L(l,a,r),width:`${l}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:G.map(({threshold:e,color:s})=>{const r=(e-a)/c*100;return r<0||r>100?null:t.jsx("div",{className:"absolute w-px h-full",style:{left:`${r}%`,backgroundColor:s}},e)})})]})]})});function O({payload:e}){return e?t.jsx("div",{className:"flex items-center gap-4 justify-center text-xs font-mono",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"text-text-muted",children:e.value})]},s))}):null}function $({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 A=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:r}){const l=function(e){const t=[],s=Math.max(0,M-e.length),a=Date.now(),r=g.system;for(let n=0;n`${e}%`}),t.jsx(u,{content:t.jsx($,{})}),t.jsx(p,{content:t.jsx(O,{})}),t.jsx(h,{type:"stepAfter",dataKey:"cpu",name:"CPU",stroke:s,strokeWidth:2,fill:"url(#cpuGradient)",fillOpacity:.85,isAnimationActive:!1,connectNulls:!1}),t.jsx(h,{type:"stepAfter",dataKey:"memory",name:"Memory",stroke:a,strokeWidth:2,fill:"url(#memoryGradient)",fillOpacity:.85,isAnimationActive:!1,connectNulls:!1})]})})})});function P(){const[o,i]=e.useState(null),[d,m]=e.useState(!0),[x,u]=e.useState(null),[p,h]=e.useState(!1),S=j(),G=y(),L=v(),O=b(),$=L.chart3,P=L.chart4,R=e.useCallback(async()=>{try{const e=await f();e.success&&e.data?(i(e.data),u(null),G(e.data.cpu.usage_percent,e.data.memory.usage_percent,M)):u(e.error??"Failed to fetch hardware stats")}catch(e){u(e instanceof Error?e.message:"Failed to fetch hardware stats")}},[G]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await R(),e&&m(!1))})(),"undefined"==typeof Worker){const t=setInterval(R,g.system);return()=>{e=!1,clearInterval(t)}}{const s=`setInterval(() => postMessage('tick'), ${g.system});`,a=new Blob([s],{type:"application/javascript"});t=new Worker(URL.createObjectURL(a)),t.onmessage=()=>{e&&R()}}return()=>{e=!1,null==t||t.terminate()}},[R]),t.jsxs(N,{children:[t.jsx(w,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{h(!0),await R(),h(!1)},disabled:p,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:c("w-4 h-4",p&&"animate-spin")}),"Refresh"]})}),x&&t.jsx(k,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:x})}),d?t.jsx(k,{className:"p-12 text-center",children:t.jsx("div",{className:"animate-pulse text-text-muted",children:"Loading system stats..."})}):o?t.jsxs(t.Fragment,{children:[t.jsx(F,{template:"hero",children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(r,{}),title:"System Resources",subtitle:"20 minute rolling window",largeTitle:!0,actions:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"type-micro",children:"CPU"}),t.jsxs("span",{className:"type-data font-semibold tabular-nums",style:{color:$},children:[o.cpu.usage_percent.toFixed(0),"%"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"type-micro",children:"MEM"}),t.jsxs("span",{className:"type-data font-semibold tabular-nums",style:{color:P},children:[o.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(A,{data:S,cpuColor:$,memoryColor:P,chartGridColors:O})}),t.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-border-subtle text-xs text-text-muted flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("span",{children:[o.cpu.count," CPU cores"]}),o.cpu.load_avg&&t.jsxs("span",{className:"tabular-nums",children:["Load: ",o.cpu.load_avg["1min"].toFixed(2)," / ",o.cpu.load_avg["5min"].toFixed(2)," / ",o.cpu.load_avg["15min"].toFixed(2)]})]}),t.jsxs("span",{className:"tabular-nums",children:[(o.memory.used/1048576).toFixed(0)," / ",(o.memory.total/1048576).toFixed(0)," MB"]})]})]})}),t.jsxs(F,{template:"compact",children:[t.jsx(_,{span:12,md:6,children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(l,{}),title:"Disk Usage",subtitle:"Storage utilization",largeTitle:!0}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-text-muted",children:"Usage"}),t.jsxs("span",{className:"text-text-primary font-medium",children:[o.disk.usage_percent.toFixed(1),"%"]})]}),t.jsx(T,{value:o.disk.usage_percent,color:"green"}),t.jsxs("div",{className:"flex justify-between text-sm mt-2",children:[t.jsxs("span",{className:"text-text-muted",children:[(o.disk.used/1073741824).toFixed(1)," GB used"]}),t.jsxs("span",{className:"text-text-muted",children:[(o.disk.total/1073741824).toFixed(1)," GB total"]})]})]})]})}),t.jsx(_,{span:12,md:6,children:t.jsxs(k,{children:[t.jsx(C,{icon:t.jsx(n,{}),title:"Temperature",subtitle:"System sensors",largeTitle:!0}),o.temperatures&&Object.keys(o.temperatures).length>0?t.jsxs("div",{className:"space-y-2.5",children:[void 0!==o.temperatures.cpu_thermal&&t.jsx(U,{value:o.temperatures.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(o.temperatures).filter(([e])=>"cpu_thermal"!==e).slice(0,3).map(([e,s])=>t.jsx(U,{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 h-20 text-text-muted text-sm",children:[t.jsx(r,{className:"w-4 h-4 mr-2"}),"No sensors available"]})]})})]})]}):null]})}export{P as default}; diff --git a/frontend/dist/assets/Terminal-Vhl_DY50.js b/frontend/dist/assets/Terminal-CXpxYdmx.js similarity index 67% rename from frontend/dist/assets/Terminal-Vhl_DY50.js rename to frontend/dist/assets/Terminal-CXpxYdmx.js index ae14012f..f7232cb6 100644 --- a/frontend/dist/assets/Terminal-Vhl_DY50.js +++ b/frontend/dist/assets/Terminal-CXpxYdmx.js @@ -1 +1 @@ -import{c as e,r as a,j as t,S as r}from"./vendor-react-O8XH9yVn.js";import{c as s}from"./recharts-BU7auunF.js";import{d as n,a8 as o,a9 as i,aa as l,ab as c,ac as m,a6 as d}from"./index-Dp0UlTio.js";import{P as p,b as y,a as u}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const g=e(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:a=>{const t="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const a=16*Math.random()|0;return("x"===e?a:3&a|8).toString(16)}),r={...a,id:t,timestamp:Date.now()};return e(e=>({entries:[...e.entries,r]})),t},updateEntry:(a,t)=>{e(e=>({entries:e.entries.map(e=>e.id===a?{...e,...t}:e)}))},addCommand:a=>{e(e=>({commandHistory:[...e.commandHistory,a]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:a=>{e({isInitialized:a})}})),h=new Set(["start ota","erase","reboot"]),f=["gps","sensor"],v=[{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"},...[{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&&!h.has(e.name)&&!f.some(a=>e.name.startsWith(a))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],x={"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"]};function b(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 w=a.memo(function({entry:e}){return"command"===e.type?t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx("span",{className:"text-text-muted font-medium select-none",children:"$"}),t.jsx("span",{className:"text-text-primary font-semibold",children:e.content})]}):"system"===e.type?t.jsx("div",{className:s("py-0.5",b(e.outputType||"system")),children:e.content}):e.content.includes("██")?t.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",b(e.outputType||"value")),children:e.content}):t.jsx("div",{className:"ml-4 font-mono text-[13px] py-1",children:e.content.split("\n").map((a,r)=>{const s=function(e,a){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 t=e.match(/^([a-z][a-z0-9.]*(?:\s+[a-z][a-z0-9.]*)?):::(.+)$/);if(t){const[,e,a]=t,r=e.split(" "),s=r[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`}];r.length>1&&o.push({text:` ${r.slice(1).join(" ")}`,color:"text-accent-primary"});const i=" ".repeat(Math.max(1,22-e.length));return o.push({text:`${i}${a}`,color:"text-text-muted"}),o}if("error"===a||"warning"===a)return[{text:e,color:b(a)}];if("value"===a)return[{text:e,color:b("value")}];const r=e.match(/^([\w\s.]+):\s*(.+)$/);if(r){const[,e,a]=r;return[{text:`${e}: `,color:"text-text-muted"},{text:a,color:"text-accent-primary font-semibold"}]}return e.startsWith("OK")?[{text:e,color:b("success")}]:[{text:e,color:b(a)}]}(a,e.outputType||"default");return t.jsx("div",{className:"leading-relaxed",children:s.map((e,a)=>t.jsx("span",{className:e.color,children:e.text},a))},r)})})});function O(){const e=n(),h=g(e=>e.entries),f=g(e=>e.commandHistory),b=g(e=>e.isInitialized),{addEntry:O,updateEntry:P,addCommand:k,clearEntries:S,setInitialized:$}=g(),[_,N]=a.useState(""),[E,j]=a.useState(-1),[G,T]=a.useState(!1),[C,F]=a.useState([]),[D,W]=a.useState(0),[L,A]=a.useState(0),[I,R]=a.useState(!1),H=a.useRef(null),K=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{b||(async()=>{O({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=O({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),P(e,{content:"✓ Initializing terminal...",outputType:"success"});const a=O({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),P(a,{content:"✓ Connected to repeater",outputType:"success"}),O({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),$(!0)})()},[b,O,P,$]),a.useEffect(()=>{K.current&&(K.current.scrollTop=K.current.scrollHeight)},[h]);const q=a.useCallback(()=>{var e;null==(e=H.current)||e.focus()},[]),z=a.useCallback(e=>{const a=e.trim().toLowerCase();if(!a)return T(!1),void F([]);const t=v.filter(e=>e.cmd.toLowerCase().startsWith(a));if(t.length>0)return F(t),W(0),void T(!0);if(a.includes(" ")){const e=a.lastIndexOf(" "),t=a.substring(0,e),r=a.substring(e+1),s=v.find(e=>e.cmd.toLowerCase()===t);if(s&&x[s.cmd]){const e=x[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return F(e),W(0),void T(!0)}}T(!1),F([])},[]),X=a.useCallback(e=>{var a;const t=C[e];t&&(t.required&&t.params?(N(t.cmd+" "),z(t.cmd+" ")):(N(t.cmd),T(!1)),null==(a=H.current)||a.focus())},[C,z]),U=a.useCallback(async e=>{var a,t,r,s,n,p,y,u;const g=e.trim();if(!g)return;const h=g.toLowerCase();if(k(g),O({type:"command",content:g}),"clear"===h)return void S();if("help"===h){const e=v.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void O({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const f=O({type:"output",content:"processing...",outputType:"system"});try{const e=await o();let v="",x="info";const b=e=>{const a=Math.floor(e/86400),t=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return a>0?`${a}d ${t}h ${r}m`:t>0?`${t}h ${r}m`:`${r}m`};if("status"===h){v=`Mode: ${(null==(t=null==(a=e.config)?void 0:a.repeater)?void 0:t.mode)||"unknown"} | Neighbors: ${Object.keys(e.neighbors||{}).length} | Uptime: ${b(e.uptime_seconds||0)}`}else if("uptime"===h)v=b(e.uptime_seconds||0),x="value";else if("packets"===h)v=`rx: ${e.rx_count??0}\ntx: ${e.tx_count??0}\nfwd: ${e.forwarded_count??0}\ndrop: ${e.dropped_count??0}`;else if("neighbors"===h){const a=e.neighbors||{},t=Object.entries(a);if(0===t.length)v="No neighbors discovered yet.",x="warning";else{const e=t.map(([e,a])=>{const t=a.name||a.node_name||"Unknown";return` ${e.slice(0,8)} ${t}`});v=`Neighbors (${t.length}):\n${e.join("\n")}`}}else if("board"===h)v="pyMC_Repeater (Linux/RPi)",x="value";else if(h.startsWith("get ")){const a=h.slice(4).trim(),t=null==(r=e.config)?void 0:r.delays,o=null==(s=e.config)?void 0:s.radio,i=null==(n=e.config)?void 0:n.repeater,l=null==(p=e.config)?void 0:p.duty_cycle;switch(a){case"name":v=(null==(y=e.config)?void 0:y.node_name)||"Unknown";break;case"role":v="repeater";break;case"lat":v=null!=(null==i?void 0:i.latitude)?String(i.latitude):"not set";break;case"lon":v=null!=(null==i?void 0:i.longitude)?String(i.longitude):"not set";break;case"freq":v=(null==o?void 0:o.frequency)?(o.frequency/1e6).toFixed(3):"?";break;case"tx":v=String((null==o?void 0:o.tx_power)??"?");break;case"bw":v=(null==o?void 0:o.bandwidth)?String(o.bandwidth/1e3):"?";break;case"sf":v=String((null==o?void 0:o.spreading_factor)??"?");break;case"cr":v=String((null==o?void 0:o.coding_rate)??"?");break;case"radio":v=o?`freq: ${(o.frequency/1e6).toFixed(3)} MHz\nbw: ${o.bandwidth/1e3} kHz\nsf: ${o.spreading_factor}\ncr: 4/${o.coding_rate}`:"?";break;case"af":case"txdelay":v=String((null==t?void 0:t.tx_delay_factor)??"1.0");break;case"direct.txdelay":v=String((null==t?void 0:t.direct_tx_delay_factor)??"0.5");break;case"mode":v=(null==i?void 0:i.mode)||"forward";break;case"repeat":v="forward"===(null==i?void 0:i.mode)?"on":"off";break;case"flood.max":v=String((null==i?void 0:i.max_flood_hops)??"3");break;case"flood.advert.interval":v=null!=(null==i?void 0:i.send_advert_interval_hours)?`${i.send_advert_interval_hours}h`:"?";break;case"advert.interval":v=null!=(null==i?void 0:i.advert_interval_minutes)?`${i.advert_interval_minutes}m`:"120m";break;case"rxdelay":v=String((null==t?void 0:t.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":v=(null==l?void 0:l.enforcement_enabled)?"on":"off";break;case"duty.max":v=null!=(null==l?void 0:l.max_airtime_percent)?`${l.max_airtime_percent}%`:"?";break;case"public.key":v=e.public_key||"not available";break;case"prv.key":v="Private key not available via stats API.\nRun: sudo ./manage.sh upgrade to apply PATCH 6",x="warning";break;case"guest.password":case"allow.read.only":v="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",x="warning";break;default:v=`Unknown parameter: ${a}\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`,x="error"}"error"!==x&&(x="value")}else if("advert"===h){const e=await i();v=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,x=e.success?"success":"error"}else if(h.startsWith("set mode ")){const e=h.split(" ")[2];if("forward"!==e&&"monitor"!==e)v='Error: Mode must be "forward" or "monitor"',x="error";else{const a=await l(e);v=a.success?`OK - Mode set to ${e}`:"Error: Failed",x=a.success?"success":"error"}}else if(h.startsWith("set duty ")){const e=h.split(" ")[2],a="on"===e||"1"===e,t=await c(a);v=t.success?"OK - Duty cycle "+(a?"enabled":"disabled"):"Error: Failed",x=t.success?"success":"error"}else if(h.startsWith("set tx ")){const e=parseInt(h.split(" ")[2]);if(isNaN(e)||e<2||e>22)v="Error: TX power must be 2-22 dBm (SX1262 chip max)",x="error";else{const a=await m({tx_power:e});v=a.success?`OK - TX power set to ${e}dBm`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set af ")||h.startsWith("set txdelay ")){const e=parseFloat(h.split(" ")[2]);if(isNaN(e)||e<0||e>5)v="Error: TX delay factor must be 0.0-5.0",x="error";else{const a=await m({tx_delay_factor:e});v=a.success?`OK - TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set direct.txdelay ")){const e=parseFloat(h.split(" ")[2]);if(isNaN(e)||e<0||e>5)v="Error: Direct TX delay must be 0.0-5.0",x="error";else{const a=await m({direct_tx_delay_factor:e});v=a.success?`OK - Direct TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set log ")){const e=null==(u=h.split(" ")[2])?void 0:u.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const a=await d(e);v=a.success?`OK - Log level set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}else v="Error: Level must be debug, info, warning, or error",x="error"}else if(h.startsWith("set rxdelay ")){const e=parseFloat(h.split(" ")[2]);if(isNaN(e)||e<0)v="Error: RX delay must be >= 0",x="error";else{const a=await m({rx_delay_base:e});v=a.success?`OK - RX delay base set to ${e}s`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set name ")){const e=g.substring(9).trim();if(e){const a=await m({node_name:e});v=a.success?`OK - Node name set to "${e}"`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}else v="Error: Node name cannot be empty",x="error"}else if(h.startsWith("set lat ")){const e=parseFloat(h.split(" ")[2]);if(isNaN(e)||e<-90||e>90)v="Error: Latitude must be -90 to 90",x="error";else{const a=await m({latitude:e});v=a.success?`OK - Latitude set to ${e}°`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set lon ")){const e=parseFloat(h.split(" ")[2]);if(isNaN(e)||e<-180||e>180)v="Error: Longitude must be -180 to 180",x="error";else{const a=await m({longitude:e});v=a.success?`OK - Longitude set to ${e}°`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set flood.max ")){const e=parseInt(h.split(" ")[2]);if(isNaN(e)||e<0||e>64)v="Error: Max flood hops must be 0-64",x="error";else{const a=await m({max_flood_hops:e});v=a.success?`OK - Max flood hops set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set flood.advert.interval ")){const e=parseInt(h.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))v="Error: Flood advert interval must be 0 (off) or 3-48 hours",x="error";else{const a=await m({flood_advert_interval_hours:e});v=a.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(h.startsWith("set advert.interval ")){const e=parseInt(h.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))v="Error: Advert interval must be 0 (off) or 1-10080 minutes",x="error";else{const a=await m({advert_interval_minutes:e});v=a.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else v=`Unknown command: ${g}\nType 'help' for available commands.`,x="error";P(f,{content:v,outputType:x})}catch(x){P(f,{content:`Error: ${x instanceof Error?x.message:"Command failed"}`,outputType:"error"})}},[O,k,P,S]),B=a.useCallback(e=>{var a,t,r,s,n,o;if(G&&C.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(D+1,C.length-1);return W(s),void(null==(r=null==(t=null==(a=M.current)?void 0:a.children[0])?void 0:t.children[s])||r.scrollIntoView({block:"nearest"}))}if("ArrowUp"===e.key){e.preventDefault();const a=Math.max(D-1,0);return W(a),void(null==(o=null==(n=null==(s=M.current)?void 0:s.children[0])?void 0:n.children[a])||o.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void X(D);if("Escape"===e.key)return e.preventDefault(),void T(!1)}if("Enter"===e.key){e.preventDefault();const a=_;return N(""),j(-1),T(!1),void U(a)}if("ArrowUp"!==e.key||G)if("ArrowDown"!==e.key||G);else if(e.preventDefault(),E>0){const e=E-1;j(e),N(f[f.length-1-e]||"")}else 0===E&&(j(-1),N(""));else if(e.preventDefault(),f.length>0&&E{N(e.target.value),A(e.target.selectionStart||e.target.value.length),z(e.target.value)},[z]),J=a.useCallback(e=>{const a=e.target;A(a.selectionStart||0)},[]);return t.jsxs(p,{children:[t.jsx(y,{title:"Terminal",icon:t.jsx(r,{})}),t.jsxs(u,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:q,children:[t.jsx("div",{ref:K,className:"flex-1 overflow-y-auto font-mono text-sm bg-black/40 p-3 sm:p-4 md:p-5",children:h.map(e=>t.jsx(w,{entry:e},e.id))}),t.jsxs("div",{className:"relative border-t border-white/10 bg-black/50",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-3",children:[t.jsx("span",{className:"text-text-muted font-mono font-bold select-none",children:"$"}),t.jsxs("div",{className:"flex-1 relative font-mono text-sm",children:[t.jsx("input",{ref:H,type:"text",value:_,onChange:V,onKeyDown:B,onSelect:J,onFocus:()=>R(!0),onBlur:()=>R(!1),disabled:!b,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}),t.jsx("div",{className:"relative pointer-events-none select-none","aria-hidden":!0,children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-text-primary",children:_.slice(0,L)}),t.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",I?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:t.jsx("span",{className:"text-bg-primary",children:_[L]||""})}),t.jsx("span",{className:"text-text-primary",children:_.slice(L+1)})]}):t.jsx("span",{className:"text-text-muted",children:"Connecting..."})})]})]}),t.jsxs("div",{className:"px-3 sm:px-4 py-1 border-t border-white/5 bg-black/30 flex justify-between text-[10px] text-text-muted",children:[t.jsx("span",{className:"hidden sm:inline",children:"↑↓ History"}),t.jsx("span",{className:"sm:hidden",children:"Terminal"}),(null==e?void 0:e.version)&&t.jsxs("span",{children:["pyMC v",e.version]})]})]}),G&&C.length>0&&t.jsxs("div",{ref:M,className:"absolute left-2 right-2 bottom-[72px] rounded-xl shadow-2xl overflow-hidden z-50 border border-white/20 bg-black/80 backdrop-blur-xl",children:[t.jsx("div",{className:"max-h-64 overflow-y-auto",children:C.map((e,a)=>t.jsxs("div",{onClick:()=>X(a),className:s("px-4 py-2.5 cursor-pointer border-b border-white/10 last:border-b-0 transition-colors",a===D?"bg-accent-primary/25":"hover:bg-white/10"),children:[t.jsx("span",{className:s("font-mono text-sm",a===D?"text-accent-primary":"text-text-primary"),children:e.cmd}),t.jsx("span",{className:"text-xs text-text-muted ml-4",children:e.desc})]},e.cmd))}),t.jsx("div",{className:"px-3 py-1.5 border-t border-white/10 text-[10px] text-text-muted text-right bg-white/5",children:"Tab to select"})]})]})]})}export{O as default}; +import{c as e,r as a,j as t,S as r}from"./vendor-react-O8XH9yVn.js";import{c as s}from"./recharts-BU7auunF.js";import{d as n,a8 as o,a9 as i,aa as l,ab as c,ac as m,a6 as d}from"./index-DGrzd8xb.js";import{P as p,b as y,a as u}from"./PageLayout-DE5PEtD2.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const g=e(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:a=>{const t="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const a=16*Math.random()|0;return("x"===e?a:3&a|8).toString(16)}),r={...a,id:t,timestamp:Date.now()};return e(e=>({entries:[...e.entries,r]})),t},updateEntry:(a,t)=>{e(e=>({entries:e.entries.map(e=>e.id===a?{...e,...t}:e)}))},addCommand:a=>{e(e=>({commandHistory:[...e.commandHistory,a]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:a=>{e({isInitialized:a})}})),f=new Set(["start ota","erase","reboot"]),h=["gps","sensor"],v=[{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"},...[{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&&!f.has(e.name)&&!h.some(a=>e.name.startsWith(a))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],x={"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"]};function b(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 w=a.memo(function({entry:e}){return"command"===e.type?t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx("span",{className:"text-text-muted font-medium select-none",children:"$"}),t.jsx("span",{className:"text-text-primary font-semibold",children:e.content})]}):"system"===e.type?t.jsx("div",{className:s("py-0.5",b(e.outputType||"system")),children:e.content}):e.content.includes("██")?t.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",b(e.outputType||"value")),children:e.content}):t.jsx("div",{className:"ml-4 font-mono text-[13px] py-1",children:e.content.split("\n").map((a,r)=>{const s=function(e,a){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 t=e.match(/^([a-z][a-z0-9.]*(?:\s+[a-z][a-z0-9.]*)?):::(.+)$/);if(t){const[,e,a]=t,r=e.split(" "),s=r[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`}];r.length>1&&o.push({text:` ${r.slice(1).join(" ")}`,color:"text-accent-primary"});const i=" ".repeat(Math.max(1,22-e.length));return o.push({text:`${i}${a}`,color:"text-text-muted"}),o}if("error"===a||"warning"===a)return[{text:e,color:b(a)}];if("value"===a)return[{text:e,color:b("value")}];const r=e.match(/^([\w\s.]+):\s*(.+)$/);if(r){const[,e,a]=r;return[{text:`${e}: `,color:"text-text-muted"},{text:a,color:"text-accent-primary font-semibold"}]}return e.startsWith("OK")?[{text:e,color:b("success")}]:[{text:e,color:b(a)}]}(a,e.outputType||"default");return t.jsx("div",{className:"leading-relaxed",children:s.map((e,a)=>t.jsx("span",{className:e.color,children:e.text},a))},r)})})});function O(){const e=n(),f=g(e=>e.entries),h=g(e=>e.commandHistory),b=g(e=>e.isInitialized),{addEntry:O,updateEntry:P,addCommand:k,clearEntries:S,setInitialized:$}=g(),[_,N]=a.useState(""),[E,j]=a.useState(-1),[G,T]=a.useState(!1),[C,F]=a.useState([]),[D,W]=a.useState(0),[L,I]=a.useState(0),[R,A]=a.useState(!1),H=a.useRef(null),K=a.useRef(null),M=a.useRef(null);a.useEffect(()=>{b||(async()=>{O({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=O({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),P(e,{content:"✓ Initializing terminal...",outputType:"success"});const a=O({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),P(a,{content:"✓ Connected to repeater",outputType:"success"}),O({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),$(!0)})()},[b,O,P,$]),a.useEffect(()=>{K.current&&(K.current.scrollTop=K.current.scrollHeight)},[f]);const q=a.useCallback(()=>{var e;null==(e=H.current)||e.focus()},[]),z=a.useCallback(e=>{const a=e.trim().toLowerCase();if(!a)return T(!1),void F([]);const t=v.filter(e=>e.cmd.toLowerCase().startsWith(a));if(t.length>0)return F(t),W(0),void T(!0);if(a.includes(" ")){const e=a.lastIndexOf(" "),t=a.substring(0,e),r=a.substring(e+1),s=v.find(e=>e.cmd.toLowerCase()===t);if(s&&x[s.cmd]){const e=x[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return F(e),W(0),void T(!0)}}T(!1),F([])},[]),X=a.useCallback(e=>{var a;const t=C[e];t&&(t.required&&t.params?(N(t.cmd+" "),z(t.cmd+" ")):(N(t.cmd),T(!1)),null==(a=H.current)||a.focus())},[C,z]),U=a.useCallback(async e=>{var a,t,r,s,n,p,y,u;const g=e.trim();if(!g)return;const f=g.toLowerCase();if(k(g),O({type:"command",content:g}),"clear"===f)return void S();if("help"===f){const e=v.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void O({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const h=O({type:"output",content:"processing...",outputType:"system"});try{const e=await o();let v="",x="info";const b=e=>{const a=Math.floor(e/86400),t=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return a>0?`${a}d ${t}h ${r}m`:t>0?`${t}h ${r}m`:`${r}m`};if("status"===f){v=`Mode: ${(null==(t=null==(a=e.config)?void 0:a.repeater)?void 0:t.mode)||"unknown"} | Neighbors: ${Object.keys(e.neighbors||{}).length} | Uptime: ${b(e.uptime_seconds||0)}`}else if("uptime"===f)v=b(e.uptime_seconds||0),x="value";else if("packets"===f)v=`rx: ${e.rx_count??0}\ntx: ${e.tx_count??0}\nfwd: ${e.forwarded_count??0}\ndrop: ${e.dropped_count??0}`;else if("neighbors"===f){const a=e.neighbors||{},t=Object.entries(a);if(0===t.length)v="No neighbors discovered yet.",x="warning";else{const e=t.map(([e,a])=>{const t=a.name||a.node_name||"Unknown";return` ${e.slice(0,8)} ${t}`});v=`Neighbors (${t.length}):\n${e.join("\n")}`}}else if("board"===f)v="pyMC_Repeater (Linux/RPi)",x="value";else if(f.startsWith("get ")){const a=f.slice(4).trim(),t=null==(r=e.config)?void 0:r.delays,o=null==(s=e.config)?void 0:s.radio,i=null==(n=e.config)?void 0:n.repeater,l=null==(p=e.config)?void 0:p.duty_cycle;switch(a){case"name":v=(null==(y=e.config)?void 0:y.node_name)||"Unknown";break;case"role":v="repeater";break;case"lat":v=null!=(null==i?void 0:i.latitude)?String(i.latitude):"not set";break;case"lon":v=null!=(null==i?void 0:i.longitude)?String(i.longitude):"not set";break;case"freq":v=(null==o?void 0:o.frequency)?(o.frequency/1e6).toFixed(3):"?";break;case"tx":v=String((null==o?void 0:o.tx_power)??"?");break;case"bw":v=(null==o?void 0:o.bandwidth)?String(o.bandwidth/1e3):"?";break;case"sf":v=String((null==o?void 0:o.spreading_factor)??"?");break;case"cr":v=String((null==o?void 0:o.coding_rate)??"?");break;case"radio":v=o?`freq: ${(o.frequency/1e6).toFixed(3)} MHz\nbw: ${o.bandwidth/1e3} kHz\nsf: ${o.spreading_factor}\ncr: 4/${o.coding_rate}`:"?";break;case"af":case"txdelay":v=String((null==t?void 0:t.tx_delay_factor)??"1.0");break;case"direct.txdelay":v=String((null==t?void 0:t.direct_tx_delay_factor)??"0.5");break;case"mode":v=(null==i?void 0:i.mode)||"forward";break;case"repeat":v="forward"===(null==i?void 0:i.mode)?"on":"off";break;case"flood.max":v=String((null==i?void 0:i.max_flood_hops)??"3");break;case"flood.advert.interval":v=null!=(null==i?void 0:i.send_advert_interval_hours)?`${i.send_advert_interval_hours}h`:"?";break;case"advert.interval":v=null!=(null==i?void 0:i.advert_interval_minutes)?`${i.advert_interval_minutes}m`:"120m";break;case"rxdelay":v=String((null==t?void 0:t.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":v=(null==l?void 0:l.enforcement_enabled)?"on":"off";break;case"duty.max":v=null!=(null==l?void 0:l.max_airtime_percent)?`${l.max_airtime_percent}%`:"?";break;case"public.key":v=e.public_key||"not available";break;case"prv.key":v="Private keys not available via CLI.\nUse /api/identities endpoint or config.yaml",x="warning";break;case"guest.password":case"allow.read.only":v="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",x="warning";break;default:v=`Unknown parameter: ${a}\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`,x="error"}"error"!==x&&(x="value")}else if("advert"===f){const e=await i();v=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,x=e.success?"success":"error"}else if(f.startsWith("set mode ")){const e=f.split(" ")[2];if("forward"!==e&&"monitor"!==e)v='Error: Mode must be "forward" or "monitor"',x="error";else{const a=await l(e);v=a.success?`OK - Mode set to ${e}`:"Error: Failed",x=a.success?"success":"error"}}else if(f.startsWith("set duty ")){const e=f.split(" ")[2],a="on"===e||"1"===e,t=await c(a);v=t.success?"OK - Duty cycle "+(a?"enabled":"disabled"):"Error: Failed",x=t.success?"success":"error"}else if(f.startsWith("set tx ")){const e=parseInt(f.split(" ")[2]);if(isNaN(e)||e<2||e>22)v="Error: TX power must be 2-22 dBm (SX1262 chip max)",x="error";else{const a=await m({tx_power:e});v=a.success?`OK - TX power set to ${e}dBm`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set af ")||f.startsWith("set txdelay ")){const e=parseFloat(f.split(" ")[2]);if(isNaN(e)||e<0||e>5)v="Error: TX delay factor must be 0.0-5.0",x="error";else{const a=await m({tx_delay_factor:e});v=a.success?`OK - TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set direct.txdelay ")){const e=parseFloat(f.split(" ")[2]);if(isNaN(e)||e<0||e>5)v="Error: Direct TX delay must be 0.0-5.0",x="error";else{const a=await m({direct_tx_delay_factor:e});v=a.success?`OK - Direct TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set log ")){const e=null==(u=f.split(" ")[2])?void 0:u.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const a=await d(e);v=a.success?`OK - Log level set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}else v="Error: Level must be debug, info, warning, or error",x="error"}else if(f.startsWith("set rxdelay ")){const e=parseFloat(f.split(" ")[2]);if(isNaN(e)||e<0)v="Error: RX delay must be >= 0",x="error";else{const a=await m({rx_delay_base:e});v=a.success?`OK - RX delay base set to ${e}s`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set name ")){const e=g.substring(9).trim();if(e){const a=await m({node_name:e});v=a.success?`OK - Node name set to "${e}"`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}else v="Error: Node name cannot be empty",x="error"}else if(f.startsWith("set lat ")){const e=parseFloat(f.split(" ")[2]);if(isNaN(e)||e<-90||e>90)v="Error: Latitude must be -90 to 90",x="error";else{const a=await m({latitude:e});v=a.success?`OK - Latitude set to ${e}°`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set lon ")){const e=parseFloat(f.split(" ")[2]);if(isNaN(e)||e<-180||e>180)v="Error: Longitude must be -180 to 180",x="error";else{const a=await m({longitude:e});v=a.success?`OK - Longitude set to ${e}°`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set flood.max ")){const e=parseInt(f.split(" ")[2]);if(isNaN(e)||e<0||e>64)v="Error: Max flood hops must be 0-64",x="error";else{const a=await m({max_flood_hops:e});v=a.success?`OK - Max flood hops set to ${e}`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set flood.advert.interval ")){const e=parseInt(f.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))v="Error: Flood advert interval must be 0 (off) or 3-48 hours",x="error";else{const a=await m({flood_advert_interval_hours:e});v=a.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else if(f.startsWith("set advert.interval ")){const e=parseInt(f.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))v="Error: Advert interval must be 0 (off) or 1-10080 minutes",x="error";else{const a=await m({advert_interval_minutes:e});v=a.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${a.error||"Failed"}`,x=a.success?"success":"error"}}else v=`Unknown command: ${g}\nType 'help' for available commands.`,x="error";P(h,{content:v,outputType:x})}catch(x){P(h,{content:`Error: ${x instanceof Error?x.message:"Command failed"}`,outputType:"error"})}},[O,k,P,S]),B=a.useCallback(e=>{var a,t,r,s,n,o;if(G&&C.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(D+1,C.length-1);return W(s),void(null==(r=null==(t=null==(a=M.current)?void 0:a.children[0])?void 0:t.children[s])||r.scrollIntoView({block:"nearest"}))}if("ArrowUp"===e.key){e.preventDefault();const a=Math.max(D-1,0);return W(a),void(null==(o=null==(n=null==(s=M.current)?void 0:s.children[0])?void 0:n.children[a])||o.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void X(D);if("Escape"===e.key)return e.preventDefault(),void T(!1)}if("Enter"===e.key){e.preventDefault();const a=_;return N(""),j(-1),T(!1),void U(a)}if("ArrowUp"!==e.key||G)if("ArrowDown"!==e.key||G);else if(e.preventDefault(),E>0){const e=E-1;j(e),N(h[h.length-1-e]||"")}else 0===E&&(j(-1),N(""));else if(e.preventDefault(),h.length>0&&E{N(e.target.value),I(e.target.selectionStart||e.target.value.length),z(e.target.value)},[z]),J=a.useCallback(e=>{const a=e.target;I(a.selectionStart||0)},[]);return t.jsxs(p,{children:[t.jsx(y,{title:"Terminal",icon:t.jsx(r,{})}),t.jsxs(u,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:q,children:[t.jsx("div",{ref:K,className:"flex-1 overflow-y-auto font-mono text-sm bg-black/40 p-3 sm:p-4 md:p-5",children:f.map(e=>t.jsx(w,{entry:e},e.id))}),t.jsxs("div",{className:"relative border-t border-white/10 bg-black/50",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-3",children:[t.jsx("span",{className:"text-text-muted font-mono font-bold select-none",children:"$"}),t.jsxs("div",{className:"flex-1 relative font-mono text-sm",children:[t.jsx("input",{ref:H,type:"text",value:_,onChange:V,onKeyDown:B,onSelect:J,onFocus:()=>A(!0),onBlur:()=>A(!1),disabled:!b,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}),t.jsx("div",{className:"relative pointer-events-none select-none","aria-hidden":!0,children:b?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-text-primary",children:_.slice(0,L)}),t.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",R?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:t.jsx("span",{className:"text-bg-primary",children:_[L]||""})}),t.jsx("span",{className:"text-text-primary",children:_.slice(L+1)})]}):t.jsx("span",{className:"text-text-muted",children:"Connecting..."})})]})]}),t.jsxs("div",{className:"px-3 sm:px-4 py-1 border-t border-white/5 bg-black/30 flex justify-between text-[10px] text-text-muted",children:[t.jsx("span",{className:"hidden sm:inline",children:"↑↓ History"}),t.jsx("span",{className:"sm:hidden",children:"Terminal"}),(null==e?void 0:e.version)&&t.jsxs("span",{children:["pyMC v",e.version]})]})]}),G&&C.length>0&&t.jsxs("div",{ref:M,className:"absolute left-2 right-2 bottom-[72px] rounded-xl shadow-2xl overflow-hidden z-50 border border-white/20 bg-black/80 backdrop-blur-xl",children:[t.jsx("div",{className:"max-h-64 overflow-y-auto",children:C.map((e,a)=>t.jsxs("div",{onClick:()=>X(a),className:s("px-4 py-2.5 cursor-pointer border-b border-white/10 last:border-b-0 transition-colors",a===D?"bg-accent-primary/25":"hover:bg-white/10"),children:[t.jsx("span",{className:s("font-mono text-sm",a===D?"text-accent-primary":"text-text-primary"),children:e.cmd}),t.jsx("span",{className:"text-xs text-text-muted ml-4",children:e.desc})]},e.cmd))}),t.jsx("div",{className:"px-3 py-1.5 border-t border-white/10 text-[10px] text-text-muted text-right bg-white/5",children:"Tab to select"})]})]})]})}export{O as default}; diff --git a/frontend/dist/assets/index-Dp0UlTio.js b/frontend/dist/assets/index-DGrzd8xb.js similarity index 99% rename from frontend/dist/assets/index-Dp0UlTio.js rename to frontend/dist/assets/index-DGrzd8xb.js index e19558ac..f3bc0533 100644 --- a/frontend/dist/assets/index-Dp0UlTio.js +++ b/frontend/dist/assets/index-DGrzd8xb.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-BF2bENkR.js","assets/vendor-react-O8XH9yVn.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-D_Tfd9l2.js","assets/useThemeColors-CD0TSU03.js","assets/PageLayout-DE5PEtD2.js","assets/PacketDetailModal-CR1FHEH5.js","assets/SignalIndicator-BVAbF7xm.js","assets/HashBadge-aS_UIcg2.js","assets/TimeRangeSelector-9pGCd7oa.js","assets/link-scoring-DacI-LFP.js","assets/Grid-CIZAny_R.js","assets/Packets-Cn-iDbXq.js","assets/Contacts-au5gCj-N.js","assets/CollisionExplorerModal-DEtEH0fD.js","assets/ConfirmModal-DYznouaT.js","assets/leaflet-CIGW-MKW.css","assets/Statistics-BHA07L60.js","assets/usePolling-UdPi_fKb.js","assets/System-CMjUiDHD.js","assets/Logs-l6s0ar29.js","assets/Terminal-Vhl_DY50.js","assets/Configuration-Cq1_waCf.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,u as o,X as i,M as l,L as r,d as c,e as u,C as d,G as h,F as f,S as p,f as m,g,h as y,i as x,k as w,l as b,m as k,n as v,o as S,p as _,q as M,b as C,t as T,v as j,N,w as L,B as P}from"./vendor-react-O8XH9yVn.js";import{_ as E}from"./deckgl-DTsmDcfs.js";import{c as I}from"./recharts-BU7auunF.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 A=[{id:"default",name:"Shades of Purple",dataTheme:null,previewColor:"#B39DF3"},{id:"amber",name:"Gruvbox",dataTheme:"amber",previewColor:"#fabd2f"},{id:"grey",name:"Deus",dataTheme:"grey",previewColor:"#83a598"},{id:"black",name:"Gotham",dataTheme:"black",previewColor:"#33859d"},{id:"flora",name:"Sonokai",dataTheme:"flora",previewColor:"#9ed072"},{id:"kanagawa",name:"Kanagawa",dataTheme:"kanagawa",previewColor:"#7E9CD8"}],R=[{id:"sand",src:"/assets/sand.jpg",suggestedScheme:"default",suggestedBrightness:80},{id:"water",src:"/assets/water.webp",suggestedScheme:"grey",suggestedBrightness:40},{id:"magma",src:"/assets/magma.webp",suggestedScheme:"amber",suggestedBrightness:50},{id:"stars",src:"/assets/stars.jpg",suggestedScheme:"black",suggestedBrightness:100},{id:"ribbons",src:"/assets/ribbons.webp",suggestedScheme:"flora",suggestedBrightness:75},{id:"folds",src:"/assets/folds.webp",suggestedScheme:"kanagawa",suggestedBrightness:50}],D=[{id:"default",name:"Shades of Purple",displayName:"BlkSand",colorScheme:"default",backgroundImage:"/assets/sand.jpg",paletteColors:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]],displayFont:"'Rubik Mono One', monospace",displayColor:"#4A4A52",displaySize:.8},{id:"amber",name:"Gruvbox",displayName:"Magma",colorScheme:"amber",backgroundImage:"/assets/magma.webp",paletteColors:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]],displayFont:"'Jacquard 12', serif",displayColor:"#fe8019",displaySize:1.75},{id:"grey",name:"Deus",displayName:"Waves",colorScheme:"grey",backgroundImage:"/assets/water.webp",paletteColors:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]],displayFont:"'Cantora One', sans-serif",displayColor:"#83a598",displaySize:1.25},{id:"black",name:"Gotham",displayName:"Stars",colorScheme:"black",backgroundImage:"/assets/stars.jpg",paletteColors:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]],displayFont:"'IBM Plex Mono', monospace",displayColor:"#c23127",displaySize:1.25},{id:"flora",name:"Sonokai",displayName:"Ribbon",colorScheme:"flora",backgroundImage:"/assets/ribbons.webp",paletteColors:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]],displayFont:"'Instrument Serif', serif",displayColor:"#E2E2E3",displaySize:1.4},{id:"kanagawa",name:"Kanagawa",displayName:"Folds",colorScheme:"kanagawa",backgroundImage:"/assets/folds.webp",paletteColors:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]],displayFont:"'Inter', sans-serif",displayColor:"#7E9CD8",displaySize:1.25}],F={colorScheme:"grey",backgroundImage:"/assets/water.webp",brightness:60},z="pymc-color-scheme",O="pymc-background-image",$="pymc-bg-brightness",B="pymc-background";function W(e){(new Image).src=e}const H={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},U=[50,100,200,300,400,500,600,700,800,900],q=["red","orange","yellow","green","aqua","blue","purple"];function G(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 J(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Y(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function V(e,t,s){const n=s*(Math.PI/180),a=t*Math.cos(n),o=t*Math.sin(n),i=e+.3963377774*a+.2158037573*o,l=e-.1055613458*a-.0638541728*o,r=e-.0894841775*a-1.291485548*o,c=i*i*i,u=l*l*l,d=r*r*r,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,f=-.0041960863*c-.7034186147*u+1.707614701*d;return[Y(4.0767416621*c-3.3077115913*u+.2309699292*d),Y(h),Y(f)]}function X(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,o]=function(e,t,s){const n=J(e),a=J(t),o=J(s),i=.4122214708*n+.5363325363*a+.0514459929*o,l=.2119034982*n+.6806995451*a+.1073969566*o,r=.0883024619*n+.2817188376*a+.6299787005*o,c=Math.cbrt(i),u=Math.cbrt(l),d=Math.cbrt(r),h=.2104542553*c+.793617785*u-.0040720468*d,f=1.9779984951*c-2.428592205*u+.4505937099*d,p=.0259040371*c+.7827717662*u-.808675766*d,m=Math.sqrt(f*f+p*p);let g=Math.atan2(p,f)*(180/Math.PI);return g<0&&(g+=360),[h,m,g]}(t,s,n),i={};for(const l of U){const e=H[l],t=a*(1-.3*Math.abs(e-.5)),[s,n,r]=V(e,t,o);i[l]=G(s,n,r)}return i}function K(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Q(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const Z="u-off",ee="u-label",te="width",se="height",ne="top",ae="bottom",oe="left",ie="right",le="#000",re=le+"0",ce="mousemove",ue="mousedown",de="mouseup",he="mouseenter",fe="mouseleave",pe="dblclick",me="change",ge="dppxchange",ye="--",xe="undefined"!=typeof window,we=xe?document:null,be=xe?window:null,ke=xe?navigator:null;let ve,Se;function _e(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function Me(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function Ce(e,t,s){e.style[t]=s+"px"}function Te(e,t,s,n){let a=we.createElement(e);return null!=t&&_e(a,t),null!=s&&s.insertBefore(a,n),a}function je(e,t){return Te("div",e,t)}const Ne=new WeakMap;function Le(e,t,s,n,a){let o="translate("+t+"px,"+s+"px)";o!=Ne.get(e)&&(e.style.transform=o,Ne.set(e,o),t<0||s<0||t>n||s>a?_e(e,Z):Me(e,Z))}const Pe=new WeakMap;function Ee(e,t,s){let n=t+s;n!=Pe.get(e)&&(Pe.set(e,n),e.style.background=t,e.style.borderColor=s)}const Ie=new WeakMap;function Ae(e,t,s,n){let a=t+""+s;a!=Ie.get(e)&&(Ie.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 Re={passive:!0},De={...Re,capture:!0};function Fe(e,t,s,n){t.addEventListener(e,s,n?De:Re)}function ze(e,t,s,n){t.removeEventListener(e,s,Re)}function Oe(e,t,s,n){let a;s=s||0;let o=(n=n||t.length-1)<=2147483647;for(;n-s>1;)a=o?s+n>>1:at((s+n)/2),t[a]{let a=-1,o=-1;for(let i=s;i<=n;i++)if(e(t[i])){a=i;break}for(let i=n;i>=s;i--)if(e(t[i])){o=i;break}return[a,o]}}xe&&function e(){let t=devicePixelRatio;ve!=t&&(ve=t,Se&&ze(me,Se,e),Se=matchMedia(`(min-resolution: ${ve-.001}dppx) and (max-resolution: ${ve+.001}dppx)`),Fe(me,Se,e),be.dispatchEvent(new CustomEvent(ge)))}();const Be=e=>null!=e,We=e=>null!=e&&e>0,He=$e(Be),Ue=$e(We);function qe(e,t,s,n){let a=ut(e),o=ut(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let i=10==s?dt:ht,l=1==o?it:at,r=(1==a?at:it)(i(nt(e))),c=l(i(nt(t))),u=ct(s,r),d=ct(s,c);return 10==s&&(r<0&&(u=Nt(u,-r)),c<0&&(d=Nt(d,-c))),n||2==s?(e=u*a,t=d*o):(e=jt(e,u),t=Tt(t,d)),[e,t]}function Ge(e,t,s,n){let a=qe(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const Je={mode:3,pad:.1},Ye={pad:0,soft:null,mode:0},Ve={min:Ye,max:Ye};function Xe(e,t,s,n){return Ot(s)?Qe(e,t,s):(Ye.pad=s,Ye.soft=n?0:null,Ye.mode=n?3:0,Qe(e,t,Ve))}function Ke(e,t){return null==e?t:e}function Qe(e,t,s){let n=s.min,a=s.max,o=Ke(n.pad,0),i=Ke(a.pad,0),l=Ke(n.hard,-pt),r=Ke(a.hard,pt),c=Ke(n.soft,pt),u=Ke(a.soft,-pt),d=Ke(n.mode,0),h=Ke(a.mode,0),f=t-e,p=dt(f),m=rt(nt(e),nt(t)),g=dt(m),y=nt(g-p);(f<1e-24||y>10)&&(f=0,0!=e&&0!=t||(f=1e-24,2==d&&c!=pt&&(o=0),2==h&&u!=-pt&&(i=0)));let x=f||m||1e3,w=dt(x),b=ct(10,at(w)),k=Nt(jt(e-x*(0==f?0==e?.1:1:o),b/10),24),v=e>=c&&(1==d||3==d&&k<=c||2==d&&k>=c)?c:pt,S=rt(l,k=v?v:lt(v,k)),_=Nt(Tt(t+x*(0==f?0==t?.1:1:i),b/10),24),M=t<=u&&(1==h||3==h&&_>=u||2==h&&_<=u)?u:-pt,C=lt(r,_>M&&t<=M?M:rt(M,_));return S==C&&0==S&&(C=100),[S,C]}const Ze=new Intl.NumberFormat(xe?ke.language:"en-US"),et=e=>Ze.format(e),tt=Math,st=tt.PI,nt=tt.abs,at=tt.floor,ot=tt.round,it=tt.ceil,lt=tt.min,rt=tt.max,ct=tt.pow,ut=tt.sign,dt=tt.log10,ht=tt.log2,ft=(e,t=1)=>tt.asinh(e/t),pt=1/0;function mt(e){return 1+(0|dt((e^e>>31)-(e>>31)))}function gt(e,t,s){return lt(rt(e,t),s)}function yt(e){return"function"==typeof e}function xt(e){return yt(e)?e:()=>e}const wt=e=>e,bt=(e,t)=>t,kt=e=>null,vt=e=>!0,St=(e,t)=>e==t,_t=/\.\d*?(?=9{6,}|0{6,})/gm,Mt=e=>{if(Ft(e)||Lt.has(e))return e;const t=`${e}`,s=t.match(_t);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${Mt(e)}e${s}`}return Nt(e,n)};function Ct(e,t){return Mt(Nt(Mt(e/t))*t)}function Tt(e,t){return Mt(it(Mt(e/t))*t)}function jt(e,t){return Mt(at(Mt(e/t))*t)}function Nt(e,t=0){if(Ft(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return ot(n)/s}const Lt=new Map;function Pt(e){return((""+e).split(".")[1]||"").length}function Et(e,t,s,n){let a=[],o=n.map(Pt);for(let i=t;i=0?0:t)+(i>=o[l]?0:o[l]),u=10==e?r:Nt(r,c);a.push(u),Lt.set(u,c)}}return a}const It={},At=[],Rt=[null,null],Dt=Array.isArray,Ft=Number.isInteger;function zt(e){return"string"==typeof e}function Ot(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function $t(e){return null!=e&&"object"==typeof e}const Bt=Object.getPrototypeOf(Uint8Array),Wt="__proto__";function Ht(e,t=Ot){let s;if(Dt(e)){let n=e.find(e=>null!=e);if(Dt(n)||t(n)){s=Array(e.length);for(let n=0;no){for(n=i-1;n>=0&&null==e[n];)e[n--]=null;for(n=i+1;nPromise.resolve().then(e):queueMicrotask,Jt=["January","February","March","April","May","June","July","August","September","October","November","December"],Yt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Vt(e){return e.slice(0,3)}const Xt=Yt.map(Vt),Kt=Jt.map(Vt),Qt={MMMM:Jt,MMM:Kt,WWWW:Yt,WWW:Xt};function Zt(e){return(e<10?"0":"")+e}const es={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=>Zt(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Zt(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>Zt(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=>Zt(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Zt(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function ts(e,t){t=t||Qt;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?es[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,as=[1,2,2.5,5],os=Et(10,-32,0,as),is=Et(10,0,32,as),ls=is.filter(ns),rs=os.concat(is),cs="{YYYY}",us="\n"+cs,ds="{M}/{D}",hs="\n"+ds,fs=hs+"/{YY}",ps="{aa}",ms="{h}:{mm}"+ps,gs="\n"+ms,ys=":{ss}",xs=null;function ws(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,o=30*a,i=365*a;return[(1==e?Et(10,0,3,as).filter(ns):Et(10,-3,0,as)).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,o,2*o,3*o,4*o,6*o,i,2*i,5*i,10*i,25*i,50*i,100*i]),[[i,cs,xs,xs,xs,xs,xs,xs,1],[28*a,"{MMM}",us,xs,xs,xs,xs,xs,1],[a,ds,us,xs,xs,xs,xs,xs,1],[n,"{h}"+ps,fs,xs,hs,xs,xs,xs,1],[s,ms,fs,xs,hs,xs,xs,xs,1],[t,ys,fs+" "+ms,xs,hs+" "+ms,xs,gs,xs,1],[e,ys+".{fff}",fs+" "+ms,xs,hs+" "+ms,xs,gs,xs,1]],function(t){return(l,r,c,u,d,h)=>{let f=[],p=d>=i,m=d>=o&&d=a?a:d,i=w+(at(c)-at(y))+Tt(y-w,o);f.push(i);let p=t(i),m=p.getHours()+p.getMinutes()/s+p.getSeconds()/n,g=d/n,x=h/l.axes[r]._space;for(;i=Nt(i+d,1==e?0:3),!(i>u);)if(g>1){let e=at(Nt(m+g,6))%24,s=t(i).getHours()-e;s>1&&(s=-1),i-=s*n,m=(m+g)%24,Nt((i-f[f.length-1])/d,3)*x>=.7&&f.push(i)}else f.push(i)}return f}}]}const[bs,ks,vs]=ws(1),[Ss,_s,Ms]=ws(.001);function Cs(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 Ts(e,t){return(s,n,a,o,i)=>{let l,r,c,u,d,h,f=t.find(e=>i>=e[0])||t[t.length-1];return n.map(t=>{let s=e(t),n=s.getFullYear(),a=s.getMonth(),o=s.getDate(),i=s.getHours(),p=s.getMinutes(),m=s.getSeconds(),g=n!=l&&f[2]||a!=r&&f[3]||o!=c&&f[4]||i!=u&&f[5]||p!=d&&f[6]||m!=h&&f[7]||f[1];return l=n,r=a,c=o,u=i,d=p,h=m,g(s)})}}function js(e,t,s){return new Date(e,t,s)}function Ns(e,t){return t(e)}function Ls(e,t){return(s,n,a,o)=>null==o?ye:t(e(n))}Et(2,-53,53,[1]);const Ps={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:[]},Es=[0,0];function Is(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function As(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const Rs={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return Es[0]=t,Es[1]=s,Es},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=je(),a=s.size(e,t);Ce(n,te,a),Ce(n,se,a);let o=a/-2;Ce(n,"marginLeft",o),Ce(n,"marginTop",o);let i=s.width(e,t,a);return i&&Ce(n,"borderWidth",i),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:Is,mouseup:Is,click:Is,dblclick:Is,mousemove:As,mouseleave:As,mouseenter:As},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},Ds={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Fs=Ut({},Ds,{filter:bt}),zs=Ut({},Fs,{size:10}),Os=Ut({},Ds,{show:!1}),$s='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"',Bs="bold "+$s,Ws={show:!0,scale:"x",stroke:le,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Bs,side:2,grid:Fs,ticks:zs,border:Os,font:$s,lineGap:1.5,rotate:0},Hs={show:!0,scale:"x",auto:!1,sorted:1,min:pt,max:-pt,idxs:[]};function Us(e,t,s,n,a){return t.map(e=>null==e?"":et(e))}function qs(e,t,s,n,a,o,i){let l=[],r=Lt.get(a)||0;for(let c=s=i?s:Nt(Tt(s,a),r);c<=n;c=Nt(c+a,r))l.push(Object.is(c,-0)?0:c);return l}function Gs(e,t,s,n,a,o,i){const l=[],r=e.scales[e.axes[t].scale].log,c=at((10==r?dt:ht)(s));a=ct(r,c),10==r&&(a=rs[Oe(a,rs)]);let u=s,d=a*r;10==r&&(d=rs[Oe(d,rs)]);do{l.push(u),u+=a,10!=r||Lt.has(u)||(u=Nt(u,Lt.get(a))),u>=d&&(d=(a=u)*r,10==r&&(d=rs[Oe(d,rs)]))}while(u<=n);return l}function Js(e,t,s,n,a,o,i){let l=e.scales[e.axes[t].scale].asinh,r=n>l?Gs(e,t,rt(l,s),n,a):[l],c=n>=0&&s<=0?[0]:[];return(s<-l?Gs(e,t,rt(l,-n),-s,a):[l]).reverse().map(e=>-e).concat(c,r)}const Ys=/./,Vs=/[12357]/,Xs=/[125]/,Ks=/1/,Qs=(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 Zs(e,t,s,n,a){let o=e.axes[s],i=o.scale,l=e.scales[i],r=e.valToPos,c=o._space,u=r(10,i),d=r(9,i)-u>=c?Ys:r(7,i)-u>=c?Vs:r(5,i)-u>=c?Xs:Ks;if(d==Ks){let e=nt(r(1,i)-u);if(ea,on={show:!0,auto:!0,sorted:0,gaps:an,alpha:1,facets:[Ut({},nn,{scale:"x"}),Ut({},nn,{scale:"y"})]},ln={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:an,alpha:1,points:{show:function(e,t){let{scale:s,idxs:n}=e.series[0],a=e._data[0],o=e.valToPos(a[n[0]],s,!0),i=e.valToPos(a[n[1]],s,!0),l=nt(i-o)/(e.series[t].points.space*ve);return n[1]-n[0]<=l},filter:null},values:null,min:pt,max:-pt,idxs:[],path:null,clip:null};function rn(e,t,s,n,a){return s/10}const cn={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},un=Ut({},cn,{time:!1,ori:1}),dn={};function hn(e,t){let s=dn[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,o,i,l){for(let r=0;r{let m=e.pxRound;const g=l.dir*(0==l.ori?1:-1),y=0==l.ori?Sn:_n;let x,w;1==g?(x=s,w=n):(x=n,w=s);let b=m(c(t[x],l,f,d)),k=m(u(i[x],r,p,h)),v=m(c(t[w],l,f,d)),S=m(u(1==o?r.max:r.min,r,p,h)),_=new Path2D(a);return y(_,v,S),y(_,b,S),y(_,b,k),_})}function yn(e,t,s,n,a,o){let i=null;if(e.length>0){i=new Path2D;const l=0==t?Mn:Cn;let r=s;for(let t=0;ts[0]){let e=s[0]-r;e>0&&l(i,r,n,e,n+o),r=s[1]}}let c=s+a-r,u=10;c>0&&l(i,r,n-u/2,c,n+o+u)}return i}function xn(e,t,s,n,a,o,i){let l=[],r=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=o(e[u]),f=d==u?h:o(e[d]),p=u-a;h=i<=0&&p>=0&&p=0&&m>=0&&m=h&&l.push([h,f])}return l}function wn(e){return 0==e?wt:1==e?ot:t=>Ct(t,e)}function bn(e){let t=0==e?kn:vn,s=0==e?(e,t,s,n,a,o)=>{e.arcTo(t,s,n,a,o)}:(e,t,s,n,a,o)=>{e.arcTo(s,t,a,n,o)},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,o,i,l,r=0,c=0)=>{0==r&&0==c?n(e,a,o,i,l):(r=lt(r,i/2,l/2),c=lt(c,i/2,l/2),t(e,a+r,o),s(e,a+i,o,a+i,o+l,r),s(e,a+i,o+l,a,o+l,c),s(e,a,o+l,a,o,c),s(e,a,o,a+i,o,r),e.closePath())}}const kn=(e,t,s)=>{e.moveTo(t,s)},vn=(e,t,s)=>{e.moveTo(s,t)},Sn=(e,t,s)=>{e.lineTo(t,s)},_n=(e,t,s)=>{e.lineTo(s,t)},Mn=bn(0),Cn=bn(1),Tn=(e,t,s,n,a,o)=>{e.arc(t,s,n,a,o)},jn=(e,t,s,n,a,o)=>{e.arc(s,t,n,a,o)},Nn=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(t,s,n,a,o,i)},Ln=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(s,t,a,n,i,o)};function Pn(e){return(e,t,s,n,a)=>fn(e,t,(t,o,i,l,r,c,u,d,h,f,p)=>{let m,g,{pxRound:y,points:x}=t;0==l.ori?(m=kn,g=Tn):(m=vn,g=jn);const w=Nt(x.width*ve,3);let b=(x.size-x.width)/2*ve,k=Nt(2*b,3),v=new Path2D,S=new Path2D,{left:_,top:M,width:C,height:T}=e.bbox;Mn(S,_-k,M-k,C+2*k,T+2*k);const j=e=>{if(null!=i[e]){let t=y(c(o[e],l,f,d)),s=y(u(i[e],r,p,h));m(v,t+b,s),g(v,t,s,b,0,2*st)}};if(a)a.forEach(j);else for(let e=s;e<=n;e++)j(e);return{stroke:w>0?v:null,fill:v,clip:S,flags:3}})}function En(e){return(t,s,n,a,o,i)=>{n!=a&&(o!=n&&i!=n&&e(t,s,n),o!=a&&i!=a&&e(t,s,a),e(t,s,i))}}const In=En(Sn),An=En(_n);function Rn(e){const t=Ke(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>fn(e,s,(o,i,l,r,c,u,d,h,f,p,m)=>{[n,a]=He(l,n,a);let g,y,x=o.pxRound,w=e=>x(u(e,r,p,h)),b=e=>x(d(e,c,m,f));0==r.ori?(g=Sn,y=In):(g=_n,y=An);const k=r.dir*(0==r.ori?1:-1),v={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=v.stroke;let _=!1;if(a-n>=4*p){let t,s,o,c=t=>e.posToVal(t,r.key,!0),u=null,d=null,h=w(i[1==k?n:a]),f=w(i[n]),p=w(i[a]),m=c(1==k?f+1:p-1);for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let n=i[e],a=(1==k?nm)?h:w(n),o=l[e];a==h?null!=o?(s=o,null==u?(g(S,a,b(s)),t=u=d=s):sd&&(d=s)):null===o&&(_=!0):(null!=u&&y(S,h,b(u),b(d),b(t),b(s)),null!=o?(s=o,g(S,a,b(s)),u=d=t=s):(u=d=null,null===o&&(_=!0)),h=a,m=c(h+k))}null!=u&&u!=d&&o!=h&&y(S,h,b(u),b(d),b(t),b(s))}else for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let t=l[e];null===t?_=!0:null!=t&&g(S,w(i[e]),b(t))}let[M,C]=pn(e,s);if(null!=o.fill||0!=M){let t=v.fill=new Path2D(S),l=b(o.fillTo(e,s,o.min,o.max,M)),r=w(i[n]),c=w(i[a]);-1==k&&([c,r]=[r,c]),g(t,c,l),g(t,r,l)}if(!o.spanGaps){let c=[];_&&c.push(...xn(i,l,n,a,k,w,t)),v.gaps=c=o.gaps(e,s,n,a,c),v.clip=yn(c,r.ori,h,f,p,m)}return 0!=C&&(v.band=2==C?[gn(e,s,n,a,S,-1),gn(e,s,n,a,S,1)]:gn(e,s,n,a,S,C)),v})}function Dn(e,t,s,n,a,o,i=pt){if(e.length>1){let l=null;for(let r=0,c=1/0;r0!=n[e]>0?s[e]=0:(s[e]=3*(r[e-1]+r[e])/((2*r[e]+r[e-1])/n[e-1]+(r[e]+2*r[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[i-1]=n[i-2];for(let c=0;c{Zn.pxRatio=ve}));const $n=Rn(),Bn=Pn();function Wn(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>Hn(e,n,t,s))}function Hn(e,t,s,n){return Ut({},0==t?s:n,e)}function Un(e,t,s){return null==t?Rt:[t,s]}const qn=Un;function Gn(e,t,s){return null==t?Rt:Xe(t,s,.1,!0)}function Jn(e,t,s,n){return null==t?Rt:qe(t,s,e.scales[n].log,!1)}const Yn=Jn;function Vn(e,t,s,n){return null==t?Rt:Ge(t,s,e.scales[n].log,!1)}const Xn=Vn;function Kn(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=ot((s=+n)*ve))+"px"),t,s]}function Qn(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Nt(e[2]*ve,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function Zn(e,t,s){const n={mode:Ke(e.mode,1)},a=n.mode;function o(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?1-a:a)}function i(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?a:1-a)}function l(e,t,s,n){return 0==t.ori?o(e,t,s,n):i(e,t,s,n)}n.valToPosH=o,n.valToPosV=i;let r=!1;n.status=0;const c=n.root=je("uplot");null!=e.id&&(c.id=e.id),_e(c,e.class),e.title&&(je("u-title",c).textContent=e.title);const u=Te("canvas"),d=n.ctx=u.getContext("2d"),h=je("u-wrap",c);Fe("click",h,e=>{e.target===p&&(Nn!=Mn||Ln!=Cn)&&Zn.click(n,e)},!0);const f=n.under=je("u-under",h);h.appendChild(u);const p=n.over=je("u-over",h),m=+Ke((e=Ht(e)).pxAlign,1),g=wn(m);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const y=e.ms||.001,x=n.series=1==a?Wn(e.series||[],Hs,ln,!1):(w=e.series||[null],b=on,w.map((e,t)=>0==t?{}:Ut({},b,e)));var w,b;const k=n.axes=Wn(e.axes||[],Ws,sn,!0),v=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=xt(e.fill||null),e.dir=Ke(e.dir,-1)});const _=2==a?x[1].facets[0].scale:x[0].scale,M={axes:function(){for(let e=0;eDs[e]):y,w=2==f.distr?Ds[y[1]]-Ds[y[0]]:u,b=t.ticks,S=t.border,_=b.show?b.size:0,M=ot(_*ve),C=ot((2==t.alignTo?t._size-_-t.gap:t.gap)*ve),T=t._rotate*-st/180,j=g(t._pos*ve),N=j+(M+C)*c;a=0==i?N:0,s=1==i?N:0,Bs(t.font[0],r,1==t.align?oe:2==t.align?ie:T>0?oe:T<0?ie:0==i?"center":3==o?ie:oe,T||1==i?"middle":2==o?ne:ae);let L=t.font[1]*t.lineGap,P=y.map(e=>g(l(e,f,p,m))),E=t._values;for(let e=0;e0){let e=x.some(e=>e._focus)&&As!=Vt.alpha;e&&(d.globalAlpha=As=Vt.alpha),x.forEach((e,s)=>{if(s>0&&e.show&&(Xs(s,!1),Xs(s,!0),null==e._paths)){let o=As;As!=e.alpha&&(d.globalAlpha=As=e.alpha);let i=2==a?[0,t[s][0].length-1]:function(e){let t=gt(ds-1,0,us-1),s=gt(hs+1,0,us-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=As;As!=e.alpha&&(d.globalAlpha=As=e.alpha),null!=e._paths&&Ks(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,ds,hs,s),o=e.points.filter(n,t,a,s);(a||o)&&(e.points._paths=e.points.paths(n,t,ds,hs,o),Ks(t,!0))}As!=s&&(d.globalAlpha=As=s),Ra("drawSeries",t)}}),e&&(d.globalAlpha=As=1)}}},C=(e.drawOrder||["axes","series"]).map(e=>M[e]);function T(e){const t=3==e.distr?t=>dt(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>ft(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return s=>{let n=t(s),{_min:a,_max:o}=e;return(n-a)/(o-a)}}function j(t){let s=v[t];if(null==s){let n=(e.scales||It)[t]||It;if(null!=n.from){j(n.from);let e=Ut({},v[n.from],n,{key:t});e.valToPct=T(e),v[t]=e}else{s=v[t]=Ut({},t==_?cn:un,n),s.key=t;let e=s.time,o=s.range,i=Dt(o);if((t!=_||2==a&&!e)&&(!i||null!=o[0]&&null!=o[1]||(o={min:null==o[0]?Je:{mode:1,hard:o[0],soft:o[0]},max:null==o[1]?Je:{mode:1,hard:o[1],soft:o[1]}},i=!1),!i&&Ot(o))){let e=o;o=(t,s,n)=>null==s?Rt:Xe(s,n,e)}s.range=xt(o||(e?qn:t==_?3==s.distr?Yn:4==s.distr?Xn:Un:3==s.distr?Jn:4==s.distr?Vn:Gn)),s.auto=xt(!i&&s.auto),s.clamp=xt(s.clamp||rn),s._min=s._max=null,s.valToPct=T(s)}}}j("x"),j("y"),1==a&&x.forEach(e=>{j(e.scale)}),k.forEach(e=>{j(e.scale)});for(let Z in e.scales)j(Z);const N=v[_],L=N.distr;let P,E;0==N.ori?(_e(c,"u-hz"),P=o,E=i):(_e(c,"u-vt"),P=i,E=o);const I={};for(let Z in v){let e=v[Z];null==e.min&&null==e.max||(I[Z]={min:e.min,max:e.max},e.min=e.max=null)}const A=e.tzDate||(e=>new Date(ot(e/y))),R=e.fmtDate||ts,D=1==y?vs(A):Ms(A),F=Ts(A,Cs(1==y?ks:_s,R)),z=Ls(A,Ns("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",R)),O=[],$=n.legend=Ut({},Ps,e.legend),B=n.cursor=Ut({},Rs,{drag:{y:2==a}},e.cursor),W=$.show,H=B.show,U=$.markers;let q,G,J;$.idxs=O,U.width=xt(U.width),U.dash=xt(U.dash),U.stroke=xt(U.stroke),U.fill=xt(U.fill);let Y,V=[],X=[],K=!1,Q={};if($.live){const e=x[1]?x[1].values:null;K=null!=e,Y=K?e(n,1,0):{_:0};for(let t in Y)Q[t]=ye}if(W)if(q=Te("table","u-legend",c),J=Te("tbody",null,q),$.mount(n,q),K){G=Te("thead",null,q,J);let e=Te("tr",null,G);for(var le in Te("th",null,e),Y)Te("th",ee,e).textContent=le}else _e(q,"u-inline"),$.live&&_e(q,"u-live");const me={show:!0},xe={show:!1},ke=new Map;function Se(e,t,s,a=!0){const o=ke.get(t)||{},i=B.bind[e](n,t,s,a);i&&(Fe(e,t,o[e]=i),ke.set(t,o))}function Ne(e,t,s){const n=ke.get(t)||{};for(let a in n)null!=e&&a!=e||(ze(a,t,n[a]),delete n[a]);null==e&&ke.delete(t)}let Pe=0,Ie=0,Re=0,De=0,$e=0,Ye=0,Ve=$e,Qe=Ye,Ze=Re,et=De,at=0,ut=0,ht=0,wt=0;n.bbox={};let _t=!1,Mt=!1,Tt=!1,jt=!1,Et=!1,Ft=!1;function Bt(e,t,s){(s||e!=n.width||t!=n.height)&&Wt(e,t),yn(!1),Tt=!0,Mt=!0,Rn()}function Wt(e,t){n.width=Pe=Re=e,n.height=Ie=De=t,$e=Ye=0,function(){let e=!1,t=!1,s=!1,n=!1;k.forEach((a,o)=>{if(a.show&&a._show){let{side:o,_size:i}=a,l=o%2,r=i+(null!=a.label?a.labelSize:0);r>0&&(l?(Re-=r,3==o?($e+=r,n=!0):s=!0):(De-=r,0==o?(Ye+=r,e=!0):t=!0))}}),as[0]=e,as[1]=s,as[2]=t,as[3]=n,Re-=cs[1]+cs[3],$e+=cs[3],De-=cs[2]+cs[0],Ye+=cs[0]}(),function(){let e=$e+Re,t=Ye+De,s=$e,n=Ye;function a(a,o){switch(a){case 1:return e+=o,e-o;case 2:return t+=o,t-o;case 3:return s-=o,s+o;case 0:return n-=o,n+o}}k.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;at=s.left=Ct($e*ve,.5),ut=s.top=Ct(Ye*ve,.5),ht=s.width=Ct(Re*ve,.5),wt=s.height=Ct(De*ve,.5)}const qt=3;if(n.setSize=function({width:e,height:t}){Bt(e,t)},null==B.dataIdx){let e=B.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=xt(e.prox),a=e.bias??(e.bias=0);B.dataIdx=(e,o,i,l)=>{if(0==o)return i;let r=i,c=n(e,o,i,l)??pt,u=c>=0&&c0;)s.has(p[e])||(t=e);if(0==a||1==a)for(e=i;null==n&&e++c&&(r=null);return r}}const Jt=e=>{B.event=e};B.idxs=O,B._lock=!1;let Yt=B.points;Yt.show=xt(Yt.show),Yt.size=xt(Yt.size),Yt.stroke=xt(Yt.stroke),Yt.width=xt(Yt.width),Yt.fill=xt(Yt.fill);const Vt=n.focus=Ut({},e.focus||{alpha:.3},B.focus),Xt=Vt.prox>=0,Kt=Xt&&Yt.one;let Qt=[],Zt=[],es=[];function ss(e,t){let s=Yt.show(n,t);if(s instanceof HTMLElement)return _e(s,"u-cursor-pt"),_e(s,e.class),Le(s,-10,-10,Re,De),p.insertBefore(s,Qt[t]),s}function ns(e,t){if(1==a||t>0){let t=1==a&&v[e.scale].time,s=e.value;e.value=t?zt(s)?Ls(A,Ns(s,R)):s||z:s||tn,e.label=e.label||(t?"Time":"Value")}if(Kt||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||$n||kt,e.fillTo=xt(e.fillTo||mn),e.pxAlign=+Ke(e.pxAlign,m),e.pxRound=wn(e.pxAlign),e.stroke=xt(e.stroke||null),e.fill=xt(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=Nt(1*(3+2*(rt(1,e.width)||1)),3),s=e.points=Ut({},{size:t,width:rt(1,.2*t),stroke:e.stroke,space:2*t,paths:Bn,_stroke:null,_fill:null},e.points);s.show=xt(s.show),s.filter=xt(s.filter),s.fill=xt(s.fill),s.stroke=xt(s.stroke),s.paths=xt(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(K||!$.live||2==a))return Rt;let s=[],o=Te("tr","u-series",J,J.childNodes[t]);_e(o,e.class),e.show||_e(o,Z);let i=Te("th",null,o);if(U.show){let e=je("u-marker",i);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 l=je(ee,i);for(var r in e.label instanceof HTMLElement?l.appendChild(e.label):l.textContent=e.label,t>0&&(U.show||(l.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),Se("click",i,t=>{if(B._lock)return;Jt(t);let s=x.indexOf(e);if((t.ctrlKey||t.metaKey)!=$.isolate){let e=x.some((e,t)=>t>0&&t!=s&&e.show);x.forEach((t,n)=>{n>0&&ia(n,e?n==s?me:xe:me,!0,Fa.setSeries)})}else ia(s,{show:!e.show},!0,Fa.setSeries)},!1),Xt&&Se(he,i,t=>{B._lock||(Jt(t),ia(x.indexOf(e),ua,!0,Fa.setSeries))},!1)),Y){let e=Te("td","u-value",o);e.textContent="--",s.push(e)}return[o,s]}(e,t);V.splice(t,0,s[0]),X.splice(t,0,s[1]),$.values.push(null)}if(H){O.splice(t,0,null);let s=null;Kt?0==t&&(s=ss(e,t)):t>0&&(s=ss(e,t)),Qt.splice(t,0,s),Zt.splice(t,0,0),es.splice(t,0,0)}Ra("addSeries",t)}n.addSeries=function(e,t){t=null==t?x.length:t,e=1==a?Hn(e,t,Hs,ln):Hn(e,t,{},on),x.splice(t,0,e),ns(x[t],t)},n.delSeries=function(e){if(x.splice(e,1),W){$.values.splice(e,1),X.splice(e,1);let t=V.splice(e,1)[0];Ne(null,t.firstChild),t.remove()}H&&(O.splice(e,1),Qt.splice(e,1)[0].remove(),Zt.splice(e,1),es.splice(e,1)),Ra("delSeries",e)};const as=[!1,!1,!1,!1];function os(e,t,s,n){let[a,o,i,l]=s,r=t%2,c=0;return 0==r&&(l||o)&&(c=0==t&&!a||2==t&&!i?ot(Ws.size/3):0),1==r&&(a||i)&&(c=1==t&&!o||3==t&&!l?ot(sn.size/2):0),c}const is=n.padding=(e.padding||[os,os,os,os]).map(e=>xt(Ke(e,os))),cs=n._padding=is.map((e,t)=>e(n,t,as,0));let us,ds=null,hs=null;const fs=1==a?x[0].idxs:null;let ps,ms,gs,ys,xs,ws,js,Es,Is,As,Ds=null,Fs=!1;function zs(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){us=0;for(let e=1;e=0,Ft=!0,Rn()}}function Os(){let e,s;Fs=!0,1==a&&(us>0?(ds=fs[0]=0,hs=fs[1]=us-1,e=t[0][ds],s=t[0][hs],2==L?(e=ds,s=hs):e==s&&(3==L?[e,s]=qe(e,e,N.log,!1):4==L?[e,s]=Ge(e,e,N.log,!1):N.time?s=e+ot(86400/y):[e,s]=Xe(e,s,.1,!0))):(ds=fs[0]=e=null,hs=fs[1]=s=null)),oa(_,e,s)}function $s(e,t,s,n,a,o){e??(e=re),s??(s=At),n??(n="butt"),a??(a=re),o??(o="round"),e!=ps&&(d.strokeStyle=ps=e),a!=ms&&(d.fillStyle=ms=a),t!=gs&&(d.lineWidth=gs=t),o!=xs&&(d.lineJoin=xs=o),n!=ws&&(d.lineCap=ws=n),s!=ys&&d.setLineDash(ys=s)}function Bs(e,t,s,n){t!=ms&&(d.fillStyle=ms=t),e!=js&&(d.font=js=e),s!=Es&&(d.textAlign=Es=s),n!=Is&&(d.textBaseline=Is=n)}function Ys(e,t,s,a,o=0){if(a.length>0&&e.auto(n,Fs)&&(null==t||null==t.min)){let t=Ke(ds,0),n=Ke(hs,a.length-1),i=null==s.min?function(e,t,s,n=0,a=!1){let o=a?Ue:He,i=a?We:Be;[t,s]=o(e,t,s);let l=e[t],r=e[t];if(t>-1)if(1==n)l=e[t],r=e[s];else if(-1==n)l=e[s],r=e[t];else for(let c=t;c<=s;c++){let t=e[c];i(t)&&(tr&&(r=t))}return[l??pt,r??-pt]}(a,t,n,o,3==e.distr):[s.min,s.max];e.min=lt(e.min,s.min=i[0]),e.max=rt(e.max,s.max=i[1])}}n.setData=zs;const Vs={min:null,max:null};function Xs(e,t){let s=t?x[e].points:x[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function Ks(e,s){let a=s?x[e].points:x[e],{stroke:o,fill:i,clip:l,flags:r,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=Nt(h*ve,3);let f=null,p=h%2/2;s&&null==u&&(u=h>0?"#fff":c);let m=1==a.pxAlign&&p>0;if(m&&d.translate(p,p),!s){let e=at-h/2,t=ut-h/2,s=ht+h,n=wt+h;f=new Path2D,f.rect(e,t,s,n)}s?nn(c,h,a.dash,a.cap,u,o,i,r,l):function(e,s,a,o,i,l,r,c,u,d,h){let f=!1;0!=u&&S.forEach((p,m)=>{if(p.series[0]==e){let e,g=x[p.series[1]],y=t[p.series[1]],w=(g._paths||It).band;Dt(w)&&(w=1==p.dir?w[0]:w[1]);let b=null;g.show&&w&&function(e,t,s){for(t=Ke(t,0),s=Ke(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(y,ds,hs)?(b=p.fill(n,m)||l,e=g._paths.clip):w=null,nn(s,a,o,i,b,r,c,u,d,h,e,w),f=!0}}),f||nn(s,a,o,i,l,r,c,u,d,h)}(e,c,h,a.dash,a.cap,u,o,i,r,f,l),m&&d.translate(-p,-p)}const Qs=3;function nn(e,t,s,n,a,o,i,l,r,c,u,h){$s(e,t,s,n,a),(r||c||h)&&(d.save(),r&&d.clip(r),c&&d.clip(c)),h?(l&Qs)==Qs?(d.clip(h),u&&d.clip(u),dn(a,i),an(e,o,t)):2&l?(dn(a,i),d.clip(h),an(e,o,t)):1&l&&(d.save(),d.clip(h),u&&d.clip(u),dn(a,i),d.restore(),an(e,o,t)):(dn(a,i),an(e,o,t)),(r||c||h)&&d.restore()}function an(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=ps=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function dn(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=ms=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function fn(e,t,s,n,a,o,i,l,r,c){let u=i%2/2;1==m&&d.translate(u,u),$s(l,i,r,c,l),d.beginPath();let h,f,p,g,y=a+(0==n||3==n?-o:o);0==s?(f=a,g=y):(h=a,p=y);for(let m=0;m{if(!s.show)return;let o=v[s.scale];if(null==o.min)return void(s._show&&(t=!1,s._show=!1,yn(!1)));s._show||(t=!1,s._show=!0,yn(!1));let i=s.side,l=i%2,{min:r,max:c}=o,[u,d]=function(e,t,s,a){let o,i=k[e];if(a<=0)o=[0,0];else{let l=i._space=i.space(n,e,t,s,a);o=function(e,t,s,n,a){let o=rt(mt(e),mt(t)),i=t-e,l=Oe(a/n*i,s);do{let e=s[l],t=n*e/i;if(t>=a&&o+(e<5?Lt.get(e):0)<=17)return[e,t]}while(++lDs[e]):f,m=2==o.distr?Ds[f[1]]-Ds[f[0]]:u,g=s._values=s.values(n,s.filter(n,p,a,d,m),a,d,m);s._rotate=2==i?s.rotate(n,g,a,d):0;let y=s._size;s._size=it(s.size(n,g,a,e)),null!=y&&s._size!=y&&(t=!1)}),t}function gn(e){let t=!0;return is.forEach((s,a)=>{let o=s(n,a,as,e);o!=cs[a]&&(t=!1),cs[a]=o}),t}function yn(e){x.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 xn,bn,kn,vn,Sn,_n,Mn,Cn,Tn,jn,Nn,Ln,Pn=!1,En=!1,In=[];function An(){En=!1;for(let e=0;e0){x.forEach((s,o)=>{if(1==a){let a=s.scale,i=I[a];if(null==i)return;let l=e[a];if(0==o){let e=l.range(n,l.min,l.max,a);l.min=e[0],l.max=e[1],ds=Oe(l.min,t[0]),hs=Oe(l.max,t[0]),hs-ds>1&&(t[0][ds]l.max&&hs--),s.min=Ds[ds],s.max=Ds[hs]}else s.show&&s.auto&&Ys(l,i,s,t[o],s.sorted);s.idxs[0]=ds,s.idxs[1]=hs}else if(o>0&&s.show&&s.auto){let[n,a]=s.facets,i=n.scale,l=a.scale,[r,c]=t[o],u=e[i],d=e[l];null!=u&&Ys(u,I[i],n,r,n.sorted),null!=d&&Ys(d,I[l],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=I[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==pt?null:s.min,s.max==-pt?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={},o=!1;for(let t in e){let n=e[t],a=v[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?dt(a.min):4==e?ft(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?dt(a.max):4==e?ft(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=o=!0}}if(o){x.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)Tt=!0,Ra("setScale",e);H&&B.left>=0&&(jt=Ft=!0)}for(let t in I)I[t]=null}(),_t=!1),Tt&&(function(){let e=!1,t=0;for(;!e;){t++;let s=pn(t),a=gn(t);e=t==qt||s&&a,e||(Wt(n.width,n.height),Mt=!0)}}(),Tt=!1),Mt){if(Ce(f,oe,$e),Ce(f,ne,Ye),Ce(f,te,Re),Ce(f,se,De),Ce(p,oe,$e),Ce(p,ne,Ye),Ce(p,te,Re),Ce(p,se,De),Ce(h,te,Pe),Ce(h,se,Ie),u.width=ot(Pe*ve),u.height=ot(Ie*ve),k.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;Ce(e,t?"left":"top",n-(3===a||0===a?s:0)),Ce(e,t?"width":"height",s),Ce(e,t?"top":"left",t?Ye:$e),Ce(e,t?"height":"width",t?De:Re),Me(e,Z)}else _e(e,Z)}),ps=ms=gs=xs=ws=js=Es=Is=ys=null,As=1,ba(!0),$e!=Ve||Ye!=Qe||Re!=Ze||De!=et){yn(!1);let e=Re/Ze,t=De/et;if(H&&!jt&&B.left>=0){B.left*=e,B.top*=t,kn&&Le(kn,ot(B.left),0,Re,De),vn&&Le(vn,0,ot(B.top),Re,De);for(let s=0;s=0&&sa.width>0){sa.left*=e,sa.width*=e,sa.top*=t,sa.height*=t;for(let e in Sa)Ce(na,e,sa[e])}Ve=$e,Qe=Ye,Ze=Re,et=De}Ra("setSize"),Mt=!1}Pe>0&&Ie>0&&(d.clearRect(0,0,u.width,u.height),Ra("drawClear"),C.forEach(e=>e()),Ra("draw")),sa.show&&Et&&(aa(sa),Et=!1),H&&jt&&(xa(null,!0,!1),jt=!1),$.show&&$.live&&Ft&&(ga(),Ft=!1),r||(r=!0,n.status=1,Ra("ready")),Fs=!1,Pn=!1}function Fn(e,s){let a=v[e];if(null==a.from){if(0==us){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(us>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==_&&2==a.distr&&us>0&&(s.min=Oe(s.min,t[0]),s.max=Oe(s.max,t[0]),s.min==s.max&&s.max++),I[e]=s,_t=!0,Rn()}}n.batch=function(e,t=!1){Pn=!0,En=t,e(n),Dn(),t&&In.length>0&&queueMicrotask(An)},n.redraw=(e,t)=>{Tt=t||!1,!1!==e?oa(_,N.min,N.max):Rn()},n.setScale=Fn;let On=!1;const Zn=B.drag;let ea=Zn.x,ta=Zn.y;H&&(B.x&&(xn=je("u-cursor-x",p)),B.y&&(bn=je("u-cursor-y",p)),0==N.ori?(kn=xn,vn=bn):(kn=bn,vn=xn),Nn=B.left,Ln=B.top);const sa=n.select=Ut({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),na=sa.show?je("u-select",sa.over?p:f):null;function aa(e,t){if(sa.show){for(let t in e)sa[t]=e[t],t in Sa&&Ce(na,t,e[t]);!1!==t&&Ra("setSelect")}}function oa(e,t,s){Fn(e,{min:t,max:s})}function ia(e,t,s,o){null!=t.focus&&function(e){if(e!=ca){let t=null==e,s=1!=Vt.alpha;x.forEach((n,o)=>{if(1==a||o>0){let a=t||0==o||o==e;n._focus=t?null:a,s&&function(e,t){x[e].alpha=t,H&&null!=Qt[e]&&(Qt[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(o,a?1:Vt.alpha)}}),ca=e,s&&Rn()}}(e),null!=t.show&&x.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(x[e].show)W&&Me(V[e],Z);else if(W&&_e(V[e],Z),H){let t=Kt?Qt[0]:Qt[e];null!=t&&Le(t,-10,-10,Re,De)}}(n),2==a?(oa(s.facets[0].scale,null,null),oa(s.facets[1].scale,null,null)):oa(s.scale,null,null),Rn())}),!1!==s&&Ra("setSeries",e,t),o&&$a("setSeries",n,e,t)}let la,ra,ca;n.setSelect=aa,n.setSeries=ia,n.addBand=function(e,t){e.fill=xt(e.fill||null),e.dir=Ke(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){Ut(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const ua={focus:!0};function da(e,t,s){let n=v[t];s&&(e=e/ve-(1==n.ori?Ye:$e));let a=Re;1==n.ori&&(a=De,e=a-e),-1==n.dir&&(e=a-e);let o=n._min,i=o+(n._max-o)*(e/a),l=n.distr;return 3==l?ct(10,i):4==l?((e,t=1)=>tt.sinh(e)*t)(i,n.asinh):100==l?n.bwd(i):i}function ha(e,t){Ce(na,oe,sa.left=e),Ce(na,te,sa.width=t)}function fa(e,t){Ce(na,ne,sa.top=e),Ce(na,se,sa.height=t)}W&&Xt&&Se(fe,q,e=>{B._lock||(Jt(e),null!=ca&&ia(null,ua,!0,Fa.setSeries))}),n.valToIdx=e=>Oe(e,t[0]),n.posToIdx=function(e,s){return Oe(da(e,_,s),t[0],ds,hs)},n.posToVal=da,n.valToPos=(e,t,s)=>0==v[t].ori?o(e,v[t],s?ht:Re,s?at:0):i(e,v[t],s?wt:De,s?ut:0),n.setCursor=(e,t,s)=>{Nn=e.left,Ln=e.top,xa(null,t,s)};let pa=0==N.ori?ha:fa,ma=1==N.ori?ha:fa;function ga(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{O[t]=e}):void 0!==e.idx&&O.fill(e.idx),$.idx=O[0]),W&&$.live){for(let e=0;e0||1==a&&!K)&&ya(e,O[e]);!function(){if(W&&$.live)for(let e=2==a?1:0;ehs;la=pt,ra=null;let r=0==N.ori?Re:De,c=1==N.ori?Re:De;if(Nn<0||0==us||l){i=B.idx=null;for(let e=0;e0&&e.show){let s=null==b?-10:b==i?o:P(1==a?t[0][b]:t[g][0][b],N,r,0),y=null==k?-10:E(k,1==a?v[e.scale]:v[e.facets[1].scale],c,0);if(Xt&&null!=k){let t=1==N.ori?Nn:Ln,s=nt(Vt.dist(n,g,b,y,t));if(s=0?1:-1;o==(k>=0?1:-1)&&(1==o?1==n?k>=a:k<=a:1==n?k<=a:k>=a)&&(la=s,ra=g)}else la=s,ra=g}}if(Ft||Kt){let e,t;0==N.ori?(e=s,t=y):(e=y,t=s);let a,o,i,r,c,x,w=!0,b=Yt.bbox;if(null!=b){w=!1;let e=b(n,g);i=e.left,r=e.top,a=e.width,o=e.height}else i=e,r=t,a=o=Yt.size(n,g);if(x=Yt.fill(n,g),c=Yt.stroke(n,g),Kt)g==ra&&la<=Vt.prox&&(l=i,u=r,d=a,h=o,f=w,p=x,m=c);else{let e=Qt[g];null!=e&&(Zt[g]=i,es[g]=r,Ae(e,a,o,w),Ee(e,x,c),Le(e,it(i),it(r),Re,De))}}}}if(Kt){let e=Vt.prox;if(Ft||(null==ca?la<=e:la>e||ra!=ca)){let e=Qt[0];null!=e&&(Zt[0]=l,es[0]=u,Ae(e,d,h,f),Ee(e,p,m),Le(e,it(l),it(u),Re,De))}}}if(sa.show&&On)if(null!=e){let[t,s]=Fa.scales,[n,a]=Fa.match,[o,i]=e.cursor.sync.scales,l=e.cursor.drag;if(ea=l._x,ta=l._y,ea||ta){let l,u,d,h,f,{left:p,top:m,width:g,height:y}=e.select,x=e.scales[o].ori,w=e.posToVal,b=null!=t&&n(t,o),k=null!=s&&a(s,i);b&&ea?(0==x?(l=p,u=g):(l=m,u=y),d=v[t],h=P(w(l,o),d,r,0),f=P(w(l+u,o),d,r,0),pa(lt(h,f),nt(f-h))):pa(0,r),k&&ta?(1==x?(l=p,u=g):(l=m,u=y),d=v[s],h=E(w(l,i),d,c,0),f=E(w(l+u,i),d,c,0),ma(lt(h,f),nt(f-h))):ma(0,c)}else _a()}else{let e=nt(Tn-Sn),t=nt(jn-_n);if(1==N.ori){let s=e;e=t,t=s}ea=Zn.x&&e>=Zn.dist,ta=Zn.y&&t>=Zn.dist;let s,n,a=Zn.uni;null!=a?ea&&ta&&(ea=e>=a,ta=t>=a,ea||ta||(t>e?ta=!0:ea=!0)):Zn.x&&Zn.y&&(ea||ta)&&(ea=ta=!0),ea&&(0==N.ori?(s=Mn,n=Nn):(s=Cn,n=Ln),pa(lt(s,n),nt(n-s)),ta||ma(0,c)),ta&&(1==N.ori?(s=Mn,n=Nn):(s=Cn,n=Ln),ma(lt(s,n),nt(n-s)),ea||pa(0,r)),ea||ta||(pa(0,0),ma(0,0))}if(Zn._x=ea,Zn._y=ta,null==e){if(o){if(null!=za){let[e,t]=Fa.scales;Fa.values[0]=null!=e?da(0==N.ori?Nn:Ln,e):null,Fa.values[1]=null!=t?da(1==N.ori?Nn:Ln,t):null}$a(ce,n,Nn,Ln,Re,De,i)}if(Xt){let e=o&&Fa.setSeries,t=Vt.prox;null==ca?la<=t&&ia(ra,ua,!0,e):la>t?ia(null,ua,!0,e):ra!=ca&&ia(ra,ua,!0,e)}}Ft&&($.idx=i,ga()),!1!==s&&Ra("setCursor")}n.setLegend=ga;let wa=null;function ba(e=!1){e?wa=null:(wa=p.getBoundingClientRect(),Ra("syncRect",wa))}function ka(e,t,s,n,a,o,i){B._lock||On&&null!=e&&0==e.movementX&&0==e.movementY||(va(e,t,s,n,a,o,0,!1,null!=e),null!=e?xa(null,!0,!0):xa(t,!0,!1))}function va(e,t,s,a,o,i,r,c,u){if(null==wa&&ba(!1),Jt(e),null!=e)s=e.clientX-wa.left,a=e.clientY-wa.top;else{if(s<0||a<0)return Nn=-10,void(Ln=-10);let[e,n]=Fa.scales,r=t.cursor.sync,[c,u]=r.values,[d,h]=r.scales,[f,p]=Fa.match,m=t.axes[0].side%2==1,g=0==N.ori?Re:De,y=1==N.ori?Re:De,x=m?i:o,w=m?o:i,b=m?a:s,k=m?s:a;if(s=null!=d?f(e,d)?l(c,v[e],g,0):-10:g*(b/x),a=null!=h?p(n,h)?l(u,v[n],y,0):-10:y*(k/w),1==N.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=ce||((s<=1||s>=Re-1)&&(s=Ct(s,Re)),(a<=1||a>=De-1)&&(a=Ct(a,De))),c?(Sn=s,_n=a,[Mn,Cn]=B.move(n,s,a)):(Nn=s,Ln=a)}Object.defineProperty(n,"rect",{get:()=>(null==wa&&ba(!1),wa)});const Sa={width:0,height:0,left:0,top:0};function _a(){aa(Sa,!1)}let Ma,Ca,Ta,ja;function Na(e,t,s,a,o,i,l){On=!0,ea=ta=Zn._x=Zn._y=!1,va(e,t,s,a,o,i,0,!0,!1),null!=e&&(Se(de,we,La,!1),$a(ue,n,Mn,Cn,Re,De,null));let{left:r,top:c,width:u,height:d}=sa;Ma=r,Ca=c,Ta=u,ja=d}function La(e,t,s,a,o,i,l){On=Zn._x=Zn._y=!1,va(e,t,s,a,o,i,0,!1,!0);let{left:r,top:c,width:u,height:d}=sa,h=u>0||d>0,f=Ma!=r||Ca!=c||Ta!=u||ja!=d;if(h&&f&&aa(sa),Zn.setScale&&h&&f){let e=r,t=u,s=c,n=d;if(1==N.ori&&(e=c,t=d,s=r,n=u),ea&&oa(_,da(e,_),da(e+t,_)),ta)for(let a in v){let e=v[a];a!=_&&null==e.from&&e.min!=pt&&oa(a,da(s+n,a),da(s,a))}_a()}else B.lock&&(B._lock=!B._lock,xa(t,!0,null!=e));null!=e&&(Ne(de,we),$a(de,n,Nn,Ln,Re,De,null))}function Pa(e,t,s,a,o,i,l){B._lock||(Jt(e),Os(),_a(),null!=e&&$a(pe,n,Nn,Ln,Re,De,null))}function Ea(){k.forEach(Qn),Bt(n.width,n.height,!0)}Fe(ge,be,Ea);const Ia={};Ia.mousedown=Na,Ia.mousemove=ka,Ia.mouseup=La,Ia.dblclick=Pa,Ia.setSeries=(e,t,s,a)=>{-1!=(s=(0,Fa.match[2])(n,t,s))&&ia(s,a,!0,!1)},H&&(Se(ue,p,Na),Se(ce,p,ka),Se(he,p,e=>{Jt(e),ba(!1)}),Se(fe,p,function(e,t,s,n,a,o,i){if(B._lock)return;Jt(e);let l=On;if(On){let e,t,s=!0,n=!0,a=10;0==N.ori?(e=ea,t=ta):(e=ta,t=ea),e&&t&&(s=Nn<=a||Nn>=Re-a,n=Ln<=a||Ln>=De-a),e&&s&&(Nn=Nn{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)Aa[t]=(Aa[t]||[]).concat(e.hooks[t])});const Da=(e,t,s)=>s,Fa=Ut({key:null,setSeries:!1,filters:{pub:vt,sub:vt},scales:[_,x[1]?x[1].scale:null],match:[St,St,Da],values:[null,null]},B.sync);2==Fa.match.length&&Fa.match.push(Da),B.sync=Fa;const za=Fa.key,Oa=hn(za);function $a(e,t,s,n,a,o,i){Fa.filters.pub(e,t,s,n,a,o,i)&&Oa.pub(e,t,s,n,a,o,i)}function Ba(){Ra("init",e,t),zs(t||e.data,!1),I[_]?Fn(_,I[_]):Os(),Et=sa.show&&(sa.width>0||sa.height>0),jt=Ft=!0,Bt(e.width,e.height)}return Oa.sub(n),n.pub=function(e,t,s,n,a,o,i){Fa.filters.sub(e,t,s,n,a,o,i)&&Ia[e](null,t,s,n,a,o,i)},n.destroy=function(){Oa.unsub(n),zn.delete(n),ke.clear(),ze(ge,be,Ea),c.remove(),null==q||q.remove(),Ra("destroy")},x.forEach(ns),k.forEach(function(e,t){if(e._show=e.show,e.show){let s=e.side%2,a=v[e.scale];null==a&&(e.scale=s?x[1].scale:_,a=v[e.scale]);let o=a.time;e.size=xt(e.size),e.space=xt(e.space),e.rotate=xt(e.rotate),Dt(e.incrs)&&e.incrs.forEach(e=>{!Lt.has(e)&&Lt.set(e,Pt(e))}),e.incrs=xt(e.incrs||(2==a.distr?ls:o?1==y?bs:Ss:rs)),e.splits=xt(e.splits||(o&&1==a.distr?D:3==a.distr?Gs:4==a.distr?Js:qs)),e.stroke=xt(e.stroke),e.grid.stroke=xt(e.grid.stroke),e.ticks.stroke=xt(e.ticks.stroke),e.border.stroke=xt(e.border.stroke);let i=e.values;e.values=Dt(i)&&!Dt(i[0])?xt(i):o?Dt(i)?Ts(A,Cs(i,R)):zt(i)?function(e,t){let s=ts(t);return(t,n,a,o,i)=>n.map(t=>s(e(t)))}(A,i):i||F:i||Us,e.filter=xt(e.filter||(a.distr>=3&&10==a.log?Zs:3==a.distr&&2==a.log?en:bt)),e.font=Kn(e.font),e.labelFont=Kn(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&&(as[t]=!0,e._el=je("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),Ba()):s(n,Ba):Ba(),n}Zn.assign=Ut,Zn.fmtNum=et,Zn.rangeNum=Xe,Zn.rangeLog=qe,Zn.rangeAsinh=Ge,Zn.orient=fn,Zn.pxRatio=ve,Zn.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 o=rt(1,at((a-n+1)/t));for(let i=e[n],l=n+o;l<=a;l+=o){const t=e[l];if(null!=t){if(t<=i)return!1;i=t}}return!0}(t[0])||(t=function(e){let t=e[0],s=t.length,n=Array(s);for(let o=0;ot[e]-t[s]);let a=[];for(let o=0;oe-t)],a=n[0].length,o=new Map;for(let i=0;ifn(e,o,(r,c,u,d,h,f,p,m,g,y,x)=>{[i,l]=He(u,i,l);let w=r.pxRound,{left:b,width:k}=e.bbox,v=e=>w(f(e,d,y,m)),S=e=>w(p(e,h,x,g)),_=0==d.ori?Sn:_n;const M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},C=M.stroke,T=d.dir*(0==d.ori?1:-1);let j=S(u[1==T?i:l]),N=v(c[1==T?i:l]),L=N,P=N;a&&-1==t&&(P=b,_(C,P,j)),_(C,N,j);for(let e=1==T?i:l;e>=i&&e<=l;e+=T){let s=u[e];if(null==s)continue;let n=v(c[e]),a=S(s);1==t?_(C,n,j):_(C,L,a),_(C,n,a),j=a,L=n}let E=L;a&&1==t&&(E=b+k,_(C,E,j));let[I,A]=pn(e,o);if(null!=r.fill||0!=I){let t=M.fill=new Path2D(C),s=S(r.fillTo(e,o,r.min,r.max,I));_(t,E,s),_(t,P,s)}if(!r.spanGaps){let a=[];a.push(...xn(c,u,i,l,T,v,n));let h=r.width*ve/2,f=s||1==t?h:-h,p=s||-1==t?-h:h;a.forEach(e=>{e[0]+=f,e[1]+=p}),M.gaps=a=r.gaps(e,o,i,l,a),M.clip=yn(a,d.ori,m,g,y,x)}return 0!=A&&(M.band=2==A?[gn(e,o,i,l,C,-1),gn(e,o,i,l,C,1)]:gn(e,o,i,l,C,A)),M})},e.bars=function(e){const t=Ke((e=e||It).size,[.6,pt,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 o=xt(a),i=1-t[0],l=Ke(t[1],pt),r=Ke(t[2],1),c=Ke(e.disp,It),u=Ke(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,f)=>fn(e,t,(p,m,g,y,x,w,b,k,v,S,_)=>{let M,C,T=p.pxRound,j=s,N=n*ve,L=l*ve,P=r*ve;0==y.ori?[M,C]=o(e,t):[C,M]=o(e,t);const E=y.dir*(0==y.ori?1:-1);let I,A,R,D=0==y.ori?Mn:Cn,F=0==y.ori?u:(e,t,s,n,a,o,i)=>{u(e,t,s,a,n,i,o)},z=Ke(e.bands,At).find(e=>e.series[0]==t),O=null!=z?z.dir:0,$=p.fillTo(e,t,p.min,p.max,O),B=T(b($,x,_,v)),W=S,H=T(p.width*ve),U=!1,q=null,G=null,J=null,Y=null;null==d||0!=H&&null==h||(U=!0,q=d.values(e,t,a,f),G=new Map,new Set(q).forEach(e=>{null!=e&&G.set(e,new Path2D)}),H>0&&(J=h.values(e,t,a,f),Y=new Map,new Set(J).forEach(e=>{null!=e&&Y.set(e,new Path2D)})));let{x0:V,size:X}=c;if(null!=V&&null!=X){j=1,m=V.values(e,t,a,f),2==V.unit&&(m=m.map(t=>e.posToVal(k+t*S,y.key,!0)));let s=X.values(e,t,a,f);A=2==X.unit?s[0]*S:w(s[0],y,S,k)-w(0,y,S,k),W=Dn(m,g,w,y,S,k,W),R=W-A+N}else W=Dn(m,g,w,y,S,k,W),R=W*i+N,A=W-R;R<1&&(R=0),H>=A/2&&(H=0),R<5&&(T=wt);let K=R>0;A=T(gt(W-R-(K?H:0),P,L)),I=(0==j?A/2:j==E?0:A)-j*E*((0==j?N/2:0)+(K?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&&(g=n.values(e,t,a,f),ee=s.values(e,t,a,f))}let te=M*A,se=C*A;for(let s=1==E?a:f;s>=a&&s<=f;s+=E){let n=g[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;B=b(e,x,_,v)}let a=w(2!=y.distr||null!=c?m[s]:s,y,S,k),o=b(Ke(n,$),x,_,v),i=T(a-I),l=T(rt(o,B)),r=T(lt(o,B)),u=l-r;if(null!=n){let a=n<0?se:te,o=n<0?te:se;U?(H>0&&null!=J[s]&&D(Y.get(J[s]),i,r+at(H/2),A,rt(0,u-H),a,o),null!=q[s]&&D(G.get(q[s]),i,r+at(H/2),A,rt(0,u-H),a,o)):D(Z,i,r+at(H/2),A,rt(0,u-H),a,o),F(e,t,s,i-H/2,r,A+H,u)}}return H>0?Q.stroke=U?Y:Z:U||(Q._fill=0==p.width?p._fill:p._stroke??p._fill,Q.width=0),Q.fill=U?G:Z,Q})},e.spline=function(e){return function(e,t){const s=Ke(null==t?void 0:t.alignGaps,0);return(t,n,a,o)=>fn(t,n,(i,l,r,c,u,d,h,f,p,m,g)=>{[a,o]=He(r,a,o);let y,x,w,b=i.pxRound,k=e=>b(d(e,c,m,f)),v=e=>b(h(e,u,g,p));0==c.ori?(y=kn,w=Sn,x=Nn):(y=vn,w=_n,x=Ln);const S=c.dir*(0==c.ori?1:-1);let _=k(l[1==S?a:o]),M=_,C=[],T=[];for(let e=1==S?a:o;e>=a&&e<=o;e+=S)if(null!=r[e]){let t=k(l[e]);C.push(M=t),T.push(v(r[e]))}const j={stroke:e(C,T,y,w,x,b),fill:null,clip:null,band:null,gaps:null,flags:1},N=j.stroke;let[L,P]=pn(t,n);if(null!=i.fill||0!=L){let e=j.fill=new Path2D(N),s=v(i.fillTo(t,n,i.min,i.max,L));w(e,M,s),w(e,_,s)}if(!i.spanGaps){let e=[];e.push(...xn(l,r,a,o,S,k,s)),j.gaps=e=i.gaps(t,n,a,o,e),j.clip=yn(e,c.ori,f,p,m,g)}return 0!=P&&(j.band=2==P?[gn(t,n,a,o,N,-1),gn(t,n,a,o,N,1)]:gn(t,n,a,o,N,P)),j})}(Fn,e)}}const ea=new Map;function ta(e){var t;if(!e.startsWith("var("))return e;const s=ea.get(e);if(s)return s;const n=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!n)return e;const a=n[1].trim(),o=(null==(t=n[2])?void 0:t.trim())||"#888888",i=getComputedStyle(document.documentElement).getPropertyValue(a).trim()||o;return ea.set(e,i),i}const sa=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:o=null,cursorColor:i="rgba(255,255,255,0.5)"}){const l=s.useRef(null),r=s.useRef(null),c=s.useRef(t),u=s.useRef(o),d=s.useRef(a),h=s.useRef(e.length);s.useLayoutEffect(()=>{c.current=t,u.current=o,d.current=a});const f=s.useMemo(()=>{const t=new Array(e.length).fill(1);return[e,t]},[e]),p=s.useMemo(()=>({hooks:{draw:e=>{!function(e,t,s){if(0===t.length)return;const n=e.ctx,a=e.bbox,o=a.left,i=a.top,l=a.width,r=a.height;if(l<=0||r<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,f=e=>{const t=c[e];return o+(t-d)/h*l},p=e=>i+r*(1-e);for(let m=0;m=0;t--){const e=f(t),s=p(o[t]);if(t===u-1)n.lineTo(e,s);else{const a=f(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:o}=e.bbox,i=window.devicePixelRatio||1,l=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=l.textPrimary,t.globalAlpha=.15,t.lineWidth=1*i,t.setLineDash([4*i,4*i]);for(const c of[.2,.4,.6,.8]){const e=Math.round(n+o*(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*i}px ${l.fontFamily}`,t.fillStyle=l.textPrimary,t.textBaseline="middle",t.textAlign="left";const r=8*i;for(const c of[0,20,40,60,80,100]){const e=n+o*(1-c/100),s=Math.max(n+r,Math.min(n+o-r,e));t.fillText(`${c}%`,0,s)}t.restore()}(e)}}}),[]),m=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:[p]}),[p]);s.useEffect(()=>{const t=l.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!r.current||a>100||s>0&&a/s>.1)&&r.current)return r.current.setData(f),void(h.current=n);r.current&&r.current.destroy();const o=t.getBoundingClientRect(),i=Math.floor(o.width)||400,c=Math.floor(o.height)||200,u=new Zn({...m,width:i,height:c},f,t);return r.current=u,h.current=n,()=>{u.destroy(),r.current=null}},[m,f,e.length]),s.useEffect(()=>{const e=l.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!r.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&r.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{r.current&&r.current.redraw()},[o,t]);const g=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:l,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})}),na=s.createContext(null);function aa({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return F;try{let t=localStorage.getItem(z),s=localStorage.getItem(O);const n=localStorage.getItem($);if(!t&&!s){const e=localStorage.getItem(B);if(e){const n=D.find(t=>t.id===e);n&&(t=n.colorScheme,s=n.backgroundImage,localStorage.setItem(z,t),localStorage.setItem(O,s),localStorage.removeItem(B))}}const a="string"==typeof(e=t)&&A.some(t=>t.id===e)?t:F.colorScheme,o=s||F.backgroundImage;let i=F.brightness;if(n){const e=parseInt(n,10);!isNaN(e)&&e>=0&&e<=100&&(i=e)}return{colorScheme:a,backgroundImage:o,brightness:i}}catch{return F}var e}());s.useEffect(()=>{(function(e){const t=(s=e,A.find(e=>e.id===s)??A[0]);var s;t.dataTheme?document.documentElement.setAttribute("data-theme",t.dataTheme):document.documentElement.removeAttribute("data-theme")})(t.colorScheme),ea.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of q){const e=K(`--palette-${t}-bright`),s=K(`--palette-${t}`),n=e||s;if(!n)continue;const a=X(n);for(const o of U)Q(`--palette-${t}-${o}`,a[o])}const e=K("--palette-bg-4");if(e){const t=X(e);for(const e of U)Q(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(z,e.colorScheme),localStorage.setItem(O,e.backgroundImage),localStorage.setItem($,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{R.forEach(e=>{(new Image).src=e.src})},[]);const o=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),i=s.useCallback(e=>{const t=R.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),l=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),r=s.useCallback(e=>{const t=D.find(t=>t.id===e);t&&a(e=>({...e,colorScheme:t.colorScheme,backgroundImage:t.backgroundImage}))},[]),c=s.useMemo(()=>({theme:t,setColorScheme:o,setBackgroundImage:i,setBrightness:l,setThemePreset:r}),[t,o,i,l,r]);return n.jsx(na.Provider,{value:c,children:e})}function oa(){const e=s.useContext(na);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const ia="0.9.143",la="'JetBrains Mono', monospace",ra=s.memo(function({height:e=16,responsive:t=!1,className:s=""}){const a="var(--accent-primary)",o="#FFFFFF";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: ${la};\n }\n .logo-accent {\n fill: var(--accent-primary, #719CDF);\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",{fill:o,children:"MC"}),n.jsx("tspan",{className:"logo-accent",children:":"}),n.jsx("tspan",{fill:o,children:"Console"})]})]})}const i="string"==typeof e?parseFloat(e):e,l={fontFamily:la,fontSize:.8*i+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:l,role:"img","aria-label":"pyMC:Console",children:[n.jsx("span",{style:{color:a},children:"py"}),n.jsx("span",{style:{color:o},children:"MC"}),n.jsx("span",{style:{color:a},children:":"}),n.jsx("span",{style:{color:o},children:"Console"})]})}),ca={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"},ua={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},da={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 ha(e){return 1===e||0===e}const fa={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function pa(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 ma(e,t={}){const s=t.spreadingFactor??fa.spreadingFactor,n=t.bandwidthHz??fa.bandwidthHz,a=t.codingRate??fa.codingRate,o=t.preambleLength??fa.preambleLength??8,i=t.crcEnabled??fa.crcEnabled?1:0,l=t.explicitHeader??fa.explicitHeader?0:1,r=s>=11&&n<=125e3?1:0,c=n/1e3,u=Math.pow(2,s)/c,d=(o+4.25)*u,h=Math.max(8*e-4*s+28+16*i-20*l,0),f=4*(s-2*r);return d+(8+Math.ceil(h/f)*a)*u}const ga="pymc_jwt_token",ya="pymc_client_id",xa="pymc_remember_me",wa=new Set;function ba(e){return wa.add(e),()=>wa.delete(e)}function ka(e){for(const s of wa)try{s(e)}catch(t){}}function va(){let e=localStorage.getItem(ya);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(ya,e)),e}function Sa(){return"true"===localStorage.getItem(xa)}function _a(e){e?localStorage.setItem(xa,"true"):localStorage.removeItem(xa)}function Ma(){return Sa()?localStorage:sessionStorage}function Ca(){return Ma().getItem(ga)||localStorage.getItem(ga)||sessionStorage.getItem(ga)}function Ta(e){Ma().setItem(ga,e),Sa()?sessionStorage.removeItem(ga):localStorage.removeItem(ga),ka(e)}function ja(){localStorage.removeItem(ga),sessionStorage.removeItem(ga),ka(null)}function Na(){return!(!Ca()||Pa()&&(ja(),1))}function La(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 Pa(){const e=Ca();if(!e)return!0;const t=La(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function Ea(){const e=Ca();if(!e)return 0;const t=La(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function Ia(){const e=Ca();if(!e)return!1;const t=La(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function Aa(){const e=Ca();if(!e)return null;const t=La(e);return t&&t.sub?t.sub:null}async function Ra(e,t,s=!1){_a(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:va()})}),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?(Ta(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function Da(){const e=Ca();if(!e)return!1;const t=La(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:va()})});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){Ta(s.token);const e=La(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 Fa=null;async function za(){const e=Ca();if(!e)return!1;const t=La(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!Ia()||Fa||(Fa=Da().finally(()=>{Fa=null}),Fa)}function Oa(){ja()}let $a=!1;function Ba(){if($a)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!Ca())return;if(Pa())return ja(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=Ea();e>0&&e<300&&await Da()};document.addEventListener("visibilitychange",e),$a=!0,"visible"===document.visibilityState&&e()}const Wa=Object.freeze(Object.defineProperty({__proto__:null,clearToken:ja,getClientId:va,getRememberMe:Sa,getToken:Ca,getTokenTimeRemaining:Ea,getUsername:Aa,isAuthenticated:Na,isTokenExpired:Pa,login:Ra,logout:Oa,onTokenChange:ba,parseJWT:La,refreshToken:Da,refreshTokenIfNeeded:za,setRememberMe:_a,setToken:Ta,shouldRefreshToken:Ia,startVisibilityBasedRefresh:Ba},Symbol.toStringTag,{value:"Module"})),Ha=new Map;let Ua=!1;async function qa(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=Ha.get(n);if(e)return e}const a=`${e}`;!s&&Ia()&&await Da();const o=Ca();if(!o&&!e.includes("/auth/"))throw window.location.href="/login",new Error("Not authenticated");const i=o?{Authorization:`Bearer ${o}`}:{};if(null==t?void 0:t.headers){const e=t.headers;e instanceof Headers?e.forEach((e,t)=>{i[t]=e}):Array.isArray(e)?e.forEach(([e,t])=>{i[e]=t}):Object.assign(i,e)}(null==t?void 0:t.body)&&(i["Content-Type"]="application/json");const l=(async()=>{const n=await fetch(a,{...t,headers:i});if(401===n.status){if(!s&&!Ua&&await Da())return qa(e,t,!0);throw Ua||(Ua=!0,ja(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText}`);return n.json()})();return n&&(Ha.set(n,l),l.finally(()=>{Ha.delete(n)})),l}function Ga(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function Ja(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=Ga(t.contact_type);return e}(await qa("/api/stats"))}async function Ya(){return qa("/api/logs")}async function Va(e=24){return qa(`/api/noise_floor_history?hours=${e}`)}async function Xa(){return qa("/api/hardware_stats")}async function Ka(){return qa("/api/send_advert",{method:"POST",body:"{}"})}async function Qa(e){return qa("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function Za(e){return qa("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}const eo=new Map;function to(e=!1){if(e)eo.clear();else for(const[t]of eo)parseInt(t.split("-")[0],10)<=60&&eo.delete(t)}function so(e,t,s,n){const a=60*e/t,o=Math.floor(Date.now()/1e3),i=Math.floor(o/a)*a,l=i-60*e,r=s.filter(e=>e.timestamp>=l&&e.timestamp<=i),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)??fa.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??fa.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??fa.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??fa.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):fa,u=function(e,t,s,n,a){const o=new Array(t),i=new Array(t),l=new Array(t),r=new Array(t),c=new Array(t);for(let d=0;d=t)continue;const f=ma(pa(u),a),p=u.packet_origin;"tx_local"===p?(i[h].count++,i[h].airtime_ms+=f):"tx_forward"===p||u.transmitted?(l[h].count++,l[h].airtime_ms+=f):u.drop_reason&&(r[h].count++,r[h].airtime_ms+=f),"tx_local"!==p&&(o[h].count++,o[h].airtime_ms+=f,c[h].snr+=u.snr||0,c[h].rssi+=u.rssi||0,c[h].count++)}for(let d=0;d0&&(o[d].avg_snr=c[d].snr/c[d].count,o[d].avg_rssi=c[d].rssi/c[d].count);return{received:o,transmitted:i,forwarded:l,dropped:r}}(r,t,l,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:l,end_time:i,...u}}async function no(e){return qa("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function ao(e){return qa("/api/set_log_level",{method:"POST",body:JSON.stringify({level:e})})}async function oo(){return qa("/api/transport_keys")}async function io(e){return qa("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}async function lo(e,t){return qa(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}async function ro(e){return qa(`/api/transport_key/${e}`,{method:"DELETE"})}async function co(e){return qa("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}async function uo(e,t=10){return qa("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:t})})}async function ho(e){return qa("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}async function fo(){return qa("/api/check_pymc_console")}async function po(){return qa("/api/restart_service",{method:"POST",body:"{}"})}async function mo(){return qa("/auth/tokens")}async function go(e){return qa("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}async function yo(e){return qa(`/auth/tokens/${e}`,{method:"DELETE"})}const xo="pymc-packet-cache",wo="pymc-packet-cache-meta",bo=36e5,ko=12096e5,vo=5e3,So=5e5,_o=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}),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}}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>bo}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-ko)/1e3),n=42e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 14-day 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,o=0,i=0;const l=Math.ceil(100);for(let r=0;r0))break;{const n=this.packets.size;this.mergePackets(u.data);const i=this.packets.size-n;a+=i;const l=Math.min(...u.data.map(e=>e.timestamp??1/0));if(l!==1/0&&(void 0===t||l=2)break}else o=0;if(u.data.length=So)break}r=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,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 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-ko)/1e3),s=42e4;this.statusMessage="Loading 14-day topology...",this.loadProgress={loaded:0,target:s,percent:0},this.notifyListeners();try{let e,n=0,a=0,o=0;const i=Math.ceil(100);for(let l=0;l0))break;{const s=this.packets.size;this.mergePackets(c.data);const o=this.packets.size-s;n+=o;const i=Math.min(...c.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===e||i=2)break}else a=0;if(c.data.length=So)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.enforceMemoryCap(),this.meta.topologyLoadComplete=!0,this.saveToStorage()}catch(n){this.statusMessage="Topology 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},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&&!this.packets.has(e)){this.packets.set(e,s),t=!0;const n=s.timestamp??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 i=0;i<3;i++)try{return await this.fetchFilteredPackets(e,t,!1,a)}catch(o){const e=2===i,t=1e3*Math.pow(2,i);o instanceof Error&&o.name,e||(this.statusMessage=`Retry in ${Math.round(t/1e3)}s...`,this.notifyListeners(),await this.delay(t))}return null}enforceMemoryCap(){if(this.packets.size<=So)return;const e=this.getPackets(),t=e.length-So;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(wo);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(xo);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>bo)return void this.clear();this.meta.backgroundLoadComplete=!1;const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(xo,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(xo),localStorage.setItem(wo,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(xo),localStorage.removeItem(wo)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await E(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Wa);return{getToken:e}},void 0),a=n(),o={};a&&(o.Authorization=`Bearer ${a}`);const i=await fetch(s,{headers:o});if(401===i.status&&!t){const{refreshToken:t}=await E(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Wa);return{refreshToken:e}},void 0);if(await t())return this.fetchRecentPackets(e,!0)}if(!i.ok)throw new Error(`API error: ${i.status}`);return i.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 o=`/api/filtered_packets?${a}`,{getToken:i}=await E(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Wa);return{getToken:e}},void 0),l=i(),r={};l&&(r.Authorization=`Bearer ${l}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(o,{headers:r,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await E(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Wa);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 Mo(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Co(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const To=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:Co(),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}}),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-BHEhB0-W.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?Mo(t.pathRegistry):Co(),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}};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,o,i,l){const r={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:o,zeroHopNeighbors:i,terrainGrid:l,enableTerrainAware:void 0!==l};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=r:this.computeInternal(r)},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()}},jo=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()}},No=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=ba(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"})}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}},Lo=.05,Po=1e3,Eo="terrarium";function Io(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const Ao=a((e,t)=>({terrainGrid:null,isLoading:!1,error:null,lastLoadedAt:null,cachedBounds:null,terrainDisambiguationEnabled:!0,loadTerrain:async(s,n)=>{const a=t();if(!(a.isLoading||(o=a.cachedBounds,i=s,o&&o.minLat<=i.minLat&&o.maxLat>=i.maxLat&&o.minLng<=i.minLng&&o.maxLng>=i.maxLng))){var o,i;e({isLoading:!0,error:null});try{n.getTerrain()||(n.getSource(Eo)||(n.addSource(Eo,{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===Eo&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:Eo}),await new Promise(e=>setTimeout(e,500)));const t=await async function(e,t){const{minLat:s,maxLat:n,minLng:a,maxLng:o}=t;let i=Math.ceil((o-a)/.001),l=Math.ceil((n-s)/.001);i>Po&&(i=Po),l>Po&&(l=Po);const r=(o-a)/i,c=(n-s)/l,u=Math.max(r,c),d=new Float32Array(i*l);let h=0;for(let f=0;fsetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:i,height:l,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(l){const t=l instanceof Error?l.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,o=-1/0;for(const i of t)s=Math.min(s,i.latitude),n=Math.max(n,i.latitude),a=Math.min(a,i.longitude),o=Math.max(o,i.longitude);return{minLat:s-Lo,maxLat:n+Lo,minLng:a-Lo,maxLng:o+Lo}}(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}}));function Ro(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function Do(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?Ro(t):null,o=n[n.length-1],i=null!==a&&o===a,l=i?n.slice(0,-1):[...n];return{effective:l,original:n,hadLocal:i,effectiveLength:l.length}}function Fo(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const zo=[{label:"20m",minutes:20,buckets:40},{label:"1h",minutes:60,buckets:60},{label:"3h",minutes:180,buckets:90},{label:"12h",minutes:720,buckets:72},{label:"24h",minutes:1440,buckets:96},{label:"3d",minutes:4320,buckets:72},{label:"7d",minutes:10080,buckets:84}],Oo=[{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 $o(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 Bo={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},Wo={DEBUG:"text-[var(--log-debug)]",INFO:"text-[var(--log-info)]",WARNING:"text-[var(--log-warning)]",ERROR:"text-[var(--log-error)]",CRITICAL:"text-[var(--log-critical)]"};function Ho(e){return Wo[e]??"text-text-muted border-border-subtle"}const Uo="pymc-resource-history",qo="pymc-resource-last-fetch",Go="pymc-hidden-contacts",Jo="pymc-quick-neighbors",Yo="pymc-local-hash";let Vo=null,Xo=null;function Ko(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function Qo(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:ha(s)?t.length<=1:0===t.length;var n}(e)}function Zo(e,t,s,n,a){if(!e)return null;let o=e;if(e.length<=4){const n=e.replace(/^0x/i,"").toUpperCase();if(n===t)return null;const a=s.get(n);if(!a)return null;o=a}return n.has(o)?o===a?null:o:null}function ei(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 ti(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function si(e,t){const s=Ko(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:Ro(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 ni(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Jo);if(e)return JSON.parse(e)}catch{}return[]}function ai(e){"undefined"!=typeof window&&(Xo&&clearTimeout(Xo),Xo=setTimeout(()=>{try{localStorage.setItem(Jo,JSON.stringify(e))}catch{}Xo=null},1e3))}function oi(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Yo);if(e)return e}catch{}}function ii(e){if("undefined"!=typeof window)try{localStorage.setItem(Yo,e)}catch{}}function li(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Uo);if(e)return JSON.parse(e)}catch{}return[]}function ri(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(Go);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function ci(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(qo);if(e)return parseInt(e,10)||0}catch{}return 0}const ui=a((e,t)=>({stats:null,statsLoading:!1,statsError:null,packets:[],packetsLoading:!1,packetsError:null,lastPacketTimestamp:0,logs:[],logsLoading:!1,liveMode:!0,flashReceived:0,flashAdvert:0,resourceHistory:li(),lastResourceFetch:ci(),hiddenContacts:ri(),quickNeighbors:ni(),cachedLocalHash:oi(),initialized:!1,packetCacheState:_o.getState(),mutationsInFlight:new Set,initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),_o.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await Ja(),a=n.neighbors??{},o=Date.now(),i=[];for(const[e,t]of Object.entries(a)){if(s.has(e))continue;if(!t.zero_hop)continue;const n=Ko(t.last_seen??0,o);"expired"!==n&&i.push({hash:e,prefix:Ro(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:n})}i.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const l=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:i,cachedLocalHash:l}),ai(i),l&&ii(l);const r=()=>{const s=_o.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 _o.initialLoad(r);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})}try{await No.init({apiBaseUrl:"",authToken:Ca()??void 0,statsIntervalMs:Bo.stats,packetsIntervalMs:Bo.packets}),No.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:o}=t();if(a.size>0)return;const i=s.neighbors??{},l=Date.now(),r=[];for(const[e,t]of Object.entries(i)){if(o.has(e))continue;if(!t.zero_hop)continue;const s=Ko(t.last_seen??0,l);"expired"!==s&&r.push({hash:e,prefix:Ro(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}r.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,quickNeighbors:r,cachedLocalHash:c}),ai(r),c&&ii(c)}),No.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:o}=t();for(const e of s)if(e.packet_hash){_o.mergePacketsDirectly(s);break}const i=a>o;i&&(e({flashReceived:t().flashReceived+1}),to());const l=_o.getPackets();e({packets:l,packetsLoading:!1,lastPacketTimestamp:a}),i&&t().triggerTopologyCompute()}),No.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||No.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},Bo.stats),setInterval(()=>{e().liveMode&&!_o.isHeavyLoadInProgress()&&e().fetchPackets()},Bo.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":Ya().catch(()=>{});break;case"/system":Xa().catch(()=>{});break;case"/statistics":(async function(e=24){return qa(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),Va(3).catch(()=>{});break;case"/settings":(async function(){return qa("/api/radio_presets")})().catch(()=>{})}},fetchStats:async s=>{const{stats:n,mutationsInFlight:a,hiddenContacts:o}=t();if(!(a.size>0)||(null==s?void 0:s.force)){n||e({statsLoading:!0}),e({statsError:null});try{const t=await Ja(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,l]of Object.entries(s)){if(o.has(e))continue;if(!l.zero_hop)continue;const t=Ko(l.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:Ro(e),count:l.advert_count??0,avgRssi:l.rssi??null,avgSnr:l.snr??null,lastSeen:l.last_seen??0,status:t})}a.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const i=t.local_hash;e({stats:t,statsLoading:!1,quickNeighbors:a,cachedLocalHash:i}),ai(a),i&&ii(i)}catch(i){e({statsError:i instanceof Error?i.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 _o.poll(),o=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,i=o>a&&a>0,l=s.length!==n.length||i;i&&(e({flashReceived:t().flashReceived+1}),to()),e(l?{packets:s,packetsLoading:!1,lastPacketTimestamp:o||a}:{packetsLoading:!1}),i&&t().triggerTopologyCompute()}catch(o){e({packetsError:o instanceof Error?o.message:"Failed to fetch packets",packetsLoading:!1})}},fetchLogs:async()=>{const{logs:s}=t();0===s.length&&e({logsLoading:!0});try{const t=await Ya();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),No.isReady()&&No.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Qa(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(i){const{mutationsInFlight:s}=t(),a=new Set(s);throw a.delete(n),e({mutationsInFlight:a}),i}},clearModeMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setMode"),e({mutationsInFlight:n})},setDutyCycle:async s=>{const n="setDutyCycle",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Za(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:o}=t(),i=new Set(o);i.add(a),e({mutationsInFlight:i});try{const e=await async function(e){return qa("/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(l){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),l}},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 Ka();return s.success&&e({flashAdvert:t().flashAdvert+1}),s.success}catch(s){return!1}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const o=Date.now(),{lastResourceFetch:i,resourceHistory:l}=t();if(o-i<1e3)return;const r=[...l,{timestamp:o,time:new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=r.length>a?r.slice(-a):r;var u,d;e({resourceHistory:c,lastResourceFetch:o}),u=c,d=o,"undefined"!=typeof window&&(Vo&&clearTimeout(Vo),Vo=setTimeout(()=>{try{localStorage.setItem(Uo,JSON.stringify(u)),localStorage.setItem(qo,d.toString())}catch{}Vo=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(Go,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{_o.clear(),e({packets:[],lastPacketTimestamp:0}),_o.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:o,stats:i,hiddenContacts:l}=t();if(0===o.length||!i)return;const r=i.neighbors??{},c=Object.fromEntries(Object.entries(r).filter(([e])=>!l.has(e))),u=i.local_hash,d=null==(s=null==(e=i.config)?void 0:e.repeater)?void 0:s.latitude,h=null==(a=null==(n=i.config)?void 0:n.repeater)?void 0:a.longitude,f=[];for(const[t,m]of Object.entries(c))m.zero_hop&&f.push({hash:t,advertCount:m.advert_count??1,avgRssi:m.rssi??null,avgSnr:m.snr??null,lastSeen:m.last_seen??0,latitude:m.latitude,longitude:m.longitude});const p=Ao.getState().getTerrainGridForDisambiguation();To.compute(o,c,u,d,h,void 0,f,p??void 0)},triggerDeepAnalysis:async()=>{await _o.forceDeepLoad();const s=_o.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 o=n.neighbors??{},i=function(e,t,s){if(!s||0===e.length||0===Object.keys(t).length)return[];const n=Date.now(),a=Ro(s),o=new Set(Object.keys(t)),i=function(e){var t,s;const n=new Map;for(const a of Object.keys(e)){const o=Ro(a),i=n.get(o);if(i){const l=null==(t=e[i])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!l&&n.set(o,a)}else n.set(o,a)}return n}(t),l=new Map;for(const c of e){if(!Qo(c))continue;const e=Zo(c.src_hash,a,i,o,s);if(!e)continue;let t=l.get(e);t||(t=ti(e),l.set(e,t)),ei(t,c)}for(const[c,u]of Object.entries(t))u.zero_hop&&!l.has(c)&&l.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 r=[];for(const c of l.values()){const e=si(c,n);e&&r.push(e)}return r.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),r}(s,Object.fromEntries(Object.entries(o).filter(([e])=>!a.has(e))),n.local_hash),l=t().quickNeighbors;(i.length!==l.length||i.some((e,t)=>{var s,n;return e.hash!==(null==(s=l[t])?void 0:s.hash)||e.count!==(null==(n=l[t])?void 0:n.count)}))&&(e({quickNeighbors:i}),ai(i))},triggerSparklineCompute:()=>{const{packets:e,stats:s,hiddenContacts:n}=t();if(0===e.length||!s)return;const a=s.neighbors??{},o=Object.keys(a).filter(e=>!n.has(e));0!==o.length&&jo.compute(e,o)}})),di=ui,hi=()=>ui(e=>e.stats),fi=()=>ui(e=>e.statsError),pi=()=>ui(e=>e.packets),mi=()=>ui(e=>e.packetsLoading),gi=()=>ui(e=>e.logs),yi=()=>ui(e=>e.logsLoading),xi=()=>ui(e=>e.liveMode),wi=()=>ui(e=>e.flashAdvert),bi=()=>ui(e=>e.fetchLogs),ki=()=>ui(e=>e.setLiveMode),vi=()=>ui(e=>e.resourceHistory),Si=()=>ui(e=>e.addResourceDataPoint),_i=()=>ui(e=>e.hiddenContacts),Mi=()=>ui(e=>e.hideContact),Ci=()=>ui(e=>e.packetCacheState),Ti=()=>ui(e=>e.triggerDeepAnalysis),ji=()=>ui(e=>e.quickNeighbors),Ni=()=>ui(e=>e.cachedLocalHash),Li=()=>ui(e=>e.lastPacketTimestamp),Pi=()=>ui(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete);function Ei({showLabel:e=!1,className:t}){const a=ui(e=>e.flashReceived),o=wi(),[i,l]=s.useState("idle");return s.useEffect(()=>{if(a<=0)return;const e=requestAnimationFrame(()=>l("received")),t=setTimeout(()=>l("idle"),300);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[a]),s.useEffect(()=>{if(o<=0)return;const e=requestAnimationFrame(()=>l("transmitted")),t=setTimeout(()=>l("idle"),300);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[o]),n.jsxs("span",{className:I("inline-flex items-center gap-2",t),children:[n.jsx("span",{className:I("inline-flex rounded-full h-2 w-2 transition-all duration-150","received"===i&&"bg-accent-danger scale-150","transmitted"===i&&"bg-white scale-150","idle"===i&&"bg-accent-success")}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Live"})]})}const Ii=a(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(()=>{jo.subscribe((e,t)=>{const s=Ii.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const Ai=()=>Ii(e=>e.isComputing),Ri=[],Di=new Map;function Fi(e){return Ii(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return Ri;const n=Di.get(e);return n===s?n:(Di.set(e,s),s)})}const zi=a(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:Co(),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}},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&&To.subscribe((e,t)=>{zi.getState().setTopology(e,t)});const Oi=()=>zi(e=>e.topology),$i=()=>zi(e=>e.topology.hubNodes),Bi=()=>zi(e=>e.topology.centrality),Wi=()=>zi(e=>e.topology.fullAffinity);let Hi=null,Ui=null,qi=null,Gi=null;const Ji=()=>zi(e=>(e.topology.hubNodes!==Ui&&(Ui=e.topology.hubNodes,Hi=new Set(e.topology.hubNodes)),Hi)),Yi=()=>zi(e=>e.topology.pathHealth),Vi=()=>zi(e=>e.topology.disambiguationStats),Xi=()=>zi(e=>e.topology.disambiguationStats.highCollisionPrefixes),Ki=()=>zi(e=>e.topology.disambiguationStats.totalPrefixes>0),Qi=()=>zi(e=>e.topology.discoveredNodes),Zi=()=>zi(e=>e.topology.viterbiStats),el=()=>zi(e=>(e.topology.discoveredNodes!==Gi&&(Gi=e.topology.discoveredNodes,qi=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),qi));function tl(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 sl(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 nl(e){const t=Date.now()/1e3-e;return t<60?`${Math.floor(t)}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function al(e){return new Date(1e3*e).toLocaleString()}function ol(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 il(e){return`${(e/1e6).toFixed(3)} MHz`}function ll(e){return`${(e/1e3).toFixed(1)} kHz`}function rl(e){const t=e>1e12?e:1e3*e,s=Date.now(),n=Math.abs(s-t),a=Math.floor(n/1e3),o=Math.floor(a/60),i=Math.floor(o/60),l=Math.floor(i/24);return l>0?`${l} day${1!==l?"s":""}`:i>0?`${i} hour${1!==i?"s":""}`:o>0?`${o} minute${1!==o?"s":""}`:`${a} second${1!==a?"s":""}`}const cl=[{name:"Dashboard",to:"/",icon:r},{name:"Contacts",to:"/contacts",icon:c},{name:"Packets",to:"/packets",icon:u},{name:"Statistics",to:"/statistics",icon:d},{name:"System",to:"/system",icon:h},{name:"Logs",to:"/logs",icon:f},{name:"Terminal",to:"/terminal",icon:p},{name:"Configuration",to:"/configuration",icon:m}],ul="pymc-controls-expanded";function dl(){var e,t,a,r;const{pathname:c}=o(),{stats:u,setMode:d,setDutyCycle:f,sendAdvert:p}=di(),m=Aa(),C=ui(e=>e.prefetchForRoute),T=Ci(),j=Ai(),N=zi(e=>e.isComputing),L=el(),[P,E]=s.useState(!1),[A,R]=s.useState(!0),[D,F]=s.useState(!1),z=s.useRef(null),O=s.useCallback(e=>{e!==c&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{C(e)},100))},[c,C]),$=s.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null)},[]);s.useEffect(()=>{const e=localStorage.getItem(ul);null!==e&&queueMicrotask(()=>R("true"===e))},[]);const B=()=>{const e=!A;R(e),localStorage.setItem(ul,String(e))};s.useEffect(()=>{queueMicrotask(()=>E(!1))},[c]),s.useEffect(()=>(document.body.style.overflow=P?"hidden":"",()=>{document.body.style.overflow=""}),[P]);const W=null==u?void 0:u.noise_floor_dbm,H=(null==(t=null==(e=null==u?void 0:u.config)?void 0:e.repeater)?void 0:t.mode)??"forward",U=(null==(r=null==(a=null==u?void 0:u.config)?void 0:a.duty_cycle)?void 0:r.enforcement_enabled)??!1,q=async()=>{F(!0),await p(),setTimeout(()=>F(!1),1e3)},G=()=>{d("forward"===H?"monitor":"forward")},J=()=>{f(!U)},Y=()=>{Oa(),window.location.href="/login"},V=T.isLoading||T.isTopologyLoading,X=V||j||N,K=T.loadProgress,Q=()=>{if(!X)return null;let e="Analyzing database";V&&K?e=`Loading ${K.loaded.toLocaleString()} packets`:j?e="Computing sparklines":N&&(e="Building topology");const t=(null==K?void 0:K.percent)??null,s=null!==t&&V;return n.jsxs("div",{className:"px-3 pb-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.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",children:e}),s&&n.jsxs("span",{className:"type-data-xs text-text-muted ml-auto",children:[t,"%"]})]}),n.jsx("div",{className:"mx-2 h-0.5 bg-white/5 rounded-full overflow-hidden",children:s?n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full transition-all duration-300 ease-out",style:{width:`${t}%`}}):n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full animate-pulse",style:{width:"100%",animation:"shimmer 1.5s ease-in-out infinite"}})})]})},Z=()=>n.jsx("nav",{className:"flex-1 px-3 py-4 space-y-1 overflow-y-auto",children:cl.map(e=>{const t=c===e.to;return n.jsxs(g,{to:e.to,onClick:()=>E(!1),onMouseEnter:()=>O(e.to),onMouseLeave:$,className:I("flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-150 min-h-[44px]",t?"bg-accent-primary/15 text-accent-primary":"text-text-muted hover:text-text-primary hover:bg-white/5"),children:[n.jsx(e.icon,{className:I("w-5 h-5 flex-shrink-0",t&&"text-accent-primary")}),n.jsx("span",{className:"type-body-sm font-medium",children:e.name}),"/contacts"===e.to&&L.length>0&&n.jsxs("span",{className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-accent-tertiary/20 text-accent-tertiary",children:[n.jsx(y,{className:"w-3 h-3"}),n.jsx("span",{className:"type-data-xs font-medium",children:L.length})]})]},e.name)})}),ee=()=>n.jsxs("div",{className:"px-3 py-3",children:[n.jsxs("button",{onClick:B,className:"w-full flex items-center justify-between px-2 py-1.5 mb-2 rounded-lg hover:bg-white/5 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(x,{className:"w-4 h-4 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Controls"})]}),n.jsx(w,{className:I("w-4 h-4 text-text-muted transition-transform duration-200",A?"rotate-0":"-rotate-90")})]}),n.jsx("div",{className:I("overflow-hidden transition-all duration-300 ease-out",A?"max-h-96 opacity-100":"max-h-0 opacity-0"),children:n.jsxs("div",{className:"control-panel-skeuo",children:[n.jsxs("button",{onClick:q,disabled:D,className:I("control-btn control-btn-primary w-full",D&&"opacity-70"),children:[n.jsx(b,{className:I("w-4 h-4",D&&"animate-pulse")}),n.jsx("span",{children:D?"Sending...":"Send Advert"})]}),n.jsxs("div",{className:"control-toggle-group",children:[n.jsxs("div",{className:"control-toggle-label",children:[n.jsx("span",{children:"Mode"}),n.jsx("span",{className:I("control-toggle-status","forward"===H?"text-accent-success":"text-accent-secondary"),children:"forward"===H?"FWD":"MON"})]}),n.jsx("button",{onClick:G,className:I("control-btn w-full","forward"===H?"control-btn-success":"control-btn-warning"),children:"forward"===H?n.jsxs(n.Fragment,{children:[n.jsx(k,{className:"w-4 h-4"}),n.jsx("span",{children:"Forward"})]}):n.jsxs(n.Fragment,{children:[n.jsx(v,{className:"w-4 h-4"}),n.jsx("span",{children:"Monitor"})]})})]}),n.jsxs("div",{className:"control-toggle-group",children:[n.jsxs("div",{className:"control-toggle-label",children:[n.jsx("span",{children:"Duty Cycle"}),n.jsx("span",{className:I("control-toggle-status",U?"text-accent-success":"text-text-muted"),children:U?"ON":"OFF"})]}),n.jsxs("button",{onClick:J,className:I("control-btn w-full",U?"control-btn-success":"control-btn-neutral"),children:[n.jsx(h,{className:"w-4 h-4"}),n.jsx("span",{children:U?"Enabled":"Disabled"})]})]})]})})]}),te=()=>n.jsxs("div",{className:"mt-auto border-t border-white/5",children:[void 0!==(null==u?void 0:u.uptime_seconds)&&n.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[n.jsx(S,{className:"w-3.5 h-3.5 text-text-muted"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[tl(u.uptime_seconds)," uptime"]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsx("div",{className:"bg-white/[0.03] 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(_,{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!=W?`${W.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-4 py-3 flex items-center justify-between border-t border-white/5",children:[n.jsx(Ei,{showLabel:!0}),(null==u?void 0:u.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted",children:["v",u.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:Y,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(M,{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,")"]})]})})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{className:"lg:hidden fixed top-0 inset-x-0 z-[10001] h-14 bg-bg-body/70 backdrop-blur-xl border-b border-white/10",children:n.jsxs("div",{className:"flex items-center justify-between h-full px-4",children:[n.jsxs("div",{className:"flex items-center",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{height:26,className:"block"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",ia]}),n.jsx(Ei,{}),n.jsx("button",{onClick:()=>E(!P),className:"w-10 h-10 flex items-center justify-center rounded-xl hover:bg-white/5 active:bg-white/10 transition-colors","aria-label":P?"Close menu":"Open menu",children:P?n.jsx(i,{className:"w-5 h-5 text-text-primary"}):n.jsx(l,{className:"w-5 h-5 text-text-primary"})})]})]})}),n.jsx("div",{className:I("lg:hidden fixed inset-0 z-[10002] bg-black/60 backdrop-blur-sm transition-opacity duration-300",P?"opacity-100":"opacity-0 pointer-events-none"),onClick:()=>E(!1),"aria-hidden":"true"}),n.jsxs("aside",{className:I("lg:hidden fixed top-0 left-0 z-[10003] w-72 max-w-[85vw] h-full","glass-sidebar","flex flex-col","transform transition-transform duration-300 ease-out",P?"translate-x-0":"-translate-x-full pointer-events-none"),children:[n.jsxs("div",{className:"px-4 py-5 border-b border-white/5",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",ia]})]}),Z(),Q(),ee(),te()]}),n.jsxs("aside",{className:"hidden lg:flex flex-col w-64 flex-shrink-0 h-full relative glass-sidebar",children:[n.jsxs("div",{className:"px-5 py-6 border-b border-white/5",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",ia]})]}),Z(),Q(),ee(),te()]})]})}const hl=s.memo(function(){const{theme:e}=oa(),{backgroundImage:t,brightness:a}=e,[o,i]=s.useState(t),[l,r]=s.useState(!1);s.useEffect(()=>{if(t===o)return;const e=new Image;e.onload=()=>{r(!0),requestAnimationFrame(()=>{i(t),setTimeout(()=>r(!1),300)})},e.onerror=()=>{i(t)},e.src=t},[t,o]);const c=(100-a)/100;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint",willChange:l?"opacity":"auto"},"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(${o})`,opacity:l?.7:1}})}),n.jsx("div",{className:"fixed inset-0 -z-10 bg-black pointer-events-none transition-opacity duration-200 ease-out",style:{opacity:c,contain:"paint"},"aria-hidden":"true"})]})}),fl=20,pl=12,ml=s.createContext(null);function gl({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),o=s.useRef(null),[i,l]=s.useState({x:0,y:0}),r=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||!o.current)return;const e=o.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,i=window.innerHeight;let r,c;r=s+fl+e.width+pl>a?s-fl-e.width:s+fl,r=Math.max(pl,Math.min(r,a-e.width-pl)),c=n-fl-e.height{c.current&&(clearTimeout(c.current),c.current=null)},h=s.useCallback(t=>{d(),c.current=setTimeout(()=>{u.current=!0,o(e,t.clientX,t.clientY)},a)},[o,e,a]),f=s.useCallback(e=>{u.current&&l(e.clientX,e.clientY)},[l]),p=s.useCallback(()=>{d(),u.current=!1,i()},[i]),m=s.useCallback(()=>{if(d(),!r.current)return;const t=r.current.getBoundingClientRect();c.current=setTimeout(()=>{u.current=!0,o(e,t.left+t.width/2,t.top)},a)},[o,e,a]),g=s.useCallback(()=>{d(),u.current=!1,i()},[i]);return s.useEffect(()=>()=>{d(),u.current&&(u.current=!1,i())},[i]),s.useEffect(()=>{const e=()=>{u.current&&(d(),u.current=!1,i())};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[i]),n.jsx("span",{ref:r,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,onFocus:m,onBlur:g,className:"contents",children:t})}function xl({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function wl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-48"}),n.jsx(xl,{className:"h-8 w-32"})]}),n.jsx(xl,{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(xl,{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(xl,{className:"h-44"},t))}),n.jsx(xl,{className:"h-96"})]})}function bl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-40"}),n.jsx(xl,{className:"h-8 w-24"})]}),n.jsx(xl,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(xl,{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(xl,{className:"h-6"})},t))})]})]})}function kl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-32"}),n.jsx(xl,{className:"h-6 w-48"})]}),n.jsx(xl,{className:"h-[500px]"}),n.jsx(xl,{className:"h-64"})]})}function vl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-36"}),n.jsx(xl,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(xl,{className:"h-80"}),n.jsx(xl,{className:"h-80"})]}),n.jsx(xl,{className:"h-64"})]})}function Sl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(xl,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(xl,{className:"h-48"}),n.jsx(xl,{className:"h-64"}),n.jsx(xl,{className:"h-32"})]})]})}function _l(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(xl,{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(xl,{className:"h-28"},t))}),n.jsx(xl,{className:"h-64"}),n.jsx(xl,{className:"h-48"})]})}const Ml=s.lazy(()=>E(()=>import("./Login-BF2bENkR.js"),__vite__mapDeps([0,1,2]))),Cl=s.lazy(()=>E(()=>import("./Dashboard-D_Tfd9l2.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11]))),Tl=s.lazy(()=>E(()=>import("./Packets-Cn-iDbXq.js"),__vite__mapDeps([12,1,2,6,7,8,5]))),jl=s.lazy(()=>E(()=>import("./Contacts-au5gCj-N.js").then(e=>e.C),__vite__mapDeps([13,1,2,5,8,7,14,15,16]))),Nl=s.lazy(()=>E(()=>import("./Statistics-BHA07L60.js"),__vite__mapDeps([17,1,2,18,4,9,5,14,11,16]))),Ll=s.lazy(()=>E(()=>import("./System-CMjUiDHD.js"),__vite__mapDeps([19,1,2,4,5,11]))),Pl=s.lazy(()=>E(()=>import("./Logs-l6s0ar29.js"),__vite__mapDeps([20,1,2,18,5]))),El=s.lazy(()=>E(()=>import("./Terminal-Vhl_DY50.js"),__vite__mapDeps([21,1,2,5]))),Il=s.lazy(()=>E(()=>import("./Configuration-Cq1_waCf.js"),__vite__mapDeps([22,1,2,8,15,5,11])));function Al({children:e}){const t=o();return Na()?n.jsx(n.Fragment,{children:e}):n.jsx(N,{to:"/login",state:{from:t},replace:!0})}class Rl 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 Dl(){const e=ui(e=>e.initializeApp),t=Na();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{za()},3e4);return za(),Ba(),()=>clearInterval(s)},[e,t]),n.jsxs(gl,{children:[n.jsx(hl,{}),n.jsxs(T,{children:[n.jsx(j,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(Ml,{})})}),n.jsx(j,{path:"/*",element:n.jsx(Al,{children:n.jsxs("div",{className:"flex h-screen overflow-hidden",children:[n.jsx(dl,{}),n.jsx("main",{className:"flex-1 w-full min-w-0 pt-14 lg:pt-0 overflow-y-auto",children:n.jsx("div",{className:"p-4 sm:p-6 lg:p-8 max-w-7xl mx-auto",children:n.jsx(Rl,{children:n.jsxs(T,{children:[n.jsx(j,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(wl,{}),children:n.jsx(Cl,{})})}),n.jsx(j,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(Tl,{})})}),n.jsx(j,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(kl,{}),children:n.jsx(jl,{})})}),n.jsx(j,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(vl,{}),children:n.jsx(Nl,{})})}),n.jsx(j,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(_l,{}),children:n.jsx(Ll,{})})}),n.jsx(j,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(Pl,{})})}),n.jsx(j,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(El,{})})}),n.jsx(j,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(Sl,{}),children:n.jsx(Il,{})})})]})})})})]})})})]})]})}const Fl=console.warn;console.warn=(...e)=>{const t=e[0];"string"==typeof t&&t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0")||Fl.apply(console,e)},L.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx(aa,{children:n.jsx(P,{children:n.jsx(Dl,{})})})}));export{vi as $,Yi as A,Zi as B,rl as C,zo as D,Fi as E,Ai as F,Ci as G,Xi as H,di as I,Mi as J,$i as K,Bi as L,uo as M,sl as N,pa as O,ra as P,ma as Q,ua as R,Zn as S,yl as T,da as U,sa as V,Vi as W,Ki as X,el as Y,Oo as Z,$o as _,mi as a,Si as a0,Xa as a1,Bo as a2,gi as a3,yi as a4,bi as a5,ao as a6,Ho as a7,Ja as a8,Ka as a9,Ao as aA,Qa as aa,Za as ab,no as ac,oa as ad,D as ae,W as af,mo as ag,oo as ah,il as ai,ll as aj,ho as ak,fo as al,po as am,go as an,yo as ao,co as ap,io as aq,lo as ar,ro as as,Li as at,_o as au,Do as av,ha as aw,Oi as ax,Ti as ay,Ni as az,xi as b,wi as c,hi as d,Ro as e,ji as f,Sa as g,_i as h,Na as i,Va as j,fi as k,Ra as l,Pi as m,so as n,tl as o,ki as p,ca as q,nl as r,_a as s,ol as t,pi as u,Fo as v,Ji as w,Wi as x,Qi as y,al as z}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-Cn28b737.js","assets/vendor-react-O8XH9yVn.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-Bb03OXu_.js","assets/useThemeColors-CD0TSU03.js","assets/PageLayout-DE5PEtD2.js","assets/PacketDetailModal-wjwmQ-9h.js","assets/SignalIndicator-BVAbF7xm.js","assets/HashBadge-aS_UIcg2.js","assets/TimeRangeSelector-9pGCd7oa.js","assets/link-scoring-Bg3LiwiV.js","assets/Grid-CIZAny_R.js","assets/Packets-Dipyssg1.js","assets/Contacts-DfRgoaov.js","assets/CollisionExplorerModal-dc7PClY6.js","assets/ConfirmModal-DYznouaT.js","assets/leaflet-CIGW-MKW.css","assets/Statistics-BAtu1fRK.js","assets/usePolling-UdPi_fKb.js","assets/System-CvdQ6ugY.js","assets/Logs-CYFnASCG.js","assets/Terminal-CXpxYdmx.js","assets/Configuration-TGWiCMQL.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,u as o,X as i,M as l,L as r,d as c,e as u,C as d,G as h,F as f,S as p,f as m,g,h as y,i as x,k as w,l as b,m as k,n as v,o as S,p as _,q as M,b as C,t as T,v as j,N,w as L,B as P}from"./vendor-react-O8XH9yVn.js";import{_ as E}from"./deckgl-DTsmDcfs.js";import{c as I}from"./recharts-BU7auunF.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 A=[{id:"default",name:"Shades of Purple",dataTheme:null,previewColor:"#B39DF3"},{id:"amber",name:"Gruvbox",dataTheme:"amber",previewColor:"#fabd2f"},{id:"grey",name:"Deus",dataTheme:"grey",previewColor:"#83a598"},{id:"black",name:"Gotham",dataTheme:"black",previewColor:"#33859d"},{id:"flora",name:"Sonokai",dataTheme:"flora",previewColor:"#9ed072"},{id:"kanagawa",name:"Kanagawa",dataTheme:"kanagawa",previewColor:"#7E9CD8"}],R=[{id:"sand",src:"/assets/sand.jpg",suggestedScheme:"default",suggestedBrightness:80},{id:"water",src:"/assets/water.webp",suggestedScheme:"grey",suggestedBrightness:40},{id:"magma",src:"/assets/magma.webp",suggestedScheme:"amber",suggestedBrightness:50},{id:"stars",src:"/assets/stars.jpg",suggestedScheme:"black",suggestedBrightness:100},{id:"ribbons",src:"/assets/ribbons.webp",suggestedScheme:"flora",suggestedBrightness:75},{id:"folds",src:"/assets/folds.webp",suggestedScheme:"kanagawa",suggestedBrightness:50}],D=[{id:"default",name:"Shades of Purple",displayName:"BlkSand",colorScheme:"default",backgroundImage:"/assets/sand.jpg",paletteColors:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]],displayFont:"'Rubik Mono One', monospace",displayColor:"#4A4A52",displaySize:.8},{id:"amber",name:"Gruvbox",displayName:"Magma",colorScheme:"amber",backgroundImage:"/assets/magma.webp",paletteColors:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]],displayFont:"'Jacquard 12', serif",displayColor:"#fe8019",displaySize:1.75},{id:"grey",name:"Deus",displayName:"Waves",colorScheme:"grey",backgroundImage:"/assets/water.webp",paletteColors:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]],displayFont:"'Cantora One', sans-serif",displayColor:"#83a598",displaySize:1.25},{id:"black",name:"Gotham",displayName:"Stars",colorScheme:"black",backgroundImage:"/assets/stars.jpg",paletteColors:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]],displayFont:"'IBM Plex Mono', monospace",displayColor:"#c23127",displaySize:1.25},{id:"flora",name:"Sonokai",displayName:"Ribbon",colorScheme:"flora",backgroundImage:"/assets/ribbons.webp",paletteColors:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]],displayFont:"'Instrument Serif', serif",displayColor:"#E2E2E3",displaySize:1.4},{id:"kanagawa",name:"Kanagawa",displayName:"Folds",colorScheme:"kanagawa",backgroundImage:"/assets/folds.webp",paletteColors:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]],displayFont:"'Inter', sans-serif",displayColor:"#7E9CD8",displaySize:1.25}],F={colorScheme:"grey",backgroundImage:"/assets/water.webp",brightness:60},z="pymc-color-scheme",O="pymc-background-image",$="pymc-bg-brightness",B="pymc-background";function W(e){(new Image).src=e}const H={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},U=[50,100,200,300,400,500,600,700,800,900],q=["red","orange","yellow","green","aqua","blue","purple"];function G(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 J(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Y(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function V(e,t,s){const n=s*(Math.PI/180),a=t*Math.cos(n),o=t*Math.sin(n),i=e+.3963377774*a+.2158037573*o,l=e-.1055613458*a-.0638541728*o,r=e-.0894841775*a-1.291485548*o,c=i*i*i,u=l*l*l,d=r*r*r,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,f=-.0041960863*c-.7034186147*u+1.707614701*d;return[Y(4.0767416621*c-3.3077115913*u+.2309699292*d),Y(h),Y(f)]}function X(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,o]=function(e,t,s){const n=J(e),a=J(t),o=J(s),i=.4122214708*n+.5363325363*a+.0514459929*o,l=.2119034982*n+.6806995451*a+.1073969566*o,r=.0883024619*n+.2817188376*a+.6299787005*o,c=Math.cbrt(i),u=Math.cbrt(l),d=Math.cbrt(r),h=.2104542553*c+.793617785*u-.0040720468*d,f=1.9779984951*c-2.428592205*u+.4505937099*d,p=.0259040371*c+.7827717662*u-.808675766*d,m=Math.sqrt(f*f+p*p);let g=Math.atan2(p,f)*(180/Math.PI);return g<0&&(g+=360),[h,m,g]}(t,s,n),i={};for(const l of U){const e=H[l],t=a*(1-.3*Math.abs(e-.5)),[s,n,r]=V(e,t,o);i[l]=G(s,n,r)}return i}function K(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Q(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const Z="u-off",ee="u-label",te="width",se="height",ne="top",ae="bottom",oe="left",ie="right",le="#000",re=le+"0",ce="mousemove",ue="mousedown",de="mouseup",he="mouseenter",fe="mouseleave",pe="dblclick",me="change",ge="dppxchange",ye="--",xe="undefined"!=typeof window,we=xe?document:null,be=xe?window:null,ke=xe?navigator:null;let ve,Se;function _e(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function Me(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function Ce(e,t,s){e.style[t]=s+"px"}function Te(e,t,s,n){let a=we.createElement(e);return null!=t&&_e(a,t),null!=s&&s.insertBefore(a,n),a}function je(e,t){return Te("div",e,t)}const Ne=new WeakMap;function Le(e,t,s,n,a){let o="translate("+t+"px,"+s+"px)";o!=Ne.get(e)&&(e.style.transform=o,Ne.set(e,o),t<0||s<0||t>n||s>a?_e(e,Z):Me(e,Z))}const Pe=new WeakMap;function Ee(e,t,s){let n=t+s;n!=Pe.get(e)&&(Pe.set(e,n),e.style.background=t,e.style.borderColor=s)}const Ie=new WeakMap;function Ae(e,t,s,n){let a=t+""+s;a!=Ie.get(e)&&(Ie.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 Re={passive:!0},De={...Re,capture:!0};function Fe(e,t,s,n){t.addEventListener(e,s,n?De:Re)}function ze(e,t,s,n){t.removeEventListener(e,s,Re)}function Oe(e,t,s,n){let a;s=s||0;let o=(n=n||t.length-1)<=2147483647;for(;n-s>1;)a=o?s+n>>1:at((s+n)/2),t[a]{let a=-1,o=-1;for(let i=s;i<=n;i++)if(e(t[i])){a=i;break}for(let i=n;i>=s;i--)if(e(t[i])){o=i;break}return[a,o]}}xe&&function e(){let t=devicePixelRatio;ve!=t&&(ve=t,Se&&ze(me,Se,e),Se=matchMedia(`(min-resolution: ${ve-.001}dppx) and (max-resolution: ${ve+.001}dppx)`),Fe(me,Se,e),be.dispatchEvent(new CustomEvent(ge)))}();const Be=e=>null!=e,We=e=>null!=e&&e>0,He=$e(Be),Ue=$e(We);function qe(e,t,s,n){let a=ut(e),o=ut(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let i=10==s?dt:ht,l=1==o?it:at,r=(1==a?at:it)(i(nt(e))),c=l(i(nt(t))),u=ct(s,r),d=ct(s,c);return 10==s&&(r<0&&(u=Nt(u,-r)),c<0&&(d=Nt(d,-c))),n||2==s?(e=u*a,t=d*o):(e=jt(e,u),t=Tt(t,d)),[e,t]}function Ge(e,t,s,n){let a=qe(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const Je={mode:3,pad:.1},Ye={pad:0,soft:null,mode:0},Ve={min:Ye,max:Ye};function Xe(e,t,s,n){return Ot(s)?Qe(e,t,s):(Ye.pad=s,Ye.soft=n?0:null,Ye.mode=n?3:0,Qe(e,t,Ve))}function Ke(e,t){return null==e?t:e}function Qe(e,t,s){let n=s.min,a=s.max,o=Ke(n.pad,0),i=Ke(a.pad,0),l=Ke(n.hard,-pt),r=Ke(a.hard,pt),c=Ke(n.soft,pt),u=Ke(a.soft,-pt),d=Ke(n.mode,0),h=Ke(a.mode,0),f=t-e,p=dt(f),m=rt(nt(e),nt(t)),g=dt(m),y=nt(g-p);(f<1e-24||y>10)&&(f=0,0!=e&&0!=t||(f=1e-24,2==d&&c!=pt&&(o=0),2==h&&u!=-pt&&(i=0)));let x=f||m||1e3,w=dt(x),b=ct(10,at(w)),k=Nt(jt(e-x*(0==f?0==e?.1:1:o),b/10),24),v=e>=c&&(1==d||3==d&&k<=c||2==d&&k>=c)?c:pt,S=rt(l,k=v?v:lt(v,k)),_=Nt(Tt(t+x*(0==f?0==t?.1:1:i),b/10),24),M=t<=u&&(1==h||3==h&&_>=u||2==h&&_<=u)?u:-pt,C=lt(r,_>M&&t<=M?M:rt(M,_));return S==C&&0==S&&(C=100),[S,C]}const Ze=new Intl.NumberFormat(xe?ke.language:"en-US"),et=e=>Ze.format(e),tt=Math,st=tt.PI,nt=tt.abs,at=tt.floor,ot=tt.round,it=tt.ceil,lt=tt.min,rt=tt.max,ct=tt.pow,ut=tt.sign,dt=tt.log10,ht=tt.log2,ft=(e,t=1)=>tt.asinh(e/t),pt=1/0;function mt(e){return 1+(0|dt((e^e>>31)-(e>>31)))}function gt(e,t,s){return lt(rt(e,t),s)}function yt(e){return"function"==typeof e}function xt(e){return yt(e)?e:()=>e}const wt=e=>e,bt=(e,t)=>t,kt=e=>null,vt=e=>!0,St=(e,t)=>e==t,_t=/\.\d*?(?=9{6,}|0{6,})/gm,Mt=e=>{if(Ft(e)||Lt.has(e))return e;const t=`${e}`,s=t.match(_t);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${Mt(e)}e${s}`}return Nt(e,n)};function Ct(e,t){return Mt(Nt(Mt(e/t))*t)}function Tt(e,t){return Mt(it(Mt(e/t))*t)}function jt(e,t){return Mt(at(Mt(e/t))*t)}function Nt(e,t=0){if(Ft(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return ot(n)/s}const Lt=new Map;function Pt(e){return((""+e).split(".")[1]||"").length}function Et(e,t,s,n){let a=[],o=n.map(Pt);for(let i=t;i=0?0:t)+(i>=o[l]?0:o[l]),u=10==e?r:Nt(r,c);a.push(u),Lt.set(u,c)}}return a}const It={},At=[],Rt=[null,null],Dt=Array.isArray,Ft=Number.isInteger;function zt(e){return"string"==typeof e}function Ot(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function $t(e){return null!=e&&"object"==typeof e}const Bt=Object.getPrototypeOf(Uint8Array),Wt="__proto__";function Ht(e,t=Ot){let s;if(Dt(e)){let n=e.find(e=>null!=e);if(Dt(n)||t(n)){s=Array(e.length);for(let n=0;no){for(n=i-1;n>=0&&null==e[n];)e[n--]=null;for(n=i+1;nPromise.resolve().then(e):queueMicrotask,Jt=["January","February","March","April","May","June","July","August","September","October","November","December"],Yt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Vt(e){return e.slice(0,3)}const Xt=Yt.map(Vt),Kt=Jt.map(Vt),Qt={MMMM:Jt,MMM:Kt,WWWW:Yt,WWW:Xt};function Zt(e){return(e<10?"0":"")+e}const es={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=>Zt(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Zt(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>Zt(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=>Zt(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Zt(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function ts(e,t){t=t||Qt;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?es[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,as=[1,2,2.5,5],os=Et(10,-32,0,as),is=Et(10,0,32,as),ls=is.filter(ns),rs=os.concat(is),cs="{YYYY}",us="\n"+cs,ds="{M}/{D}",hs="\n"+ds,fs=hs+"/{YY}",ps="{aa}",ms="{h}:{mm}"+ps,gs="\n"+ms,ys=":{ss}",xs=null;function ws(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,o=30*a,i=365*a;return[(1==e?Et(10,0,3,as).filter(ns):Et(10,-3,0,as)).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,o,2*o,3*o,4*o,6*o,i,2*i,5*i,10*i,25*i,50*i,100*i]),[[i,cs,xs,xs,xs,xs,xs,xs,1],[28*a,"{MMM}",us,xs,xs,xs,xs,xs,1],[a,ds,us,xs,xs,xs,xs,xs,1],[n,"{h}"+ps,fs,xs,hs,xs,xs,xs,1],[s,ms,fs,xs,hs,xs,xs,xs,1],[t,ys,fs+" "+ms,xs,hs+" "+ms,xs,gs,xs,1],[e,ys+".{fff}",fs+" "+ms,xs,hs+" "+ms,xs,gs,xs,1]],function(t){return(l,r,c,u,d,h)=>{let f=[],p=d>=i,m=d>=o&&d=a?a:d,i=w+(at(c)-at(y))+Tt(y-w,o);f.push(i);let p=t(i),m=p.getHours()+p.getMinutes()/s+p.getSeconds()/n,g=d/n,x=h/l.axes[r]._space;for(;i=Nt(i+d,1==e?0:3),!(i>u);)if(g>1){let e=at(Nt(m+g,6))%24,s=t(i).getHours()-e;s>1&&(s=-1),i-=s*n,m=(m+g)%24,Nt((i-f[f.length-1])/d,3)*x>=.7&&f.push(i)}else f.push(i)}return f}}]}const[bs,ks,vs]=ws(1),[Ss,_s,Ms]=ws(.001);function Cs(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 Ts(e,t){return(s,n,a,o,i)=>{let l,r,c,u,d,h,f=t.find(e=>i>=e[0])||t[t.length-1];return n.map(t=>{let s=e(t),n=s.getFullYear(),a=s.getMonth(),o=s.getDate(),i=s.getHours(),p=s.getMinutes(),m=s.getSeconds(),g=n!=l&&f[2]||a!=r&&f[3]||o!=c&&f[4]||i!=u&&f[5]||p!=d&&f[6]||m!=h&&f[7]||f[1];return l=n,r=a,c=o,u=i,d=p,h=m,g(s)})}}function js(e,t,s){return new Date(e,t,s)}function Ns(e,t){return t(e)}function Ls(e,t){return(s,n,a,o)=>null==o?ye:t(e(n))}Et(2,-53,53,[1]);const Ps={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:[]},Es=[0,0];function Is(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function As(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const Rs={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return Es[0]=t,Es[1]=s,Es},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=je(),a=s.size(e,t);Ce(n,te,a),Ce(n,se,a);let o=a/-2;Ce(n,"marginLeft",o),Ce(n,"marginTop",o);let i=s.width(e,t,a);return i&&Ce(n,"borderWidth",i),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:Is,mouseup:Is,click:Is,dblclick:Is,mousemove:As,mouseleave:As,mouseenter:As},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},Ds={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Fs=Ut({},Ds,{filter:bt}),zs=Ut({},Fs,{size:10}),Os=Ut({},Ds,{show:!1}),$s='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"',Bs="bold "+$s,Ws={show:!0,scale:"x",stroke:le,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Bs,side:2,grid:Fs,ticks:zs,border:Os,font:$s,lineGap:1.5,rotate:0},Hs={show:!0,scale:"x",auto:!1,sorted:1,min:pt,max:-pt,idxs:[]};function Us(e,t,s,n,a){return t.map(e=>null==e?"":et(e))}function qs(e,t,s,n,a,o,i){let l=[],r=Lt.get(a)||0;for(let c=s=i?s:Nt(Tt(s,a),r);c<=n;c=Nt(c+a,r))l.push(Object.is(c,-0)?0:c);return l}function Gs(e,t,s,n,a,o,i){const l=[],r=e.scales[e.axes[t].scale].log,c=at((10==r?dt:ht)(s));a=ct(r,c),10==r&&(a=rs[Oe(a,rs)]);let u=s,d=a*r;10==r&&(d=rs[Oe(d,rs)]);do{l.push(u),u+=a,10!=r||Lt.has(u)||(u=Nt(u,Lt.get(a))),u>=d&&(d=(a=u)*r,10==r&&(d=rs[Oe(d,rs)]))}while(u<=n);return l}function Js(e,t,s,n,a,o,i){let l=e.scales[e.axes[t].scale].asinh,r=n>l?Gs(e,t,rt(l,s),n,a):[l],c=n>=0&&s<=0?[0]:[];return(s<-l?Gs(e,t,rt(l,-n),-s,a):[l]).reverse().map(e=>-e).concat(c,r)}const Ys=/./,Vs=/[12357]/,Xs=/[125]/,Ks=/1/,Qs=(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 Zs(e,t,s,n,a){let o=e.axes[s],i=o.scale,l=e.scales[i],r=e.valToPos,c=o._space,u=r(10,i),d=r(9,i)-u>=c?Ys:r(7,i)-u>=c?Vs:r(5,i)-u>=c?Xs:Ks;if(d==Ks){let e=nt(r(1,i)-u);if(ea,on={show:!0,auto:!0,sorted:0,gaps:an,alpha:1,facets:[Ut({},nn,{scale:"x"}),Ut({},nn,{scale:"y"})]},ln={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:an,alpha:1,points:{show:function(e,t){let{scale:s,idxs:n}=e.series[0],a=e._data[0],o=e.valToPos(a[n[0]],s,!0),i=e.valToPos(a[n[1]],s,!0),l=nt(i-o)/(e.series[t].points.space*ve);return n[1]-n[0]<=l},filter:null},values:null,min:pt,max:-pt,idxs:[],path:null,clip:null};function rn(e,t,s,n,a){return s/10}const cn={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},un=Ut({},cn,{time:!1,ori:1}),dn={};function hn(e,t){let s=dn[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,o,i,l){for(let r=0;r{let m=e.pxRound;const g=l.dir*(0==l.ori?1:-1),y=0==l.ori?Sn:_n;let x,w;1==g?(x=s,w=n):(x=n,w=s);let b=m(c(t[x],l,f,d)),k=m(u(i[x],r,p,h)),v=m(c(t[w],l,f,d)),S=m(u(1==o?r.max:r.min,r,p,h)),_=new Path2D(a);return y(_,v,S),y(_,b,S),y(_,b,k),_})}function yn(e,t,s,n,a,o){let i=null;if(e.length>0){i=new Path2D;const l=0==t?Mn:Cn;let r=s;for(let t=0;ts[0]){let e=s[0]-r;e>0&&l(i,r,n,e,n+o),r=s[1]}}let c=s+a-r,u=10;c>0&&l(i,r,n-u/2,c,n+o+u)}return i}function xn(e,t,s,n,a,o,i){let l=[],r=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=o(e[u]),f=d==u?h:o(e[d]),p=u-a;h=i<=0&&p>=0&&p=0&&m>=0&&m=h&&l.push([h,f])}return l}function wn(e){return 0==e?wt:1==e?ot:t=>Ct(t,e)}function bn(e){let t=0==e?kn:vn,s=0==e?(e,t,s,n,a,o)=>{e.arcTo(t,s,n,a,o)}:(e,t,s,n,a,o)=>{e.arcTo(s,t,a,n,o)},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,o,i,l,r=0,c=0)=>{0==r&&0==c?n(e,a,o,i,l):(r=lt(r,i/2,l/2),c=lt(c,i/2,l/2),t(e,a+r,o),s(e,a+i,o,a+i,o+l,r),s(e,a+i,o+l,a,o+l,c),s(e,a,o+l,a,o,c),s(e,a,o,a+i,o,r),e.closePath())}}const kn=(e,t,s)=>{e.moveTo(t,s)},vn=(e,t,s)=>{e.moveTo(s,t)},Sn=(e,t,s)=>{e.lineTo(t,s)},_n=(e,t,s)=>{e.lineTo(s,t)},Mn=bn(0),Cn=bn(1),Tn=(e,t,s,n,a,o)=>{e.arc(t,s,n,a,o)},jn=(e,t,s,n,a,o)=>{e.arc(s,t,n,a,o)},Nn=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(t,s,n,a,o,i)},Ln=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(s,t,a,n,i,o)};function Pn(e){return(e,t,s,n,a)=>fn(e,t,(t,o,i,l,r,c,u,d,h,f,p)=>{let m,g,{pxRound:y,points:x}=t;0==l.ori?(m=kn,g=Tn):(m=vn,g=jn);const w=Nt(x.width*ve,3);let b=(x.size-x.width)/2*ve,k=Nt(2*b,3),v=new Path2D,S=new Path2D,{left:_,top:M,width:C,height:T}=e.bbox;Mn(S,_-k,M-k,C+2*k,T+2*k);const j=e=>{if(null!=i[e]){let t=y(c(o[e],l,f,d)),s=y(u(i[e],r,p,h));m(v,t+b,s),g(v,t,s,b,0,2*st)}};if(a)a.forEach(j);else for(let e=s;e<=n;e++)j(e);return{stroke:w>0?v:null,fill:v,clip:S,flags:3}})}function En(e){return(t,s,n,a,o,i)=>{n!=a&&(o!=n&&i!=n&&e(t,s,n),o!=a&&i!=a&&e(t,s,a),e(t,s,i))}}const In=En(Sn),An=En(_n);function Rn(e){const t=Ke(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>fn(e,s,(o,i,l,r,c,u,d,h,f,p,m)=>{[n,a]=He(l,n,a);let g,y,x=o.pxRound,w=e=>x(u(e,r,p,h)),b=e=>x(d(e,c,m,f));0==r.ori?(g=Sn,y=In):(g=_n,y=An);const k=r.dir*(0==r.ori?1:-1),v={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=v.stroke;let _=!1;if(a-n>=4*p){let t,s,o,c=t=>e.posToVal(t,r.key,!0),u=null,d=null,h=w(i[1==k?n:a]),f=w(i[n]),p=w(i[a]),m=c(1==k?f+1:p-1);for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let n=i[e],a=(1==k?nm)?h:w(n),o=l[e];a==h?null!=o?(s=o,null==u?(g(S,a,b(s)),t=u=d=s):sd&&(d=s)):null===o&&(_=!0):(null!=u&&y(S,h,b(u),b(d),b(t),b(s)),null!=o?(s=o,g(S,a,b(s)),u=d=t=s):(u=d=null,null===o&&(_=!0)),h=a,m=c(h+k))}null!=u&&u!=d&&o!=h&&y(S,h,b(u),b(d),b(t),b(s))}else for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let t=l[e];null===t?_=!0:null!=t&&g(S,w(i[e]),b(t))}let[M,C]=pn(e,s);if(null!=o.fill||0!=M){let t=v.fill=new Path2D(S),l=b(o.fillTo(e,s,o.min,o.max,M)),r=w(i[n]),c=w(i[a]);-1==k&&([c,r]=[r,c]),g(t,c,l),g(t,r,l)}if(!o.spanGaps){let c=[];_&&c.push(...xn(i,l,n,a,k,w,t)),v.gaps=c=o.gaps(e,s,n,a,c),v.clip=yn(c,r.ori,h,f,p,m)}return 0!=C&&(v.band=2==C?[gn(e,s,n,a,S,-1),gn(e,s,n,a,S,1)]:gn(e,s,n,a,S,C)),v})}function Dn(e,t,s,n,a,o,i=pt){if(e.length>1){let l=null;for(let r=0,c=1/0;r0!=n[e]>0?s[e]=0:(s[e]=3*(r[e-1]+r[e])/((2*r[e]+r[e-1])/n[e-1]+(r[e]+2*r[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[i-1]=n[i-2];for(let c=0;c{Zn.pxRatio=ve}));const $n=Rn(),Bn=Pn();function Wn(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>Hn(e,n,t,s))}function Hn(e,t,s,n){return Ut({},0==t?s:n,e)}function Un(e,t,s){return null==t?Rt:[t,s]}const qn=Un;function Gn(e,t,s){return null==t?Rt:Xe(t,s,.1,!0)}function Jn(e,t,s,n){return null==t?Rt:qe(t,s,e.scales[n].log,!1)}const Yn=Jn;function Vn(e,t,s,n){return null==t?Rt:Ge(t,s,e.scales[n].log,!1)}const Xn=Vn;function Kn(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=ot((s=+n)*ve))+"px"),t,s]}function Qn(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Nt(e[2]*ve,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function Zn(e,t,s){const n={mode:Ke(e.mode,1)},a=n.mode;function o(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?1-a:a)}function i(e,t,s,n){let a=t.valToPct(e);return n+s*(-1==t.dir?a:1-a)}function l(e,t,s,n){return 0==t.ori?o(e,t,s,n):i(e,t,s,n)}n.valToPosH=o,n.valToPosV=i;let r=!1;n.status=0;const c=n.root=je("uplot");null!=e.id&&(c.id=e.id),_e(c,e.class),e.title&&(je("u-title",c).textContent=e.title);const u=Te("canvas"),d=n.ctx=u.getContext("2d"),h=je("u-wrap",c);Fe("click",h,e=>{e.target===p&&(Nn!=Mn||Ln!=Cn)&&Zn.click(n,e)},!0);const f=n.under=je("u-under",h);h.appendChild(u);const p=n.over=je("u-over",h),m=+Ke((e=Ht(e)).pxAlign,1),g=wn(m);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const y=e.ms||.001,x=n.series=1==a?Wn(e.series||[],Hs,ln,!1):(w=e.series||[null],b=on,w.map((e,t)=>0==t?{}:Ut({},b,e)));var w,b;const k=n.axes=Wn(e.axes||[],Ws,sn,!0),v=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=xt(e.fill||null),e.dir=Ke(e.dir,-1)});const _=2==a?x[1].facets[0].scale:x[0].scale,M={axes:function(){for(let e=0;eDs[e]):y,w=2==f.distr?Ds[y[1]]-Ds[y[0]]:u,b=t.ticks,S=t.border,_=b.show?b.size:0,M=ot(_*ve),C=ot((2==t.alignTo?t._size-_-t.gap:t.gap)*ve),T=t._rotate*-st/180,j=g(t._pos*ve),N=j+(M+C)*c;a=0==i?N:0,s=1==i?N:0,Bs(t.font[0],r,1==t.align?oe:2==t.align?ie:T>0?oe:T<0?ie:0==i?"center":3==o?ie:oe,T||1==i?"middle":2==o?ne:ae);let L=t.font[1]*t.lineGap,P=y.map(e=>g(l(e,f,p,m))),E=t._values;for(let e=0;e0){let e=x.some(e=>e._focus)&&As!=Vt.alpha;e&&(d.globalAlpha=As=Vt.alpha),x.forEach((e,s)=>{if(s>0&&e.show&&(Xs(s,!1),Xs(s,!0),null==e._paths)){let o=As;As!=e.alpha&&(d.globalAlpha=As=e.alpha);let i=2==a?[0,t[s][0].length-1]:function(e){let t=gt(ds-1,0,us-1),s=gt(hs+1,0,us-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=As;As!=e.alpha&&(d.globalAlpha=As=e.alpha),null!=e._paths&&Ks(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,ds,hs,s),o=e.points.filter(n,t,a,s);(a||o)&&(e.points._paths=e.points.paths(n,t,ds,hs,o),Ks(t,!0))}As!=s&&(d.globalAlpha=As=s),Ra("drawSeries",t)}}),e&&(d.globalAlpha=As=1)}}},C=(e.drawOrder||["axes","series"]).map(e=>M[e]);function T(e){const t=3==e.distr?t=>dt(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>ft(t,e.asinh):100==e.distr?t=>e.fwd(t):e=>e;return s=>{let n=t(s),{_min:a,_max:o}=e;return(n-a)/(o-a)}}function j(t){let s=v[t];if(null==s){let n=(e.scales||It)[t]||It;if(null!=n.from){j(n.from);let e=Ut({},v[n.from],n,{key:t});e.valToPct=T(e),v[t]=e}else{s=v[t]=Ut({},t==_?cn:un,n),s.key=t;let e=s.time,o=s.range,i=Dt(o);if((t!=_||2==a&&!e)&&(!i||null!=o[0]&&null!=o[1]||(o={min:null==o[0]?Je:{mode:1,hard:o[0],soft:o[0]},max:null==o[1]?Je:{mode:1,hard:o[1],soft:o[1]}},i=!1),!i&&Ot(o))){let e=o;o=(t,s,n)=>null==s?Rt:Xe(s,n,e)}s.range=xt(o||(e?qn:t==_?3==s.distr?Yn:4==s.distr?Xn:Un:3==s.distr?Jn:4==s.distr?Vn:Gn)),s.auto=xt(!i&&s.auto),s.clamp=xt(s.clamp||rn),s._min=s._max=null,s.valToPct=T(s)}}}j("x"),j("y"),1==a&&x.forEach(e=>{j(e.scale)}),k.forEach(e=>{j(e.scale)});for(let Z in e.scales)j(Z);const N=v[_],L=N.distr;let P,E;0==N.ori?(_e(c,"u-hz"),P=o,E=i):(_e(c,"u-vt"),P=i,E=o);const I={};for(let Z in v){let e=v[Z];null==e.min&&null==e.max||(I[Z]={min:e.min,max:e.max},e.min=e.max=null)}const A=e.tzDate||(e=>new Date(ot(e/y))),R=e.fmtDate||ts,D=1==y?vs(A):Ms(A),F=Ts(A,Cs(1==y?ks:_s,R)),z=Ls(A,Ns("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",R)),O=[],$=n.legend=Ut({},Ps,e.legend),B=n.cursor=Ut({},Rs,{drag:{y:2==a}},e.cursor),W=$.show,H=B.show,U=$.markers;let q,G,J;$.idxs=O,U.width=xt(U.width),U.dash=xt(U.dash),U.stroke=xt(U.stroke),U.fill=xt(U.fill);let Y,V=[],X=[],K=!1,Q={};if($.live){const e=x[1]?x[1].values:null;K=null!=e,Y=K?e(n,1,0):{_:0};for(let t in Y)Q[t]=ye}if(W)if(q=Te("table","u-legend",c),J=Te("tbody",null,q),$.mount(n,q),K){G=Te("thead",null,q,J);let e=Te("tr",null,G);for(var le in Te("th",null,e),Y)Te("th",ee,e).textContent=le}else _e(q,"u-inline"),$.live&&_e(q,"u-live");const me={show:!0},xe={show:!1},ke=new Map;function Se(e,t,s,a=!0){const o=ke.get(t)||{},i=B.bind[e](n,t,s,a);i&&(Fe(e,t,o[e]=i),ke.set(t,o))}function Ne(e,t,s){const n=ke.get(t)||{};for(let a in n)null!=e&&a!=e||(ze(a,t,n[a]),delete n[a]);null==e&&ke.delete(t)}let Pe=0,Ie=0,Re=0,De=0,$e=0,Ye=0,Ve=$e,Qe=Ye,Ze=Re,et=De,at=0,ut=0,ht=0,wt=0;n.bbox={};let _t=!1,Mt=!1,Tt=!1,jt=!1,Et=!1,Ft=!1;function Bt(e,t,s){(s||e!=n.width||t!=n.height)&&Wt(e,t),yn(!1),Tt=!0,Mt=!0,Rn()}function Wt(e,t){n.width=Pe=Re=e,n.height=Ie=De=t,$e=Ye=0,function(){let e=!1,t=!1,s=!1,n=!1;k.forEach((a,o)=>{if(a.show&&a._show){let{side:o,_size:i}=a,l=o%2,r=i+(null!=a.label?a.labelSize:0);r>0&&(l?(Re-=r,3==o?($e+=r,n=!0):s=!0):(De-=r,0==o?(Ye+=r,e=!0):t=!0))}}),as[0]=e,as[1]=s,as[2]=t,as[3]=n,Re-=cs[1]+cs[3],$e+=cs[3],De-=cs[2]+cs[0],Ye+=cs[0]}(),function(){let e=$e+Re,t=Ye+De,s=$e,n=Ye;function a(a,o){switch(a){case 1:return e+=o,e-o;case 2:return t+=o,t-o;case 3:return s-=o,s+o;case 0:return n-=o,n+o}}k.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;at=s.left=Ct($e*ve,.5),ut=s.top=Ct(Ye*ve,.5),ht=s.width=Ct(Re*ve,.5),wt=s.height=Ct(De*ve,.5)}const qt=3;if(n.setSize=function({width:e,height:t}){Bt(e,t)},null==B.dataIdx){let e=B.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=xt(e.prox),a=e.bias??(e.bias=0);B.dataIdx=(e,o,i,l)=>{if(0==o)return i;let r=i,c=n(e,o,i,l)??pt,u=c>=0&&c0;)s.has(p[e])||(t=e);if(0==a||1==a)for(e=i;null==n&&e++c&&(r=null);return r}}const Jt=e=>{B.event=e};B.idxs=O,B._lock=!1;let Yt=B.points;Yt.show=xt(Yt.show),Yt.size=xt(Yt.size),Yt.stroke=xt(Yt.stroke),Yt.width=xt(Yt.width),Yt.fill=xt(Yt.fill);const Vt=n.focus=Ut({},e.focus||{alpha:.3},B.focus),Xt=Vt.prox>=0,Kt=Xt&&Yt.one;let Qt=[],Zt=[],es=[];function ss(e,t){let s=Yt.show(n,t);if(s instanceof HTMLElement)return _e(s,"u-cursor-pt"),_e(s,e.class),Le(s,-10,-10,Re,De),p.insertBefore(s,Qt[t]),s}function ns(e,t){if(1==a||t>0){let t=1==a&&v[e.scale].time,s=e.value;e.value=t?zt(s)?Ls(A,Ns(s,R)):s||z:s||tn,e.label=e.label||(t?"Time":"Value")}if(Kt||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||$n||kt,e.fillTo=xt(e.fillTo||mn),e.pxAlign=+Ke(e.pxAlign,m),e.pxRound=wn(e.pxAlign),e.stroke=xt(e.stroke||null),e.fill=xt(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=Nt(1*(3+2*(rt(1,e.width)||1)),3),s=e.points=Ut({},{size:t,width:rt(1,.2*t),stroke:e.stroke,space:2*t,paths:Bn,_stroke:null,_fill:null},e.points);s.show=xt(s.show),s.filter=xt(s.filter),s.fill=xt(s.fill),s.stroke=xt(s.stroke),s.paths=xt(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(K||!$.live||2==a))return Rt;let s=[],o=Te("tr","u-series",J,J.childNodes[t]);_e(o,e.class),e.show||_e(o,Z);let i=Te("th",null,o);if(U.show){let e=je("u-marker",i);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 l=je(ee,i);for(var r in e.label instanceof HTMLElement?l.appendChild(e.label):l.textContent=e.label,t>0&&(U.show||(l.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),Se("click",i,t=>{if(B._lock)return;Jt(t);let s=x.indexOf(e);if((t.ctrlKey||t.metaKey)!=$.isolate){let e=x.some((e,t)=>t>0&&t!=s&&e.show);x.forEach((t,n)=>{n>0&&ia(n,e?n==s?me:xe:me,!0,Fa.setSeries)})}else ia(s,{show:!e.show},!0,Fa.setSeries)},!1),Xt&&Se(he,i,t=>{B._lock||(Jt(t),ia(x.indexOf(e),ua,!0,Fa.setSeries))},!1)),Y){let e=Te("td","u-value",o);e.textContent="--",s.push(e)}return[o,s]}(e,t);V.splice(t,0,s[0]),X.splice(t,0,s[1]),$.values.push(null)}if(H){O.splice(t,0,null);let s=null;Kt?0==t&&(s=ss(e,t)):t>0&&(s=ss(e,t)),Qt.splice(t,0,s),Zt.splice(t,0,0),es.splice(t,0,0)}Ra("addSeries",t)}n.addSeries=function(e,t){t=null==t?x.length:t,e=1==a?Hn(e,t,Hs,ln):Hn(e,t,{},on),x.splice(t,0,e),ns(x[t],t)},n.delSeries=function(e){if(x.splice(e,1),W){$.values.splice(e,1),X.splice(e,1);let t=V.splice(e,1)[0];Ne(null,t.firstChild),t.remove()}H&&(O.splice(e,1),Qt.splice(e,1)[0].remove(),Zt.splice(e,1),es.splice(e,1)),Ra("delSeries",e)};const as=[!1,!1,!1,!1];function os(e,t,s,n){let[a,o,i,l]=s,r=t%2,c=0;return 0==r&&(l||o)&&(c=0==t&&!a||2==t&&!i?ot(Ws.size/3):0),1==r&&(a||i)&&(c=1==t&&!o||3==t&&!l?ot(sn.size/2):0),c}const is=n.padding=(e.padding||[os,os,os,os]).map(e=>xt(Ke(e,os))),cs=n._padding=is.map((e,t)=>e(n,t,as,0));let us,ds=null,hs=null;const fs=1==a?x[0].idxs:null;let ps,ms,gs,ys,xs,ws,js,Es,Is,As,Ds=null,Fs=!1;function zs(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){us=0;for(let e=1;e=0,Ft=!0,Rn()}}function Os(){let e,s;Fs=!0,1==a&&(us>0?(ds=fs[0]=0,hs=fs[1]=us-1,e=t[0][ds],s=t[0][hs],2==L?(e=ds,s=hs):e==s&&(3==L?[e,s]=qe(e,e,N.log,!1):4==L?[e,s]=Ge(e,e,N.log,!1):N.time?s=e+ot(86400/y):[e,s]=Xe(e,s,.1,!0))):(ds=fs[0]=e=null,hs=fs[1]=s=null)),oa(_,e,s)}function $s(e,t,s,n,a,o){e??(e=re),s??(s=At),n??(n="butt"),a??(a=re),o??(o="round"),e!=ps&&(d.strokeStyle=ps=e),a!=ms&&(d.fillStyle=ms=a),t!=gs&&(d.lineWidth=gs=t),o!=xs&&(d.lineJoin=xs=o),n!=ws&&(d.lineCap=ws=n),s!=ys&&d.setLineDash(ys=s)}function Bs(e,t,s,n){t!=ms&&(d.fillStyle=ms=t),e!=js&&(d.font=js=e),s!=Es&&(d.textAlign=Es=s),n!=Is&&(d.textBaseline=Is=n)}function Ys(e,t,s,a,o=0){if(a.length>0&&e.auto(n,Fs)&&(null==t||null==t.min)){let t=Ke(ds,0),n=Ke(hs,a.length-1),i=null==s.min?function(e,t,s,n=0,a=!1){let o=a?Ue:He,i=a?We:Be;[t,s]=o(e,t,s);let l=e[t],r=e[t];if(t>-1)if(1==n)l=e[t],r=e[s];else if(-1==n)l=e[s],r=e[t];else for(let c=t;c<=s;c++){let t=e[c];i(t)&&(tr&&(r=t))}return[l??pt,r??-pt]}(a,t,n,o,3==e.distr):[s.min,s.max];e.min=lt(e.min,s.min=i[0]),e.max=rt(e.max,s.max=i[1])}}n.setData=zs;const Vs={min:null,max:null};function Xs(e,t){let s=t?x[e].points:x[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function Ks(e,s){let a=s?x[e].points:x[e],{stroke:o,fill:i,clip:l,flags:r,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=Nt(h*ve,3);let f=null,p=h%2/2;s&&null==u&&(u=h>0?"#fff":c);let m=1==a.pxAlign&&p>0;if(m&&d.translate(p,p),!s){let e=at-h/2,t=ut-h/2,s=ht+h,n=wt+h;f=new Path2D,f.rect(e,t,s,n)}s?nn(c,h,a.dash,a.cap,u,o,i,r,l):function(e,s,a,o,i,l,r,c,u,d,h){let f=!1;0!=u&&S.forEach((p,m)=>{if(p.series[0]==e){let e,g=x[p.series[1]],y=t[p.series[1]],w=(g._paths||It).band;Dt(w)&&(w=1==p.dir?w[0]:w[1]);let b=null;g.show&&w&&function(e,t,s){for(t=Ke(t,0),s=Ke(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(y,ds,hs)?(b=p.fill(n,m)||l,e=g._paths.clip):w=null,nn(s,a,o,i,b,r,c,u,d,h,e,w),f=!0}}),f||nn(s,a,o,i,l,r,c,u,d,h)}(e,c,h,a.dash,a.cap,u,o,i,r,f,l),m&&d.translate(-p,-p)}const Qs=3;function nn(e,t,s,n,a,o,i,l,r,c,u,h){$s(e,t,s,n,a),(r||c||h)&&(d.save(),r&&d.clip(r),c&&d.clip(c)),h?(l&Qs)==Qs?(d.clip(h),u&&d.clip(u),dn(a,i),an(e,o,t)):2&l?(dn(a,i),d.clip(h),an(e,o,t)):1&l&&(d.save(),d.clip(h),u&&d.clip(u),dn(a,i),d.restore(),an(e,o,t)):(dn(a,i),an(e,o,t)),(r||c||h)&&d.restore()}function an(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=ps=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function dn(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=ms=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function fn(e,t,s,n,a,o,i,l,r,c){let u=i%2/2;1==m&&d.translate(u,u),$s(l,i,r,c,l),d.beginPath();let h,f,p,g,y=a+(0==n||3==n?-o:o);0==s?(f=a,g=y):(h=a,p=y);for(let m=0;m{if(!s.show)return;let o=v[s.scale];if(null==o.min)return void(s._show&&(t=!1,s._show=!1,yn(!1)));s._show||(t=!1,s._show=!0,yn(!1));let i=s.side,l=i%2,{min:r,max:c}=o,[u,d]=function(e,t,s,a){let o,i=k[e];if(a<=0)o=[0,0];else{let l=i._space=i.space(n,e,t,s,a);o=function(e,t,s,n,a){let o=rt(mt(e),mt(t)),i=t-e,l=Oe(a/n*i,s);do{let e=s[l],t=n*e/i;if(t>=a&&o+(e<5?Lt.get(e):0)<=17)return[e,t]}while(++lDs[e]):f,m=2==o.distr?Ds[f[1]]-Ds[f[0]]:u,g=s._values=s.values(n,s.filter(n,p,a,d,m),a,d,m);s._rotate=2==i?s.rotate(n,g,a,d):0;let y=s._size;s._size=it(s.size(n,g,a,e)),null!=y&&s._size!=y&&(t=!1)}),t}function gn(e){let t=!0;return is.forEach((s,a)=>{let o=s(n,a,as,e);o!=cs[a]&&(t=!1),cs[a]=o}),t}function yn(e){x.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 xn,bn,kn,vn,Sn,_n,Mn,Cn,Tn,jn,Nn,Ln,Pn=!1,En=!1,In=[];function An(){En=!1;for(let e=0;e0){x.forEach((s,o)=>{if(1==a){let a=s.scale,i=I[a];if(null==i)return;let l=e[a];if(0==o){let e=l.range(n,l.min,l.max,a);l.min=e[0],l.max=e[1],ds=Oe(l.min,t[0]),hs=Oe(l.max,t[0]),hs-ds>1&&(t[0][ds]l.max&&hs--),s.min=Ds[ds],s.max=Ds[hs]}else s.show&&s.auto&&Ys(l,i,s,t[o],s.sorted);s.idxs[0]=ds,s.idxs[1]=hs}else if(o>0&&s.show&&s.auto){let[n,a]=s.facets,i=n.scale,l=a.scale,[r,c]=t[o],u=e[i],d=e[l];null!=u&&Ys(u,I[i],n,r,n.sorted),null!=d&&Ys(d,I[l],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=I[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==pt?null:s.min,s.max==-pt?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={},o=!1;for(let t in e){let n=e[t],a=v[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?dt(a.min):4==e?ft(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?dt(a.max):4==e?ft(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=o=!0}}if(o){x.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)Tt=!0,Ra("setScale",e);H&&B.left>=0&&(jt=Ft=!0)}for(let t in I)I[t]=null}(),_t=!1),Tt&&(function(){let e=!1,t=0;for(;!e;){t++;let s=pn(t),a=gn(t);e=t==qt||s&&a,e||(Wt(n.width,n.height),Mt=!0)}}(),Tt=!1),Mt){if(Ce(f,oe,$e),Ce(f,ne,Ye),Ce(f,te,Re),Ce(f,se,De),Ce(p,oe,$e),Ce(p,ne,Ye),Ce(p,te,Re),Ce(p,se,De),Ce(h,te,Pe),Ce(h,se,Ie),u.width=ot(Pe*ve),u.height=ot(Ie*ve),k.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;Ce(e,t?"left":"top",n-(3===a||0===a?s:0)),Ce(e,t?"width":"height",s),Ce(e,t?"top":"left",t?Ye:$e),Ce(e,t?"height":"width",t?De:Re),Me(e,Z)}else _e(e,Z)}),ps=ms=gs=xs=ws=js=Es=Is=ys=null,As=1,ba(!0),$e!=Ve||Ye!=Qe||Re!=Ze||De!=et){yn(!1);let e=Re/Ze,t=De/et;if(H&&!jt&&B.left>=0){B.left*=e,B.top*=t,kn&&Le(kn,ot(B.left),0,Re,De),vn&&Le(vn,0,ot(B.top),Re,De);for(let s=0;s=0&&sa.width>0){sa.left*=e,sa.width*=e,sa.top*=t,sa.height*=t;for(let e in Sa)Ce(na,e,sa[e])}Ve=$e,Qe=Ye,Ze=Re,et=De}Ra("setSize"),Mt=!1}Pe>0&&Ie>0&&(d.clearRect(0,0,u.width,u.height),Ra("drawClear"),C.forEach(e=>e()),Ra("draw")),sa.show&&Et&&(aa(sa),Et=!1),H&&jt&&(xa(null,!0,!1),jt=!1),$.show&&$.live&&Ft&&(ga(),Ft=!1),r||(r=!0,n.status=1,Ra("ready")),Fs=!1,Pn=!1}function Fn(e,s){let a=v[e];if(null==a.from){if(0==us){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(us>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==_&&2==a.distr&&us>0&&(s.min=Oe(s.min,t[0]),s.max=Oe(s.max,t[0]),s.min==s.max&&s.max++),I[e]=s,_t=!0,Rn()}}n.batch=function(e,t=!1){Pn=!0,En=t,e(n),Dn(),t&&In.length>0&&queueMicrotask(An)},n.redraw=(e,t)=>{Tt=t||!1,!1!==e?oa(_,N.min,N.max):Rn()},n.setScale=Fn;let On=!1;const Zn=B.drag;let ea=Zn.x,ta=Zn.y;H&&(B.x&&(xn=je("u-cursor-x",p)),B.y&&(bn=je("u-cursor-y",p)),0==N.ori?(kn=xn,vn=bn):(kn=bn,vn=xn),Nn=B.left,Ln=B.top);const sa=n.select=Ut({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),na=sa.show?je("u-select",sa.over?p:f):null;function aa(e,t){if(sa.show){for(let t in e)sa[t]=e[t],t in Sa&&Ce(na,t,e[t]);!1!==t&&Ra("setSelect")}}function oa(e,t,s){Fn(e,{min:t,max:s})}function ia(e,t,s,o){null!=t.focus&&function(e){if(e!=ca){let t=null==e,s=1!=Vt.alpha;x.forEach((n,o)=>{if(1==a||o>0){let a=t||0==o||o==e;n._focus=t?null:a,s&&function(e,t){x[e].alpha=t,H&&null!=Qt[e]&&(Qt[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(o,a?1:Vt.alpha)}}),ca=e,s&&Rn()}}(e),null!=t.show&&x.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(x[e].show)W&&Me(V[e],Z);else if(W&&_e(V[e],Z),H){let t=Kt?Qt[0]:Qt[e];null!=t&&Le(t,-10,-10,Re,De)}}(n),2==a?(oa(s.facets[0].scale,null,null),oa(s.facets[1].scale,null,null)):oa(s.scale,null,null),Rn())}),!1!==s&&Ra("setSeries",e,t),o&&$a("setSeries",n,e,t)}let la,ra,ca;n.setSelect=aa,n.setSeries=ia,n.addBand=function(e,t){e.fill=xt(e.fill||null),e.dir=Ke(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){Ut(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const ua={focus:!0};function da(e,t,s){let n=v[t];s&&(e=e/ve-(1==n.ori?Ye:$e));let a=Re;1==n.ori&&(a=De,e=a-e),-1==n.dir&&(e=a-e);let o=n._min,i=o+(n._max-o)*(e/a),l=n.distr;return 3==l?ct(10,i):4==l?((e,t=1)=>tt.sinh(e)*t)(i,n.asinh):100==l?n.bwd(i):i}function ha(e,t){Ce(na,oe,sa.left=e),Ce(na,te,sa.width=t)}function fa(e,t){Ce(na,ne,sa.top=e),Ce(na,se,sa.height=t)}W&&Xt&&Se(fe,q,e=>{B._lock||(Jt(e),null!=ca&&ia(null,ua,!0,Fa.setSeries))}),n.valToIdx=e=>Oe(e,t[0]),n.posToIdx=function(e,s){return Oe(da(e,_,s),t[0],ds,hs)},n.posToVal=da,n.valToPos=(e,t,s)=>0==v[t].ori?o(e,v[t],s?ht:Re,s?at:0):i(e,v[t],s?wt:De,s?ut:0),n.setCursor=(e,t,s)=>{Nn=e.left,Ln=e.top,xa(null,t,s)};let pa=0==N.ori?ha:fa,ma=1==N.ori?ha:fa;function ga(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{O[t]=e}):void 0!==e.idx&&O.fill(e.idx),$.idx=O[0]),W&&$.live){for(let e=0;e0||1==a&&!K)&&ya(e,O[e]);!function(){if(W&&$.live)for(let e=2==a?1:0;ehs;la=pt,ra=null;let r=0==N.ori?Re:De,c=1==N.ori?Re:De;if(Nn<0||0==us||l){i=B.idx=null;for(let e=0;e0&&e.show){let s=null==b?-10:b==i?o:P(1==a?t[0][b]:t[g][0][b],N,r,0),y=null==k?-10:E(k,1==a?v[e.scale]:v[e.facets[1].scale],c,0);if(Xt&&null!=k){let t=1==N.ori?Nn:Ln,s=nt(Vt.dist(n,g,b,y,t));if(s=0?1:-1;o==(k>=0?1:-1)&&(1==o?1==n?k>=a:k<=a:1==n?k<=a:k>=a)&&(la=s,ra=g)}else la=s,ra=g}}if(Ft||Kt){let e,t;0==N.ori?(e=s,t=y):(e=y,t=s);let a,o,i,r,c,x,w=!0,b=Yt.bbox;if(null!=b){w=!1;let e=b(n,g);i=e.left,r=e.top,a=e.width,o=e.height}else i=e,r=t,a=o=Yt.size(n,g);if(x=Yt.fill(n,g),c=Yt.stroke(n,g),Kt)g==ra&&la<=Vt.prox&&(l=i,u=r,d=a,h=o,f=w,p=x,m=c);else{let e=Qt[g];null!=e&&(Zt[g]=i,es[g]=r,Ae(e,a,o,w),Ee(e,x,c),Le(e,it(i),it(r),Re,De))}}}}if(Kt){let e=Vt.prox;if(Ft||(null==ca?la<=e:la>e||ra!=ca)){let e=Qt[0];null!=e&&(Zt[0]=l,es[0]=u,Ae(e,d,h,f),Ee(e,p,m),Le(e,it(l),it(u),Re,De))}}}if(sa.show&&On)if(null!=e){let[t,s]=Fa.scales,[n,a]=Fa.match,[o,i]=e.cursor.sync.scales,l=e.cursor.drag;if(ea=l._x,ta=l._y,ea||ta){let l,u,d,h,f,{left:p,top:m,width:g,height:y}=e.select,x=e.scales[o].ori,w=e.posToVal,b=null!=t&&n(t,o),k=null!=s&&a(s,i);b&&ea?(0==x?(l=p,u=g):(l=m,u=y),d=v[t],h=P(w(l,o),d,r,0),f=P(w(l+u,o),d,r,0),pa(lt(h,f),nt(f-h))):pa(0,r),k&&ta?(1==x?(l=p,u=g):(l=m,u=y),d=v[s],h=E(w(l,i),d,c,0),f=E(w(l+u,i),d,c,0),ma(lt(h,f),nt(f-h))):ma(0,c)}else _a()}else{let e=nt(Tn-Sn),t=nt(jn-_n);if(1==N.ori){let s=e;e=t,t=s}ea=Zn.x&&e>=Zn.dist,ta=Zn.y&&t>=Zn.dist;let s,n,a=Zn.uni;null!=a?ea&&ta&&(ea=e>=a,ta=t>=a,ea||ta||(t>e?ta=!0:ea=!0)):Zn.x&&Zn.y&&(ea||ta)&&(ea=ta=!0),ea&&(0==N.ori?(s=Mn,n=Nn):(s=Cn,n=Ln),pa(lt(s,n),nt(n-s)),ta||ma(0,c)),ta&&(1==N.ori?(s=Mn,n=Nn):(s=Cn,n=Ln),ma(lt(s,n),nt(n-s)),ea||pa(0,r)),ea||ta||(pa(0,0),ma(0,0))}if(Zn._x=ea,Zn._y=ta,null==e){if(o){if(null!=za){let[e,t]=Fa.scales;Fa.values[0]=null!=e?da(0==N.ori?Nn:Ln,e):null,Fa.values[1]=null!=t?da(1==N.ori?Nn:Ln,t):null}$a(ce,n,Nn,Ln,Re,De,i)}if(Xt){let e=o&&Fa.setSeries,t=Vt.prox;null==ca?la<=t&&ia(ra,ua,!0,e):la>t?ia(null,ua,!0,e):ra!=ca&&ia(ra,ua,!0,e)}}Ft&&($.idx=i,ga()),!1!==s&&Ra("setCursor")}n.setLegend=ga;let wa=null;function ba(e=!1){e?wa=null:(wa=p.getBoundingClientRect(),Ra("syncRect",wa))}function ka(e,t,s,n,a,o,i){B._lock||On&&null!=e&&0==e.movementX&&0==e.movementY||(va(e,t,s,n,a,o,0,!1,null!=e),null!=e?xa(null,!0,!0):xa(t,!0,!1))}function va(e,t,s,a,o,i,r,c,u){if(null==wa&&ba(!1),Jt(e),null!=e)s=e.clientX-wa.left,a=e.clientY-wa.top;else{if(s<0||a<0)return Nn=-10,void(Ln=-10);let[e,n]=Fa.scales,r=t.cursor.sync,[c,u]=r.values,[d,h]=r.scales,[f,p]=Fa.match,m=t.axes[0].side%2==1,g=0==N.ori?Re:De,y=1==N.ori?Re:De,x=m?i:o,w=m?o:i,b=m?a:s,k=m?s:a;if(s=null!=d?f(e,d)?l(c,v[e],g,0):-10:g*(b/x),a=null!=h?p(n,h)?l(u,v[n],y,0):-10:y*(k/w),1==N.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=ce||((s<=1||s>=Re-1)&&(s=Ct(s,Re)),(a<=1||a>=De-1)&&(a=Ct(a,De))),c?(Sn=s,_n=a,[Mn,Cn]=B.move(n,s,a)):(Nn=s,Ln=a)}Object.defineProperty(n,"rect",{get:()=>(null==wa&&ba(!1),wa)});const Sa={width:0,height:0,left:0,top:0};function _a(){aa(Sa,!1)}let Ma,Ca,Ta,ja;function Na(e,t,s,a,o,i,l){On=!0,ea=ta=Zn._x=Zn._y=!1,va(e,t,s,a,o,i,0,!0,!1),null!=e&&(Se(de,we,La,!1),$a(ue,n,Mn,Cn,Re,De,null));let{left:r,top:c,width:u,height:d}=sa;Ma=r,Ca=c,Ta=u,ja=d}function La(e,t,s,a,o,i,l){On=Zn._x=Zn._y=!1,va(e,t,s,a,o,i,0,!1,!0);let{left:r,top:c,width:u,height:d}=sa,h=u>0||d>0,f=Ma!=r||Ca!=c||Ta!=u||ja!=d;if(h&&f&&aa(sa),Zn.setScale&&h&&f){let e=r,t=u,s=c,n=d;if(1==N.ori&&(e=c,t=d,s=r,n=u),ea&&oa(_,da(e,_),da(e+t,_)),ta)for(let a in v){let e=v[a];a!=_&&null==e.from&&e.min!=pt&&oa(a,da(s+n,a),da(s,a))}_a()}else B.lock&&(B._lock=!B._lock,xa(t,!0,null!=e));null!=e&&(Ne(de,we),$a(de,n,Nn,Ln,Re,De,null))}function Pa(e,t,s,a,o,i,l){B._lock||(Jt(e),Os(),_a(),null!=e&&$a(pe,n,Nn,Ln,Re,De,null))}function Ea(){k.forEach(Qn),Bt(n.width,n.height,!0)}Fe(ge,be,Ea);const Ia={};Ia.mousedown=Na,Ia.mousemove=ka,Ia.mouseup=La,Ia.dblclick=Pa,Ia.setSeries=(e,t,s,a)=>{-1!=(s=(0,Fa.match[2])(n,t,s))&&ia(s,a,!0,!1)},H&&(Se(ue,p,Na),Se(ce,p,ka),Se(he,p,e=>{Jt(e),ba(!1)}),Se(fe,p,function(e,t,s,n,a,o,i){if(B._lock)return;Jt(e);let l=On;if(On){let e,t,s=!0,n=!0,a=10;0==N.ori?(e=ea,t=ta):(e=ta,t=ea),e&&t&&(s=Nn<=a||Nn>=Re-a,n=Ln<=a||Ln>=De-a),e&&s&&(Nn=Nn{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)Aa[t]=(Aa[t]||[]).concat(e.hooks[t])});const Da=(e,t,s)=>s,Fa=Ut({key:null,setSeries:!1,filters:{pub:vt,sub:vt},scales:[_,x[1]?x[1].scale:null],match:[St,St,Da],values:[null,null]},B.sync);2==Fa.match.length&&Fa.match.push(Da),B.sync=Fa;const za=Fa.key,Oa=hn(za);function $a(e,t,s,n,a,o,i){Fa.filters.pub(e,t,s,n,a,o,i)&&Oa.pub(e,t,s,n,a,o,i)}function Ba(){Ra("init",e,t),zs(t||e.data,!1),I[_]?Fn(_,I[_]):Os(),Et=sa.show&&(sa.width>0||sa.height>0),jt=Ft=!0,Bt(e.width,e.height)}return Oa.sub(n),n.pub=function(e,t,s,n,a,o,i){Fa.filters.sub(e,t,s,n,a,o,i)&&Ia[e](null,t,s,n,a,o,i)},n.destroy=function(){Oa.unsub(n),zn.delete(n),ke.clear(),ze(ge,be,Ea),c.remove(),null==q||q.remove(),Ra("destroy")},x.forEach(ns),k.forEach(function(e,t){if(e._show=e.show,e.show){let s=e.side%2,a=v[e.scale];null==a&&(e.scale=s?x[1].scale:_,a=v[e.scale]);let o=a.time;e.size=xt(e.size),e.space=xt(e.space),e.rotate=xt(e.rotate),Dt(e.incrs)&&e.incrs.forEach(e=>{!Lt.has(e)&&Lt.set(e,Pt(e))}),e.incrs=xt(e.incrs||(2==a.distr?ls:o?1==y?bs:Ss:rs)),e.splits=xt(e.splits||(o&&1==a.distr?D:3==a.distr?Gs:4==a.distr?Js:qs)),e.stroke=xt(e.stroke),e.grid.stroke=xt(e.grid.stroke),e.ticks.stroke=xt(e.ticks.stroke),e.border.stroke=xt(e.border.stroke);let i=e.values;e.values=Dt(i)&&!Dt(i[0])?xt(i):o?Dt(i)?Ts(A,Cs(i,R)):zt(i)?function(e,t){let s=ts(t);return(t,n,a,o,i)=>n.map(t=>s(e(t)))}(A,i):i||F:i||Us,e.filter=xt(e.filter||(a.distr>=3&&10==a.log?Zs:3==a.distr&&2==a.log?en:bt)),e.font=Kn(e.font),e.labelFont=Kn(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&&(as[t]=!0,e._el=je("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),Ba()):s(n,Ba):Ba(),n}Zn.assign=Ut,Zn.fmtNum=et,Zn.rangeNum=Xe,Zn.rangeLog=qe,Zn.rangeAsinh=Ge,Zn.orient=fn,Zn.pxRatio=ve,Zn.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 o=rt(1,at((a-n+1)/t));for(let i=e[n],l=n+o;l<=a;l+=o){const t=e[l];if(null!=t){if(t<=i)return!1;i=t}}return!0}(t[0])||(t=function(e){let t=e[0],s=t.length,n=Array(s);for(let o=0;ot[e]-t[s]);let a=[];for(let o=0;oe-t)],a=n[0].length,o=new Map;for(let i=0;ifn(e,o,(r,c,u,d,h,f,p,m,g,y,x)=>{[i,l]=He(u,i,l);let w=r.pxRound,{left:b,width:k}=e.bbox,v=e=>w(f(e,d,y,m)),S=e=>w(p(e,h,x,g)),_=0==d.ori?Sn:_n;const M={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},C=M.stroke,T=d.dir*(0==d.ori?1:-1);let j=S(u[1==T?i:l]),N=v(c[1==T?i:l]),L=N,P=N;a&&-1==t&&(P=b,_(C,P,j)),_(C,N,j);for(let e=1==T?i:l;e>=i&&e<=l;e+=T){let s=u[e];if(null==s)continue;let n=v(c[e]),a=S(s);1==t?_(C,n,j):_(C,L,a),_(C,n,a),j=a,L=n}let E=L;a&&1==t&&(E=b+k,_(C,E,j));let[I,A]=pn(e,o);if(null!=r.fill||0!=I){let t=M.fill=new Path2D(C),s=S(r.fillTo(e,o,r.min,r.max,I));_(t,E,s),_(t,P,s)}if(!r.spanGaps){let a=[];a.push(...xn(c,u,i,l,T,v,n));let h=r.width*ve/2,f=s||1==t?h:-h,p=s||-1==t?-h:h;a.forEach(e=>{e[0]+=f,e[1]+=p}),M.gaps=a=r.gaps(e,o,i,l,a),M.clip=yn(a,d.ori,m,g,y,x)}return 0!=A&&(M.band=2==A?[gn(e,o,i,l,C,-1),gn(e,o,i,l,C,1)]:gn(e,o,i,l,C,A)),M})},e.bars=function(e){const t=Ke((e=e||It).size,[.6,pt,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 o=xt(a),i=1-t[0],l=Ke(t[1],pt),r=Ke(t[2],1),c=Ke(e.disp,It),u=Ke(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,f)=>fn(e,t,(p,m,g,y,x,w,b,k,v,S,_)=>{let M,C,T=p.pxRound,j=s,N=n*ve,L=l*ve,P=r*ve;0==y.ori?[M,C]=o(e,t):[C,M]=o(e,t);const E=y.dir*(0==y.ori?1:-1);let I,A,R,D=0==y.ori?Mn:Cn,F=0==y.ori?u:(e,t,s,n,a,o,i)=>{u(e,t,s,a,n,i,o)},z=Ke(e.bands,At).find(e=>e.series[0]==t),O=null!=z?z.dir:0,$=p.fillTo(e,t,p.min,p.max,O),B=T(b($,x,_,v)),W=S,H=T(p.width*ve),U=!1,q=null,G=null,J=null,Y=null;null==d||0!=H&&null==h||(U=!0,q=d.values(e,t,a,f),G=new Map,new Set(q).forEach(e=>{null!=e&&G.set(e,new Path2D)}),H>0&&(J=h.values(e,t,a,f),Y=new Map,new Set(J).forEach(e=>{null!=e&&Y.set(e,new Path2D)})));let{x0:V,size:X}=c;if(null!=V&&null!=X){j=1,m=V.values(e,t,a,f),2==V.unit&&(m=m.map(t=>e.posToVal(k+t*S,y.key,!0)));let s=X.values(e,t,a,f);A=2==X.unit?s[0]*S:w(s[0],y,S,k)-w(0,y,S,k),W=Dn(m,g,w,y,S,k,W),R=W-A+N}else W=Dn(m,g,w,y,S,k,W),R=W*i+N,A=W-R;R<1&&(R=0),H>=A/2&&(H=0),R<5&&(T=wt);let K=R>0;A=T(gt(W-R-(K?H:0),P,L)),I=(0==j?A/2:j==E?0:A)-j*E*((0==j?N/2:0)+(K?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&&(g=n.values(e,t,a,f),ee=s.values(e,t,a,f))}let te=M*A,se=C*A;for(let s=1==E?a:f;s>=a&&s<=f;s+=E){let n=g[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;B=b(e,x,_,v)}let a=w(2!=y.distr||null!=c?m[s]:s,y,S,k),o=b(Ke(n,$),x,_,v),i=T(a-I),l=T(rt(o,B)),r=T(lt(o,B)),u=l-r;if(null!=n){let a=n<0?se:te,o=n<0?te:se;U?(H>0&&null!=J[s]&&D(Y.get(J[s]),i,r+at(H/2),A,rt(0,u-H),a,o),null!=q[s]&&D(G.get(q[s]),i,r+at(H/2),A,rt(0,u-H),a,o)):D(Z,i,r+at(H/2),A,rt(0,u-H),a,o),F(e,t,s,i-H/2,r,A+H,u)}}return H>0?Q.stroke=U?Y:Z:U||(Q._fill=0==p.width?p._fill:p._stroke??p._fill,Q.width=0),Q.fill=U?G:Z,Q})},e.spline=function(e){return function(e,t){const s=Ke(null==t?void 0:t.alignGaps,0);return(t,n,a,o)=>fn(t,n,(i,l,r,c,u,d,h,f,p,m,g)=>{[a,o]=He(r,a,o);let y,x,w,b=i.pxRound,k=e=>b(d(e,c,m,f)),v=e=>b(h(e,u,g,p));0==c.ori?(y=kn,w=Sn,x=Nn):(y=vn,w=_n,x=Ln);const S=c.dir*(0==c.ori?1:-1);let _=k(l[1==S?a:o]),M=_,C=[],T=[];for(let e=1==S?a:o;e>=a&&e<=o;e+=S)if(null!=r[e]){let t=k(l[e]);C.push(M=t),T.push(v(r[e]))}const j={stroke:e(C,T,y,w,x,b),fill:null,clip:null,band:null,gaps:null,flags:1},N=j.stroke;let[L,P]=pn(t,n);if(null!=i.fill||0!=L){let e=j.fill=new Path2D(N),s=v(i.fillTo(t,n,i.min,i.max,L));w(e,M,s),w(e,_,s)}if(!i.spanGaps){let e=[];e.push(...xn(l,r,a,o,S,k,s)),j.gaps=e=i.gaps(t,n,a,o,e),j.clip=yn(e,c.ori,f,p,m,g)}return 0!=P&&(j.band=2==P?[gn(t,n,a,o,N,-1),gn(t,n,a,o,N,1)]:gn(t,n,a,o,N,P)),j})}(Fn,e)}}const ea=new Map;function ta(e){var t;if(!e.startsWith("var("))return e;const s=ea.get(e);if(s)return s;const n=e.match(/var\(([^,)]+)(?:,\s*([^)]+))?\)/);if(!n)return e;const a=n[1].trim(),o=(null==(t=n[2])?void 0:t.trim())||"#888888",i=getComputedStyle(document.documentElement).getPropertyValue(a).trim()||o;return ea.set(e,i),i}const sa=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:o=null,cursorColor:i="rgba(255,255,255,0.5)"}){const l=s.useRef(null),r=s.useRef(null),c=s.useRef(t),u=s.useRef(o),d=s.useRef(a),h=s.useRef(e.length);s.useLayoutEffect(()=>{c.current=t,u.current=o,d.current=a});const f=s.useMemo(()=>{const t=new Array(e.length).fill(1);return[e,t]},[e]),p=s.useMemo(()=>({hooks:{draw:e=>{!function(e,t,s){if(0===t.length)return;const n=e.ctx,a=e.bbox,o=a.left,i=a.top,l=a.width,r=a.height;if(l<=0||r<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,f=e=>{const t=c[e];return o+(t-d)/h*l},p=e=>i+r*(1-e);for(let m=0;m=0;t--){const e=f(t),s=p(o[t]);if(t===u-1)n.lineTo(e,s);else{const a=f(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:o}=e.bbox,i=window.devicePixelRatio||1,l=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=l.textPrimary,t.globalAlpha=.15,t.lineWidth=1*i,t.setLineDash([4*i,4*i]);for(const c of[.2,.4,.6,.8]){const e=Math.round(n+o*(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*i}px ${l.fontFamily}`,t.fillStyle=l.textPrimary,t.textBaseline="middle",t.textAlign="left";const r=8*i;for(const c of[0,20,40,60,80,100]){const e=n+o*(1-c/100),s=Math.max(n+r,Math.min(n+o-r,e));t.fillText(`${c}%`,0,s)}t.restore()}(e)}}}),[]),m=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:[p]}),[p]);s.useEffect(()=>{const t=l.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!r.current||a>100||s>0&&a/s>.1)&&r.current)return r.current.setData(f),void(h.current=n);r.current&&r.current.destroy();const o=t.getBoundingClientRect(),i=Math.floor(o.width)||400,c=Math.floor(o.height)||200,u=new Zn({...m,width:i,height:c},f,t);return r.current=u,h.current=n,()=>{u.destroy(),r.current=null}},[m,f,e.length]),s.useEffect(()=>{const e=l.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!r.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&r.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{r.current&&r.current.redraw()},[o,t]);const g=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:l,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})}),na=s.createContext(null);function aa({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return F;try{let t=localStorage.getItem(z),s=localStorage.getItem(O);const n=localStorage.getItem($);if(!t&&!s){const e=localStorage.getItem(B);if(e){const n=D.find(t=>t.id===e);n&&(t=n.colorScheme,s=n.backgroundImage,localStorage.setItem(z,t),localStorage.setItem(O,s),localStorage.removeItem(B))}}const a="string"==typeof(e=t)&&A.some(t=>t.id===e)?t:F.colorScheme,o=s||F.backgroundImage;let i=F.brightness;if(n){const e=parseInt(n,10);!isNaN(e)&&e>=0&&e<=100&&(i=e)}return{colorScheme:a,backgroundImage:o,brightness:i}}catch{return F}var e}());s.useEffect(()=>{(function(e){const t=(s=e,A.find(e=>e.id===s)??A[0]);var s;t.dataTheme?document.documentElement.setAttribute("data-theme",t.dataTheme):document.documentElement.removeAttribute("data-theme")})(t.colorScheme),ea.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of q){const e=K(`--palette-${t}-bright`),s=K(`--palette-${t}`),n=e||s;if(!n)continue;const a=X(n);for(const o of U)Q(`--palette-${t}-${o}`,a[o])}const e=K("--palette-bg-4");if(e){const t=X(e);for(const e of U)Q(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(z,e.colorScheme),localStorage.setItem(O,e.backgroundImage),localStorage.setItem($,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{R.forEach(e=>{(new Image).src=e.src})},[]);const o=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),i=s.useCallback(e=>{const t=R.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),l=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),r=s.useCallback(e=>{const t=D.find(t=>t.id===e);t&&a(e=>({...e,colorScheme:t.colorScheme,backgroundImage:t.backgroundImage}))},[]),c=s.useMemo(()=>({theme:t,setColorScheme:o,setBackgroundImage:i,setBrightness:l,setThemePreset:r}),[t,o,i,l,r]);return n.jsx(na.Provider,{value:c,children:e})}function oa(){const e=s.useContext(na);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const ia="0.9.144",la="'JetBrains Mono', monospace",ra=s.memo(function({height:e=16,responsive:t=!1,className:s=""}){const a="var(--accent-primary)",o="#FFFFFF";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: ${la};\n }\n .logo-accent {\n fill: var(--accent-primary, #719CDF);\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",{fill:o,children:"MC"}),n.jsx("tspan",{className:"logo-accent",children:":"}),n.jsx("tspan",{fill:o,children:"Console"})]})]})}const i="string"==typeof e?parseFloat(e):e,l={fontFamily:la,fontSize:.8*i+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:l,role:"img","aria-label":"pyMC:Console",children:[n.jsx("span",{style:{color:a},children:"py"}),n.jsx("span",{style:{color:o},children:"MC"}),n.jsx("span",{style:{color:a},children:":"}),n.jsx("span",{style:{color:o},children:"Console"})]})}),ca={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"},ua={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},da={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 ha(e){return 1===e||0===e}const fa={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function pa(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 ma(e,t={}){const s=t.spreadingFactor??fa.spreadingFactor,n=t.bandwidthHz??fa.bandwidthHz,a=t.codingRate??fa.codingRate,o=t.preambleLength??fa.preambleLength??8,i=t.crcEnabled??fa.crcEnabled?1:0,l=t.explicitHeader??fa.explicitHeader?0:1,r=s>=11&&n<=125e3?1:0,c=n/1e3,u=Math.pow(2,s)/c,d=(o+4.25)*u,h=Math.max(8*e-4*s+28+16*i-20*l,0),f=4*(s-2*r);return d+(8+Math.ceil(h/f)*a)*u}const ga="pymc_jwt_token",ya="pymc_client_id",xa="pymc_remember_me",wa=new Set;function ba(e){return wa.add(e),()=>wa.delete(e)}function ka(e){for(const s of wa)try{s(e)}catch(t){}}function va(){let e=localStorage.getItem(ya);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(ya,e)),e}function Sa(){return"true"===localStorage.getItem(xa)}function _a(e){e?localStorage.setItem(xa,"true"):localStorage.removeItem(xa)}function Ma(){return Sa()?localStorage:sessionStorage}function Ca(){return Ma().getItem(ga)||localStorage.getItem(ga)||sessionStorage.getItem(ga)}function Ta(e){Ma().setItem(ga,e),Sa()?sessionStorage.removeItem(ga):localStorage.removeItem(ga),ka(e)}function ja(){localStorage.removeItem(ga),sessionStorage.removeItem(ga),ka(null)}function Na(){return!(!Ca()||Pa()&&(ja(),1))}function La(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 Pa(){const e=Ca();if(!e)return!0;const t=La(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function Ea(){const e=Ca();if(!e)return 0;const t=La(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function Ia(){const e=Ca();if(!e)return!1;const t=La(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function Aa(){const e=Ca();if(!e)return null;const t=La(e);return t&&t.sub?t.sub:null}async function Ra(e,t,s=!1){_a(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:va()})}),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?(Ta(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function Da(){const e=Ca();if(!e)return!1;const t=La(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:va()})});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){Ta(s.token);const e=La(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 Fa=null;async function za(){const e=Ca();if(!e)return!1;const t=La(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!Ia()||Fa||(Fa=Da().finally(()=>{Fa=null}),Fa)}function Oa(){ja()}let $a=!1;function Ba(){if($a)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!Ca())return;if(Pa())return ja(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=Ea();e>0&&e<300&&await Da()};document.addEventListener("visibilitychange",e),$a=!0,"visible"===document.visibilityState&&e()}const Wa=Object.freeze(Object.defineProperty({__proto__:null,clearToken:ja,getClientId:va,getRememberMe:Sa,getToken:Ca,getTokenTimeRemaining:Ea,getUsername:Aa,isAuthenticated:Na,isTokenExpired:Pa,login:Ra,logout:Oa,onTokenChange:ba,parseJWT:La,refreshToken:Da,refreshTokenIfNeeded:za,setRememberMe:_a,setToken:Ta,shouldRefreshToken:Ia,startVisibilityBasedRefresh:Ba},Symbol.toStringTag,{value:"Module"})),Ha=new Map;let Ua=!1;async function qa(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=Ha.get(n);if(e)return e}const a=`${e}`;!s&&Ia()&&await Da();const o=Ca();if(!o&&!e.includes("/auth/"))throw window.location.href="/login",new Error("Not authenticated");const i=o?{Authorization:`Bearer ${o}`}:{};if(null==t?void 0:t.headers){const e=t.headers;e instanceof Headers?e.forEach((e,t)=>{i[t]=e}):Array.isArray(e)?e.forEach(([e,t])=>{i[e]=t}):Object.assign(i,e)}(null==t?void 0:t.body)&&(i["Content-Type"]="application/json");const l=(async()=>{const n=await fetch(a,{...t,headers:i});if(401===n.status){if(!s&&!Ua&&await Da())return qa(e,t,!0);throw Ua||(Ua=!0,ja(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText}`);return n.json()})();return n&&(Ha.set(n,l),l.finally(()=>{Ha.delete(n)})),l}function Ga(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function Ja(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=Ga(t.contact_type);return e}(await qa("/api/stats"))}async function Ya(){return qa("/api/logs")}async function Va(e=24){return qa(`/api/noise_floor_history?hours=${e}`)}async function Xa(){return qa("/api/hardware_stats")}async function Ka(){return qa("/api/send_advert",{method:"POST",body:"{}"})}async function Qa(e){return qa("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function Za(e){return qa("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}const eo=new Map;function to(e=!1){if(e)eo.clear();else for(const[t]of eo)parseInt(t.split("-")[0],10)<=60&&eo.delete(t)}function so(e,t,s,n){const a=60*e/t,o=Math.floor(Date.now()/1e3),i=Math.floor(o/a)*a,l=i-60*e,r=s.filter(e=>e.timestamp>=l&&e.timestamp<=i),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)??fa.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??fa.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??fa.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??fa.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):fa,u=function(e,t,s,n,a){const o=new Array(t),i=new Array(t),l=new Array(t),r=new Array(t),c=new Array(t);for(let d=0;d=t)continue;const f=ma(pa(u),a),p=u.packet_origin;"tx_local"===p?(i[h].count++,i[h].airtime_ms+=f):"tx_forward"===p||u.transmitted?(l[h].count++,l[h].airtime_ms+=f):u.drop_reason&&(r[h].count++,r[h].airtime_ms+=f),"tx_local"!==p&&(o[h].count++,o[h].airtime_ms+=f,c[h].snr+=u.snr||0,c[h].rssi+=u.rssi||0,c[h].count++)}for(let d=0;d0&&(o[d].avg_snr=c[d].snr/c[d].count,o[d].avg_rssi=c[d].rssi/c[d].count);return{received:o,transmitted:i,forwarded:l,dropped:r}}(r,t,l,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:l,end_time:i,...u}}async function no(e){return qa("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function ao(e){return qa("/api/set_log_level",{method:"POST",body:JSON.stringify({level:e})})}async function oo(){return qa("/api/transport_keys")}async function io(e){return qa("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}async function lo(e,t){return qa(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}async function ro(e){return qa(`/api/transport_key/${e}`,{method:"DELETE"})}async function co(e){return qa("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}async function uo(e,t=10){return qa("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:t})})}async function ho(e){return qa("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}async function fo(){return qa("/api/check_pymc_console")}async function po(){return qa("/api/restart_service",{method:"POST",body:"{}"})}async function mo(){return qa("/auth/tokens")}async function go(e){return qa("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}async function yo(e){return qa(`/auth/tokens/${e}`,{method:"DELETE"})}const xo="pymc-packet-cache",wo="pymc-packet-cache-meta",bo=36e5,ko=12096e5,vo=5e3,So=5e5,_o=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}),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}}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>bo}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-ko)/1e3),n=42e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 14-day 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,o=0,i=0;const l=Math.ceil(100);for(let r=0;r0))break;{const n=this.packets.size;this.mergePackets(u.data);const i=this.packets.size-n;a+=i;const l=Math.min(...u.data.map(e=>e.timestamp??1/0));if(l!==1/0&&(void 0===t||l=2)break}else o=0;if(u.data.length=So)break}r=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,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 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-ko)/1e3),s=42e4;this.statusMessage="Loading 14-day topology...",this.loadProgress={loaded:0,target:s,percent:0},this.notifyListeners();try{let e,n=0,a=0,o=0;const i=Math.ceil(100);for(let l=0;l0))break;{const s=this.packets.size;this.mergePackets(c.data);const o=this.packets.size-s;n+=o;const i=Math.min(...c.data.map(e=>e.timestamp??1/0));if(i!==1/0&&(void 0===e||i=2)break}else a=0;if(c.data.length=So)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.enforceMemoryCap(),this.meta.topologyLoadComplete=!0,this.saveToStorage()}catch(n){this.statusMessage="Topology 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},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&&!this.packets.has(e)){this.packets.set(e,s),t=!0;const n=s.timestamp??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 i=0;i<3;i++)try{return await this.fetchFilteredPackets(e,t,!1,a)}catch(o){const e=2===i,t=1e3*Math.pow(2,i);o instanceof Error&&o.name,e||(this.statusMessage=`Retry in ${Math.round(t/1e3)}s...`,this.notifyListeners(),await this.delay(t))}return null}enforceMemoryCap(){if(this.packets.size<=So)return;const e=this.getPackets(),t=e.length-So;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(wo);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(xo);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>bo)return void this.clear();this.meta.backgroundLoadComplete=!1;const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(xo,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(xo),localStorage.setItem(wo,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(xo),localStorage.removeItem(wo)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await E(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Wa);return{getToken:e}},void 0),a=n(),o={};a&&(o.Authorization=`Bearer ${a}`);const i=await fetch(s,{headers:o});if(401===i.status&&!t){const{refreshToken:t}=await E(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Wa);return{refreshToken:e}},void 0);if(await t())return this.fetchRecentPackets(e,!0)}if(!i.ok)throw new Error(`API error: ${i.status}`);return i.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 o=`/api/filtered_packets?${a}`,{getToken:i}=await E(async()=>{const{getToken:e}=await Promise.resolve().then(()=>Wa);return{getToken:e}},void 0),l=i(),r={};l&&(r.Authorization=`Bearer ${l}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(o,{headers:r,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await E(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>Wa);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 Mo(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Co(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const To=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:Co(),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}}),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-BHEhB0-W.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?Mo(t.pathRegistry):Co(),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}};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,o,i,l){const r={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:o,zeroHopNeighbors:i,terrainGrid:l,enableTerrainAware:void 0!==l};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=r:this.computeInternal(r)},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()}},jo=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()}},No=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=ba(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"})}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}},Lo=.05,Po=1e3,Eo="terrarium";function Io(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const Ao=a((e,t)=>({terrainGrid:null,isLoading:!1,error:null,lastLoadedAt:null,cachedBounds:null,terrainDisambiguationEnabled:!0,loadTerrain:async(s,n)=>{const a=t();if(!(a.isLoading||(o=a.cachedBounds,i=s,o&&o.minLat<=i.minLat&&o.maxLat>=i.maxLat&&o.minLng<=i.minLng&&o.maxLng>=i.maxLng))){var o,i;e({isLoading:!0,error:null});try{n.getTerrain()||(n.getSource(Eo)||(n.addSource(Eo,{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===Eo&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:Eo}),await new Promise(e=>setTimeout(e,500)));const t=await async function(e,t){const{minLat:s,maxLat:n,minLng:a,maxLng:o}=t;let i=Math.ceil((o-a)/.001),l=Math.ceil((n-s)/.001);i>Po&&(i=Po),l>Po&&(l=Po);const r=(o-a)/i,c=(n-s)/l,u=Math.max(r,c),d=new Float32Array(i*l);let h=0;for(let f=0;fsetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:i,height:l,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(l){const t=l instanceof Error?l.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,o=-1/0;for(const i of t)s=Math.min(s,i.latitude),n=Math.max(n,i.latitude),a=Math.min(a,i.longitude),o=Math.max(o,i.longitude);return{minLat:s-Lo,maxLat:n+Lo,minLng:a-Lo,maxLng:o+Lo}}(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}}));function Ro(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function Do(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?Ro(t):null,o=n[n.length-1],i=null!==a&&o===a,l=i?n.slice(0,-1):[...n];return{effective:l,original:n,hadLocal:i,effectiveLength:l.length}}function Fo(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const zo=[{label:"20m",minutes:20,buckets:40},{label:"1h",minutes:60,buckets:60},{label:"3h",minutes:180,buckets:90},{label:"12h",minutes:720,buckets:72},{label:"24h",minutes:1440,buckets:96},{label:"3d",minutes:4320,buckets:72},{label:"7d",minutes:10080,buckets:84}],Oo=[{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 $o(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 Bo={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},Wo={DEBUG:"text-[var(--log-debug)]",INFO:"text-[var(--log-info)]",WARNING:"text-[var(--log-warning)]",ERROR:"text-[var(--log-error)]",CRITICAL:"text-[var(--log-critical)]"};function Ho(e){return Wo[e]??"text-text-muted border-border-subtle"}const Uo="pymc-resource-history",qo="pymc-resource-last-fetch",Go="pymc-hidden-contacts",Jo="pymc-quick-neighbors",Yo="pymc-local-hash";let Vo=null,Xo=null;function Ko(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function Qo(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:ha(s)?t.length<=1:0===t.length;var n}(e)}function Zo(e,t,s,n,a){if(!e)return null;let o=e;if(e.length<=4){const n=e.replace(/^0x/i,"").toUpperCase();if(n===t)return null;const a=s.get(n);if(!a)return null;o=a}return n.has(o)?o===a?null:o:null}function ei(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 ti(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function si(e,t){const s=Ko(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:Ro(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 ni(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Jo);if(e)return JSON.parse(e)}catch{}return[]}function ai(e){"undefined"!=typeof window&&(Xo&&clearTimeout(Xo),Xo=setTimeout(()=>{try{localStorage.setItem(Jo,JSON.stringify(e))}catch{}Xo=null},1e3))}function oi(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Yo);if(e)return e}catch{}}function ii(e){if("undefined"!=typeof window)try{localStorage.setItem(Yo,e)}catch{}}function li(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Uo);if(e)return JSON.parse(e)}catch{}return[]}function ri(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(Go);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function ci(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(qo);if(e)return parseInt(e,10)||0}catch{}return 0}const ui=a((e,t)=>({stats:null,statsLoading:!1,statsError:null,packets:[],packetsLoading:!1,packetsError:null,lastPacketTimestamp:0,logs:[],logsLoading:!1,liveMode:!0,flashReceived:0,flashAdvert:0,resourceHistory:li(),lastResourceFetch:ci(),hiddenContacts:ri(),quickNeighbors:ni(),cachedLocalHash:oi(),initialized:!1,packetCacheState:_o.getState(),mutationsInFlight:new Set,initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),_o.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await Ja(),a=n.neighbors??{},o=Date.now(),i=[];for(const[e,t]of Object.entries(a)){if(s.has(e))continue;if(!t.zero_hop)continue;const n=Ko(t.last_seen??0,o);"expired"!==n&&i.push({hash:e,prefix:Ro(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:n})}i.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const l=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:i,cachedLocalHash:l}),ai(i),l&&ii(l);const r=()=>{const s=_o.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 _o.initialLoad(r);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})}try{await No.init({apiBaseUrl:"",authToken:Ca()??void 0,statsIntervalMs:Bo.stats,packetsIntervalMs:Bo.packets}),No.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:o}=t();if(a.size>0)return;const i=s.neighbors??{},l=Date.now(),r=[];for(const[e,t]of Object.entries(i)){if(o.has(e))continue;if(!t.zero_hop)continue;const s=Ko(t.last_seen??0,l);"expired"!==s&&r.push({hash:e,prefix:Ro(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}r.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,quickNeighbors:r,cachedLocalHash:c}),ai(r),c&&ii(c)}),No.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:o}=t();for(const e of s)if(e.packet_hash){_o.mergePacketsDirectly(s);break}const i=a>o;i&&(e({flashReceived:t().flashReceived+1}),to());const l=_o.getPackets();e({packets:l,packetsLoading:!1,lastPacketTimestamp:a}),i&&t().triggerTopologyCompute()}),No.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||No.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},Bo.stats),setInterval(()=>{e().liveMode&&!_o.isHeavyLoadInProgress()&&e().fetchPackets()},Bo.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":Ya().catch(()=>{});break;case"/system":Xa().catch(()=>{});break;case"/statistics":(async function(e=24){return qa(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),Va(3).catch(()=>{});break;case"/settings":(async function(){return qa("/api/radio_presets")})().catch(()=>{})}},fetchStats:async s=>{const{stats:n,mutationsInFlight:a,hiddenContacts:o}=t();if(!(a.size>0)||(null==s?void 0:s.force)){n||e({statsLoading:!0}),e({statsError:null});try{const t=await Ja(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,l]of Object.entries(s)){if(o.has(e))continue;if(!l.zero_hop)continue;const t=Ko(l.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:Ro(e),count:l.advert_count??0,avgRssi:l.rssi??null,avgSnr:l.snr??null,lastSeen:l.last_seen??0,status:t})}a.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const i=t.local_hash;e({stats:t,statsLoading:!1,quickNeighbors:a,cachedLocalHash:i}),ai(a),i&&ii(i)}catch(i){e({statsError:i instanceof Error?i.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 _o.poll(),o=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,i=o>a&&a>0,l=s.length!==n.length||i;i&&(e({flashReceived:t().flashReceived+1}),to()),e(l?{packets:s,packetsLoading:!1,lastPacketTimestamp:o||a}:{packetsLoading:!1}),i&&t().triggerTopologyCompute()}catch(o){e({packetsError:o instanceof Error?o.message:"Failed to fetch packets",packetsLoading:!1})}},fetchLogs:async()=>{const{logs:s}=t();0===s.length&&e({logsLoading:!0});try{const t=await Ya();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),No.isReady()&&No.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Qa(s)).success)throw new Error("Backend returned unsuccessful response");await t().fetchStats({force:!0})}catch(i){const{mutationsInFlight:s}=t(),a=new Set(s);throw a.delete(n),e({mutationsInFlight:a}),i}},clearModeMutation:()=>{const{mutationsInFlight:s}=t(),n=new Set(s);n.delete("setMode"),e({mutationsInFlight:n})},setDutyCycle:async s=>{const n="setDutyCycle",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Za(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:o}=t(),i=new Set(o);i.add(a),e({mutationsInFlight:i});try{const e=await async function(e){return qa("/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(l){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),l}},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 Ka();return s.success&&e({flashAdvert:t().flashAdvert+1}),s.success}catch(s){return!1}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const o=Date.now(),{lastResourceFetch:i,resourceHistory:l}=t();if(o-i<1e3)return;const r=[...l,{timestamp:o,time:new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=r.length>a?r.slice(-a):r;var u,d;e({resourceHistory:c,lastResourceFetch:o}),u=c,d=o,"undefined"!=typeof window&&(Vo&&clearTimeout(Vo),Vo=setTimeout(()=>{try{localStorage.setItem(Uo,JSON.stringify(u)),localStorage.setItem(qo,d.toString())}catch{}Vo=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(Go,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{_o.clear(),e({packets:[],lastPacketTimestamp:0}),_o.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:o,stats:i,hiddenContacts:l}=t();if(0===o.length||!i)return;const r=i.neighbors??{},c=Object.fromEntries(Object.entries(r).filter(([e])=>!l.has(e))),u=i.local_hash,d=null==(s=null==(e=i.config)?void 0:e.repeater)?void 0:s.latitude,h=null==(a=null==(n=i.config)?void 0:n.repeater)?void 0:a.longitude,f=[];for(const[t,m]of Object.entries(c))m.zero_hop&&f.push({hash:t,advertCount:m.advert_count??1,avgRssi:m.rssi??null,avgSnr:m.snr??null,lastSeen:m.last_seen??0,latitude:m.latitude,longitude:m.longitude});const p=Ao.getState().getTerrainGridForDisambiguation();To.compute(o,c,u,d,h,void 0,f,p??void 0)},triggerDeepAnalysis:async()=>{await _o.forceDeepLoad();const s=_o.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 o=n.neighbors??{},i=function(e,t,s){if(!s||0===e.length||0===Object.keys(t).length)return[];const n=Date.now(),a=Ro(s),o=new Set(Object.keys(t)),i=function(e){var t,s;const n=new Map;for(const a of Object.keys(e)){const o=Ro(a),i=n.get(o);if(i){const l=null==(t=e[i])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!l&&n.set(o,a)}else n.set(o,a)}return n}(t),l=new Map;for(const c of e){if(!Qo(c))continue;const e=Zo(c.src_hash,a,i,o,s);if(!e)continue;let t=l.get(e);t||(t=ti(e),l.set(e,t)),ei(t,c)}for(const[c,u]of Object.entries(t))u.zero_hop&&!l.has(c)&&l.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 r=[];for(const c of l.values()){const e=si(c,n);e&&r.push(e)}return r.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),r}(s,Object.fromEntries(Object.entries(o).filter(([e])=>!a.has(e))),n.local_hash),l=t().quickNeighbors;(i.length!==l.length||i.some((e,t)=>{var s,n;return e.hash!==(null==(s=l[t])?void 0:s.hash)||e.count!==(null==(n=l[t])?void 0:n.count)}))&&(e({quickNeighbors:i}),ai(i))},triggerSparklineCompute:()=>{const{packets:e,stats:s,hiddenContacts:n}=t();if(0===e.length||!s)return;const a=s.neighbors??{},o=Object.keys(a).filter(e=>!n.has(e));0!==o.length&&jo.compute(e,o)}})),di=ui,hi=()=>ui(e=>e.stats),fi=()=>ui(e=>e.statsError),pi=()=>ui(e=>e.packets),mi=()=>ui(e=>e.packetsLoading),gi=()=>ui(e=>e.logs),yi=()=>ui(e=>e.logsLoading),xi=()=>ui(e=>e.liveMode),wi=()=>ui(e=>e.flashAdvert),bi=()=>ui(e=>e.fetchLogs),ki=()=>ui(e=>e.setLiveMode),vi=()=>ui(e=>e.resourceHistory),Si=()=>ui(e=>e.addResourceDataPoint),_i=()=>ui(e=>e.hiddenContacts),Mi=()=>ui(e=>e.hideContact),Ci=()=>ui(e=>e.packetCacheState),Ti=()=>ui(e=>e.triggerDeepAnalysis),ji=()=>ui(e=>e.quickNeighbors),Ni=()=>ui(e=>e.cachedLocalHash),Li=()=>ui(e=>e.lastPacketTimestamp),Pi=()=>ui(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete);function Ei({showLabel:e=!1,className:t}){const a=ui(e=>e.flashReceived),o=wi(),[i,l]=s.useState("idle");return s.useEffect(()=>{if(a<=0)return;const e=requestAnimationFrame(()=>l("received")),t=setTimeout(()=>l("idle"),300);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[a]),s.useEffect(()=>{if(o<=0)return;const e=requestAnimationFrame(()=>l("transmitted")),t=setTimeout(()=>l("idle"),300);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[o]),n.jsxs("span",{className:I("inline-flex items-center gap-2",t),children:[n.jsx("span",{className:I("inline-flex rounded-full h-2 w-2 transition-all duration-150","received"===i&&"bg-accent-danger scale-150","transmitted"===i&&"bg-white scale-150","idle"===i&&"bg-accent-success")}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Live"})]})}const Ii=a(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(()=>{jo.subscribe((e,t)=>{const s=Ii.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const Ai=()=>Ii(e=>e.isComputing),Ri=[],Di=new Map;function Fi(e){return Ii(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return Ri;const n=Di.get(e);return n===s?n:(Di.set(e,s),s)})}const zi=a(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:Co(),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}},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&&To.subscribe((e,t)=>{zi.getState().setTopology(e,t)});const Oi=()=>zi(e=>e.topology),$i=()=>zi(e=>e.topology.hubNodes),Bi=()=>zi(e=>e.topology.centrality),Wi=()=>zi(e=>e.topology.fullAffinity);let Hi=null,Ui=null,qi=null,Gi=null;const Ji=()=>zi(e=>(e.topology.hubNodes!==Ui&&(Ui=e.topology.hubNodes,Hi=new Set(e.topology.hubNodes)),Hi)),Yi=()=>zi(e=>e.topology.pathHealth),Vi=()=>zi(e=>e.topology.disambiguationStats),Xi=()=>zi(e=>e.topology.disambiguationStats.highCollisionPrefixes),Ki=()=>zi(e=>e.topology.disambiguationStats.totalPrefixes>0),Qi=()=>zi(e=>e.topology.discoveredNodes),Zi=()=>zi(e=>e.topology.viterbiStats),el=()=>zi(e=>(e.topology.discoveredNodes!==Gi&&(Gi=e.topology.discoveredNodes,qi=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),qi));function tl(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 sl(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 nl(e){const t=Date.now()/1e3-e;return t<60?`${Math.floor(t)}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function al(e){return new Date(1e3*e).toLocaleString()}function ol(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 il(e){return`${(e/1e6).toFixed(3)} MHz`}function ll(e){return`${(e/1e3).toFixed(1)} kHz`}function rl(e){const t=e>1e12?e:1e3*e,s=Date.now(),n=Math.abs(s-t),a=Math.floor(n/1e3),o=Math.floor(a/60),i=Math.floor(o/60),l=Math.floor(i/24);return l>0?`${l} day${1!==l?"s":""}`:i>0?`${i} hour${1!==i?"s":""}`:o>0?`${o} minute${1!==o?"s":""}`:`${a} second${1!==a?"s":""}`}const cl=[{name:"Dashboard",to:"/",icon:r},{name:"Contacts",to:"/contacts",icon:c},{name:"Packets",to:"/packets",icon:u},{name:"Statistics",to:"/statistics",icon:d},{name:"System",to:"/system",icon:h},{name:"Logs",to:"/logs",icon:f},{name:"Terminal",to:"/terminal",icon:p},{name:"Configuration",to:"/configuration",icon:m}],ul="pymc-controls-expanded";function dl(){var e,t,a,r;const{pathname:c}=o(),{stats:u,setMode:d,setDutyCycle:f,sendAdvert:p}=di(),m=Aa(),C=ui(e=>e.prefetchForRoute),T=Ci(),j=Ai(),N=zi(e=>e.isComputing),L=el(),[P,E]=s.useState(!1),[A,R]=s.useState(!0),[D,F]=s.useState(!1),z=s.useRef(null),O=s.useCallback(e=>{e!==c&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{C(e)},100))},[c,C]),$=s.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null)},[]);s.useEffect(()=>{const e=localStorage.getItem(ul);null!==e&&queueMicrotask(()=>R("true"===e))},[]);const B=()=>{const e=!A;R(e),localStorage.setItem(ul,String(e))};s.useEffect(()=>{queueMicrotask(()=>E(!1))},[c]),s.useEffect(()=>(document.body.style.overflow=P?"hidden":"",()=>{document.body.style.overflow=""}),[P]);const W=null==u?void 0:u.noise_floor_dbm,H=(null==(t=null==(e=null==u?void 0:u.config)?void 0:e.repeater)?void 0:t.mode)??"forward",U=(null==(r=null==(a=null==u?void 0:u.config)?void 0:a.duty_cycle)?void 0:r.enforcement_enabled)??!1,q=async()=>{F(!0),await p(),setTimeout(()=>F(!1),1e3)},G=()=>{d("forward"===H?"monitor":"forward")},J=()=>{f(!U)},Y=()=>{Oa(),window.location.href="/login"},V=T.isLoading||T.isTopologyLoading,X=V||j||N,K=T.loadProgress,Q=()=>{if(!X)return null;let e="Analyzing database";V&&K?e=`Loading ${K.loaded.toLocaleString()} packets`:j?e="Computing sparklines":N&&(e="Building topology");const t=(null==K?void 0:K.percent)??null,s=null!==t&&V;return n.jsxs("div",{className:"px-3 pb-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.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",children:e}),s&&n.jsxs("span",{className:"type-data-xs text-text-muted ml-auto",children:[t,"%"]})]}),n.jsx("div",{className:"mx-2 h-0.5 bg-white/5 rounded-full overflow-hidden",children:s?n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full transition-all duration-300 ease-out",style:{width:`${t}%`}}):n.jsx("div",{className:"h-full bg-accent-primary/60 rounded-full animate-pulse",style:{width:"100%",animation:"shimmer 1.5s ease-in-out infinite"}})})]})},Z=()=>n.jsx("nav",{className:"flex-1 px-3 py-4 space-y-1 overflow-y-auto",children:cl.map(e=>{const t=c===e.to;return n.jsxs(g,{to:e.to,onClick:()=>E(!1),onMouseEnter:()=>O(e.to),onMouseLeave:$,className:I("flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-150 min-h-[44px]",t?"bg-accent-primary/15 text-accent-primary":"text-text-muted hover:text-text-primary hover:bg-white/5"),children:[n.jsx(e.icon,{className:I("w-5 h-5 flex-shrink-0",t&&"text-accent-primary")}),n.jsx("span",{className:"type-body-sm font-medium",children:e.name}),"/contacts"===e.to&&L.length>0&&n.jsxs("span",{className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-accent-tertiary/20 text-accent-tertiary",children:[n.jsx(y,{className:"w-3 h-3"}),n.jsx("span",{className:"type-data-xs font-medium",children:L.length})]})]},e.name)})}),ee=()=>n.jsxs("div",{className:"px-3 py-3",children:[n.jsxs("button",{onClick:B,className:"w-full flex items-center justify-between px-2 py-1.5 mb-2 rounded-lg hover:bg-white/5 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(x,{className:"w-4 h-4 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Controls"})]}),n.jsx(w,{className:I("w-4 h-4 text-text-muted transition-transform duration-200",A?"rotate-0":"-rotate-90")})]}),n.jsx("div",{className:I("overflow-hidden transition-all duration-300 ease-out",A?"max-h-96 opacity-100":"max-h-0 opacity-0"),children:n.jsxs("div",{className:"control-panel-skeuo",children:[n.jsxs("button",{onClick:q,disabled:D,className:I("control-btn control-btn-primary w-full",D&&"opacity-70"),children:[n.jsx(b,{className:I("w-4 h-4",D&&"animate-pulse")}),n.jsx("span",{children:D?"Sending...":"Send Advert"})]}),n.jsxs("div",{className:"control-toggle-group",children:[n.jsxs("div",{className:"control-toggle-label",children:[n.jsx("span",{children:"Mode"}),n.jsx("span",{className:I("control-toggle-status","forward"===H?"text-accent-success":"text-accent-secondary"),children:"forward"===H?"FWD":"MON"})]}),n.jsx("button",{onClick:G,className:I("control-btn w-full","forward"===H?"control-btn-success":"control-btn-warning"),children:"forward"===H?n.jsxs(n.Fragment,{children:[n.jsx(k,{className:"w-4 h-4"}),n.jsx("span",{children:"Forward"})]}):n.jsxs(n.Fragment,{children:[n.jsx(v,{className:"w-4 h-4"}),n.jsx("span",{children:"Monitor"})]})})]}),n.jsxs("div",{className:"control-toggle-group",children:[n.jsxs("div",{className:"control-toggle-label",children:[n.jsx("span",{children:"Duty Cycle"}),n.jsx("span",{className:I("control-toggle-status",U?"text-accent-success":"text-text-muted"),children:U?"ON":"OFF"})]}),n.jsxs("button",{onClick:J,className:I("control-btn w-full",U?"control-btn-success":"control-btn-neutral"),children:[n.jsx(h,{className:"w-4 h-4"}),n.jsx("span",{children:U?"Enabled":"Disabled"})]})]})]})})]}),te=()=>n.jsxs("div",{className:"mt-auto border-t border-white/5",children:[void 0!==(null==u?void 0:u.uptime_seconds)&&n.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[n.jsx(S,{className:"w-3.5 h-3.5 text-text-muted"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[tl(u.uptime_seconds)," uptime"]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsx("div",{className:"bg-white/[0.03] 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(_,{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!=W?`${W.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-4 py-3 flex items-center justify-between border-t border-white/5",children:[n.jsx(Ei,{showLabel:!0}),(null==u?void 0:u.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted",children:["v",u.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:Y,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(M,{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,")"]})]})})]});return n.jsxs(n.Fragment,{children:[n.jsx("header",{className:"lg:hidden fixed top-0 inset-x-0 z-[10001] h-14 bg-bg-body/70 backdrop-blur-xl border-b border-white/10",children:n.jsxs("div",{className:"flex items-center justify-between h-full px-4",children:[n.jsxs("div",{className:"flex items-center",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{height:26,className:"block"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",ia]}),n.jsx(Ei,{}),n.jsx("button",{onClick:()=>E(!P),className:"w-10 h-10 flex items-center justify-center rounded-xl hover:bg-white/5 active:bg-white/10 transition-colors","aria-label":P?"Close menu":"Open menu",children:P?n.jsx(i,{className:"w-5 h-5 text-text-primary"}):n.jsx(l,{className:"w-5 h-5 text-text-primary"})})]})]})}),n.jsx("div",{className:I("lg:hidden fixed inset-0 z-[10002] bg-black/60 backdrop-blur-sm transition-opacity duration-300",P?"opacity-100":"opacity-0 pointer-events-none"),onClick:()=>E(!1),"aria-hidden":"true"}),n.jsxs("aside",{className:I("lg:hidden fixed top-0 left-0 z-[10003] w-72 max-w-[85vw] h-full","glass-sidebar","flex flex-col","transform transition-transform duration-300 ease-out",P?"translate-x-0":"-translate-x-full pointer-events-none"),children:[n.jsxs("div",{className:"px-4 py-5 border-b border-white/5",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",ia]})]}),Z(),Q(),ee(),te()]}),n.jsxs("aside",{className:"hidden lg:flex flex-col w-64 flex-shrink-0 h-full relative glass-sidebar",children:[n.jsxs("div",{className:"px-5 py-6 border-b border-white/5",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(ra,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",ia]})]}),Z(),Q(),ee(),te()]})]})}const hl=s.memo(function(){const{theme:e}=oa(),{backgroundImage:t,brightness:a}=e,[o,i]=s.useState(t),[l,r]=s.useState(!1);s.useEffect(()=>{if(t===o)return;const e=new Image;e.onload=()=>{r(!0),requestAnimationFrame(()=>{i(t),setTimeout(()=>r(!1),300)})},e.onerror=()=>{i(t)},e.src=t},[t,o]);const c=(100-a)/100;return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint",willChange:l?"opacity":"auto"},"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(${o})`,opacity:l?.7:1}})}),n.jsx("div",{className:"fixed inset-0 -z-10 bg-black pointer-events-none transition-opacity duration-200 ease-out",style:{opacity:c,contain:"paint"},"aria-hidden":"true"})]})}),fl=20,pl=12,ml=s.createContext(null);function gl({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),o=s.useRef(null),[i,l]=s.useState({x:0,y:0}),r=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||!o.current)return;const e=o.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,i=window.innerHeight;let r,c;r=s+fl+e.width+pl>a?s-fl-e.width:s+fl,r=Math.max(pl,Math.min(r,a-e.width-pl)),c=n-fl-e.height{c.current&&(clearTimeout(c.current),c.current=null)},h=s.useCallback(t=>{d(),c.current=setTimeout(()=>{u.current=!0,o(e,t.clientX,t.clientY)},a)},[o,e,a]),f=s.useCallback(e=>{u.current&&l(e.clientX,e.clientY)},[l]),p=s.useCallback(()=>{d(),u.current=!1,i()},[i]),m=s.useCallback(()=>{if(d(),!r.current)return;const t=r.current.getBoundingClientRect();c.current=setTimeout(()=>{u.current=!0,o(e,t.left+t.width/2,t.top)},a)},[o,e,a]),g=s.useCallback(()=>{d(),u.current=!1,i()},[i]);return s.useEffect(()=>()=>{d(),u.current&&(u.current=!1,i())},[i]),s.useEffect(()=>{const e=()=>{u.current&&(d(),u.current=!1,i())};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[i]),n.jsx("span",{ref:r,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,onFocus:m,onBlur:g,className:"contents",children:t})}function xl({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function wl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-48"}),n.jsx(xl,{className:"h-8 w-32"})]}),n.jsx(xl,{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(xl,{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(xl,{className:"h-44"},t))}),n.jsx(xl,{className:"h-96"})]})}function bl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-40"}),n.jsx(xl,{className:"h-8 w-24"})]}),n.jsx(xl,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(xl,{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(xl,{className:"h-6"})},t))})]})]})}function kl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-32"}),n.jsx(xl,{className:"h-6 w-48"})]}),n.jsx(xl,{className:"h-[500px]"}),n.jsx(xl,{className:"h-64"})]})}function vl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(xl,{className:"h-8 w-36"}),n.jsx(xl,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(xl,{className:"h-80"}),n.jsx(xl,{className:"h-80"})]}),n.jsx(xl,{className:"h-64"})]})}function Sl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(xl,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(xl,{className:"h-48"}),n.jsx(xl,{className:"h-64"}),n.jsx(xl,{className:"h-32"})]})]})}function _l(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(xl,{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(xl,{className:"h-28"},t))}),n.jsx(xl,{className:"h-64"}),n.jsx(xl,{className:"h-48"})]})}const Ml=s.lazy(()=>E(()=>import("./Login-Cn28b737.js"),__vite__mapDeps([0,1,2]))),Cl=s.lazy(()=>E(()=>import("./Dashboard-Bb03OXu_.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11]))),Tl=s.lazy(()=>E(()=>import("./Packets-Dipyssg1.js"),__vite__mapDeps([12,1,2,6,7,8,5]))),jl=s.lazy(()=>E(()=>import("./Contacts-DfRgoaov.js").then(e=>e.C),__vite__mapDeps([13,1,2,5,8,7,14,15,16]))),Nl=s.lazy(()=>E(()=>import("./Statistics-BAtu1fRK.js"),__vite__mapDeps([17,1,2,18,4,9,5,14,11,16]))),Ll=s.lazy(()=>E(()=>import("./System-CvdQ6ugY.js"),__vite__mapDeps([19,1,2,4,5,11]))),Pl=s.lazy(()=>E(()=>import("./Logs-CYFnASCG.js"),__vite__mapDeps([20,1,2,18,5]))),El=s.lazy(()=>E(()=>import("./Terminal-CXpxYdmx.js"),__vite__mapDeps([21,1,2,5]))),Il=s.lazy(()=>E(()=>import("./Configuration-TGWiCMQL.js"),__vite__mapDeps([22,1,2,8,15,5,11])));function Al({children:e}){const t=o();return Na()?n.jsx(n.Fragment,{children:e}):n.jsx(N,{to:"/login",state:{from:t},replace:!0})}class Rl 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 Dl(){const e=ui(e=>e.initializeApp),t=Na();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{za()},3e4);return za(),Ba(),()=>clearInterval(s)},[e,t]),n.jsxs(gl,{children:[n.jsx(hl,{}),n.jsxs(T,{children:[n.jsx(j,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(Ml,{})})}),n.jsx(j,{path:"/*",element:n.jsx(Al,{children:n.jsxs("div",{className:"flex h-screen overflow-hidden",children:[n.jsx(dl,{}),n.jsx("main",{className:"flex-1 w-full min-w-0 pt-14 lg:pt-0 overflow-y-auto",children:n.jsx("div",{className:"p-4 sm:p-6 lg:p-8 max-w-7xl mx-auto",children:n.jsx(Rl,{children:n.jsxs(T,{children:[n.jsx(j,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(wl,{}),children:n.jsx(Cl,{})})}),n.jsx(j,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(Tl,{})})}),n.jsx(j,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(kl,{}),children:n.jsx(jl,{})})}),n.jsx(j,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(vl,{}),children:n.jsx(Nl,{})})}),n.jsx(j,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(_l,{}),children:n.jsx(Ll,{})})}),n.jsx(j,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(Pl,{})})}),n.jsx(j,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(bl,{}),children:n.jsx(El,{})})}),n.jsx(j,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(Sl,{}),children:n.jsx(Il,{})})})]})})})})]})})})]})]})}const Fl=console.warn;console.warn=(...e)=>{const t=e[0];"string"==typeof t&&t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0")||Fl.apply(console,e)},L.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx(aa,{children:n.jsx(P,{children:n.jsx(Dl,{})})})}));export{vi as $,Yi as A,Zi as B,rl as C,zo as D,Fi as E,Ai as F,Ci as G,Xi as H,di as I,Mi as J,$i as K,Bi as L,uo as M,sl as N,pa as O,ra as P,ma as Q,ua as R,Zn as S,yl as T,da as U,sa as V,Vi as W,Ki as X,el as Y,Oo as Z,$o as _,mi as a,Si as a0,Xa as a1,Bo as a2,gi as a3,yi as a4,bi as a5,ao as a6,Ho as a7,Ja as a8,Ka as a9,Ao as aA,Qa as aa,Za as ab,no as ac,oa as ad,D as ae,W as af,mo as ag,oo as ah,il as ai,ll as aj,ho as ak,fo as al,po as am,go as an,yo as ao,co as ap,io as aq,lo as ar,ro as as,Li as at,_o as au,Do as av,ha as aw,Oi as ax,Ti as ay,Ni as az,xi as b,wi as c,hi as d,Ro as e,ji as f,Sa as g,_i as h,Na as i,Va as j,fi as k,Ra as l,Pi as m,so as n,tl as o,ki as p,ca as q,nl as r,_a as s,ol as t,pi as u,Fo as v,Ji as w,Wi as x,Qi as y,al as z}; diff --git a/frontend/dist/assets/link-scoring-DacI-LFP.js b/frontend/dist/assets/link-scoring-Bg3LiwiV.js similarity index 94% rename from frontend/dist/assets/link-scoring-DacI-LFP.js rename to frontend/dist/assets/link-scoring-Bg3LiwiV.js index 4673879b..3688ce58 100644 --- a/frontend/dist/assets/link-scoring-DacI-LFP.js +++ b/frontend/dist/assets/link-scoring-Bg3LiwiV.js @@ -1 +1 @@ -import{e as t,aw as e}from"./index-Dp0UlTio.js";function o(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 n(n,r,s){const a=new Map;for(const e of r){const o=t(e);a.has(o)||a.set(o,e)}const c=new Map,i=new Map;for(const t of n){const n=t.route??t.route_type;if(!e(n))continue;const r=o(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,o=i.get(t)??0,n=f>0?Math.round(e/f*100):0,r=u>0?Math.round(o/u*100):0,s=n+r;h.set(t,{hash:t,listenerCount:e,loudCount:o,listenerScore:n,loudScore:r,blendedScore:s}),g=Math.max(g,n),l=Math.max(l,r),p=Math.max(p,s)}return{scores:h,maxListenerScore:g,maxLoudScore:l,maxBlendedScore:p}}const r={YELLOW:"#FBBF24",GREEN:"#719872",RED:"#E12672",GRAY:"#505050"};export{r as L,n as c}; +import{e as t,aw as e}from"./index-DGrzd8xb.js";function o(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 n(n,r,s){const a=new Map;for(const e of r){const o=t(e);a.has(o)||a.set(o,e)}const c=new Map,i=new Map;for(const t of n){const n=t.route??t.route_type;if(!e(n))continue;const r=o(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,o=i.get(t)??0,n=f>0?Math.round(e/f*100):0,r=u>0?Math.round(o/u*100):0,s=n+r;h.set(t,{hash:t,listenerCount:e,loudCount:o,listenerScore:n,loudScore:r,blendedScore:s}),g=Math.max(g,n),l=Math.max(l,r),p=Math.max(p,s)}return{scores:h,maxListenerScore:g,maxLoudScore:l,maxBlendedScore:p}}const r={YELLOW:"#FBBF24",GREEN:"#719872",RED:"#E12672",GRAY:"#505050"};export{r as L,n as c}; diff --git a/frontend/dist/index.html b/frontend/dist/index.html index e49fffe6..edb5f140 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -38,7 +38,7 @@ --font-data: 'JetBrains Mono', 'SF Mono', Monaco, monospace; } - + diff --git a/frontend/package.json b/frontend/package.json index f73f34b5..d886cca3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "pymc_console", - "version": "0.9.143", + "version": "0.9.144", "description": "Vite + React Dashboard for pyMC_Repeater", "private": true, "type": "module", diff --git a/manage.sh b/manage.sh index 37b029ed..6e895cea 100755 --- a/manage.sh +++ b/manage.sh @@ -897,17 +897,13 @@ do_install() { } # ========================================================================= - # Step 4: Apply patches to installed files + # Step 4: Apply log level API patch # ========================================================================= - print_step 4 $total_steps "Applying pyMC Console patches" + print_step 4 $total_steps "Configuring log level API" - # Apply patches to /opt/pymc_repeater (the installed location, not the clone) - print_info "Patching installed files..." - # PATCH 1 & 5 removed - merged upstream in PR #36 (feat/identity branch) - patch_logging_section "$INSTALL_DIR" # PATCH 2: Ensure logging section exists - patch_log_level_api "$INSTALL_DIR" # PATCH 3: Log level toggle API - patch_mesh_cli "$INSTALL_DIR" # PATCH 4: MeshCore CLI parity - patch_private_key_api "$INSTALL_DIR" # PATCH 6: Private key get/set API + # Apply single patch: POST /api/set_log_level endpoint for Logs page toggle + # Will be removed once upstream merges this feature + patch_log_level_api "$INSTALL_DIR" # ========================================================================= # Step 5: Install dashboard and console extras @@ -1283,18 +1279,13 @@ Continue?"; then return 1 } - # Step 4: Apply patches and update dashboard + # Step 4: Apply log level API patch and update dashboard ((step_num++)) || true - print_step $step_num $total_steps "Applying pyMC Console patches & dashboard" + print_step $step_num $total_steps "Updating dashboard & log level API" - # Apply patches to /opt/pymc_repeater (the installed location) - print_info "Patching installed files..." - patch_api_endpoints "$INSTALL_DIR" # PATCH 1: Radio config API endpoint - patch_logging_section "$INSTALL_DIR" # PATCH 2: Ensure logging section exists - patch_log_level_api "$INSTALL_DIR" # PATCH 3: Log level toggle API - patch_mesh_cli "$INSTALL_DIR" # PATCH 4: MeshCore CLI parity - patch_stats_api "$INSTALL_DIR" # PATCH 5: Extend stats API with MeshCore config - patch_private_key_api "$INSTALL_DIR" # PATCH 6: Private key get/set API + # Apply single patch: POST /api/set_log_level endpoint for Logs page toggle + # Will be removed once upstream merges this feature + patch_log_level_api "$INSTALL_DIR" # Ensure --log-level DEBUG if [ -f /etc/systemd/system/pymc-repeater.service ]; then @@ -2288,68 +2279,26 @@ run_upstream_installer() { # ============================================================================ # PATCH REGISTRY # ============================================================================ -# Core patches that enhance pyMC_Repeater with pyMC Console features. -# These patches are candidates for upstream PR submission. +# Minimal patches for pyMC Console. Most functionality now provided natively +# by upstream pyMC_Repeater dev branch. # -# REMOVED (Merged Upstream in PR #36 - feat/identity branch): -# - patch_api_endpoints - /api/update_radio_config endpoint -# - patch_stats_api - Extended /api/stats with max_flood_hops, advert_interval_minutes, rx_delay_base +# REMOVED (No longer needed - upstream provides natively): +# - patch_api_endpoints - Merged upstream in PR #36 +# - patch_stats_api - Merged upstream in PR #36 +# - patch_logging_section - Fixed in upstream dev branch (main.py lines 535-538) +# - patch_mesh_cli - Not essential; Terminal.tsx uses /api/stats data directly +# - patch_private_key_api - Use Identity Management API (/api/identities) instead # -# Remaining Patches: -# -# 2. patch_logging_section (main.py) -# - Ensures config['logging'] exists before setting level from --log-level arg -# - Fixes KeyError when service starts with --log-level DEBUG -# - PR Status: Pending +# REMAINING (Pending upstream PR): # # 3. patch_log_level_api (api_endpoints.py) # - Adds POST /api/set_log_level endpoint # - Allows web UI to toggle log level (INFO/DEBUG) and restart service -# - PR Status: Pending +# - PR Status: Pending - will be removed once merged upstream # -# 4. patch_mesh_cli (mesh_cli.py) -# - Enhances mesh CLI with MeshCore CommonCLI.cpp parity -# - tempradio with auto-revert timer, reboot, stats-*, board, neighbor.remove -# - Implemented via external Python patch script (patches/mesh_cli_enhancements.py) -# - PR Status: Pending -# -# 6. patch_private_key_api (mesh_cli.py) -# - Adds get/set prv.key for private key management via Terminal -# - Stores key in config['mesh']['identity_key'] -# - PR Status: Pending -# -# NOTE: patch_static_file_serving was removed -# Upstream's default() method already returns index.html for all unknown routes, -# which is exactly what a true SPA needs. React Router handles client-side routing. -# -# NOTE: GPIO patches (Fix A-D) were removed after discovery that the real issue -# was a race condition in pymc_core's interrupt initialization. Adding --log-level -# DEBUG to the service provides enough delay for the asyncio event loop to -# initialize before interrupt callbacks are registered. See create_backend_service(). -# -# To generate clean patches for upstream PR: -# 1. Clone fresh pyMC_Repeater -# 2. Apply patches via manage.sh upgrade -# 3. git diff > patches/feature-name.patch +# NOTE: GPIO timing issue is handled by --log-level DEBUG in service file. # ============================================================================ -# ------------------------------------------------------------------------------ -# PATCH 1: Radio Configuration API Endpoint [REMOVED - MERGED UPSTREAM PR #36] -# ------------------------------------------------------------------------------ -# This patch was merged upstream in PR #36 to the feat/identity branch. -# The patch is preserved below (commented out) for reference and for users -# who may still be on main/dev branches before the PR is merged there. -# ------------------------------------------------------------------------------ - -# Patch removed - see PR #36: https://github.com/rightup/pyMC_Repeater/pull/36 -patch_api_endpoints() { - # DISABLED: This patch was merged upstream in PR #36 (feat/identity branch) - # See: https://github.com/rightup/pyMC_Repeater/pull/36 - # The /api/update_radio_config endpoint is now part of upstream pyMC_Repeater - print_info "API endpoints patch skipped (merged upstream in PR #36)" - return 0 -} - # ------------------------------------------------------------------------------ # PATCH 3: Log Level API Endpoint # ------------------------------------------------------------------------------ @@ -2472,182 +2421,6 @@ PATCHEOF fi } -# ------------------------------------------------------------------------------ -# PATCH 2: Ensure logging section exists before setting level (main.py) -# ------------------------------------------------------------------------------ -patch_logging_section() { - local target_dir="${1:-$CLONE_DIR}" - local main_file="$target_dir/repeater/main.py" - - if [ ! -f "$main_file" ]; then - print_warning "main.py not found, skipping logging patch" - return 0 - fi - - # Check if already patched (upstream may have fixed this) - if grep -q 'if "logging" not in config' "$main_file" 2>/dev/null; then - print_info "Logging section already guarded (upstream fix)" - return 0 - fi - - # Only patch if the vulnerable pattern exists - if grep -q 'if args.log_level:' "$main_file" 2>/dev/null; then - python3 << PATCHEOF -import io, sys -path = "$main_file" -with open(path, 'r') as f: - s = f.read() -old = """ - if args.log_level: - config[\"logging\"][\"level\"] = args.log_level -""" -new = """ - if args.log_level: - if \"logging\" not in config: - config[\"logging\"] = {} - config[\"logging\"][\"level\"] = args.log_level -""" -if old in s and new not in s: - s = s.replace(old, new) -else: - # Try a more flexible replacement using lines - lines = s.splitlines(True) - out = [] - i = 0 - while i < len(lines): - line = lines[i] - if line.strip().startswith("if args.log_level"): - out.append(line) - i += 1 - if i < len(lines) and "config[\"logging\"][\"level\"]" in lines[i]: - indent = lines[i].split('c')[0] # leading spaces - out.append(f"{indent}if \"logging\" not in config:\n") - out.append(f"{indent} config[\"logging\"] = {{}}\n") - out.append(lines[i]) - i += 1 - continue - out.append(line) - i += 1 - s = ''.join(out) -with open(path, 'w') as f: - f.write(s) -print("Patched logging section in main.py") -PATCHEOF - # Verify - if grep -q 'if "logging" not in config' "$main_file"; then - print_success "Patched logging section in main.py" - else - print_warning "Logging patch may not have applied" - fi - else - print_info "No log_level handling found - may be older version" - fi -} - -# ------------------------------------------------------------------------------ -# PATCH 4: MeshCore CLI Parity (mesh_cli.py) -# ------------------------------------------------------------------------------ -# File: repeater/handler_helpers/mesh_cli.py -# Purpose: Enhance mesh CLI with MeshCore CommonCLI.cpp parity -# Changes: -# - tempradio with auto-revert timer (saves config, reverts after timeout) -# - reboot via systemctl restart -# - neighbor.remove implementation -# - clear stats implementation -# - stats-packets, stats-radio, stats-core commands -# - board command for platform info -# PR Status: Pending upstream submission -# ------------------------------------------------------------------------------ -patch_mesh_cli() { - local target_dir="${1:-$CLONE_DIR}" - local mesh_cli_file="$target_dir/repeater/handler_helpers/mesh_cli.py" - local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - local patch_script="$script_dir/patches/mesh_cli_enhancements.py" - - if [ ! -f "$mesh_cli_file" ]; then - print_warning "mesh_cli.py not found, skipping MeshCore CLI patch" - return 0 - fi - - # Check if already patched (look for our marker comment) - if grep -q 'pymc_console: tempradio' "$mesh_cli_file" 2>/dev/null; then - print_info "MeshCore CLI patch already applied" - return 0 - fi - - # Check if patch script exists - if [ ! -f "$patch_script" ]; then - print_warning "Patch script not found: $patch_script" - print_info "Skipping MeshCore CLI enhancements" - return 0 - fi - - # Run the Python patch script - if python3 "$patch_script" "$mesh_cli_file" 2>/dev/null; then - print_success "Applied MeshCore CLI parity patch" - else - print_warning "MeshCore CLI patch may not have applied correctly" - fi -} - -# ------------------------------------------------------------------------------ -# PATCH 5: Stats API Extension [REMOVED - MERGED UPSTREAM PR #36] -# ------------------------------------------------------------------------------ -# This patch was merged upstream in PR #36 to the feat/identity branch. -# The /api/stats endpoint now includes max_flood_hops, advert_interval_minutes, -# and rx_delay_base in the response. -# ------------------------------------------------------------------------------ - -# Patch removed - see PR #36: https://github.com/rightup/pyMC_Repeater/pull/36 -patch_stats_api() { - # Patch disabled - merged upstream in PR #36 (feat/identity branch) - print_info "Stats API patch skipped (merged upstream in PR #36)" - return 0 -} - -# ------------------------------------------------------------------------------ -# PATCH 6: Private Key API (mesh_cli.py) -# ------------------------------------------------------------------------------ -# File: repeater/handler_helpers/mesh_cli.py -# Purpose: Enable get/set prv.key for private key management via Terminal -# Changes: -# - get prv.key: Returns 32-byte Ed25519 signing key seed in hex -# - set prv.key: Stores key in config['mesh']['identity_key'], requires restart -# Security: Only accessible to admin users via authenticated CLI -# PR Status: Pending upstream submission -# ------------------------------------------------------------------------------ -patch_private_key_api() { - local target_dir="${1:-$CLONE_DIR}" - local mesh_cli_file="$target_dir/repeater/handler_helpers/mesh_cli.py" - local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - local patch_script="$script_dir/patches/private_key_api.py" - - if [ ! -f "$mesh_cli_file" ]; then - print_warning "mesh_cli.py not found, skipping private key API patch" - return 0 - fi - - # Check if already patched - if grep -q 'pymc_console: prv.key' "$mesh_cli_file" 2>/dev/null; then - print_info "Private key API patch already applied" - return 0 - fi - - # Check if patch script exists - if [ ! -f "$patch_script" ]; then - print_warning "Patch script not found: $patch_script" - print_info "Skipping private key API" - return 0 - fi - - # Run the Python patch script - if python3 "$patch_script" "$mesh_cli_file" 2>/dev/null; then - print_success "Applied private key API patch" - else - print_warning "Private key API patch may not have applied correctly" - fi -} - install_backend_service() { # Copy upstream's service file as base (from clone directory) local service_file="$CLONE_DIR/pymc-repeater.service"