From 126853f033b82b5afa578869723ce82969556606 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Wed, 21 Jan 2026 22:25:38 +0000 Subject: [PATCH] Sync build v0.9.169 Automated sync from private repository. Commit: af34a4007730703b7bd2ac344afbf883c190af34 --- frontend/dist/VERSION | 2 +- ...erModal-CZ-TWl8d.js => CollisionExplorerModal-gzC3uL5Q.js} | 2 +- .../{Configuration-koaN0oYB.js => Configuration-mzUD-v3l.js} | 2 +- .../assets/{Contacts-D7dmBQTJ.js => Contacts-Dm2Yh1zu.js} | 4 ++-- ...apMapLibre-CyTSx1md.js => ContactsMapMapLibre-BJZGJRTF.js} | 2 +- .../assets/{Dashboard-D0ZyJ9cS.js => Dashboard-DPV4UcXa.js} | 2 +- frontend/dist/assets/{Login-DxQgqPyH.js => Login-D81eBYn4.js} | 2 +- frontend/dist/assets/{Logs-YP9BpQVI.js => Logs-DmMC1IFZ.js} | 2 +- ...tDetailModal-ZVXSkr9b.js => PacketDetailModal-I-Pe3tob.js} | 2 +- .../dist/assets/{Packets-paAuyZUE.js => Packets-Dx7VKSq1.js} | 2 +- .../assets/{Statistics-CjF2BXTB.js => Statistics-rMuAOtUm.js} | 2 +- .../dist/assets/{System-Bl3LqV-u.js => System-CfbhqMgy.js} | 2 +- .../assets/{Terminal-CLPRu8Bc.js => Terminal-D4B4ypGn.js} | 2 +- frontend/dist/assets/{index-BIsccma_.js => index-Bmit1I8S.js} | 4 ++-- .../{link-scoring-v5IA77Bo.js => link-scoring-t1Ov70gg.js} | 2 +- frontend/dist/assets/{ping-SvrcEczO.js => ping-BBb1dLdC.js} | 2 +- ...Colormap-nDz0kTVE.js => useScientificColormap-n_Aivg5g.js} | 2 +- frontend/dist/index.html | 2 +- frontend/package.json | 2 +- 19 files changed, 21 insertions(+), 21 deletions(-) rename frontend/dist/assets/{CollisionExplorerModal-CZ-TWl8d.js => CollisionExplorerModal-gzC3uL5Q.js} (99%) rename frontend/dist/assets/{Configuration-koaN0oYB.js => Configuration-mzUD-v3l.js} (99%) rename frontend/dist/assets/{Contacts-D7dmBQTJ.js => Contacts-Dm2Yh1zu.js} (98%) rename frontend/dist/assets/{ContactsMapMapLibre-CyTSx1md.js => ContactsMapMapLibre-BJZGJRTF.js} (99%) rename frontend/dist/assets/{Dashboard-D0ZyJ9cS.js => Dashboard-DPV4UcXa.js} (99%) rename frontend/dist/assets/{Login-DxQgqPyH.js => Login-D81eBYn4.js} (99%) rename frontend/dist/assets/{Logs-YP9BpQVI.js => Logs-DmMC1IFZ.js} (97%) rename frontend/dist/assets/{PacketDetailModal-ZVXSkr9b.js => PacketDetailModal-I-Pe3tob.js} (99%) rename frontend/dist/assets/{Packets-paAuyZUE.js => Packets-Dx7VKSq1.js} (98%) rename frontend/dist/assets/{Statistics-CjF2BXTB.js => Statistics-rMuAOtUm.js} (99%) rename frontend/dist/assets/{System-Bl3LqV-u.js => System-CfbhqMgy.js} (99%) rename frontend/dist/assets/{Terminal-CLPRu8Bc.js => Terminal-D4B4ypGn.js} (99%) rename frontend/dist/assets/{index-BIsccma_.js => index-Bmit1I8S.js} (99%) rename frontend/dist/assets/{link-scoring-v5IA77Bo.js => link-scoring-t1Ov70gg.js} (94%) rename frontend/dist/assets/{ping-SvrcEczO.js => ping-BBb1dLdC.js} (94%) rename frontend/dist/assets/{useScientificColormap-nDz0kTVE.js => useScientificColormap-n_Aivg5g.js} (99%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index da219f88..bbbdf397 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.168 +0.9.169 diff --git a/frontend/dist/assets/CollisionExplorerModal-CZ-TWl8d.js b/frontend/dist/assets/CollisionExplorerModal-gzC3uL5Q.js similarity index 99% rename from frontend/dist/assets/CollisionExplorerModal-CZ-TWl8d.js rename to frontend/dist/assets/CollisionExplorerModal-gzC3uL5Q.js index f1ef60b3..572706fe 100644 --- a/frontend/dist/assets/CollisionExplorerModal-CZ-TWl8d.js +++ b/frontend/dist/assets/CollisionExplorerModal-gzC3uL5Q.js @@ -1 +1 @@ -import{r as e,b as t,j as o,a8 as s,X as n,a6 as r,ap as a,aq as l,ar as i,as as c,ab as d,$ as u}from"./vendor-react-DtVWNgeu.js";import{L as m}from"./leaflet-D_ckmI2R.js";import{c as h}from"./recharts-C9LxPobD.js";import{c as x,B as p,e as f}from"./index-BIsccma_.js";const y={DEFAULT:"#4338CA",AMBER:"#F59E0B",NEIGHBOR:"#39D98A",MUTED:"#6B7280",HIGHLIGHT:"#FBBF24"};function b(){if("undefined"==typeof document)return y;const e=document.documentElement,t=getComputedStyle(e);return{DEFAULT:t.getPropertyValue("--map-hub-color").trim()||y.DEFAULT,AMBER:t.getPropertyValue("--pkt-txt-msg").trim()||y.AMBER,NEIGHBOR:t.getPropertyValue("--accent-success").trim()||y.NEIGHBOR,MUTED:t.getPropertyValue("--text-muted").trim()||y.MUTED,HIGHLIGHT:t.getPropertyValue("--accent-secondary").trim()||y.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=b(),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-secondary")}):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-secondary")})}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-secondary 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=b(),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=b(),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-secondary 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,y]=e.useState(null),b=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:b.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,b,d]),j=e.useCallback(e=>y(e),[]),E=e.useCallback(()=>y(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-secondary",children:[g.length," nodes share this prefix"]})]})]}),o.jsx("button",{onClick:i,className:"p-2 rounded-lg text-text-secondary 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,a8 as s,X as n,a6 as r,ap as a,aq as l,ar as i,as as c,ab as d,$ as u}from"./vendor-react-DtVWNgeu.js";import{L as m}from"./leaflet-D_ckmI2R.js";import{c as h}from"./recharts-C9LxPobD.js";import{c as x,B as p,e as f}from"./index-Bmit1I8S.js";const y={DEFAULT:"#4338CA",AMBER:"#F59E0B",NEIGHBOR:"#39D98A",MUTED:"#6B7280",HIGHLIGHT:"#FBBF24"};function b(){if("undefined"==typeof document)return y;const e=document.documentElement,t=getComputedStyle(e);return{DEFAULT:t.getPropertyValue("--map-hub-color").trim()||y.DEFAULT,AMBER:t.getPropertyValue("--pkt-txt-msg").trim()||y.AMBER,NEIGHBOR:t.getPropertyValue("--accent-success").trim()||y.NEIGHBOR,MUTED:t.getPropertyValue("--text-muted").trim()||y.MUTED,HIGHLIGHT:t.getPropertyValue("--accent-secondary").trim()||y.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=b(),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-secondary")}):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-secondary")})}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-secondary 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=b(),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=b(),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-secondary 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,y]=e.useState(null),b=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:b.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,b,d]),j=e.useCallback(e=>y(e),[]),E=e.useCallback(()=>y(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-secondary",children:[g.length," nodes share this prefix"]})]})]}),o.jsx("button",{onClick:i,className:"p-2 rounded-lg text-text-secondary 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-koaN0oYB.js b/frontend/dist/assets/Configuration-mzUD-v3l.js similarity index 99% rename from frontend/dist/assets/Configuration-koaN0oYB.js rename to frontend/dist/assets/Configuration-mzUD-v3l.js index c467b5c6..6a5344db 100644 --- a/frontend/dist/assets/Configuration-koaN0oYB.js +++ b/frontend/dist/assets/Configuration-mzUD-v3l.js @@ -1 +1 @@ -import{r as e,j as t,f as s,i as a,X as r,a5 as n,ab as l,a$ as c,b0 as i,k as o,p as d,b1 as u,ag as m,b2 as x,b3 as p,b4 as h,aP as b,av as y,b5 as g,ak as f,b6 as j,a8 as v,a2 as N,$ as w,aa as k,b7 as C}from"./vendor-react-DtVWNgeu.js";import{c as _}from"./recharts-C9LxPobD.js";import{al as S,_ as T,am as F,an as E,O as P,ao as L,ap as R,aj as A}from"./index-BIsccma_.js";import{D}from"./DataBox-Dl3NmnnB.js";import{C as M}from"./ConfirmModal-Dq3wq7Fw.js";import{P as I,b as O,a as z,c as K}from"./PageLayout-CG02PCA-.js";import{R as q,C as $}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";async function H(e){return S("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}const Y=e.memo(function(){const{theme:e}=T(),{colorScheme:s}=e,a=F.find(e=>e.colorScheme===s)??F[0],r=a.displaySize,n=`clamp(${.8*r}rem, ${.6*r}rem + 1.5vw, ${1.4*r}rem)`;return t.jsx("div",{className:"w-32 sm:w-40 flex items-center justify-center flex-shrink-0",children:t.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center truncate",style:{fontFamily:a.displayFont,color:a.displayColor,fontSize:n,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:a.displayName})})}),V=e.memo(function(){const{theme:s,setThemePreset:a,setBrightness:r}=T(),{colorScheme:n,brightness:l}=s,[c,i]=e.useState(!1),[o,d]=e.useState(!1),u=e.useRef(null),m=e.useRef(null),x=(F.find(e=>e.colorScheme===n)??F[0]).id,p=e.useCallback((e,t)=>{if(!m.current)return l;const s=(m.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,m.current.brightness+s)))},[l]),h=e.useCallback(e=>{a(e),i(!0)},[a]),b=e.useCallback(e=>{r(e)},[r]),y=e.useCallback(e=>{const t=F.find(t=>t.id===e);t&&E(t.backgroundImage)},[]);return t.jsx("div",{className:"grid grid-cols-4 gap-2 flex-shrink-0",children:F.map(e=>{const s=x===e.id,a=s&&(c||o);return t.jsxs("div",{ref:s?u: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?i(!0):y(e.id)},onMouseLeave:()=>!o&&i(!1),onClick:()=>!s&&h(e.id),onTouchStart:e=>{if(!s)return;e.preventDefault();const t=e.touches[0];m.current={y:t.clientY,brightness:l},d(!0),i(!0);const a=e=>{e.preventDefault();const t=e.touches[0];b(p(t.clientY,!0))},r=()=>{document.removeEventListener("touchmove",a),document.removeEventListener("touchend",r),m.current=null,d(!1),setTimeout(()=>i(!1),1500)};document.addEventListener("touchmove",a,{passive:!1}),document.addEventListener("touchend",r)},onMouseDown:e=>{if(!s)return;e.preventDefault(),m.current={y:e.clientY,brightness:l},d(!0),i(!0);const t=e=>{b(p(e.clientY,!1))},a=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",a),m.current=null,d(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",a)},children:[t.jsxs("div",{className:"glass-thumbnail w-10 h-10",children:["kde breeze"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#242627]",style:{opacity:a?.4:1},children:t.jsx("span",{className:"text-[#58b99d] text-xl font-bold font-mono",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,filter:"brightness(1.3)"}}),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-l+"%"}}),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-l+"%"}}),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:[l,"%"]})})]})]}),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)})})}),U=e.memo(function({layout:e="horizontal"}){return"logo-only"===e?t.jsx(Y,{}):"thumbnails-only"===e?t.jsx(V,{}):"vertical"===e?t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(Y,{}),t.jsx(V,{})]}):t.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx(Y,{})}),t.jsx("div",{className:"flex-shrink-0",children:t.jsx(V,{})})]})}),B=[{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"}],X=[5,6,7,8,9,10,11,12],J=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],G="radioConfig",W="repeaterSettings",Q="operatingMode";function Z({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c}){const i=a.has(e.id),o=r===e.id,d=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",o?"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:[d?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"})]}),d&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(Z,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c},e.id))})]})}function ee(){var k,C,T,F,E,Y;const{stats:V,setMode:ee,clearModeMutation:te,setDutyCycleConfig:se,clearDutyCycleMutation:ae,fetchStats:re,startMutation:ne,clearMutation:le}=P(),ce=null==(k=null==V?void 0:V.config)?void 0:k.radio,ie=null==(C=null==V?void 0:V.config)?void 0:C.repeater,oe=null==(T=null==V?void 0:V.config)?void 0:T.duty_cycle,de=(null==V?void 0:V.node_name)||(null==(F=null==V?void 0:V.config)?void 0:F.node_name)||"Unknown Node",ue=(null==ie?void 0:ie.mode)??"forward",me=(null==oe?void 0:oe.enforcement_enabled)??!1,xe=null==(E=null==V?void 0:V.config)?void 0:E.delays,[pe,he]=e.useState(!1),[be,ye]=e.useState(""),[ge,fe]=e.useState(62.5),[je,ve]=e.useState(7),[Ne,we]=e.useState(5),[ke,Ce]=e.useState(""),[_e,Se]=e.useState("idle"),[Te,Fe]=e.useState(null),Ee=e.useRef(null),Pe=e.useRef(null),[Le,Re]=e.useState(!1),[Ae,De]=e.useState(""),[Me,Ie]=e.useState(""),[Oe,ze]=e.useState(""),[Ke,qe]=e.useState("idle"),$e=e.useRef(null),He=e.useRef(null),[Ye,Ve]=e.useState(!1),[Ue,Be]=e.useState(""),[Xe,Je]=e.useState(""),[Ge,We]=e.useState(""),[Qe,Ze]=e.useState(""),[et,tt]=e.useState("idle"),[st,at]=e.useState(null),rt=e.useRef(null),nt=e.useRef(null),[lt,ct]=e.useState("idle"),[it,ot]=e.useState("idle"),[dt,ut]=e.useState(null),[mt,xt]=e.useState(null),pt=e.useRef(!0),ht=e.useRef(null),bt=e.useRef(null),yt=e.useRef(null),gt=e.useRef(null),ft=e.useRef(!1),jt=e.useRef(!1);e.useEffect(()=>(pt.current=!0,()=>{pt.current=!1,ht.current&&clearTimeout(ht.current),bt.current&&clearTimeout(bt.current),yt.current&&clearTimeout(yt.current),gt.current&&clearTimeout(gt.current),_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Pe.current&&clearTimeout(Pe.current),$e.current&&clearTimeout($e.current),nt.current&&clearTimeout(nt.current)}),[]),e.useEffect(()=>{const e=e=>{if(pe||Ye||Le)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)},[pe,Ye,Le]);const vt=null==(Y=null==V?void 0:V.config)?void 0:Y.web,[Nt,wt]=e.useState("idle"),[kt,Ct]=e.useState(null),_t=e.useRef(null),St=e.useRef(null),Tt=e.useRef(!1),[Ft,Et]=e.useState([]),[Pt,Lt]=e.useState(!1),[Rt,At]=e.useState(null),[Dt,Mt]=e.useState(!1),[It,Ot]=e.useState(""),[zt,Kt]=e.useState(null),[qt,$t]=e.useState(!1),[Ht,Yt]=e.useState(null),[Vt,Ut]=e.useState(!1),[Bt,Xt]=e.useState(!1),[Jt,Gt]=e.useState(!1),[Wt,Qt]=e.useState([]),[Zt,es]=e.useState(!1),[ts,ss]=e.useState(null),[as,rs]=e.useState("deny"),[ns,ls]=e.useState(!1),[cs,is]=e.useState(null),[os,ds]=e.useState(new Set),[us,ms]=e.useState(!1),[xs,ps]=e.useState(!1),[hs,bs]=e.useState(!1),[ys,gs]=e.useState(null),[fs,js]=e.useState(null),[vs,Ns]=e.useState(""),[ws,ks]=e.useState("deny"),[Cs,_s]=e.useState(!1),[Ss,Ts]=e.useState(!0),[Fs,Es]=e.useState(!1),[Ps,Ls]=e.useState(!0),[Rs,As]=e.useState("idle"),[Ds,Ms]=e.useState(!1),[Is,Os]=e.useState(!1),zs=e.useRef(!1);e.useEffect(()=>{const e=pe&&!zs.current;zs.current=pe,ce&&e&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power)))},[ce,pe]);const Ks=e.useMemo(()=>{if(!ce||!pe)return!1;const e=ce.frequency/1e6,t=ce.bandwidth/1e3,s=parseFloat(be)||0;return Math.abs(s-e)>1e-4||ge!==t||je!==ce.spreading_factor||Ne!==ce.coding_rate||parseInt(ke)!==ce.tx_power},[ce,pe,be,ge,je,Ne,ke]),qs=e.useCallback(()=>{he(!1),Fe(null),ce&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power)))},[ce]);e.useEffect(()=>{if(!pe)return;const e=e=>{"loading"!==_e&&Ee.current&&!Ee.current.contains(e.target)&&qs()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[pe,qs,_e]);const $s=e.useCallback(()=>{const e=null==xe?void 0:xe.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[xe]),Hs=e.useCallback(()=>{const e=null==xe?void 0:xe.direct_tx_delay_factor;return"number"==typeof e?e:.5},[xe]),Ys=e.useCallback(()=>{const e=null==oe?void 0:oe.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[oe]),Vs=e.useCallback(()=>{De($s().toFixed(2)),Ie(Hs().toFixed(2)),ze(Ys().toFixed(1)),Re(!0)},[$s,Hs,Ys]),Us=e.useCallback(()=>{Re(!1)},[]);e.useEffect(()=>{if(!Le)return;const e=e=>{"loading"!==Ke&&He.current&&!He.current.contains(e.target)&&Us()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Le,Us,Ke]);const Bs=e.useCallback(()=>{var e,t,s;Be(de),Je((null==(e=null==ie?void 0:ie.latitude)?void 0:e.toString())||"0"),We((null==(t=null==ie?void 0:ie.longitude)?void 0:t.toString())||"0"),Ze((null==(s=null==ie?void 0:ie.send_advert_interval_hours)?void 0:s.toString())||"0"),at(null),Ve(!0)},[de,ie]),Xs=e.useCallback(()=>{Ve(!1),at(null)},[]);e.useEffect(()=>{if(!Ye)return;const e=e=>{"loading"!==et&&rt.current&&!rt.current.contains(e.target)&&Xs()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Ye,Xs,et]);const Js=async()=>{var e;if("loading"===Nt)return;const t=(null==vt?void 0:vt.cors_enabled)??!1,s=!t,a=t;_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Tt.current=!1,Ct(s),wt("loading"),_t.current=setTimeout(()=>{Tt.current||pt.current&&(Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3))},1e4);try{const t=await H({web:{cors_enabled:s}});if(Tt.current=!0,_t.current&&clearTimeout(_t.current),!pt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await re(),wt("success"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3)):(Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3))}catch{if(Tt.current=!0,_t.current&&clearTimeout(_t.current),!pt.current)return;Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3)}};e.useEffect(()=>{(async()=>{Ls(!0);try{const e=await async function(){return S("/api/check_pymc_console")}();e.success&&e.data?Es(e.data.exists):Es(!1);const t=null==vt?void 0:vt.web_path;Ts(!t||""===t)}catch{Es(!1)}finally{Ls(!1)}})()},[null==vt?void 0:vt.web_path]);const Gs=async e=>{var t;if("loading"!==Rs){As("loading");try{const s=await H({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!pt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Ts(e),As("success"),Ms(!0),setTimeout(()=>{pt.current&&As("idle")},2e3)):(As("error"),setTimeout(()=>{pt.current&&As("idle")},2e3))}catch{if(!pt.current)return;As("error"),setTimeout(()=>{pt.current&&As("idle")},2e3)}}},Ws=e.useCallback(async()=>{Lt(!0),At(null);try{const e=await async function(){return S("/auth/tokens")}();Et(e.tokens||[])}catch(e){At(e instanceof Error?e.message:"Failed to fetch tokens")}finally{Lt(!1)}},[]);e.useEffect(()=>{Ws()},[Ws]);const Qs=async()=>{if(It.trim()){Ut(!0),At(null);try{const e=await async function(e){return S("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}(It.trim());Kt(e.token||null),Mt(!1),$t(!0),Ot(""),await Ws()}catch(e){At(e instanceof Error?e.message:"Failed to create token")}finally{Ut(!1)}}else At("Token name is required")},Zs=e=>e?new Date(1e3*e).toLocaleString():"Never",ea=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},[]),ta=e.useCallback(async()=>{es(!0),ss(null);try{const e=await async function(){return S("/api/transport_keys")}();e.success&&e.data?Qt(ea(e.data)):ss(e.error||"Failed to load transport keys")}catch(e){ss(e instanceof Error?e.message:"Unknown error occurred")}finally{es(!1)}},[ea]);e.useEffect(()=>{ta()},[ta]);const sa=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=sa(s.children,t);if(e)return e}}return null},[]),aa=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);return null==e?void 0:e.name},[cs,Wt,sa]),ra=e.useCallback(e=>{ds(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),na=async e=>{ls(!0),ss(null);try{const t=await async function(e){return S("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}("allow"===e);t.success?rs(e):ss(t.error||"Failed to update global flood policy")}catch(t){ss(t instanceof Error?t.message:"Failed to update global flood policy")}finally{ls(!1)}},la=async()=>{if(vs.trim()){_s(!0),ss(null);try{const e=await async function(e){return S("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}({name:vs.trim(),flood_policy:ws,parent_id:cs??void 0});e.success?(await ta(),ms(!1),Ns(""),ks("deny")):ss(e.error||"Failed to add transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to add transport key")}finally{_s(!1)}}else ss("Key name is required")},ca=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);e&&(gs({...e}),ps(!0))},[cs,Wt,sa]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(us&&(ms(!1),Ns(""),ks("deny")),xs&&(ps(!1),gs(null)),hs&&(bs(!1),js(null)),Dt&&(Mt(!1),Ot("")),qt&&($t(!1),Kt(null)))};if(us||xs||hs||Dt||qt)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[us,xs,hs,Dt,qt]);const ia=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);e&&(js(e),bs(!0))},[cs,Wt,sa]);return t.jsxs(I,{children:[t.jsx(O,{title:"Configuration",icon:t.jsx(s,{})}),t.jsxs(q,{template:"standard",children:[t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:rt,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:ie&&(Ye?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Xs,disabled:"loading"===et,className:_("p-2 rounded-lg transition-colors","loading"===et?"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"!==et){nt.current&&clearTimeout(nt.current),ne(W),tt("loading"),at(null);try{const e={};Ue&&Ue!==de&&(e.node_name=Ue);const t=parseFloat(Xe);isNaN(t)||t===(null==ie?void 0:ie.latitude)||(e.latitude=t);const s=parseFloat(Ge);isNaN(s)||s===(null==ie?void 0:ie.longitude)||(e.longitude=s);const a=parseInt(Qe);if(isNaN(a)||a===(null==ie?void 0:ie.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return at({success:!0,message:"No changes to save"}),tt("idle"),void le(W);const r=await A(e);if(!pt.current)return void le(W);if(r.success&&r.data){const e=r.data.applied.join(", ");at({success:!0,message:`Updated: ${e}`}),await re({force:!0}),tt("success"),nt.current=setTimeout(()=>{pt.current&&(tt("idle"),Ve(!1),at(null),le(W))},1500)}else at({success:!1,message:r.error||"Failed to save"}),tt("error"),le(W),nt.current=setTimeout(()=>{pt.current&&tt("idle")},2e3)}catch(e){if(!pt.current)return void le(W);at({success:!1,message:String(e)}),tt("error"),le(W),nt.current=setTimeout(()=>{pt.current&&tt("idle")},2e3)}}},disabled:"loading"===et,className:_("p-2 rounded-lg transition-colors","loading"===et?"text-accent-primary cursor-wait":"success"===et?"text-accent-success":"error"===et?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===et?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===et?t.jsx(l,{className:"w-4 h-4"}):"error"===et?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Bs,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"})}))})]}),st&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",st.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:st.message}),ie?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",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"text",value:Ue,onChange:e=>Be(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:de})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Xe,onChange:e=>Je(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!==ie.latitude?ie.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Ge,onChange:e=>We(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!==ie.longitude?ie.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Qe,onChange:e=>Ze(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:ie.send_advert_interval_hours>0?`${ie.send_advert_interval_hours}h`:"Disabled"})}),Ye&&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:ie.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:Ee,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:ce&&(pe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:qs,disabled:"loading"===_e,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==_e){Pe.current&&clearTimeout(Pe.current),ne(G),Se("loading"),Fe(null);try{const e={},t=parseFloat(be),s=ce?ce.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=ce?ce.bandwidth/1e3:0;ge!==a&&(e.bandwidth_khz=ge),je!==(null==ce?void 0:ce.spreading_factor)&&(e.spreading_factor=je),Ne!==(null==ce?void 0:ce.coding_rate)&&(e.coding_rate=Ne);const r=parseInt(ke);if(r!==(null==ce?void 0:ce.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return Fe({success:!0,message:"No changes to save"}),Se("idle"),void le(G);const n=await A(e);if(!pt.current)return void le(G);if(n.success&&n.data){const e=n.data.applied.join(", "),t=n.data.live_update?" (applied live)":" (restart required)";Fe({success:!0,message:`Updated: ${e}${t}`}),await re({force:!0}),Se("success"),Pe.current=setTimeout(()=>{pt.current&&(Se("idle"),he(!1),Fe(null),le(G))},1500)}else Fe({success:!1,message:n.error||"Failed to save"}),Se("error"),le(G),Pe.current=setTimeout(()=>{pt.current&&Se("idle")},2e3)}catch(e){if(!pt.current)return void le(G);Fe({success:!1,message:String(e)}),Se("error"),le(G),Pe.current=setTimeout(()=>{pt.current&&Se("idle")},2e3)}}},disabled:"loading"===_e||!Ks,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-accent-primary cursor-wait":"success"===_e?"text-accent-success":"error"===_e?"text-accent-danger":Ks?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:Ks?"Save changes":"No changes to save",children:"loading"===_e?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===_e?t.jsx(l,{className:"w-4 h-4"}):"error"===_e?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{ce&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power))),Fe(null),he(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit radio settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),Te&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",Te.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:Te.message}),ce?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:pe?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsx("input",{type:"number",value:be,onChange:e=>ye(e.target.value),step:"0.001",min:"400",max:"930",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:L(ce.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:pe?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsx("input",{type:"number",value:ke,onChange:e=>Ce(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:[ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:ge,onChange:e=>fe(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:B.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(o,{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:R(ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:je,onChange:e=>ve(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:X.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(o,{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",ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Ne,onChange:e=>we(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:J.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(o,{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/",ce.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:[ce.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(q,{template:"standard",children:[t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:He,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(d,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:Le?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==Ke){$e.current&&clearTimeout($e.current),ne(Q),qe("loading");try{const e=await A({tx_delay_factor:parseFloat(Ae),direct_tx_delay_factor:parseFloat(Me)});if(await se({max_airtime_percent:parseFloat(Oe),enforcement_enabled:me}),!pt.current)return void le(Q);e.success&&e.data?(await re({force:!0}),qe("success"),$e.current=setTimeout(()=>{pt.current&&(qe("idle"),Re(!1),le(Q))},1500)):(qe("error"),le(Q),$e.current=setTimeout(()=>{pt.current&&qe("idle")},2e3))}catch{if(!pt.current)return void le(Q);qe("error"),le(Q),$e.current=setTimeout(()=>{pt.current&&qe("idle")},2e3)}}},disabled:"loading"===Ke,className:_("p-2 rounded-lg transition-colors","loading"===Ke?"text-accent-primary cursor-wait":"success"===Ke?"text-accent-success":"error"===Ke?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===Ke?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ke?t.jsx(l,{className:"w-4 h-4"}):"error"===Ke?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})}),t.jsx("button",{onClick:Us,className:"p-2 rounded-lg text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Vs,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit settings",children:t.jsx(c,{className:"w-4 h-4"})})})]}),t.jsx("p",{className:"type-label text-text-muted mb-3",children:"Control how the repeater handles packets"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsxs("div",{className:"flex-1 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Repeat"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==dt?dt:"forward"===ue;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===lt)return;const t=!e,s="forward"===ue;ht.current&&clearTimeout(ht.current),bt.current&&clearTimeout(bt.current),ft.current=!1,ut(t),ct("loading"),ht.current=setTimeout(()=>{ft.current||pt.current&&(ut(s),ct("error"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null))},2e3))},1e4);try{if(await ee(t?"forward":"monitor"),ft.current=!0,ht.current&&clearTimeout(ht.current),!pt.current)return;ct("success"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null),te())},2e3)}catch{if(ft.current=!0,ht.current&&clearTimeout(ht.current),!pt.current)return;ut(s),ct("error"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null))},2e3)}},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"),"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"===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",{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!==mt?mt:me;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===it)return;const t=!e,s=me;yt.current&&clearTimeout(yt.current),gt.current&&clearTimeout(gt.current),jt.current=!1,xt(t),ot("loading"),yt.current=setTimeout(()=>{jt.current||pt.current&&(xt(s),ot("error"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null))},2e3))},1e4);try{if(await se({max_airtime_percent:Ys(),enforcement_enabled:t}),jt.current=!0,yt.current&&clearTimeout(yt.current),!pt.current)return;ot("success"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null),ae())},2e3)}catch{if(jt.current=!0,yt.current&&clearTimeout(yt.current),!pt.current)return;xt(s),ot("error"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null))},2e3)}},disabled:"loading"===it,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"===it&&"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"===it&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===it&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===it&&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]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Oe,onChange:e=>ze(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:[Ys().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]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ae,onChange:e=>De(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"x"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[$s().toFixed(2),"x"]})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Direct"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Me,onChange:e=>Ie(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:[Hs().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx($,{span:12,md:6,children:t.jsxs(z,{children:[t.jsx(K,{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!==kt?kt:(null==vt?void 0:vt.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Js,disabled:"loading"===Nt,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"===Nt&&"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"===Nt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===Nt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===Nt&&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.jsx(U,{})]})]})]})})]}),t.jsx(q,{template:"auto",children:t.jsxs(z,{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:()=>ms(!0),disabled:"allow"===as,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===as?"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:ca,disabled:!cs||"allow"===as,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",cs&&"allow"!==as?"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:ia,disabled:!cs||"allow"===as,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",cs&&"allow"!==as?"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"===as?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===as?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:()=>na("deny"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===as?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>na("allow"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===as?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Allow"})]}),ns&&t.jsx(n,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),ts&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:ts}),t.jsx("div",{className:"bg-white/[0.02] rounded-2xl p-4 min-h-[120px]",children:Zt?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===Wt.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:Wt.map(e=>t.jsx(Z,{node:e,level:0,expandedKeys:os,selectedKeyId:cs,globalFloodPolicy:as,onSelect:is,onToggle:ra},e.id))})})]})}),t.jsx(q,{template:"auto",children:t.jsxs(z,{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:()=>Mt(!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."})]})]})}),Rt&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Rt}),Pt&&0===Ft.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..."})]}):Ft.length>0?t.jsx("div",{className:"space-y-2",children:Ft.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: ",Zs(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",Zs(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Yt({id:e.id,name:e.name}),disabled:Bt,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:()=>Mt(!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(q,{template:"auto",children:t.jsxs(z,{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",Ss?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Rs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ss,onChange:()=>Gs(!0),disabled:"loading"===Rs,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",Ss?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Rs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ss,onChange:()=>Gs(!1),disabled:"loading"===Rs,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"PyMC Console"}),t.jsx("span",{className:"type-data-xs bg-accent-secondary/15 text-accent-secondary px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_console/web/html"})]})]})]}),!Ps&&t.jsx("div",{className:_("bg-white/[0.02] rounded-2xl p-4",Fs?"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",Fs?"bg-accent-success/20":"bg-accent-tertiary/20"),children:Fs?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:Fs?"PyMC Console has been detected":"PyMC Console Not Installed"}),Fs?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"]})]})]})]})}),Ds&&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(!Is){Os(!0);try{await async function(){return S("/api/restart_service",{method:"POST",body:"{}"})}(),Ms(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ms(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:Is,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:Is?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(q,{template:"auto",children:t.jsxs(z,{children:[t.jsx(K,{icon:t.jsx(d,{}),title:"Node Information",largeTitle:!0}),V?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:de})]}),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",V.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",V.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:V.local_hash?t.jsx(D,{copy:!0,size:"compact",children:V.local_hash}):t.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),V.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(D,{copy:!0,children:V.public_key})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading node information..."})]})}),Dt&&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&&Mt(!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:It,onChange:e=>Ot(e.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&Qs(),autoFocus:!0}),t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Give your token a descriptive name to identify its purpose"})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{Mt(!1),Ot(""),At(null)},disabled:Vt,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:Qs,disabled:Vt||!It.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Vt?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),qt&&zt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&$t(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-lg w-full shadow-2xl",children:[t.jsx("h3",{id:"show-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Token Created Successfully"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(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:zt,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:()=>{zt&&(navigator.clipboard.writeText(zt),Gt(!0),setTimeout(()=>Gt(!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:[Jt?t.jsx(l,{className:"w-4 h-4 text-accent-success"}):t.jsx(w,{className:"w-4 h-4"}),Jt?"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: ',zt.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{$t(!1),Kt(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(M,{isOpen:!!Ht,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Ht?void 0:Ht.name}'? This action cannot be undone.`,confirmLabel:Bt?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Ht){Xt(!0),At(null);try{await async function(e){return S(`/auth/tokens/${e}`,{method:"DELETE"})}(Ht.id),await Ws(),Yt(null)}catch(e){At(e instanceof Error?e.message:"Failed to revoke token")}finally{Xt(!1)}}},onCancel:()=>Yt(null)}),us&&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&&ms(!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:[cs&&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:aa()})]}),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:vs,onChange:e=>Ns(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&&la(),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:()=>ks("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ws?"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:()=>ks("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ws?"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:()=>{ms(!1),Ns(""),ks("deny")},disabled:Cs,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:la,disabled:Cs||!vs.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:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),xs&&ys&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&ps(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"edit-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Edit Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:ys.name,onChange:e=>gs({...ys,name:e.target.value}),className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>gs({...ys,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ys.floodPolicy?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>gs({...ys,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ys.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),ys.transport_key&&t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Transport Key"}),t.jsx("code",{className:"block bg-bg-subtle px-3 py-2 rounded-lg text-xs text-text-muted font-mono overflow-x-auto",children:ys.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{ps(!1),js(ys),bs(!0),gs(null)},disabled:Cs,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:()=>{ps(!1),gs(null)},disabled:Cs,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(ys){_s(!0),ss(null);try{const e=await async function(e,t){return S(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}(ys.id,{name:ys.name,flood_policy:ys.floodPolicy});e.success?(await ta(),ps(!1),gs(null)):ss(e.error||"Failed to update transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to update transport key")}finally{_s(!1)}}},disabled:Cs||!ys.name.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),hs&&fs&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&bs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"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:["'",fs.name,"'"]}),"?"]}),fs.children&&fs.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 ",fs.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:()=>{bs(!1),js(null)},disabled:Cs,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(fs){_s(!0),ss(null);try{const e=await async function(e){return S(`/api/transport_key/${e}`,{method:"DELETE"})}(fs.id);e.success?(await ta(),bs(!1),js(null),is(null)):ss(e.error||"Failed to delete transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to delete transport key")}finally{_s(!1)}}},disabled:Cs,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:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ee as default}; +import{r as e,j as t,f as s,i as a,X as r,a5 as n,ab as l,a$ as c,b0 as i,k as o,p as d,b1 as u,ag as m,b2 as x,b3 as p,b4 as h,aP as b,av as y,b5 as g,ak as f,b6 as j,a8 as v,a2 as N,$ as w,aa as k,b7 as C}from"./vendor-react-DtVWNgeu.js";import{c as _}from"./recharts-C9LxPobD.js";import{al as S,_ as T,am as F,an as E,O as P,ao as L,ap as R,aj as A}from"./index-Bmit1I8S.js";import{D}from"./DataBox-Dl3NmnnB.js";import{C as M}from"./ConfirmModal-Dq3wq7Fw.js";import{P as I,b as O,a as z,c as K}from"./PageLayout-CG02PCA-.js";import{R as q,C as $}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";async function H(e){return S("/api/update_web_config",{method:"POST",body:JSON.stringify(e)})}const Y=e.memo(function(){const{theme:e}=T(),{colorScheme:s}=e,a=F.find(e=>e.colorScheme===s)??F[0],r=a.displaySize,n=`clamp(${.8*r}rem, ${.6*r}rem + 1.5vw, ${1.4*r}rem)`;return t.jsx("div",{className:"w-32 sm:w-40 flex items-center justify-center flex-shrink-0",children:t.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center truncate",style:{fontFamily:a.displayFont,color:a.displayColor,fontSize:n,fontOpticalSizing:"auto",letterSpacing:"-0.03em"},children:a.displayName})})}),V=e.memo(function(){const{theme:s,setThemePreset:a,setBrightness:r}=T(),{colorScheme:n,brightness:l}=s,[c,i]=e.useState(!1),[o,d]=e.useState(!1),u=e.useRef(null),m=e.useRef(null),x=(F.find(e=>e.colorScheme===n)??F[0]).id,p=e.useCallback((e,t)=>{if(!m.current)return l;const s=(m.current.y-e)/(t?200:80)*100;return Math.round(Math.max(0,Math.min(100,m.current.brightness+s)))},[l]),h=e.useCallback(e=>{a(e),i(!0)},[a]),b=e.useCallback(e=>{r(e)},[r]),y=e.useCallback(e=>{const t=F.find(t=>t.id===e);t&&E(t.backgroundImage)},[]);return t.jsx("div",{className:"grid grid-cols-4 gap-2 flex-shrink-0",children:F.map(e=>{const s=x===e.id,a=s&&(c||o);return t.jsxs("div",{ref:s?u: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?i(!0):y(e.id)},onMouseLeave:()=>!o&&i(!1),onClick:()=>!s&&h(e.id),onTouchStart:e=>{if(!s)return;e.preventDefault();const t=e.touches[0];m.current={y:t.clientY,brightness:l},d(!0),i(!0);const a=e=>{e.preventDefault();const t=e.touches[0];b(p(t.clientY,!0))},r=()=>{document.removeEventListener("touchmove",a),document.removeEventListener("touchend",r),m.current=null,d(!1),setTimeout(()=>i(!1),1500)};document.addEventListener("touchmove",a,{passive:!1}),document.addEventListener("touchend",r)},onMouseDown:e=>{if(!s)return;e.preventDefault(),m.current={y:e.clientY,brightness:l},d(!0),i(!0);const t=e=>{b(p(e.clientY,!1))},a=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",a),m.current=null,d(!1)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",a)},children:[t.jsxs("div",{className:"glass-thumbnail w-10 h-10",children:["kde breeze"===e.id?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#242627]",style:{opacity:a?.4:1},children:t.jsx("span",{className:"text-[#58b99d] text-xl font-bold font-mono",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,filter:"brightness(1.3)"}}),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-l+"%"}}),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-l+"%"}}),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:[l,"%"]})})]})]}),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)})})}),U=e.memo(function({layout:e="horizontal"}){return"logo-only"===e?t.jsx(Y,{}):"thumbnails-only"===e?t.jsx(V,{}):"vertical"===e?t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(Y,{}),t.jsx(V,{})]}):t.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[t.jsx("div",{className:"flex items-center justify-center",children:t.jsx(Y,{})}),t.jsx("div",{className:"flex-shrink-0",children:t.jsx(V,{})})]})}),B=[{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"}],X=[5,6,7,8,9,10,11,12],J=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],G="radioConfig",W="repeaterSettings",Q="operatingMode";function Z({node:e,level:s,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c}){const i=a.has(e.id),o=r===e.id,d=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",o?"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:[d?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"})]}),d&&i&&t.jsx("div",{children:e.children.map(e=>t.jsx(Z,{node:e,level:s+1,expandedKeys:a,selectedKeyId:r,globalFloodPolicy:n,onSelect:l,onToggle:c},e.id))})]})}function ee(){var k,C,T,F,E,Y;const{stats:V,setMode:ee,clearModeMutation:te,setDutyCycleConfig:se,clearDutyCycleMutation:ae,fetchStats:re,startMutation:ne,clearMutation:le}=P(),ce=null==(k=null==V?void 0:V.config)?void 0:k.radio,ie=null==(C=null==V?void 0:V.config)?void 0:C.repeater,oe=null==(T=null==V?void 0:V.config)?void 0:T.duty_cycle,de=(null==V?void 0:V.node_name)||(null==(F=null==V?void 0:V.config)?void 0:F.node_name)||"Unknown Node",ue=(null==ie?void 0:ie.mode)??"forward",me=(null==oe?void 0:oe.enforcement_enabled)??!1,xe=null==(E=null==V?void 0:V.config)?void 0:E.delays,[pe,he]=e.useState(!1),[be,ye]=e.useState(""),[ge,fe]=e.useState(62.5),[je,ve]=e.useState(7),[Ne,we]=e.useState(5),[ke,Ce]=e.useState(""),[_e,Se]=e.useState("idle"),[Te,Fe]=e.useState(null),Ee=e.useRef(null),Pe=e.useRef(null),[Le,Re]=e.useState(!1),[Ae,De]=e.useState(""),[Me,Ie]=e.useState(""),[Oe,ze]=e.useState(""),[Ke,qe]=e.useState("idle"),$e=e.useRef(null),He=e.useRef(null),[Ye,Ve]=e.useState(!1),[Ue,Be]=e.useState(""),[Xe,Je]=e.useState(""),[Ge,We]=e.useState(""),[Qe,Ze]=e.useState(""),[et,tt]=e.useState("idle"),[st,at]=e.useState(null),rt=e.useRef(null),nt=e.useRef(null),[lt,ct]=e.useState("idle"),[it,ot]=e.useState("idle"),[dt,ut]=e.useState(null),[mt,xt]=e.useState(null),pt=e.useRef(!0),ht=e.useRef(null),bt=e.useRef(null),yt=e.useRef(null),gt=e.useRef(null),ft=e.useRef(!1),jt=e.useRef(!1);e.useEffect(()=>(pt.current=!0,()=>{pt.current=!1,ht.current&&clearTimeout(ht.current),bt.current&&clearTimeout(bt.current),yt.current&&clearTimeout(yt.current),gt.current&&clearTimeout(gt.current),_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Pe.current&&clearTimeout(Pe.current),$e.current&&clearTimeout($e.current),nt.current&&clearTimeout(nt.current)}),[]),e.useEffect(()=>{const e=e=>{if(pe||Ye||Le)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)},[pe,Ye,Le]);const vt=null==(Y=null==V?void 0:V.config)?void 0:Y.web,[Nt,wt]=e.useState("idle"),[kt,Ct]=e.useState(null),_t=e.useRef(null),St=e.useRef(null),Tt=e.useRef(!1),[Ft,Et]=e.useState([]),[Pt,Lt]=e.useState(!1),[Rt,At]=e.useState(null),[Dt,Mt]=e.useState(!1),[It,Ot]=e.useState(""),[zt,Kt]=e.useState(null),[qt,$t]=e.useState(!1),[Ht,Yt]=e.useState(null),[Vt,Ut]=e.useState(!1),[Bt,Xt]=e.useState(!1),[Jt,Gt]=e.useState(!1),[Wt,Qt]=e.useState([]),[Zt,es]=e.useState(!1),[ts,ss]=e.useState(null),[as,rs]=e.useState("deny"),[ns,ls]=e.useState(!1),[cs,is]=e.useState(null),[os,ds]=e.useState(new Set),[us,ms]=e.useState(!1),[xs,ps]=e.useState(!1),[hs,bs]=e.useState(!1),[ys,gs]=e.useState(null),[fs,js]=e.useState(null),[vs,Ns]=e.useState(""),[ws,ks]=e.useState("deny"),[Cs,_s]=e.useState(!1),[Ss,Ts]=e.useState(!0),[Fs,Es]=e.useState(!1),[Ps,Ls]=e.useState(!0),[Rs,As]=e.useState("idle"),[Ds,Ms]=e.useState(!1),[Is,Os]=e.useState(!1),zs=e.useRef(!1);e.useEffect(()=>{const e=pe&&!zs.current;zs.current=pe,ce&&e&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power)))},[ce,pe]);const Ks=e.useMemo(()=>{if(!ce||!pe)return!1;const e=ce.frequency/1e6,t=ce.bandwidth/1e3,s=parseFloat(be)||0;return Math.abs(s-e)>1e-4||ge!==t||je!==ce.spreading_factor||Ne!==ce.coding_rate||parseInt(ke)!==ce.tx_power},[ce,pe,be,ge,je,Ne,ke]),qs=e.useCallback(()=>{he(!1),Fe(null),ce&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power)))},[ce]);e.useEffect(()=>{if(!pe)return;const e=e=>{"loading"!==_e&&Ee.current&&!Ee.current.contains(e.target)&&qs()};return document.addEventListener("mouseup",e),()=>{document.removeEventListener("mouseup",e)}},[pe,qs,_e]);const $s=e.useCallback(()=>{const e=null==xe?void 0:xe.tx_delay_factor;return e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??1:"number"==typeof e?e:1},[xe]),Hs=e.useCallback(()=>{const e=null==xe?void 0:xe.direct_tx_delay_factor;return"number"==typeof e?e:.5},[xe]),Ys=e.useCallback(()=>{const e=null==oe?void 0:oe.max_airtime_percent;return"number"==typeof e?e:e&&"object"==typeof e&&"parsedValue"in e?e.parsedValue??6:6},[oe]),Vs=e.useCallback(()=>{De($s().toFixed(2)),Ie(Hs().toFixed(2)),ze(Ys().toFixed(1)),Re(!0)},[$s,Hs,Ys]),Us=e.useCallback(()=>{Re(!1)},[]);e.useEffect(()=>{if(!Le)return;const e=e=>{"loading"!==Ke&&He.current&&!He.current.contains(e.target)&&Us()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Le,Us,Ke]);const Bs=e.useCallback(()=>{var e,t,s;Be(de),Je((null==(e=null==ie?void 0:ie.latitude)?void 0:e.toString())||"0"),We((null==(t=null==ie?void 0:ie.longitude)?void 0:t.toString())||"0"),Ze((null==(s=null==ie?void 0:ie.send_advert_interval_hours)?void 0:s.toString())||"0"),at(null),Ve(!0)},[de,ie]),Xs=e.useCallback(()=>{Ve(!1),at(null)},[]);e.useEffect(()=>{if(!Ye)return;const e=e=>{"loading"!==et&&rt.current&&!rt.current.contains(e.target)&&Xs()};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[Ye,Xs,et]);const Js=async()=>{var e;if("loading"===Nt)return;const t=(null==vt?void 0:vt.cors_enabled)??!1,s=!t,a=t;_t.current&&clearTimeout(_t.current),St.current&&clearTimeout(St.current),Tt.current=!1,Ct(s),wt("loading"),_t.current=setTimeout(()=>{Tt.current||pt.current&&(Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3))},1e4);try{const t=await H({web:{cors_enabled:s}});if(Tt.current=!0,_t.current&&clearTimeout(_t.current),!pt.current)return;t.success||(null==(e=t.data)?void 0:e.persisted)?(await re(),wt("success"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3)):(Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3))}catch{if(Tt.current=!0,_t.current&&clearTimeout(_t.current),!pt.current)return;Ct(a),wt("error"),St.current=setTimeout(()=>{pt.current&&(wt("idle"),Ct(null))},2e3)}};e.useEffect(()=>{(async()=>{Ls(!0);try{const e=await async function(){return S("/api/check_pymc_console")}();e.success&&e.data?Es(e.data.exists):Es(!1);const t=null==vt?void 0:vt.web_path;Ts(!t||""===t)}catch{Es(!1)}finally{Ls(!1)}})()},[null==vt?void 0:vt.web_path]);const Gs=async e=>{var t;if("loading"!==Rs){As("loading");try{const s=await H({web:{web_path:e?null:"/opt/pymc_console/web/html"}});if(!pt.current)return;s.success||(null==(t=s.data)?void 0:t.persisted)?(Ts(e),As("success"),Ms(!0),setTimeout(()=>{pt.current&&As("idle")},2e3)):(As("error"),setTimeout(()=>{pt.current&&As("idle")},2e3))}catch{if(!pt.current)return;As("error"),setTimeout(()=>{pt.current&&As("idle")},2e3)}}},Ws=e.useCallback(async()=>{Lt(!0),At(null);try{const e=await async function(){return S("/auth/tokens")}();Et(e.tokens||[])}catch(e){At(e instanceof Error?e.message:"Failed to fetch tokens")}finally{Lt(!1)}},[]);e.useEffect(()=>{Ws()},[Ws]);const Qs=async()=>{if(It.trim()){Ut(!0),At(null);try{const e=await async function(e){return S("/auth/tokens",{method:"POST",body:JSON.stringify({name:e})})}(It.trim());Kt(e.token||null),Mt(!1),$t(!0),Ot(""),await Ws()}catch(e){At(e instanceof Error?e.message:"Failed to create token")}finally{Ut(!1)}}else At("Token name is required")},Zs=e=>e?new Date(1e3*e).toLocaleString():"Never",ea=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},[]),ta=e.useCallback(async()=>{es(!0),ss(null);try{const e=await async function(){return S("/api/transport_keys")}();e.success&&e.data?Qt(ea(e.data)):ss(e.error||"Failed to load transport keys")}catch(e){ss(e instanceof Error?e.message:"Unknown error occurred")}finally{es(!1)}},[ea]);e.useEffect(()=>{ta()},[ta]);const sa=e.useCallback((e,t)=>{for(const s of e){if(s.id===t)return s;if(s.children){const e=sa(s.children,t);if(e)return e}}return null},[]),aa=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);return null==e?void 0:e.name},[cs,Wt,sa]),ra=e.useCallback(e=>{ds(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),na=async e=>{ls(!0),ss(null);try{const t=await async function(e){return S("/api/global_flood_policy",{method:"POST",body:JSON.stringify({global_flood_allow:e})})}("allow"===e);t.success?rs(e):ss(t.error||"Failed to update global flood policy")}catch(t){ss(t instanceof Error?t.message:"Failed to update global flood policy")}finally{ls(!1)}},la=async()=>{if(vs.trim()){_s(!0),ss(null);try{const e=await async function(e){return S("/api/transport_keys",{method:"POST",body:JSON.stringify(e)})}({name:vs.trim(),flood_policy:ws,parent_id:cs??void 0});e.success?(await ta(),ms(!1),Ns(""),ks("deny")):ss(e.error||"Failed to add transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to add transport key")}finally{_s(!1)}}else ss("Key name is required")},ca=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);e&&(gs({...e}),ps(!0))},[cs,Wt,sa]);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&(us&&(ms(!1),Ns(""),ks("deny")),xs&&(ps(!1),gs(null)),hs&&(bs(!1),js(null)),Dt&&(Mt(!1),Ot("")),qt&&($t(!1),Kt(null)))};if(us||xs||hs||Dt||qt)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[us,xs,hs,Dt,qt]);const ia=e.useCallback(()=>{if(!cs)return;const e=sa(Wt,cs);e&&(js(e),bs(!0))},[cs,Wt,sa]);return t.jsxs(I,{children:[t.jsx(O,{title:"Configuration",icon:t.jsx(s,{})}),t.jsxs(q,{template:"standard",children:[t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:rt,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:ie&&(Ye?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Xs,disabled:"loading"===et,className:_("p-2 rounded-lg transition-colors","loading"===et?"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"!==et){nt.current&&clearTimeout(nt.current),ne(W),tt("loading"),at(null);try{const e={};Ue&&Ue!==de&&(e.node_name=Ue);const t=parseFloat(Xe);isNaN(t)||t===(null==ie?void 0:ie.latitude)||(e.latitude=t);const s=parseFloat(Ge);isNaN(s)||s===(null==ie?void 0:ie.longitude)||(e.longitude=s);const a=parseInt(Qe);if(isNaN(a)||a===(null==ie?void 0:ie.send_advert_interval_hours)||(e.flood_advert_interval_hours=a),0===Object.keys(e).length)return at({success:!0,message:"No changes to save"}),tt("idle"),void le(W);const r=await A(e);if(!pt.current)return void le(W);if(r.success&&r.data){const e=r.data.applied.join(", ");at({success:!0,message:`Updated: ${e}`}),await re({force:!0}),tt("success"),nt.current=setTimeout(()=>{pt.current&&(tt("idle"),Ve(!1),at(null),le(W))},1500)}else at({success:!1,message:r.error||"Failed to save"}),tt("error"),le(W),nt.current=setTimeout(()=>{pt.current&&tt("idle")},2e3)}catch(e){if(!pt.current)return void le(W);at({success:!1,message:String(e)}),tt("error"),le(W),nt.current=setTimeout(()=>{pt.current&&tt("idle")},2e3)}}},disabled:"loading"===et,className:_("p-2 rounded-lg transition-colors","loading"===et?"text-accent-primary cursor-wait":"success"===et?"text-accent-success":"error"===et?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save changes",children:"loading"===et?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===et?t.jsx(l,{className:"w-4 h-4"}):"error"===et?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Bs,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"})}))})]}),st&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",st.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:st.message}),ie?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",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"text",value:Ue,onChange:e=>Be(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:de})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Latitude (°)":"Latitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Xe,onChange:e=>Je(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!==ie.latitude?ie.latitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Longitude (°)":"Longitude"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Ge,onChange:e=>We(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!==ie.longitude?ie.longitude.toFixed(6):"Not set"})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:Ye?"Advert Interval (hours)":"Advert Interval"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",Ye?"bg-white/5":"bg-white/[0.02]"),children:Ye?t.jsx("input",{type:"number",value:Qe,onChange:e=>Ze(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:ie.send_advert_interval_hours>0?`${ie.send_advert_interval_hours}h`:"Disabled"})}),Ye&&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:ie.use_score_for_tx?"Enabled":"Disabled"})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading repeater settings..."})]})})}),t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:Ee,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:ce&&(pe?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:qs,disabled:"loading"===_e,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-text-muted cursor-not-allowed":"text-text-muted hover:text-accent-danger hover:bg-accent-danger/10"),title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})}),t.jsx("button",{onClick:async()=>{if("loading"!==_e){Pe.current&&clearTimeout(Pe.current),ne(G),Se("loading"),Fe(null);try{const e={},t=parseFloat(be),s=ce?ce.frequency/1e6:0;Math.abs(t-s)>1e-4&&(e.frequency_mhz=t);const a=ce?ce.bandwidth/1e3:0;ge!==a&&(e.bandwidth_khz=ge),je!==(null==ce?void 0:ce.spreading_factor)&&(e.spreading_factor=je),Ne!==(null==ce?void 0:ce.coding_rate)&&(e.coding_rate=Ne);const r=parseInt(ke);if(r!==(null==ce?void 0:ce.tx_power)&&(e.tx_power=r),0===Object.keys(e).length)return Fe({success:!0,message:"No changes to save"}),Se("idle"),void le(G);const n=await A(e);if(!pt.current)return void le(G);if(n.success&&n.data){const e=n.data.applied.join(", "),t=n.data.live_update?" (applied live)":" (restart required)";Fe({success:!0,message:`Updated: ${e}${t}`}),await re({force:!0}),Se("success"),Pe.current=setTimeout(()=>{pt.current&&(Se("idle"),he(!1),Fe(null),le(G))},1500)}else Fe({success:!1,message:n.error||"Failed to save"}),Se("error"),le(G),Pe.current=setTimeout(()=>{pt.current&&Se("idle")},2e3)}catch(e){if(!pt.current)return void le(G);Fe({success:!1,message:String(e)}),Se("error"),le(G),Pe.current=setTimeout(()=>{pt.current&&Se("idle")},2e3)}}},disabled:"loading"===_e||!Ks,className:_("p-2 rounded-lg transition-colors","loading"===_e?"text-accent-primary cursor-wait":"success"===_e?"text-accent-success":"error"===_e?"text-accent-danger":Ks?"text-accent-success hover:bg-accent-success/10":"text-text-muted cursor-not-allowed"),title:Ks?"Save changes":"No changes to save",children:"loading"===_e?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===_e?t.jsx(l,{className:"w-4 h-4"}):"error"===_e?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:()=>{ce&&(ye((ce.frequency/1e6).toFixed(3)),fe(ce.bandwidth/1e3),ve(ce.spreading_factor),we(ce.coding_rate),Ce(String(ce.tx_power))),Fe(null),he(!0)},className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit radio settings",children:t.jsx(c,{className:"w-4 h-4"})}))})]}),Te&&t.jsx("div",{className:_("text-xs mb-3 px-2 py-1.5 rounded-md",Te.success?"text-accent-success bg-accent-success/10":"text-accent-danger bg-accent-danger/10"),children:Te.message}),ce?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:pe?"Frequency (MHz)":"Frequency"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsx("input",{type:"number",value:be,onChange:e=>ye(e.target.value),step:"0.001",min:"400",max:"930",className:"w-full bg-transparent text-text-primary focus:outline-none type-data"}):t.jsx("span",{className:"type-data text-text-primary",children:L(ce.frequency)})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-1",children:pe?"TX Power (dBm)":"TX Power"}),t.jsx("div",{className:_("h-[38px] rounded-full px-4 flex items-center transition-colors",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsx("input",{type:"number",value:ke,onChange:e=>Ce(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:[ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:ge,onChange:e=>fe(parseFloat(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:B.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(o,{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:R(ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:je,onChange:e=>ve(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:X.map(e=>t.jsxs("option",{value:e,children:["SF",e]},e))}),t.jsx(o,{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",ce.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",pe?"bg-white/5":"bg-white/[0.02]"),children:pe?t.jsxs(t.Fragment,{children:[t.jsx("select",{value:Ne,onChange:e=>we(parseInt(e.target.value)),className:"w-full bg-transparent text-text-primary focus:outline-none appearance-none cursor-pointer type-data pr-6",children:J.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))}),t.jsx(o,{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/",ce.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:[ce.preamble_length," symbols"]})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading radio configuration..."})]})})})]}),t.jsxs(q,{template:"standard",children:[t.jsx($,{span:12,md:6,children:t.jsx(z,{children:t.jsxs("div",{ref:He,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(d,{className:"icon-md text-icon-card-title"}),"Operating Mode"]}),t.jsx("div",{className:"flex items-center gap-1",children:Le?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"!==Ke){$e.current&&clearTimeout($e.current),ne(Q),qe("loading");try{const e=await A({tx_delay_factor:parseFloat(Ae),direct_tx_delay_factor:parseFloat(Me)});if(await se({max_airtime_percent:parseFloat(Oe),enforcement_enabled:me}),!pt.current)return void le(Q);e.success&&e.data?(await re({force:!0}),qe("success"),$e.current=setTimeout(()=>{pt.current&&(qe("idle"),Re(!1),le(Q))},1500)):(qe("error"),le(Q),$e.current=setTimeout(()=>{pt.current&&qe("idle")},2e3))}catch{if(!pt.current)return void le(Q);qe("error"),le(Q),$e.current=setTimeout(()=>{pt.current&&qe("idle")},2e3)}}},disabled:"loading"===Ke,className:_("p-2 rounded-lg transition-colors","loading"===Ke?"text-accent-primary cursor-wait":"success"===Ke?"text-accent-success":"error"===Ke?"text-accent-danger":"text-accent-success hover:bg-accent-success/10"),title:"Save",children:"loading"===Ke?t.jsx(n,{className:"w-4 h-4 animate-spin"}):"success"===Ke?t.jsx(l,{className:"w-4 h-4"}):"error"===Ke?t.jsx(r,{className:"w-4 h-4"}):t.jsx(l,{className:"w-4 h-4"})}),t.jsx("button",{onClick:Us,className:"p-2 rounded-lg text-text-muted hover:text-accent-danger hover:bg-accent-danger/10",title:"Cancel",children:t.jsx(r,{className:"w-4 h-4"})})]}):t.jsx("button",{onClick:Vs,className:"p-2 rounded-lg transition-colors text-text-muted hover:text-text-primary hover:bg-bg-subtle",title:"Edit settings",children:t.jsx(c,{className:"w-4 h-4"})})})]}),t.jsx("p",{className:"type-label text-text-muted mb-3",children:"Control how the repeater handles packets"}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[t.jsxs("div",{className:"flex-1 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("label",{className:"type-label text-text-muted",children:"Repeat"}),t.jsx("div",{className:"flex items-center gap-2",children:(()=>{const e=null!==dt?dt:"forward"===ue;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===lt)return;const t=!e,s="forward"===ue;ht.current&&clearTimeout(ht.current),bt.current&&clearTimeout(bt.current),ft.current=!1,ut(t),ct("loading"),ht.current=setTimeout(()=>{ft.current||pt.current&&(ut(s),ct("error"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null))},2e3))},1e4);try{if(await ee(t?"forward":"monitor"),ft.current=!0,ht.current&&clearTimeout(ht.current),!pt.current)return;ct("success"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null),te())},2e3)}catch{if(ft.current=!0,ht.current&&clearTimeout(ht.current),!pt.current)return;ut(s),ct("error"),bt.current=setTimeout(()=>{pt.current&&(ct("idle"),ut(null))},2e3)}},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"),"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"===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",{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!==mt?mt:me;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:async()=>{if("loading"===it)return;const t=!e,s=me;yt.current&&clearTimeout(yt.current),gt.current&&clearTimeout(gt.current),jt.current=!1,xt(t),ot("loading"),yt.current=setTimeout(()=>{jt.current||pt.current&&(xt(s),ot("error"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null))},2e3))},1e4);try{if(await se({max_airtime_percent:Ys(),enforcement_enabled:t}),jt.current=!0,yt.current&&clearTimeout(yt.current),!pt.current)return;ot("success"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null),ae())},2e3)}catch{if(jt.current=!0,yt.current&&clearTimeout(yt.current),!pt.current)return;xt(s),ot("error"),gt.current=setTimeout(()=>{pt.current&&(ot("idle"),xt(null))},2e3)}},disabled:"loading"===it,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"===it&&"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"===it&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===it&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===it&&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]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Oe,onChange:e=>ze(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:[Ys().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]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Ae,onChange:e=>De(e.target.value),step:"0.1",min:"0",max:"5",className:"w-12 bg-transparent text-text-primary text-right focus:outline-none type-data"}),t.jsx("span",{className:"text-text-muted type-data",children:"x"})]}):t.jsxs("span",{className:"type-data text-text-primary",children:[$s().toFixed(2),"x"]})})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"type-label text-text-muted",children:"Direct"}),t.jsx("div",{className:_("h-[32px] rounded-full px-3 flex items-center justify-end transition-colors min-w-[80px]",Le?"bg-white/5":"bg-white/[0.02]"),children:Le?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"number",value:Me,onChange:e=>Ie(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:[Hs().toFixed(2),"s"]})})]})]})]})]})]})})}),t.jsx($,{span:12,md:6,children:t.jsxs(z,{children:[t.jsx(K,{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!==kt?kt:(null==vt?void 0:vt.cors_enabled)??!1;return t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:Js,disabled:"loading"===Nt,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"===Nt&&"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"===Nt&&t.jsx(n,{className:"w-4 h-4 text-text-muted animate-spin"}),"success"===Nt&&t.jsx(l,{className:"w-4 h-4 text-accent-success"}),"error"===Nt&&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.jsx(U,{})]})]})]})})]}),t.jsx(q,{template:"auto",children:t.jsxs(z,{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:()=>ms(!0),disabled:"allow"===as,className:_("flex items-center gap-1.5 h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium","allow"===as?"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:ca,disabled:!cs||"allow"===as,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",cs&&"allow"!==as?"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:ia,disabled:!cs||"allow"===as,className:_("h-[32px] px-3 rounded-full transition-colors type-body-sm font-medium",cs&&"allow"!==as?"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"===as?"bg-accent-success/20":"bg-accent-danger/20"),children:"allow"===as?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:()=>na("deny"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","deny"===as?"bg-accent-danger/20 text-accent-danger":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Deny"}),t.jsx("button",{onClick:()=>na("allow"),disabled:ns,className:_("px-4 py-1.5 rounded-full transition-colors type-body-sm font-medium","allow"===as?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-secondary",ns&&"opacity-50"),children:"Allow"})]}),ns&&t.jsx(n,{className:"w-4 h-4 animate-spin text-text-muted"})]})]})}),ts&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:ts}),t.jsx("div",{className:"bg-white/[0.02] rounded-2xl p-4 min-h-[120px]",children:Zt?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===Wt.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:Wt.map(e=>t.jsx(Z,{node:e,level:0,expandedKeys:os,selectedKeyId:cs,globalFloodPolicy:as,onSelect:is,onToggle:ra},e.id))})})]})}),t.jsx(q,{template:"auto",children:t.jsxs(z,{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:()=>Mt(!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."})]})]})}),Rt&&t.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-accent-danger bg-accent-danger/10",children:Rt}),Pt&&0===Ft.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..."})]}):Ft.length>0?t.jsx("div",{className:"space-y-2",children:Ft.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: ",Zs(e.created_at)]}),t.jsxs("span",{className:"type-data-sm text-text-muted truncate",children:["Last used: ",Zs(e.last_used)]})]})]})]}),t.jsxs("button",{onClick:()=>Yt({id:e.id,name:e.name}),disabled:Bt,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:()=>Mt(!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(q,{template:"auto",children:t.jsxs(z,{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",Ss?"border-accent-primary bg-accent-primary/5":"border-transparent hover:border-accent-primary/30","loading"===Rs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:Ss,onChange:()=>Gs(!0),disabled:"loading"===Rs,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",Ss?"border-transparent hover:border-accent-primary/30":"border-accent-primary bg-accent-primary/5","loading"===Rs&&"opacity-50 pointer-events-none"),children:[t.jsx("input",{type:"radio",name:"frontend",checked:!Ss,onChange:()=>Gs(!1),disabled:"loading"===Rs,className:"mt-1 h-4 w-4 text-accent-primary focus:ring-accent-primary focus:ring-offset-bg-elevated"}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"type-body text-text-primary font-medium",children:"PyMC Console"}),t.jsx("span",{className:"type-data-xs bg-accent-secondary/15 text-accent-secondary px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),t.jsx("div",{className:"type-body-sm text-text-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),t.jsx("div",{className:"type-data-xs text-text-muted/60 mt-1 font-mono",children:"/opt/pymc_console/web/html"})]})]})]}),!Ps&&t.jsx("div",{className:_("bg-white/[0.02] rounded-2xl p-4",Fs?"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",Fs?"bg-accent-success/20":"bg-accent-tertiary/20"),children:Fs?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:Fs?"PyMC Console has been detected":"PyMC Console Not Installed"}),Fs?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"]})]})]})]})}),Ds&&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(!Is){Os(!0);try{await async function(){return S("/api/restart_service",{method:"POST",body:"{}"})}(),Ms(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{Ms(!1),setTimeout(()=>{window.location.reload()},3e3)}}},disabled:Is,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:Is?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(q,{template:"auto",children:t.jsxs(z,{children:[t.jsx(K,{icon:t.jsx(d,{}),title:"Node Information",largeTitle:!0}),V?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:de})]}),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",V.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",V.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:V.local_hash?t.jsx(D,{copy:!0,size:"compact",children:V.local_hash}):t.jsx("span",{className:"type-data-sm text-text-muted",children:"N/A"})})]})]}),V.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(D,{copy:!0,children:V.public_key})})]})]}):t.jsx("p",{className:"text-text-muted",children:"Loading node information..."})]})}),Dt&&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&&Mt(!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:It,onChange:e=>Ot(e.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",onKeyDown:e=>"Enter"===e.key&&Qs(),autoFocus:!0}),t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Give your token a descriptive name to identify its purpose"})]}),t.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{Mt(!1),Ot(""),At(null)},disabled:Vt,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:Qs,disabled:Vt||!It.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Vt?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),qt&&zt&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&$t(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-lg w-full shadow-2xl",children:[t.jsx("h3",{id:"show-token-modal-title",className:"type-subheading text-text-primary mb-4",children:"Token Created Successfully"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-accent-secondary/10 border border-accent-secondary/30 rounded-lg p-3",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(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:zt,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:()=>{zt&&(navigator.clipboard.writeText(zt),Gt(!0),setTimeout(()=>Gt(!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:[Jt?t.jsx(l,{className:"w-4 h-4 text-accent-success"}):t.jsx(w,{className:"w-4 h-4"}),Jt?"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: ',zt.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),t.jsx("div",{className:"flex justify-end mt-6",children:t.jsx("button",{onClick:()=>{$t(!1),Kt(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(M,{isOpen:!!Ht,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${null==Ht?void 0:Ht.name}'? This action cannot be undone.`,confirmLabel:Bt?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:async()=>{if(Ht){Xt(!0),At(null);try{await async function(e){return S(`/auth/tokens/${e}`,{method:"DELETE"})}(Ht.id),await Ws(),Yt(null)}catch(e){At(e instanceof Error?e.message:"Failed to revoke token")}finally{Xt(!1)}}},onCancel:()=>Yt(null)}),us&&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&&ms(!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:[cs&&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:aa()})]}),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:vs,onChange:e=>Ns(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&&la(),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:()=>ks("deny"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ws?"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:()=>ks("allow"),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ws?"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:()=>{ms(!1),Ns(""),ks("deny")},disabled:Cs,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:la,disabled:Cs||!vs.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:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),xs&&ys&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&ps(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:t.jsxs("div",{className:"bg-bg-elevated border border-border-subtle rounded-xl p-6 max-w-md w-full shadow-2xl",children:[t.jsx("h3",{id:"edit-key-modal-title",className:"type-subheading text-text-primary mb-4",children:"Edit Transport Key"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Key Name"}),t.jsx("input",{type:"text",value:ys.name,onChange:e=>gs({...ys,name:e.target.value}),className:"w-full px-4 py-2 bg-bg-subtle border border-border-subtle rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary/50 transition-colors",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Flood Policy"}),t.jsxs("div",{className:"flex bg-bg-subtle rounded-lg border border-border-subtle p-1",children:[t.jsx("button",{onClick:()=>gs({...ys,floodPolicy:"deny"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","deny"===ys.floodPolicy?"bg-accent-danger/20 text-accent-danger border border-accent-danger/50":"text-text-muted hover:text-text-secondary"),children:"DENY"}),t.jsx("button",{onClick:()=>gs({...ys,floodPolicy:"allow"}),className:_("flex-1 px-3 py-2 text-sm font-medium rounded transition-colors","allow"===ys.floodPolicy?"bg-accent-success/20 text-accent-success border border-accent-success/50":"text-text-muted hover:text-text-secondary"),children:"ALLOW"})]})]}),ys.transport_key&&t.jsxs("div",{children:[t.jsx("label",{className:"type-label text-text-muted block mb-2",children:"Transport Key"}),t.jsx("code",{className:"block bg-bg-subtle px-3 py-2 rounded-lg text-xs text-text-muted font-mono overflow-x-auto",children:ys.transport_key})]}),t.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[t.jsx("button",{onClick:()=>{ps(!1),js(ys),bs(!0),gs(null)},disabled:Cs,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:()=>{ps(!1),gs(null)},disabled:Cs,className:"px-4 py-2 bg-bg-subtle hover:bg-bg-elevated text-text-secondary rounded-lg border border-border-subtle transition-colors disabled:opacity-50",children:"Cancel"}),t.jsx("button",{onClick:async()=>{if(ys){_s(!0),ss(null);try{const e=await async function(e,t){return S(`/api/transport_key/${e}`,{method:"PUT",body:JSON.stringify(t)})}(ys.id,{name:ys.name,flood_policy:ys.floodPolicy});e.success?(await ta(),ps(!1),gs(null)):ss(e.error||"Failed to update transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to update transport key")}finally{_s(!1)}}},disabled:Cs||!ys.name.trim(),className:"px-4 py-2 bg-accent-primary/20 hover:bg-accent-primary/30 text-text-primary rounded-lg border border-accent-primary/50 transition-colors disabled:opacity-50 flex items-center gap-2",children:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),hs&&fs&&t.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:e=>e.target===e.currentTarget&&bs(!1),role:"dialog","aria-modal":"true","aria-labelledby":"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:["'",fs.name,"'"]}),"?"]}),fs.children&&fs.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 ",fs.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:()=>{bs(!1),js(null)},disabled:Cs,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(fs){_s(!0),ss(null);try{const e=await async function(e){return S(`/api/transport_key/${e}`,{method:"DELETE"})}(fs.id);e.success?(await ta(),bs(!1),js(null),is(null)):ss(e.error||"Failed to delete transport key")}catch(e){ss(e instanceof Error?e.message:"Failed to delete transport key")}finally{_s(!1)}}},disabled:Cs,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:Cs?t.jsxs(t.Fragment,{children:[t.jsx(n,{className:"w-4 h-4 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{ee as default}; diff --git a/frontend/dist/assets/Contacts-D7dmBQTJ.js b/frontend/dist/assets/Contacts-Dm2Yh1zu.js similarity index 98% rename from frontend/dist/assets/Contacts-D7dmBQTJ.js rename to frontend/dist/assets/Contacts-Dm2Yh1zu.js index c23c53f5..ae4242c3 100644 --- a/frontend/dist/assets/Contacts-D7dmBQTJ.js +++ b/frontend/dist/assets/Contacts-Dm2Yh1zu.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-CyTSx1md.js","assets/vendor-react-DtVWNgeu.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-v5IA77Bo.js","assets/index-BIsccma_.js","assets/ConfirmModal-Dq3wq7Fw.js","assets/useThemeColors-DaJMJYCA.js","assets/BasemapLayer-00O5HUtM.js","assets/ping-SvrcEczO.js","assets/PageLayout-CG02PCA-.js","assets/DataBox-Dl3NmnnB.js","assets/SignalIndicator-DagI_WOB.js","assets/CollisionExplorerModal-CZ-TWl8d.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-BvCAJWnK.css","assets/leaflet-CIGW-MKW.css"])))=>i.map(i=>d[i]); -import{j as e,r as s,ac as t,a8 as a,z as n,h as l,ad as c,k as i,ae as r,Z as o,af as d,T as x,A as m,a1 as h,ag as p,ah as u,ab as g,a7 as j,a0 as b,a6 as N,ai as v,o as f,aj as y,ak as w,Y as k,al as C,p as S,am as M,X as L,an as H,ao as P,ap as F,aq as E,ar as R,as as T,at as $,a5 as _,au as A,av as O}from"./vendor-react-DtVWNgeu.js";import{H as D,I as z,E as G,J as U,K as W,M as I,p as K,N as V,d as B,O as q,f as J,Q,S as Y,U as Z,e as X,n as ee,V as se}from"./index-BIsccma_.js";import{p as te}from"./ping-SvrcEczO.js";import{P as ae,b as ne}from"./PageLayout-CG02PCA-.js";import{_ as le}from"./deckgl-DTsmDcfs.js";import{c as ce,L as ie,T as re,a as oe}from"./recharts-C9LxPobD.js";import{D as de}from"./DataBox-Dl3NmnnB.js";import{a as xe}from"./SignalIndicator-DagI_WOB.js";import{C as me}from"./CollisionExplorerModal-CZ-TWl8d.js";import{C as he}from"./ConfirmModal-Dq3wq7Fw.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-CyTSx1md.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));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 ke({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 k=s.useMemo(()=>Array.from(t.commonNeighbors).map(e=>{var s;return{hash:e,name:null==(s=n[e])?void 0:s.name}}),[t.commonNeighbors,n]),C=t.estimatedLocation?t.estimatedLocation.uncertaintyM>=1e3?`±${(t.estimatedLocation.uncertaintyM/1e3).toFixed(1)}km`:`±${Math.round(t.estimatedLocation.uncertaintyM)}m`:null,S=j&&t.temporal?(M=t.temporal.consistency)>=.7?{label:"Steady",color:"text-accent-success"}:M>=.4?{label:"Regular",color:"text-accent-tertiary"}:M>=.2?{label:"Sporadic",color:"text-accent-secondary"}:{label:"Bursty",color:"text-signal-poor"}:null;var M;const L=j&&t.collisionCandidates&&t.collisionCandidates.length>0,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-sm",children:[e.jsx("span",{className:"font-mono font-medium text-text-secondary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:"text-text-muted",children:t.observationCount})]}):e.jsxs("div",{className: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-sm font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:ce("text-sm mt-0.5",g.textClass),children:(null==(p=t.classification)?void 0:p.reason)??"Unknown"}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-text-muted mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3"}),t.observationCount]}),e.jsxs("span",{children:[(100*t.confidence).toFixed(0),"%"]}),t.commonNeighbors.size>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(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"}),C]}),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-sm",children:[e.jsx(v,{className:"w-4 h-4 text-signal-poor flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-signal-poor font-medium",children:"Possible collision with known node"}),e.jsx("div",{className:"text-text-secondary mt-0.5",children: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,{copy:!0,size:"compact",className:"inline",children:H.knownNodeHash})," ","(",(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-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:[t.estimatedLocation.lat.toFixed(5),", ",t.estimatedLocation.lon.toFixed(5)]}),e.jsxs("div",{className:"text-text-muted",children:["Uncertainty: ",C]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",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-sm text-text-muted",children:[e.jsx(a,{className:"w-4 h-4 text-signal-poor"}),"Location unknown (neighbors lack coordinates)"]}),j&&t.temporal&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:["Temporal Pattern: ",e.jsx("span",{className:null==S?void 0:S.color,children:null==S?void 0:S.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 mt-1 text-text-muted",children:[e.jsxs("span",{children:["Distinct hours: ",t.temporal.distinctHours]}),e.jsxs("span",{children:["Distinct days: ",t.temporal.distinctDays]}),e.jsxs("span",{children:["Burstiness: ",(100*t.temporal.burstiness).toFixed(0),"%"]}),e.jsxs("span",{children:["Consistency: ",(100*t.temporal.consistency).toFixed(0),"%"]}),e.jsxs("span",{children:["Last 24h: ",t.temporal.last24HourCount," obs"]}),e.jsxs("span",{children:["Active hours: ",t.temporal.activeHoursLast24,"/24"]})]})]})]}),!j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(f,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",U(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",U(t.lastSeen)," ago"]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(y,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",U(t.firstSeen)," – ",U(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),k.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",k.length," known node",1!==k.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,5).map(({hash:s})=>e.jsx(de,{copy:!0,size:"compact",children:s},s)),k.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",k.length-5," more"]})]})]})]}),j&&t.validationStages&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1.5 uppercase tracking-wide",children:"Validation Stages"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(Ce,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(Ce,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(Ce,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(Ce,{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 Ce({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(k,{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,k]=s.useState(!0),[C,S]=s.useState(Date.now);s.useEffect(()=>{S(Date.now())},[o]);const M=s.useMemo(()=>o.filter(e=>!function(e,s){return s-1e3*e.lastSeen>6048e5}(e,C)),[o,C]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),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:T}=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 $=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",T>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-accent-success/20 text-accent-success",children:[T," 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:()=>k(e=>!e),className:"flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-elevated text-text-muted hover:text-text-secondary transition-colors",title:w?"Expand panel":"Minimize panel",children:w?e.jsx(p,{className:"w-3 h-3"}):e.jsx(m,{className:"w-3 h-3"})})]})]}),w?e.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 text-xs cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>k(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===N&&0===T&&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=W(s),o=I(),d=!K().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})]})})}),Te=s.memo(function({hash:t,className:a="",size:n="sm"}){const l=V(),c=z(),[i,o]=s.useState(!1),d=s.useMemo(()=>B(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(C,{className:u})}),e.jsx(me,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function $e(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=Q(),l=Y(),c=Z(),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(""),[k,C]=s.useState(!1),[D,z]=s.useState(null),[U,W]=s.useState(null),[I,K]=s.useState(null),[V,B]=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]),ke=null==t?void 0:t.local_hash,Ce=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,$e(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=k||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,k,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=Ce.get(e)??null,a=Ce.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,Ce,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,k,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(),!V){B(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 te(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{B(null)}}},[V]);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:ke,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:ze,highlightedEdgeKey:U,highlightedGhost:I}):e.jsx("div",{className:"glass-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),e.jsx(fe,{maxPaths:10,highlightedEdge:U,onHighlightEdge:W}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Se,{neighbors:ye,onGhostSelect:K})}):e.jsxs("div",{className:"glass-card",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-6 h-6 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-20 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]})})]})),e.jsx("div",{className:"chart-container",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(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:()=>C(!k),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-sm rounded-lg transition-colors "+(k?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:k?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),e.jsx("span",{className:"sm:hidden tabular-nums",children: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-sm bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),y&&e.jsx("button",{onClick:()=>{w(""),"neighbor"!==y.toLowerCase().trim()&&"neighbors"!==y.toLowerCase().trim()||C(!1)},className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:e.jsx(L,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[e.jsxs("button",{onClick:()=>Oe("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("lastHeard"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[e.jsx(f,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===p&&e.jsx(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-sm rounded-lg transition-colors "+("distance"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[e.jsx(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-sm rounded-lg transition-colors "+("centrality"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[e.jsx(d,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===p&&e.jsx(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-sm text-text-muted hover:text-text-secondary hover:bg-white/5 rounded-lg transition-colors",title:"Items per page",children:[e.jsx("span",{className:"tabular-nums",children:0===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-sm 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=Ce.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(T,{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($,{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,{copy:!0,size:"compact",children:s}),e.jsx(Te,{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?se(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!==V,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:V===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,Te as P}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-BJZGJRTF.js","assets/vendor-react-DtVWNgeu.js","assets/vendor-core-WoOfkQwm.js","assets/link-scoring-t1Ov70gg.js","assets/index-Bmit1I8S.js","assets/ConfirmModal-Dq3wq7Fw.js","assets/useThemeColors-DaJMJYCA.js","assets/BasemapLayer-00O5HUtM.js","assets/ping-BBb1dLdC.js","assets/PageLayout-CG02PCA-.js","assets/DataBox-Dl3NmnnB.js","assets/SignalIndicator-DagI_WOB.js","assets/CollisionExplorerModal-gzC3uL5Q.js","assets/maplibre-gl-B1CfjdFi.css","assets/index-BvCAJWnK.css","assets/leaflet-CIGW-MKW.css"])))=>i.map(i=>d[i]); +import{j as e,r as s,ac as t,a8 as a,z as n,h as l,ad as c,k as i,ae as r,Z as o,af as d,T as x,A as m,a1 as h,ag as p,ah as u,ab as g,a7 as j,a0 as b,a6 as N,ai as v,o as f,aj as y,ak as w,Y as k,al as C,p as S,am as M,X as L,an as H,ao as P,ap as F,aq as E,ar as R,as as T,at as $,a5 as _,au as A,av as O}from"./vendor-react-DtVWNgeu.js";import{H as D,I as z,E as G,J as U,K as W,M as I,p as K,N as V,d as B,O as q,f as J,Q,S as Y,U as Z,e as X,n as ee,V as se}from"./index-Bmit1I8S.js";import{p as te}from"./ping-BBb1dLdC.js";import{P as ae,b as ne}from"./PageLayout-CG02PCA-.js";import{_ as le}from"./deckgl-DTsmDcfs.js";import{c as ce,L as ie,T as re,a as oe}from"./recharts-C9LxPobD.js";import{D as de}from"./DataBox-Dl3NmnnB.js";import{a as xe}from"./SignalIndicator-DagI_WOB.js";import{C as me}from"./CollisionExplorerModal-gzC3uL5Q.js";import{C as he}from"./ConfirmModal-Dq3wq7Fw.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-BJZGJRTF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));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 ke({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 k=s.useMemo(()=>Array.from(t.commonNeighbors).map(e=>{var s;return{hash:e,name:null==(s=n[e])?void 0:s.name}}),[t.commonNeighbors,n]),C=t.estimatedLocation?t.estimatedLocation.uncertaintyM>=1e3?`±${(t.estimatedLocation.uncertaintyM/1e3).toFixed(1)}km`:`±${Math.round(t.estimatedLocation.uncertaintyM)}m`:null,S=j&&t.temporal?(M=t.temporal.consistency)>=.7?{label:"Steady",color:"text-accent-success"}:M>=.4?{label:"Regular",color:"text-accent-tertiary"}:M>=.2?{label:"Sporadic",color:"text-accent-secondary"}:{label:"Bursty",color:"text-signal-poor"}:null;var M;const L=j&&t.collisionCandidates&&t.collisionCandidates.length>0,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-sm",children:[e.jsx("span",{className:"font-mono font-medium text-text-secondary",children:t.prefix.toUpperCase()}),e.jsx("span",{className:"text-text-muted",children:t.observationCount})]}):e.jsxs("div",{className: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-sm font-medium",g.badgeClass),children:g.label})]}),e.jsx("div",{className:ce("text-sm mt-0.5",g.textClass),children:(null==(p=t.classification)?void 0:p.reason)??"Unknown"}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-text-muted mt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(r,{className:"w-3 h-3"}),t.observationCount]}),e.jsxs("span",{children:[(100*t.confidence).toFixed(0),"%"]}),t.commonNeighbors.size>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(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"}),C]}),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-sm",children:[e.jsx(v,{className:"w-4 h-4 text-signal-poor flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-signal-poor font-medium",children:"Possible collision with known node"}),e.jsx("div",{className:"text-text-secondary mt-0.5",children: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,{copy:!0,size:"compact",className:"inline",children:H.knownNodeHash})," ","(",(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-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:[t.estimatedLocation.lat.toFixed(5),", ",t.estimatedLocation.lon.toFixed(5)]}),e.jsxs("div",{className:"text-text-muted",children:["Uncertainty: ",C]}),j&&t.location&&e.jsxs("div",{className:"mt-1 text-text-muted",children:[e.jsxs("div",{children:["Method: ",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-sm text-text-muted",children:[e.jsx(a,{className:"w-4 h-4 text-signal-poor"}),"Location unknown (neighbors lack coordinates)"]}),j&&t.temporal&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(d,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary font-medium",children:["Temporal Pattern: ",e.jsx("span",{className:null==S?void 0:S.color,children:null==S?void 0:S.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 mt-1 text-text-muted",children:[e.jsxs("span",{children:["Distinct hours: ",t.temporal.distinctHours]}),e.jsxs("span",{children:["Distinct days: ",t.temporal.distinctDays]}),e.jsxs("span",{children:["Burstiness: ",(100*t.temporal.burstiness).toFixed(0),"%"]}),e.jsxs("span",{children:["Consistency: ",(100*t.temporal.consistency).toFixed(0),"%"]}),e.jsxs("span",{children:["Last 24h: ",t.temporal.last24HourCount," obs"]}),e.jsxs("span",{children:["Active hours: ",t.temporal.activeHoursLast24,"/24"]})]})]})]}),!j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(f,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["First seen: ",U(t.firstSeen)," ago"]}),e.jsxs("div",{className:"text-text-muted",children:["Last seen: ",U(t.lastSeen)," ago"]})]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(y,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-primary",children:["Active period: ",U(t.firstSeen)," – ",U(t.lastSeen)," ago"]}),t.temporal&&e.jsxs("div",{className:"text-text-muted",children:["Obs/hour avg: ",t.temporal.observationsPerHour.toFixed(1)]})]})]}),k.length>0&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(b,{className:"w-4 h-4 text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"text-text-muted mb-1",children:["Adjacent to ",k.length," known node",1!==k.length?"s":"",":"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.slice(0,5).map(({hash:s})=>e.jsx(de,{copy:!0,size:"compact",children:s},s)),k.length>5&&e.jsxs("span",{className:"text-text-muted",children:["+",k.length-5," more"]})]})]})]}),j&&t.validationStages&&e.jsxs("div",{className:"pt-2 border-t border-border-muted/30",children:[e.jsx("div",{className:"text-[10px] text-text-muted mb-1.5 uppercase tracking-wide",children:"Validation Stages"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(Ce,{label:"Candidates",passed:t.validationStages.candidateExhaustion}),e.jsx(Ce,{label:"Temporal",passed:t.validationStages.temporalConsistency}),e.jsx(Ce,{label:"Topology",passed:t.validationStages.topologicalFit}),e.jsx(Ce,{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 Ce({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(k,{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,k]=s.useState(!0),[C,S]=s.useState(Date.now);s.useEffect(()=>{S(Date.now())},[o]);const M=s.useMemo(()=>o.filter(e=>!function(e,s){return s-1e3*e.lastSeen>6048e5}(e,C)),[o,C]),L=s.useMemo(()=>{const e=Array.from(x);return e.length>0?e[0]:null},[x]),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:T}=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 $=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",T>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-accent-success/20 text-accent-success",children:[T," 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:()=>k(e=>!e),className:"flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-elevated text-text-muted hover:text-text-secondary transition-colors",title:w?"Expand panel":"Minimize panel",children:w?e.jsx(p,{className:"w-3 h-3"}):e.jsx(m,{className:"w-3 h-3"})})]})]}),w?e.jsxs("div",{className:"px-5 py-3 flex items-center gap-3 text-xs cursor-pointer hover:bg-white/5 transition-colors",onClick:()=>k(!1),children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:x.has(s.prefix),onToggle:()=>$(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(ke,{ghost:s,neighbors:t,isExpanded:!1,onToggle:()=>{},compact:!0},s.prefix))})]}),"actionable"===N&&0===T&&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=W(s),o=I(),d=!K().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})]})})}),Te=s.memo(function({hash:t,className:a="",size:n="sm"}){const l=V(),c=z(),[i,o]=s.useState(!1),d=s.useMemo(()=>B(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(C,{className:u})}),e.jsx(me,{isOpen:i,prefix:x.prefix,candidateHashes:x.candidateHashes,onClose:p})]})});function $e(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=Q(),l=Y(),c=Z(),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(""),[k,C]=s.useState(!1),[D,z]=s.useState(null),[U,W]=s.useState(null),[I,K]=s.useState(null),[V,B]=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]),ke=null==t?void 0:t.local_hash,Ce=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,$e(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=k||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,k,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=Ce.get(e)??null,a=Ce.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,Ce,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,k,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(),!V){B(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 te(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{B(null)}}},[V]);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:ke,onRemoveNode:n,selectedNodeHash:D,onNodeSelected:ze,highlightedEdgeKey:U,highlightedGhost:I}):e.jsx("div",{className:"glass-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading map..."})]})}),e.jsx(fe,{maxPaths:10,highlightedEdge:U,onHighlightEdge:W}),o.length>0&&(x?e.jsx("div",{className:"chart-container",children:e.jsx(Se,{neighbors:ye,onGhostSelect:K})}):e.jsxs("div",{className:"glass-card",children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-4 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-6 h-6 rounded bg-bg-elevated animate-pulse"})]}),e.jsx("div",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-20 h-4 rounded bg-bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-bg-elevated animate-pulse"})]})})]})),e.jsx("div",{className:"chart-container",children:x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"chart-header",children:[e.jsxs("div",{className:"chart-title",children:[e.jsx(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:()=>C(!k),className:"flex items-center gap-1 px-1.5 sm:px-2.5 py-1.5 text-sm rounded-lg transition-colors "+(k?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-secondary hover:bg-white/5 border border-transparent"),title:k?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(S,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Neighbors"}),e.jsx("span",{className:"sm:hidden tabular-nums",children: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-sm bg-white/5 border border-white/10 rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-primary/50"}),y&&e.jsx("button",{onClick:()=>{w(""),"neighbor"!==y.toLowerCase().trim()&&"neighbors"!==y.toLowerCase().trim()||C(!1)},className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary p-0.5",children:e.jsx(L,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[e.jsxs("button",{onClick:()=>Oe("lastHeard"),className:"flex items-center gap-1 p-1.5 sm:px-2 sm:py-1.5 text-sm rounded-lg transition-colors "+("lastHeard"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by last heard",children:[e.jsx(f,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Recent"}),"lastHeard"===p&&e.jsx(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-sm rounded-lg transition-colors "+("distance"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by distance",children:[e.jsx(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-sm rounded-lg transition-colors "+("centrality"===p?"bg-accent-primary/20 text-accent-primary":"text-text-muted hover:text-text-secondary hover:bg-white/5"),title:"Sort by network centrality",children:[e.jsx(d,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Centrality"}),"centrality"===p&&e.jsx(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-sm text-text-muted hover:text-text-secondary hover:bg-white/5 rounded-lg transition-colors",title:"Items per page",children:[e.jsx("span",{className:"tabular-nums",children:0===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-sm 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=Ce.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(T,{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($,{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,{copy:!0,size:"compact",children:s}),e.jsx(Te,{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?se(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!==V,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:V===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,Te as P}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-CyTSx1md.js b/frontend/dist/assets/ContactsMapMapLibre-BJZGJRTF.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-CyTSx1md.js rename to frontend/dist/assets/ContactsMapMapLibre-BJZGJRTF.js index 7e09efd4..a20dbd4f 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-CyTSx1md.js +++ b/frontend/dist/assets/ContactsMapMapLibre-BJZGJRTF.js @@ -1 +1 @@ -import{r as A,b as e,j as t,ab as r,ac as n,bd as o,be as i,h as a,a5 as s,ap as l,V as c,a2 as u,ae as f,k as d,aP as g,aV as h,bf as m,bg as b,bh as p,bi as v,bj as x,ag as w,A as y,aL as k,Z as C,bk as B,c as M,bl as D,X as E,bm as Q,a9 as N,bn as j,av as F,b6 as S,bo as P,$ as I,o as L,ao as R,a6 as T,bp as _,b9 as H,ba as z,bc as G,b8 as O,bq as U}from"./vendor-react-DtVWNgeu.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as Y,c as W}from"./link-scoring-v5IA77Bo.js";import{E as V,I as Z,T as K,k as J,aq as X,ar as q,d as $,as as AA,V as eA,at as tA,au as rA,e as nA,p as oA,av as iA,aw as aA}from"./index-BIsccma_.js";import{C as sA}from"./ConfirmModal-Dq3wq7Fw.js";import{c as lA}from"./recharts-C9LxPobD.js";import{g as cA,f as uA,h as fA,i as dA}from"./useThemeColors-DaJMJYCA.js";import{p as gA,a as hA}from"./vendor-core-WoOfkQwm.js";import{u as mA,a as bA,B as pA}from"./BasemapLayer-00O5HUtM.js";import{P as vA,N as xA}from"./Contacts-D7dmBQTJ.js";import"./deckgl-DTsmDcfs.js";import"./ping-SvrcEczO.js";import"./PageLayout-CG02PCA-.js";import"./DataBox-Dl3NmnnB.js";import"./SignalIndicator-DagI_WOB.js";import"./CollisionExplorerModal-CZ-TWl8d.js";import"./leaflet-D_ckmI2R.js";function wA(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 yA({label:A,icon:e,status:n,detail:o}){return t.jsxs("div",{className:lA("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-primary/10 ring-2 ring-inset ring-accent-primary","pending"===n&&"opacity-40"),children:[t.jsx("div",{className:lA("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-primary/20","pending"===n&&"bg-white/5"),children:"complete"===n?t.jsx(r,{className:"w-4 h-4 text-accent-primary"}):"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:lA("text-sm font-medium transition-colors","active"===n&&"text-accent-primary","complete"===n&&"text-accent-primary","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 kA=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 f="complete"===l,d=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(yA,{label:"Analyzing Database",icon:t.jsx(i,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),t.jsx(yA,{label:"Building Topology",icon:t.jsx(n,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),t.jsx(yA,{label:"Discovering Nodes",icon:t.jsx(a,{className:"w-4 h-4"}),status:d("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)}),CA={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 BA(){if("undefined"==typeof window)return CA;const A=cA(),e=uA();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:CA.edges.neighborRest,neighborHover:CA.edges.neighborHover,highlight:e.highlight},edgeOpacity:CA.edgeOpacity}}const MA=2e3;function DA({text:A}){return t.jsx(K,{content:A,delay:200,children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted cursor-help"})})}function EA({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(DA,{text:e})]}),t.jsx(d,{className:"w-3 h-3 text-text-muted transition-transform duration-200 "+(r?"":"-rotate-90")})]})}function QA({showTopology:e,validatedPolylineCount:r,filteredNeighborCount:n,hasLocalNode:o,meshTopology:i,zeroHopNeighbors:s,neighborsWithLocation:d}){const g=fA(),h=V(),m=Z(),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),[v,x]=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(EA,{title:"Nodes",tooltip:"Node type shown by shape. Yellow = direct RF neighbor.",isOpen:v,onToggle:()=>x(!v)}),v&&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(DA,{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(DA,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow."})]}),(B=d,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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(EA,{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:Y.YELLOW}}),t.jsx("span",{className:"text-text-muted",children:"2-Way"}),t.jsx(DA,{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:Y.GREEN}}),t.jsx("span",{className:"text-text-muted",children:"Listener"}),t.jsx(DA,{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:Y.RED}}),t.jsx("span",{className:"text-text-muted",children:"Loud"}),t.jsx(DA,{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(EA,{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:CA.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:CA.edges.hoverLoop}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:CA.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(f,{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 jA({mapRef:A,showNeighborLines:e,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:c,show3DTerrain:u,onToggle3DTerrain:f,basemapMode:d,onToggleBasemap:g,isFullscreen:C,onToggleFullscreen:B}){const M=[{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")})}),M.length>1&&t.jsx(NA,{options:M,value:o,onChange:i,size:"sm"}),t.jsx("button",{onClick:g,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:"light"===d?{backgroundColor:"#0a1520"}:void 0,title:"light"===d?"Switch to dark map":"Switch to light map","aria-label":"light"===d?"Switch to dark map":"Switch to light map","aria-pressed":"light"===d,children:"light"===d?t.jsx(m,{className:"map-control-icon text-sky-400"}):t.jsx(b,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:f,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(p,{className:"map-control-icon "+(u?"text-teal-400":"text-text-secondary")})}),t.jsx("button",{onClick:B,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",title:C?"Exit fullscreen":"Fullscreen","aria-label":C?"Exit fullscreen":"Enter fullscreen","aria-pressed":C,children:C?t.jsx(v,{className:"map-control-icon text-text-secondary"}):t.jsx(x,{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(w,{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(y,{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(k,{className:"map-control-icon text-text-secondary"})})]})})]})}const FA="#4ADE80",SA="DeepAnalysis";function PA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function IA({isActive:e,hasAnalyzed:r,isLoading:o,onClick:i}){const[a,l]=A.useState(!1),[c,u]=A.useState(SA),f=A.useRef(!1),d=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&&!f.current){f.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{d.current&&cancelAnimationFrame(d.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":"var(--bg-body)"},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:FA}: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:FA}:{}},children:m})]})}const LA="#00FFFF";function RA({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),f=A.useRef(!1),[d]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!e&&d;A.useEffect(()=>{g&&!f.current&&(f.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(f.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!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&&Ad&&o(!0),onMouseLeave:()=>d&&o(!1),onPointerEnter:()=>d&&o(!0),onPointerLeave:()=>d&&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":"var(--bg-body)"},title:e?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[t.jsx(C,{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 TA="#fe8019";function _A({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)),f=u<.999,d=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":"var(--bg-body)"},title:e?"Configure wardriving coverage":"Show wardriving coverage",children:[t.jsx(B,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-amber-400":"text-text-secondary"),style:g?{color:TA}: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:TA}:{}},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:!d,className:"p-0.5 rounded transition-colors "+(d?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:t.jsx(b,{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:!f,className:"p-0.5 rounded transition-colors "+(f?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:t.jsx(m,{className:"w-3.5 h-3.5"})})]})]})}function HA(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 zA(A){return Math.exp(-A*Math.LN2/7)}const GA="pymc-wardriving-url",OA="pymc-wardriving-enabled",UA="pymc-wardriving-brightness";function YA(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(GA,A):localStorage.removeItem(GA))}function WA(A){"undefined"!=typeof localStorage&&localStorage.setItem(OA,String(A))}function VA(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(UA);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function ZA(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 KA=M((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(OA),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(GA)||"",brightness:VA(),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(UA,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;WA(t),A({isVisible:t})},setVisible:e=>{WA(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}=HA(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=zA(i),s=ZA(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()}),YA(e.trim()),WA(!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:""}),YA(""),WA(!1)}}));function JA({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 XA(){const{isModalOpen:e,closeModal:n,status:i,isVisible:a,stats:l,error:c,url:u,brightness:d,loadCoverage:g,clearCoverage:h,toggleVisibility:b,setUrl:p,setBrightness:v}=KA(),x="connecting"===i||"loading"===i||"processing"===i,[w,y]=A.useState(u),k=A.useCallback(async()=>{await g(w)},[w,g]),C=A.useCallback(()=>{y(""),h()},[h]),B=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||x||(A.preventDefault(),k())},[k,x]),M=A.useCallback(A=>{const e=A.target.value;y(e),p(e)},[p]);if(!e)return null;const P=l.coverageCount>0,I=w.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:w,onChange:M,onKeyDown:B,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(JA,{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(Q,{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&&P&&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"]})]})]}),P&&!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(N,{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()}`]})]})]}),P&&!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(m,{className:"w-4 h-4 flex-shrink-0 "+(d>.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*d),"%"]})]}),t.jsx("input",{type:"range",min:"1",max:"100",value:100*d,onChange:A=>v(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:P&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:b,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(f,{className:"w-3.5 h-3.5"})," Show"]})}),t.jsxs("button",{onClick:C,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(F,{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:P?"Done":"Cancel"}),t.jsx("button",{onClick:k,disabled:!I,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..."]}):P?t.jsxs(t.Fragment,{children:[t.jsx(o,{className:"w-4 h-4"}),"Refresh"]}):t.jsxs(t.Fragment,{children:[t.jsx(S,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}const qA={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{}}},$A=M()(gA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:hA(()=>qA)}));var Ae=function(A){var e,t=void 0!==(A=A||{})?A:{},r={};for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);var n,o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",n=function(A,e,t){var r=new XMLHttpRequest;r.open("GET",A,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)e(r.response);else{var n=O(A);n?e(n.buffer):t()}},r.onerror=t,r.send(null)};var i=t.print||function(){}.bind(),a=t.printErr||function(){}.bind();for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);r=null,t.arguments&&t.arguments;var s=0,l=!1;function c(A){var e=t["_"+A];return e||tA("Assertion failed: "+("Cannot call unknown function "+A+", make sure it is exported")),e}var u,f,d,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function v(A,e){return A?function(A,e,t){for(var r=e+t,n=e;A[n]&&!(n>=r);)++n;if(n-e>16&&A.subarray&&p)return p.decode(A.subarray(e,n));for(var o="";e>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|a)}else o+=String.fromCharCode(i)}return o}(d,A,e):""}function x(A,e){return A%e>0&&(A+=e-A%e),A}function w(A){u=A,t.HEAP8=f=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=d=new Uint8Array(A),t.HEAPU16=new Uint16Array(A),t.HEAPU32=new Uint32Array(A),t.HEAPF32=m=new Float32Array(A),t.HEAPF64=b=new Float64Array(A)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var y=t.TOTAL_MEMORY||33554432;function k(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?t.dynCall_v(r):t.dynCall_vi(r,e.arg):r(void 0===e.arg?null:e.arg)}else e()}}y=(u=t.buffer?t.buffer:new ArrayBuffer(y)).byteLength,w(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function Q(A){D.unshift(A)}var N=Math.abs,j=Math.ceil,F=Math.floor,S=Math.min,P=0,I=null;t.preloadedImages={},t.preloadedAudios={};var L,R,T=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return f.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|L(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|L(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return F=i,0|a}function I(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=F,F=F+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return F=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 F=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|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+(d<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(d<<2)>>2]=h,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|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+(d<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else s=0}while(0);return F=a,0|s}function L(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0;if(u=F,F=F+16|0,l=u+8|0,c=u,f=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(f<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(d=(0|p)==(0|A)&(0|b)==(0|e))))do{f=0|$e(0|(f=0|Ve(0|f,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),d=(0|(b=0|n[(p=h=r+(f<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|d));if(f=o+(f<<2)|0,d&&(0|n[f>>2])<=(0|s))return F=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[f>>2]=s,(0|s)>=(0|t))return F=u,0;switch(d=s+1|0,n[l>>2]=0,0|(f=0|R(A,e,2,l,c))){case 9:m=9;break;case 0:(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(f=0|R(A,e,3,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,1,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,5,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,4,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,6,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}return F=u,0}}while(0);return F=u,0|f}function R(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if((t|=0)>>>0>6)return 1;if(f=(0|n[(r|=0)>>2])%6|0,n[r>>2]=f,(0|f)>0){s=0;do{t=0|vA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(f=0|tt(0|A,0|e,45),B(),(a=127&f)>>>0>121)return 5;i=0|OA(A,e),s=0|tt(0|A,0|e,52),B(),s&=15;A:do{if(s){for(;;){if(c=0|tt(0|A,0|e,0|(l=3*(15-s|0)|0)),B(),7==(0|(c&=7))){e=5;break}if(g=!(0|ZA(s)),s=s+-1|0,d=0|rt(7,0,0|l),e&=~B(),A=0|rt(0|n[(g?432:16)+(28*c|0)+(t<<2)>>2],0,0|l)|A&~d,e|=l=0|B(),!(t=0|n[(g?640:224)+(28*c|0)+(t<<2)>>2])){t=0;break A}if(!s){u=8;break A}}return 0|e}u=8}while(0);8==(0|u)&&(A|=0|rt(0|(g=0|n[848+(28*a|0)+(t<<2)>>2]),0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+(t<<2)>>2],127&~g||(g=0|rt(0|n[848+(28*a|0)+20>>2],0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+20>>2],A=0|YA(g|A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]))),c=0|tt(0|A,0|e,45),B(),c&=127;A:do{if(0|z(c)){e:do{if(1==(0|OA(A,e))){if((0|a)!=(0|c)){if(0|Y(c,0|n[7696+(28*a|0)>>2])){A=0|VA(A,e),l=1,e=0|B();break}M(27795,26864,533,26872)}switch(0|i){case 3:A=0|YA(A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]),l=0;break e;case 5:A=0|VA(A,e),e=0|B(),n[r>>2]=5+(0|n[r>>2]),l=0;break e;case 0:return 9;default:return 1}}else l=0}while(0);if((0|t)>0){s=0;do{A=0|UA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}if((0|a)!=(0|c)){if(!(0|G(c))){if(!!(0|l)|5!=(0|OA(A,e)))break;n[r>>2]=1+(0|n[r>>2]);break}switch(127&f){case 8:case 118:break A}3!=(0|OA(A,e))&&(n[r>>2]=1+(0|n[r>>2]))}}else if((0|t)>0){s=0;do{A=0|YA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}}while(0);return n[r>>2]=((0|n[r>>2])+t|0)%6|0,n[(g=o)>>2]=A,n[g+4>>2]=e,0}function 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,f=0,d=0,g=0,h=0;if(i=F,F=F+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return F=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,F=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[(d=r)>>2]=g,n[d+4>>2]=e,d=t+-1|0,f=0,A=1;do{if(a=26800+(f<<2)|0,5==(0|f))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|R(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|d)){if(c=0|n[(u=o)>>2],u=0|n[u+4>>2],n[(A=r+(a<<3)|0)>>2]=c,n[A+4>>2]=u,0|HA(c,u)){A=9;break A}A=a+1|0}else A=a;if((0|(s=s+1|0))>=(0|t))break;a=A}else for(l=o,u=0|n[a>>2],c=0,a=A,s=0|n[l>>2],l=0|n[l+4>>2];;){if(0|(A=0|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}f=f+1|0}while(f>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return F=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=F,F=F+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)?(F=a,0|s):0}function H(A,e,t,r,i,a,s){e|=0,t|=0,r|=0,i|=0,a|=0,s|=0;var l,c,u,f,d,g,h,m,b,p,v=0,x=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,N=0,j=0,S=0,P=0,I=0,L=0,R=0,T=0,_=0;if(p=F,F=F+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(x=0|n[(A|=0)>>2]))<=0)return F=p,0;for(u=A+4|0,f=h+8|0,d=m+8|0,g=l+8|0,v=0,S=0;;){j=(w=0|n[u>>2])+(S<<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|S)==(x+-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+(S+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]),x=0|tA(h,m,r,b);A:do{if(x)w=0,v=x;else if(w=0|n[(x=b)>>2],(0|(x=0|n[x+4>>2]))>0|!(0|x)&w>>>0>0){N=0,j=0;e:for(;;){if(R=1/(+(w>>>0)+4294967296*+(0|x)),_=+o[h>>3],T=+((x=0|Ze(0|w,0|x,0|N,0|j))>>>0)+4294967296*+(0|B()),L=+(N>>>0)+4294967296*+(0|j),o[l>>3]=R*(_*T)+R*(+o[m>>3]*L),o[g>>3]=R*(+o[f>>3]*T)+R*(+o[d>>3]*L),0|(x=0|KA(l,r,c))){v=x;break}C=0|At(0|(E=0|n[(Q=c)>>2]),0|(Q=0|n[Q+4>>2]),0|e,0|t),y=0|B(),w=0|n[(k=x=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|w)&!(0|k))P=x,I=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){v=1;break e}if((0|w)==(0|E)&(0|k)==(0|Q))break t;if(C=0|$e(0|(x=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=x=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){P=x,I=16;break}}}while(0);if(16!=(0|I)||(I=0,!(0|E)&!(0|Q))||(n[(D=P)>>2]=E,n[D+4>>2]=Q,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=Q,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(Q=i)>>2]=D,n[Q+4>>2]=E),N=0|Ve(0|N,0|j,1,0),j=0|B(),w=0|n[(x=b)>>2],!((0|(x=0|n[x+4>>2]))>(0|j)|(0|x)==(0|j)&w>>>0>N>>>0)){w=1;break A}}w=0}else w=1}while(0);if(S=S+1|0,!w){I=21;break}if((0|S)>=(0|(x=0|n[A>>2]))){v=0,I=21;break}}return 21==(0|I)?(F=p,0|v):0}function z(A){return(A|=0)>>>0>121?0|(A=0):0|(A=0|n[7696+(28*A|0)+16>>2])}function G(A){return 4==(0|(A|=0))|117==(0|A)|0}function O(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)>>2]}function U(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)+4>>2]}function Y(A,e){return e|=0,(0|n[7696+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|n[7696+(28*A|0)+24>>2])==(0|e))}function W(A,e){return 0|n[848+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function V(A,e){return e|=0,(0|n[848+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|n[848+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|n[848+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|n[848+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|n[848+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|n[848+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|n[848+(28*A|0)+24>>2])==(0|e)?6:7)}function Z(A){var e,t,r;return e=(r=+o[16+(A|=0)>>3])-(t=+o[A+24>>3]),+(r>3]<+o[A+24>>3]|0}function J(A){return+(+o[(A|=0)>>3]-+o[A+8>>3])}function X(A,e){A|=0;var t,r,n=0;return(n=+o[(e|=0)>>3])>=+o[A+8>>3]&&n<=+o[A>>3]?(t=+o[A+16>>3],n=+o[A+24>>3],e=(r=+o[e+8>>3])>=n,A=r<=t&1,t>3]<+o[e+8>>3]||+o[A+8>>3]>+o[e>>3]?0|(s=0):(n=(l=+o[A+16>>3])<(u=+o[(t=A+24|0)>>3]),c=(a=+o[(s=e+16|0)>>3])<(i=+o[(r=e+24|0)>>3]),e=u-a>3],e)||(u=+ie(+o[t>>3],A))>+ie(+o[s>>3],e)?0|(c=0):0|(c=1))}function $(A,e){e|=0;var t,r,n,i,a,s=0,l=0,c=0,u=0;return+o[(A|=0)>>3]<+o[e>>3]||+o[A+8>>3]>+o[e+8>>3]?0|(s=0):(n=(i=+o[(s=A+16|0)>>3])<(l=+o[A+24>>3]),c=(u=+o[(t=e+16|0)>>3])<(a=+o[(r=e+24|0)>>3]),e=l-u>3],e)?0|(c=(u=+ie(+o[s>>3],A))>=+ie(+o[t>>3],e)):0|(c=0))}function AA(A,e){A|=0,e|=0;var t,r,i,a,s,l=0;i=F,F=F+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),F=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,f,d,g,h=0,m=0,b=0,p=0,x=0,y=0,k=0;d=F,F=F+288|0,f=d+264|0,p=d+96|0,m=(h=b=d)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(F=d,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],f),$A(b,m,p),u=+ae(f,p+8|0),o[f>>3]=+o[A>>3],o[(m=f+8|0)>>3]=+o[A+16>>3],o[p>>3]=+o[A+8>>3],o[(b=p+8|0)>>3]=+o[A+24>>3],a=+ae(f,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[f>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+v(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,x=~~k>>>0,y=+l(k)>=1?k>0?~~+w(+s(k/4294967296),4294967295)>>>0:~~+v((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|x)&!(0|y),n[(e=t)>>2]=p?1:x,n[e+4>>2]=p?0:y,e=0):e=1,F=d,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,f,d=0,g=0,h=0;f=F,F=F+288|0,c=f+264|0,u=f+96|0,a=(d=g=f)+96|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(t=0|Ae(t,g))?(F=f,0|(r=t)):(qA(d=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(d,t,u),h=+ae(c,u+8|0),h=+v(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,d=+l(h)>=1?h>0?~~+w(+s(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|d),n[r>>2]=g?1:t,n[r+4>>2]=g?0:d,F=f,0|(r=0)):(F=f,0|(r=1)))}function rA(A,e,t,r){e|=0,t|=0,r|=0,n[(A|=0)>>2]=e,n[A+4>>2]=t,n[A+8>>2]=r}function nA(A){var e,t=0,r=0,o=0,i=0,a=0;t=0|n[(A|=0)>>2],r=0|n[(e=A+4|0)>>2],(0|t)<0&&(r=r-t|0,n[e>>2]=r,n[(a=A+8|0)>>2]=(0|n[a>>2])-t,n[A>>2]=0,t=0),(0|r)<0?(t=t-r|0,n[A>>2]=t,i=(0|n[(a=A+8|0)>>2])-r|0,n[a>>2]=i,n[e>>2]=0,r=0):(a=i=A+8|0,i=0|n[i>>2]),(0|i)<0&&(t=t-i|0,n[A>>2]=t,r=r-i|0,n[e>>2]=r,n[a>>2]=0,i=0),(0|(o=(0|i)<(0|(o=(0|r)<(0|t)?r:t))?i:o))<=0||(n[A>>2]=t-o,n[e>>2]=r-o,n[a>>2]=i-o)}function oA(A,e){var t,r;e|=0,r=0|n[8+(A|=0)>>2],t=+((0|n[A+4>>2])-r|0),o[e>>3]=+((0|n[A>>2])-r|0)-.5*t,o[e+8>>3]=.8660254037844386*t}function iA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[e>>2])+(0|n[A>>2]),n[t+4>>2]=(0|n[e+4>>2])+(0|n[A+4>>2]),n[t+8>>2]=(0|n[e+8>>2])+(0|n[A+8>>2])}function aA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[A>>2])-(0|n[e>>2]),n[t+4>>2]=(0|n[A+4>>2])-(0|n[e+4>>2]),n[t+8>>2]=(0|n[A+8>>2])-(0|n[e+8>>2])}function sA(A,e){e|=0;var t,r=0;r=0|x(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|x(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|x(0|n[(A=A+8|0)>>2],e),n[A>>2]=e}function lA(A){var e,t,r=0,o=0,i=0,a=0,s=0;s=(0|(t=0|n[(A|=0)>>2]))<0,A=(A=(o=(0|(a=((e=(0|(i=(0|n[A+4>>2])-(s?t:0)|0))<0)?0-i|0:0)+((0|n[A+8>>2])-(s?t:0))|0))<0)?0:a)-((i=(0|(o=(0|A)<(0|(o=(0|(r=(e?0:i)-(o?a:0)|0))<(0|(a=(s?0:t)-(e?i:0)-(o?a:0)|0))?r:a))?A:o))>0)?o:0)|0,r=r-(i?o:0)|0;A:do{switch(a-(i?o:0)|0){case 0:switch(0|r){case 0:return 0|(0|A?1==(0|A)?1:7:0);case 1:return 0|(0|A?1==(0|A)?3:7:2);default:break A}case 1:switch(0|r){case 0:return 0|(0|A?1==(0|A)?5:7:4);case 1:if(A)break A;return 6;default:break A}}}while(0);return 7}function cA(A){var e,t,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(l=0|n[(t=8+(A|=0)|0)>>2],(e=(0|n[A>>2])-l|0)>>>0>715827881|(l=(0|n[(c=A+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-e|0,s=-2147483648-e|0,(i=(0|e)>0)?(0|a)<(0|e):(0|s)>(0|e))return 1;if(o=e<<1,i?(2147483647-o|0)<(0|e):(-2147483648-o|0)>(0|e))return 1;if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 1;if(r=3*e|0,o=l<<1,(i?(0|a)<(0|o):(0|s)>(0|o))||((0|e)>-1?(-2147483648|r)>=(0|l):(-2147483648^r)<(0|l)))return 1}else o=l<<1,r=3*e|0;return i=0|Oe(.14285714285714285*+(r-l|0)),n[A>>2]=i,a=0|Oe(.14285714285714285*+(o+e|0)),n[c>>2]=a,n[t>>2]=0,r=(o=(0|a)<(0|i))?i:a,(0|(o=o?a:i))<0&&((-2147483648==(0|o)||((0|r)>0?(2147483647-r|0)<(0|o):(-2147483648-r|0)>(0|o)))&&M(27795,26892,354,26903),((0|r)>-1?(-2147483648|r)>=(0|o):(-2147483648^r)<(0|o))&&M(27795,26892,354,26903)),r=a-i|0,(0|i)<0?(o=0-i|0,n[c>>2]=r,n[t>>2]=o,n[A>>2]=0,i=0):(r=a,o=0),(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[t>>2]=o,n[c>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[c>>2]=a,n[t>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[c>>2]=r-i,n[t>>2]=o-i),0}function uA(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(i=0|n[(e=8+(A|=0)|0)>>2],(a=(0|n[A>>2])-i|0)>>>0>715827881|(i=(0|n[(s=A+4|0)>>2])-i|0)>>>0>715827881){if((r=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 1;if(t=a<<1,(o=(0|i)>0)?(2147483647-i|0)<(0|i):(-2147483648-i|0)>(0|i))return 1;if(l=i<<1,o?(2147483647-l|0)<(0|i):(-2147483648-l|0)>(0|i))return 1;if(r?(2147483647-t|0)<(0|i):(-2147483648-t|0)>(0|i))return 1;if(r=3*i|0,(0|i)>-1?(-2147483648|r)>=(0|a):(-2147483648^r)<(0|a))return 1}else r=3*i|0,t=a<<1;return o=0|Oe(.14285714285714285*+(t+i|0)),n[A>>2]=o,i=0|Oe(.14285714285714285*+(r-a|0)),n[s>>2]=i,n[e>>2]=0,t=(r=(0|i)<(0|o))?o:i,(0|(r=r?i:o))<0&&((-2147483648==(0|r)||((0|t)>0?(2147483647-t|0)<(0|r):(-2147483648-t|0)>(0|r)))&&M(27795,26892,402,26917),((0|t)>-1?(-2147483648|t)>=(0|r):(-2147483648^t)<(0|r))&&M(27795,26892,402,26917)),t=i-o|0,(0|o)<0?(r=0-o|0,n[s>>2]=t,n[e>>2]=r,n[A>>2]=0,o=0):(t=i,r=0),(0|t)<0&&(o=o-t|0,n[A>>2]=o,r=r-t|0,n[e>>2]=r,n[s>>2]=0,t=0),a=o-r|0,i=t-r|0,(0|r)<0?(n[A>>2]=a,n[s>>2]=i,n[e>>2]=0,t=i,i=a,r=0):i=o,(0|(o=(0|r)<(0|(o=(0|t)<(0|i)?t:i))?r:o))<=0||(n[A>>2]=i-o,n[s>>2]=t-o,n[e>>2]=r-o),0}function fA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+((3*(r=(0|n[A>>2])-o|0)|0)-(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((o<<1)+r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function dA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+(((r=(0|n[A>>2])-o|0)<<1)+(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((3*o|0)-r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function gA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(3*o|0)|0,n[A>>2]=s,i=a+(3*i|0)|0,n[t>>2]=i,o=(3*a|0)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function hA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(3*(o=0|n[(t=A+4|0)>>2])|0)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(3*s|0)|0,n[A>>2]=s,n[t>>2]=a,o=(3*i|0)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function mA(A,e){A|=0;var t,r,o,i=0,a=0,s=0;((e|=0)-1|0)>>>0>=6||(s=(0|n[15440+(12*e|0)>>2])+(0|n[A>>2])|0,n[A>>2]=s,o=A+4|0,a=(0|n[15440+(12*e|0)+4>>2])+(0|n[o>>2])|0,n[o>>2]=a,r=A+8|0,e=(0|n[15440+(12*e|0)+8>>2])+(0|n[r>>2])|0,n[r>>2]=e,i=a-s|0,(0|s)<0?(e=e-s|0,n[o>>2]=i,n[r>>2]=e,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,e=e-i|0,n[r>>2]=e,n[o>>2]=0,i=0),t=a-e|0,s=i-e|0,(0|e)<0?(n[A>>2]=t,n[o>>2]=s,n[r>>2]=0,a=t,e=0):s=i,(0|(i=(0|e)<(0|(i=(0|s)<(0|a)?s:a))?e:i))<=0||(n[A>>2]=a-i,n[o>>2]=s-i,n[r>>2]=e-i))}function bA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(o=0|n[(t=A+4|0)>>2])+s|0,s=(i=0|n[(r=A+8|0)>>2])+s|0,n[A>>2]=s,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function pA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],a=0|n[(t=A+4|0)>>2],i=0|n[(r=A+8|0)>>2],s=a+o|0,n[A>>2]=s,a=i+a|0,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function vA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function xA(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|LA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=F,F=F+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=F,F=F+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return F=r,-1;if(1==(0|t)&(o=!!(0|o)))return F=r,-1;do{if(!(0|Se(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 F=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,F=o,0|(a=6)):(0|XA(A,a,r)&&M(27795,26932,282,26947),e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,a)?QA(r,e,i,2,t):SA(r,e,i,2,t),F=o,0|(a=0))):(F=o,0|(a=6))}function EA(A,e,t,r,i){e|=0,t|=0,r|=0,i|=0;var a,s=0,u=0;if(s=+function(A){var e,t;return t=+o[(A|=0)>>3],e=+o[A+8>>3],+ +c(+(t*t+e*e))}(A|=0),s<1e-16)return e=15600+(e<<4)|0,n[i>>2]=n[e>>2],n[i+4>>2]=n[e+4>>2],n[i+8>>2]=n[e+8>>2],void(n[i+12>>2]=n[e+12>>2]);if(u=+p(+ +o[A+8>>3],+ +o[A>>3]),(0|t)>0){A=0;do{s*=.37796447300922725,A=A+1|0}while((0|A)!=(0|t))}a=.3333333333333333*s,r?(t=!(0|ZA(t)),s=+b(.381966011250105*(t?a:.37796447300922725*a))):(s=+b(.381966011250105*s),0|ZA(t)&&(u=+ne(u+.3334731722518321))),function(A,e,t,r){A|=0,e=+e,r|=0;var i=0,a=0,s=0,c=0;if((t=+t)<1e-16)return n[r>>2]=n[A>>2],n[r+4>>2]=n[A+4>>2],n[r+8>>2]=n[A+8>>2],void(n[r+12>>2]=n[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(i=+l(+(a+-3.141592653589793))<1e-16,e=+o[A>>3],i){e-=t,o[r>>3]=e,i=r;break}if(s=+f(+t),t=+d(+t),e=s*+d(+e)+ +f(+a)*(t*+f(+e)),e=+m(+((e=e>1?1:e)<-1?-1:e)),o[r>>3]=e,+l(+(e+-1.5707963267948966))<1e-16)return o[r>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[r>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if(c=1/+f(+e),a=t*+d(+a)*c,t=+o[A>>3],e=c*((s-+d(+e)*+d(+t))/+f(+t)),s=a>1?1:a,e=e>1?1:e,(e=+o[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(o[r+8>>3]=e)}e=+o[A>>3]+t,o[r>>3]=e,i=r}while(0);if(+l(+(e+-1.5707963267948966))<1e-16)return o[i>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[i>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if((e=+o[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);o[r+8>>3]=e}(15600+(e<<4)|0,+ne(+o[15920+(24*e|0)>>3]-u),s,i)}function QA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,x,w,y,k,C,B,D,E,Q,N=0,j=0,S=0,P=0,I=0,L=0;if(Q=F,F=F+272|0,P=Q+240|0,B=Q,D=Q+224|0,E=Q+208|0,b=Q+176|0,p=Q+160|0,v=Q+192|0,x=Q+144|0,w=Q+128|0,y=Q+112|0,k=Q+96|0,C=Q+80|0,n[(N=Q+256|0)>>2]=e,n[P>>2]=n[A>>2],n[P+4>>2]=n[A+4>>2],n[P+8>>2]=n[A+8>>2],n[P+12>>2]=n[A+12>>2],NA(P,N,B),n[i>>2]=0,(0|(P=r+t+(5==(0|r)&1)|0))<=(0|t))F=Q;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[N>>2])<<2)|0,f=16960+(a<<2)|0,d=w+8|0,g=y+8|0,h=k+8|0,m=E+4|0,S=t;A:for(;;){j=B+((0|S)%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|S)>(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],N=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*N|0)>>2],(0|(j=0|n[18640+(80*r|0)+(20*N|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*N|0)+4|0,n[v>>2]=n[j>>2],n[v+4>>2]=n[j+4>>2],n[v+8>>2]=n[j+8>>2],sA(v,3*(0|n[u>>2])|0),iA(l,v,l),nA(l),oA(l,x),I=+(0|n[f>>2]),o[w>>3]=3*I,o[d>>3]=0,L=-1.5*I,o[y>>3]=L,o[g>>3]=2.598076211353316*I,o[k>>3]=L,o[h>>3]=-2.598076211353316*I,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}Ne(p,x,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|S)<(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|(S=S+1|0))>=(0|P)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):F=Q}}function NA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=F,F=F+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),F=r}function jA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,f=0,d=0,g=0,h=0;if(c=F,F=F+32|0,l=c+12|0,i=c,h=4+(A|=0)|0,g=0|n[16960+((e|=0)<<2)>>2],g=(s=!!(0|r))?3*g|0:g,u=0|n[h>>2],o=0|n[(a=A+8|0)>>2],s){if((0|(u=o+u+(r=0|n[(f=A+12|0)>>2])|0))==(0|g))return F=c,1;d=f}else u=o+u+(r=0|n[(d=A+12|0)>>2])|0;if((0|u)<=(0|g))return F=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){f=18640+(80*r|0)+60|0,r=A;break}r=18640+(80*r|0)+40|0,t?(rA(l,g,0,0),aA(h,l,i),pA(i),iA(i,l,h),f=r,r=A):(f=r,r=A)}else f=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[f>>2],(0|n[(u=f+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=f+4|0,n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],e=0|n[16880+(e<<2)>>2],sA(l,s?3*e|0:e),iA(h,l,h),nA(h),r=s&&((0|n[a>>2])+(0|n[h>>2])+(0|n[d>>2])|0)==(0|g)?1:2,F=c,0|r}function FA(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 SA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,x,w,y,k,C,B=0,D=0,E=0,Q=0,N=0;if(C=F,F=F+240|0,x=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,v=C+96|0,n[(B=C+224|0)>>2]=e,n[x>>2]=n[A>>2],n[x+4>>2]=n[A+4>>2],n[x+8>>2]=n[A+8>>2],n[x+12>>2]=n[A+12>>2],PA(x,B,w),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))F=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,f=p+8|0,d=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=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),Q=+(0|n[l>>2]),o[m>>3]=3*Q,o[c>>3]=0,N=-1.5*Q,o[b>>3]=N,o[u>>3]=2.598076211353316*Q,o[p>>3]=N,o[f>>3]=-2.598076211353316*Q,B=0|n[x>>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}Ne(k,h,r,A,v),0|je(k,v)||0|je(h,v)||(EA(v,0|n[x>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(d,k),EA(k,0|n[y>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),(0|(E=E+1|0))>=(0|g)){A=3;break}r=0|n[y>>2]}3!=(0|A)?8==(0|A)&&M(27054,27017,737,27099):F=C}}function PA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=F,F=F+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),F=r}function IA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function LA(A,e){A|=0;var t=0,n=0,o=0,i=0;return!0&134217728==(-16777216&(e|=0))?(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0>121?0|(A=0):!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())?0|r[20528+t|0]?!(0|A)&!(0|(e&=8191))?0|(i=1):(i=0|nt(0|A,0|e),B(),0|!!((63-i|0)%3|0)):0|(i=1):0|(i=0)):0|(A=0)}function 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|vA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(n=0|tt(0|A,0|e,0|(i=3*(15-t|0)|0)),B(),o=0|rt(7,0,0|i),e&=~B(),A=A&~o|(i=0|rt(0|vA(7&n),0,0|i)),e=0|e|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function YA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;i=0|tt(0|A,0|e,0|(o=3*(15-t|0)|0)),B(),n=0|rt(7,0,0|o),e&=~B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~n,e=0|B()|e,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function WA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|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(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|xA(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|xA(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=F,F=F+16|0,i=r,(e|=0)>>>0>15?(F=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=F,F=F+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=F,F=F+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=F,F=F+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+f(+n),n=+d(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+f(+n),o[e>>3]=r,n=t*+d(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Fe(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Fe(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Fe(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Fe(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Fe(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Fe(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Fe(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Fe(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Fe(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Fe(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Fe(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Fe(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Fe(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Fe(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Fe(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Fe(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Fe(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Fe(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Fe(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Fe(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,F=i):F=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(F=i);if(c=0|n[t>>2],a=+ne((a=+o[15920+(24*c|0)>>3])-+ne(+function(A,e){var t,r,n,i,a;return A|=0,i=+o[(e|=0)>>3],r=+f(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+d(+n),t=+o[A>>3],+ +p(+a,+(+d(+i)*+f(+t)-+f(+n)*(r*+d(+t))))}(15600+(c<<4)|0,A))),l=0|ZA(e)?+ne(a+-.3334731722518321):a,a=2.618033988749896*+g(+s),(0|e)>0){A=0;do{a*=2.6457513110645907,A=A+1|0}while((0|A)!=(0|e))}s=+f(+l)*a,o[r>>3]=s,l=+d(+l)*a,o[r+8>>3]=l,F=i}(A|=0,e|=0,t|=0,i=r),function(A,e){A|=0;var t,r,i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],f=+l(+r),i=+o[A+8>>3],f+=.5*(d=1.1547005383792515*+l(+i)),f-=+(0|(s=~~f)),d-=+(0|(A=~~d));do{if(f<.5){if(f<.3333333333333333){if(n[e>>2]=s,d<.5*(f+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(d<(h=1-f)))+A|0,n[e+4>>2]=A,h<=d&d<2*f){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(f<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,d<.5*f){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(d<1-f){if(n[e+4>>2]=A,2*f-1>2]=s;break}}else A=A+1|0,n[e+4>>2]=A;s=s+1|0,n[e>>2]=s}while(0);do{if(r<0){if(1&A){s=~~(+(0|s)-(2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(A+1|0)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))+1)),n[e>>2]=s;break}s=~~(+(0|s)-2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(0|A)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))),n[e>>2]=s;break}}while(0);g=e+4|0,i<0&&(s=s-((1|A<<1)/2|0)|0,n[e>>2]=s,A=0-A|0,n[g>>2]=A),c=A-s|0,(0|s)<0?(u=0-s|0,n[g>>2]=c,n[a>>2]=u,n[e>>2]=0,A=c,s=0):u=0,(0|A)<0&&(s=s-A|0,n[e>>2]=s,u=u-A|0,n[a>>2]=u,n[g>>2]=0,A=0),t=s-u|0,c=A-u|0,(0|u)<0&&(n[e>>2]=t,n[g>>2]=c,n[a>>2]=0,A=c,s=t,u=0),(0|(c=(0|u)<(0|(c=(0|A)<(0|s)?A:s))?u:c))<=0||(n[e>>2]=s-c,n[g>>2]=A-c,n[a>>2]=u-c)}(i,t+4|0),F=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=F,F=F+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)),F=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),F=t,0|l);if(n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],n[l+12>>2]=n[A+12>>2],s=l+4|0,(0|e)>0)for(A=-1;n[o>>2]=n[s>>2],n[o+4>>2]=n[s+4>>2],n[o+8>>2]=n[s+8>>2],1&e?(fA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],gA(i)):(dA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],hA(i)),aA(o,i,a),nA(a),c=0|rt(7,0,0|(u=3*(15-e|0)|0)),r&=~B(),A=(u=0|rt(0|lA(a),0,0|u))|A&~c,r=0|B()|r,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|n[s>>2])<=2&&(0|n[l+8>>2])<=2&&(0|n[l+12>>2])<=2){if(e=0|rt(0|(o=0|O(l)),0,45),e|=A,A=B()|-1040385&r,a=0|U(l),!(0|z(o))){if((0|a)<=0)break;for(i=0;;){if(o=0|tt(0|e,0|A,52),B(),o&=15)for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0;if((0|(i=i+1|0))==(0|a))break A}}i=0|tt(0|e,0|A,52),B(),i&=15;e:do{if(i){r=1;t:for(;;){switch(u=0|tt(0|e,0|A,3*(15-r|0)|0),B(),7&u){case 1:break t;case 0:break;default:break e}if(!(r>>>0>>0))break e;r=r+1|0}if(0|Y(o,0|n[l>>2]))for(r=1;c=0|rt(7,0,0|(l=3*(15-r|0)|0)),u=A&~B(),A=0|tt(0|e,0|A,0|l),B(),e=e&~c|(A=0|rt(0|xA(7&A),0,0|l)),A=0|u|B(),r>>>0>>0;)r=r+1|0;else for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0}}while(0);if((0|a)>0){r=0;do{e=0|UA(e,A),A=0|B(),r=r+1|0}while((0|r)!=(0|a))}}else e=0,A=0}while(0);return u=e,C(0|(c=A)),F=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),F=r,0|(i=0)):(F=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=F,F=F+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,F=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|xA(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 F=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)&&dA(l)}else(0|s)!=(0|c)&&(n[l>>2]=n[r>>2],n[l+4>>2]=n[r+4>>2],n[l+8>>2]=n[r+8>>2]);return F=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=F,F=F+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(F=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=F,F=F+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),F=r}(r,15&i,t),F=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=F,F=F+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return F=r,0|n;n=0|tt(0|A,0|e,45),B(),n=!(0|z(127&n)),o=0|tt(0|A,0|e,52),B(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(!((0|rt(7,0,3*(15-n|0)|0))&A)&!((0|B())&e)))break A;if(!(n>>>0>>0))break;n=n+1|0}return QA(i,o,0,5,t),F=r,0}}while(0);return SA(i,o,0,6,t),F=r,0}function Ae(A,e){e|=0;var t=0,r=0,o=0,i=0,a=0,s=0,l=0;if((A|=0)>>>0>15)return 4;if(rt(0|A,0,52),s=134225919|B(),!A){t=0,r=0;do{0|z(r)&&(rt(0|r,0,45),a=0|s|B(),n[(A=e+(t<<3)|0)>>2]=-1,n[A+4>>2]=a,t=t+1|0),r=r+1|0}while(122!=(0|r));return 0}t=0,a=0;do{if(0|z(a)){for(rt(0|a,0,45),r=1,o=-1,i=0|s|B();o&=~(l=0|rt(7,0,3*(15-r|0)|0)),i&=~B(),(0|r)!=(0|A);)r=r+1|0;n[(l=e+(t<<3)|0)>>2]=o,n[l+4>>2]=i,t=t+1|0}a=a+1|0}while(122!=(0|a));return 0}function ee(A,e,t,r){A|=0,r|=0;var o=0,i=0,a=0;o=0|tt(0|(e|=0),0|(t|=0),52),B(),!(0|e)&!(0|t)|(0|r)>15|(0|(o&=15))>(0|r)?(i=-1,e=-1,t=0,o=0):(e=0|zA(e,t,o+1|0,r),a=-15728641&B(),t=0|rt(0|r,0,52),i=o,e=(e=!(0|HA(t|=e,a=0|a|B())))?-1:r,o=a),n[(a=A)>>2]=t,n[a+4>>2]=o,n[A+8>>2]=i,n[A+12>>2]=e}function te(A,e,t,r){t|=0,r|=0;var o=0,i=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,n[(i=r+8|0)>>2]=o,!(0|A)&!(0|e)|(0|t)>15|(0|o)>(0|t)?(n[(t=r)>>2]=0,n[t+4>>2]=0,n[i>>2]=-1,void(n[r+12>>2]=-1)):(A=0|zA(A,e,o+1|0,t),i=-15728641&B(),o=0|rt(0|t,0,52),o|=A,i=0|i|B(),n[(A=r)>>2]=o,n[A+4>>2]=i,A=r+12|0,0|HA(o,i)?void(n[A>>2]=t):void(n[A>>2]=-1))}function re(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(!(!(0|(t=0|n[(r=A|=0)>>2]))&!(0|(r=0|n[r+4>>2]))||(o=0|tt(0|t,0|r,52),B(),t=0|Ve(0|(l=0|rt(1,0,3*(15^(o&=15))|0)),0|B(),0|t,0|r),r=0|B(),n[(l=A)>>2]=t,n[l+4>>2]=r,(0|o)<(0|(s=0|n[(l=A+8|0)>>2]))))){for(e=A+12|0,a=o;;){if((0|a)==(0|s)){o=5;break}if(c=(0|a)==(0|n[e>>2]),o=0|tt(0|t,0|r,0|(i=3*(15-a|0)|0)),B(),c&1==(0|(o&=7))&!0){o=7;break}if(!(7==(0|o)&!0)){o=10;break}if(t=0|Ve(0|t,0|r,0|(c=0|rt(1,0,0|i)),0|B()),r=0|B(),n[(c=A)>>2]=t,n[c+4>>2]=r,!((0|a)>(0|s))){o=10;break}a=a+-1|0}if(5==(0|o))return n[(c=A)>>2]=0,n[c+4>>2]=0,n[l>>2]=-1,void(n[e>>2]=-1);if(7==(0|o))return s=0|Ve(0|t,0|r,0|(s=0|rt(1,0,0|i)),0|B()),l=0|B(),n[(c=A)>>2]=s,n[c+4>>2]=l,void(n[e>>2]=a+-1)}}function ne(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function oe(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<17453292519943298e-27?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<17453292519943298e-27):0|(e=0)}function ie(A,e){switch(A=+A,0|(e|=0)){case 1:A=A<0?A+6.283185307179586:A;break;case 2:A=A>0?A+-6.283185307179586:A}return+A}function ae(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475}function se(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20656+(A<<3)>>3],0|(e=0))}function le(A,e){e|=0;var t=0;return(A|=0)>>>0>15?0|(e=4):(t=0|qe(0|(t=0|pe(7,0,A,((0|A)<0)<<31>>31)),0|B(),120,0),A=0|B(),n[e>>2]=2|t,n[e+4>>2]=A,0|(e=0))}function ce(A,e,t){A|=0,t|=0;var r,n,i,a,s=0,l=0,u=0,h=0,m=0,v=0;return v=+o[(e|=0)>>3],i=+o[A>>3],m=+d(.5*(v-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+d(.5*(u-n)),r=+f(+i),a=+f(+v),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],v=+d(.5*(m-v)),s=+o[t+8>>3],u=+d(.5*(s-u)),l=+f(+m),u=2*+p(+ +c(+(u=v*v+u*(a*l*u))),+ +c(+(1-u))),m=+d(.5*(i-m)),s=+d(.5*(n-s)),s=2*+p(+ +c(+(s=m*m+s*(r*l*s))),+ +c(+(1-s))),4*+b(+ +c(+ +g(.5*(l=.5*(h+u+s)))*+g(.5*(l-h))*+g(.5*(l-u))*+g(.5*(l-s))))}function ue(A,e,t){t|=0;var r,i,a,s=0,l=0;if(a=F,F=F+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return F=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,F=a,0}function fe(A){A|=0;var e,t,r=0;return(e=0|We(1,12))||M(27280,27235,49,27293),0|(r=0|n[(t=A+4|0)>>2])?(n[(r=r+8|0)>>2]=e,n[t>>2]=e,0|e):(0|n[A>>2]&&M(27310,27235,61,27333),n[(r=A)>>2]=e,n[t>>2]=e,0|e)}function de(A,e){var t,r;return A|=0,e|=0,(r=0|Ue(24))||M(27347,27235,78,27361),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[r+16>>2]=0,0|(t=0|n[(e=A+4|0)>>2])?(n[t+16>>2]=r,n[e>>2]=r,0|r):(0|n[A>>2]&&M(27376,27235,82,27361),n[A>>2]=r,n[e>>2]=r,0|r)}function ge(A){var e=0,t=0,r=0,o=0;if(A|=0)for(r=1;;){if(0|(e=0|n[A>>2]))do{if(0|(t=0|n[e>>2]))do{o=t,t=0|n[t+16>>2],Ye(o)}while(0|t);o=e,e=0|n[e+8>>2],Ye(o)}while(0|e);if(e=A,A=0|n[A+8>>2],r||Ye(e),!A)break;r=0}}function he(A,e,t){A|=0;var r=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),r=+o[t>>3],i=e&(i=+o[t+8>>3])<0?i+6.283185307179586:i,!(A=0|n[A>>2]))return 0;if(e){e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(((c=(l=s<0?s+6.283185307179586:s)+(r-a)/(c-a)*((s=i<0?i+6.283185307179586:i)-l))<0?c+6.283185307179586:c)>(u=l==u|s==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}else{e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(s+(r-a)/(c-a)*(i-s)>(u=s==u|i==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}return 0}function me(A,e,t,o,i){t|=0,o|=0,i|=0;var a,s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(c=F,F=F+32|0,x=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 F=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 F=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(d=0|V(h,m))))return F=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=d,f=g)}else p=0,f=0;a=0|z(h),s=0|z(m),n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0;do{if(p){if(d=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(d){h=0,g=t,d=o;do{g=0|WA(g,d),d=0|B(),1==(0|(f=0|xA(f)))&&(f=0|xA(1)),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;else if(d){h=0,g=t,d=o;do{g=0|VA(g,d),d=0|B(),f=0|xA(f),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;if(JA(h,g,x),b||M(27563,27538,191,27548),(d=!!(0|a))&(f=!!(0|s))&&M(27590,27538,192,27548),d){if(7==(0|(f=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*f|0)+p|0]){u=1;break}h=g=0|n[21168+(28*f|0)+(p<<2)>>2]}else if(f){if(7==(0|(f=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*f|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(f<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){d=x+4|0,f=0;do{pA(d),f=f+1|0}while((0|f)!=(0|g))}if(n[l>>2]=0,n[l+4>>2]=0,n[l+8>>2]=0,mA(l,p),0|u)for(;0|ZA(u)?gA(l):hA(l),(0|u)>1;)u=u+-1|0;if((0|h)>0){u=0;do{pA(l),u=u+1|0}while((0|u)!=(0|h))}iA(v=x+4|0,l,v),nA(v),v=51}}else if(JA(t,o,x),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(f=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*f|0)+u|0])u=1;else if((0|(f=0|n[21168+(28*f|0)+(u<<2)>>2]))>0){d=x+4|0,u=0;do{pA(d),u=u+1|0}while((0|u)!=(0|f));v=51}else v=51;else v=51}while(0);return 51==(0|v)&&(u=x+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),F=c,0|u}function be(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(a=F,F=F+48|0,o=a+36|0,c=a+24|0,u=a+12|0,f=a,s=0|tt(0|(A|=0),0|(e|=0),52),B(),s&=15,g=0|tt(0|A,0|e,45),B(),(g&=127)>>>0>121)return F=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)))?(F=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,F=a,0|(b=0));for(n[o>>2]=n[t>>2],n[o+4>>2]=n[t+4>>2],n[o+8>>2]=n[t+8>>2],t=s;;){if(l=t,t=t+-1|0,n[c>>2]=n[o>>2],n[c+4>>2]=n[o+4>>2],n[c+8>>2]=n[o+8>>2],0|ZA(l)){if(0|(s=0|cA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],gA(u)}else{if(0|(s=0|uA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],hA(u)}if(aA(c,u,f),nA(f),v=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(x=3*(15-l|0)|0)),s&=~B(),x=0|rt(0|lA(f),0,0|x),s=0|B()|s,n[(b=r)>>2]=x|v&~p,n[b+4>>2]=s,(0|l)<=1){t=14;break}}A:do{if(13!=(0|t)&&14==(0|t))if((0|n[o>>2])<=1&&(0|n[o+4>>2])<=1&&(0|n[o+8>>2])<=1){f=127==(0|(s=0|W(g,t=0|lA(o))))?0:0|z(s);e:do{if(t){if(i){if(7==(0|(s=0|OA(A,e)))){s=5;break A}if((0|(l=0|n[21376+(28*s|0)+(t<<2)>>2]))>0){s=t,t=0;do{s=0|vA(s),t=t+1|0}while((0|t)!=(0|l))}else s=t;if(1==(0|s)){s=9;break A}127==(0|(t=0|W(g,s)))&&M(27648,27538,411,27678),0|z(t)?M(27693,27538,412,27678):(m=t,h=l,d=s)}else m=s,h=0,d=t;if((0|(u=0|n[4272+(28*g|0)+(d<<2)>>2]))<=-1&&M(27724,27538,419,27678),!f){if((0|h)<0){s=5;break A}if(0|h){s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];do{t=0|YA(t,l),l=0|B(),n[(x=r)>>2]=t,n[x+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[(x=r)>>2]=t,n[x+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[(x=r)>>2]=t,n[x+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[(x=r)>>2]=l,n[x+4>>2]=c,s=s+1|0}while((0|s)<(0|t));s=m,t=58}else s=m,t=58}else if(!!(0|i)&!!(0|f)){if(7==(0|(t=0|OA(A,e)))|7==(0|(l=0|OA(0|n[(l=r)>>2],0|n[l+4>>2])))){s=5;break A}if((0|(l=0|n[21376+(28*t|0)+(l<<2)>>2]))<0){s=5;break A}if(l){t=0,c=0|n[(u=r)>>2],u=0|n[u+4>>2];do{c=0|YA(c,u),u=0|B(),n[(x=r)>>2]=c,n[x+4>>2]=u,t=t+1|0}while((0|t)<(0|l));t=58}else t=59}else t=58}while(0);if(58==(0|t)&&f&&(t=59),59==(0|t)&&1==(0|OA(0|n[(x=r)>>2],0|n[x+4>>2]))){s=9;break}p=0|n[(x=r)>>2],x=-1040385&n[x+4>>2],v=0|rt(0|s,0,45),x=0|x|B(),n[(s=r)>>2]=p|v,n[s+4>>2]=x,s=0}else s=1}while(0);return F=a,0|s}function pe(A,e,t,r){A|=0,e|=0;var n=0,o=0,i=0;if(!(0|(t|=0))&!(0|(r|=0)))return o=1,C(0|(n=0)),0|o;o=A,n=e,A=1,e=0;do{A=0|qe(0|((i=!0&!(1&t))?1:o),0|(i?0:n),0|A,0|e),e=0|B(),t=0|et(0|t,0|r,1),r=0|B(),o=0|qe(0|o,0|n,0|o,0|n),n=0|B()}while(!(!(0|t)&!(0|r)));return C(0|e),0|A}function ve(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,d=0;i=F,F=F+16|0,s=i,l=0|tt(0|(A|=0),0|(e|=0),52),B(),l&=15;do{if(l){if(!(a=0|qA(A,e,s))){u=+o[s>>3],c=1/+f(+u),d=+o[25968+(l<<3)>>3],o[t>>3]=u+d,o[t+8>>3]=u-d,u=+o[s+8>>3],c*=d,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return F=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return F=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]?(F=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,F=i,0|(l=0))}function xe(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0;if(i=F,F=F+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))F=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(F=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))w=A+24|0;else{v=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,f=3==(2|c),d=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){x=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){x=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)){x=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){x=29;break}}if(h){if(0|(c=0|$A(s,l,e))){x=32;break}if(0|ve(s,l,t,0)){x=36;break}if(f&&0|De(0|n[o>>2],0|n[p>>2],e,t)){x=42;break}if(g&&0|Qe(0|n[o>>2],0|n[p>>2],e,t)){x=42;break}}if(b){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){x=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){x=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],d)){x=53;break}if(0|Qe(0|n[o>>2],0|n[p>>2],t,e)){x=53;break}}}}do{if((0|u)<(0|n[v>>2])){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){x=58;break e}if(!(0|q(c,e))){x=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){x=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){x=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else x=73}while(0);if(73==(0|x)&&(x=0,s=0|we(s,l),l=0|B()),!(0|s)&!(0|l)){w=p;break A}}switch(0|x){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,x=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,x=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(F=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[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(F=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,x=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,x=55;break;case 58:0|c&&Ye(c),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,x=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,x=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[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(F=i)}if(20==(0|x))return void(F=i);if(55==(0|x))return void(F=i);if(71==(0|x))return void(F=i)}}while(0);0|(a=0|n[w>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+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,F=i}}function we(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;t=F,F=F+16|0,f=t,o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,r=0|tt(0|A,0|e,45),B();do{if(o){for(;r=0|rt(o+4095|0,0,52),i=B()|-15728641&e,r=r|A|(s=0|rt(7,0,0|(a=3*(15-o|0)|0))),i|=l=0|B(),c=0|tt(0|A,0|e,0|a),B(),o=o+-1|0,!((c&=7)>>>0<6);){if(!o){u=4;break}e=i,A=r}if(4==(0|u)){r=0|tt(0|r,0|i,45),B();break}return f=0|rt(((f=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,f|=A&~s,C(0|u),F=t,0|f}}while(0);return(r&=127)>>>0>120?(f=0,C(0|(u=0)),F=t,0|f):(RA(f,0,r+1|0,0),u=0|n[f+4>>2],f=0|n[f>>2],C(0|u),F=t,0|f)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),i=+o[t>>3],a=e&(a=+o[t+8>>3])<0?a+6.283185307179586:a,(0|(g=0|n[A>>2]))<=0)return 0;if(r=0|n[A+4>>2],e){e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(((u=(c=l<0?l+6.283185307179586:l)+(i-s)/(u-s)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}else{e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(d=l==d|a==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}return 0}function ke(A,e){e|=0;var t,r,i,a,s,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=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,v=0,A=-1,d=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,x=0;c=+o[t+(x<<4)>>3],h=+o[t+(x<<4)+8>>3],f=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,d=c),h>3]=h,g=h),c>m?o[e>>3]=c:c=m,h>u&&(o[s>>3]=h,u=h),b=h>0&hp?h:p,v|=+l(+(h-f))>3.141592653589793,(0|(A=x+1|0))!=(0|r);)w=x,m=c,x=A,A=w;v&&(o[s>>3]=p,o[a>>3]=b)}}function Ce(A){return 0|((A|=0)>>>0<4?0:15)}function Be(A,e){e|=0;var t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(v=e+8|0)>>3]=17976931348623157e292,o[(x=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,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292,y=0;s=+o[a+(y<<4)>>3],g=+o[a+(y<<4)+8>>3],u=+o[a+(((0|(B=r+2|0))==(0|p)?0:B)<<4)+8>>3],s>3]=s,f=s),g>3]=g,d=g),s>h?o[e>>3]=s:s=h,g>c&&(o[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[x>>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,x=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[x>>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,v=0,f=17976931348623157e292,d=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(v<<4)>>3],h=+o[p+(v<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|w)?0:i)<<4)+8>>3],s>3]=s,f=s),h>3]=h,d=h),s>g?o[x>>3]=s:s=g,h>c&&(o[k>>3]=h,c=h),m=h>0&hb?h:b,a|=+l(+(h-u))>3.141592653589793,(0|(i=v+1|0))!=(0|w);)M=v,v=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0,n[x+16>>2]=0,n[x+20>>2]=0,n[x+24>>2]=0,n[x+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=F,F=F+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return F=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 F=i,0|a}}while(0);if(0|Ee(A,e,t,r))return F=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 F=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,M=0;if(u=F,F=F+176|0,l=u+172|0,f=u+168|0,c=u,!(0|q(e|=0,r|=0)))return F=u,0;if(function(A,e,t,r){var i,a,s,l,c;e|=0,t|=0,r|=0,A=(a=+o[16+(A|=0)>>3])<(c=+o[A+24>>3]),i=(l=+o[e+16>>3])<(s=+o[e+24>>3]),e=c-l>2]=A?i|e?1:2:0,n[r>>2]=i?A?1:e?2:1:0}(e,r,l,f),st(0|c,0|t,168),(0|n[t>>2])>0){e=0;do{y=+ie(+o[(B=c+8+(e<<4)+8|0)>>3],0|n[f>>2]),o[B>>3]=y,e=e+1|0}while((0|e)<(0|n[t>>2]))}a=+o[r>>3],s=+o[r+8>>3],y=+ie(+o[r+16>>3],0|n[f>>2]),i=+ie(+o[r+24>>3],0|n[f>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(f=0|n[c>>2]))<=0)for(e=0;;)if((0|(e=e+1|0))>=(0|n[A>>2])){e=0;break A}for(t=0;;){if(e=0|n[r>>2],x=+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,d=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(x>=a)|!(d>=a)&&!(x<=s)|!(d<=s)&&!(w<=i)|!(g<=i)&&!(w>=y)|!(g>=y)){v=d-x,b=g-w,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|f)?0:e,d=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-d,h=+o[c+8+(M<<4)>>3],!(0==(p=v*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=w-d,C=x-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(v*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|f))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return F=u,0|e}function Qe(A,e,t,r){var o=0,i=0,a=0;if(0|Ee(A|=0,e|=0,t|=0,r|=0))return 1;if((0|n[(i=A+8|0)>>2])<=0)return 0;for(o=A+12|0,A=0;;){if(a=A,A=A+1|0,0|Ee((0|n[o>>2])+(a<<3)|0,e+(A<<5)|0,t,r)){A=1,o=6;break}if((0|A)>=(0|n[i>>2])){A=0,o=6;break}}return 6==(0|o)?0|A:0}function Ne(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,f,d=0;l=+o[(A|=0)>>3],s=+o[e>>3]-l,a=+o[A+8>>3],i=+o[e+8>>3]-a,u=+o[t>>3],d=((d=+o[r>>3]-u)*(a-(f=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-f))/(s*c-i*d),o[n>>3]=l+s*d,o[n+8>>3]=a+i*d}function 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 Fe(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 Se(A,e,t){t|=0;var r,o,i,a,s=0,l=0,c=0,u=0;if(a=F,F=F+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return F=a,0|s;r=0|IA(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,F=a,0}function Pe(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(l=F,F=F+32|0,x=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 F=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 F=l,1;if(0|Se(A,e,x))return F=l,1;if(u=(0|n[x>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return F=l,1;n[s>>2]=0,c=0|R(A,e,p,s,a);do{if(!c){if(h=0|n[(d=a)>>2],u=(f=(d=0|n[d+4>>2])>>>0>>0|(0|d)==(0|e)&h>>>0>>0)?h:A,f=f?d:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(d&(0|B())))c=t;else{if(d=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|d)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|d)&&M(27795,27797,248,27822),0|Se(A,e,x)&&M(27795,27797,248,27822),c=(0|n[x>>2])+d|0,7==(0|(d=0|n[(c=g?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&M(27795,27797,248,27822),n[i>>2]=0,0|(c=0|R(A,e,d,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|f)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,f=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,f=h;break}do{if(!(0|Se(g,h,x))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[x>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[x>>2])|0)%6|0;break}c=-1}while(0);u=g,f=h}else c=t}while(0);h=0|n[(d=a)>>2],d=0|n[d+4>>2]}if((0|u)==(0|h)&(0|f)==(0|d)){if(A=(g=!!(0|HA(h,d)))?0|_(h,d,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,d),(A+-1|0)>>>0<=5&&!(1==(0|A)&(v=!!(0|c))))do{if(!(0|Se(h,d,x))){if(v){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[x>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[x>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|g&5==(0|c)?0:c}e=f,A=u;break A}}while(0);return F=l,0|c}}while(0);return v=0|rt(0|c,0,56),x=B()|-2130706433&e|536870912,n[r>>2]=v|A,n[r+4>>2]=x,F=l,0}function Ie(A,e){A|=0;var t,r,o=0,i=0;return r=F,F=F+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|LA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Pe(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,F=r,0|o):(F=r,0|(o=0))}function Le(A,e,t){A|=0,t|=0;var r=0;(0|(e|=0))>0?(r=0|We(e,4),n[A>>2]=r,r||M(27835,27858,40,27872)):n[A>>2]=0,n[A+4>>2]=e,n[A+8>>2]=0,n[A+12>>2]=t}function 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,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0;e=F,F=F+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(d=0|n[6981])>>>A))return o=0|n[(r=8+(A=27964+((t=(1&r^1)+A|0)<<1<<2)|0)|0)>>2],(0|(a=0|n[(i=o+8|0)>>2]))==(0|A)?n[6981]=d&~(1<>2]=A,n[r>>2]=a),y=t<<3,n[o+4>>2]=3|y,n[(y=o+y+4|0)>>2]=1|n[y>>2],F=e,0|i;if(u>>>0>(f=0|n[6983])>>>0){if(0|r)return t=((t=r<>>=l=t>>>12&16)>>>5&8)|l|(a=(t>>>=r)>>>2&4)|(A=(t>>>=a)>>>1&2)|(o=(t>>>=A)>>>1&1))+(t>>>o)|0)<<1<<2)|0)|0)>>2],(0|(r=0|n[(l=a+8|0)>>2]))==(0|t)?(A=d&~(1<>2]=t,n[A>>2]=r,A=d),s=(y=o<<3)-u|0,n[a+4>>2]=3|u,n[4+(i=a+u|0)>>2]=1|s,n[a+y>>2]=s,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,A&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=s,n[6986]=i,F=e,0|l;if(a=0|n[6982]){for(r=(a&0-a)-1|0,r=c=0|n[28228+(((o=(r>>>=i=r>>>12&16)>>>5&8)|i|(s=(r>>>=o)>>>2&4)|(l=(r>>>=s)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&n[c+4>>2])-u|0;(A=0|n[r+16>>2])||(A=0|n[r+20>>2]);)r=A,l=(i=(s=(-8&n[A+4>>2])-u|0)>>>0>>0)?A:l,c=i?s:c;if((s=l+u|0)>>>0>l>>>0){i=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){r=0;break}for(;;)if(r=0|n[(o=t+20|0)>>2])t=r,A=o;else{if(!(r=0|n[(o=t+16|0)>>2]))break;t=r,A=o}n[A>>2]=0,r=t}else r=0|n[l+8>>2],n[r+12>>2]=t,n[t+8>>2]=r,r=t}while(0);do{if(0|i){if(t=0|n[l+28>>2],(0|l)==(0|n[(A=28228+(t<<2)|0)>>2])){if(n[A>>2]=r,!r){n[6982]=a&~(1<>2])==(0|l)?y:i+20)>>2]=r,!r)break;n[r+24>>2]=i,0|(t=0|n[l+16>>2])&&(n[r+16>>2]=t,n[t+24>>2]=r),0|(t=0|n[l+20>>2])&&(n[r+20>>2]=t,n[t+24>>2]=r)}}while(0);return c>>>0<16?(y=c+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2]):(n[l+4>>2]=3|u,n[s+4>>2]=1|c,n[s+c>>2]=c,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|d,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=c,n[6986]=s),F=e,0|l+8}d=u}else d=u}else d=u}else if(A>>>0<=4294967231)if(u=-8&(A=A+11|0),o=0|n[6982]){i=0-u|0,c=(A>>>=8)?u>>>0>16777215?31:u>>>(7+(c=14-((l=(520192+(b=A<<(d=(A+1048320|0)>>>16&8))|0)>>>16&4)|d|(c=(245760+(b<<=l)|0)>>>16&2))+(b<>>15)|0)|0)&1|c<<1:0,r=0|n[28228+(c<<2)>>2];A:do{if(r)for(A=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((s=(-8&n[r+4>>2])-u|0)>>>0>>0){if(!s){A=r,i=0,b=65;break A}A=r,i=s}if(a=!(0|(b=0|n[r+20>>2]))|(0|b)==(0|(r=0|n[r+16+(l>>>31<<2)>>2]))?a:b,!r){r=a,b=61;break}l<<=1}else r=0,A=0,b=61}while(0);if(61==(0|b)){if(!(0|r)&!(0|A)){if(!(A=((A=2<>>=s=d>>>12&16)>>>5&8)|s|(l=(d>>>=a)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(d=(-8&n[a+4>>2])-u|0)>>>0>>0)?d:i,A=r?a:A,(r=0|n[a+16>>2])||(r=0|n[a+20>>2]),!r){l=A,s=i;break}a=r}if(0|l&&s>>>0<((0|n[6983])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){a=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){t=0;break}for(;;)if(r=0|n[(i=t+20|0)>>2])t=r,A=i;else{if(!(r=0|n[(i=t+16|0)>>2]))break;t=r,A=i}n[A>>2]=0}else y=0|n[l+8>>2],n[y+12>>2]=t,n[t+8>>2]=y}while(0);do{if(a){if(A=0|n[l+28>>2],(0|l)==(0|n[(r=28228+(A<<2)|0)>>2])){if(n[r>>2]=t,!t){o&=~(1<>2])==(0|l)?y:a+20)>>2]=t,!t)break;n[t+24>>2]=a,0|(A=0|n[l+16>>2])&&(n[t+16>>2]=A,n[A+24>>2]=t),(A=0|n[l+20>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);A:do{if(s>>>0<16)y=s+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2];else{if(n[l+4>>2]=3|u,n[f+4>>2]=1|s,n[f+s>>2]=s,t=s>>>3,s>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=f,n[t+12>>2]=f,n[f+8>>2]=t,n[f+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(r=(245760+(y<<=x)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[f+28>>2]=r,n[4+(A=f+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break}t=0|n[t>>2];e:do{if((-8&n[t+4>>2])!=(0|s)){for(o=s<<(31==(0|r)?0:25-(r>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|s)){t=A;break e}o<<=1,t=A}n[r>>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break A}}while(0);y=0|n[(w=t+8|0)>>2],n[y+12>>2]=f,n[w>>2]=f,n[f+8>>2]=y,n[f+12>>2]=t,n[f+24>>2]=0}}while(0);return F=e,0|l+8}d=u}else d=u;else d=-1}while(0);if((r=0|n[6983])>>>0>=d>>>0)return t=r-d|0,A=0|n[6986],t>>>0>15?(y=A+d|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|d):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),F=e,0|A+8;if((s=0|n[6984])>>>0>d>>>0)return x=s-d|0,n[6984]=x,w=(y=0|n[6987])+d|0,n[6987]=w,n[w+4>>2]=1|x,n[y+4>>2]=3|d,F=e,0|y+8;if(0|n[7099]?A=0|n[7101]:(n[7101]=4096,n[7100]=4096,n[7102]=-1,n[7103]=-1,n[7104]=0,n[7092]=0,n[7099]=-16&g^1431655768,A=4096),l=d+48|0,(u=(a=A+(c=d+47|0)|0)&(i=0-A|0))>>>0<=d>>>0)return F=e,0;if(0|(A=0|n[7091])&&(g=(f=0|n[7089])+u|0)>>>0<=f>>>0|g>>>0>A>>>0)return F=e,0;A:do{if(4&n[7092])t=0,b=143;else{r=0|n[6987];e:do{if(r){for(o=28372;!((g=0|n[o>>2])>>>0<=r>>>0&&(g+(0|n[o+4>>2])|0)>>>0>r>>>0);){if(!(A=0|n[o+8>>2])){b=128;break e}o=A}if((t=a-s&i)>>>0<2147483647)if((0|(A=0|ut(0|t)))==((0|n[o>>2])+(0|n[o+4>>2])|0)){if(-1!=(0|A)){s=t,a=A,b=145;break A}}else o=A,b=136;else t=0}else b=128}while(0);do{if(128==(0|b))if(-1!=(0|(r=0|ut(0)))&&(t=r,m=(t=((m=(h=0|n[7100])-1|0)&t?(m+t&0-h)-t|0:0)+u|0)+(h=0|n[7089])|0,t>>>0>d>>>0&t>>>0<2147483647)){if(0|(g=0|n[7091])&&m>>>0<=h>>>0|m>>>0>g>>>0){t=0;break}if((0|(A=0|ut(0|t)))==(0|r)){s=t,a=r,b=145;break A}o=A,b=136}else t=0}while(0);do{if(136==(0|b)){if(r=0-t|0,!(l>>>0>t>>>0&t>>>0<2147483647&-1!=(0|o))){if(-1==(0|o)){t=0;break}s=t,a=o,b=145;break A}if((A=c-t+(A=0|n[7101])&0-A)>>>0>=2147483647){s=t,a=o,b=145;break A}if(-1==(0|ut(0|A))){ut(0|r),t=0;break}s=A+t|0,a=o,b=145;break A}}while(0);n[7092]=4|n[7092],b=143}}while(0);if(143==(0|b)&&u>>>0<2147483647&&!(-1==(0|(x=0|ut(0|u)))|1^(v=(p=(m=0|ut(0))-x|0)>>>0>(d+40|0)>>>0)|x>>>0>>0&-1!=(0|x)&-1!=(0|m)^1)&&(s=v?p:t,a=x,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+(x=7&(x=c+8|0)?0-x&7:0)|0,x=(y=(0|n[6984])+s|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,n[c+y+4>>2]=40,n[6988]=n[7103];break}for(a>>>0<(0|n[6985])>>>0&&(n[6985]=a),r=a+s|0,t=28372;;){if((0|n[t>>2])==(0|r)){b=162;break}if(!(A=0|n[t+8>>2]))break;t=A}if(162==(0|b)&&!(8&n[t+12>>2])){n[t>>2]=a,n[(f=t+4|0)>>2]=(0|n[f>>2])+s,u=(f=a+(7&(f=a+8|0)?0-f&7:0)|0)+d|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-f-d|0,n[f+4>>2]=3|d;e:do{if((0|c)==(0|t))y=(0|n[6984])+l|0,n[6984]=y,n[6987]=u,n[u+4>>2]=1|y;else{if((0|n[6986])==(0|t)){y=(0|n[6983])+l|0,n[6983]=y,n[6986]=u,n[u+4>>2]=1|y,n[u+y>>2]=y;break}if(1==(3&(A=0|n[t+4>>2]))){s=-8&A,o=A>>>3;t:do{if(A>>>0<256){if(A=0|n[t+8>>2],(0|(r=0|n[t+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=r,n[r+8>>2]=A;break}a=0|n[t+24>>2],A=0|n[t+12>>2];do{if((0|A)==(0|t)){if(A=0|n[(o=4+(r=t+16|0)|0)>>2])r=o;else if(!(A=0|n[r>>2])){A=0;break}for(;;)if(o=0|n[(i=A+20|0)>>2])A=o,r=i;else{if(!(o=0|n[(i=A+16|0)>>2]))break;A=o,r=i}n[r>>2]=0}else y=0|n[t+8>>2],n[y+12>>2]=A,n[A+8>>2]=y}while(0);if(!a)break;o=28228+((r=0|n[t+28>>2])<<2)|0;do{if((0|n[o>>2])==(0|t)){if(n[o>>2]=A,0|A)break;n[6982]=n[6982]&~(1<>2])==(0|t)?y:a+20)>>2]=A,!A)break t}while(0);if(n[A+24>>2]=a,0|(o=0|n[(r=t+16|0)>>2])&&(n[A+16>>2]=o,n[o+24>>2]=A),!(r=0|n[r+4>>2]))break;n[A+20>>2]=r,n[r+24>>2]=A}while(0);t=t+s|0,i=s+l|0}else i=l;if(n[(t=t+4|0)>>2]=-2&n[t>>2],n[u+4>>2]=1|i,n[u+i>>2]=i,t=i>>>3,i>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=u,n[t+12>>2]=u,n[u+8>>2]=t,n[u+12>>2]=r;break}t=i>>>8;do{if(t){if(i>>>0>16777215){o=31;break}o=i>>>(7+(o=14-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=x)|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 F=e,0|f+8}for(t=28372;!((A=0|n[t>>2])>>>0<=c>>>0&&(y=A+(0|n[t+4>>2])|0)>>>0>c>>>0);)t=0|n[t+8>>2];t=(A=(A=(i=y+-47|0)+(7&(A=i+8|0)?0-A&7:0)|0)>>>0<(i=c+16|0)>>>0?c:A)+8|0,w=a+(x=7&(x=a+8|0)?0-x&7:0)|0,x=(r=s+-40|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,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-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=x)|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+(x=7&(x=a+8|0)?0-x&7:0)|0,x=(y=s+-40|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>d>>>0)return x=t-d|0,n[6984]=x,w=(y=0|n[6987])+d|0,n[6987]=w,n[w+4>>2]=1|x,n[y+4>>2]=3|d,F=e,0|y+8}return n[(y=27920)>>2]=12,F=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|x(e,A),(e|A)>>>0>65535&&(t=((t>>>0)/(A>>>0)|0)==(0|e)?t:-1)):t=0,(A=0|Ue(t))&&3&n[A+-4>>2]?(lt(0|A,0,0|t),0|A):0|A}function Ve(A,e,t,r){return 0|(C((e|=0)+(r|=0)+((t=(A|=0)+(t|=0)>>>0)>>>0>>0|0)>>>0|0),t)}function Ze(A,e,t,r){return 0|(C(0|(r=(e|=0)-(r|=0)-((t|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-t>>>0)}function Ke(A){return 0|((A|=0)?31-(0|k(A^A-1)):32)}function Je(A,e,t,r,o){o|=0;var i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(u=A|=0,a=t|=0,s=d=r|=0,!(c=l=e|=0))return i=!!(0|o),s?i?(n[o>>2]=0|A,n[o+4>>2]=0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(d=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=f=i+1|0,A=u>>>(f>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(f>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(f=32-s|0)-1>>31&c>>>((g=s-32|0)>>>0)|(c<>>(s>>>0))&(e=g>>31),e&=c>>>(s>>>0),i=u<<(h=64-s|0)&(l=f>>31),s=(c<>>(g>>>0))&l|u<>31;break}return 0|o&&(n[o>>2]=i&u,n[o+4>>2]=0),1==(0|a)?(h=0|A,0|(C(0|(g=l|0&e)),h)):(g=c>>>((h=0|Ke(0|a))>>>0)|0,h=c<<32-h|u>>>(h>>>0),0|(C(0|g),h))}if(i)return 0|o&&(n[o>>2]=(c>>>0)%(a>>>0),n[o+4>>2]=0),h=(c>>>0)/(a>>>0)>>>0,0|(C(0|(g=0)),h);if(!u)return 0|o&&(n[o>>2]=0,n[o+4>>2]=(c>>>0)%(s>>>0)),h=(c>>>0)/(s>>>0)>>>0,0|(C(0|(g=0)),h);if(!((i=s-1|0)&s))return 0|o&&(n[o>>2]=0|A,n[o+4>>2]=i&c|0&e),g=0,h=c>>>((0|Ke(0|s))>>>0),0|(C(0|g),h);if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=30){a=e=i+1|0,A=c<<(s=31-i|0)|u>>>(e>>>0),e=c>>>(e>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,h=0,0|(C(0|(g=0)),h)):(h=0,0|(C(0|(g=0)),h))}while(0);if(a){c=0|Ve(0|(f=0|t),0|(u=d|0&r),-1,-1),t=0|B(),l=s,s=0;do{r=l,l=i>>>31|l<<1,i=s|i<<1,Ze(0|c,0|t,0|(r=A<<1|r>>>31),0|(d=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|d,g&f|0,(((0|h)<0?-1:0)>>31|((0|h)<0?-1:0)<<1)&u),e=0|B(),a=a-1|0}while(0|a);c=l,l=0}else c=s,l=0,s=0;return a=0,0|o&&(n[o>>2]=A,n[o+4>>2]=e),h=i<<1&-2|s,0|(C(0|(g=(0|i)>>>31|(c|a)<<1|l)),h)}function Xe(A,e,t,r){var n,o,i,a,s;return t|=0,o=(r|=0)>>31|((0|r)<0?-1:0)<<1,n=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,i=0|Ze((s=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(a=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|s,0|a),A=o^s,e=n^a,0|Ze((0|Je(i,0|B(),0|Ze(o^t|0,n^r|0,0|o,0|n),0|B(),0))^A,(0|B())^e,0|A,0|e)}function qe(A,e,t,r){var n,o;return e|=0,r|=0,t=0|function(A,e){var t,r,n,o=0;return A=((t=0|x(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|x(o,r=A>>>16))|0,e=0|x(o=e>>>16,n),0|(C((A>>>16)+(0|x(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|x(e,o))+(0|x(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=F,F=F+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(),F=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=F,F=F+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),F=i,0|(C(0|n[o+4>>2]),n[o>>2])}function et(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>t|0),A>>>t|(e&(1<>t-32)}function tt(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>>t|0),A>>>t|(e&(1<>>t-32|0)}function rt(A,e,t){return A|=0,(0|(t|=0))<32?(C((e|=0)<>>32-t),A<=0?+s(A+.5):+v(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return Q(0|A,0|e,0|t),0|A;if(i=0|A,o=A+t|0,(3&A)==(3&e)){for(;3&A;){if(!t)return 0|i;r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0,t=t-1|0}for(a=(t=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],n[A+12>>2]=n[e+12>>2],n[A+16>>2]=n[e+16>>2],n[A+20>>2]=n[e+20>>2],n[A+24>>2]=n[e+24>>2],n[A+28>>2]=n[e+28>>2],n[A+32>>2]=n[e+32>>2],n[A+36>>2]=n[e+36>>2],n[A+40>>2]=n[e+40>>2],n[A+44>>2]=n[e+44>>2],n[A+48>>2]=n[e+48>>2],n[A+52>>2]=n[e+52>>2],n[A+56>>2]=n[e+56>>2],n[A+60>>2]=n[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|t);)n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}else for(t=o-4|0;(0|A)<(0|t);)r[0|A]=0|r[0|e],r[A+1|0]=0|r[e+1|0],r[A+2|0]=0|r[e+2|0],r[A+3|0]=0|r[e+3|0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|o);)r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0;return 0|i}function lt(A,e,t){e|=0;var o,i=0,a=0,s=0;if(o=(A|=0)+(t|=0)|0,e&=255,(0|t)>=67){for(;3&A;)r[0|A]=e,A=A+1|0;for(s=e|e<<8|e<<16|e<<24,a=(i=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=s,n[A+4>>2]=s,n[A+8>>2]=s,n[A+12>>2]=s,n[A+16>>2]=s,n[A+20>>2]=s,n[A+24>>2]=s,n[A+28>>2]=s,n[A+32>>2]=s,n[A+36>>2]=s,n[A+40>>2]=s,n[A+44>>2]=s,n[A+48>>2]=s,n[A+52>>2]=s,n[A+56>>2]=s,n[A+60>>2]=s,A=A+64|0;for(;(0|A)<(0|i);)n[A>>2]=s,A=A+4|0}for(;(0|A)<(0|o);)r[0|A]=e,A=A+1|0;return o-t|0}function ct(A){return(A=+A)>=0?+s(A+.5):+v(A-.5)}function ut(A){var e,t,r;return A|=0,r=0|E(),(0|A)>0&(0|(e=(t=0|n[a>>2])+A|0))<(0|t)|(0|e)<0?(j(0|e),D(12),-1):(0|e)>(0|r)&&!(0|N(0|e))?(D(12),-1):(n[a>>2]=e,0|t)}return{___divdi3:Xe,___muldi3:qe,___remdi3:$e,___uremdi3:At,_areNeighborCells:function(A,e,t,r,o){o|=0;var i,a,s,l=0,c=0,u=0,f=0;if(s=F,F=F+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return F=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,F=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,f=0|tt(0|t,0|r,52),B(),(0|c)!=(15&f))return F=s,12;if(l=c+-1|0,c>>>0>1){TA(A,e,l,a),TA(t,r,l,i),u=0|n[(f=a)>>2],f=0|n[f+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|f)==(0|n[i+4>>2])){l=0|tt(0|A,0|e,0|(c=3*(15^c)|0)),B(),l&=7,c=0|tt(0|t,0|r,0|c),B(),c&=7;do{if(!(0|l)|!(0|c))n[o>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|HA(u,f)){l=5;break}if((0|n[15536+(l<<2)>>2])!=(0|c)&&(0|n[15568+(l<<2)>>2])!=(0|c))break A;n[o>>2]=1,l=0}}while(0);return F=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 S(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,F=s,0},_bitshift64Ashr:et,_bitshift64Lshr:tt,_bitshift64Shl:rt,_calloc:We,_cellAreaKm2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475),0|A},_cellAreaM2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475*1e3*1e3),0|A},_cellAreaRads2:ue,_cellToBoundary:$A,_cellToCenterChild:GA,_cellToChildPos:function(A,e,t,r){t|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0;if(o=F,F=F+16|0,p=o,v=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return F=o,4;if((0|(v&=15))<(0|t))return F=o,12;if((0|v)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|v)>(0|t)){c=t;do{b=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,a|=b,l=0|B()|l}while((0|c)<(0|v));b=a}else b=a;else b=A,l=e;m=0|tt(0|b,0|l,45),B();A:do{if(0|z(127&m)){if(c=0|tt(0|b,0|l,52),B(),0|(c&=15))for(a=1;;){if(!(!((m=0|rt(7,0,3*(15-a|0)|0))&b)&!((0|B())&l))){u=33;break A}if(!(a>>>0>>0))break;a=a+1|0}if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(m=-15728641&e,h=v;;){if(g=h,(h=h+-1|0)>>>0>15|(0|v)<(0|h)){u=19;break}if((0|v)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|v)<(0|g))d=a;else{u=h;do{d=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,c=0|B()|c}while((0|u)<(0|v));d=a}else d=A,c=e;if(f=0|tt(0|d,0|c,45),B(),0|z(127&f)){f=0|tt(0|d,0|c,52),B(),f&=15;e:do{if(f)for(u=1;;){if(a=0|tt(0|d,0|c,3*(15-u|0)|0),B(),0|(a&=7))break e;if(!(u>>>0>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|tt(0|A,0|e,3*(15-g|0)|0),B(),7==(0|(c&=7))){i=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){i=5,u=42;break}if(0|(d=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=v-g|0,((0|u)<0)<<31>>31),f=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|f,5,0)),0|B(),-5,-1),a=0|Ve(0|(a=0|Xe(0|a,0|B(),6,0)),0|B(),1,0),c=0|B()):(a=u,c=f),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|f,0|(g=d+-1|0),((0|g)<0)<<31>>31)),0|B()),f=0|Ve(0|g,0|(d=0|B()),0|n[(f=r)>>2],0|n[f+4>>2]),d=0|B(),n[(g=r)>>2]=f,n[g+4>>2]=d),(0|h)<=(0|t)){u=37;break}}if(19==(0|u))M(27795,27122,1367,27158);else{if(37==(0|u)){i=0|n[(s=r)+4>>2],s=0|n[s>>2];break}if(42==(0|u))return F=o,0|i}}else i=0,s=0}else u=33}while(0);A:do{if(33==(0|u)){if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(a=v;;){if(i=0|tt(0|A,0|e,3*(15-a|0)|0),B(),7==(0|(i&=7))){i=5;break}if(i=0|qe(0|(s=0|pe(7,0,s=v-a|0,((0|s)<0)<<31>>31)),0|B(),0|i,0),s=0|B(),s=0|Ve(0|n[(m=r)>>2],0|n[m+4>>2],0|i,0|s),i=0|B(),n[(m=r)>>2]=s,n[m+4>>2]=i,(0|(a=a+-1|0))<=(0|t))break A}return F=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,v,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(v=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[v>>2])>>>0>s>>>0:0))?(F=o,0|(v=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=F,F=F+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 F=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 F=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=F,F=F+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),F=s,0|A},_cellToParent:TA,_cellToVertex:Pe,_cellToVertexes:function(A,e,t){t|=0;var r,o=0,i=0;return i=!(0|HA(A|=0,e|=0)),r=!(0|(o=0|Pe(A,e,0,t))),i?r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||(o=0|Pe(A,e,4,t+32|0))?0|(i=o):0|Pe(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||0|(o=0|Pe(A,e,4,t+32|0))?0|(i=o):(n[(i=t+40|0)>>2]=0,n[i+4>>2]=0,0|(i=0)):0|(i=o)},_cellsToDirectedEdge:function(A,e,t,r,o){return o|=0,7==(0|(t=0|_(A|=0,e|=0,t|=0,r|=0)))?0|(o=11):(r=0|rt(0|t,0,56),e=-2130706433&e|B()|268435456,n[o>>2]=A|r,n[o+4>>2]=e,0|(o=0))},_cellsToLinkedMultiPolygon:function(A,e,t){t|=0;var r,i,a,s=0;if(a=F,F=F+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=F,F=F+176|0,r=o,(0|(e|=0))<1)return Le(t,0,0),F=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Le(t,(0|e)>6?e:6,15&c),c=0;!(0|(i=0|$A(0|n[(i=A+(c<<3)|0)>>2],0|n[i+4>>2],r)));){if((0|(i=0|n[r>>2]))>0){l=0;do{s=r+8+(l<<4)|0,(a=0|ze(t,i=r+8+((0|(l=l+1|0))%(0|i)<<4)|0,s))?_e(t,a):He(t,s,i),i=0|n[r>>2]}while((0|l)<(0|i))}if((0|(c=c+1|0))>=(0|e)){i=0,u=13;break}}return 13==(0|u)?(F=o,0|i):(Re(t),F=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return F=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|fe(t);do{de(e,A),s=A+16|0,n[r>>2]=n[s>>2],n[r+4>>2]=n[s+4>>2],n[r+8>>2]=n[s+8>>2],n[r+12>>2]=n[s+12>>2],_e(i,A),A=0|Ge(i,r)}while(0|A);A=0|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,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,D=0,E=0,Q=0,N=0,j=0,F=0,S=0,P=0,I=0,L=0;if(0|n[(s=(A|=0)+8|0)>>2])return 1;if(!(a=0|n[A>>2]))return 0;r=a,i=0;do{i=i+1|0,r=0|n[r+8>>2]}while(0|r);if(i>>>0<2)return 0;(t=0|Ue(i<<2))||M(27396,27235,317,27415),(e=0|Ue(i<<5))||M(27437,27235,321,27415),n[A>>2]=0,n[(E=A+4|0)>>2]=0,n[s>>2]=0,i=0,P=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(d=+o[u+8>>3],r=u,u=0|n[u+16>>2],f=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(d-f))>3.141592653589793){L=14;break}c+=(f-d)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|L)){L=0,c=0,r=h;do{B=+o[r+8>>3],F=0|n[(S=r+16|0)>>2],C=+o[(F=0|F?F:h)+8>>3],c+=(+o[r>>3]+ +o[F>>3])*((C<0?C+6.283185307179586:C)-(B<0?B+6.283185307179586:B)),r=0|n[(0|r?S:a)>>2]}while(0|r)}c>0?(n[t+(P<<2)>>2]=a,P=P+1|0,s=D,r=m):L=19}else L=19;if(19==(0|L)){L=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){L=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){L=21;break A}if(!(i=0|We(1,12))){L=23;break A}n[r>>2]=i,s=i+4|0,u=i,r=m}while(0);if(n[u>>2]=a,n[s>>2]=a,u=e+(D<<5)|0,g=0|n[a>>2]){for(o[(h=e+(D<<5)+8|0)>>3]=17976931348623157e292,o[(m=e+(D<<5)+24|0)>>3]=17976931348623157e292,o[u>>3]=-17976931348623157e292,o[(b=e+(D<<5)+16|0)>>3]=-17976931348623157e292,y=17976931348623157e292,k=-17976931348623157e292,s=0,p=g,d=17976931348623157e292,x=17976931348623157e292,w=-17976931348623157e292,f=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((v=!(0|p))?g:p)+8>>3],c>3]=c,d=c),B>3]=B,x=B),c>w?o[u>>3]=c:c=w,B>f&&(o[b>>3]=B,f=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!v;)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[(S=a+8|0)>>2],n[S>>2]=0,!a){L=45;break}D=s,m=r}if(21==(0|L))M(27213,27235,35,27247);else if(23==(0|L))M(27267,27235,37,27247);else if(27==(0|L))M(27310,27235,61,27333);else if(45==(0|L)){A:do{if((0|P)>0){for(S=!(0|s),j=s<<2,F=!(0|A),N=0,r=0;;){if(Q=0|n[t+(N<<2)>>2],S)L=73;else{if(!(D=0|Ue(j))){L=50;break}if(!(E=0|Ue(j))){L=52;break}e:do{if(F)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[Q>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,v=i+1|0):v=i,u=0|n[u+8>>2];)s=s+1|0,i=v;if((0|v)>0)if(a=0|n[D>>2],1==(0|v))i=a;else for(b=0,p=-1,i=a,m=a;;){for(g=0|n[m>>2],a=0,u=0;h=(0|(s=0|n[n[D+(u<<2)>>2]>>2]))==(0|g)?a:a+(1&he(s,0|n[E+(u<<2)>>2],0|n[g>>2]))|0,(0|(u=u+1|0))!=(0|v);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|v))break e;b=a,p=s?h:p,m=0|n[D+(a<<2)>>2]}else i=0}}while(0);if(Ye(D),Ye(E),i){if(a=0|n[(s=i+4|0)>>2])i=a+8|0;else if(0|n[i>>2]){L=70;break}n[i>>2]=Q,n[s>>2]=Q}else L=73}if(73==(0|L)){if(L=0,0|(r=0|n[Q>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(Q),r=1}if((0|(N=N+1|0))>=(0|P)){I=r;break A}}50==(0|L)?M(27452,27235,249,27471):52==(0|L)?M(27490,27235,252,27471):70==(0|L)&&M(27310,27235,61,27333)}else I=0}while(0);return Ye(t),Ye(e),0|I}return 0}(t))?(ge(t),F=a,0|(s=A)):(F=a,0|(s=0))},_childPosToCell:function(A,e,t,r,o,i){A|=0,e|=0,i|=0;var a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=F,F=F+16|0,s=a,(o|=0)>>>0>15)return F=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return F=a,12;if(0|_A(t,r,o,s)&&M(27795,27122,1327,27173),!(((0|e)>-1|-1==(0|e)&A>>>0>4294967295)&((0|(u=0|n[(f=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[f>>2])>>>0>A>>>0:0))))return F=a,2;f=o-l|0,o=0|rt(0|o,0,52),c=B()|-15728641&r,n[(u=i)>>2]=o|t,n[u+4>>2]=c,u=0|tt(0|t,0|r,45),B();A:do{if(0|z(127&u)){if(0|l)for(s=1;;){if(!(!((u=0|rt(7,0,3*(15-s|0)|0))&t)&!((0|B())&r)))break A;if(!(s>>>0>>0))break;s=s+1|0}if((0|f)<1)return F=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=f-c|0,((0|l)<0)<<31>>31),t=0|B();do{if(s){if(s=0|Xe(0|(s=0|Ve(0|(s=0|qe(0|l,0|t,5,0)),0|B(),-5,-1)),0|B(),6,0),(0|e)>(0|(o=0|B()))|(0|e)==(0|o)&A>>>0>s>>>0){e=0|Ze(0|(e=0|Ve(0|A,0|e,-1,-1)),0|B(),0|s,0|o),s=0|B(),h=0|n[(d=i)>>2],d=0|n[d+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),d&=~B(),m=0|rt(0|(o=0|Ve(0|(r=0|Xe(0|e,0|s,0|l,0|t)),0|(A=0|B()),2,0)),0|B(),0|m),d=0|B()|d,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=d,A=0|Ze(0|e,0|s,0|(A=0|qe(0|r,0|A,0|l,0|t)),0|B()),s=0,e=0|B();break}g=0|n[(m=i)>>2],m=0|n[m+4>>2],h=0|rt(7,0,3*(u+r|0)|0),m&=~B(),n[(s=i)>>2]=g&~h,n[s+4>>2]=m,s=1;break}o=0|n[(g=i)>>2],g=0|n[g+4>>2],d=0|rt(7,0,0|(r=3*(u+r|0)|0)),g&=~B(),r=0|rt(0|(m=0|Xe(0|A,0|e,0|l,0|t)),0|(s=0|B()),0|r),g=0|B()|g,n[(h=i)>>2]=r|o&~d,n[h+4>>2]=g,A=0|Ze(0|A,0|e,0|(s=0|qe(0|m,0|s,0|l,0|t)),0|B()),s=0,e=0|B()}while(0);if(!((0|f)>(0|c))){e=0;break}r=~c,c=c+1|0}return F=a,0|e}}while(0);if((0|f)<1)return F=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=f-s|0,((0|h)<0)<<31>>31),m=0|B(),t=0|n[(c=i)>>2],c=0|n[c+4>>2],r=0|rt(7,0,0|(l=3*(o-s|0)|0)),c&=~B(),l=0|rt(0|(d=0|Xe(0|A,0|e,0|h,0|m)),0|(g=0|B()),0|l),c=0|B()|c,n[(u=i)>>2]=l|t&~r,n[u+4>>2]=c,A=0|Ze(0|A,0|e,0|(m=0|qe(0|d,0|g,0|h,0|m)),0|B()),e=0|B(),(0|f)<=(0|s)){e=0;break}s=s+1|0}return F=a,0|e},_compactCells:function(A,e,t,r){e|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,D=0,E=0,Q=0,N=0,j=0,F=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[(F=e)>>2]=a,n[F+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{j=0|n[4+(N=A+(i<<3)|0)>>2],n[(F=e+(i<<3)|0)>>2]=n[N>>2],n[F+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),!(N=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(),Q=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(x=0|rt(0|Q,0,52),w=0|B(),Q>>>0>15){if(!(!(0|u)&!(0|i))){F=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,F=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){F=21;break A}if(f=0|tt(0|l,0|A,52),B(),(0|(f&=15))<(0|Q)){i=12,F=27;break A}if((0|f)!=(0|Q)&&(l|=x,A=-15728641&A|w,f>>>0>=E>>>0)){c=Q;do{k=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,l|=k,A=0|B()|A}while(c>>>0>>0)}if(g=0|At(0|l,0|A,0|t,0|r),h=0|B(),!(!(0|(d=0|n[(f=c=N+(g<<3)|0)>>2]))&!(0|(f=0|n[f+4>>2])))){p=0,v=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&v>>>0>t>>>0){F=31;break A}if((0|d)==(0|l)&(-117440513&f)==(0|A)){m=0|tt(0|d,0|f,56),B(),b=1+(m&=7)|0,k=0|tt(0|d,0|f,45),B();t:do{if(0|z(127&k)){if(d=0|tt(0|d,0|f,52),B(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((k=0|rt(7,0,3*(15-f|0)|0))&l)&!((0|B())&A))){f=7;break t}if(!(f>>>0>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){F=41;break A}k=0|rt(0|b,0,56),A=B()|-117440513&A,n[(y=c)>>2]=0,n[y+4>>2]=0,l|=k}else g=0|$e(0|(g=0|Ve(0|g,0|h,1,0)),0|B(),0|t,0|r),h=0|B();v=0|Ve(0|v,0|p,1,0),p=0|B(),d=0|n[(f=c=N+(g<<3)|0)>>2],f=0|n[f+4>>2]}while(!(!(0|d)&!(0|f)))}n[(k=c)>>2]=l,n[k+4>>2]=A}if(a=0|Ve(0|a,0|s,1,0),!((0|(s=0|B()))<(0|r)|(0|s)==(0|r)&a>>>0>>0))break e;l=0|n[(A=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){F=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){F=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=f=N+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{d=0|tt(0|a,0|s,56),B(),l=1+(d&=7)|0,g=-117440513&s,y=0|tt(0|a,0|s,45),B();e:do{if(0|z(127&y)){if(h=0|tt(0|a,0|s,52),B(),0|(h&=15))for(c=1;;){if(!(!(a&(y=0|rt(7,0,3*(15-c|0)|0)))&!(g&(0|B()))))break e;if(!(c>>>0>>0))break;c=c+1|0}a|=s=0|rt(0|l,0,56),s=0|B()|g,n[(l=f)>>2]=a,n[l+4>>2]=s,l=d+2|0}}while(0);7==(0|l)?(n[(y=k+(A<<3)|0)>>2]=a,n[y+4>>2]=-117440513&s,A=0|Ve(0|A,0|m,1,0),y=0|B()):y=m}if(b=0|Ve(0|b,0|p,1,0),!((0|(p=0|B()))<(0|r)|(0|p)==(0|r)&b>>>0>>0))break;m=y}if(C){if(v=Q>>>0>15,x=0|rt(0|Q,0,52),w=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(Q=e+(a<<3)|0)>>2]=u,n[Q+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()),l=0|Ve(0|l,0|s,1,0),(0|(s=0|B()))<(0|r)|(0|s)==(0|r)&l>>>0>>0;)u=0|n[(i=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(),v|(0|(h&=15))<(0|Q)){F=80;break A}if((0|h)!=(0|Q)){if(f=u|x,d=-15728641&i|w,h>>>0>=E>>>0){g=Q;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,f|=D,d=0|B()|d}while(g>>>0>>0)}}else f=u,d=i;m=0|At(0|f,0|d,0|t,0|r),g=0,h=0,p=0|B();do{if((0|g)>(0|r)|(0|g)==(0|r)&h>>>0>t>>>0){F=81;break A}if((-117440513&(b=0|n[4+(D=N+(m<<3)|0)>>2]))==(0|d)&&(0|n[D>>2])==(0|f)){F=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=N+(m<<3)|0}while((0|n[D>>2])!=(0|f)||(0|n[D+4>>2])!=(0|d));if(65==(0|F)&&(F=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|N,0,0|o),st(0|j,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){F=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|F))!0&!(117440512&i)?(i=4,F=27):F=21;else if(31==(0|F))M(27795,27122,620,27132);else{if(41==(0|F))return Ye(j),Ye(N),10;if(48==(0|F))return Ye(j),Ye(N),13;80==(0|F)?M(27795,27122,711,27132):81==(0|F)?M(27795,27122,723,27132):85==(0|F)&&(st(0|e,0|j,t<<3),F=89)}return 21==(0|F)?(Ye(j),Ye(N),0|(F=5)):27==(0|F)?(Ye(j),Ye(N),0|(F=i)):89==(0|F)?(Ye(j),Ye(N),0|(F=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=F,F=F+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),F=r,0|a):(F=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=F,F=F+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,F=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,F=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,o[t>>3]=h,F=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=F,F=F+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,F=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,F=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,h*=1e3,o[t>>3]=h,F=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=F,F=F+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return F=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return F=r,0;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+i)*+f(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,F=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:IA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=F,F=F+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),F=r,0|i):(F=r,0|(i=6))},_getDirectedEdgeOrigin:function(A,e,t){return A|=0,t|=0,!0&268435456==(2013265920&(e|=0))?(n[t>>2]=A,n[t+4>>2]=-2130706433&e|134217728,0|(t=0)):0|(t=6)},_getHexagonAreaAvgKm2:se,_getHexagonAreaAvgM2:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20784+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgKm:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20912+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgM:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[21040+(A<<3)>>3],0|(e=0))},_getIcosahedronFaces:function A(e,t,r){r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;o=F,F=F+128|0,f=o+112|0,s=o+96|0,d=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[f>>2]=c,l=0|tt(0|e,0|t,45),B(),l&=127;A:do{if(0|z(l)){if(0|c)for(i=1;;){if(!(!((u=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){a=0;break A}if(!(i>>>0>>0))break;i=i+1|0}if(!(1&a))return u=0|rt(c+1|0,0,52),d=B()|-15728641&t,d=0|A((u|e)&~(f=0|rt(7,0,3*(14-c|0)|0)),d&~B(),r),F=o,0|d;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(NA(s,f,d),u=5):(PA(s,f,d),u=6);A:do{if(0|z(l))if(c)for(i=1;;){if(!(!((l=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){e=2;break A}if(!(i>>>0>>0)){e=5;break}i=i+1|0}else e=5;else e=2}while(0);lt(0|r,-1,e<<2);A:do{if(a)for(s=0;;){if(FA(l=d+(s<<4)|0,0|n[f>>2]),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}else for(s=0;;){if(jA(l=d+(s<<4)|0,0|n[f>>2],0,1),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}}while(0)}return F=o,0|i},_getIndexDigit:function(A,e,t,r){return r|=0,((t|=0)-1|0)>>>0>14?0|(r=4):(t=0|tt(0|(A|=0),0|(e|=0),3*(15-t|0)|0),B(),n[r>>2]=7&t,0|(r=0))},_getNumCells:le,_getPentagons:Ae,_getRes0Cells:function(A){A|=0;var e=0,t=0,r=0;e=0;do{rt(0|e,0,45),r=134225919|B(),n[(t=A+(e<<3)|0)>>2]=-1,n[t+4>>2]=r,e=e+1|0}while(122!=(0|e));return 0},_getResolution:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),15&e},_greatCircleDistanceKm:ae,_greatCircleDistanceM:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:S,_gridDiskDistances:P,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=F,F=F+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(F=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(F=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,F=a,0|(l=0))},_gridPathCells:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,D=0,E=0;if(a=F,F=F+48|0,c=a+12|0,D=a,!(s=0|me(A|=0,e|=0,A,e,i=a+24|0))&&!(s=0|me(A,e,t,r,c))){C=((0|(k=0|kA(i,c)))<0)<<31>>31,n[i>>2]=0,n[i+4>>2]=0,n[i+8>>2]=0,n[c>>2]=0,n[c+4>>2]=0,n[c+8>>2]=0,0|me(A,e,A,e,i)&&M(27795,27538,692,27747),0|me(A,e,t,r,c)&&M(27795,27538,697,27747),CA(i),CA(c),g=0|k?1/+(0|k):0,t=0|n[i>>2],v=g*+((0|n[c>>2])-t|0),r=0|n[(x=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=v*(f=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=w*f+ +(0|r),f=g*f+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+f),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),f=+l(+(+(0|s)-f));do{if(!(E>u&E>f)){if(d=0-t|0,u>f){r=d-s|0;break}r=c,s=d-c|0;break}t=0-(c+s)|0,r=c}while(0);if(n[D>>2]=t,n[h>>2]=r,n[m>>2]=s,BA(D),0|(s=0|be(A,e,D,o+(p<<3)|0)))break A;if(!((0|b)<(0|C)|(0|b)==(0|C)&p>>>0>>0)){s=0;break A}t=0|Ve(0|p,0|b,1,0),b=r=0|B(),p=t,t=0|n[i>>2],r=0|n[x>>2],s=0|n[y>>2]}}while(0);return F=a,0|s}return F=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=F,F=F+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))?(F=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,F=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,f=0,d=0;if(o=F,F=F+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,F=o,0;do{if((0|t)>=0){if((0|t)>13780509){if(0|(i=0|le(15,s)))break;i=0|n[(a=s)>>2],a=0|n[a+4>>2]}else f=0|qe(0|t,0|(i=((0|t)<0)<<31>>31),3,0),a=0|B(),i=0|Ve(0|t,0|i,1,0),i=0|Ve(0|(i=0|qe(0|f,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(f=s)>>2]=i,n[f+4>>2]=a;if(u=0|We(i,8)){if(!(f=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|L(A,e,t,u,f,i,a,0))){Ye(u),Ye(f);break}if(e=0|n[s>>2],(0|(s=0|n[s+4>>2]))>0|!(0|s)&e>>>0>0){i=0,l=0,c=0;do{!(0|(a=0|n[(A=u+(l<<3)|0)>>2]))&!(0|(A=0|n[A+4>>2]))||(0|n[f+(l<<2)>>2])!=(0|t)||(n[(d=r+(i<<3)|0)>>2]=a,n[d+4>>2]=A,i=i+1|0),l=0|Ve(0|l,0|c,1,0),c=0|B()}while((0|c)<(0|s)|(0|c)==(0|s)&l>>>0>>0)}Ye(u),Ye(f),i=0}else i=13}else i=2}while(0);return F=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:LA,_isValidDirectedEdge:MA,_isValidIndex:function(A,e){A|=0;var t=0,n=0,o=0,i=0;if(!0&134217728==(-16777216&(e|=0))&&(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0<=121)&&!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())){if(!(0|r[20528+t|0]))return 1;if(!(0|A)&!(0|(t=8191&e)))return 1;if(i=0|nt(0|A,0|t),B(),(63-i|0)%3|0)return 1}return 0|MA(A,e)?0|(i=1):0|(i=1&!!(0|Ie(A,e)))},_isValidVertex:Ie,_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=F,F=F+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)),F=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=F,F=F+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return F=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 F=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,d=0,g=0,h=0,m=0,b=0,p=0;if(s=F,F=F+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,F=s,0;RA(h,0,0,0),c=0|n[(d=h)>>2],d=0|n[d+4>>2];do{if(e>>>0>15)n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=4,m=9;else{if(0|(t=0|Ce(t))){n[(h=a)>>2]=0,n[h+4>>2]=0,n[a+8>>2]=t,n[a+12>>2]=-1,m=a+29|0,n[(h=a+16|0)>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,r[h+12|0]=0,r[0|m]=0|r[0|g],r[m+1|0]=0|r[g+1|0],r[m+2|0]=0|r[g+2|0],m=9;break}if(!(t=0|We(1+(0|n[A+8>>2])|0,32))){n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=13,m=9;break}Be(A,t),n[(p=a)>>2]=c,n[p+4>>2]=d,n[(d=a+8|0)>>2]=0,n[a+12>>2]=e,n[a+20>>2]=A,n[a+24>>2]=t,r[a+28|0]=0,r[0|(c=a+29|0)]=0|r[0|g],r[c+1|0]=0|r[g+1|0],r[c+2|0]=0|r[g+2|0],n[a+16>>2]=3,b=+J(t),b*=+Z(t),u=+l(+ +o[t>>3]),u=b/+f(+ +it(+u,+ +l(+ +o[t+8>>3])))*6371.007180918475*6371.007180918475,t=0|n[(c=a+12|0)>>2];A:do{if((0|t)>0)do{if(se(t+-1|0,h),!(u/+o[h>>3]>10))break A;t=(p=0|n[c>>2])-1|0,n[c>>2]=t}while((0|p)>1)}while(0);if(xe(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,xe(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[d>>2]}}while(0);return F=s,0|t},_memcpy:st,_memset:lt,_originToDirectedEdges:function(A,e,t){t|=0;var r,o=0;return r=!(0|HA(A|=0,e|=0)),e&=-2130706433,n[(o=t)>>2]=r?A:0,n[o+4>>2]=r?285212672|e:0,n[(o=t+8|0)>>2]=A,n[o+4>>2]=301989888|e,n[(o=t+16|0)>>2]=A,n[o+4>>2]=318767104|e,n[(o=t+24|0)>>2]=A,n[o+4>>2]=335544320|e,n[(o=t+32|0)>>2]=A,n[o+4>>2]=352321536|e,n[(t=t+40|0)>>2]=A,n[t+4>>2]=369098752|e,0},_pentagonCount:function(){return 12},_polygonToCells:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i,a,s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,N=0,j=0,S=0,P=0,R=0,T=0,_=0;if(s=F,F=F+112|0,o=s+80|0,d=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return F=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return F=s,13;if(Be(A,_),!(l=0|Ce(t))){if(T=0|n[(R=A)+4>>2],n[(l=d)>>2]=n[R>>2],n[l+4>>2]=T,ke(d,o),l=0|eA(o,e,i))R=0,T=0;else{if(l=0|n[d>>2],(0|(c=0|n[g>>2]))>0){u=0|n[A+12>>2],t=0;do{l=(0|n[u+(t<<3)>>2])+l|0,t=t+1|0}while((0|t)!=(0|c));t=l}else t=l;c=0|n[(l=i)>>2],(0|(l=0|n[l+4>>2]))<(0|(u=((0|t)<0)<<31>>31))|(0|l)==(0|u)&c>>>0>>0?(n[(l=i)>>2]=t,n[l+4>>2]=u,l=u):t=c,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(_),F=s,13;if(!(f=0|We(R,8)))return Ye(_),Ye(t),F=s,13;n[(S=o)>>2]=0,n[S+4>>2]=0,P=0|n[(S=A)+4>>2],n[(l=d)>>2]=n[S>>2],n[l+4>>2]=P,l=0|H(d,R,T,e,o,t,f);A:do{if(l)Ye(t),Ye(f),Ye(_);else{e:do{if((0|n[g>>2])>0){for(u=A+12|0,c=0;l=0|H((0|n[u>>2])+(c<<3)|0,R,T,e,o,t,f),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(f),Ye(_);break A}}while(0);(0|T)>0|!(0|T)&R>>>0>0&<(0|f,0,R<<3),S=0|n[(P=o)+4>>2];e:do{if((0|S)>0|!(0|S)&(0|n[P>>2])>>>0>0){Q=t,N=f,j=t,S=f,P=t,l=t,M=t,D=f,E=f,t=f;t:for(;;){for(w=0,y=0,k=0,C=0,c=0,u=0;;){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|I(g=0|n[(e=Q+(w<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|We(7,4))&&(L(g,e,1,i,f,7,0,0),Ye(f))}for(x=0;;){p=0|n[(v=i+(x<<3)|0)>>2],v=0|n[v+4>>2];r:do{if(!(0|p)&!(0|v))f=c,d=u;else{if(h=0|At(0|p,0|v,0|R,0|T),g=0|B(),!(!(0|(d=0|n[(e=f=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|T)|(0|m)==(0|T)&b>>>0>R>>>0)break t;if((0|d)==(0|p)&(0|e)==(0|v)){f=c,d=u;break r}h=0|$e(0|(f=0|Ve(0|h,0|g,1,0)),0|B(),0|R,0|T),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),d=0|n[(e=f=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|d)&!(0|e)))}if(!(0|p)&!(0|v)){f=c,d=u;break}qA(p,v,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=f)>>2]=p,n[m+4>>2]=v,n[(c=N+(c<<3)|0)>>2]=p,n[c+4>>2]=v,c=b),f=c,d=u}}while(0);if((x=x+1|0)>>>0>=7)break;c=f,u=d}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=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=Q+(c<<3)|0)>>2]=0,n[C+4>>2]=0,c=0|Ve(0|c,0|u,1,0),u=0|B(),k=0|n[(C=o)+4>>2]}while((0|u)<(0|k)|((0|u)==(0|k)?c>>>0<(0|n[C>>2])>>>0:0))}if(n[(C=o)>>2]=f,n[C+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break e;x=t,w=E,y=P,k=D,C=N,t=M,E=l,D=j,M=x,l=w,P=S,S=y,j=k,N=Q,Q=C}Ye(j),Ye(S),Ye(_),l=1;break A}l=f}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return F=s,0|l}}return Ye(_),F=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0;c=F,F=F+160|0,f=c+64|0,h=c+112|0,p=c,function(A,e,t,o){A|=0,e|=0,t|=0,o|=0;var i,a,s,l=0,c=0,u=0,f=0;s=F,F=F+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[(f=a)>>2]=u,n[f+4>>2]=c,n[a+8>>2]=0,n[a+12>>2]=t,n[a+16>>2]=o,n[a+20>>2]=e,n[a+24>>2]=l,r[a+28|0]=0,r[0|(u=a+29|0)]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(u=a)>>2]=0,n[u+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,f=a+29|0,n[(u=a+16|0)>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,r[u+12|0]=0,r[0|f]=0|r[0|i],r[f+1|0]=0|r[i+1|0],r[f+2|0]=0|r[i+2|0]}while(0);xe(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],F=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(f,0|n[(d=g)>>2],0|n[d+4>>2],e),s=0|n[(d=f)>>2],d=0|n[d+4>>2],u=0|n[g+8>>2],n[(m=h+4|0)>>2]=n[g>>2],n[m+4>>2]=n[g+4>>2],n[m+8>>2]=n[g+8>>2],n[m+12>>2]=n[g+12>>2],n[m+16>>2]=n[g+16>>2],n[m+20>>2]=n[g+20>>2],n[m+24>>2]=n[g+24>>2],n[m+28>>2]=n[g+28>>2],n[(m=p)>>2]=s,n[m+4>>2]=d,n[(m=p+8|0)>>2]=u,e=h,t=36+(A=p+12|0)|0;do{n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}while((0|A)<(0|t));if(n[(h=p+48|0)>>2]=n[f>>2],n[h+4>>2]=n[f+4>>2],n[h+8>>2]=n[f+8>>2],n[h+12>>2]=n[f+12>>2],!(0|s)&!(0|d))return F=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,f=0,e=s,A=d;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&f>>>0>>0)){b=4;break}if(d=f,f=0|Ve(0|f,0|u,1,0),u=0|B(),n[(d=a+(d<<3)|0)>>2]=e,n[d+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(xe(t),!(0|(A=0|n[(e=t)>>2]))&!(0|(e=0|n[e+4>>2]))){b=10;break}te(A,e,0|n[g>>2],h),e=0|n[(A=h)>>2],A=0|n[A+4>>2]}n[(d=p)>>2]=e,n[d+4>>2]=A}while(!(!(0|e)&!(0|A)));return 4==(0|b)?(0|(e=0|n[(A=p+40|0)>>2])&&Ye(e),n[(b=p+16|0)>>2]=0,n[b+4>>2]=0,n[l>>2]=0,n[p+36>>2]=0,n[g>>2]=-1,n[p+32>>2]=0,n[A>>2]=0,te(0,0,0,h),n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=0,F=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],F=c,0|p)},_readInt64AsDoubleFromPointer:function(A){return+(+((0|n[(A|=0)>>2])>>>0)+4294967296*+(0|n[A+4>>2]))},_res0CellCount:function(){return 122},_round:ct,_sbrk:ut,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(A,e,t,r,o,i,a){A|=0,r|=0,o|=0,i|=0;var s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(s=F,F=F+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return F=s,0;if((0|(a|=0))>=16)return F=s,12;g=0,h=0,d=0,l=0;A:for(;;){if(f=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&f)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(f=m)>>2]))&!(0|(f=0|n[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(d=r+(c<<3)|0)>>2]=u,n[d+4>>2]=f,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(d=m)>>2],f=0|n[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(g=0|Ve(0|g,0|h,1,0),!((0|(h=0|B()))<(0|t)|(0|h)==(0|t)&g>>>0>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(F=s,0|(m=14)):11==(0|c)?(F=s,0|l):0},_uncompactCellsSize:function(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0;a=F,F=F+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(f=0,l=0,s=0,d=0;;){if(!(!(0|(c=0|n[(u=A+(f<<3)|0)>>2]))&!(0|(u=0|n[u+4>>2]))||(u=!(0|_A(c,u,r,i)),l=0|Ve(0|n[(c=i)>>2],0|n[c+4>>2],0|l,0|s),s=0|B(),u))){s=12;break}if(f=0|Ve(0|f,0|d,1,0),!((0|(d=0|B()))<(0|t)|(0|d)==(0|t)&f>>>0>>0))break A}return F=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,F=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=F,F=F+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))?(F=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?QA(i,e,s,1,o):SA(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],F=a,0|(l=0))},establishStackSpace:function(A,e){F=A|=0},stackAlloc:function(A){var e;return e=F,F=15+(F=F+(A|=0)|0)&-16,0|e},stackRestore:function(A){F=A|=0},stackSave:function(){return 0|F}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(A){s=A},c:function(){return s},d:function(A,e,t,r){tA("Assertion failed: "+v(A)+", at: "+[e?v(e):"unknown filename",t,r?v(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){d.set(d.subarray(e,e+t),A)},h:function(A){var e=z(),t=16777216,r=2130706432;if(A>r)return!1;for(var n=Math.max(e,16777216);n0))return 0;for(var n=t+r-1,o=0;o=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++o)),i<=127){if(t>=n)break;e[t++]=i}else if(i<=2047){if(t+1>=n)break;e[t++]=192|i>>6,e[t++]=128|63&i}else if(i<=65535){if(t+2>=n)break;e[t++]=224|i>>12,e[t++]=128|i>>6&63,e[t++]=128|63&i}else{if(t+3>=n)break;e[t++]=240|i>>18,e[t++]=128|i>>12&63,e[t++]=128|i>>6&63,e[t++]=128|63&i}}e[t]=0}(A,d,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,f.set(e,t),r}},o=c(A),i=[],a=0;if(r)for(var s=0;s>1]=e;break;case"i32":h[A>>2]=e;break;case"i64":R=[e>>>0,(L=e,+N(L)>=1?L>0?(0|S(+F(L/4294967296),4294967295))>>>0:~~+j((L-+(~~L>>>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 f[0|A];case"i16":return g[A>>1];case"i32":case"i64":return h[A>>2];case"float":return m[A>>2];case"double":return b[A>>3];default:tA("invalid type for getValue: "+e)}return null},T){H(T)||(W=T,T=t.locateFile?t.locateFile(W,o):o+W),P++,t.monitorRunDependencies&&t.monitorRunDependencies(P);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),d.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(P--,t.monitorRunDependencies&&t.monitorRunDependencies(P),0==P&&I){var A=I;I=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;)Q(t.postRun.shift());k(D)}()))}P>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),P>0||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),e()},1)):e()))}function tA(A){throw t.onAbort&&t.onAbort(A),i(A+=""),a(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(I=function A(){V||eA(),V||(I=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 Ae?Ae:{}),ee="number",te={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"},re={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function ne(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 oe(A){if(0!==A)throw function(A,e){return ne(te,A,2===arguments.length?{value:e}:{})}(A)}var ie={};[["sizeOfH3Index",ee],["sizeOfLatLng",ee],["sizeOfCellBoundary",ee],["sizeOfGeoLoop",ee],["sizeOfGeoPolygon",ee],["sizeOfLinkedGeoPolygon",ee],["sizeOfCoordIJ",ee],["readInt64AsDoubleFromPointer",ee],["isValidCell",ee,[ee,ee]],["isValidIndex",ee,[ee,ee]],["latLngToCell",ee,[ee,ee,ee,ee]],["cellToLatLng",ee,[ee,ee,ee]],["cellToBoundary",ee,[ee,ee,ee]],["maxGridDiskSize",ee,[ee,ee]],["gridDisk",ee,[ee,ee,ee,ee]],["gridDiskDistances",ee,[ee,ee,ee,ee,ee]],["gridRing",ee,[ee,ee,ee,ee]],["gridRingUnsafe",ee,[ee,ee,ee,ee]],["maxPolygonToCellsSize",ee,[ee,ee,ee,ee]],["polygonToCells",ee,[ee,ee,ee,ee]],["maxPolygonToCellsSizeExperimental",ee,[ee,ee,ee,ee]],["polygonToCellsExperimental",ee,[ee,ee,ee,ee,ee,ee]],["cellsToLinkedMultiPolygon",ee,[ee,ee,ee]],["destroyLinkedMultiPolygon",null,[ee]],["compactCells",ee,[ee,ee,ee,ee]],["uncompactCells",ee,[ee,ee,ee,ee,ee,ee]],["uncompactCellsSize",ee,[ee,ee,ee,ee,ee]],["isPentagon",ee,[ee,ee]],["isResClassIII",ee,[ee,ee]],["getBaseCellNumber",ee,[ee,ee]],["getResolution",ee,[ee,ee]],["getIndexDigit",ee,[ee,ee,ee]],["constructCell",ee,[ee,ee,ee,ee]],["maxFaceCount",ee,[ee,ee,ee]],["getIcosahedronFaces",ee,[ee,ee,ee]],["cellToParent",ee,[ee,ee,ee,ee]],["cellToChildren",ee,[ee,ee,ee,ee]],["cellToCenterChild",ee,[ee,ee,ee,ee]],["cellToChildrenSize",ee,[ee,ee,ee,ee]],["cellToChildPos",ee,[ee,ee,ee,ee]],["childPosToCell",ee,[ee,ee,ee,ee,ee,ee]],["areNeighborCells",ee,[ee,ee,ee,ee,ee]],["cellsToDirectedEdge",ee,[ee,ee,ee,ee,ee]],["getDirectedEdgeOrigin",ee,[ee,ee,ee]],["getDirectedEdgeDestination",ee,[ee,ee,ee]],["isValidDirectedEdge",ee,[ee,ee]],["directedEdgeToCells",ee,[ee,ee,ee]],["originToDirectedEdges",ee,[ee,ee,ee]],["directedEdgeToBoundary",ee,[ee,ee,ee]],["gridDistance",ee,[ee,ee,ee,ee,ee]],["gridPathCells",ee,[ee,ee,ee,ee,ee]],["gridPathCellsSize",ee,[ee,ee,ee,ee,ee]],["cellToLocalIj",ee,[ee,ee,ee,ee,ee,ee]],["localIjToCell",ee,[ee,ee,ee,ee,ee]],["getHexagonAreaAvgM2",ee,[ee,ee]],["getHexagonAreaAvgKm2",ee,[ee,ee]],["getHexagonEdgeLengthAvgM",ee,[ee,ee]],["getHexagonEdgeLengthAvgKm",ee,[ee,ee]],["greatCircleDistanceM",ee,[ee,ee]],["greatCircleDistanceKm",ee,[ee,ee]],["greatCircleDistanceRads",ee,[ee,ee]],["cellAreaM2",ee,[ee,ee,ee]],["cellAreaKm2",ee,[ee,ee,ee]],["cellAreaRads2",ee,[ee,ee,ee]],["edgeLengthM",ee,[ee,ee,ee]],["edgeLengthKm",ee,[ee,ee,ee]],["edgeLengthRads",ee,[ee,ee,ee]],["getNumCells",ee,[ee,ee]],["getRes0Cells",ee,[ee]],["res0CellCount",ee],["getPentagons",ee,[ee,ee]],["pentagonCount",ee],["cellToVertex",ee,[ee,ee,ee,ee]],["cellToVertexes",ee,[ee,ee,ee]],["vertexToLatLng",ee,[ee,ee,ee]],["isValidVertex",ee,[ee,ee]]].forEach(function(A){ie[A[0]]=Ae.cwrap.apply(Ae,A)});var ae=16,se=ie.sizeOfH3Index(),le=ie.sizeOfLatLng(),ce=ie.sizeOfCellBoundary();ie.sizeOfGeoPolygon(),ie.sizeOfGeoLoop(),ie.sizeOfLinkedGeoPolygon(),ie.sizeOfCoordIJ();var ue=/[^0-9a-fA-F]/;function fe(A){if(A>=0)return A.toString(ae);var e=de(8,(A&=2147483647).toString(ae));return(parseInt(e[0],ae)+8).toString(ae)+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 ke(r[Math.min(23,Math.floor(24*o))])}function Be({coveragePoints:e,visible:r,terrainEnabled:n=!1,brightness:o=.7,basemapMode:i="dark"}){const{current:a}=P(),[s,l]=A.useState(null);A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==a?void 0:a.getMap)?void 0:A.call(a);e&&!s&&l(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[a,s]);const[c,u]=A.useState(null),[f,d]=A.useState(!1),g=A.useRef({aborted:!1}),h=A.useRef(0),m=A.useRef(i),b=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(e),p=A.useMemo(()=>function(A="dark"){var e;if("light"===A)return ye;const t=dA();return 24===t.length&&0!==(null==(e=t[0])?void 0:e[0])?t:we}(i),[i]);A.useEffect(()=>{if(!b||!Array.isArray(b)||0===b.length)return void queueMicrotask(()=>{u(null),h.current=0});const A=m.current!==i;if(b.length===h.current&&c&&!A)return;h.current=b.length,m.current=i,g.current.aborted=!0,g.current={aborted:!1};const e=g.current;d(!0);const{cells:t,minQuality:r,maxQuality:n}=function(A){const e=new Map;for(const o of A){if("number"!=typeof o.lat||"number"!=typeof o.lon||isNaN(o.lat)||isNaN(o.lon))continue;const A=me(o.lat,o.lon,8),t=e.get(A),r=o.weight;t?(t.count++,t.qualitySum+=r):e.set(A,{count:1,qualitySum:r})}const t=[];let r=1/0,n=-1/0;for(const[o,i]of e.entries()){const A=i.qualitySum/i.count;t.push({hexId:o,count:i.count,avgQuality:A}),r=Math.min(r,A),n=Math.max(n,A)}return{cells:t,minQuality:t.length>0?r:0,maxQuality:t.length>0?n:0}}(b);if(0===t.length)return u(null),void d(!1);if(t.length<500){const A=function(A,e,t,r){const n=[];for(const o of A){const A=be(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=Ce(o.avgQuality,e,t,r);n.push({type:"Feature",properties:{color:i,quality:o.avgQuality,count:o.count},geometry:{type:"Polygon",coordinates:[A]}})}return{type:"FeatureCollection",features:n}}(t,r,n,p);return void(e.aborted||(u(A),d(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=Ce(n.avgQuality,e,t,r);o.push({type:"Feature",properties:{color:s,quality:n.avgQuality,count:n.count},geometry:{type:"Polygon",coordinates:[a]}})}irequestAnimationFrame(A))}return{type:"FeatureCollection",features:o}}(t,r,n,p,e).then(A=>{!e.aborted&&A&&u(A)}).finally(()=>{e.aborted||d(!1)}),()=>{e.aborted=!0}},[b,p]),A.useEffect(()=>{if(!s)return;const A=()=>{var A,e;try{const t=s.getLayer(xe),n=s.getSource(ve);if(r&&c&&c.features.length>0){if(n?s.getSource(ve).setData(c):s.addSource(ve,{type:"geojson",data:c}),!t){const t=s.getLayer("topology-weak-edges-native"),r=null==(e=null==(A=s.getStyle())?void 0:A.layers)?void 0:e.find(A=>"symbol"===A.type),n=t?"topology-weak-edges-native":null==r?void 0:r.id;s.addLayer({id:xe,type:"fill",source:ve,paint:{"fill-color":["get","color"],"fill-opacity":o}},n)}}else t&&s.removeLayer(xe),n&&s.removeSource(ve)}catch(t){}};s.isStyleLoaded()?A():s.once("style.load",A)},[s,r,c,n]),A.useEffect(()=>{if(s&&r)try{s.getLayer(xe)&&s.setPaintProperty(xe,"fill-opacity",o)}catch{}},[s,o,r]),A.useEffect(()=>()=>{if(s)try{s.getLayer(xe)&&s.removeLayer(xe),s.getSource(ve)&&s.removeSource(ve)}catch{}},[s]);const v=(null==c?void 0:c.features.length)??0;return v>0&&r?t.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==e?void 0:e.length)||0,"data-cell-count":v,"data-terrain-enabled":n,"data-is-processing":f,style:{display:"none"}}):null}const Me="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",De="terrarium",Ee="terrain-dem",Qe="hillshade-dem",Ne="terrain-hillshade";function je({enabled:e,exaggeration:t=4}){const{current:r}=P(),[n,o]=A.useState(null),i=A.useRef(null);return A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);e&&!n&&o(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[r,n]),A.useEffect(()=>{if(!n)return;let A=!0;const e=()=>{var e,t;if(A)try{if(n.getSource(Qe)||n.addSource(Qe,{type:"raster-dem",tiles:[Me],encoding:De,tileSize:256,maxzoom:14}),!n.getLayer(Ne)){const A=null==(t=null==(e=n.getStyle())?void 0:e.layers)?void 0:t.find(A=>"symbol"===A.type);n.addLayer({id:Ne,type:"hillshade",source:Qe,paint:{"hillshade-shadow-color":"rgba(10, 10, 10, 0.6)","hillshade-highlight-color":"rgba(245, 240, 230, 0.4)","hillshade-accent-color":"rgba(90, 75, 65, 0.3)","hillshade-illumination-direction":315,"hillshade-exaggeration":.35}},null==A?void 0:A.id)}n.getSource(Ee)||n.addSource(Ee,{type:"raster-dem",tiles:[Me],encoding:De,tileSize:256,maxzoom:14})}catch(r){}};return n.isStyleLoaded()?e():(n.once("style.load",e),n.once("load",()=>{A&&!n.getSource(Qe)&&e()})),()=>{A=!1}},[n]),A.useEffect(()=>{if(!n)return;let A=!0,r=!1;const o=()=>{if(A&&n.getSource(Ee))try{e?(n.setCenterClampedToGround(!1),n.setTerrain({source:Ee,exaggeration:t}),n.setMaxPitch(70),!r&&n.getPitch()<30&&!n.isMoving()&&(r=!0,null!==i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,A&&!n.isMoving()&&n.getPitch()<30&&n.easeTo({pitch:45,duration:1e3})},200))):(n.setTerrain(null),n.setCenterClampedToGround(!0),n.getPitch()>0&&!n.isMoving()&&n.easeTo({pitch:0,duration:800}),n.setMaxPitch(60))}catch(o){}};if(n.isStyleLoaded()&&n.getSource(Ee))o();else{const A=()=>{n.getSource(Ee)&&o()};n.once("idle",A)}return()=>{A=!1,null!==i.current&&(clearTimeout(i.current),i.current=null)}},[n,e,t]),A.useEffect(()=>()=>{var A;try{(null==(A=null==n?void 0:n.getStyle)?void 0:A.call(n))&&n.isStyleLoaded()&&(n.setTerrain(null),n.getLayer(Ne)&&n.removeLayer(Ne),n.getSource(Qe)&&n.removeSource(Qe),n.getSource(Ee)&&n.removeSource(Ee))}catch{}},[n]),null}function Fe(A,e=!1,t=!1,r=!1,n=.7,o){const i=uA(o);return r?n>=.75?i.restBright:i.rest:n>=.85?i.rest:i.restDim}function Se(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 Ie(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Le(A,e,t,r,n,o,i,a,s,l,c,u="dark"){const f=BA(),d=[];let g=1/0,h=-1/0;const m=[];for(const p of A){const A=.7*(p.edge.avgConfidence??(e?.7:.5))+p.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);m.push({polyline:p,brightnessScore:A}),g=Math.min(g,A),h=Math.max(h,A)}if(0===m.length)return{type:"FeatureCollection",features:[]};const b=h-g||1;m.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:p,brightnessScore:v}of m){const{from:A,to:i,edge:h}=p,m=t.get(h.key)??0;if(m<=0)continue;const x=a.has(h.key),w=s.has(h.key),y=h.avgConfidence??(e?.7:.5),k=l===h.key,C=c[h.fromHash],B=c[h.toHash],M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||h.fromHash.slice(0,8),D=(null==B?void 0:B.node_name)||(null==B?void 0:B.name)||h.toHash.slice(0,8),E=[A[0]+(i[0]-A[0])*m,A[1]+(i[1]-A[1])*m];let Q,N,j,F;if(e){const A=o.get(h.key)??wA(h.certainCount),e=n.get(h.key)??A;Q=e+(A-e)*r,k?Q=Math.max(1.6*Q,4.5):w&&(Q*=1.3)}else Q=1.5;if(N=k?f.edges.highlight:Fe(0,h.isDirectPathEdge??!1,x,w,y,u),j=k?f.edges.highlight:h.isDirectPathEdge?f.edges.hoverDirect:x?f.edges.hoverLoop:f.edges.hoverStandard,e){const A=Math.min(1.5*m,1)*f.edgeOpacity;F=w?1.15*A:A}else F=(.3+.3*y)*m;k&&(F=.95);const S=(v-g)/b;d.push({type:"Feature",properties:{key:h.key,baseColor:N,hoverColor:j,baseWidth:Q,baseOpacity:F,brightnessScore:S,isLoopEdge:x,isBackbone:w,isDirectPath:h.isDirectPathEdge??!1,isHubConnection:h.isHubConnection??!1,isZeroHop:h.isZeroHop??!1,isValidated:e,certainCount:h.certainCount,confidence:y,symmetryRatio:h.symmetryRatio??1,dominantDirection:h.dominantDirection??"balanced",fromName:M,toName:D,fromHash:h.fromHash,toHash:h.toHash},geometry:{type:"LineString",coordinates:[Se(A),Se(E)]}})}return{type:"FeatureCollection",features:d}}function Re(A,e){const t=BA(),r=[];let n=0;for(const o of A){const A=e.get(o.hash);A&&A.blendedScore>n&&(n=A.blendedScore)}for(const o of A){const{from:A,to:i,hash:a,neighbor:s,lastHopData:l}=o,c=`neighbor-${a}`,u=(null==l?void 0:l.avgRssi)??s.rssi??null,f=(null==l?void 0:l.avgSnr)??s.snr??null,d=(null==l?void 0:l.count)??0,g=(null==l?void 0:l.confidence)??1,h=e.get(a),m=(null==h?void 0:h.listenerScore)??0,b=(null==h?void 0:h.loudScore)??0,p=(null==h?void 0:h.blendedScore)??0,v=n>0?p/n:0,x=o.rxAdvertCount??0,w=o.txProxyCount??0,y=x+w,k=y>0?(w-x)/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:f,packetCount:d,confidence:g,hasAvgRssi:void 0!==(null==l?void 0:l.avgRssi),hasAvgSnr:void 0!==(null==l?void 0:l.avgSnr),isNeighborEdge:!0,listenerScore:m,loudScore:b,blendedScore:p,trafficWeight:v,linkAsymmetry:k,rxAdvertCount:x,txProxyCount:w},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Te(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function _e(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 He(A,e,t){const r=t?$(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 ze="edge-blink-source",Ge="edge-blink-layer",Oe=1e3,Ue=1e3,Ye="node-markers-layer";function We(A){return A<0||A>=Oe?0:1-A/Oe}function Ve(A){if(A<0)return 0;if(A>=Ue)return 0;const e=A/Ue;return Math.pow(1-e,3)}function Ze(A){return[A[1],A[0]]}function Ke(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function Je({hash:e,hashPrefix:n,name:o,isHub:i,isGateway:a,isBackbone:s,isZeroHop:l,isMobile:c,isRoomServer:u,isStale:f,lastSeenTimestamp:d,centrality:g,affinity:h,meanSnr:m,meanRssi:b,neighbor:p,onRemove:v,txDelayRec:x}){const w=fA(),[y,k]=A.useState(!1),C=l?"Direct":(null==h?void 0:h.typicalHopPosition)?`${h.typicalHopPosition}-hop`:null,B=x&&!x.insufficientData,M={hub:{color:"var(--accent-secondary)",title:"Hub: High-connectivity node that bridges many paths"},backbone:{color:"var(--map-hub-color)",title:"Backbone: Critical relay with high traffic"},relay:{color:"var(--accent-tertiary)",title:"Relay: Standard forwarding node"},edge:{color:"var(--text-muted)",title:"Edge: Peripheral node"}},D={high:{color:"var(--accent-success)",title:"1000+ packets"},medium:{color:"var(--accent-secondary)",title:"500-999 packets"},low:{color:"var(--accent-danger)",title:"100-499 packets"},insufficient:{color:"var(--text-muted)",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),k(!0),setTimeout(()=>k(!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"),k(!0),setTimeout(()=>k(!1),1500)}catch{}document.body.removeChild(t)}},className:"p-0.5 hover:bg-[#252525] rounded transition-colors",title:"Copy full hash",children:y?t.jsx(r,{className:"w-3 h-3 text-accent-success"}):t.jsx(I,{className:"w-3 h-3 text-text-secondary"})}),t.jsx(vA,{hash:e,size:"sm"}),C&&t.jsx("span",{className:"color-pill color-pill-compact "+(l?"color-pill-filled":""),style:l?{"--pill-color":"var(--accent-secondary)","--pill-text":"rgba(0,0,0,0.9)"}:{"--pill-color":"var(--text-muted)"},children:C}),p.is_repeater&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--accent-tertiary)"},children:"Rptr"}),i&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":w.hubColor,"--pill-text":"#fff"},title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a&&!i&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":w.hubColor,"--pill-text":"#fff",opacity:.8},title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),s&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":"var(--map-hub-color)","--pill-text":"#fff"},title:"Backbone",children:"Bone"}),c&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--map-mobile-color)"},children:"Mobile"}),u&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--map-room-color)"},children:"Room"}),f&&d&&t.jsxs("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--text-muted)"},title:"Neighbor not heard in 7+ days",children:["Idle ",Ke(d)]})]}),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(L,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono",children:eA(p.last_seen)})]}),(null==h?void 0:h.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:(E=h.distanceMeters,null===E?"—":E<1e3?`${Math.round(E)}m`:`${(E/1e3).toFixed(1)}km`)})]}),p.latitude&&p.longitude&&0!==p.latitude&&0!==p.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:[p.latitude.toFixed(2),", ",p.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-1",children:[t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"data-box data-box-compact",children:(null==h?void 0:h.frequency)||0})]}),l&&void 0!==m&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"data-box data-box-compact",children:[m.toFixed(1)," dB"]})]}),B&&x.networkRole&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":M[x.networkRole].color},title:M[x.networkRole].title,children:x.networkRole})]})]}),t.jsxs("div",{className:"flex-1 space-y-1",children:[t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Adverts"}),t.jsx("span",{className:"data-box data-box-compact",children:p.advert_count||0})]}),l&&void 0!==b&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(b)," dBm"]})]}),B&&x.dataConfidence&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Data"}),t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":D[x.dataConfidence].color},title:D[x.dataConfidence].title,children:x.dataConfidence})]})]}),!B&&v&&t.jsx("button",{onClick:v,className:"p-1 self-start text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:t.jsx(F,{className:"w-3.5 h-3.5"})})]}),B&&t.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 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-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"F"}),t.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",(x.floodFactor??x.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:"data-box data-box-compact text-amber-400",children:["×",(x.directFactor??x.directTxDelayFactor).toFixed(1)]})]})]})]}),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(F,{className:"w-3.5 h-3.5"})})]})]});var E}const Xe="node-markers-native",qe="node-markers-layer",$e="node-markers-layer-local",At="marker-standard",et="marker-standard-neighbor",tt="marker-hub",rt="marker-hub-neighbor",nt="marker-gateway",ot="marker-gateway-neighbor",it="marker-mobile",at="marker-mobile-neighbor",st="marker-room-server",lt="marker-room-server-neighbor",ct="marker-local",ut="marker-blink-black",ft="marker-blink-black-local",dt="marker-blink",gt="marker-blink-local";function ht(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 mt(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function bt({neighborsWithLocation:e,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:f,openPopupId:d,onOpenPopup:g,onClosePopup:h,blinkingNodes:m}){const{current:b}=P(),p=A.useRef(!1),[v,x]=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=()=>{try{!function(A){const e=cA(),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={[At]:t(e.nodeFill,e.nodeStroke,1.5),[et]:t(e.neighborColor),[tt]:t(e.hubColor),[rt]:t(e.neighborColor),[nt]:t(e.hubColor+"B3"),[ot]:t(e.neighborColor),[it]:t("transparent",e.mobileColor,2),[at]:t(e.neighborColor),[st]:n(e.roomColor),[lt]:n(e.neighborColor,"#1a1a1c"),[ct]:r(e.localColor),[ut]:t("#000000"),[ft]:r("#000000"),[dt]:t(o,void 0,0,!0),[gt]: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||x(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{e.hasImage(At)||t()};e.on("styledata",r);const n=()=>{p.current=!1,t()},o=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(n,100);break}});return o.observe(document.documentElement,{attributes:!0}),()=>{e.off("styledata",r),o.disconnect()}},[b,v]);const w=A.useMemo(()=>{var A;const t=[],r=[...e].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return ht(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),f=a.hubNodes.includes(e),d=(null==(A=a.gatewayNodes)?void 0:A.includes(e))??!1,g=a.mobileNodes.includes(e),h=ht(n),m=a.centrality.get(e)||0,b=i.get(e),p="stale"===(null==b?void 0:b.status),v=p?Math.min(s,.5):s;let x="standard";h?x="roomServer":f?x="hub":d?x="gateway":g&&(x="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:mt(e),iconType:x,isNeighbor:l,isHub:f,isGateway:d,isMobile:g,isRoomServer:h,isStale:p,isZeroHop:l,opacity:v,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?mt(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||!v)return;const t=[qe,$e];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,v,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||!v||!m||0===m.size)return;const t=e.getSource(Xe),r=e.getSource(`${Xe}-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,v,m,n]);const E=A.useMemo(()=>{if(!d)return null;if("local"===d&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=w.features.find(A=>A.properties.hash===d);if(!A)return null;const e=A.properties,t=e.txDelayRecJson?JSON.parse(e.txDelayRecJson):void 0;return{longitude:A.geometry.coordinates[0],latitude:A.geometry.coordinates[1],isLocal:!1,hash:e.hash,hashPrefix:e.hashPrefix,name:e.name,isHub:e.isHub,isGateway:e.isGateway,isBackbone:"backbone"===(null==t?void 0:t.networkRole),isZeroHop:e.isZeroHop,isMobile:e.isMobile,isRoomServer:e.isRoomServer,isStale:e.isStale,lastSeenTimestamp:e.lastSeenTimestamp,centrality:e.centrality,neighbor:e.neighborJson?JSON.parse(e.neighborJson):void 0,affinity:e.affinityJson?JSON.parse(e.affinityJson):void 0,txDelayRec:t,meanSnr:e.meanSnr,meanRssi:e.meanRssi}},[d,r,n,w]);if(!v)return null;const Q=cA(),N=["case",[">",["get","blinkIntensity"],.66],dt,[">",["get","blinkIntensity"],.33],ut,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],lt,st],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],rt,tt],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],ot,nt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],at,it],["case",["get","isNeighbor"],et,At]],j=["interpolate",["linear"],["zoom"],6,.25,10,1];return t.jsxs(t.Fragment,{children:[t.jsx(H,{id:Xe,type:"geojson",data:w,children:t.jsx(z,{id:qe,type:"symbol",layout:{"icon-image":N,"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),t.jsx(H,{id:`${Xe}-local`,type:"geojson",data:y,children:t.jsx(z,{id:$e,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],gt,[">",["get","blinkIntensity"],.33],ft,ct],"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),E&&h&&t.jsx(G,{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:mt(E.hash)}),t.jsx("br",{}),t.jsx("span",{style:{color:Q.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(Je,{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:f?()=>f(E.hash,E.name):void 0}):null})]})}const pt=[qe,$e];A.createContext(null);const vt="topology-validated-edges-native",xt="topology-weak-edges-native",wt="neighbor-edges-native",yt="topology-weak-edges-native",kt="topology-validated-edges-native",Ct="neighbor-edges-native",Bt={type:"FeatureCollection",features:[]},Mt={"line-cap":"round","line-join":"round"},Dt={"line-color":"transparent","line-width":16,"line-opacity":0};function Et({showTopology:e,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,onEdgeHover:i,onLoopHover:a,loops:s=[],neighborNames:l={},opacityBias:c=.5,widthMultiplier:u=1,trafficFilter:f=0,showNeighborLines:d=!0,disableHover:g=!1}){const{current:h}=P(),m=e||r,b=!0,p=d?"visible":"none",v=g||r,x=A.useRef(null),w=A.useRef(v),y=A.useRef(new Map),k=A.useRef(l),C=A.useRef(a);A.useLayoutEffect(()=>{w.current=v,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!==x.current){x.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!==x.current&&(x.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||!d)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,d,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(Ct,"node-markers-layer"),r("neighbor-edges-hitarea-native",Ct),(r(kt,"neighbor-edges-hitarea-native")||r(kt,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",kt),r(yt,"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===vt||A.sourceId===xt||A.sourceId===wt)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[h,m,b,d]);const E=v?null:n,Q=function(A,e,t,r,n){const o=BA(),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],f=i||a,d=o.edges.hoverLoop??"#A78BFA";return{"line-color":f?["case",u,a?d:["get","hoverColor"],l]:l,"line-width":f?["case",u,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,f?["case",u,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],c,.35]]:["*",["get","baseOpacity"],c]]}}(E,c,u,f,v?null:o),N=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=Y,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(H,{id:xt,type:"geojson",data:Bt,children:t.jsx(z,{id:yt,type:"line",paint:Q,layout:Mt})}),m&&t.jsxs(H,{id:vt,type:"geojson",data:Bt,children:[t.jsx(z,{id:"topology-validated-edges-hitarea-native",type:"line",paint:Dt,layout:Mt}),t.jsx(z,{id:kt,type:"line",paint:Q,layout:Mt})]}),t.jsxs(H,{id:wt,type:"geojson",data:Bt,children:[t.jsx(z,{id:"neighbor-edges-hitarea-native",type:"line",paint:Dt,layout:{...Mt,visibility:p}}),t.jsx(z,{id:Ct,type:"line",paint:N,layout:{...Mt,visibility:p}})]})]})}const Qt=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function Nt({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=P(),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 jt({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=P(),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 Ft(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 St(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}=P(),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:[St(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(H,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:t.jsx(z,{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))}(CA.edges.neighborHover);const It={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},Lt={longitude:0,latitude:0,zoom:2};function Rt(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 Tt({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 _t({neighbors:e,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=tA(),f=rA(),d=nA(),g=oA(),h=iA(),[m,b]=A.useState(!1),p=aA(A=>A.preloadFromNodes),v=aA(A=>A.isLoading),x=aA(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:Rt(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[d,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,d),i=Math.max(i,d);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let f=16;return u>0&&(f=Math.floor(Math.log2(360/u*1.2)),f=Math.max(1,Math.min(14,f))),f=Math.min(f+1,12),{longitude:a,latitude:s,zoom:f}}(y,r),[y,r]),[C,B]=A.useState(()=>k??Lt),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),[Q,N]=A.useState(!1),[j,F]=A.useState(!0),[S,P]=A.useState(!1),[I,L]=A.useState(!1),[R,T]=A.useState("all"),[_,H]=A.useState(null),[z,G]=A.useState(null),[Y]=A.useState(0),[V]=A.useState(.5),[Z]=A.useState(0),[K,eA]=A.useState(null),[lA,cA]=A.useState(""),[uA,fA]=A.useState(!1),[dA,gA]=A.useState("fetching"),[hA,vA]=A.useState(!1),[xA,yA]=A.useState(0),[CA,BA]=A.useState(!1),[DA,EA]=A.useState(null),NA=A.useCallback(A=>EA(A),[]),FA=A.useCallback(()=>EA(null),[]),[,SA]=A.useState(new Set),PA=KA(A=>A.coveragePoints),LA=KA(A=>A.isVisible),TA=KA(A=>A.brightness),HA=KA(A=>A.openModal),zA=$A(A=>A.isEnabled),GA=$A(A=>A.toggle),OA=mA(),UA=bA(),YA=A.useRef(!1);A.useEffect(()=>{PA.length>0&&LA&&!YA.current&&(F(!1),YA.current=!0)},[PA.length,LA]);const WA=A.useRef(null);A.useEffect(()=>{if(i&&i!==WA.current){WA.current=i;const A=setTimeout(()=>{EA(i)},1250);return()=>clearTimeout(A)}},[i]);const[VA,ZA]=A.useState(null),[JA,qA]=A.useState(null),Ae=A.useCallback((A,e,t)=>{G(A),A&&e&&t?ZA({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||ZA(null)},[]),ee=A.useCallback((A,e)=>{qA(A),A&&ZA(null)},[]),te=A.useMemo(()=>{var A;if(!Q)return null;if(!_)return null;if(z)return null;const t=u.loops;if(0===t.length)return null;const r=function(A,e,t){const r=function(A,e){return e.filter(e=>e.nodes.includes(A)).sort((A,e)=>e.avgCertainCount-A.avgCertainCount)}(A,e),n=new Set,o=[];for(const i of r)for(const A of i.edgeKeys)if(!n.has(A)){n.add(A);const e=t.get(A);o.push({key:A,certainCount:(null==e?void 0:e.certainCount)??0})}return o.sort((A,e)=>e.certainCount-A.certainCount),{loops:r,highlightedEdgeKeys:n,sortedEdges:o}}(_,t,u.edgeMap);if(0===r.loops.length)return null;const n=r.loops[0].nodes.map(A=>{var t,r;return A===w?"You":(null==(t=e[A])?void 0:t.node_name)||(null==(r=e[A])?void 0:r.name)||A.substring(0,4)});return{loops:r.loops,highlightedEdgeKeys:r.highlightedEdgeKeys,hoveredEdgeKey:(null==(A=r.sortedEdges[0])?void 0:A.key)||"",nodeNames:n}},[Q,_,z,u.loops,u.edgeMap,e,w]);A.useEffect(()=>{z||qA(te)},[te,z]);const re=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]),ne=A.useMemo(()=>Object.entries(e).filter(([,A])=>A.latitude&&A.longitude),[e]),oe=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 ne)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[w,r,ne]),ie=A.useMemo(()=>{const A=new Map;for(const e of d)"expired"!==e.status&&A.set(e.hash,{hash:e.hash,prefix:e.prefix,count:e.count,avgRssi:e.avgRssi,avgSnr:e.avgSnr,lastSeen:e.lastSeen,confidence:1,status:e.status});return A},[d]),ae=A.useMemo(()=>{var A,t;const r=new Set;for(const n of ie.keys())(null==(A=e[n])?void 0:A.latitude)&&(null==(t=e[n])?void 0:t.longitude)&&r.add(n);return r},[ie,e]),se=A.useMemo(()=>{if(0===ae.size||!w)return new Map;const A=X.getPackets();if(0===A.length)return new Map;const e=$(w);return W(A,ae,e).scores},[ae,w,g.packetCount]),le=A.useCallback(A=>!!(w&&(A.fromHash===w&&ae.has(A.toHash)||A.toHash===w&&ae.has(A.fromHash))),[w,ae]),ce=A.useMemo(()=>{var A,t;if(0===d.length||!w)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of d){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},[d,w,g.backgroundLoadComplete,e]),ue=A.useMemo(()=>{const A=[];if(ce.length>0&&!g.backgroundLoadComplete){for(const e of ce){const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(le(e))continue;const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,oe,le,ce,g.backgroundLoadComplete]),fe=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(le(e))continue;const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,oe,le]),de=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 d)o.set(e.hash,e.count);for(const r of ae){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:ie.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,ae,e,ie,u.lastHopNeighbors,d]),ge=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),he=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),me=A.useMemo(()=>{let A=0;if(ce.length>0&&!g.backgroundLoadComplete){for(const e of ce)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,ce,g.backgroundLoadComplete]),be=A.useRef(null);A.useLayoutEffect(()=>{var A,e;be.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const pe=J(),ve=A.useMemo(()=>X.getPackets(),[pe]);!function({map:e,nodeCoordinates:t,packets:r,localHash:n,neighbors:o,meshTopology:i,enabled:a=!0}){const s=A.useRef(null),l=e&&"current"in e?e.current:e;A.useEffect(()=>{s.current=l},[l]);const c=A.useRef(!1),u=A.useRef(null),f=A.useRef([]),d=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),v=A.useRef(new Map),x=A.useRef(t);A.useEffect(()=>{x.current=t},[t]),A.useEffect(()=>{v.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=$(r);t.has(A)||t.set(A,r)}if(e){const A=$(e);t.set(A,e)}return t}(o,n)},[o,n]),A.useEffect(()=>{if(!a){b.current&&(clearTimeout(b.current),b.current=null),p.current=[],null!==u.current&&(cancelAnimationFrame(u.current),u.current=null),f.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(ze);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,d.current=0}},[a]),A.useEffect(()=>{const A=l;if(!A)return;let e=null,t=!1;const r=()=>{if(!t&&!c.current)try{A.getLayer(Ge)&&A.removeLayer(Ge),A.getSource(ze)&&A.removeSource(ze),A.addSource(ze,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Ye)?Ye:void 0;A.addLayer({id:Ge,type:"line",source:ze,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(Ge)&&A.removeLayer(Ge),A.getSource(ze)&&A.removeSource(ze)}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(ze);if(!e)return;const t=performance.now(),r=f.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ue:Oe)){o.push(i);const e=i.isSpeculative?Ve(A):We(A);e>0&&n.push({type:"Feature",properties:{intensity:e,opacityMult:i.isSpeculative?.5:1,isSpeculative:i.isSpeculative??!1},geometry:{type:"LineString",coordinates:[i.fromCoord,i.toCoord]}})}}e.setData({type:"FeatureCollection",features:n}),f.current=o,o.length>0?u.current=requestAnimationFrame(()=>w.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(Ge))return;const e=A.getLayer(Ye)?Ye:void 0;try{A.moveLayer(Ge,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=v.current,t=x.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=q(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,d=null;for(let n=0;n0){A.sort((A,e)=>e.confidence-A.confidence);const e=Math.max(1,Math.ceil(.25*A.length)),n=A.slice(0,e),i=o+150*u;for(const{edgeKey:A,otherHash:o}of n){const e=t.get(d),n=t.get(o);f.current.push({edgeKey:A,fromCoord:Ze(e),toCoord:Ze(n),startTime:r,delay:i,isSpeculative:!0}),l.add(A),a=!0}}}u>0&&(o+=150*u*.5)}a&&y()},[n,i,y]);A.useEffect(()=>{const A=s.current;if(!a)return;if(!A)return;if(!h)return;if(0===r.length)return;const e=Date.now(),t=d.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A);let n=0;for(const e of r){const A=e.timestamp??0;A>n&&(n=A)}if(d.current=n,t.length>0){t.sort((A,e)=>(A.timestamp??0)-(e.timestamp??0));const A=t.slice(-20);p.current.push(...A),k()}return}const n=r.filter(A=>(A.timestamp??0)>t);if(0===n.length)return;let o=0;for(const r of n){const A=r.timestamp??0;A>o&&(o=A)}d.current=o,p.current.push(...n),b.current&&clearTimeout(b.current),b.current=setTimeout(k,175)},[a,r,k,h]),A.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[])}({map:be,nodeCoordinates:oe,packets:ve,localHash:w,neighbors:e,meshTopology:u,enabled:zA});const{isExiting:xe,isAnimating:we,resetAnimationState:ye}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:f=[],showNeighborLines:d=!0,neighborSourceId:g,neighborLinkScores:h=new Map,basemapMode:m}){const b=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;b.current=A});const p=A.useRef(new Map),v=A.useRef(1),x=A.useRef(new Map),w=A.useRef(new Map),y=A.useRef(!1),k=A.useRef(null),C=A.useRef(t),B=A.useRef(new Set),M=A.useRef(""),D=A.useRef(new Map),E=A.useRef(""),Q=A.useRef(""),N=A.useRef(""),j=A.useRef(r),F=A.useRef(n),S=A.useRef(o),P=A.useRef(i),I=A.useRef(a),L=A.useRef(s),R=A.useRef(l),T=A.useRef(f),_=A.useRef(d),H=A.useRef(h),z=A.useRef(m);A.useEffect(()=>{j.current=r,F.current=n,S.current=o,P.current=i,I.current=a,L.current=s,R.current=l,T.current=f,_.current=d,H.current=h,z.current=m},[r,n,o,i,a,s,l,f,d,h,m]);const G=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,f;const d=b.current;if(!d)return;const h=d.getSource(c),m=d.getSource(u),y=d.getSource(g);if(h){const o=Le(j.current,!0,p.current,v.current,x.current,w.current,S.current,P.current,I.current,L.current,R.current,z.current),i=`${o.features.length}:${(null==(t=null==(e=o.features[0])?void 0:e.properties)?void 0:t.key)??""}:${(null==(n=null==(r=o.features[o.features.length-1])?void 0:r.properties)?void 0:n.key)??""}:${Array.from(p.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==E.current)&&(h.setData(o),E.current=i)}if(m){const e=Le(F.current,!1,p.current,v.current,x.current,w.current,S.current,P.current,I.current,L.current,R.current,z.current),t=`${e.features.length}:${(null==(i=null==(o=e.features[0])?void 0:o.properties)?void 0:i.key)??""}:${(null==(s=null==(a=e.features[e.features.length-1])?void 0:a.properties)?void 0:s.key)??""}`;(A||t!==Q.current)&&(m.setData(e),Q.current=t)}if(y&&T.current.length>0){const e=Re(T.current,H.current),t=`${e.features.length}:${(null==(f=null==(l=e.features[0])?void 0:l.properties)?void 0:f.hash)??""}`;(A||t!==N.current)&&(y.setData(e),N.current=t)}},[c,u,g]),O=A.useCallback(()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null),p.current=new Map,v.current=1,x.current=new Map,w.current=new Map,y.current=!1,B.current=new Set,M.current="",D.current=new Map},[]);A.useEffect(()=>{const A=C.current,e=t;if(C.current=t,b.current){if(k.current&&(cancelAnimationFrame(k.current),k.current=null),A&&!e&&!y.current){y.current=!0;const A=new Map(p.current);let e=null;const t=r=>{e||(e=r);const n=r-e,o=Math.min(n/500,1),i=(a=o,1-Math.pow(1-a,3));var a;for(const[e,t]of A)p.current.set(e,t*(1-i));G(!0),o<1?k.current=requestAnimationFrame(t):(y.current=!1,p.current=new Map,B.current=new Set,M.current="",x.current=new Map,w.current=new Map,k.current=null,G(!0))};k.current=requestAnimationFrame(t)}!A&&e&&(p.current=new Map,B.current=new Set,M.current="")}},[t,G]),A.useEffect(()=>{const A=b.current;if(!t||y.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===B.current.size,a=""!==M.current&&M.current!==o;if(!i&&!a)return void G();const s=[],l=[];for(const{edge:t}of e)B.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(x.current=new Map(D.current),v.current=0),w.current=new Map;for(const{edge:t}of r){const A=wA(t.certainCount);w.current.set(t.key,A)}for(const t of s)p.current.set(t,0);for(const t of l)p.current.has(t)||p.current.set(t,1);if(s.length>0||a&&l.length>0){k.current&&(cancelAnimationFrame(k.current),k.current=null);let A=null;const e=Math.min(100,MA/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/MA,1);v.current=Ie(A)}G(!0);const o=MA+(s.length-1)*e;k.current=n{const A=b.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(f.length>0){const A=Re(f,h);e.setData(A)}else e.setData({type:"FeatureCollection",features:[]});return!0};if(e())return;const t=r=>{r.sourceId===g&&e()&&A.off("sourcedata",t)};A.on("sourcedata",t);const r=()=>{e()&&(A.off("styledata",r),A.off("sourcedata",t))};return A.on("styledata",r),()=>{A.off("sourcedata",t),A.off("styledata",r)}},[g,f,h]);const U=A.useRef(m);return A.useEffect(()=>{m!==U.current&&(U.current=m,E.current="",Q.current="",N.current="",G(!0))},[m,G]),A.useEffect(()=>()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null)},[]),{isExiting:y.current,isAnimating:null!==k.current,resetAnimationState:O,weightAnimProgress:v.current,animStartWeights:x.current,animTargetWeights:w.current}}({map:be,showTopology:Q,validatedPolylines:ue,weakPolylines:fe,maxCertainCount:me,loopEdgeKeys:ge,backboneEdgeKeys:he,highlightedEdgeKey:s,neighbors:e,validatedSourceId:vt,weakSourceId:xt,neighborPolylines:de,showNeighborLines:j,neighborSourceId:wt,neighborLinkScores:se,basemapMode:OA}),ke=A.useMemo(()=>{const A=new Set;for(const e of u.hubNodes){A.add(e);for(const t of u.validatedEdges)t.fromHash===e&&A.add(t.toHash),t.toHash===e&&A.add(t.fromHash)}return A},[u.hubNodes,u.validatedEdges]),Ce=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:Me}=function({soloDirect:e,soloHubs:t,neighborHashes:r,hubConnectedNodes:n,directNodeSet:o,localConnectedNodes:i,showTopology:a}){const[s,l]=A.useState(new Map),c=A.useRef(e),u=A.useRef(t),f=A.useRef(new Map),d=A.useRef(null),g=A.useRef(n),h=A.useRef(o),m=A.useRef(i),b=A.useRef(a);return A.useEffect(()=>{g.current=n,h.current=o,m.current=i,b.current=a},[n,o,i,a]),A.useEffect(()=>{const A=c.current,n=u.current,o=e,i=t;if(c.current=e,u.current=t,A===o&&n===i)return;d.current&&(cancelAnimationFrame(d.current),d.current=null);const a=g.current,s=h.current,p=m.current,v=b.current;for(const e of r)f.current.has(e)||f.current.set(e,Math.random());const x=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=v&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},w=[];for(const e of r){const t=x(e,A,n),r=x(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*(f.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Te(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?d.current=requestAnimationFrame(C):(d.current=null,l(new Map))};return d.current=requestAnimationFrame(C),()=>{d.current&&(cancelAnimationFrame(d.current),d.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===R,soloHubs:"hubs"===R,neighborHashes:ne.map(([A])=>A),hubConnectedNodes:ke,directNodeSet:ae,localConnectedNodes:Ce,showTopology:Q}),{blinkingNodes:De,blinkColor:Ee}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=J(),a=A.useRef(X.getPackets());A.useEffect(()=>{a.current=X.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=$(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const f=A.useRef(null);return A.useEffect(()=>{f.current=()=>{const A=performance.now(),e=c.current;if(0===e.size)return l.current=null,void o(new Map);const t=new Map,r=[];for(const[n,{startTime:o,staggerDelay:i}]of e){const e=A-o-i;if(e<0);else if(e>=750)r.push(n);else{const A=_e(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&f.current?l.current=requestAnimationFrame(f.current):l.current=null}},[]),A.useEffect(()=>{if(!r)return;const A=a.current;if(0===A.length)return;const e=s.current,n=A.filter(A=>(A.timestamp??0)>e);if(0===e){const e=A.reduce((A,e)=>Math.max(A,e.timestamp??0),0);return void(s.current=e)}if(0===n.length)return;const o=n.reduce((A,e)=>Math.max(A,e.timestamp??0),0);s.current=o;const i=performance.now();let d=0;for(const r of n){const A=q(r,t);if(!A||0===A.original.length)continue;const e=He(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:zA}),Qe=A.useCallback(A=>{if("all"===R)return!0;if("direct"===R)return ae.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,ae,u.hubNodes,u.validatedEdges]);A.useEffect(()=>{"fetching"===dA&&(g.loadProgress?yA(g.loadProgress.loaded):g.packetCount>0&&yA(g.packetCount))},[dA,g.loadProgress,g.packetCount]);const Ne=A.useCallback(async()=>{vA(!0),fA(!0),gA("fetching"),yA(0),await f(),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)),fA(!1),vA(!1),ye(),BA(!0),setTimeout(()=>{N(!0)},150)},[f,ye]),Fe=A.useCallback(()=>{CA?N(A=>!A):Ne()},[CA,Ne]),Se=A.useCallback(A=>{B(A.viewState),(A.viewState.pitch??0)>10&&!I&&L(!0)},[I]),Pe=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})},[]),Ke=A.useCallback(A=>{T(A)},[]),Je=A.useCallback(()=>{F(A=>!A)},[]),Xe=A.useCallback(()=>{P(A=>!A)},[]),qe=A.useCallback(()=>{L(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})},[]),$e=A.useCallback(()=>{Q||N(!0)},[Q]),At=A.useCallback((A,e)=>{eA(A),cA(e)},[]),et=A.useCallback(()=>{K&&o&&o(K),eA(null),cA("")},[K,o]),tt=A.useMemo(()=>[...Qt,...pt],[]),rt=A.useRef(!1);A.useEffect(()=>{rt.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const nt=A.useCallback(A=>{!rt.current||!VA||A.features&&0!==A.features.length||(ZA(null),G(null))},[VA]),ot=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),ZA(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&&ZA({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]),it=A.useCallback(()=>{var A;G(null),ZA(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),at=D?"map-container-fullscreen":"map-container-16-9",st=y.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),lt=!m||!st,ct=st;return t.jsxs("div",{className:`relative ${at}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":OA,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."}),lt&&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..."})]})}),ct&&t.jsx("div",{className:`relative w-full h-full ${D?"":"rounded-[1.125rem] overflow-hidden"} ${lt?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:t.jsxs(O,{ref:c,...C,onMove:Se,mapStyle:It,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:tt,onMouseMove:ot,onMouseLeave:it,onClick:nt,onError:A=>{},onIdle:()=>{if(!x&&!v&&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(U,{position:"bottom-right"}),t.jsx(pA,{mode:OA}),t.jsx(je,{enabled:I,exaggeration:4}),t.jsx(Be,{coveragePoints:PA,visible:PA.length>0&&LA,terrainEnabled:I,brightness:TA,basemapMode:OA}),t.jsx(Et,{showTopology:Q,isExiting:xe,hoveredEdgeKey:z,highlightedLoopEdges:null==JA?void 0:JA.highlightedEdgeKeys,onEdgeHover:Ae,onLoopHover:ee,loops:u.loops,neighborNames:re,opacityBias:Y,widthMultiplier:V,trafficFilter:Z,showNeighborLines:j,disableHover:we||hA}),i&&t.jsx(Nt,{targetHash:i,nodeCoordinates:oe,onComplete:a}),s&&t.jsx(jt,{highlightedEdgeKey:s,validatedPolylines:ue,weakPolylines:fe,onEnsureTopology:$e}),t.jsx(Pt,{ghost:l??null,neighborCoordinates:oe,onHighlightedNeighborsChange:SA}),t.jsx(bt,{neighborsWithLocation:ne,localNode:r,localHash:n,zeroHopNeighbors:ae,lastHopNeighborMap:ie,meshTopology:u,hoveredMarker:_,onMarkerHover:H,getNodeOpacity:Me,shouldShowNode:Qe,onRequestRemove:o?At:void 0,openPopupId:DA,onOpenPopup:NA,onClosePopup:FA,blinkingNodes:De,blinkColor:Ee})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"hops",value:A.size},{label:"seen",value:A.minCertainCount}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`+${t-1} overlapping`,color:"text-violet-400/70"}),{type:"loop",title:{icon:"⟳",text:"Redundant Path"+(t>1?"s":""),color:"text-violet-400"},subtitle:{text:`${e.nodeNames.join(" → ")} → ${e.nodeNames[0]}`,color:"text-text-secondary",mono:!0},stats:r,badges:n}}if("neighbor"===(null==A?void 0:A.type)){const e=A.properties,t=[];void 0!==e.rssi&&null!==e.rssi&&t.push({label:"RSSI",value:`${Math.round(e.rssi)} dBm`,unit:e.hasAvgRssi?"avg":void 0}),void 0!==e.snr&&null!==e.snr&&t.push({label:"SNR",value:`${Number(e.snr).toFixed(1)} dB`,unit:e.hasAvgSnr?"avg":void 0});const r=e.listenerScore??0,n=e.loudScore??0,o=r>0||n>0;return o&&(t.push({label:"listener",value:r,color:"text-accent-success"}),t.push({label:"loud",value:n,color:"text-accent-danger"})),void 0===e.packetCount||o||t.push({label:"packets",value:Number(e.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:e.prefix?`${e.name} (${e.prefix})`:e.name,color:"text-amber-400"},subtitle:{text:"Direct RF Neighbor",color:"text-amber-400/70"},stats:t,badges:[]}}if("topology"===(null==A?void 0:A.type)){const e=A.properties,r=t>0?Number(e.certainCount)/t:0,n=[{label:"validations",value:e.certainCount},{label:"of max traffic",value:`${Math.round(100*r)}%`},{label:"confidence",value:`${Math.round(100*Number(e.confidence))}%`}];if(void 0!==e.symmetryRatio&&e.symmetryRatio<1){const A="forward"===e.dominantDirection?"→":"reverse"===e.dominantDirection?"←":"↔";n.push({label:"symmetric",value:`${A} ${Math.round(100*e.symmetryRatio)}%`,color:"text-text-muted"})}const o=[];return e.isBackbone&&o.push({text:"Backbone",color:"text-gray-300"}),e.isLoopEdge&&o.push({text:"Redundant",color:"text-violet-400"}),e.isDirectPath&&o.push({text:"Direct Path",color:"text-teal-400"}),{type:"topology",title:{icon:"",text:`${e.fromName} ↔ ${e.toName}`,color:"text-text-primary"},stats:n,badges:o}}return null}(VA?{type:VA.type,properties:VA.properties}:null,JA,me);return A&&t.jsx("div",{className:"map-edge-tooltip",children:t.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:t.jsx(Tt,{data:A})})})})(),t.jsx(jA,{mapRef:c,showNeighborLines:j,onToggleNeighborLines:Je,hasNeighborPolylines:de.length>0,nodeFilter:R,onNodeFilterChange:Ke,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:ae.size>0,showCoverage:S,onToggleCoverage:Xe,show3DTerrain:I,onToggle3DTerrain:qe,basemapMode:OA,onToggleBasemap:UA,isFullscreen:D,onToggleFullscreen:Pe}),t.jsxs("div",{className:"map-legend-stack",children:[t.jsx(IA,{isActive:Q,hasAnalyzed:CA,isLoading:hA,onClick:Fe}),t.jsx(RA,{isActive:zA,onClick:GA}),t.jsx(_A,{isActive:PA.length>0&&LA,onClick:HA}),t.jsx(QA,{showTopology:Q,validatedPolylineCount:ue.length,filteredNeighborCount:ne.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:ae,neighborsWithLocation:ne})]}),!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(sA,{isOpen:null!==K,onCancel:()=>eA(null),onConfirm:et,title:"Remove Node?",message:`Remove "${lA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),t.jsx(kA,{isOpen:uA,currentStep:dA,packetCount:xA}),t.jsx(XA,{})]})}export{_t as default}; +import{r as A,b as e,j as t,ab as r,ac as n,bd as o,be as i,h as a,a5 as s,ap as l,V as c,a2 as u,ae as f,k as d,aP as g,aV as h,bf as m,bg as b,bh as p,bi as v,bj as x,ag as w,A as y,aL as k,Z as C,bk as B,c as M,bl as D,X as E,bm as Q,a9 as N,bn as j,av as F,b6 as S,bo as P,$ as I,o as L,ao as R,a6 as T,bp as _,b9 as H,ba as z,bc as G,b8 as O,bq as U}from"./vendor-react-DtVWNgeu.js";import"./maplibre-gl-Bk5DsYkB.js";import{L as Y,c as W}from"./link-scoring-t1Ov70gg.js";import{E as V,I as Z,T as K,k as J,aq as X,ar as q,d as $,as as AA,V as eA,at as tA,au as rA,e as nA,p as oA,av as iA,aw as aA}from"./index-Bmit1I8S.js";import{C as sA}from"./ConfirmModal-Dq3wq7Fw.js";import{c as lA}from"./recharts-C9LxPobD.js";import{g as cA,f as uA,h as fA,i as dA}from"./useThemeColors-DaJMJYCA.js";import{p as gA,a as hA}from"./vendor-core-WoOfkQwm.js";import{u as mA,a as bA,B as pA}from"./BasemapLayer-00O5HUtM.js";import{P as vA,N as xA}from"./Contacts-Dm2Yh1zu.js";import"./deckgl-DTsmDcfs.js";import"./ping-BBb1dLdC.js";import"./PageLayout-CG02PCA-.js";import"./DataBox-Dl3NmnnB.js";import"./SignalIndicator-DagI_WOB.js";import"./CollisionExplorerModal-gzC3uL5Q.js";import"./leaflet-D_ckmI2R.js";function wA(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 yA({label:A,icon:e,status:n,detail:o}){return t.jsxs("div",{className:lA("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-primary/10 ring-2 ring-inset ring-accent-primary","pending"===n&&"opacity-40"),children:[t.jsx("div",{className:lA("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-primary/20","pending"===n&&"bg-white/5"),children:"complete"===n?t.jsx(r,{className:"w-4 h-4 text-accent-primary"}):"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:lA("text-sm font-medium transition-colors","active"===n&&"text-accent-primary","complete"===n&&"text-accent-primary","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 kA=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 f="complete"===l,d=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(yA,{label:"Analyzing Database",icon:t.jsx(i,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),t.jsx(yA,{label:"Building Topology",icon:t.jsx(n,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),t.jsx(yA,{label:"Discovering Nodes",icon:t.jsx(a,{className:"w-4 h-4"}),status:d("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)}),CA={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 BA(){if("undefined"==typeof window)return CA;const A=cA(),e=uA();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:CA.edges.neighborRest,neighborHover:CA.edges.neighborHover,highlight:e.highlight},edgeOpacity:CA.edgeOpacity}}const MA=2e3;function DA({text:A}){return t.jsx(K,{content:A,delay:200,children:t.jsx(g,{className:"w-3.5 h-3.5 text-text-muted cursor-help"})})}function EA({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(DA,{text:e})]}),t.jsx(d,{className:"w-3 h-3 text-text-muted transition-transform duration-200 "+(r?"":"-rotate-90")})]})}function QA({showTopology:e,validatedPolylineCount:r,filteredNeighborCount:n,hasLocalNode:o,meshTopology:i,zeroHopNeighbors:s,neighborsWithLocation:d}){const g=fA(),h=V(),m=Z(),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),[v,x]=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(EA,{title:"Nodes",tooltip:"Node type shown by shape. Yellow = direct RF neighbor.",isOpen:v,onToggle:()=>x(!v)}),v&&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(DA,{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(DA,{text:"Network hub (≥10% of last-hop traffic). Hubs are central to mesh traffic flow."})]}),(B=d,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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(DA,{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(EA,{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:Y.YELLOW}}),t.jsx("span",{className:"text-text-muted",children:"2-Way"}),t.jsx(DA,{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:Y.GREEN}}),t.jsx("span",{className:"text-text-muted",children:"Listener"}),t.jsx(DA,{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:Y.RED}}),t.jsx("span",{className:"text-text-muted",children:"Loud"}),t.jsx(DA,{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(EA,{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:CA.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:CA.edges.hoverLoop}}),t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("span",{style:{color:CA.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(f,{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 jA({mapRef:A,showNeighborLines:e,onToggleNeighborLines:r,hasNeighborPolylines:n,nodeFilter:o,onNodeFilterChange:i,hasHubNodes:a,hasZeroHopNeighbors:s,showCoverage:l,onToggleCoverage:c,show3DTerrain:u,onToggle3DTerrain:f,basemapMode:d,onToggleBasemap:g,isFullscreen:C,onToggleFullscreen:B}){const M=[{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")})}),M.length>1&&t.jsx(NA,{options:M,value:o,onChange:i,size:"sm"}),t.jsx("button",{onClick:g,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",style:"light"===d?{backgroundColor:"#0a1520"}:void 0,title:"light"===d?"Switch to dark map":"Switch to light map","aria-label":"light"===d?"Switch to dark map":"Switch to light map","aria-pressed":"light"===d,children:"light"===d?t.jsx(m,{className:"map-control-icon text-sky-400"}):t.jsx(b,{className:"map-control-icon text-text-secondary"})}),t.jsx("button",{onClick:f,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(p,{className:"map-control-icon "+(u?"text-teal-400":"text-text-secondary")})}),t.jsx("button",{onClick:B,className:"map-control-btn rounded-lg transition-colors hover:bg-white/5",title:C?"Exit fullscreen":"Fullscreen","aria-label":C?"Exit fullscreen":"Enter fullscreen","aria-pressed":C,children:C?t.jsx(v,{className:"map-control-icon text-text-secondary"}):t.jsx(x,{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(w,{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(y,{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(k,{className:"map-control-icon text-text-secondary"})})]})})]})}const FA="#4ADE80",SA="DeepAnalysis";function PA(){return"abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())]}function IA({isActive:e,hasAnalyzed:r,isLoading:o,onClick:i}){const[a,l]=A.useState(!1),[c,u]=A.useState(SA),f=A.useRef(!1),d=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&&!f.current){f.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{d.current&&cancelAnimationFrame(d.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":"var(--bg-body)"},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:FA}: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:FA}:{}},children:m})]})}const LA="#00FFFF";function RA({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),f=A.useRef(!1),[d]=A.useState(()=>{var A;return"undefined"!=typeof window&&((null==(A=window.matchMedia)?void 0:A.call(window,"(hover: hover)").matches)??!1)}),g=n&&!e&&d;A.useEffect(()=>{g&&!f.current&&(f.current=!0,u(1),setTimeout(()=>u(2),100),setTimeout(()=>u(3),200)),n||(f.current=!1,u(0))},[g,n]),A.useEffect(()=>{if(n&&!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&&Ad&&o(!0),onMouseLeave:()=>d&&o(!1),onPointerEnter:()=>d&&o(!0),onPointerLeave:()=>d&&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":"var(--bg-body)"},title:e?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing",children:[t.jsx(C,{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 TA="#fe8019";function _A({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)),f=u<.999,d=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":"var(--bg-body)"},title:e?"Configure wardriving coverage":"Show wardriving coverage",children:[t.jsx(B,{className:"w-3.5 h-3.5 flex-shrink-0 transition-colors "+(e?"text-amber-400":"text-text-secondary"),style:g?{color:TA}: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:TA}:{}},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:!d,className:"p-0.5 rounded transition-colors "+(d?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Decrease opacity (${Math.round(100*u)}%)`,children:t.jsx(b,{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:!f,className:"p-0.5 rounded transition-colors "+(f?"hover:bg-bg-elevated text-amber-400":"text-amber-400/30 cursor-not-allowed"),title:`Increase opacity (${Math.round(100*u)}%)`,children:t.jsx(m,{className:"w-3.5 h-3.5"})})]})]})}function HA(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 zA(A){return Math.exp(-A*Math.LN2/7)}const GA="pymc-wardriving-url",OA="pymc-wardriving-enabled",UA="pymc-wardriving-brightness";function YA(A){"undefined"!=typeof localStorage&&(A?localStorage.setItem(GA,A):localStorage.removeItem(GA))}function WA(A){"undefined"!=typeof localStorage&&localStorage.setItem(OA,String(A))}function VA(){if("undefined"==typeof localStorage)return.7;const A=localStorage.getItem(UA);if(A){const e=parseFloat(A);if(!isNaN(e)&&e>=.01&&e<=1)return e}return.7}function ZA(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 KA=M((A,e)=>({status:"idle",isVisible:"undefined"!=typeof localStorage&&"true"===localStorage.getItem(OA),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:"undefined"==typeof localStorage?"":localStorage.getItem(GA)||"",brightness:VA(),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(UA,String(e))}(t),A({brightness:t})},toggleVisibility:()=>{const t=!e().isVisible;WA(t),A({isVisible:t})},setVisible:e=>{WA(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}=HA(r.hash),o=parseInt(r.time,10),i=isNaN(o)?30:(Date.now()-o)/864e5,a=zA(i),s=ZA(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()}),YA(e.trim()),WA(!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:""}),YA(""),WA(!1)}}));function JA({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 XA(){const{isModalOpen:e,closeModal:n,status:i,isVisible:a,stats:l,error:c,url:u,brightness:d,loadCoverage:g,clearCoverage:h,toggleVisibility:b,setUrl:p,setBrightness:v}=KA(),x="connecting"===i||"loading"===i||"processing"===i,[w,y]=A.useState(u),k=A.useCallback(async()=>{await g(w)},[w,g]),C=A.useCallback(()=>{y(""),h()},[h]),B=A.useCallback(A=>{"Enter"!==A.key||A.shiftKey||x||(A.preventDefault(),k())},[k,x]),M=A.useCallback(A=>{const e=A.target.value;y(e),p(e)},[p]);if(!e)return null;const P=l.coverageCount>0,I=w.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:w,onChange:M,onKeyDown:B,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(JA,{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(Q,{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&&P&&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"]})]})]}),P&&!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(N,{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()}`]})]})]}),P&&!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(m,{className:"w-4 h-4 flex-shrink-0 "+(d>.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*d),"%"]})]}),t.jsx("input",{type:"range",min:"1",max:"100",value:100*d,onChange:A=>v(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:P&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:b,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(f,{className:"w-3.5 h-3.5"})," Show"]})}),t.jsxs("button",{onClick:C,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(F,{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:P?"Done":"Cancel"}),t.jsx("button",{onClick:k,disabled:!I,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..."]}):P?t.jsxs(t.Fragment,{children:[t.jsx(o,{className:"w-4 h-4"}),"Refresh"]}):t.jsxs(t.Fragment,{children:[t.jsx(S,{className:"w-4 h-4"}),"Connect"]})})]})]})]})]})}const qA={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{}}},$A=M()(gA(A=>({isEnabled:!1,toggle:()=>A(A=>({isEnabled:!A.isEnabled})),setEnabled:e=>A({isEnabled:e})}),{name:"pymc-live-trace",storage:hA(()=>qA)}));var Ae=function(A){var e,t=void 0!==(A=A||{})?A:{},r={};for(e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);var n,o="";"undefined"!=typeof document&&document.currentScript&&(o=document.currentScript.src),o=0!==o.indexOf("blob:")?o.substr(0,o.lastIndexOf("/")+1):"",n=function(A,e,t){var r=new XMLHttpRequest;r.open("GET",A,!0),r.responseType="arraybuffer",r.onload=function(){if(200==r.status||0==r.status&&r.response)e(r.response);else{var n=O(A);n?e(n.buffer):t()}},r.onerror=t,r.send(null)};var i=t.print||function(){}.bind(),a=t.printErr||function(){}.bind();for(e in r)r.hasOwnProperty(e)&&(t[e]=r[e]);r=null,t.arguments&&t.arguments;var s=0,l=!1;function c(A){var e=t["_"+A];return e||tA("Assertion failed: "+("Cannot call unknown function "+A+", make sure it is exported")),e}var u,f,d,g,h,m,b,p="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function v(A,e){return A?function(A,e,t){for(var r=e+t,n=e;A[n]&&!(n>=r);)++n;if(n-e>16&&A.subarray&&p)return p.decode(A.subarray(e,n));for(var o="";e>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|a)}else o+=String.fromCharCode(i)}return o}(d,A,e):""}function x(A,e){return A%e>0&&(A+=e-A%e),A}function w(A){u=A,t.HEAP8=f=new Int8Array(A),t.HEAP16=g=new Int16Array(A),t.HEAP32=h=new Int32Array(A),t.HEAPU8=d=new Uint8Array(A),t.HEAPU16=new Uint16Array(A),t.HEAPU32=new Uint32Array(A),t.HEAPF32=m=new Float32Array(A),t.HEAPF64=b=new Float64Array(A)}"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le");var y=t.TOTAL_MEMORY||33554432;function k(A){for(;A.length>0;){var e=A.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?t.dynCall_v(r):t.dynCall_vi(r,e.arg):r(void 0===e.arg?null:e.arg)}else e()}}y=(u=t.buffer?t.buffer:new ArrayBuffer(y)).byteLength,w(u),h[7156]=5271536;var C=[],B=[],M=[],D=[];function E(A){C.unshift(A)}function Q(A){D.unshift(A)}var N=Math.abs,j=Math.ceil,F=Math.floor,S=Math.min,P=0,I=null;t.preloadedImages={},t.preloadedAudios={};var L,R,T=null,_="data:application/octet-stream;base64,";function H(A){return String.prototype.startsWith?A.startsWith(_):0===A.indexOf(_)}function z(){return f.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|L(A,e,t,r,o,s,l,0);break}(a=0|We(s,4))?(c=0|L(A,e,t,r,a,s,l,0),Ye(a),a=c):a=13}else a=2}while(0);return F=i,0|a}function I(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=F,F=F+16|0,m=a+8|0,n[(h=i=a)>>2]=A,n[h+4>>2]=e,(0|t)<0)return F=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 F=a,9;n[m>>2]=0;A:do{if((0|t)>=1)if(s)for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|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+(d<<3)|0)>>2]=s,n[A+4>>2]=e,n[o+(d<<2)>>2]=h,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else for(d=1,f=0,g=0,h=1,s=A;;){if(!(f|g)){if(0|(s=0|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+(d<<3)|0)>>2]=s,n[A+4>>2]=e,l=(0|(A=f+1|0))==(0|h),u=6==(0|(c=g+1|0)),0|HA(s,e)){s=9;break A}if((0|(h=h+(u&l&1)|0))>(0|t)){s=0;break}d=d+1|0,f=l?0:A,g=l?u?0:c:g}else s=0}while(0);return F=a,0|s}function L(A,e,t,r,o,i,a,s){t|=0,r|=0,o|=0,s|=0;var l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0;if(u=F,F=F+16|0,l=u+8|0,c=u,f=0|At(0|(A|=0),0|(e|=0),0|(i|=0),0|(a|=0)),g=0|B(),!(!(0|(p=0|n[(b=h=r+(f<<3)|0)>>2]))&!(0|(b=0|n[b+4>>2]))|(d=(0|p)==(0|A)&(0|b)==(0|e))))do{f=0|$e(0|(f=0|Ve(0|f,0|g,1,0)),0|B(),0|i,0|a),g=0|B(),d=(0|(b=0|n[(p=h=r+(f<<3)|0)>>2]))==(0|A)&(0|(p=0|n[p+4>>2]))==(0|e)}while(!(!(0|b)&!(0|p)|d));if(f=o+(f<<2)|0,d&&(0|n[f>>2])<=(0|s))return F=u,0;if(n[(p=h)>>2]=A,n[p+4>>2]=e,n[f>>2]=s,(0|s)>=(0|t))return F=u,0;switch(d=s+1|0,n[l>>2]=0,0|(f=0|R(A,e,2,l,c))){case 9:m=9;break;case 0:(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d))||(m=9)}A:do{if(9==(0|m)){switch(n[l>>2]=0,0|(f=0|R(A,e,3,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,1,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,5,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,4,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}switch(n[l>>2]=0,0|(f=0|R(A,e,6,l,c))){case 9:break;case 0:if(0|(f=0|L(0|n[(f=c)>>2],0|n[f+4>>2],t,r,o,i,a,d)))break A;break;default:break A}return F=u,0}}while(0);return F=u,0|f}function R(A,e,t,r,o){A|=0,e|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if((t|=0)>>>0>6)return 1;if(f=(0|n[(r|=0)>>2])%6|0,n[r>>2]=f,(0|f)>0){s=0;do{t=0|vA(t),s=s+1|0}while((0|s)<(0|n[r>>2]))}if(f=0|tt(0|A,0|e,45),B(),(a=127&f)>>>0>121)return 5;i=0|OA(A,e),s=0|tt(0|A,0|e,52),B(),s&=15;A:do{if(s){for(;;){if(c=0|tt(0|A,0|e,0|(l=3*(15-s|0)|0)),B(),7==(0|(c&=7))){e=5;break}if(g=!(0|ZA(s)),s=s+-1|0,d=0|rt(7,0,0|l),e&=~B(),A=0|rt(0|n[(g?432:16)+(28*c|0)+(t<<2)>>2],0,0|l)|A&~d,e|=l=0|B(),!(t=0|n[(g?640:224)+(28*c|0)+(t<<2)>>2])){t=0;break A}if(!s){u=8;break A}}return 0|e}u=8}while(0);8==(0|u)&&(A|=0|rt(0|(g=0|n[848+(28*a|0)+(t<<2)>>2]),0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+(t<<2)>>2],127&~g||(g=0|rt(0|n[848+(28*a|0)+20>>2],0,45),e=B()|-1040385&e,t=0|n[4272+(28*a|0)+20>>2],A=0|YA(g|A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]))),c=0|tt(0|A,0|e,45),B(),c&=127;A:do{if(0|z(c)){e:do{if(1==(0|OA(A,e))){if((0|a)!=(0|c)){if(0|Y(c,0|n[7696+(28*a|0)>>2])){A=0|VA(A,e),l=1,e=0|B();break}M(27795,26864,533,26872)}switch(0|i){case 3:A=0|YA(A,e),e=0|B(),n[r>>2]=1+(0|n[r>>2]),l=0;break e;case 5:A=0|VA(A,e),e=0|B(),n[r>>2]=5+(0|n[r>>2]),l=0;break e;case 0:return 9;default:return 1}}else l=0}while(0);if((0|t)>0){s=0;do{A=0|UA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}if((0|a)!=(0|c)){if(!(0|G(c))){if(!!(0|l)|5!=(0|OA(A,e)))break;n[r>>2]=1+(0|n[r>>2]);break}switch(127&f){case 8:case 118:break A}3!=(0|OA(A,e))&&(n[r>>2]=1+(0|n[r>>2]))}}else if((0|t)>0){s=0;do{A=0|YA(A,e),e=0|B(),s=s+1|0}while((0|s)!=(0|t))}}while(0);return n[r>>2]=((0|n[r>>2])+t|0)%6|0,n[(g=o)>>2]=A,n[g+4>>2]=e,0}function 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,f=0,d=0,g=0,h=0;if(i=F,F=F+16|0,h=i+8|0,n[(g=o=i)>>2]=A,n[g+4>>2]=e,(0|t)<0)return F=i,2;if(!t)return n[(h=r)>>2]=A,n[h+4>>2]=e,F=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[(d=r)>>2]=g,n[d+4>>2]=e,d=t+-1|0,f=0,A=1;do{if(a=26800+(f<<2)|0,5==(0|f))for(l=0|n[a>>2],s=0,a=A;;){if(0|(A=0|R(0|n[(A=o)>>2],0|n[A+4>>2],l,h,o)))break A;if((0|s)!=(0|d)){if(c=0|n[(u=o)>>2],u=0|n[u+4>>2],n[(A=r+(a<<3)|0)>>2]=c,n[A+4>>2]=u,0|HA(c,u)){A=9;break A}A=a+1|0}else A=a;if((0|(s=s+1|0))>=(0|t))break;a=A}else for(l=o,u=0|n[a>>2],c=0,a=A,s=0|n[l>>2],l=0|n[l+4>>2];;){if(0|(A=0|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}f=f+1|0}while(f>>>0<6);A=(0|g)==(0|n[(A=o)>>2])&&(0|e)==(0|n[A+4>>2])?0:9}}while(0);return F=i,0|A}function _(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0;for(a=F,F=F+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)?(F=a,0|s):0}function H(A,e,t,r,i,a,s){e|=0,t|=0,r|=0,i|=0,a|=0,s|=0;var l,c,u,f,d,g,h,m,b,p,v=0,x=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,N=0,j=0,S=0,P=0,I=0,L=0,R=0,T=0,_=0;if(p=F,F=F+64|0,h=p+48|0,m=p+32|0,b=p+24|0,l=p+8|0,c=p,(0|(x=0|n[(A|=0)>>2]))<=0)return F=p,0;for(u=A+4|0,f=h+8|0,d=m+8|0,g=l+8|0,v=0,S=0;;){j=(w=0|n[u>>2])+(S<<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|S)==(x+-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+(S+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]),x=0|tA(h,m,r,b);A:do{if(x)w=0,v=x;else if(w=0|n[(x=b)>>2],(0|(x=0|n[x+4>>2]))>0|!(0|x)&w>>>0>0){N=0,j=0;e:for(;;){if(R=1/(+(w>>>0)+4294967296*+(0|x)),_=+o[h>>3],T=+((x=0|Ze(0|w,0|x,0|N,0|j))>>>0)+4294967296*+(0|B()),L=+(N>>>0)+4294967296*+(0|j),o[l>>3]=R*(_*T)+R*(+o[m>>3]*L),o[g>>3]=R*(+o[f>>3]*T)+R*(+o[d>>3]*L),0|(x=0|KA(l,r,c))){v=x;break}C=0|At(0|(E=0|n[(Q=c)>>2]),0|(Q=0|n[Q+4>>2]),0|e,0|t),y=0|B(),w=0|n[(k=x=s+(C<<3)|0)>>2],k=0|n[k+4>>2];t:do{if(!(0|w)&!(0|k))P=x,I=16;else for(M=0,D=0;;){if((0|M)>(0|t)|(0|M)==(0|t)&D>>>0>e>>>0){v=1;break e}if((0|w)==(0|E)&(0|k)==(0|Q))break t;if(C=0|$e(0|(x=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=x=s+(C<<3)|0)>>2]))&!(0|(k=0|n[k+4>>2]))){P=x,I=16;break}}}while(0);if(16!=(0|I)||(I=0,!(0|E)&!(0|Q))||(n[(D=P)>>2]=E,n[D+4>>2]=Q,D=a+(n[i>>2]<<3)|0,n[D>>2]=E,n[D+4>>2]=Q,D=0|Ve(0|n[(D=i)>>2],0|n[D+4>>2],1,0),E=0|B(),n[(Q=i)>>2]=D,n[Q+4>>2]=E),N=0|Ve(0|N,0|j,1,0),j=0|B(),w=0|n[(x=b)>>2],!((0|(x=0|n[x+4>>2]))>(0|j)|(0|x)==(0|j)&w>>>0>N>>>0)){w=1;break A}}w=0}else w=1}while(0);if(S=S+1|0,!w){I=21;break}if((0|S)>=(0|(x=0|n[A>>2]))){v=0,I=21;break}}return 21==(0|I)?(F=p,0|v):0}function z(A){return(A|=0)>>>0>121?0|(A=0):0|(A=0|n[7696+(28*A|0)+16>>2])}function G(A){return 4==(0|(A|=0))|117==(0|A)|0}function O(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)>>2]}function U(A){return 0|n[11120+(216*(0|n[(A|=0)>>2])|0)+(72*(0|n[A+4>>2])|0)+(24*(0|n[A+8>>2])|0)+(n[A+12>>2]<<3)+4>>2]}function Y(A,e){return e|=0,(0|n[7696+(28*(A|=0)|0)+20>>2])==(0|e)?0|(e=1):0|(e=(0|n[7696+(28*A|0)+24>>2])==(0|e))}function W(A,e){return 0|n[848+(28*(A|=0)|0)+((e|=0)<<2)>>2]}function V(A,e){return e|=0,(0|n[848+(28*(A|=0)|0)>>2])==(0|e)?0|(e=0):(0|n[848+(28*A|0)+4>>2])==(0|e)?0|(e=1):(0|n[848+(28*A|0)+8>>2])==(0|e)?0|(e=2):(0|n[848+(28*A|0)+12>>2])==(0|e)?0|(e=3):(0|n[848+(28*A|0)+16>>2])==(0|e)?0|(e=4):(0|n[848+(28*A|0)+20>>2])==(0|e)?0|(e=5):0|((0|n[848+(28*A|0)+24>>2])==(0|e)?6:7)}function Z(A){var e,t,r;return e=(r=+o[16+(A|=0)>>3])-(t=+o[A+24>>3]),+(r>3]<+o[A+24>>3]|0}function J(A){return+(+o[(A|=0)>>3]-+o[A+8>>3])}function X(A,e){A|=0;var t,r,n=0;return(n=+o[(e|=0)>>3])>=+o[A+8>>3]&&n<=+o[A>>3]?(t=+o[A+16>>3],n=+o[A+24>>3],e=(r=+o[e+8>>3])>=n,A=r<=t&1,t>3]<+o[e+8>>3]||+o[A+8>>3]>+o[e>>3]?0|(s=0):(n=(l=+o[A+16>>3])<(u=+o[(t=A+24|0)>>3]),c=(a=+o[(s=e+16|0)>>3])<(i=+o[(r=e+24|0)>>3]),e=u-a>3],e)||(u=+ie(+o[t>>3],A))>+ie(+o[s>>3],e)?0|(c=0):0|(c=1))}function $(A,e){e|=0;var t,r,n,i,a,s=0,l=0,c=0,u=0;return+o[(A|=0)>>3]<+o[e>>3]||+o[A+8>>3]>+o[e+8>>3]?0|(s=0):(n=(i=+o[(s=A+16|0)>>3])<(l=+o[A+24>>3]),c=(u=+o[(t=e+16|0)>>3])<(a=+o[(r=e+24|0)>>3]),e=l-u>3],e)?0|(c=(u=+ie(+o[s>>3],A))>=+ie(+o[t>>3],e)):0|(c=0))}function AA(A,e){A|=0,e|=0;var t,r,i,a,s,l=0;i=F,F=F+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),F=i}function eA(A,e,t){A|=0,e|=0,t|=0;var r,a,c,u,f,d,g,h=0,m=0,b=0,p=0,x=0,y=0,k=0;d=F,F=F+288|0,f=d+264|0,p=d+96|0,m=(h=b=d)+96|0;do{n[h>>2]=0,h=h+4|0}while((0|h)<(0|m));return 0|(e=0|Ae(e,b))?(F=d,0|(y=e)):(qA(b=0|n[(m=b)>>2],m=0|n[m+4>>2],f),$A(b,m,p),u=+ae(f,p+8|0),o[f>>3]=+o[A>>3],o[(m=f+8|0)>>3]=+o[A+16>>3],o[p>>3]=+o[A+8>>3],o[(b=p+8|0)>>3]=+o[A+24>>3],a=+ae(f,p),k=+o[m>>3]-+o[b>>3],c=+l(+k),g=+o[f>>3]-+o[p>>3],r=+l(+g),!(0==k|0==g)&&(k=+ot(+c,+r),k=+v(+a*a/+it(+k/+it(+c,+r),3)/(u*(2.59807621135*u)*.8)),o[i>>3]=k,x=~~k>>>0,y=+l(k)>=1?k>0?~~+w(+s(k/4294967296),4294967295)>>>0:~~+v((k-+(~~k>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2])?(p=!(0|x)&!(0|y),n[(e=t)>>2]=p?1:x,n[e+4>>2]=p?0:y,e=0):e=1,F=d,0|(y=e))}function tA(A,e,t,r){A|=0,e|=0,t|=0,r|=0;var a,c,u,f,d=0,g=0,h=0;f=F,F=F+288|0,c=f+264|0,u=f+96|0,a=(d=g=f)+96|0;do{n[d>>2]=0,d=d+4|0}while((0|d)<(0|a));return 0|(t=0|Ae(t,g))?(F=f,0|(r=t)):(qA(d=0|n[(t=g)>>2],t=0|n[t+4>>2],c),$A(d,t,u),h=+ae(c,u+8|0),h=+v(+ +ae(A,e)/(2*h)),o[i>>3]=h,t=~~h>>>0,d=+l(h)>=1?h>0?~~+w(+s(h/4294967296),4294967295)>>>0:~~+v((h-+(~~h>>>0))/4294967296)>>>0:0,2146435072&~n[i+4>>2]?(g=!(0|t)&!(0|d),n[r>>2]=g?1:t,n[r+4>>2]=g?0:d,F=f,0|(r=0)):(F=f,0|(r=1)))}function rA(A,e,t,r){e|=0,t|=0,r|=0,n[(A|=0)>>2]=e,n[A+4>>2]=t,n[A+8>>2]=r}function nA(A){var e,t=0,r=0,o=0,i=0,a=0;t=0|n[(A|=0)>>2],r=0|n[(e=A+4|0)>>2],(0|t)<0&&(r=r-t|0,n[e>>2]=r,n[(a=A+8|0)>>2]=(0|n[a>>2])-t,n[A>>2]=0,t=0),(0|r)<0?(t=t-r|0,n[A>>2]=t,i=(0|n[(a=A+8|0)>>2])-r|0,n[a>>2]=i,n[e>>2]=0,r=0):(a=i=A+8|0,i=0|n[i>>2]),(0|i)<0&&(t=t-i|0,n[A>>2]=t,r=r-i|0,n[e>>2]=r,n[a>>2]=0,i=0),(0|(o=(0|i)<(0|(o=(0|r)<(0|t)?r:t))?i:o))<=0||(n[A>>2]=t-o,n[e>>2]=r-o,n[a>>2]=i-o)}function oA(A,e){var t,r;e|=0,r=0|n[8+(A|=0)>>2],t=+((0|n[A+4>>2])-r|0),o[e>>3]=+((0|n[A>>2])-r|0)-.5*t,o[e+8>>3]=.8660254037844386*t}function iA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[e>>2])+(0|n[A>>2]),n[t+4>>2]=(0|n[e+4>>2])+(0|n[A+4>>2]),n[t+8>>2]=(0|n[e+8>>2])+(0|n[A+8>>2])}function aA(A,e,t){A|=0,e|=0,n[(t|=0)>>2]=(0|n[A>>2])-(0|n[e>>2]),n[t+4>>2]=(0|n[A+4>>2])-(0|n[e+4>>2]),n[t+8>>2]=(0|n[A+8>>2])-(0|n[e+8>>2])}function sA(A,e){e|=0;var t,r=0;r=0|x(0|n[(A|=0)>>2],e),n[A>>2]=r,t=0|x(0|n[(r=A+4|0)>>2],e),n[r>>2]=t,e=0|x(0|n[(A=A+8|0)>>2],e),n[A>>2]=e}function lA(A){var e,t,r=0,o=0,i=0,a=0,s=0;s=(0|(t=0|n[(A|=0)>>2]))<0,A=(A=(o=(0|(a=((e=(0|(i=(0|n[A+4>>2])-(s?t:0)|0))<0)?0-i|0:0)+((0|n[A+8>>2])-(s?t:0))|0))<0)?0:a)-((i=(0|(o=(0|A)<(0|(o=(0|(r=(e?0:i)-(o?a:0)|0))<(0|(a=(s?0:t)-(e?i:0)-(o?a:0)|0))?r:a))?A:o))>0)?o:0)|0,r=r-(i?o:0)|0;A:do{switch(a-(i?o:0)|0){case 0:switch(0|r){case 0:return 0|(0|A?1==(0|A)?1:7:0);case 1:return 0|(0|A?1==(0|A)?3:7:2);default:break A}case 1:switch(0|r){case 0:return 0|(0|A?1==(0|A)?5:7:4);case 1:if(A)break A;return 6;default:break A}}}while(0);return 7}function cA(A){var e,t,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(l=0|n[(t=8+(A|=0)|0)>>2],(e=(0|n[A>>2])-l|0)>>>0>715827881|(l=(0|n[(c=A+4|0)>>2])-l|0)>>>0>715827881){if(a=2147483647-e|0,s=-2147483648-e|0,(i=(0|e)>0)?(0|a)<(0|e):(0|s)>(0|e))return 1;if(o=e<<1,i?(2147483647-o|0)<(0|e):(-2147483648-o|0)>(0|e))return 1;if((0|l)>0?(2147483647-l|0)<(0|l):(-2147483648-l|0)>(0|l))return 1;if(r=3*e|0,o=l<<1,(i?(0|a)<(0|o):(0|s)>(0|o))||((0|e)>-1?(-2147483648|r)>=(0|l):(-2147483648^r)<(0|l)))return 1}else o=l<<1,r=3*e|0;return i=0|Oe(.14285714285714285*+(r-l|0)),n[A>>2]=i,a=0|Oe(.14285714285714285*+(o+e|0)),n[c>>2]=a,n[t>>2]=0,r=(o=(0|a)<(0|i))?i:a,(0|(o=o?a:i))<0&&((-2147483648==(0|o)||((0|r)>0?(2147483647-r|0)<(0|o):(-2147483648-r|0)>(0|o)))&&M(27795,26892,354,26903),((0|r)>-1?(-2147483648|r)>=(0|o):(-2147483648^r)<(0|o))&&M(27795,26892,354,26903)),r=a-i|0,(0|i)<0?(o=0-i|0,n[c>>2]=r,n[t>>2]=o,n[A>>2]=0,i=0):(r=a,o=0),(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[t>>2]=o,n[c>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[c>>2]=a,n[t>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[c>>2]=r-i,n[t>>2]=o-i),0}function uA(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0;if(i=0|n[(e=8+(A|=0)|0)>>2],(a=(0|n[A>>2])-i|0)>>>0>715827881|(i=(0|n[(s=A+4|0)>>2])-i|0)>>>0>715827881){if((r=(0|a)>0)?(2147483647-a|0)<(0|a):(-2147483648-a|0)>(0|a))return 1;if(t=a<<1,(o=(0|i)>0)?(2147483647-i|0)<(0|i):(-2147483648-i|0)>(0|i))return 1;if(l=i<<1,o?(2147483647-l|0)<(0|i):(-2147483648-l|0)>(0|i))return 1;if(r?(2147483647-t|0)<(0|i):(-2147483648-t|0)>(0|i))return 1;if(r=3*i|0,(0|i)>-1?(-2147483648|r)>=(0|a):(-2147483648^r)<(0|a))return 1}else r=3*i|0,t=a<<1;return o=0|Oe(.14285714285714285*+(t+i|0)),n[A>>2]=o,i=0|Oe(.14285714285714285*+(r-a|0)),n[s>>2]=i,n[e>>2]=0,t=(r=(0|i)<(0|o))?o:i,(0|(r=r?i:o))<0&&((-2147483648==(0|r)||((0|t)>0?(2147483647-t|0)<(0|r):(-2147483648-t|0)>(0|r)))&&M(27795,26892,402,26917),((0|t)>-1?(-2147483648|t)>=(0|r):(-2147483648^t)<(0|r))&&M(27795,26892,402,26917)),t=i-o|0,(0|o)<0?(r=0-o|0,n[s>>2]=t,n[e>>2]=r,n[A>>2]=0,o=0):(t=i,r=0),(0|t)<0&&(o=o-t|0,n[A>>2]=o,r=r-t|0,n[e>>2]=r,n[s>>2]=0,t=0),a=o-r|0,i=t-r|0,(0|r)<0?(n[A>>2]=a,n[s>>2]=i,n[e>>2]=0,t=i,i=a,r=0):i=o,(0|(o=(0|r)<(0|(o=(0|t)<(0|i)?t:i))?r:o))<=0||(n[A>>2]=i-o,n[s>>2]=t-o,n[e>>2]=r-o),0}function fA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+((3*(r=(0|n[A>>2])-o|0)|0)-(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((o<<1)+r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function dA(A){var e,t,r=0,o=0,i=0,a=0,s=0;o=0|n[(e=8+(A|=0)|0)>>2],i=0|Oe(.14285714285714285*+(((r=(0|n[A>>2])-o|0)<<1)+(o=(0|n[(t=A+4|0)>>2])-o|0)|0)),n[A>>2]=i,r=0|Oe(.14285714285714285*+((3*o|0)-r|0)),n[t>>2]=r,n[e>>2]=0,o=r-i|0,(0|i)<0?(s=0-i|0,n[t>>2]=o,n[e>>2]=s,n[A>>2]=0,r=o,i=0,o=s):o=0,(0|r)<0&&(i=i-r|0,n[A>>2]=i,o=o-r|0,n[e>>2]=o,n[t>>2]=0,r=0),s=i-o|0,a=r-o|0,(0|o)<0?(n[A>>2]=s,n[t>>2]=a,n[e>>2]=0,r=a,a=s,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|r)<(0|a)?r:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=r-i,n[e>>2]=o-i)}function gA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],i=0|n[(t=A+4|0)>>2],a=0|n[(r=A+8|0)>>2],s=i+(3*o|0)|0,n[A>>2]=s,i=a+(3*i|0)|0,n[t>>2]=i,o=(3*a|0)+o|0,n[r>>2]=o,a=i-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=a,n[r>>2]=o,n[A>>2]=0,i=a,a=0):a=s,(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function hA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(3*(o=0|n[(t=A+4|0)>>2])|0)+s|0,s=(i=0|n[(r=A+8|0)>>2])+(3*s|0)|0,n[A>>2]=s,n[t>>2]=a,o=(3*i|0)+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,s=0):i=a,(0|i)<0&&(s=s-i|0,n[A>>2]=s,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=s-o|0,a=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=a,n[r>>2]=0,s=e,o=0):a=i,(0|(i=(0|o)<(0|(i=(0|a)<(0|s)?a:s))?o:i))<=0||(n[A>>2]=s-i,n[t>>2]=a-i,n[r>>2]=o-i)}function mA(A,e){A|=0;var t,r,o,i=0,a=0,s=0;((e|=0)-1|0)>>>0>=6||(s=(0|n[15440+(12*e|0)>>2])+(0|n[A>>2])|0,n[A>>2]=s,o=A+4|0,a=(0|n[15440+(12*e|0)+4>>2])+(0|n[o>>2])|0,n[o>>2]=a,r=A+8|0,e=(0|n[15440+(12*e|0)+8>>2])+(0|n[r>>2])|0,n[r>>2]=e,i=a-s|0,(0|s)<0?(e=e-s|0,n[o>>2]=i,n[r>>2]=e,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,e=e-i|0,n[r>>2]=e,n[o>>2]=0,i=0),t=a-e|0,s=i-e|0,(0|e)<0?(n[A>>2]=t,n[o>>2]=s,n[r>>2]=0,a=t,e=0):s=i,(0|(i=(0|e)<(0|(i=(0|s)<(0|a)?s:a))?e:i))<=0||(n[A>>2]=a-i,n[o>>2]=s-i,n[r>>2]=e-i))}function bA(A){var e,t,r,o=0,i=0,a=0,s=0;s=0|n[(A|=0)>>2],a=(o=0|n[(t=A+4|0)>>2])+s|0,s=(i=0|n[(r=A+8|0)>>2])+s|0,n[A>>2]=s,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function pA(A){var e,t,r,o=0,i=0,a=0,s=0;o=0|n[(A|=0)>>2],a=0|n[(t=A+4|0)>>2],i=0|n[(r=A+8|0)>>2],s=a+o|0,n[A>>2]=s,a=i+a|0,n[t>>2]=a,o=i+o|0,n[r>>2]=o,i=a-s|0,(0|s)<0?(o=o-s|0,n[t>>2]=i,n[r>>2]=o,n[A>>2]=0,a=0):(i=a,a=s),(0|i)<0&&(a=a-i|0,n[A>>2]=a,o=o-i|0,n[r>>2]=o,n[t>>2]=0,i=0),e=a-o|0,s=i-o|0,(0|o)<0?(n[A>>2]=e,n[t>>2]=s,n[r>>2]=0,a=e,o=0):s=i,(0|(i=(0|o)<(0|(i=(0|s)<(0|a)?s:a))?o:i))<=0||(n[A>>2]=a-i,n[t>>2]=s-i,n[r>>2]=o-i)}function vA(A){switch(0|(A|=0)){case 1:A=5;break;case 5:A=4;break;case 4:A=6;break;case 6:A=2;break;case 2:A=3;break;case 3:A=1}return 0|A}function xA(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|LA(A,t)):0|(t=0)}function DA(A,e,t){t|=0;var r,o,i=0,a=0;return o=F,F=F+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=F,F=F+16|0,i=r,o=0|HA(A|=0,e|=0),(t+-1|0)>>>0>5)return F=r,-1;if(1==(0|t)&(o=!!(0|o)))return F=r,-1;do{if(!(0|Se(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 F=r,0|(i=o)}(A,a,7&i),-1==(0|i)?(n[t>>2]=0,F=o,0|(a=6)):(0|XA(A,a,r)&&M(27795,26932,282,26947),e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,a)?QA(r,e,i,2,t):SA(r,e,i,2,t),F=o,0|(a=0))):(F=o,0|(a=6))}function EA(A,e,t,r,i){e|=0,t|=0,r|=0,i|=0;var a,s=0,u=0;if(s=+function(A){var e,t;return t=+o[(A|=0)>>3],e=+o[A+8>>3],+ +c(+(t*t+e*e))}(A|=0),s<1e-16)return e=15600+(e<<4)|0,n[i>>2]=n[e>>2],n[i+4>>2]=n[e+4>>2],n[i+8>>2]=n[e+8>>2],void(n[i+12>>2]=n[e+12>>2]);if(u=+p(+ +o[A+8>>3],+ +o[A>>3]),(0|t)>0){A=0;do{s*=.37796447300922725,A=A+1|0}while((0|A)!=(0|t))}a=.3333333333333333*s,r?(t=!(0|ZA(t)),s=+b(.381966011250105*(t?a:.37796447300922725*a))):(s=+b(.381966011250105*s),0|ZA(t)&&(u=+ne(u+.3334731722518321))),function(A,e,t,r){A|=0,e=+e,r|=0;var i=0,a=0,s=0,c=0;if((t=+t)<1e-16)return n[r>>2]=n[A>>2],n[r+4>>2]=n[A+4>>2],n[r+8>>2]=n[A+8>>2],void(n[r+12>>2]=n[A+12>>2]);a=e<0?e+6.283185307179586:e,a=e>=6.283185307179586?a+-6.283185307179586:a;do{if(!(a<1e-16)){if(i=+l(+(a+-3.141592653589793))<1e-16,e=+o[A>>3],i){e-=t,o[r>>3]=e,i=r;break}if(s=+f(+t),t=+d(+t),e=s*+d(+e)+ +f(+a)*(t*+f(+e)),e=+m(+((e=e>1?1:e)<-1?-1:e)),o[r>>3]=e,+l(+(e+-1.5707963267948966))<1e-16)return o[r>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[r>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if(c=1/+f(+e),a=t*+d(+a)*c,t=+o[A>>3],e=c*((s-+d(+e)*+d(+t))/+f(+t)),s=a>1?1:a,e=e>1?1:e,(e=+o[A+8>>3]+ +p(+(s<-1?-1:s),+(e<-1?-1:e)))>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);return void(o[r+8>>3]=e)}e=+o[A>>3]+t,o[r>>3]=e,i=r}while(0);if(+l(+(e+-1.5707963267948966))<1e-16)return o[i>>3]=1.5707963267948966,void(o[r+8>>3]=0);if(+l(+(e+1.5707963267948966))<1e-16)return o[i>>3]=-1.5707963267948966,void(o[r+8>>3]=0);if((e=+o[A+8>>3])>3.141592653589793)do{e+=-6.283185307179586}while(e>3.141592653589793);if(e<-3.141592653589793)do{e+=6.283185307179586}while(e<-3.141592653589793);o[r+8>>3]=e}(15600+(e<<4)|0,+ne(+o[15920+(24*e|0)>>3]-u),s,i)}function QA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,x,w,y,k,C,B,D,E,Q,N=0,j=0,S=0,P=0,I=0,L=0;if(Q=F,F=F+272|0,P=Q+240|0,B=Q,D=Q+224|0,E=Q+208|0,b=Q+176|0,p=Q+160|0,v=Q+192|0,x=Q+144|0,w=Q+128|0,y=Q+112|0,k=Q+96|0,C=Q+80|0,n[(N=Q+256|0)>>2]=e,n[P>>2]=n[A>>2],n[P+4>>2]=n[A+4>>2],n[P+8>>2]=n[A+8>>2],n[P+12>>2]=n[A+12>>2],NA(P,N,B),n[i>>2]=0,(0|(P=r+t+(5==(0|r)&1)|0))<=(0|t))F=Q;else{s=D+4|0,l=b+4|0,c=t+5|0,u=16880+((a=0|n[N>>2])<<2)|0,f=16960+(a<<2)|0,d=w+8|0,g=y+8|0,h=k+8|0,m=E+4|0,S=t;A:for(;;){j=B+((0|S)%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|S)>(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],N=0|n[17040+(80*r|0)+(n[D>>2]<<2)>>2],n[b>>2]=n[18640+(80*r|0)+(20*N|0)>>2],(0|(j=0|n[18640+(80*r|0)+(20*N|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*N|0)+4|0,n[v>>2]=n[j>>2],n[v+4>>2]=n[j+4>>2],n[v+8>>2]=n[j+8>>2],sA(v,3*(0|n[u>>2])|0),iA(l,v,l),nA(l),oA(l,x),I=+(0|n[f>>2]),o[w>>3]=3*I,o[d>>3]=0,L=-1.5*I,o[y>>3]=L,o[g>>3]=2.598076211353316*I,o[k>>3]=L,o[h>>3]=-2.598076211353316*I,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}Ne(p,x,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|S)<(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|(S=S+1|0))>=(0|P)){A=3;break}}3!=(0|A)?12==(0|A)&&M(26970,27017,572,27027):F=Q}}function NA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=F,F=F+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),F=r}function jA(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c,u=0,f=0,d=0,g=0,h=0;if(c=F,F=F+32|0,l=c+12|0,i=c,h=4+(A|=0)|0,g=0|n[16960+((e|=0)<<2)>>2],g=(s=!!(0|r))?3*g|0:g,u=0|n[h>>2],o=0|n[(a=A+8|0)>>2],s){if((0|(u=o+u+(r=0|n[(f=A+12|0)>>2])|0))==(0|g))return F=c,1;d=f}else u=o+u+(r=0|n[(d=A+12|0)>>2])|0;if((0|u)<=(0|g))return F=c,0;do{if((0|r)>0){if(r=0|n[A>>2],(0|o)>0){f=18640+(80*r|0)+60|0,r=A;break}r=18640+(80*r|0)+40|0,t?(rA(l,g,0,0),aA(h,l,i),pA(i),iA(i,l,h),f=r,r=A):(f=r,r=A)}else f=18640+(80*(0|n[A>>2])|0)+20|0,r=A}while(0);if(n[r>>2]=n[f>>2],(0|n[(u=f+16|0)>>2])>0){r=0;do{bA(h),r=r+1|0}while((0|r)<(0|n[u>>2]))}return A=f+4|0,n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],e=0|n[16880+(e<<2)>>2],sA(l,s?3*e|0:e),iA(h,l,h),nA(h),r=s&&((0|n[a>>2])+(0|n[h>>2])+(0|n[d>>2])|0)==(0|g)?1:2,F=c,0|r}function FA(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 SA(A,e,t,r,i){A|=0,e|=0,t|=0,r|=0,i|=0;var a,s,l,c,u,f,d,g,h,m,b,p,v,x,w,y,k,C,B=0,D=0,E=0,Q=0,N=0;if(C=F,F=F+240|0,x=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,v=C+96|0,n[(B=C+224|0)>>2]=e,n[x>>2]=n[A>>2],n[x+4>>2]=n[A+4>>2],n[x+8>>2]=n[A+8>>2],n[x+12>>2]=n[A+12>>2],PA(x,B,w),n[i>>2]=0,(0|(g=r+t+(6==(0|r)&1)|0))<=(0|t))F=C;else{s=t+6|0,l=16960+((a=0|n[B>>2])<<2)|0,c=m+8|0,u=b+8|0,f=p+8|0,d=y+4|0,D=0,E=t,r=-1;A:for(;;){if(A=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),Q=+(0|n[l>>2]),o[m>>3]=3*Q,o[c>>3]=0,N=-1.5*Q,o[b>>3]=N,o[u>>3]=2.598076211353316*Q,o[p>>3]=N,o[f>>3]=-2.598076211353316*Q,B=0|n[x>>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}Ne(k,h,r,A,v),0|je(k,v)||0|je(h,v)||(EA(v,0|n[x>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2]))}if((0|E)<(0|s)&&(oA(d,k),EA(k,0|n[y>>2],a,1,i+8+(n[i>>2]<<4)|0),n[i>>2]=1+(0|n[i>>2])),(0|(E=E+1|0))>=(0|g)){A=3;break}r=0|n[y>>2]}3!=(0|A)?8==(0|A)&&M(27054,27017,737,27099):F=C}}function PA(A,e,t){A|=0,e|=0,t|=0;var r,o=0,i=0,a=0,s=0,l=0;r=F,F=F+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),F=r}function IA(A,e){return e=0|tt(0|(A|=0),0|(e|=0),45),B(),127&e}function LA(A,e){A|=0;var t=0,n=0,o=0,i=0;return!0&134217728==(-16777216&(e|=0))?(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0>121?0|(A=0):!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())?0|r[20528+t|0]?!(0|A)&!(0|(e&=8191))?0|(i=1):(i=0|nt(0|A,0|e),B(),0|!!((63-i|0)%3|0)):0|(i=1):0|(i=0)):0|(A=0)}function 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|vA(7&i),0,0|o))|A&~r,e=(i=0|B())|e&~n;A:do{if(!t)if(!(o&r|0)&!(i&n|0))t=0;else if(r=0|tt(0|A,0|e,52),B(),r&=15){t=1;e:for(;;){switch(i=0|tt(0|A,0|e,3*(15-t|0)|0),B(),7&i){case 1:break e;case 0:break;default:t=1;break A}if(!(t>>>0>>0)){t=1;break A}t=t+1|0}for(t=1;;){if(n=0|tt(0|A,0|e,0|(i=3*(15-t|0)|0)),B(),o=0|rt(7,0,0|i),e&=~B(),A=A&~o|(i=0|rt(0|vA(7&n),0,0|i)),e=0|e|B(),!(t>>>0>>0)){t=1;break}t=t+1|0}}else t=1}while(0);if(!(a>>>0>>0))break;a=a+1|0}return C(0|e),0|A}function YA(A,e){var t=0,r=0,n=0,o=0,i=0;if(r=0|tt(0|(A|=0),0|(e|=0),52),B(),!(r&=15))return r=A,C(0|(t=e)),0|r;for(t=1;i=0|tt(0|A,0|e,0|(o=3*(15-t|0)|0)),B(),n=0|rt(7,0,0|o),e&=~B(),A=(o=0|rt(0|vA(7&i),0,0|o))|A&~n,e=0|B()|e,t>>>0>>0;)t=t+1|0;return C(0|e),0|A}function WA(A,e){var t=0,r=0,n=0,o=0,i=0,a=0,s=0;if(s=0|tt(0|(A|=0),0|(e|=0),52),B(),!(s&=15))return s=A,C(0|(a=e)),0|s;for(a=1,t=0;;){r=0|rt(7,0,0|(o=3*(15-a|0)|0)),n=0|B(),i=0|tt(0|A,0|e,0|o),B(),A=(o=0|rt(0|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(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|xA(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|xA(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=F,F=F+16|0,i=r,(e|=0)>>>0>15?(F=r,0|(i=4)):2146435072&~n[4+(A|=0)>>2]&&2146435072&~n[A+8+4>>2]?(function(A,e,t){var r,i;r=F,F=F+16|0,function(A,e,t,r){e|=0,r|=0;var i,a=0,s=0,l=0,c=0;if(i=F,F=F+16|0,function(A,e,t){e|=0,t|=0;var r,i,a=0;i=F,F=F+32|0,function(A,e){e|=0;var t,r,n=0;n=+o[(A|=0)>>3],t=+f(+n),n=+d(+n),o[e+16>>3]=n,n=+o[A+8>>3],r=t*+f(+n),o[e>>3]=r,n=t*+d(+n),o[e+8>>3]=n}(A|=0,r=i),n[e>>2]=0,o[t>>3]=5,(a=+Fe(16400,r))<+o[t>>3]&&(n[e>>2]=0,o[t>>3]=a),(a=+Fe(16424,r))<+o[t>>3]&&(n[e>>2]=1,o[t>>3]=a),(a=+Fe(16448,r))<+o[t>>3]&&(n[e>>2]=2,o[t>>3]=a),(a=+Fe(16472,r))<+o[t>>3]&&(n[e>>2]=3,o[t>>3]=a),(a=+Fe(16496,r))<+o[t>>3]&&(n[e>>2]=4,o[t>>3]=a),(a=+Fe(16520,r))<+o[t>>3]&&(n[e>>2]=5,o[t>>3]=a),(a=+Fe(16544,r))<+o[t>>3]&&(n[e>>2]=6,o[t>>3]=a),(a=+Fe(16568,r))<+o[t>>3]&&(n[e>>2]=7,o[t>>3]=a),(a=+Fe(16592,r))<+o[t>>3]&&(n[e>>2]=8,o[t>>3]=a),(a=+Fe(16616,r))<+o[t>>3]&&(n[e>>2]=9,o[t>>3]=a),(a=+Fe(16640,r))<+o[t>>3]&&(n[e>>2]=10,o[t>>3]=a),(a=+Fe(16664,r))<+o[t>>3]&&(n[e>>2]=11,o[t>>3]=a),(a=+Fe(16688,r))<+o[t>>3]&&(n[e>>2]=12,o[t>>3]=a),(a=+Fe(16712,r))<+o[t>>3]&&(n[e>>2]=13,o[t>>3]=a),(a=+Fe(16736,r))<+o[t>>3]&&(n[e>>2]=14,o[t>>3]=a),(a=+Fe(16760,r))<+o[t>>3]&&(n[e>>2]=15,o[t>>3]=a),(a=+Fe(16784,r))<+o[t>>3]&&(n[e>>2]=16,o[t>>3]=a),(a=+Fe(16808,r))<+o[t>>3]&&(n[e>>2]=17,o[t>>3]=a),(a=+Fe(16832,r))<+o[t>>3]&&(n[e>>2]=18,o[t>>3]=a),(a=+Fe(16856,r))<+o[t>>3]?(n[e>>2]=19,o[t>>3]=a,F=i):F=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(F=i);if(c=0|n[t>>2],a=+ne((a=+o[15920+(24*c|0)>>3])-+ne(+function(A,e){var t,r,n,i,a;return A|=0,i=+o[(e|=0)>>3],r=+f(+i),n=+o[e+8>>3]-+o[A+8>>3],a=r*+d(+n),t=+o[A>>3],+ +p(+a,+(+d(+i)*+f(+t)-+f(+n)*(r*+d(+t))))}(15600+(c<<4)|0,A))),l=0|ZA(e)?+ne(a+-.3334731722518321):a,a=2.618033988749896*+g(+s),(0|e)>0){A=0;do{a*=2.6457513110645907,A=A+1|0}while((0|A)!=(0|e))}s=+f(+l)*a,o[r>>3]=s,l=+d(+l)*a,o[r+8>>3]=l,F=i}(A|=0,e|=0,t|=0,i=r),function(A,e){A|=0;var t,r,i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0;n[(a=8+(e|=0)|0)>>2]=0,r=+o[A>>3],f=+l(+r),i=+o[A+8>>3],f+=.5*(d=1.1547005383792515*+l(+i)),f-=+(0|(s=~~f)),d-=+(0|(A=~~d));do{if(f<.5){if(f<.3333333333333333){if(n[e>>2]=s,d<.5*(f+1)){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(A=(1&!(d<(h=1-f)))+A|0,n[e+4>>2]=A,h<=d&d<2*f){s=s+1|0,n[e>>2]=s;break}n[e>>2]=s;break}if(!(f<.6666666666666666)){if(s=s+1|0,n[e>>2]=s,d<.5*f){n[e+4>>2]=A;break}A=A+1|0,n[e+4>>2]=A;break}if(d<1-f){if(n[e+4>>2]=A,2*f-1>2]=s;break}}else A=A+1|0,n[e+4>>2]=A;s=s+1|0,n[e>>2]=s}while(0);do{if(r<0){if(1&A){s=~~(+(0|s)-(2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(A+1|0)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))+1)),n[e>>2]=s;break}s=~~(+(0|s)-2*(+((g=0|Ze(0|s,((0|s)<0)<<31>>31,0|(g=(0|A)/2|0),((0|g)<0)<<31>>31))>>>0)+4294967296*+(0|B()))),n[e>>2]=s;break}}while(0);g=e+4|0,i<0&&(s=s-((1|A<<1)/2|0)|0,n[e>>2]=s,A=0-A|0,n[g>>2]=A),c=A-s|0,(0|s)<0?(u=0-s|0,n[g>>2]=c,n[a>>2]=u,n[e>>2]=0,A=c,s=0):u=0,(0|A)<0&&(s=s-A|0,n[e>>2]=s,u=u-A|0,n[a>>2]=u,n[g>>2]=0,A=0),t=s-u|0,c=A-u|0,(0|u)<0&&(n[e>>2]=t,n[g>>2]=c,n[a>>2]=0,A=c,s=t,u=0),(0|(c=(0|u)<(0|(c=(0|A)<(0|s)?A:s))?u:c))<=0||(n[e>>2]=s-c,n[g>>2]=A-c,n[a>>2]=u-c)}(i,t+4|0),F=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=F,F=F+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)),F=t,0|l):(rt(0|O(A),0,45),s=0|B()|r,l=-1,C(0|s),F=t,0|l);if(n[l>>2]=n[A>>2],n[l+4>>2]=n[A+4>>2],n[l+8>>2]=n[A+8>>2],n[l+12>>2]=n[A+12>>2],s=l+4|0,(0|e)>0)for(A=-1;n[o>>2]=n[s>>2],n[o+4>>2]=n[s+4>>2],n[o+8>>2]=n[s+8>>2],1&e?(fA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],gA(i)):(dA(s),n[i>>2]=n[s>>2],n[i+4>>2]=n[s+4>>2],n[i+8>>2]=n[s+8>>2],hA(i)),aA(o,i,a),nA(a),c=0|rt(7,0,0|(u=3*(15-e|0)|0)),r&=~B(),A=(u=0|rt(0|lA(a),0,0|u))|A&~c,r=0|B()|r,(0|e)>1;)e=e+-1|0;else A=-1;A:do{if((0|n[s>>2])<=2&&(0|n[l+8>>2])<=2&&(0|n[l+12>>2])<=2){if(e=0|rt(0|(o=0|O(l)),0,45),e|=A,A=B()|-1040385&r,a=0|U(l),!(0|z(o))){if((0|a)<=0)break;for(i=0;;){if(o=0|tt(0|e,0|A,52),B(),o&=15)for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0;if((0|(i=i+1|0))==(0|a))break A}}i=0|tt(0|e,0|A,52),B(),i&=15;e:do{if(i){r=1;t:for(;;){switch(u=0|tt(0|e,0|A,3*(15-r|0)|0),B(),7&u){case 1:break t;case 0:break;default:break e}if(!(r>>>0>>0))break e;r=r+1|0}if(0|Y(o,0|n[l>>2]))for(r=1;c=0|rt(7,0,0|(l=3*(15-r|0)|0)),u=A&~B(),A=0|tt(0|e,0|A,0|l),B(),e=e&~c|(A=0|rt(0|xA(7&A),0,0|l)),A=0|u|B(),r>>>0>>0;)r=r+1|0;else for(r=1;l=0|tt(0|e,0|A,0|(u=3*(15-r|0)|0)),B(),c=0|rt(7,0,0|u),A&=~B(),e=e&~c|(u=0|rt(0|vA(7&l),0,0|u)),A=0|A|B(),r>>>0>>0;)r=r+1|0}}while(0);if((0|a)>0){r=0;do{e=0|UA(e,A),A=0|B(),r=r+1|0}while((0|r)!=(0|a))}}else e=0,A=0}while(0);return u=e,C(0|(c=A)),F=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),F=r,0|(i=0)):(F=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=F,F=F+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,F=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|xA(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 F=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)&&dA(l)}else(0|s)!=(0|c)&&(n[l>>2]=n[r>>2],n[l+4>>2]=n[r+4>>2],n[l+8>>2]=n[r+8>>2]);return F=o,0}function qA(A,e,t){t|=0;var r,o,i=0;return o=F,F=F+16|0,0|(i=0|XA(A|=0,e|=0,r=o))?(F=o,0|i):(i=0|tt(0|A,0|e,52),B(),function(A,e,t){var r,o;e|=0,t|=0,r=F,F=F+16|0,oA(4+(A|=0)|0,o=r),EA(o,0|n[A>>2],e,0,t),F=r}(r,15&i,t),F=o,0|(i=0))}function $A(A,e,t){t|=0;var r,n=0,o=0,i=0;if(r=F,F=F+16|0,0|(n=0|XA(A|=0,e|=0,i=r)))return F=r,0|n;n=0|tt(0|A,0|e,45),B(),n=!(0|z(127&n)),o=0|tt(0|A,0|e,52),B(),o&=15;A:do{if(!n){if(0|o)for(n=1;;){if(!(!((0|rt(7,0,3*(15-n|0)|0))&A)&!((0|B())&e)))break A;if(!(n>>>0>>0))break;n=n+1|0}return QA(i,o,0,5,t),F=r,0}}while(0);return SA(i,o,0,6,t),F=r,0}function Ae(A,e){e|=0;var t=0,r=0,o=0,i=0,a=0,s=0,l=0;if((A|=0)>>>0>15)return 4;if(rt(0|A,0,52),s=134225919|B(),!A){t=0,r=0;do{0|z(r)&&(rt(0|r,0,45),a=0|s|B(),n[(A=e+(t<<3)|0)>>2]=-1,n[A+4>>2]=a,t=t+1|0),r=r+1|0}while(122!=(0|r));return 0}t=0,a=0;do{if(0|z(a)){for(rt(0|a,0,45),r=1,o=-1,i=0|s|B();o&=~(l=0|rt(7,0,3*(15-r|0)|0)),i&=~B(),(0|r)!=(0|A);)r=r+1|0;n[(l=e+(t<<3)|0)>>2]=o,n[l+4>>2]=i,t=t+1|0}a=a+1|0}while(122!=(0|a));return 0}function ee(A,e,t,r){A|=0,r|=0;var o=0,i=0,a=0;o=0|tt(0|(e|=0),0|(t|=0),52),B(),!(0|e)&!(0|t)|(0|r)>15|(0|(o&=15))>(0|r)?(i=-1,e=-1,t=0,o=0):(e=0|zA(e,t,o+1|0,r),a=-15728641&B(),t=0|rt(0|r,0,52),i=o,e=(e=!(0|HA(t|=e,a=0|a|B())))?-1:r,o=a),n[(a=A)>>2]=t,n[a+4>>2]=o,n[A+8>>2]=i,n[A+12>>2]=e}function te(A,e,t,r){t|=0,r|=0;var o=0,i=0;return o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,n[(i=r+8|0)>>2]=o,!(0|A)&!(0|e)|(0|t)>15|(0|o)>(0|t)?(n[(t=r)>>2]=0,n[t+4>>2]=0,n[i>>2]=-1,void(n[r+12>>2]=-1)):(A=0|zA(A,e,o+1|0,t),i=-15728641&B(),o=0|rt(0|t,0,52),o|=A,i=0|i|B(),n[(A=r)>>2]=o,n[A+4>>2]=i,A=r+12|0,0|HA(o,i)?void(n[A>>2]=t):void(n[A>>2]=-1))}function re(A){var e,t=0,r=0,o=0,i=0,a=0,s=0,l=0,c=0;if(!(!(0|(t=0|n[(r=A|=0)>>2]))&!(0|(r=0|n[r+4>>2]))||(o=0|tt(0|t,0|r,52),B(),t=0|Ve(0|(l=0|rt(1,0,3*(15^(o&=15))|0)),0|B(),0|t,0|r),r=0|B(),n[(l=A)>>2]=t,n[l+4>>2]=r,(0|o)<(0|(s=0|n[(l=A+8|0)>>2]))))){for(e=A+12|0,a=o;;){if((0|a)==(0|s)){o=5;break}if(c=(0|a)==(0|n[e>>2]),o=0|tt(0|t,0|r,0|(i=3*(15-a|0)|0)),B(),c&1==(0|(o&=7))&!0){o=7;break}if(!(7==(0|o)&!0)){o=10;break}if(t=0|Ve(0|t,0|r,0|(c=0|rt(1,0,0|i)),0|B()),r=0|B(),n[(c=A)>>2]=t,n[c+4>>2]=r,!((0|a)>(0|s))){o=10;break}a=a+-1|0}if(5==(0|o))return n[(c=A)>>2]=0,n[c+4>>2]=0,n[l>>2]=-1,void(n[e>>2]=-1);if(7==(0|o))return s=0|Ve(0|t,0|r,0|(s=0|rt(1,0,0|i)),0|B()),l=0|B(),n[(c=A)>>2]=s,n[c+4>>2]=l,void(n[e>>2]=a+-1)}}function ne(A){var e;return e=(A=+A)<0?A+6.283185307179586:A,+(A>=6.283185307179586?e+-6.283185307179586:e)}function oe(A,e){return e|=0,+l(+(+o[(A|=0)>>3]-+o[e>>3]))<17453292519943298e-27?0|(e=+l(+(+o[A+8>>3]-+o[e+8>>3]))<17453292519943298e-27):0|(e=0)}function ie(A,e){switch(A=+A,0|(e|=0)){case 1:A=A<0?A+6.283185307179586:A;break;case 2:A=A>0?A+-6.283185307179586:A}return+A}function ae(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475}function se(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20656+(A<<3)>>3],0|(e=0))}function le(A,e){e|=0;var t=0;return(A|=0)>>>0>15?0|(e=4):(t=0|qe(0|(t=0|pe(7,0,A,((0|A)<0)<<31>>31)),0|B(),120,0),A=0|B(),n[e>>2]=2|t,n[e+4>>2]=A,0|(e=0))}function ce(A,e,t){A|=0,t|=0;var r,n,i,a,s=0,l=0,u=0,h=0,m=0,v=0;return v=+o[(e|=0)>>3],i=+o[A>>3],m=+d(.5*(v-i)),u=+o[e+8>>3],n=+o[A+8>>3],h=+d(.5*(u-n)),r=+f(+i),a=+f(+v),h=2*+p(+ +c(+(h=m*m+h*(a*r*h))),+ +c(+(1-h))),m=+o[t>>3],v=+d(.5*(m-v)),s=+o[t+8>>3],u=+d(.5*(s-u)),l=+f(+m),u=2*+p(+ +c(+(u=v*v+u*(a*l*u))),+ +c(+(1-u))),m=+d(.5*(i-m)),s=+d(.5*(n-s)),s=2*+p(+ +c(+(s=m*m+s*(r*l*s))),+ +c(+(1-s))),4*+b(+ +c(+ +g(.5*(l=.5*(h+u+s)))*+g(.5*(l-h))*+g(.5*(l-u))*+g(.5*(l-s))))}function ue(A,e,t){t|=0;var r,i,a,s=0,l=0;if(a=F,F=F+192|0,i=a,0|(l=0|qA(A|=0,e|=0,r=a+168|0)))return F=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,F=a,0}function fe(A){A|=0;var e,t,r=0;return(e=0|We(1,12))||M(27280,27235,49,27293),0|(r=0|n[(t=A+4|0)>>2])?(n[(r=r+8|0)>>2]=e,n[t>>2]=e,0|e):(0|n[A>>2]&&M(27310,27235,61,27333),n[(r=A)>>2]=e,n[t>>2]=e,0|e)}function de(A,e){var t,r;return A|=0,e|=0,(r=0|Ue(24))||M(27347,27235,78,27361),n[r>>2]=n[e>>2],n[r+4>>2]=n[e+4>>2],n[r+8>>2]=n[e+8>>2],n[r+12>>2]=n[e+12>>2],n[r+16>>2]=0,0|(t=0|n[(e=A+4|0)>>2])?(n[t+16>>2]=r,n[e>>2]=r,0|r):(0|n[A>>2]&&M(27376,27235,82,27361),n[A>>2]=r,n[e>>2]=r,0|r)}function ge(A){var e=0,t=0,r=0,o=0;if(A|=0)for(r=1;;){if(0|(e=0|n[A>>2]))do{if(0|(t=0|n[e>>2]))do{o=t,t=0|n[t+16>>2],Ye(o)}while(0|t);o=e,e=0|n[e+8>>2],Ye(o)}while(0|e);if(e=A,A=0|n[A+8>>2],r||Ye(e),!A)break;r=0}}function he(A,e,t){A|=0;var r=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),r=+o[t>>3],i=e&(i=+o[t+8>>3])<0?i+6.283185307179586:i,!(A=0|n[A>>2]))return 0;if(e){e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(((c=(l=s<0?s+6.283185307179586:s)+(r-a)/(c-a)*((s=i<0?i+6.283185307179586:i)-l))<0?c+6.283185307179586:c)>(u=l==u|s==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}else{e=0,u=i,t=A;A:for(;;){for(;s=+o[t>>3],i=+o[t+8>>3],f=0|n[(t=t+16|0)>>2],a=+o[(f=0|f?f:A)>>3],l=+o[f+8>>3],s>a?(c=s,s=l):(c=a,a=s,s=i,i=l),(r=r==a|r==c?r+2220446049250313e-31:r)c;)if(!(t=0|n[t>>2])){t=22;break A}if(s+(r-a)/(c-a)*(i-s)>(u=s==u|i==u?u+-2220446049250313e-31:u)&&(e^=1),!(t=0|n[t>>2])){t=22;break}}if(22==(0|t))return 0|e}return 0}function me(A,e,t,o,i){t|=0,o|=0,i|=0;var a,s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(c=F,F=F+32|0,x=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 F=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 F=c,5;if(b=(0|h)!=(0|m)){if(7==(0|(d=0|V(h,m))))return F=c,1;7==(0|(g=0|V(m,h)))?M(27514,27538,161,27548):(p=d,f=g)}else p=0,f=0;a=0|z(h),s=0|z(m),n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0;do{if(p){if(d=(0|(m=0|n[4272+(28*h|0)+(p<<2)>>2]))>0,s)if(d){h=0,g=t,d=o;do{g=0|WA(g,d),d=0|B(),1==(0|(f=0|xA(f)))&&(f=0|xA(1)),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;else if(d){h=0,g=t,d=o;do{g=0|VA(g,d),d=0|B(),f=0|xA(f),h=h+1|0}while((0|h)!=(0|m));m=f,h=g,g=d}else m=f,h=t,g=o;if(JA(h,g,x),b||M(27563,27538,191,27548),(d=!!(0|a))&(f=!!(0|s))&&M(27590,27538,192,27548),d){if(7==(0|(f=0|OA(A,e)))){u=5;break}if(0|r[22e3+(7*f|0)+p|0]){u=1;break}h=g=0|n[21168+(28*f|0)+(p<<2)>>2]}else if(f){if(7==(0|(f=0|OA(h,g)))){u=5;break}if(0|r[22e3+(7*f|0)+m|0]){u=1;break}h=0,g=0|n[21168+(28*m|0)+(f<<2)>>2]}else h=0,g=0;if((h|g|0)<0)u=5;else{if((0|g)>0){d=x+4|0,f=0;do{pA(d),f=f+1|0}while((0|f)!=(0|g))}if(n[l>>2]=0,n[l+4>>2]=0,n[l+8>>2]=0,mA(l,p),0|u)for(;0|ZA(u)?gA(l):hA(l),(0|u)>1;)u=u+-1|0;if((0|h)>0){u=0;do{pA(l),u=u+1|0}while((0|u)!=(0|h))}iA(v=x+4|0,l,v),nA(v),v=51}}else if(JA(t,o,x),!!(0|a)&!!(0|s))if((0|m)!=(0|h)&&M(27621,27538,261,27548),7==(0|(f=0|OA(A,e)))|7==(0|(u=0|OA(t,o))))u=5;else if(0|r[22e3+(7*f|0)+u|0])u=1;else if((0|(f=0|n[21168+(28*f|0)+(u<<2)>>2]))>0){d=x+4|0,u=0;do{pA(d),u=u+1|0}while((0|u)!=(0|f));v=51}else v=51;else v=51}while(0);return 51==(0|v)&&(u=x+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),F=c,0|u}function be(A,e,t,r){t|=0,r|=0;var o,i,a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(a=F,F=F+48|0,o=a+36|0,c=a+24|0,u=a+12|0,f=a,s=0|tt(0|(A|=0),0|(e|=0),52),B(),s&=15,g=0|tt(0|A,0|e,45),B(),(g&=127)>>>0>121)return F=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)))?(F=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,F=a,0|(b=0));for(n[o>>2]=n[t>>2],n[o+4>>2]=n[t+4>>2],n[o+8>>2]=n[t+8>>2],t=s;;){if(l=t,t=t+-1|0,n[c>>2]=n[o>>2],n[c+4>>2]=n[o+4>>2],n[c+8>>2]=n[o+8>>2],0|ZA(l)){if(0|(s=0|cA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],gA(u)}else{if(0|(s=0|uA(o))){t=13;break}n[u>>2]=n[o>>2],n[u+4>>2]=n[o+4>>2],n[u+8>>2]=n[o+8>>2],hA(u)}if(aA(c,u,f),nA(f),v=0|n[(s=r)>>2],s=0|n[s+4>>2],p=0|rt(7,0,0|(x=3*(15-l|0)|0)),s&=~B(),x=0|rt(0|lA(f),0,0|x),s=0|B()|s,n[(b=r)>>2]=x|v&~p,n[b+4>>2]=s,(0|l)<=1){t=14;break}}A:do{if(13!=(0|t)&&14==(0|t))if((0|n[o>>2])<=1&&(0|n[o+4>>2])<=1&&(0|n[o+8>>2])<=1){f=127==(0|(s=0|W(g,t=0|lA(o))))?0:0|z(s);e:do{if(t){if(i){if(7==(0|(s=0|OA(A,e)))){s=5;break A}if((0|(l=0|n[21376+(28*s|0)+(t<<2)>>2]))>0){s=t,t=0;do{s=0|vA(s),t=t+1|0}while((0|t)!=(0|l))}else s=t;if(1==(0|s)){s=9;break A}127==(0|(t=0|W(g,s)))&&M(27648,27538,411,27678),0|z(t)?M(27693,27538,412,27678):(m=t,h=l,d=s)}else m=s,h=0,d=t;if((0|(u=0|n[4272+(28*g|0)+(d<<2)>>2]))<=-1&&M(27724,27538,419,27678),!f){if((0|h)<0){s=5;break A}if(0|h){s=0,t=0|n[(l=r)>>2],l=0|n[l+4>>2];do{t=0|YA(t,l),l=0|B(),n[(x=r)>>2]=t,n[x+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[(x=r)>>2]=t,n[x+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[(x=r)>>2]=t,n[x+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[(x=r)>>2]=l,n[x+4>>2]=c,s=s+1|0}while((0|s)<(0|t));s=m,t=58}else s=m,t=58}else if(!!(0|i)&!!(0|f)){if(7==(0|(t=0|OA(A,e)))|7==(0|(l=0|OA(0|n[(l=r)>>2],0|n[l+4>>2])))){s=5;break A}if((0|(l=0|n[21376+(28*t|0)+(l<<2)>>2]))<0){s=5;break A}if(l){t=0,c=0|n[(u=r)>>2],u=0|n[u+4>>2];do{c=0|YA(c,u),u=0|B(),n[(x=r)>>2]=c,n[x+4>>2]=u,t=t+1|0}while((0|t)<(0|l));t=58}else t=59}else t=58}while(0);if(58==(0|t)&&f&&(t=59),59==(0|t)&&1==(0|OA(0|n[(x=r)>>2],0|n[x+4>>2]))){s=9;break}p=0|n[(x=r)>>2],x=-1040385&n[x+4>>2],v=0|rt(0|s,0,45),x=0|x|B(),n[(s=r)>>2]=p|v,n[s+4>>2]=x,s=0}else s=1}while(0);return F=a,0|s}function pe(A,e,t,r){A|=0,e|=0;var n=0,o=0,i=0;if(!(0|(t|=0))&!(0|(r|=0)))return o=1,C(0|(n=0)),0|o;o=A,n=e,A=1,e=0;do{A=0|qe(0|((i=!0&!(1&t))?1:o),0|(i?0:n),0|A,0|e),e=0|B(),t=0|et(0|t,0|r,1),r=0|B(),o=0|qe(0|o,0|n,0|o,0|n),n=0|B()}while(!(!(0|t)&!(0|r)));return C(0|e),0|A}function ve(A,e,t,r){t|=0,r|=0;var i,a=0,s=0,l=0,c=0,u=0,d=0;i=F,F=F+16|0,s=i,l=0|tt(0|(A|=0),0|(e|=0),52),B(),l&=15;do{if(l){if(!(a=0|qA(A,e,s))){u=+o[s>>3],c=1/+f(+u),d=+o[25968+(l<<3)>>3],o[t>>3]=u+d,o[t+8>>3]=u-d,u=+o[s+8>>3],c*=d,o[t+16>>3]=c+u,o[t+24>>3]=u-c;break}return F=i,0|a}if(a=0|tt(0|A,0|e,45),B(),(a&=127)>>>0>121)return F=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]?(F=i,0|(l=0)):(o[t+16>>3]=3.141592653589793,o[t+24>>3]=-3.141592653589793,F=i,0|(l=0))}function xe(A){var e,t,o,i,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0;if(i=F,F=F+336|0,e=i+168|0,t=i,!(0|(s=0|n[(l=A|=0)>>2]))&!(0|(l=0|n[l+4>>2])))F=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(F=i);c=15&(a=0|n[(y=A+16|0)>>2]);A:do{if(!(0|s)&!(0|l))w=A+24|0;else{v=A+12|0,b=3==(0|c),m=255&a,g=3==(1|c),p=A+24|0,h=(c+-1|0)>>>0<3,f=3==(2|c),d=t+8|0;e:for(;;){if(u=0|tt(0|s,0|l,52),B(),(0|(u&=15))==(0|n[v>>2])){switch(15&m){case 0:case 2:case 3:if(0|(c=0|qA(s,l,e))){x=15;break e}if(0|Me(0|n[o>>2],0|n[p>>2],e)){x=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)){x=25;break}if((0|n[(c=t)>>2])==(0|s)&&(0|n[c+4>>2])==(0|l)){x=29;break}}if(h){if(0|(c=0|$A(s,l,e))){x=32;break}if(0|ve(s,l,t,0)){x=36;break}if(f&&0|De(0|n[o>>2],0|n[p>>2],e,t)){x=42;break}if(g&&0|Qe(0|n[o>>2],0|n[p>>2],e,t)){x=42;break}}if(b){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){x=45;break}if(0|q(c,e)){if(AA(t,e),0|$(e,0|n[p>>2])){x=53;break}if(0|Me(0|n[o>>2],0|n[p>>2],d)){x=53;break}if(0|Qe(0|n[o>>2],0|n[p>>2],t,e)){x=53;break}}}}do{if((0|u)<(0|n[v>>2])){if(a=0|ve(s,l,e,1),c=0|n[p>>2],0|a){x=58;break e}if(!(0|q(c,e))){x=73;break}if(0|$(0|n[p>>2],e)&&(AA(t,e),0|De(0|n[o>>2],0|n[p>>2],t,e))){x=65;break e}if(0|(s=0|GA(s,l,u+1|0,t))){x=67;break e}s=0|n[(l=t)>>2],l=0|n[l+4>>2]}else x=73}while(0);if(73==(0|x)&&(x=0,s=0|we(s,l),l=0|B()),!(0|s)&!(0|l)){w=p;break A}}switch(0|x){case 15:0|(a=0|n[p>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,x=20;break;case 19:n[A>>2]=s,n[A+4>>2]=l,x=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(F=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[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=c,void(F=i);case 36:M(27795,27761,493,27772);break;case 45:0|c&&Ye(c),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,x=55;break;case 53:n[A>>2]=s,n[A+4>>2]=l,x=55;break;case 58:0|c&&Ye(c),n[(x=A)>>2]=0,n[x+4>>2]=0,n[o>>2]=0,n[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=a,x=71;break;case 65:n[A>>2]=s,n[A+4>>2]=l,x=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[v>>2]=-1,n[y>>2]=0,n[p>>2]=0,n[A+8>>2]=s,void(F=i)}if(20==(0|x))return void(F=i);if(55==(0|x))return void(F=i);if(71==(0|x))return void(F=i)}}while(0);0|(a=0|n[w>>2])&&Ye(a),n[(x=A)>>2]=0,n[x+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,F=i}}function we(A,e){var t,r=0,o=0,i=0,a=0,s=0,l=0,c=0,u=0,f=0;t=F,F=F+16|0,f=t,o=0|tt(0|(A|=0),0|(e|=0),52),B(),o&=15,r=0|tt(0|A,0|e,45),B();do{if(o){for(;r=0|rt(o+4095|0,0,52),i=B()|-15728641&e,r=r|A|(s=0|rt(7,0,0|(a=3*(15-o|0)|0))),i|=l=0|B(),c=0|tt(0|A,0|e,0|a),B(),o=o+-1|0,!((c&=7)>>>0<6);){if(!o){u=4;break}e=i,A=r}if(4==(0|u)){r=0|tt(0|r,0|i,45),B();break}return f=0|rt(((f=!(0|c)&!!(0|HA(r,i)))?2:1)+c|0,0,0|a),u=0|B()|e&~l,f|=A&~s,C(0|u),F=t,0|f}}while(0);return(r&=127)>>>0>120?(f=0,C(0|(u=0)),F=t,0|f):(RA(f,0,r+1|0,0),u=0|n[f+4>>2],f=0|n[f>>2],C(0|u),F=t,0|f)}function ye(A,e,t){A|=0;var r,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0;if(!(0|X(e|=0,t|=0)))return 0;if(e=0|K(e),i=+o[t>>3],a=e&(a=+o[t+8>>3])<0?a+6.283185307179586:a,(0|(g=0|n[A>>2]))<=0)return 0;if(r=0|n[A+4>>2],e){e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(((u=(c=l<0?l+6.283185307179586:l)+(i-s)/(u-s)*((l=a<0?a+6.283185307179586:a)-c))<0?u+6.283185307179586:u)>(d=c==d|l==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}else{e=0,d=a,t=-1,A=0;A:for(;;){for(f=A;l=+o[r+(f<<4)>>3],a=+o[r+(f<<4)+8>>3],s=+o[r+((A=(t+2|0)%(0|g)|0)<<4)>>3],c=+o[r+(A<<4)+8>>3],l>s?(u=l,l=c):(u=s,s=l,l=a,a=c),(i=i==s|i==u?i+2220446049250313e-31:i)u;){if((0|(t=f+1|0))>=(0|g)){t=22;break A}A=f,f=t,t=A}if(l+(i-s)/(u-s)*(a-l)>(d=l==d|a==d?d+-2220446049250313e-31:d)&&(e^=1),(0|(A=f+1|0))>=(0|g)){t=22;break}t=f}if(22==(0|t))return 0|e}return 0}function ke(A,e){e|=0;var t,r,i,a,s,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=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,v=0,A=-1,d=17976931348623157e292,g=17976931348623157e292,m=-17976931348623157e292,u=-17976931348623157e292,x=0;c=+o[t+(x<<4)>>3],h=+o[t+(x<<4)+8>>3],f=+o[t+(((0|(A=A+2|0))==(0|r)?0:A)<<4)+8>>3],c>3]=c,d=c),h>3]=h,g=h),c>m?o[e>>3]=c:c=m,h>u&&(o[s>>3]=h,u=h),b=h>0&hp?h:p,v|=+l(+(h-f))>3.141592653589793,(0|(A=x+1|0))!=(0|r);)w=x,m=c,x=A,A=w;v&&(o[s>>3]=p,o[a>>3]=b)}}function Ce(A){return 0|((A|=0)>>>0<4?0:15)}function Be(A,e){e|=0;var t,r=0,i=0,a=0,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,M=0;if(p=0|n[(A|=0)>>2]){if(o[(v=e+8|0)>>3]=17976931348623157e292,o[(x=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,f=17976931348623157e292,d=17976931348623157e292,h=-17976931348623157e292,c=-17976931348623157e292,y=0;s=+o[a+(y<<4)>>3],g=+o[a+(y<<4)+8>>3],u=+o[a+(((0|(B=r+2|0))==(0|p)?0:B)<<4)+8>>3],s>3]=s,f=s),g>3]=g,d=g),s>h?o[e>>3]=s:s=h,g>c&&(o[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[x>>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,x=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[x>>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,v=0,f=17976931348623157e292,d=17976931348623157e292,g=-17976931348623157e292,c=-17976931348623157e292;s=+o[p+(v<<4)>>3],h=+o[p+(v<<4)+8>>3],u=+o[p+(((0|(i=i+2|0))==(0|w)?0:i)<<4)+8>>3],s>3]=s,f=s),h>3]=h,d=h),s>g?o[x>>3]=s:s=g,h>c&&(o[k>>3]=h,c=h),m=h>0&hb?h:b,a|=+l(+(h-u))>3.141592653589793,(0|(i=v+1|0))!=(0|w);)M=v,v=i,g=s,i=M;a&&(o[k>>3]=b,o[A>>3]=m)}}else n[x>>2]=0,n[x+4>>2]=0,n[x+8>>2]=0,n[x+12>>2]=0,n[x+16>>2]=0,n[x+20>>2]=0,n[x+24>>2]=0,n[x+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=F,F=F+16|0,o=i,!(0|ye(A|=0,e|=0,l=8+(t|=0)|0)))return F=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 F=i,0|a}}while(0);if(0|Ee(A,e,t,r))return F=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 F=i,0|a}function Ee(A,e,t,r){A|=0,t|=0;var i,a,s,l,c,u,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,M=0;if(u=F,F=F+176|0,l=u+172|0,f=u+168|0,c=u,!(0|q(e|=0,r|=0)))return F=u,0;if(function(A,e,t,r){var i,a,s,l,c;e|=0,t|=0,r|=0,A=(a=+o[16+(A|=0)>>3])<(c=+o[A+24>>3]),i=(l=+o[e+16>>3])<(s=+o[e+24>>3]),e=c-l>2]=A?i|e?1:2:0,n[r>>2]=i?A?1:e?2:1:0}(e,r,l,f),st(0|c,0|t,168),(0|n[t>>2])>0){e=0;do{y=+ie(+o[(B=c+8+(e<<4)+8|0)>>3],0|n[f>>2]),o[B>>3]=y,e=e+1|0}while((0|e)<(0|n[t>>2]))}a=+o[r>>3],s=+o[r+8>>3],y=+ie(+o[r+16>>3],0|n[f>>2]),i=+ie(+o[r+24>>3],0|n[f>>2]);A:do{if((0|n[A>>2])>0){if(r=A+4|0,(0|(f=0|n[c>>2]))<=0)for(e=0;;)if((0|(e=e+1|0))>=(0|n[A>>2])){e=0;break A}for(t=0;;){if(e=0|n[r>>2],x=+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,d=+o[e+(B<<4)>>3],g=+ie(+o[e+(B<<4)+8>>3],0|n[l>>2]),!(x>=a)|!(d>=a)&&!(x<=s)|!(d<=s)&&!(w<=i)|!(g<=i)&&!(w>=y)|!(g>=y)){v=d-x,b=g-w,e=0;do{if(M=e,B=(0|(e=e+1|0))==(0|f)?0:e,d=+o[c+8+(M<<4)+8>>3],g=+o[c+8+(B<<4)+8>>3]-d,h=+o[c+8+(M<<4)>>3],!(0==(p=v*g-b*(m=+o[c+8+(B<<4)>>3]-h))||(k=w-d,C=x-h,m=(k*m-g*C)/p,m<0|m>1))&&(p=(v*k-b*C)/p)>=0&p<=1){e=1;break A}}while((0|e)<(0|f))}if((0|t)>=(0|n[A>>2])){e=0;break}}}else e=0}while(0);return F=u,0|e}function Qe(A,e,t,r){var o=0,i=0,a=0;if(0|Ee(A|=0,e|=0,t|=0,r|=0))return 1;if((0|n[(i=A+8|0)>>2])<=0)return 0;for(o=A+12|0,A=0;;){if(a=A,A=A+1|0,0|Ee((0|n[o>>2])+(a<<3)|0,e+(A<<5)|0,t,r)){A=1,o=6;break}if((0|A)>=(0|n[i>>2])){A=0,o=6;break}}return 6==(0|o)?0|A:0}function Ne(A,e,t,r,n){e|=0,t|=0,r|=0,n|=0;var i,a,s,l,c,u,f,d=0;l=+o[(A|=0)>>3],s=+o[e>>3]-l,a=+o[A+8>>3],i=+o[e+8>>3]-a,u=+o[t>>3],d=((d=+o[r>>3]-u)*(a-(f=+o[t+8>>3]))-(l-u)*(c=+o[r+8>>3]-f))/(s*c-i*d),o[n>>3]=l+s*d,o[n+8>>3]=a+i*d}function 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 Fe(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 Se(A,e,t){t|=0;var r,o,i,a,s=0,l=0,c=0,u=0;if(a=F,F=F+32|0,u=a,0|(s=0|XA(A|=0,e|=0,o=a+16|0)))return F=a,0|s;r=0|IA(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,F=a,0}function Pe(A,e,t,r){t|=0,r|=0;var o,i,a,s,l,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0;if(l=F,F=F+32|0,x=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 F=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 F=l,1;if(0|Se(A,e,x))return F=l,1;if(u=(0|n[x>>2])+t|0,7==(0|(p=0|n[(c=c?26704+((0|u)%5<<2)|0:26736+((0|u)%6<<2)|0)>>2])))return F=l,1;n[s>>2]=0,c=0|R(A,e,p,s,a);do{if(!c){if(h=0|n[(d=a)>>2],u=(f=(d=0|n[d+4>>2])>>>0>>0|(0|d)==(0|e)&h>>>0>>0)?h:A,f=f?d:e,!b&&!(h&(b=0|rt(7,0,3*(15^m)|0)))&!(d&(0|B())))c=t;else{if(d=(t+-1+g|0)%(0|g)|0,c=0|HA(A,e),(0|d)<0&&M(27795,27797,248,27822),(0|((g=!!(0|c))?4:5))<(0|d)&&M(27795,27797,248,27822),0|Se(A,e,x)&&M(27795,27797,248,27822),c=(0|n[x>>2])+d|0,7==(0|(d=0|n[(c=g?26704+((0|c)%5<<2)|0:26736+((0|c)%6<<2)|0)>>2]))&&M(27795,27797,248,27822),n[i>>2]=0,0|(c=0|R(A,e,d,i,o)))break;g=0|n[(h=o)>>2],h=0|n[h+4>>2];do{if(h>>>0>>0|(0|h)==(0|f)&g>>>0>>0){if(u=0|HA(g,h)?0|_(g,h,A,e):0|n[26800+(((0|n[i>>2])+(0|n[26768+(d<<2)>>2])|0)%6<<2)>>2],c=0|HA(g,h),(u+-1|0)>>>0>5){c=-1,u=g,f=h;break}if(1==(0|u)&(c=!!(0|c))){c=-1,u=g,f=h;break}do{if(!(0|Se(g,h,x))){if(c){c=(5+(0|n[26352+(u<<2)>>2])-(0|n[x>>2])|0)%5|0;break}c=(6+(0|n[26384+(u<<2)>>2])-(0|n[x>>2])|0)%6|0;break}c=-1}while(0);u=g,f=h}else c=t}while(0);h=0|n[(d=a)>>2],d=0|n[d+4>>2]}if((0|u)==(0|h)&(0|f)==(0|d)){if(A=(g=!!(0|HA(h,d)))?0|_(h,d,A,e):0|n[26800+(((0|n[s>>2])+(0|n[26768+(p<<2)>>2])|0)%6<<2)>>2],c=0|HA(h,d),(A+-1|0)>>>0<=5&&!(1==(0|A)&(v=!!(0|c))))do{if(!(0|Se(h,d,x))){if(v){c=(5+(0|n[26352+(A<<2)>>2])-(0|n[x>>2])|0)%5|0;break}c=(6+(0|n[26384+(A<<2)>>2])-(0|n[x>>2])|0)%6|0;break}c=-1}while(0);else c=-1;c=6==(0|(c=c+1|0))|g&5==(0|c)?0:c}e=f,A=u;break A}}while(0);return F=l,0|c}}while(0);return v=0|rt(0|c,0,56),x=B()|-2130706433&e|536870912,n[r>>2]=v|A,n[r+4>>2]=x,F=l,0}function Ie(A,e){A|=0;var t,r,o=0,i=0;return r=F,F=F+16|0,t=r,!0&536870912==(2013265920&(e|=0))&&0|LA(A,o=-2130706433&e|134217728)?(i=0|tt(0|A,0|e,56),B(),o=(i=!(0|Pe(A,o,7&i,t)))&((0|n[(o=t)>>2])==(0|A)?(0|n[o+4>>2])==(0|e):0)&1,F=r,0|o):(F=r,0|(o=0))}function Le(A,e,t){A|=0,t|=0;var r=0;(0|(e|=0))>0?(r=0|We(e,4),n[A>>2]=r,r||M(27835,27858,40,27872)):n[A>>2]=0,n[A+4>>2]=e,n[A+8>>2]=0,n[A+12>>2]=t}function 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,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0;e=F,F=F+16|0,g=e;do{if(A>>>0<245){if(A=(u=A>>>0<11?16:A+11&-8)>>>3,3&(r=(d=0|n[6981])>>>A))return o=0|n[(r=8+(A=27964+((t=(1&r^1)+A|0)<<1<<2)|0)|0)>>2],(0|(a=0|n[(i=o+8|0)>>2]))==(0|A)?n[6981]=d&~(1<>2]=A,n[r>>2]=a),y=t<<3,n[o+4>>2]=3|y,n[(y=o+y+4|0)>>2]=1|n[y>>2],F=e,0|i;if(u>>>0>(f=0|n[6983])>>>0){if(0|r)return t=((t=r<>>=l=t>>>12&16)>>>5&8)|l|(a=(t>>>=r)>>>2&4)|(A=(t>>>=a)>>>1&2)|(o=(t>>>=A)>>>1&1))+(t>>>o)|0)<<1<<2)|0)|0)>>2],(0|(r=0|n[(l=a+8|0)>>2]))==(0|t)?(A=d&~(1<>2]=t,n[A>>2]=r,A=d),s=(y=o<<3)-u|0,n[a+4>>2]=3|u,n[4+(i=a+u|0)>>2]=1|s,n[a+y>>2]=s,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,A&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=s,n[6986]=i,F=e,0|l;if(a=0|n[6982]){for(r=(a&0-a)-1|0,r=c=0|n[28228+(((o=(r>>>=i=r>>>12&16)>>>5&8)|i|(s=(r>>>=o)>>>2&4)|(l=(r>>>=s)>>>1&2)|(c=(r>>>=l)>>>1&1))+(r>>>c)<<2)>>2],l=c,c=(-8&n[c+4>>2])-u|0;(A=0|n[r+16>>2])||(A=0|n[r+20>>2]);)r=A,l=(i=(s=(-8&n[A+4>>2])-u|0)>>>0>>0)?A:l,c=i?s:c;if((s=l+u|0)>>>0>l>>>0){i=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){r=0;break}for(;;)if(r=0|n[(o=t+20|0)>>2])t=r,A=o;else{if(!(r=0|n[(o=t+16|0)>>2]))break;t=r,A=o}n[A>>2]=0,r=t}else r=0|n[l+8>>2],n[r+12>>2]=t,n[t+8>>2]=r,r=t}while(0);do{if(0|i){if(t=0|n[l+28>>2],(0|l)==(0|n[(A=28228+(t<<2)|0)>>2])){if(n[A>>2]=r,!r){n[6982]=a&~(1<>2])==(0|l)?y:i+20)>>2]=r,!r)break;n[r+24>>2]=i,0|(t=0|n[l+16>>2])&&(n[r+16>>2]=t,n[t+24>>2]=r),0|(t=0|n[l+20>>2])&&(n[r+20>>2]=t,n[t+24>>2]=r)}}while(0);return c>>>0<16?(y=c+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2]):(n[l+4>>2]=3|u,n[s+4>>2]=1|c,n[s+c>>2]=c,0|f&&(o=0|n[6986],r=27964+((t=f>>>3)<<1<<2)|0,(t=1<>2]:(n[6981]=t|d,t=r,A=r+8|0),n[A>>2]=o,n[t+12>>2]=o,n[o+8>>2]=t,n[o+12>>2]=r),n[6983]=c,n[6986]=s),F=e,0|l+8}d=u}else d=u}else d=u}else if(A>>>0<=4294967231)if(u=-8&(A=A+11|0),o=0|n[6982]){i=0-u|0,c=(A>>>=8)?u>>>0>16777215?31:u>>>(7+(c=14-((l=(520192+(b=A<<(d=(A+1048320|0)>>>16&8))|0)>>>16&4)|d|(c=(245760+(b<<=l)|0)>>>16&2))+(b<>>15)|0)|0)&1|c<<1:0,r=0|n[28228+(c<<2)>>2];A:do{if(r)for(A=0,l=u<<(31==(0|c)?0:25-(c>>>1)|0),a=0;;){if((s=(-8&n[r+4>>2])-u|0)>>>0>>0){if(!s){A=r,i=0,b=65;break A}A=r,i=s}if(a=!(0|(b=0|n[r+20>>2]))|(0|b)==(0|(r=0|n[r+16+(l>>>31<<2)>>2]))?a:b,!r){r=a,b=61;break}l<<=1}else r=0,A=0,b=61}while(0);if(61==(0|b)){if(!(0|r)&!(0|A)){if(!(A=((A=2<>>=s=d>>>12&16)>>>5&8)|s|(l=(d>>>=a)>>>2&4)|(c=(d>>>=l)>>>1&2)|(r=(d>>>=c)>>>1&1))+(d>>>r)<<2)>>2]}r?b=65:(l=A,s=i)}if(65==(0|b))for(a=r;;){if(i=(r=(d=(-8&n[a+4>>2])-u|0)>>>0>>0)?d:i,A=r?a:A,(r=0|n[a+16>>2])||(r=0|n[a+20>>2]),!r){l=A,s=i;break}a=r}if(0|l&&s>>>0<((0|n[6983])-u|0)>>>0&&(f=l+u|0)>>>0>l>>>0){a=0|n[l+24>>2],t=0|n[l+12>>2];do{if((0|t)==(0|l)){if(!(t=0|n[(A=l+20|0)>>2])&&!(t=0|n[(A=l+16|0)>>2])){t=0;break}for(;;)if(r=0|n[(i=t+20|0)>>2])t=r,A=i;else{if(!(r=0|n[(i=t+16|0)>>2]))break;t=r,A=i}n[A>>2]=0}else y=0|n[l+8>>2],n[y+12>>2]=t,n[t+8>>2]=y}while(0);do{if(a){if(A=0|n[l+28>>2],(0|l)==(0|n[(r=28228+(A<<2)|0)>>2])){if(n[r>>2]=t,!t){o&=~(1<>2])==(0|l)?y:a+20)>>2]=t,!t)break;n[t+24>>2]=a,0|(A=0|n[l+16>>2])&&(n[t+16>>2]=A,n[A+24>>2]=t),(A=0|n[l+20>>2])&&(n[t+20>>2]=A,n[A+24>>2]=t)}}while(0);A:do{if(s>>>0<16)y=s+u|0,n[l+4>>2]=3|y,n[(y=l+y+4|0)>>2]=1|n[y>>2];else{if(n[l+4>>2]=3|u,n[f+4>>2]=1|s,n[f+s>>2]=s,t=s>>>3,s>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=f,n[t+12>>2]=f,n[f+8>>2]=t,n[f+12>>2]=r;break}if(t=28228+((r=(t=s>>>8)?s>>>0>16777215?31:s>>>(7+(r=14-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(r=(245760+(y<<=x)|0)>>>16&2))+(y<>>15)|0)|0)&1|r<<1:0)<<2)|0,n[f+28>>2]=r,n[4+(A=f+16|0)>>2]=0,n[A>>2]=0,!(o&(A=1<>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break}t=0|n[t>>2];e:do{if((-8&n[t+4>>2])!=(0|s)){for(o=s<<(31==(0|r)?0:25-(r>>>1)|0);A=0|n[(r=t+16+(o>>>31<<2)|0)>>2];){if((-8&n[A+4>>2])==(0|s)){t=A;break e}o<<=1,t=A}n[r>>2]=f,n[f+24>>2]=t,n[f+12>>2]=f,n[f+8>>2]=f;break A}}while(0);y=0|n[(w=t+8|0)>>2],n[y+12>>2]=f,n[w>>2]=f,n[f+8>>2]=y,n[f+12>>2]=t,n[f+24>>2]=0}}while(0);return F=e,0|l+8}d=u}else d=u;else d=-1}while(0);if((r=0|n[6983])>>>0>=d>>>0)return t=r-d|0,A=0|n[6986],t>>>0>15?(y=A+d|0,n[6986]=y,n[6983]=t,n[y+4>>2]=1|t,n[A+r>>2]=t,n[A+4>>2]=3|d):(n[6983]=0,n[6986]=0,n[A+4>>2]=3|r,n[(y=A+r+4|0)>>2]=1|n[y>>2]),F=e,0|A+8;if((s=0|n[6984])>>>0>d>>>0)return x=s-d|0,n[6984]=x,w=(y=0|n[6987])+d|0,n[6987]=w,n[w+4>>2]=1|x,n[y+4>>2]=3|d,F=e,0|y+8;if(0|n[7099]?A=0|n[7101]:(n[7101]=4096,n[7100]=4096,n[7102]=-1,n[7103]=-1,n[7104]=0,n[7092]=0,n[7099]=-16&g^1431655768,A=4096),l=d+48|0,(u=(a=A+(c=d+47|0)|0)&(i=0-A|0))>>>0<=d>>>0)return F=e,0;if(0|(A=0|n[7091])&&(g=(f=0|n[7089])+u|0)>>>0<=f>>>0|g>>>0>A>>>0)return F=e,0;A:do{if(4&n[7092])t=0,b=143;else{r=0|n[6987];e:do{if(r){for(o=28372;!((g=0|n[o>>2])>>>0<=r>>>0&&(g+(0|n[o+4>>2])|0)>>>0>r>>>0);){if(!(A=0|n[o+8>>2])){b=128;break e}o=A}if((t=a-s&i)>>>0<2147483647)if((0|(A=0|ut(0|t)))==((0|n[o>>2])+(0|n[o+4>>2])|0)){if(-1!=(0|A)){s=t,a=A,b=145;break A}}else o=A,b=136;else t=0}else b=128}while(0);do{if(128==(0|b))if(-1!=(0|(r=0|ut(0)))&&(t=r,m=(t=((m=(h=0|n[7100])-1|0)&t?(m+t&0-h)-t|0:0)+u|0)+(h=0|n[7089])|0,t>>>0>d>>>0&t>>>0<2147483647)){if(0|(g=0|n[7091])&&m>>>0<=h>>>0|m>>>0>g>>>0){t=0;break}if((0|(A=0|ut(0|t)))==(0|r)){s=t,a=r,b=145;break A}o=A,b=136}else t=0}while(0);do{if(136==(0|b)){if(r=0-t|0,!(l>>>0>t>>>0&t>>>0<2147483647&-1!=(0|o))){if(-1==(0|o)){t=0;break}s=t,a=o,b=145;break A}if((A=c-t+(A=0|n[7101])&0-A)>>>0>=2147483647){s=t,a=o,b=145;break A}if(-1==(0|ut(0|A))){ut(0|r),t=0;break}s=A+t|0,a=o,b=145;break A}}while(0);n[7092]=4|n[7092],b=143}}while(0);if(143==(0|b)&&u>>>0<2147483647&&!(-1==(0|(x=0|ut(0|u)))|1^(v=(p=(m=0|ut(0))-x|0)>>>0>(d+40|0)>>>0)|x>>>0>>0&-1!=(0|x)&-1!=(0|m)^1)&&(s=v?p:t,a=x,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+(x=7&(x=c+8|0)?0-x&7:0)|0,x=(y=(0|n[6984])+s|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,n[c+y+4>>2]=40,n[6988]=n[7103];break}for(a>>>0<(0|n[6985])>>>0&&(n[6985]=a),r=a+s|0,t=28372;;){if((0|n[t>>2])==(0|r)){b=162;break}if(!(A=0|n[t+8>>2]))break;t=A}if(162==(0|b)&&!(8&n[t+12>>2])){n[t>>2]=a,n[(f=t+4|0)>>2]=(0|n[f>>2])+s,u=(f=a+(7&(f=a+8|0)?0-f&7:0)|0)+d|0,l=(t=r+(7&(t=r+8|0)?0-t&7:0)|0)-f-d|0,n[f+4>>2]=3|d;e:do{if((0|c)==(0|t))y=(0|n[6984])+l|0,n[6984]=y,n[6987]=u,n[u+4>>2]=1|y;else{if((0|n[6986])==(0|t)){y=(0|n[6983])+l|0,n[6983]=y,n[6986]=u,n[u+4>>2]=1|y,n[u+y>>2]=y;break}if(1==(3&(A=0|n[t+4>>2]))){s=-8&A,o=A>>>3;t:do{if(A>>>0<256){if(A=0|n[t+8>>2],(0|(r=0|n[t+12>>2]))==(0|A)){n[6981]=n[6981]&~(1<>2]=r,n[r+8>>2]=A;break}a=0|n[t+24>>2],A=0|n[t+12>>2];do{if((0|A)==(0|t)){if(A=0|n[(o=4+(r=t+16|0)|0)>>2])r=o;else if(!(A=0|n[r>>2])){A=0;break}for(;;)if(o=0|n[(i=A+20|0)>>2])A=o,r=i;else{if(!(o=0|n[(i=A+16|0)>>2]))break;A=o,r=i}n[r>>2]=0}else y=0|n[t+8>>2],n[y+12>>2]=A,n[A+8>>2]=y}while(0);if(!a)break;o=28228+((r=0|n[t+28>>2])<<2)|0;do{if((0|n[o>>2])==(0|t)){if(n[o>>2]=A,0|A)break;n[6982]=n[6982]&~(1<>2])==(0|t)?y:a+20)>>2]=A,!A)break t}while(0);if(n[A+24>>2]=a,0|(o=0|n[(r=t+16|0)>>2])&&(n[A+16>>2]=o,n[o+24>>2]=A),!(r=0|n[r+4>>2]))break;n[A+20>>2]=r,n[r+24>>2]=A}while(0);t=t+s|0,i=s+l|0}else i=l;if(n[(t=t+4|0)>>2]=-2&n[t>>2],n[u+4>>2]=1|i,n[u+i>>2]=i,t=i>>>3,i>>>0<256){r=27964+(t<<1<<2)|0,(A=0|n[6981])&(t=1<>2]:(n[6981]=A|t,t=r,A=r+8|0),n[A>>2]=u,n[t+12>>2]=u,n[u+8>>2]=t,n[u+12>>2]=r;break}t=i>>>8;do{if(t){if(i>>>0>16777215){o=31;break}o=i>>>(7+(o=14-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=x)|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 F=e,0|f+8}for(t=28372;!((A=0|n[t>>2])>>>0<=c>>>0&&(y=A+(0|n[t+4>>2])|0)>>>0>c>>>0);)t=0|n[t+8>>2];t=(A=(A=(i=y+-47|0)+(7&(A=i+8|0)?0-A&7:0)|0)>>>0<(i=c+16|0)>>>0?c:A)+8|0,w=a+(x=7&(x=a+8|0)?0-x&7:0)|0,x=(r=s+-40|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,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-((x=(520192+(y=t<<(w=(t+1048320|0)>>>16&8))|0)>>>16&4)|w|(o=(245760+(y<<=x)|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+(x=7&(x=a+8|0)?0-x&7:0)|0,x=(y=s+-40|0)-x|0,n[6987]=w,n[6984]=x,n[w+4>>2]=1|x,n[a+y+4>>2]=40,n[6988]=n[7103]}while(0);if((t=0|n[6984])>>>0>d>>>0)return x=t-d|0,n[6984]=x,w=(y=0|n[6987])+d|0,n[6987]=w,n[w+4>>2]=1|x,n[y+4>>2]=3|d,F=e,0|y+8}return n[(y=27920)>>2]=12,F=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|x(e,A),(e|A)>>>0>65535&&(t=((t>>>0)/(A>>>0)|0)==(0|e)?t:-1)):t=0,(A=0|Ue(t))&&3&n[A+-4>>2]?(lt(0|A,0,0|t),0|A):0|A}function Ve(A,e,t,r){return 0|(C((e|=0)+(r|=0)+((t=(A|=0)+(t|=0)>>>0)>>>0>>0|0)>>>0|0),t)}function Ze(A,e,t,r){return 0|(C(0|(r=(e|=0)-(r|=0)-((t|=0)>>>0>(A|=0)>>>0|0)>>>0)),A-t>>>0)}function Ke(A){return 0|((A|=0)?31-(0|k(A^A-1)):32)}function Je(A,e,t,r,o){o|=0;var i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0;if(u=A|=0,a=t|=0,s=d=r|=0,!(c=l=e|=0))return i=!!(0|o),s?i?(n[o>>2]=0|A,n[o+4>>2]=0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o)):(i&&(n[o>>2]=(u>>>0)%(a>>>0),n[o+4>>2]=0),o=(u>>>0)/(a>>>0)>>>0,0|(C(0|(d=0)),o));i=!(0|s);do{if(a){if(!i){if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=31){a=f=i+1|0,A=u>>>(f>>>0)&(e=i-31>>31)|c<<(s=31-i|0),e&=c>>>(f>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,o=0,0|(C(0|(d=0)),o)):(o=0,0|(C(0|(d=0)),o))}if((i=a-1|0)&a){a=s=33+(0|k(0|a))-(0|k(0|c))|0,A=(f=32-s|0)-1>>31&c>>>((g=s-32|0)>>>0)|(c<>>(s>>>0))&(e=g>>31),e&=c>>>(s>>>0),i=u<<(h=64-s|0)&(l=f>>31),s=(c<>>(g>>>0))&l|u<>31;break}return 0|o&&(n[o>>2]=i&u,n[o+4>>2]=0),1==(0|a)?(h=0|A,0|(C(0|(g=l|0&e)),h)):(g=c>>>((h=0|Ke(0|a))>>>0)|0,h=c<<32-h|u>>>(h>>>0),0|(C(0|g),h))}if(i)return 0|o&&(n[o>>2]=(c>>>0)%(a>>>0),n[o+4>>2]=0),h=(c>>>0)/(a>>>0)>>>0,0|(C(0|(g=0)),h);if(!u)return 0|o&&(n[o>>2]=0,n[o+4>>2]=(c>>>0)%(s>>>0)),h=(c>>>0)/(s>>>0)>>>0,0|(C(0|(g=0)),h);if(!((i=s-1|0)&s))return 0|o&&(n[o>>2]=0|A,n[o+4>>2]=i&c|0&e),g=0,h=c>>>((0|Ke(0|s))>>>0),0|(C(0|g),h);if((i=(0|k(0|s))-(0|k(0|c))|0)>>>0<=30){a=e=i+1|0,A=c<<(s=31-i|0)|u>>>(e>>>0),e=c>>>(e>>>0),i=0,s=u<>2]=0|A,n[o+4>>2]=l|0&e,h=0,0|(C(0|(g=0)),h)):(h=0,0|(C(0|(g=0)),h))}while(0);if(a){c=0|Ve(0|(f=0|t),0|(u=d|0&r),-1,-1),t=0|B(),l=s,s=0;do{r=l,l=i>>>31|l<<1,i=s|i<<1,Ze(0|c,0|t,0|(r=A<<1|r>>>31),0|(d=A>>>31|e<<1)),s=1&(g=(h=0|B())>>31|((0|h)<0?-1:0)<<1),A=0|Ze(0|r,0|d,g&f|0,(((0|h)<0?-1:0)>>31|((0|h)<0?-1:0)<<1)&u),e=0|B(),a=a-1|0}while(0|a);c=l,l=0}else c=s,l=0,s=0;return a=0,0|o&&(n[o>>2]=A,n[o+4>>2]=e),h=i<<1&-2|s,0|(C(0|(g=(0|i)>>>31|(c|a)<<1|l)),h)}function Xe(A,e,t,r){var n,o,i,a,s;return t|=0,o=(r|=0)>>31|((0|r)<0?-1:0)<<1,n=((0|r)<0?-1:0)>>31|((0|r)<0?-1:0)<<1,i=0|Ze((s=(e|=0)>>31|((0|e)<0?-1:0)<<1)^(A|=0),(a=((0|e)<0?-1:0)>>31|((0|e)<0?-1:0)<<1)^e,0|s,0|a),A=o^s,e=n^a,0|Ze((0|Je(i,0|B(),0|Ze(o^t|0,n^r|0,0|o,0|n),0|B(),0))^A,(0|B())^e,0|A,0|e)}function qe(A,e,t,r){var n,o;return e|=0,r|=0,t=0|function(A,e){var t,r,n,o=0;return A=((t=0|x(o=65535&(e|=0),n=65535&(A|=0)))>>>16)+(0|x(o,r=A>>>16))|0,e=0|x(o=e>>>16,n),0|(C((A>>>16)+(0|x(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|x(e,o))+(0|x(r,n))+A|0&A),t)}function $e(A,e,t,r){var o,i,a,s,l,c;return t|=0,o=F,F=F+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(),F=o,0|(C(0|t),r)}function At(A,e,t,r){var o,i;return i=F,F=F+16|0,Je(A|=0,e|=0,t|=0,r|=0,o=0|i),F=i,0|(C(0|n[o+4>>2]),n[o>>2])}function et(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>t|0),A>>>t|(e&(1<>t-32)}function tt(A,e,t){return A|=0,e|=0,(0|(t|=0))<32?(C(e>>>t|0),A>>>t|(e&(1<>>t-32|0)}function rt(A,e,t){return A|=0,(0|(t|=0))<32?(C((e|=0)<>>32-t),A<=0?+s(A+.5):+v(A-.5)}function st(A,e,t){A|=0,e|=0;var o,i,a=0;if((0|(t|=0))>=8192)return Q(0|A,0|e,0|t),0|A;if(i=0|A,o=A+t|0,(3&A)==(3&e)){for(;3&A;){if(!t)return 0|i;r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0,t=t-1|0}for(a=(t=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=n[e>>2],n[A+4>>2]=n[e+4>>2],n[A+8>>2]=n[e+8>>2],n[A+12>>2]=n[e+12>>2],n[A+16>>2]=n[e+16>>2],n[A+20>>2]=n[e+20>>2],n[A+24>>2]=n[e+24>>2],n[A+28>>2]=n[e+28>>2],n[A+32>>2]=n[e+32>>2],n[A+36>>2]=n[e+36>>2],n[A+40>>2]=n[e+40>>2],n[A+44>>2]=n[e+44>>2],n[A+48>>2]=n[e+48>>2],n[A+52>>2]=n[e+52>>2],n[A+56>>2]=n[e+56>>2],n[A+60>>2]=n[e+60>>2],A=A+64|0,e=e+64|0;for(;(0|A)<(0|t);)n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}else for(t=o-4|0;(0|A)<(0|t);)r[0|A]=0|r[0|e],r[A+1|0]=0|r[e+1|0],r[A+2|0]=0|r[e+2|0],r[A+3|0]=0|r[e+3|0],A=A+4|0,e=e+4|0;for(;(0|A)<(0|o);)r[0|A]=0|r[0|e],A=A+1|0,e=e+1|0;return 0|i}function lt(A,e,t){e|=0;var o,i=0,a=0,s=0;if(o=(A|=0)+(t|=0)|0,e&=255,(0|t)>=67){for(;3&A;)r[0|A]=e,A=A+1|0;for(s=e|e<<8|e<<16|e<<24,a=(i=-4&o)-64|0;(0|A)<=(0|a);)n[A>>2]=s,n[A+4>>2]=s,n[A+8>>2]=s,n[A+12>>2]=s,n[A+16>>2]=s,n[A+20>>2]=s,n[A+24>>2]=s,n[A+28>>2]=s,n[A+32>>2]=s,n[A+36>>2]=s,n[A+40>>2]=s,n[A+44>>2]=s,n[A+48>>2]=s,n[A+52>>2]=s,n[A+56>>2]=s,n[A+60>>2]=s,A=A+64|0;for(;(0|A)<(0|i);)n[A>>2]=s,A=A+4|0}for(;(0|A)<(0|o);)r[0|A]=e,A=A+1|0;return o-t|0}function ct(A){return(A=+A)>=0?+s(A+.5):+v(A-.5)}function ut(A){var e,t,r;return A|=0,r=0|E(),(0|A)>0&(0|(e=(t=0|n[a>>2])+A|0))<(0|t)|(0|e)<0?(j(0|e),D(12),-1):(0|e)>(0|r)&&!(0|N(0|e))?(D(12),-1):(n[a>>2]=e,0|t)}return{___divdi3:Xe,___muldi3:qe,___remdi3:$e,___uremdi3:At,_areNeighborCells:function(A,e,t,r,o){o|=0;var i,a,s,l=0,c=0,u=0,f=0;if(s=F,F=F+64|0,a=s,i=s+56|0,!(!0&134217728==(2013265920&(e|=0))&!0&134217728==(2013265920&(r|=0))))return F=s,5;if((0|(A|=0))==(0|(t|=0))&(0|e)==(0|r))return n[o>>2]=0,F=s,0;if(c=0|tt(0|A,0|e,52),B(),c&=15,f=0|tt(0|t,0|r,52),B(),(0|c)!=(15&f))return F=s,12;if(l=c+-1|0,c>>>0>1){TA(A,e,l,a),TA(t,r,l,i),u=0|n[(f=a)>>2],f=0|n[f+4>>2];A:do{if((0|u)==(0|n[i>>2])&&(0|f)==(0|n[i+4>>2])){l=0|tt(0|A,0|e,0|(c=3*(15^c)|0)),B(),l&=7,c=0|tt(0|t,0|r,0|c),B(),c&=7;do{if(!(0|l)|!(0|c))n[o>>2]=1,l=0;else if(7==(0|l))l=5;else{if(1==(0|l)|1==(0|c)&&0|HA(u,f)){l=5;break}if((0|n[15536+(l<<2)>>2])!=(0|c)&&(0|n[15568+(l<<2)>>2])!=(0|c))break A;n[o>>2]=1,l=0}}while(0);return F=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 S(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,F=s,0},_bitshift64Ashr:et,_bitshift64Lshr:tt,_bitshift64Shl:rt,_calloc:We,_cellAreaKm2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475),0|A},_cellAreaM2:function(A,e,t){return 0|(A=0|ue(A|=0,e|=0,t|=0))||(o[t>>3]=6371.007180918475*+o[t>>3]*6371.007180918475*1e3*1e3),0|A},_cellAreaRads2:ue,_cellToBoundary:$A,_cellToCenterChild:GA,_cellToChildPos:function(A,e,t,r){t|=0,r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0;if(o=F,F=F+16|0,p=o,v=0|tt(0|(A|=0),0|(e|=0),52),B(),t>>>0>15)return F=o,4;if((0|(v&=15))<(0|t))return F=o,12;if((0|v)!=(0|t))if(a=0|rt(0|t,0,52),a|=A,l=B()|-15728641&e,(0|v)>(0|t)){c=t;do{b=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,a|=b,l=0|B()|l}while((0|c)<(0|v));b=a}else b=a;else b=A,l=e;m=0|tt(0|b,0|l,45),B();A:do{if(0|z(127&m)){if(c=0|tt(0|b,0|l,52),B(),0|(c&=15))for(a=1;;){if(!(!((m=0|rt(7,0,3*(15-a|0)|0))&b)&!((0|B())&l))){u=33;break A}if(!(a>>>0>>0))break;a=a+1|0}if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(m=-15728641&e,h=v;;){if(g=h,(h=h+-1|0)>>>0>15|(0|v)<(0|h)){u=19;break}if((0|v)!=(0|h))if(a=0|rt(0|h,0,52),a|=A,c=0|B()|m,(0|v)<(0|g))d=a;else{u=h;do{d=0|rt(7,0,3*(14-u|0)|0),u=u+1|0,a|=d,c=0|B()|c}while((0|u)<(0|v));d=a}else d=A,c=e;if(f=0|tt(0|d,0|c,45),B(),0|z(127&f)){f=0|tt(0|d,0|c,52),B(),f&=15;e:do{if(f)for(u=1;;){if(a=0|tt(0|d,0|c,3*(15-u|0)|0),B(),0|(a&=7))break e;if(!(u>>>0>>0)){a=0;break}u=u+1|0}else a=0}while(0);a=1&!(0|a)}else a=0;if(c=0|tt(0|A,0|e,3*(15-g|0)|0),B(),7==(0|(c&=7))){i=5,u=42;break}if(1==(0|c)&(a=!!(0|a))){i=5,u=42;break}if(0|(d=c+((!!(0|c)&a)<<31>>31)|0)&&(u=0|pe(7,0,u=v-g|0,((0|u)<0)<<31>>31),f=0|B(),a?(a=0|Ve(0|(a=0|qe(0|u,0|f,5,0)),0|B(),-5,-1),a=0|Ve(0|(a=0|Xe(0|a,0|B(),6,0)),0|B(),1,0),c=0|B()):(a=u,c=f),g=0|Ve(0|a,0|c,0|(g=0|qe(0|u,0|f,0|(g=d+-1|0),((0|g)<0)<<31>>31)),0|B()),f=0|Ve(0|g,0|(d=0|B()),0|n[(f=r)>>2],0|n[f+4>>2]),d=0|B(),n[(g=r)>>2]=f,n[g+4>>2]=d),(0|h)<=(0|t)){u=37;break}}if(19==(0|u))M(27795,27122,1367,27158);else{if(37==(0|u)){i=0|n[(s=r)+4>>2],s=0|n[s>>2];break}if(42==(0|u))return F=o,0|i}}else i=0,s=0}else u=33}while(0);A:do{if(33==(0|u)){if(n[(m=r)>>2]=0,n[m+4>>2]=0,(0|v)>(0|t)){for(a=v;;){if(i=0|tt(0|A,0|e,3*(15-a|0)|0),B(),7==(0|(i&=7))){i=5;break}if(i=0|qe(0|(s=0|pe(7,0,s=v-a|0,((0|s)<0)<<31>>31)),0|B(),0|i,0),s=0|B(),s=0|Ve(0|n[(m=r)>>2],0|n[m+4>>2],0|i,0|s),i=0|B(),n[(m=r)>>2]=s,n[m+4>>2]=i,(0|(a=a+-1|0))<=(0|t))break A}return F=o,0|i}i=0,s=0}}while(0);return 0|_A(b,l,v,p)&&M(27795,27122,1327,27173),((0|i)>-1|-1==(0|i)&s>>>0>4294967295)&((0|(p=0|n[(v=p)+4>>2]))>(0|i)|((0|p)==(0|i)?(0|n[v>>2])>>>0>s>>>0:0))?(F=o,0|(v=0)):(M(27795,27122,1407,27158),0)},_cellToChildren:function(A,e,t,r){r|=0;var o,i,a=0,s=0;if(i=F,F=F+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 F=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 F=i,0},_cellToChildrenSize:_A,_cellToLatLng:qA,_cellToLocalIj:function(A,e,t,r,o,i){var a,s;return A|=0,i|=0,s=F,F=F+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),F=s,0|A},_cellToParent:TA,_cellToVertex:Pe,_cellToVertexes:function(A,e,t){t|=0;var r,o=0,i=0;return i=!(0|HA(A|=0,e|=0)),r=!(0|(o=0|Pe(A,e,0,t))),i?r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||(o=0|Pe(A,e,4,t+32|0))?0|(i=o):0|Pe(A,e,5,t+40|0):0|(i=o):r?0|(o=0|Pe(A,e,1,t+8|0))||0|(o=0|Pe(A,e,2,t+16|0))||0|(o=0|Pe(A,e,3,t+24|0))||0|(o=0|Pe(A,e,4,t+32|0))?0|(i=o):(n[(i=t+40|0)>>2]=0,n[i+4>>2]=0,0|(i=0)):0|(i=o)},_cellsToDirectedEdge:function(A,e,t,r,o){return o|=0,7==(0|(t=0|_(A|=0,e|=0,t|=0,r|=0)))?0|(o=11):(r=0|rt(0|t,0,56),e=-2130706433&e|B()|268435456,n[o>>2]=A|r,n[o+4>>2]=e,0|(o=0))},_cellsToLinkedMultiPolygon:function(A,e,t){t|=0;var r,i,a,s=0;if(a=F,F=F+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=F,F=F+176|0,r=o,(0|(e|=0))<1)return Le(t,0,0),F=o,0;for(c=0|tt(0|n[(c=A)>>2],0|n[c+4>>2],52),B(),Le(t,(0|e)>6?e:6,15&c),c=0;!(0|(i=0|$A(0|n[(i=A+(c<<3)|0)>>2],0|n[i+4>>2],r)));){if((0|(i=0|n[r>>2]))>0){l=0;do{s=r+8+(l<<4)|0,(a=0|ze(t,i=r+8+((0|(l=l+1|0))%(0|i)<<4)|0,s))?_e(t,a):He(t,s,i),i=0|n[r>>2]}while((0|l)<(0|i))}if((0|(c=c+1|0))>=(0|e)){i=0,u=13;break}}return 13==(0|u)?(F=o,0|i):(Re(t),F=o,0|(u=i))}(A|=0,e|=0,i=a+16|0)))return F=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|fe(t);do{de(e,A),s=A+16|0,n[r>>2]=n[s>>2],n[r+4>>2]=n[s+4>>2],n[r+8>>2]=n[s+8>>2],n[r+12>>2]=n[s+12>>2],_e(i,A),A=0|Ge(i,r)}while(0|A);A=0|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,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,B=0,D=0,E=0,Q=0,N=0,j=0,F=0,S=0,P=0,I=0,L=0;if(0|n[(s=(A|=0)+8|0)>>2])return 1;if(!(a=0|n[A>>2]))return 0;r=a,i=0;do{i=i+1|0,r=0|n[r+8>>2]}while(0|r);if(i>>>0<2)return 0;(t=0|Ue(i<<2))||M(27396,27235,317,27415),(e=0|Ue(i<<5))||M(27437,27235,321,27415),n[A>>2]=0,n[(E=A+4|0)>>2]=0,n[s>>2]=0,i=0,P=0,D=0,m=0;A:for(;;){if(h=0|n[a>>2]){c=0,u=h;do{if(d=+o[u+8>>3],r=u,u=0|n[u+16>>2],f=+o[(s=(g=!(0|u))?h:u)+8>>3],+l(+(d-f))>3.141592653589793){L=14;break}c+=(f-d)*(+o[r>>3]+ +o[s>>3])}while(!g);if(14==(0|L)){L=0,c=0,r=h;do{B=+o[r+8>>3],F=0|n[(S=r+16|0)>>2],C=+o[(F=0|F?F:h)+8>>3],c+=(+o[r>>3]+ +o[F>>3])*((C<0?C+6.283185307179586:C)-(B<0?B+6.283185307179586:B)),r=0|n[(0|r?S:a)>>2]}while(0|r)}c>0?(n[t+(P<<2)>>2]=a,P=P+1|0,s=D,r=m):L=19}else L=19;if(19==(0|L)){L=0;do{if(!i){if(m){s=E,u=m+8|0,r=a,i=A;break}if(0|n[A>>2]){L=27;break A}s=E,u=A,r=a,i=A;break}if(0|n[(r=i+8|0)>>2]){L=21;break A}if(!(i=0|We(1,12))){L=23;break A}n[r>>2]=i,s=i+4|0,u=i,r=m}while(0);if(n[u>>2]=a,n[s>>2]=a,u=e+(D<<5)|0,g=0|n[a>>2]){for(o[(h=e+(D<<5)+8|0)>>3]=17976931348623157e292,o[(m=e+(D<<5)+24|0)>>3]=17976931348623157e292,o[u>>3]=-17976931348623157e292,o[(b=e+(D<<5)+16|0)>>3]=-17976931348623157e292,y=17976931348623157e292,k=-17976931348623157e292,s=0,p=g,d=17976931348623157e292,x=17976931348623157e292,w=-17976931348623157e292,f=-17976931348623157e292;c=+o[p>>3],B=+o[p+8>>3],p=0|n[p+16>>2],C=+o[((v=!(0|p))?g:p)+8>>3],c>3]=c,d=c),B>3]=B,x=B),c>w?o[u>>3]=c:c=w,B>f&&(o[b>>3]=B,f=B),y=B>0&Bk?B:k,s|=+l(+(B-C))>3.141592653589793,!v;)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[(S=a+8|0)>>2],n[S>>2]=0,!a){L=45;break}D=s,m=r}if(21==(0|L))M(27213,27235,35,27247);else if(23==(0|L))M(27267,27235,37,27247);else if(27==(0|L))M(27310,27235,61,27333);else if(45==(0|L)){A:do{if((0|P)>0){for(S=!(0|s),j=s<<2,F=!(0|A),N=0,r=0;;){if(Q=0|n[t+(N<<2)>>2],S)L=73;else{if(!(D=0|Ue(j))){L=50;break}if(!(E=0|Ue(j))){L=52;break}e:do{if(F)i=0;else{for(s=0,i=0,u=A;a=e+(s<<5)|0,0|he(0|n[u>>2],a,0|n[Q>>2])?(n[D+(i<<2)>>2]=u,n[E+(i<<2)>>2]=a,v=i+1|0):v=i,u=0|n[u+8>>2];)s=s+1|0,i=v;if((0|v)>0)if(a=0|n[D>>2],1==(0|v))i=a;else for(b=0,p=-1,i=a,m=a;;){for(g=0|n[m>>2],a=0,u=0;h=(0|(s=0|n[n[D+(u<<2)>>2]>>2]))==(0|g)?a:a+(1&he(s,0|n[E+(u<<2)>>2],0|n[g>>2]))|0,(0|(u=u+1|0))!=(0|v);)a=h;if(i=(s=(0|h)>(0|p))?m:i,(0|(a=b+1|0))==(0|v))break e;b=a,p=s?h:p,m=0|n[D+(a<<2)>>2]}else i=0}}while(0);if(Ye(D),Ye(E),i){if(a=0|n[(s=i+4|0)>>2])i=a+8|0;else if(0|n[i>>2]){L=70;break}n[i>>2]=Q,n[s>>2]=Q}else L=73}if(73==(0|L)){if(L=0,0|(r=0|n[Q>>2]))do{E=r,r=0|n[r+16>>2],Ye(E)}while(0|r);Ye(Q),r=1}if((0|(N=N+1|0))>=(0|P)){I=r;break A}}50==(0|L)?M(27452,27235,249,27471):52==(0|L)?M(27490,27235,252,27471):70==(0|L)&&M(27310,27235,61,27333)}else I=0}while(0);return Ye(t),Ye(e),0|I}return 0}(t))?(ge(t),F=a,0|(s=A)):(F=a,0|(s=0))},_childPosToCell:function(A,e,t,r,o,i){A|=0,e|=0,i|=0;var a,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(a=F,F=F+16|0,s=a,(o|=0)>>>0>15)return F=a,4;if(l=0|tt(0|(t|=0),0|(r|=0),52),B(),(0|(l&=15))>(0|o))return F=a,12;if(0|_A(t,r,o,s)&&M(27795,27122,1327,27173),!(((0|e)>-1|-1==(0|e)&A>>>0>4294967295)&((0|(u=0|n[(f=s)+4>>2]))>(0|e)|((0|u)==(0|e)?(0|n[f>>2])>>>0>A>>>0:0))))return F=a,2;f=o-l|0,o=0|rt(0|o,0,52),c=B()|-15728641&r,n[(u=i)>>2]=o|t,n[u+4>>2]=c,u=0|tt(0|t,0|r,45),B();A:do{if(0|z(127&u)){if(0|l)for(s=1;;){if(!(!((u=0|rt(7,0,3*(15-s|0)|0))&t)&!((0|B())&r)))break A;if(!(s>>>0>>0))break;s=s+1|0}if((0|f)<1)return F=a,0;for(u=15^l,r=-1,c=1,s=1;;){l=0|pe(7,0,l=f-c|0,((0|l)<0)<<31>>31),t=0|B();do{if(s){if(s=0|Xe(0|(s=0|Ve(0|(s=0|qe(0|l,0|t,5,0)),0|B(),-5,-1)),0|B(),6,0),(0|e)>(0|(o=0|B()))|(0|e)==(0|o)&A>>>0>s>>>0){e=0|Ze(0|(e=0|Ve(0|A,0|e,-1,-1)),0|B(),0|s,0|o),s=0|B(),h=0|n[(d=i)>>2],d=0|n[d+4>>2],g=0|rt(7,0,0|(m=3*(u+r|0)|0)),d&=~B(),m=0|rt(0|(o=0|Ve(0|(r=0|Xe(0|e,0|s,0|l,0|t)),0|(A=0|B()),2,0)),0|B(),0|m),d=0|B()|d,n[(o=i)>>2]=m|h&~g,n[o+4>>2]=d,A=0|Ze(0|e,0|s,0|(A=0|qe(0|r,0|A,0|l,0|t)),0|B()),s=0,e=0|B();break}g=0|n[(m=i)>>2],m=0|n[m+4>>2],h=0|rt(7,0,3*(u+r|0)|0),m&=~B(),n[(s=i)>>2]=g&~h,n[s+4>>2]=m,s=1;break}o=0|n[(g=i)>>2],g=0|n[g+4>>2],d=0|rt(7,0,0|(r=3*(u+r|0)|0)),g&=~B(),r=0|rt(0|(m=0|Xe(0|A,0|e,0|l,0|t)),0|(s=0|B()),0|r),g=0|B()|g,n[(h=i)>>2]=r|o&~d,n[h+4>>2]=g,A=0|Ze(0|A,0|e,0|(s=0|qe(0|m,0|s,0|l,0|t)),0|B()),s=0,e=0|B()}while(0);if(!((0|f)>(0|c))){e=0;break}r=~c,c=c+1|0}return F=a,0|e}}while(0);if((0|f)<1)return F=a,0;for(o=15^l,s=1;;){if(h=0|pe(7,0,h=f-s|0,((0|h)<0)<<31>>31),m=0|B(),t=0|n[(c=i)>>2],c=0|n[c+4>>2],r=0|rt(7,0,0|(l=3*(o-s|0)|0)),c&=~B(),l=0|rt(0|(d=0|Xe(0|A,0|e,0|h,0|m)),0|(g=0|B()),0|l),c=0|B()|c,n[(u=i)>>2]=l|t&~r,n[u+4>>2]=c,A=0|Ze(0|A,0|e,0|(m=0|qe(0|d,0|g,0|h,0|m)),0|B()),e=0|B(),(0|f)<=(0|s)){e=0;break}s=s+1|0}return F=a,0|e},_compactCells:function(A,e,t,r){e|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,D=0,E=0,Q=0,N=0,j=0,F=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[(F=e)>>2]=a,n[F+4>>2]=i,1==(0|t)&!(0|r))return 0;i=1,a=0;do{j=0|n[4+(N=A+(i<<3)|0)>>2],n[(F=e+(i<<3)|0)>>2]=n[N>>2],n[F+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),!(N=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(),Q=(E&=15)-1|0,D=!!(0|E),C=(0|r)>0|!(0|r)&t>>>0>0;e:do{if(D&C){if(x=0|rt(0|Q,0,52),w=0|B(),Q>>>0>15){if(!(!(0|u)&!(0|i))){F=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,F=16;break A}}}for(l=u,A=i,a=0,s=0;;){if(!(!(0|l)&!(0|A))){if(!(!0&!(117440512&A))){F=21;break A}if(f=0|tt(0|l,0|A,52),B(),(0|(f&=15))<(0|Q)){i=12,F=27;break A}if((0|f)!=(0|Q)&&(l|=x,A=-15728641&A|w,f>>>0>=E>>>0)){c=Q;do{k=0|rt(7,0,3*(14-c|0)|0),c=c+1|0,l|=k,A=0|B()|A}while(c>>>0>>0)}if(g=0|At(0|l,0|A,0|t,0|r),h=0|B(),!(!(0|(d=0|n[(f=c=N+(g<<3)|0)>>2]))&!(0|(f=0|n[f+4>>2])))){p=0,v=0;do{if((0|p)>(0|r)|(0|p)==(0|r)&v>>>0>t>>>0){F=31;break A}if((0|d)==(0|l)&(-117440513&f)==(0|A)){m=0|tt(0|d,0|f,56),B(),b=1+(m&=7)|0,k=0|tt(0|d,0|f,45),B();t:do{if(0|z(127&k)){if(d=0|tt(0|d,0|f,52),B(),!(d&=15)){f=6;break}for(f=1;;){if(!(!((k=0|rt(7,0,3*(15-f|0)|0))&l)&!((0|B())&A))){f=7;break t}if(!(f>>>0>>0)){f=6;break}f=f+1|0}}else f=7}while(0);if((m+2|0)>>>0>f>>>0){F=41;break A}k=0|rt(0|b,0,56),A=B()|-117440513&A,n[(y=c)>>2]=0,n[y+4>>2]=0,l|=k}else g=0|$e(0|(g=0|Ve(0|g,0|h,1,0)),0|B(),0|t,0|r),h=0|B();v=0|Ve(0|v,0|p,1,0),p=0|B(),d=0|n[(f=c=N+(g<<3)|0)>>2],f=0|n[f+4>>2]}while(!(!(0|d)&!(0|f)))}n[(k=c)>>2]=l,n[k+4>>2]=A}if(a=0|Ve(0|a,0|s,1,0),!((0|(s=0|B()))<(0|r)|(0|s)==(0|r)&a>>>0>>0))break e;l=0|n[(A=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){F=85;break}if(k=0|Xe(0|t,0|r,6,0),B(),!(k=0|We(k,8))){F=48;break}do{if(C){for(b=0,A=0,m=0,p=0;;){if(!(0|(a=0|n[(s=f=N+(b<<3)|0)>>2]))&!(0|(s=0|n[s+4>>2])))y=m;else{d=0|tt(0|a,0|s,56),B(),l=1+(d&=7)|0,g=-117440513&s,y=0|tt(0|a,0|s,45),B();e:do{if(0|z(127&y)){if(h=0|tt(0|a,0|s,52),B(),0|(h&=15))for(c=1;;){if(!(!(a&(y=0|rt(7,0,3*(15-c|0)|0)))&!(g&(0|B()))))break e;if(!(c>>>0>>0))break;c=c+1|0}a|=s=0|rt(0|l,0,56),s=0|B()|g,n[(l=f)>>2]=a,n[l+4>>2]=s,l=d+2|0}}while(0);7==(0|l)?(n[(y=k+(A<<3)|0)>>2]=a,n[y+4>>2]=-117440513&s,A=0|Ve(0|A,0|m,1,0),y=0|B()):y=m}if(b=0|Ve(0|b,0|p,1,0),!((0|(p=0|B()))<(0|r)|(0|p)==(0|r)&b>>>0>>0))break;m=y}if(C){if(v=Q>>>0>15,x=0|rt(0|Q,0,52),w=0|B(),!D){for(a=0,c=0,l=0,s=0;!(0|u)&!(0|i)||(n[(Q=e+(a<<3)|0)>>2]=u,n[Q+4>>2]=i,a=0|Ve(0|a,0|c,1,0),c=0|B()),l=0|Ve(0|l,0|s,1,0),(0|(s=0|B()))<(0|r)|(0|s)==(0|r)&l>>>0>>0;)u=0|n[(i=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(),v|(0|(h&=15))<(0|Q)){F=80;break A}if((0|h)!=(0|Q)){if(f=u|x,d=-15728641&i|w,h>>>0>=E>>>0){g=Q;do{D=0|rt(7,0,3*(14-g|0)|0),g=g+1|0,f|=D,d=0|B()|d}while(g>>>0>>0)}}else f=u,d=i;m=0|At(0|f,0|d,0|t,0|r),g=0,h=0,p=0|B();do{if((0|g)>(0|r)|(0|g)==(0|r)&h>>>0>t>>>0){F=81;break A}if((-117440513&(b=0|n[4+(D=N+(m<<3)|0)>>2]))==(0|d)&&(0|n[D>>2])==(0|f)){F=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=N+(m<<3)|0}while((0|n[D>>2])!=(0|f)||(0|n[D+4>>2])!=(0|d));if(65==(0|F)&&(F=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|N,0,0|o),st(0|j,0|k,A<<3),Ye(k),!(0|A)&!(0|i)){F=89;break}e=e+(a<<3)|0,r=i,t=A}if(16==(0|F))!0&!(117440512&i)?(i=4,F=27):F=21;else if(31==(0|F))M(27795,27122,620,27132);else{if(41==(0|F))return Ye(j),Ye(N),10;if(48==(0|F))return Ye(j),Ye(N),13;80==(0|F)?M(27795,27122,711,27132):81==(0|F)?M(27795,27122,723,27132):85==(0|F)&&(st(0|e,0|j,t<<3),F=89)}return 21==(0|F)?(Ye(j),Ye(N),0|(F=5)):27==(0|F)?(Ye(j),Ye(N),0|(F=i)):89==(0|F)?(Ye(j),Ye(N),0|(F=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=F,F=F+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),F=r,0|a):(F=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=F,F=F+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,F=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,F=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,o[t>>3]=h,F=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=F,F=F+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,F=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,F=r,0|l;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+g)*+f(+i)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)!=(0|e));return o[t>>3]=s,l=0,h=s,h*=6371.007180918475,h*=1e3,o[t>>3]=h,F=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=F,F=F+176|0,0|(A=0|DA(A|=0,e|=0,l=r)))return F=r,0|A;if(o[t>>3]=0,(0|(A=0|n[l>>2]))<=1)return F=r,0;e=A+-1|0,A=0,i=+o[l+8>>3],a=+o[l+16>>3],s=0;do{g=i,i=+o[l+8+((A=A+1|0)<<4)>>3],h=+d(.5*(i-g)),u=a,a=+o[l+8+(A<<4)+8>>3],u=h*h+(u=+d(.5*(a-u)))*(+f(+i)*+f(+g)*u),s+=2*+p(+ +c(+u),+ +c(+(1-u)))}while((0|A)<(0|e));return o[t>>3]=s,F=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:IA,_getDirectedEdgeDestination:function(A,e,t){A|=0,e|=0,t|=0;var r,o,i=0;return r=F,F=F+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),F=r,0|i):(F=r,0|(i=6))},_getDirectedEdgeOrigin:function(A,e,t){return A|=0,t|=0,!0&268435456==(2013265920&(e|=0))?(n[t>>2]=A,n[t+4>>2]=-2130706433&e|134217728,0|(t=0)):0|(t=6)},_getHexagonAreaAvgKm2:se,_getHexagonAreaAvgM2:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20784+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgKm:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[20912+(A<<3)>>3],0|(e=0))},_getHexagonEdgeLengthAvgM:function(A,e){return e|=0,(A|=0)>>>0>15?0|(e=4):(o[e>>3]=+o[21040+(A<<3)>>3],0|(e=0))},_getIcosahedronFaces:function A(e,t,r){r|=0;var o,i=0,a=0,s=0,l=0,c=0,u=0,f=0,d=0;o=F,F=F+128|0,f=o+112|0,s=o+96|0,d=o,a=0|tt(0|(e|=0),0|(t|=0),52),B(),c=15&a,n[f>>2]=c,l=0|tt(0|e,0|t,45),B(),l&=127;A:do{if(0|z(l)){if(0|c)for(i=1;;){if(!(!((u=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){a=0;break A}if(!(i>>>0>>0))break;i=i+1|0}if(!(1&a))return u=0|rt(c+1|0,0,52),d=B()|-15728641&t,d=0|A((u|e)&~(f=0|rt(7,0,3*(14-c|0)|0)),d&~B(),r),F=o,0|d;a=1}else a=0}while(0);if(!(i=0|XA(e,t,s))){a?(NA(s,f,d),u=5):(PA(s,f,d),u=6);A:do{if(0|z(l))if(c)for(i=1;;){if(!(!((l=0|rt(7,0,3*(15-i|0)|0))&e)&!((0|B())&t))){e=2;break A}if(!(i>>>0>>0)){e=5;break}i=i+1|0}else e=5;else e=2}while(0);lt(0|r,-1,e<<2);A:do{if(a)for(s=0;;){if(FA(l=d+(s<<4)|0,0|n[f>>2]),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}else for(s=0;;){if(jA(l=d+(s<<4)|0,0|n[f>>2],0,1),l=0|n[l>>2],-1==(0|(c=0|n[r>>2]))|(0|c)==(0|l))i=r;else{a=0;do{if((a=a+1|0)>>>0>=e>>>0){i=1;break A}c=0|n[(i=r+(a<<2)|0)>>2]}while(!(-1==(0|c)|(0|c)==(0|l)))}if(n[i>>2]=l,(s=s+1|0)>>>0>=u>>>0){i=0;break}}}while(0)}return F=o,0|i},_getIndexDigit:function(A,e,t,r){return r|=0,((t|=0)-1|0)>>>0>14?0|(r=4):(t=0|tt(0|(A|=0),0|(e|=0),3*(15-t|0)|0),B(),n[r>>2]=7&t,0|(r=0))},_getNumCells:le,_getPentagons:Ae,_getRes0Cells:function(A){A|=0;var e=0,t=0,r=0;e=0;do{rt(0|e,0,45),r=134225919|B(),n[(t=A+(e<<3)|0)>>2]=-1,n[t+4>>2]=r,e=e+1|0}while(122!=(0|e));return 0},_getResolution:function(A,e){return e=0|tt(0|(A|=0),0|(e|=0),52),B(),15&e},_greatCircleDistanceKm:ae,_greatCircleDistanceM:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))*6371.007180918475*1e3},_greatCircleDistanceRads:function(A,e){A|=0;var t,r,n,i=0;return r=+o[(e|=0)>>3],t=+o[A>>3],i=(n=+d(.5*(r-t)))*n+(i=+d(.5*(+o[e+8>>3]-+o[A+8>>3])))*(+f(+r)*+f(+t)*i),2*+p(+ +c(+i),+ +c(+(1-i)))},_gridDisk:S,_gridDiskDistances:P,_gridDistance:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,l=0;return a=F,F=F+32|0,l=a,0|(i=0|me(A|=0,e|=0,A,e,s=a+12|0))?(F=a,0|(l=i)):0|(A=0|me(A,e,t,r,l))?(F=a,0|(l=A)):(s=0|kA(s,l),n[(l=o)>>2]=s,n[l+4>>2]=((0|s)<0)<<31>>31,F=a,0|(l=0))},_gridPathCells:function(A,e,t,r,o){t|=0,r|=0,o|=0;var i,a,s=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,D=0,E=0;if(a=F,F=F+48|0,c=a+12|0,D=a,!(s=0|me(A|=0,e|=0,A,e,i=a+24|0))&&!(s=0|me(A,e,t,r,c))){C=((0|(k=0|kA(i,c)))<0)<<31>>31,n[i>>2]=0,n[i+4>>2]=0,n[i+8>>2]=0,n[c>>2]=0,n[c+4>>2]=0,n[c+8>>2]=0,0|me(A,e,A,e,i)&&M(27795,27538,692,27747),0|me(A,e,t,r,c)&&M(27795,27538,697,27747),CA(i),CA(c),g=0|k?1/+(0|k):0,t=0|n[i>>2],v=g*+((0|n[c>>2])-t|0),r=0|n[(x=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=v*(f=+(p>>>0)+4294967296*+(0|b))+ +(0|t),u=w*f+ +(0|r),f=g*f+ +(0|s),t=~~+at(+E),c=~~+at(+u),s=~~+at(+f),E=+l(+(+(0|t)-E)),u=+l(+(+(0|c)-u)),f=+l(+(+(0|s)-f));do{if(!(E>u&E>f)){if(d=0-t|0,u>f){r=d-s|0;break}r=c,s=d-c|0;break}t=0-(c+s)|0,r=c}while(0);if(n[D>>2]=t,n[h>>2]=r,n[m>>2]=s,BA(D),0|(s=0|be(A,e,D,o+(p<<3)|0)))break A;if(!((0|b)<(0|C)|(0|b)==(0|C)&p>>>0>>0)){s=0;break A}t=0|Ve(0|p,0|b,1,0),b=r=0|B(),p=t,t=0|n[i>>2],r=0|n[x>>2],s=0|n[y>>2]}}while(0);return F=a,0|s}return F=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=F,F=F+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))?(F=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,F=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,f=0,d=0;if(o=F,F=F+16|0,s=o,!(t|=0))return n[r>>2]=A,n[r+4>>2]=e,F=o,0;do{if((0|t)>=0){if((0|t)>13780509){if(0|(i=0|le(15,s)))break;i=0|n[(a=s)>>2],a=0|n[a+4>>2]}else f=0|qe(0|t,0|(i=((0|t)<0)<<31>>31),3,0),a=0|B(),i=0|Ve(0|t,0|i,1,0),i=0|Ve(0|(i=0|qe(0|f,0|a,0|i,0|B())),0|B(),1,0),a=0|B(),n[(f=s)>>2]=i,n[f+4>>2]=a;if(u=0|We(i,8)){if(!(f=0|We(i,4))){Ye(u),i=13;break}if(0|(i=0|L(A,e,t,u,f,i,a,0))){Ye(u),Ye(f);break}if(e=0|n[s>>2],(0|(s=0|n[s+4>>2]))>0|!(0|s)&e>>>0>0){i=0,l=0,c=0;do{!(0|(a=0|n[(A=u+(l<<3)|0)>>2]))&!(0|(A=0|n[A+4>>2]))||(0|n[f+(l<<2)>>2])!=(0|t)||(n[(d=r+(i<<3)|0)>>2]=a,n[d+4>>2]=A,i=i+1|0),l=0|Ve(0|l,0|c,1,0),c=0|B()}while((0|c)<(0|s)|(0|c)==(0|s)&l>>>0>>0)}Ye(u),Ye(f),i=0}else i=13}else i=2}while(0);return F=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:LA,_isValidDirectedEdge:MA,_isValidIndex:function(A,e){A|=0;var t=0,n=0,o=0,i=0;if(!0&134217728==(-16777216&(e|=0))&&(n=0|tt(0|A,0|e,52),B(),n&=15,t=0|tt(0|A,0|e,45),B(),(t&=127)>>>0<=121)&&!(613566756&(i=0|rt(0|(o=0|tt(0|A,0|e,0|(i=3*(15^n)|0))),0|B(),0|i))&Ze(-1227133514,-1171,0|i,0|(o=0|B())))&!(4681&o&B())&&15==(0|n)|!(0|(i=0|tt(0|rt(0|~A,0|~e,0|(i=19+(3*n|0)|0)),0|B(),0|i)))&!(0|B())){if(!(0|r[20528+t|0]))return 1;if(!(0|A)&!(0|(t=8191&e)))return 1;if(i=0|nt(0|A,0|t),B(),(63-i|0)%3|0)return 1}return 0|MA(A,e)?0|(i=1):0|(i=1&!!(0|Ie(A,e)))},_isValidVertex:Ie,_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=F,F=F+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)),F=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=F,F=F+48|0,i=o+16|0,a=o+8|0,s=o,0|(t=0|Ce(t|=0)))return F=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 F=o,0|t},_maxPolygonToCellsSizeExperimental:function(A,e,t,i){e|=0,t|=0,i|=0;var a,s,c=0,u=0,d=0,g=0,h=0,m=0,b=0,p=0;if(s=F,F=F+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,F=s,0;RA(h,0,0,0),c=0|n[(d=h)>>2],d=0|n[d+4>>2];do{if(e>>>0>15)n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=4,m=9;else{if(0|(t=0|Ce(t))){n[(h=a)>>2]=0,n[h+4>>2]=0,n[a+8>>2]=t,n[a+12>>2]=-1,m=a+29|0,n[(h=a+16|0)>>2]=0,n[h+4>>2]=0,n[h+8>>2]=0,r[h+12|0]=0,r[0|m]=0|r[0|g],r[m+1|0]=0|r[g+1|0],r[m+2|0]=0|r[g+2|0],m=9;break}if(!(t=0|We(1+(0|n[A+8>>2])|0,32))){n[(m=a)>>2]=0,n[m+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,t=a+29|0,n[(m=a+16|0)>>2]=0,n[m+4>>2]=0,n[m+8>>2]=0,r[m+12|0]=0,r[0|t]=0|r[0|g],r[t+1|0]=0|r[g+1|0],r[t+2|0]=0|r[g+2|0],t=13,m=9;break}Be(A,t),n[(p=a)>>2]=c,n[p+4>>2]=d,n[(d=a+8|0)>>2]=0,n[a+12>>2]=e,n[a+20>>2]=A,n[a+24>>2]=t,r[a+28|0]=0,r[0|(c=a+29|0)]=0|r[0|g],r[c+1|0]=0|r[g+1|0],r[c+2|0]=0|r[g+2|0],n[a+16>>2]=3,b=+J(t),b*=+Z(t),u=+l(+ +o[t>>3]),u=b/+f(+ +it(+u,+ +l(+ +o[t+8>>3])))*6371.007180918475*6371.007180918475,t=0|n[(c=a+12|0)>>2];A:do{if((0|t)>0)do{if(se(t+-1|0,h),!(u/+o[h>>3]>10))break A;t=(p=0|n[c>>2])-1|0,n[c>>2]=t}while((0|p)>1)}while(0);if(xe(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,xe(a),t=0|n[(p=a)>>2],c=0|n[p+4>>2]}while(!(!(0|t)&!(0|c)));t=0|n[d>>2]}}while(0);return F=s,0|t},_memcpy:st,_memset:lt,_originToDirectedEdges:function(A,e,t){t|=0;var r,o=0;return r=!(0|HA(A|=0,e|=0)),e&=-2130706433,n[(o=t)>>2]=r?A:0,n[o+4>>2]=r?285212672|e:0,n[(o=t+8|0)>>2]=A,n[o+4>>2]=301989888|e,n[(o=t+16|0)>>2]=A,n[o+4>>2]=318767104|e,n[(o=t+24|0)>>2]=A,n[o+4>>2]=335544320|e,n[(o=t+32|0)>>2]=A,n[o+4>>2]=352321536|e,n[(t=t+40|0)>>2]=A,n[t+4>>2]=369098752|e,0},_pentagonCount:function(){return 12},_polygonToCells:function(A,e,t,r){A|=0,e|=0,r|=0;var o,i,a,s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0,v=0,x=0,w=0,y=0,k=0,C=0,M=0,D=0,E=0,Q=0,N=0,j=0,S=0,P=0,R=0,T=0,_=0;if(s=F,F=F+112|0,o=s+80|0,d=s+72|0,i=s,a=s+56|0,0|(l=0|Ce(t|=0)))return F=s,0|l;if(!(_=0|Ue(32+(n[(g=A+8|0)>>2]<<5)|0)))return F=s,13;if(Be(A,_),!(l=0|Ce(t))){if(T=0|n[(R=A)+4>>2],n[(l=d)>>2]=n[R>>2],n[l+4>>2]=T,ke(d,o),l=0|eA(o,e,i))R=0,T=0;else{if(l=0|n[d>>2],(0|(c=0|n[g>>2]))>0){u=0|n[A+12>>2],t=0;do{l=(0|n[u+(t<<3)>>2])+l|0,t=t+1|0}while((0|t)!=(0|c));t=l}else t=l;c=0|n[(l=i)>>2],(0|(l=0|n[l+4>>2]))<(0|(u=((0|t)<0)<<31>>31))|(0|l)==(0|u)&c>>>0>>0?(n[(l=i)>>2]=t,n[l+4>>2]=u,l=u):t=c,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(_),F=s,13;if(!(f=0|We(R,8)))return Ye(_),Ye(t),F=s,13;n[(S=o)>>2]=0,n[S+4>>2]=0,P=0|n[(S=A)+4>>2],n[(l=d)>>2]=n[S>>2],n[l+4>>2]=P,l=0|H(d,R,T,e,o,t,f);A:do{if(l)Ye(t),Ye(f),Ye(_);else{e:do{if((0|n[g>>2])>0){for(u=A+12|0,c=0;l=0|H((0|n[u>>2])+(c<<3)|0,R,T,e,o,t,f),c=c+1|0,!(0|l);)if((0|c)>=(0|n[g>>2]))break e;Ye(t),Ye(f),Ye(_);break A}}while(0);(0|T)>0|!(0|T)&R>>>0>0&<(0|f,0,R<<3),S=0|n[(P=o)+4>>2];e:do{if((0|S)>0|!(0|S)&(0|n[P>>2])>>>0>0){Q=t,N=f,j=t,S=f,P=t,l=t,M=t,D=f,E=f,t=f;t:for(;;){for(w=0,y=0,k=0,C=0,c=0,u=0;;){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));if(0|I(g=0|n[(e=Q+(w<<3)|0)>>2],e=0|n[e+4>>2],1,i,0)){d=(f=i)+56|0;do{n[f>>2]=0,f=f+4|0}while((0|f)<(0|d));0|(f=0|We(7,4))&&(L(g,e,1,i,f,7,0,0),Ye(f))}for(x=0;;){p=0|n[(v=i+(x<<3)|0)>>2],v=0|n[v+4>>2];r:do{if(!(0|p)&!(0|v))f=c,d=u;else{if(h=0|At(0|p,0|v,0|R,0|T),g=0|B(),!(!(0|(d=0|n[(e=f=r+(h<<3)|0)>>2]))&!(0|(e=0|n[e+4>>2])))){m=0,b=0;do{if((0|m)>(0|T)|(0|m)==(0|T)&b>>>0>R>>>0)break t;if((0|d)==(0|p)&(0|e)==(0|v)){f=c,d=u;break r}h=0|$e(0|(f=0|Ve(0|h,0|g,1,0)),0|B(),0|R,0|T),g=0|B(),b=0|Ve(0|b,0|m,1,0),m=0|B(),d=0|n[(e=f=r+(h<<3)|0)>>2],e=0|n[e+4>>2]}while(!(!(0|d)&!(0|e)))}if(!(0|p)&!(0|v)){f=c,d=u;break}qA(p,v,a),0|Me(A,_,a)&&(b=0|Ve(0|c,0|u,1,0),u=0|B(),n[(m=f)>>2]=p,n[m+4>>2]=v,n[(c=N+(c<<3)|0)>>2]=p,n[c+4>>2]=v,c=b),f=c,d=u}}while(0);if((x=x+1|0)>>>0>=7)break;c=f,u=d}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=f,u=d}if((0|u)>0|!(0|u)&c>>>0>0){c=0,u=0;do{n[(C=Q+(c<<3)|0)>>2]=0,n[C+4>>2]=0,c=0|Ve(0|c,0|u,1,0),u=0|B(),k=0|n[(C=o)+4>>2]}while((0|u)<(0|k)|((0|u)==(0|k)?c>>>0<(0|n[C>>2])>>>0:0))}if(n[(C=o)>>2]=f,n[C+4>>2]=d,!((0|d)>0|!(0|d)&f>>>0>0))break e;x=t,w=E,y=P,k=D,C=N,t=M,E=l,D=j,M=x,l=w,P=S,S=y,j=k,N=Q,Q=C}Ye(j),Ye(S),Ye(_),l=1;break A}l=f}while(0);Ye(_),Ye(t),Ye(l),l=0}}while(0);return F=s,0|l}}return Ye(_),F=s,0|l},_polygonToCellsExperimental:function(A,e,t,o,i,a){o|=0,i|=0,a|=0;var s,l,c,u=0,f=0,d=0,g=0,h=0,m=0,b=0,p=0;c=F,F=F+160|0,f=c+64|0,h=c+112|0,p=c,function(A,e,t,o){A|=0,e|=0,t|=0,o|=0;var i,a,s,l=0,c=0,u=0,f=0;s=F,F=F+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[(f=a)>>2]=u,n[f+4>>2]=c,n[a+8>>2]=0,n[a+12>>2]=t,n[a+16>>2]=o,n[a+20>>2]=e,n[a+24>>2]=l,r[a+28|0]=0,r[0|(u=a+29|0)]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(o=a)>>2]=0,n[o+4>>2]=0,n[a+8>>2]=13,n[a+12>>2]=-1,u=a+29|0,n[(o=a+16|0)>>2]=0,n[o+4>>2]=0,n[o+8>>2]=0,r[o+12|0]=0,r[0|u]=0|r[0|i],r[u+1|0]=0|r[i+1|0],r[u+2|0]=0|r[i+2|0];break}n[(u=a)>>2]=0,n[u+4>>2]=0,n[a+8>>2]=4,n[a+12>>2]=-1,f=a+29|0,n[(u=a+16|0)>>2]=0,n[u+4>>2]=0,n[u+8>>2]=0,r[u+12|0]=0,r[0|f]=0|r[0|i],r[f+1|0]=0|r[i+1|0],r[f+2|0]=0|r[i+2|0]}while(0);xe(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],F=s}(g=c+80|0,A|=0,e|=0,t|=0),ee(f,0|n[(d=g)>>2],0|n[d+4>>2],e),s=0|n[(d=f)>>2],d=0|n[d+4>>2],u=0|n[g+8>>2],n[(m=h+4|0)>>2]=n[g>>2],n[m+4>>2]=n[g+4>>2],n[m+8>>2]=n[g+8>>2],n[m+12>>2]=n[g+12>>2],n[m+16>>2]=n[g+16>>2],n[m+20>>2]=n[g+20>>2],n[m+24>>2]=n[g+24>>2],n[m+28>>2]=n[g+28>>2],n[(m=p)>>2]=s,n[m+4>>2]=d,n[(m=p+8|0)>>2]=u,e=h,t=36+(A=p+12|0)|0;do{n[A>>2]=n[e>>2],A=A+4|0,e=e+4|0}while((0|A)<(0|t));if(n[(h=p+48|0)>>2]=n[f>>2],n[h+4>>2]=n[f+4>>2],n[h+8>>2]=n[f+8>>2],n[h+12>>2]=n[f+12>>2],!(0|s)&!(0|d))return F=c,0|u;t=p+16|0,l=p+24|0,g=p+28|0,u=0,f=0,e=s,A=d;do{if(!((0|u)<(0|i)|(0|u)==(0|i)&f>>>0>>0)){b=4;break}if(d=f,f=0|Ve(0|f,0|u,1,0),u=0|B(),n[(d=a+(d<<3)|0)>>2]=e,n[d+4>>2]=A,re(h),!(0|(e=0|n[(A=h)>>2]))&!(0|(A=0|n[A+4>>2]))){if(xe(t),!(0|(A=0|n[(e=t)>>2]))&!(0|(e=0|n[e+4>>2]))){b=10;break}te(A,e,0|n[g>>2],h),e=0|n[(A=h)>>2],A=0|n[A+4>>2]}n[(d=p)>>2]=e,n[d+4>>2]=A}while(!(!(0|e)&!(0|A)));return 4==(0|b)?(0|(e=0|n[(A=p+40|0)>>2])&&Ye(e),n[(b=p+16|0)>>2]=0,n[b+4>>2]=0,n[l>>2]=0,n[p+36>>2]=0,n[g>>2]=-1,n[p+32>>2]=0,n[A>>2]=0,te(0,0,0,h),n[p>>2]=0,n[p+4>>2]=0,n[m>>2]=0,F=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],F=c,0|p)},_readInt64AsDoubleFromPointer:function(A){return+(+((0|n[(A|=0)>>2])>>>0)+4294967296*+(0|n[A+4>>2]))},_res0CellCount:function(){return 122},_round:ct,_sbrk:ut,_sizeOfCellBoundary:function(){return 168},_sizeOfCoordIJ:function(){return 8},_sizeOfGeoLoop:function(){return 8},_sizeOfGeoPolygon:function(){return 16},_sizeOfH3Index:function(){return 8},_sizeOfLatLng:function(){return 16},_sizeOfLinkedGeoPolygon:function(){return 12},_uncompactCells:function(A,e,t,r,o,i,a){A|=0,r|=0,o|=0,i|=0;var s,l=0,c=0,u=0,f=0,d=0,g=0,h=0,m=0;if(s=F,F=F+16|0,m=s,!((0|(t|=0))>0|!(0|t)&(e|=0)>>>0>0))return F=s,0;if((0|(a|=0))>=16)return F=s,12;g=0,h=0,d=0,l=0;A:for(;;){if(f=0|tt(0|(c=0|n[(u=A+(g<<3)|0)>>2]),0|(u=0|n[u+4>>2]),52),B(),(15&f)>(0|a)){l=12,c=11;break}if(ee(m,c,u,a),!(0|(u=0|n[(f=m)>>2]))&!(0|(f=0|n[f+4>>2])))c=d;else{c=d;do{if(!((0|l)<(0|i)|(0|l)==(0|i)&c>>>0>>0)){c=10;break A}n[(d=r+(c<<3)|0)>>2]=u,n[d+4>>2]=f,c=0|Ve(0|c,0|l,1,0),l=0|B(),re(m),u=0|n[(d=m)>>2],f=0|n[d+4>>2]}while(!(!(0|u)&!(0|f)))}if(g=0|Ve(0|g,0|h,1,0),!((0|(h=0|B()))<(0|t)|(0|h)==(0|t)&g>>>0>>0)){l=0,c=11;break}d=c}return 10==(0|c)?(F=s,0|(m=14)):11==(0|c)?(F=s,0|l):0},_uncompactCellsSize:function(A,e,t,r,o){A|=0,e|=0,t|=0,r|=0,o|=0;var i,a,s=0,l=0,c=0,u=0,f=0,d=0;a=F,F=F+16|0,i=a;A:do{if((0|t)>0|!(0|t)&e>>>0>0){for(f=0,l=0,s=0,d=0;;){if(!(!(0|(c=0|n[(u=A+(f<<3)|0)>>2]))&!(0|(u=0|n[u+4>>2]))||(u=!(0|_A(c,u,r,i)),l=0|Ve(0|n[(c=i)>>2],0|n[c+4>>2],0|l,0|s),s=0|B(),u))){s=12;break}if(f=0|Ve(0|f,0|d,1,0),!((0|(d=0|B()))<(0|t)|(0|d)==(0|t)&f>>>0>>0))break A}return F=a,0|s}l=0,s=0}while(0);return n[o>>2]=l,n[o+4>>2]=s,F=a,0},_vertexToLatLng:function(A,e,t){t|=0;var r,o,i,a,s=0,l=0;return a=F,F=F+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))?(F=a,0|(l=r)):(e=0|tt(0|A,0|e,52),B(),e&=15,0|HA(A,l)?QA(i,e,s,1,o):SA(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],F=a,0|(l=0))},establishStackSpace:function(A,e){F=A|=0},stackAlloc:function(A){var e;return e=F,F=15+(F=F+(A|=0)|0)&-16,0|e},stackRestore:function(A){F=A|=0},stackSave:function(){return 0|F}}}({Math:Math,Int8Array:Int8Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Float32Array:Float32Array,Float64Array:Float64Array},{b:function(A){s=A},c:function(){return s},d:function(A,e,t,r){tA("Assertion failed: "+v(A)+", at: "+[e?v(e):"unknown filename",t,r?v(r):"unknown function"])},e:function(A){return t.___errno_location&&(h[t.___errno_location()>>2]=A),A},f:z,g:function(A,e,t){d.set(d.subarray(e,e+t),A)},h:function(A){var e=z(),t=16777216,r=2130706432;if(A>r)return!1;for(var n=Math.max(e,16777216);n0))return 0;for(var n=t+r-1,o=0;o=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++o)),i<=127){if(t>=n)break;e[t++]=i}else if(i<=2047){if(t+1>=n)break;e[t++]=192|i>>6,e[t++]=128|63&i}else if(i<=65535){if(t+2>=n)break;e[t++]=224|i>>12,e[t++]=128|i>>6&63,e[t++]=128|63&i}else{if(t+3>=n)break;e[t++]=240|i>>18,e[t++]=128|i>>12&63,e[t++]=128|i>>6&63,e[t++]=128|63&i}}e[t]=0}(A,d,e,t)}(A,e=Z(t),t)}return e},array:function(A){var e,t,r=Z(A.length);return e=A,t=r,f.set(e,t),r}},o=c(A),i=[],a=0;if(r)for(var s=0;s>1]=e;break;case"i32":h[A>>2]=e;break;case"i64":R=[e>>>0,(L=e,+N(L)>=1?L>0?(0|S(+F(L/4294967296),4294967295))>>>0:~~+j((L-+(~~L>>>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 f[0|A];case"i16":return g[A>>1];case"i32":case"i64":return h[A>>2];case"float":return m[A>>2];case"double":return b[A>>3];default:tA("invalid type for getValue: "+e)}return null},T){H(T)||(W=T,T=t.locateFile?t.locateFile(W,o):o+W),P++,t.monitorRunDependencies&&t.monitorRunDependencies(P);var X=function(A){A.byteLength&&(A=new Uint8Array(A)),d.set(A,8),t.memoryInitializerRequest&&delete t.memoryInitializerRequest.response,function(){if(P--,t.monitorRunDependencies&&t.monitorRunDependencies(P),0==P&&I){var A=I;I=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;)Q(t.postRun.shift());k(D)}()))}P>0||(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)E(t.preRun.shift());k(C)}(),P>0||(t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),e()},1)):e()))}function tA(A){throw t.onAbort&&t.onAbort(A),i(A+=""),a(A),l=!0,"abort("+A+"). Build with -s ASSERTIONS=1 for more info."}if(I=function A(){V||eA(),V||(I=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 Ae?Ae:{}),ee="number",te={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"},re={1e3:"Unknown unit",1001:"Array length out of bounds",1002:"Got unexpected null value for H3 index"};function ne(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 oe(A){if(0!==A)throw function(A,e){return ne(te,A,2===arguments.length?{value:e}:{})}(A)}var ie={};[["sizeOfH3Index",ee],["sizeOfLatLng",ee],["sizeOfCellBoundary",ee],["sizeOfGeoLoop",ee],["sizeOfGeoPolygon",ee],["sizeOfLinkedGeoPolygon",ee],["sizeOfCoordIJ",ee],["readInt64AsDoubleFromPointer",ee],["isValidCell",ee,[ee,ee]],["isValidIndex",ee,[ee,ee]],["latLngToCell",ee,[ee,ee,ee,ee]],["cellToLatLng",ee,[ee,ee,ee]],["cellToBoundary",ee,[ee,ee,ee]],["maxGridDiskSize",ee,[ee,ee]],["gridDisk",ee,[ee,ee,ee,ee]],["gridDiskDistances",ee,[ee,ee,ee,ee,ee]],["gridRing",ee,[ee,ee,ee,ee]],["gridRingUnsafe",ee,[ee,ee,ee,ee]],["maxPolygonToCellsSize",ee,[ee,ee,ee,ee]],["polygonToCells",ee,[ee,ee,ee,ee]],["maxPolygonToCellsSizeExperimental",ee,[ee,ee,ee,ee]],["polygonToCellsExperimental",ee,[ee,ee,ee,ee,ee,ee]],["cellsToLinkedMultiPolygon",ee,[ee,ee,ee]],["destroyLinkedMultiPolygon",null,[ee]],["compactCells",ee,[ee,ee,ee,ee]],["uncompactCells",ee,[ee,ee,ee,ee,ee,ee]],["uncompactCellsSize",ee,[ee,ee,ee,ee,ee]],["isPentagon",ee,[ee,ee]],["isResClassIII",ee,[ee,ee]],["getBaseCellNumber",ee,[ee,ee]],["getResolution",ee,[ee,ee]],["getIndexDigit",ee,[ee,ee,ee]],["constructCell",ee,[ee,ee,ee,ee]],["maxFaceCount",ee,[ee,ee,ee]],["getIcosahedronFaces",ee,[ee,ee,ee]],["cellToParent",ee,[ee,ee,ee,ee]],["cellToChildren",ee,[ee,ee,ee,ee]],["cellToCenterChild",ee,[ee,ee,ee,ee]],["cellToChildrenSize",ee,[ee,ee,ee,ee]],["cellToChildPos",ee,[ee,ee,ee,ee]],["childPosToCell",ee,[ee,ee,ee,ee,ee,ee]],["areNeighborCells",ee,[ee,ee,ee,ee,ee]],["cellsToDirectedEdge",ee,[ee,ee,ee,ee,ee]],["getDirectedEdgeOrigin",ee,[ee,ee,ee]],["getDirectedEdgeDestination",ee,[ee,ee,ee]],["isValidDirectedEdge",ee,[ee,ee]],["directedEdgeToCells",ee,[ee,ee,ee]],["originToDirectedEdges",ee,[ee,ee,ee]],["directedEdgeToBoundary",ee,[ee,ee,ee]],["gridDistance",ee,[ee,ee,ee,ee,ee]],["gridPathCells",ee,[ee,ee,ee,ee,ee]],["gridPathCellsSize",ee,[ee,ee,ee,ee,ee]],["cellToLocalIj",ee,[ee,ee,ee,ee,ee,ee]],["localIjToCell",ee,[ee,ee,ee,ee,ee]],["getHexagonAreaAvgM2",ee,[ee,ee]],["getHexagonAreaAvgKm2",ee,[ee,ee]],["getHexagonEdgeLengthAvgM",ee,[ee,ee]],["getHexagonEdgeLengthAvgKm",ee,[ee,ee]],["greatCircleDistanceM",ee,[ee,ee]],["greatCircleDistanceKm",ee,[ee,ee]],["greatCircleDistanceRads",ee,[ee,ee]],["cellAreaM2",ee,[ee,ee,ee]],["cellAreaKm2",ee,[ee,ee,ee]],["cellAreaRads2",ee,[ee,ee,ee]],["edgeLengthM",ee,[ee,ee,ee]],["edgeLengthKm",ee,[ee,ee,ee]],["edgeLengthRads",ee,[ee,ee,ee]],["getNumCells",ee,[ee,ee]],["getRes0Cells",ee,[ee]],["res0CellCount",ee],["getPentagons",ee,[ee,ee]],["pentagonCount",ee],["cellToVertex",ee,[ee,ee,ee,ee]],["cellToVertexes",ee,[ee,ee,ee]],["vertexToLatLng",ee,[ee,ee,ee]],["isValidVertex",ee,[ee,ee]]].forEach(function(A){ie[A[0]]=Ae.cwrap.apply(Ae,A)});var ae=16,se=ie.sizeOfH3Index(),le=ie.sizeOfLatLng(),ce=ie.sizeOfCellBoundary();ie.sizeOfGeoPolygon(),ie.sizeOfGeoLoop(),ie.sizeOfLinkedGeoPolygon(),ie.sizeOfCoordIJ();var ue=/[^0-9a-fA-F]/;function fe(A){if(A>=0)return A.toString(ae);var e=de(8,(A&=2147483647).toString(ae));return(parseInt(e[0],ae)+8).toString(ae)+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 ke(r[Math.min(23,Math.floor(24*o))])}function Be({coveragePoints:e,visible:r,terrainEnabled:n=!1,brightness:o=.7,basemapMode:i="dark"}){const{current:a}=P(),[s,l]=A.useState(null);A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==a?void 0:a.getMap)?void 0:A.call(a);e&&!s&&l(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[a,s]);const[c,u]=A.useState(null),[f,d]=A.useState(!1),g=A.useRef({aborted:!1}),h=A.useRef(0),m=A.useRef(i),b=function(e){const[t,r]=A.useState(e);return A.useEffect(()=>{const A=setTimeout(()=>r(e),300);return()=>clearTimeout(A)},[e,300]),t}(e),p=A.useMemo(()=>function(A="dark"){var e;if("light"===A)return ye;const t=dA();return 24===t.length&&0!==(null==(e=t[0])?void 0:e[0])?t:we}(i),[i]);A.useEffect(()=>{if(!b||!Array.isArray(b)||0===b.length)return void queueMicrotask(()=>{u(null),h.current=0});const A=m.current!==i;if(b.length===h.current&&c&&!A)return;h.current=b.length,m.current=i,g.current.aborted=!0,g.current={aborted:!1};const e=g.current;d(!0);const{cells:t,minQuality:r,maxQuality:n}=function(A){const e=new Map;for(const o of A){if("number"!=typeof o.lat||"number"!=typeof o.lon||isNaN(o.lat)||isNaN(o.lon))continue;const A=me(o.lat,o.lon,8),t=e.get(A),r=o.weight;t?(t.count++,t.qualitySum+=r):e.set(A,{count:1,qualitySum:r})}const t=[];let r=1/0,n=-1/0;for(const[o,i]of e.entries()){const A=i.qualitySum/i.count;t.push({hexId:o,count:i.count,avgQuality:A}),r=Math.min(r,A),n=Math.max(n,A)}return{cells:t,minQuality:t.length>0?r:0,maxQuality:t.length>0?n:0}}(b);if(0===t.length)return u(null),void d(!1);if(t.length<500){const A=function(A,e,t,r){const n=[];for(const o of A){const A=be(o.hexId).map(([A,e])=>[e,A]);A.push(A[0]);const i=Ce(o.avgQuality,e,t,r);n.push({type:"Feature",properties:{color:i,quality:o.avgQuality,count:o.count},geometry:{type:"Polygon",coordinates:[A]}})}return{type:"FeatureCollection",features:n}}(t,r,n,p);return void(e.aborted||(u(A),d(!1)))}return async function(A,e,t,r,n){const o=[];let i=0;for(;i[e,A]);a.push(a[0]);const s=Ce(n.avgQuality,e,t,r);o.push({type:"Feature",properties:{color:s,quality:n.avgQuality,count:n.count},geometry:{type:"Polygon",coordinates:[a]}})}irequestAnimationFrame(A))}return{type:"FeatureCollection",features:o}}(t,r,n,p,e).then(A=>{!e.aborted&&A&&u(A)}).finally(()=>{e.aborted||d(!1)}),()=>{e.aborted=!0}},[b,p]),A.useEffect(()=>{if(!s)return;const A=()=>{var A,e;try{const t=s.getLayer(xe),n=s.getSource(ve);if(r&&c&&c.features.length>0){if(n?s.getSource(ve).setData(c):s.addSource(ve,{type:"geojson",data:c}),!t){const t=s.getLayer("topology-weak-edges-native"),r=null==(e=null==(A=s.getStyle())?void 0:A.layers)?void 0:e.find(A=>"symbol"===A.type),n=t?"topology-weak-edges-native":null==r?void 0:r.id;s.addLayer({id:xe,type:"fill",source:ve,paint:{"fill-color":["get","color"],"fill-opacity":o}},n)}}else t&&s.removeLayer(xe),n&&s.removeSource(ve)}catch(t){}};s.isStyleLoaded()?A():s.once("style.load",A)},[s,r,c,n]),A.useEffect(()=>{if(s&&r)try{s.getLayer(xe)&&s.setPaintProperty(xe,"fill-opacity",o)}catch{}},[s,o,r]),A.useEffect(()=>()=>{if(s)try{s.getLayer(xe)&&s.removeLayer(xe),s.getSource(ve)&&s.removeSource(ve)}catch{}},[s]);const v=(null==c?void 0:c.features.length)??0;return v>0&&r?t.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(null==e?void 0:e.length)||0,"data-cell-count":v,"data-terrain-enabled":n,"data-is-processing":f,style:{display:"none"}}):null}const Me="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",De="terrarium",Ee="terrain-dem",Qe="hillshade-dem",Ne="terrain-hillshade";function je({enabled:e,exaggeration:t=4}){const{current:r}=P(),[n,o]=A.useState(null),i=A.useRef(null);return A.useEffect(()=>{const A=()=>{var A;const e=null==(A=null==r?void 0:r.getMap)?void 0:A.call(r);e&&!n&&o(e)};A();const e=setInterval(A,50),t=setTimeout(()=>clearInterval(e),5e3);return()=>{clearInterval(e),clearTimeout(t)}},[r,n]),A.useEffect(()=>{if(!n)return;let A=!0;const e=()=>{var e,t;if(A)try{if(n.getSource(Qe)||n.addSource(Qe,{type:"raster-dem",tiles:[Me],encoding:De,tileSize:256,maxzoom:14}),!n.getLayer(Ne)){const A=null==(t=null==(e=n.getStyle())?void 0:e.layers)?void 0:t.find(A=>"symbol"===A.type);n.addLayer({id:Ne,type:"hillshade",source:Qe,paint:{"hillshade-shadow-color":"rgba(10, 10, 10, 0.6)","hillshade-highlight-color":"rgba(245, 240, 230, 0.4)","hillshade-accent-color":"rgba(90, 75, 65, 0.3)","hillshade-illumination-direction":315,"hillshade-exaggeration":.35}},null==A?void 0:A.id)}n.getSource(Ee)||n.addSource(Ee,{type:"raster-dem",tiles:[Me],encoding:De,tileSize:256,maxzoom:14})}catch(r){}};return n.isStyleLoaded()?e():(n.once("style.load",e),n.once("load",()=>{A&&!n.getSource(Qe)&&e()})),()=>{A=!1}},[n]),A.useEffect(()=>{if(!n)return;let A=!0,r=!1;const o=()=>{if(A&&n.getSource(Ee))try{e?(n.setCenterClampedToGround(!1),n.setTerrain({source:Ee,exaggeration:t}),n.setMaxPitch(70),!r&&n.getPitch()<30&&!n.isMoving()&&(r=!0,null!==i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,A&&!n.isMoving()&&n.getPitch()<30&&n.easeTo({pitch:45,duration:1e3})},200))):(n.setTerrain(null),n.setCenterClampedToGround(!0),n.getPitch()>0&&!n.isMoving()&&n.easeTo({pitch:0,duration:800}),n.setMaxPitch(60))}catch(o){}};if(n.isStyleLoaded()&&n.getSource(Ee))o();else{const A=()=>{n.getSource(Ee)&&o()};n.once("idle",A)}return()=>{A=!1,null!==i.current&&(clearTimeout(i.current),i.current=null)}},[n,e,t]),A.useEffect(()=>()=>{var A;try{(null==(A=null==n?void 0:n.getStyle)?void 0:A.call(n))&&n.isStyleLoaded()&&(n.setTerrain(null),n.getLayer(Ne)&&n.removeLayer(Ne),n.getSource(Qe)&&n.removeSource(Qe),n.getSource(Ee)&&n.removeSource(Ee))}catch{}},[n]),null}function Fe(A,e=!1,t=!1,r=!1,n=.7,o){const i=uA(o);return r?n>=.75?i.restBright:i.rest:n>=.85?i.rest:i.restDim}function Se(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 Ie(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function Le(A,e,t,r,n,o,i,a,s,l,c,u="dark"){const f=BA(),d=[];let g=1/0,h=-1/0;const m=[];for(const p of A){const A=.7*(p.edge.avgConfidence??(e?.7:.5))+p.edge.certainCount/Math.max(i,1)*.3+(e?.5:0);m.push({polyline:p,brightnessScore:A}),g=Math.min(g,A),h=Math.max(h,A)}if(0===m.length)return{type:"FeatureCollection",features:[]};const b=h-g||1;m.sort((A,e)=>A.brightnessScore-e.brightnessScore);for(const{polyline:p,brightnessScore:v}of m){const{from:A,to:i,edge:h}=p,m=t.get(h.key)??0;if(m<=0)continue;const x=a.has(h.key),w=s.has(h.key),y=h.avgConfidence??(e?.7:.5),k=l===h.key,C=c[h.fromHash],B=c[h.toHash],M=(null==C?void 0:C.node_name)||(null==C?void 0:C.name)||h.fromHash.slice(0,8),D=(null==B?void 0:B.node_name)||(null==B?void 0:B.name)||h.toHash.slice(0,8),E=[A[0]+(i[0]-A[0])*m,A[1]+(i[1]-A[1])*m];let Q,N,j,F;if(e){const A=o.get(h.key)??wA(h.certainCount),e=n.get(h.key)??A;Q=e+(A-e)*r,k?Q=Math.max(1.6*Q,4.5):w&&(Q*=1.3)}else Q=1.5;if(N=k?f.edges.highlight:Fe(0,h.isDirectPathEdge??!1,x,w,y,u),j=k?f.edges.highlight:h.isDirectPathEdge?f.edges.hoverDirect:x?f.edges.hoverLoop:f.edges.hoverStandard,e){const A=Math.min(1.5*m,1)*f.edgeOpacity;F=w?1.15*A:A}else F=(.3+.3*y)*m;k&&(F=.95);const S=(v-g)/b;d.push({type:"Feature",properties:{key:h.key,baseColor:N,hoverColor:j,baseWidth:Q,baseOpacity:F,brightnessScore:S,isLoopEdge:x,isBackbone:w,isDirectPath:h.isDirectPathEdge??!1,isHubConnection:h.isHubConnection??!1,isZeroHop:h.isZeroHop??!1,isValidated:e,certainCount:h.certainCount,confidence:y,symmetryRatio:h.symmetryRatio??1,dominantDirection:h.dominantDirection??"balanced",fromName:M,toName:D,fromHash:h.fromHash,toHash:h.toHash},geometry:{type:"LineString",coordinates:[Se(A),Se(E)]}})}return{type:"FeatureCollection",features:d}}function Re(A,e){const t=BA(),r=[];let n=0;for(const o of A){const A=e.get(o.hash);A&&A.blendedScore>n&&(n=A.blendedScore)}for(const o of A){const{from:A,to:i,hash:a,neighbor:s,lastHopData:l}=o,c=`neighbor-${a}`,u=(null==l?void 0:l.avgRssi)??s.rssi??null,f=(null==l?void 0:l.avgSnr)??s.snr??null,d=(null==l?void 0:l.count)??0,g=(null==l?void 0:l.confidence)??1,h=e.get(a),m=(null==h?void 0:h.listenerScore)??0,b=(null==h?void 0:h.loudScore)??0,p=(null==h?void 0:h.blendedScore)??0,v=n>0?p/n:0,x=o.rxAdvertCount??0,w=o.txProxyCount??0,y=x+w,k=y>0?(w-x)/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:f,packetCount:d,confidence:g,hasAvgRssi:void 0!==(null==l?void 0:l.avgRssi),hasAvgSnr:void 0!==(null==l?void 0:l.avgSnr),isNeighborEdge:!0,listenerScore:m,loudScore:b,blendedScore:p,trafficWeight:v,linkAsymmetry:k,rxAdvertCount:x,txProxyCount:w},geometry:{type:"LineString",coordinates:C}})}return{type:"FeatureCollection",features:r}}function Te(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function _e(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 He(A,e,t){const r=t?$(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 ze="edge-blink-source",Ge="edge-blink-layer",Oe=1e3,Ue=1e3,Ye="node-markers-layer";function We(A){return A<0||A>=Oe?0:1-A/Oe}function Ve(A){if(A<0)return 0;if(A>=Ue)return 0;const e=A/Ue;return Math.pow(1-e,3)}function Ze(A){return[A[1],A[0]]}function Ke(A){const e=new Date(1e3*A);return`${(e.getMonth()+1).toString().padStart(2,"0")}/${e.getDate().toString().padStart(2,"0")}`}function Je({hash:e,hashPrefix:n,name:o,isHub:i,isGateway:a,isBackbone:s,isZeroHop:l,isMobile:c,isRoomServer:u,isStale:f,lastSeenTimestamp:d,centrality:g,affinity:h,meanSnr:m,meanRssi:b,neighbor:p,onRemove:v,txDelayRec:x}){const w=fA(),[y,k]=A.useState(!1),C=l?"Direct":(null==h?void 0:h.typicalHopPosition)?`${h.typicalHopPosition}-hop`:null,B=x&&!x.insufficientData,M={hub:{color:"var(--accent-secondary)",title:"Hub: High-connectivity node that bridges many paths"},backbone:{color:"var(--map-hub-color)",title:"Backbone: Critical relay with high traffic"},relay:{color:"var(--accent-tertiary)",title:"Relay: Standard forwarding node"},edge:{color:"var(--text-muted)",title:"Edge: Peripheral node"}},D={high:{color:"var(--accent-success)",title:"1000+ packets"},medium:{color:"var(--accent-secondary)",title:"500-999 packets"},low:{color:"var(--accent-danger)",title:"100-499 packets"},insufficient:{color:"var(--text-muted)",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),k(!0),setTimeout(()=>k(!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"),k(!0),setTimeout(()=>k(!1),1500)}catch{}document.body.removeChild(t)}},className:"p-0.5 hover:bg-[#252525] rounded transition-colors",title:"Copy full hash",children:y?t.jsx(r,{className:"w-3 h-3 text-accent-success"}):t.jsx(I,{className:"w-3 h-3 text-text-secondary"})}),t.jsx(vA,{hash:e,size:"sm"}),C&&t.jsx("span",{className:"color-pill color-pill-compact "+(l?"color-pill-filled":""),style:l?{"--pill-color":"var(--accent-secondary)","--pill-text":"rgba(0,0,0,0.9)"}:{"--pill-color":"var(--text-muted)"},children:C}),p.is_repeater&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--accent-tertiary)"},children:"Rptr"}),i&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":w.hubColor,"--pill-text":"#fff"},title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),a&&!i&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":w.hubColor,"--pill-text":"#fff",opacity:.8},title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),s&&t.jsx("span",{className:"color-pill color-pill-compact color-pill-filled",style:{"--pill-color":"var(--map-hub-color)","--pill-text":"#fff"},title:"Backbone",children:"Bone"}),c&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--map-mobile-color)"},children:"Mobile"}),u&&t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--map-room-color)"},children:"Room"}),f&&d&&t.jsxs("span",{className:"color-pill color-pill-compact",style:{"--pill-color":"var(--text-muted)"},title:"Neighbor not heard in 7+ days",children:["Idle ",Ke(d)]})]}),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(L,{className:"w-3 h-3 text-text-muted shrink-0"}),t.jsx("span",{className:"font-mono",children:eA(p.last_seen)})]}),(null==h?void 0:h.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:(E=h.distanceMeters,null===E?"—":E<1e3?`${Math.round(E)}m`:`${(E/1e3).toFixed(1)}km`)})]}),p.latitude&&p.longitude&&0!==p.latitude&&0!==p.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:[p.latitude.toFixed(2),", ",p.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-1",children:[t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Packets"}),t.jsx("span",{className:"data-box data-box-compact",children:(null==h?void 0:h.frequency)||0})]}),l&&void 0!==m&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"SNR"}),t.jsxs("span",{className:"data-box data-box-compact",children:[m.toFixed(1)," dB"]})]}),B&&x.networkRole&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Role"}),t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":M[x.networkRole].color},title:M[x.networkRole].title,children:x.networkRole})]})]}),t.jsxs("div",{className:"flex-1 space-y-1",children:[t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Adverts"}),t.jsx("span",{className:"data-box data-box-compact",children:p.advert_count||0})]}),l&&void 0!==b&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"RSSI"}),t.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(b)," dBm"]})]}),B&&x.dataConfidence&&t.jsxs("div",{className:"flex justify-between items-center gap-2",children:[t.jsx("span",{className:"text-text-muted",children:"Data"}),t.jsx("span",{className:"color-pill color-pill-compact",style:{"--pill-color":D[x.dataConfidence].color},title:D[x.dataConfidence].title,children:x.dataConfidence})]})]}),!B&&v&&t.jsx("button",{onClick:v,className:"p-1 self-start text-text-secondary hover:text-red-400 hover:bg-red-500/10 rounded transition-colors",title:"Remove from contacts",children:t.jsx(F,{className:"w-3.5 h-3.5"})})]}),B&&t.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 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-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-text-muted",children:"F"}),t.jsxs("span",{className:"data-box data-box-compact text-amber-400",children:["×",(x.floodFactor??x.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:"data-box data-box-compact text-amber-400",children:["×",(x.directFactor??x.directTxDelayFactor).toFixed(1)]})]})]})]}),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(F,{className:"w-3.5 h-3.5"})})]})]});var E}const Xe="node-markers-native",qe="node-markers-layer",$e="node-markers-layer-local",At="marker-standard",et="marker-standard-neighbor",tt="marker-hub",rt="marker-hub-neighbor",nt="marker-gateway",ot="marker-gateway-neighbor",it="marker-mobile",at="marker-mobile-neighbor",st="marker-room-server",lt="marker-room-server-neighbor",ct="marker-local",ut="marker-blink-black",ft="marker-blink-black-local",dt="marker-blink",gt="marker-blink-local";function ht(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 mt(A){return A.startsWith("0x")?A.slice(2,4).toUpperCase():A.slice(0,2).toUpperCase()}function bt({neighborsWithLocation:e,localNode:r,localHash:n,zeroHopNeighbors:o,lastHopNeighborMap:i,meshTopology:a,hoveredMarker:s,onMarkerHover:l,getNodeOpacity:c,shouldShowNode:u,onRequestRemove:f,openPopupId:d,onOpenPopup:g,onClosePopup:h,blinkingNodes:m}){const{current:b}=P(),p=A.useRef(!1),[v,x]=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=()=>{try{!function(A){const e=cA(),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={[At]:t(e.nodeFill,e.nodeStroke,1.5),[et]:t(e.neighborColor),[tt]:t(e.hubColor),[rt]:t(e.neighborColor),[nt]:t(e.hubColor+"B3"),[ot]:t(e.neighborColor),[it]:t("transparent",e.mobileColor,2),[at]:t(e.neighborColor),[st]:n(e.roomColor),[lt]:n(e.neighborColor,"#1a1a1c"),[ct]:r(e.localColor),[ut]:t("#000000"),[ft]:r("#000000"),[dt]:t(o,void 0,0,!0),[gt]: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||x(!0)}catch(A){}};e.isStyleLoaded()?t():e.once("style.load",t);const r=()=>{e.hasImage(At)||t()};e.on("styledata",r);const n=()=>{p.current=!1,t()},o=new MutationObserver(A=>{for(const e of A)if("data-theme"===e.attributeName){setTimeout(n,100);break}});return o.observe(document.documentElement,{attributes:!0}),()=>{e.off("styledata",r),o.disconnect()}},[b,v]);const w=A.useMemo(()=>{var A;const t=[],r=[...e].sort(([A,e],[t,r])=>{const n=(A,e)=>{var t;return ht(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),f=a.hubNodes.includes(e),d=(null==(A=a.gatewayNodes)?void 0:A.includes(e))??!1,g=a.mobileNodes.includes(e),h=ht(n),m=a.centrality.get(e)||0,b=i.get(e),p="stale"===(null==b?void 0:b.status),v=p?Math.min(s,.5):s;let x="standard";h?x="roomServer":f?x="hub":d?x="gateway":g&&(x="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:mt(e),iconType:x,isNeighbor:l,isHub:f,isGateway:d,isMobile:g,isRoomServer:h,isStale:p,isZeroHop:l,opacity:v,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?mt(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||!v)return;const t=[qe,$e];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,v,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||!v||!m||0===m.size)return;const t=e.getSource(Xe),r=e.getSource(`${Xe}-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,v,m,n]);const E=A.useMemo(()=>{if(!d)return null;if("local"===d&&r)return{longitude:r.longitude,latitude:r.latitude,isLocal:!0,name:r.name,hash:n};const A=w.features.find(A=>A.properties.hash===d);if(!A)return null;const e=A.properties,t=e.txDelayRecJson?JSON.parse(e.txDelayRecJson):void 0;return{longitude:A.geometry.coordinates[0],latitude:A.geometry.coordinates[1],isLocal:!1,hash:e.hash,hashPrefix:e.hashPrefix,name:e.name,isHub:e.isHub,isGateway:e.isGateway,isBackbone:"backbone"===(null==t?void 0:t.networkRole),isZeroHop:e.isZeroHop,isMobile:e.isMobile,isRoomServer:e.isRoomServer,isStale:e.isStale,lastSeenTimestamp:e.lastSeenTimestamp,centrality:e.centrality,neighbor:e.neighborJson?JSON.parse(e.neighborJson):void 0,affinity:e.affinityJson?JSON.parse(e.affinityJson):void 0,txDelayRec:t,meanSnr:e.meanSnr,meanRssi:e.meanRssi}},[d,r,n,w]);if(!v)return null;const Q=cA(),N=["case",[">",["get","blinkIntensity"],.66],dt,[">",["get","blinkIntensity"],.33],ut,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],lt,st],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],rt,tt],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],ot,nt],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],at,it],["case",["get","isNeighbor"],et,At]],j=["interpolate",["linear"],["zoom"],6,.25,10,1];return t.jsxs(t.Fragment,{children:[t.jsx(H,{id:Xe,type:"geojson",data:w,children:t.jsx(z,{id:qe,type:"symbol",layout:{"icon-image":N,"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":["get","opacity"]}})}),t.jsx(H,{id:`${Xe}-local`,type:"geojson",data:y,children:t.jsx(z,{id:$e,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],gt,[">",["get","blinkIntensity"],.33],ft,ct],"icon-size":j,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),E&&h&&t.jsx(G,{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:mt(E.hash)}),t.jsx("br",{}),t.jsx("span",{style:{color:Q.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(Je,{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:f?()=>f(E.hash,E.name):void 0}):null})]})}const pt=[qe,$e];A.createContext(null);const vt="topology-validated-edges-native",xt="topology-weak-edges-native",wt="neighbor-edges-native",yt="topology-weak-edges-native",kt="topology-validated-edges-native",Ct="neighbor-edges-native",Bt={type:"FeatureCollection",features:[]},Mt={"line-cap":"round","line-join":"round"},Dt={"line-color":"transparent","line-width":16,"line-opacity":0};function Et({showTopology:e,isExiting:r,hoveredEdgeKey:n,highlightedLoopEdges:o,onEdgeHover:i,onLoopHover:a,loops:s=[],neighborNames:l={},opacityBias:c=.5,widthMultiplier:u=1,trafficFilter:f=0,showNeighborLines:d=!0,disableHover:g=!1}){const{current:h}=P(),m=e||r,b=!0,p=d?"visible":"none",v=g||r,x=A.useRef(null),w=A.useRef(v),y=A.useRef(new Map),k=A.useRef(l),C=A.useRef(a);A.useLayoutEffect(()=>{w.current=v,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!==x.current){x.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!==x.current&&(x.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||!d)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,d,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(Ct,"node-markers-layer"),r("neighbor-edges-hitarea-native",Ct),(r(kt,"neighbor-edges-hitarea-native")||r(kt,"node-markers-layer"))&&r("topology-validated-edges-hitarea-native",kt),r(yt,"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===vt||A.sourceId===xt||A.sourceId===wt)&&o()};return e.on("sourcedata",a),()=>{clearTimeout(i),t&&clearTimeout(t);try{e.off("styledata",o),e.off("sourcedata",a)}catch{}}},[h,m,b,d]);const E=v?null:n,Q=function(A,e,t,r,n){const o=BA(),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],f=i||a,d=o.edges.hoverLoop??"#A78BFA";return{"line-color":f?["case",u,a?d:["get","hoverColor"],l]:l,"line-width":f?["case",u,["max",["*",["get","baseWidth"],t,1.3],3.5],["*",["get","baseWidth"],t]]:["*",["get","baseWidth"],t],"line-opacity":["case",["<",["get","brightnessScore"],r],0,f?["case",u,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],c,.35]]:["*",["get","baseOpacity"],c]]}}(E,c,u,f,v?null:o),N=function(A){const e=null!==A,{YELLOW:t,GREEN:r,RED:n,GRAY:o}=Y,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(H,{id:xt,type:"geojson",data:Bt,children:t.jsx(z,{id:yt,type:"line",paint:Q,layout:Mt})}),m&&t.jsxs(H,{id:vt,type:"geojson",data:Bt,children:[t.jsx(z,{id:"topology-validated-edges-hitarea-native",type:"line",paint:Dt,layout:Mt}),t.jsx(z,{id:kt,type:"line",paint:Q,layout:Mt})]}),t.jsxs(H,{id:wt,type:"geojson",data:Bt,children:[t.jsx(z,{id:"neighbor-edges-hitarea-native",type:"line",paint:Dt,layout:{...Mt,visibility:p}}),t.jsx(z,{id:Ct,type:"line",paint:N,layout:{...Mt,visibility:p}})]})]})}const Qt=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function Nt({targetHash:e,nodeCoordinates:t,onComplete:r}){const{current:n}=P(),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 jt({highlightedEdgeKey:e,validatedPolylines:t,weakPolylines:r,onEnsureTopology:n}){const{current:o}=P(),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 Ft(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 St(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}=P(),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:[St(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(H,{id:"ghost-uncertainty-circle",type:"geojson",data:c,children:t.jsx(z,{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))}(CA.edges.neighborHover);const It={version:8,sources:{},layers:[],glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf"},Lt={longitude:0,latitude:0,zoom:2};function Rt(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 Tt({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 _t({neighbors:e,localNode:r,localHash:n,onRemoveNode:o,selectedNodeHash:i,onNodeSelected:a,highlightedEdgeKey:s,highlightedGhost:l}){const c=A.useRef(null),u=tA(),f=rA(),d=nA(),g=oA(),h=iA(),[m,b]=A.useState(!1),p=aA(A=>A.preloadFromNodes),v=aA(A=>A.isLoading),x=aA(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:Rt(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[d,g]of t)r=Math.min(r,g),n=Math.max(n,g),o=Math.min(o,d),i=Math.max(i,d);const a=(r+n)/2,s=(o+i)/2,l=i-o,c=n-r,u=Math.max(l,c);let f=16;return u>0&&(f=Math.floor(Math.log2(360/u*1.2)),f=Math.max(1,Math.min(14,f))),f=Math.min(f+1,12),{longitude:a,latitude:s,zoom:f}}(y,r),[y,r]),[C,B]=A.useState(()=>k??Lt),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),[Q,N]=A.useState(!1),[j,F]=A.useState(!0),[S,P]=A.useState(!1),[I,L]=A.useState(!1),[R,T]=A.useState("all"),[_,H]=A.useState(null),[z,G]=A.useState(null),[Y]=A.useState(0),[V]=A.useState(.5),[Z]=A.useState(0),[K,eA]=A.useState(null),[lA,cA]=A.useState(""),[uA,fA]=A.useState(!1),[dA,gA]=A.useState("fetching"),[hA,vA]=A.useState(!1),[xA,yA]=A.useState(0),[CA,BA]=A.useState(!1),[DA,EA]=A.useState(null),NA=A.useCallback(A=>EA(A),[]),FA=A.useCallback(()=>EA(null),[]),[,SA]=A.useState(new Set),PA=KA(A=>A.coveragePoints),LA=KA(A=>A.isVisible),TA=KA(A=>A.brightness),HA=KA(A=>A.openModal),zA=$A(A=>A.isEnabled),GA=$A(A=>A.toggle),OA=mA(),UA=bA(),YA=A.useRef(!1);A.useEffect(()=>{PA.length>0&&LA&&!YA.current&&(F(!1),YA.current=!0)},[PA.length,LA]);const WA=A.useRef(null);A.useEffect(()=>{if(i&&i!==WA.current){WA.current=i;const A=setTimeout(()=>{EA(i)},1250);return()=>clearTimeout(A)}},[i]);const[VA,ZA]=A.useState(null),[JA,qA]=A.useState(null),Ae=A.useCallback((A,e,t)=>{G(A),A&&e&&t?ZA({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||ZA(null)},[]),ee=A.useCallback((A,e)=>{qA(A),A&&ZA(null)},[]),te=A.useMemo(()=>{var A;if(!Q)return null;if(!_)return null;if(z)return null;const t=u.loops;if(0===t.length)return null;const r=function(A,e,t){const r=function(A,e){return e.filter(e=>e.nodes.includes(A)).sort((A,e)=>e.avgCertainCount-A.avgCertainCount)}(A,e),n=new Set,o=[];for(const i of r)for(const A of i.edgeKeys)if(!n.has(A)){n.add(A);const e=t.get(A);o.push({key:A,certainCount:(null==e?void 0:e.certainCount)??0})}return o.sort((A,e)=>e.certainCount-A.certainCount),{loops:r,highlightedEdgeKeys:n,sortedEdges:o}}(_,t,u.edgeMap);if(0===r.loops.length)return null;const n=r.loops[0].nodes.map(A=>{var t,r;return A===w?"You":(null==(t=e[A])?void 0:t.node_name)||(null==(r=e[A])?void 0:r.name)||A.substring(0,4)});return{loops:r.loops,highlightedEdgeKeys:r.highlightedEdgeKeys,hoveredEdgeKey:(null==(A=r.sortedEdges[0])?void 0:A.key)||"",nodeNames:n}},[Q,_,z,u.loops,u.edgeMap,e,w]);A.useEffect(()=>{z||qA(te)},[te,z]);const re=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]),ne=A.useMemo(()=>Object.entries(e).filter(([,A])=>A.latitude&&A.longitude),[e]),oe=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 ne)t.latitude&&t.longitude&&A.set(e,[t.latitude,t.longitude]);return A},[w,r,ne]),ie=A.useMemo(()=>{const A=new Map;for(const e of d)"expired"!==e.status&&A.set(e.hash,{hash:e.hash,prefix:e.prefix,count:e.count,avgRssi:e.avgRssi,avgSnr:e.avgSnr,lastSeen:e.lastSeen,confidence:1,status:e.status});return A},[d]),ae=A.useMemo(()=>{var A,t;const r=new Set;for(const n of ie.keys())(null==(A=e[n])?void 0:A.latitude)&&(null==(t=e[n])?void 0:t.longitude)&&r.add(n);return r},[ie,e]),se=A.useMemo(()=>{if(0===ae.size||!w)return new Map;const A=X.getPackets();if(0===A.length)return new Map;const e=$(w);return W(A,ae,e).scores},[ae,w,g.packetCount]),le=A.useCallback(A=>!!(w&&(A.fromHash===w&&ae.has(A.toHash)||A.toHash===w&&ae.has(A.fromHash))),[w,ae]),ce=A.useMemo(()=>{var A,t;if(0===d.length||!w)return[];if(g.backgroundLoadComplete)return[];const r=[];for(const n of d){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},[d,w,g.backgroundLoadComplete,e]),ue=A.useMemo(()=>{const A=[];if(ce.length>0&&!g.backgroundLoadComplete){for(const e of ce){const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A}for(const e of u.validatedEdges){if(le(e))continue;const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.validatedEdges,oe,le,ce,g.backgroundLoadComplete]),fe=A.useMemo(()=>{const A=[];for(const e of u.weakEdges){if(le(e))continue;const t=oe.get(e.fromHash),r=oe.get(e.toHash);t&&r&&A.push({from:t,to:r,edge:e})}return A},[u.weakEdges,oe,le]),de=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 d)o.set(e.hash,e.count);for(const r of ae){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:ie.get(r)??null,rxAdvertCount:a,txProxyCount:s})}return A},[r,ae,e,ie,u.lastHopNeighbors,d]),ge=A.useMemo(()=>new Set(u.loopEdgeKeys),[u.loopEdgeKeys]),he=A.useMemo(()=>new Set(u.backboneEdges),[u.backboneEdges]),me=A.useMemo(()=>{let A=0;if(ce.length>0&&!g.backgroundLoadComplete){for(const e of ce)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,ce,g.backgroundLoadComplete]),be=A.useRef(null);A.useLayoutEffect(()=>{var A,e;be.current=(null==(e=null==(A=c.current)?void 0:A.getMap)?void 0:e.call(A))??null});const pe=J(),ve=A.useMemo(()=>X.getPackets(),[pe]);!function({map:e,nodeCoordinates:t,packets:r,localHash:n,neighbors:o,meshTopology:i,enabled:a=!0}){const s=A.useRef(null),l=e&&"current"in e?e.current:e;A.useEffect(()=>{s.current=l},[l]);const c=A.useRef(!1),u=A.useRef(null),f=A.useRef([]),d=A.useRef(0),g=A.useRef(!1),[h,m]=A.useState(!1),b=A.useRef(null),p=A.useRef([]),v=A.useRef(new Map),x=A.useRef(t);A.useEffect(()=>{x.current=t},[t]),A.useEffect(()=>{v.current=function(A,e){const t=new Map;for(const r of Object.keys(A)){const A=$(r);t.has(A)||t.set(A,r)}if(e){const A=$(e);t.set(A,e)}return t}(o,n)},[o,n]),A.useEffect(()=>{if(!a){b.current&&(clearTimeout(b.current),b.current=null),p.current=[],null!==u.current&&(cancelAnimationFrame(u.current),u.current=null),f.current=[];const A=s.current;if(A&&c.current){const e=A.getSource(ze);e&&e.setData({type:"FeatureCollection",features:[]})}g.current=!1,d.current=0}},[a]),A.useEffect(()=>{const A=l;if(!A)return;let e=null,t=!1;const r=()=>{if(!t&&!c.current)try{A.getLayer(Ge)&&A.removeLayer(Ge),A.getSource(ze)&&A.removeSource(ze),A.addSource(ze,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const t=A.getLayer(Ye)?Ye:void 0;A.addLayer({id:Ge,type:"line",source:ze,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(Ge)&&A.removeLayer(Ge),A.getSource(ze)&&A.removeSource(ze)}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(ze);if(!e)return;const t=performance.now(),r=f.current,n=[],o=[];for(const i of r){const A=t-i.startTime-i.delay;if(A<(i.isSpeculative?Ue:Oe)){o.push(i);const e=i.isSpeculative?Ve(A):We(A);e>0&&n.push({type:"Feature",properties:{intensity:e,opacityMult:i.isSpeculative?.5:1,isSpeculative:i.isSpeculative??!1},geometry:{type:"LineString",coordinates:[i.fromCoord,i.toCoord]}})}}e.setData({type:"FeatureCollection",features:n}),f.current=o,o.length>0?u.current=requestAnimationFrame(()=>w.current()):u.current=null}},[]);const y=A.useCallback(()=>{const A=s.current;A&&function(A){if(!A.getLayer(Ge))return;const e=A.getLayer(Ye)?Ye:void 0;try{A.moveLayer(Ge,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=v.current,t=x.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=q(s,n);if(!A||A.original.length<2)continue;const c=A.original;let u=0,d=null;for(let n=0;n0){A.sort((A,e)=>e.confidence-A.confidence);const e=Math.max(1,Math.ceil(.25*A.length)),n=A.slice(0,e),i=o+150*u;for(const{edgeKey:A,otherHash:o}of n){const e=t.get(d),n=t.get(o);f.current.push({edgeKey:A,fromCoord:Ze(e),toCoord:Ze(n),startTime:r,delay:i,isSpeculative:!0}),l.add(A),a=!0}}}u>0&&(o+=150*u*.5)}a&&y()},[n,i,y]);A.useEffect(()=>{const A=s.current;if(!a)return;if(!A)return;if(!h)return;if(0===r.length)return;const e=Date.now(),t=d.current;if(!g.current){g.current=!0;const A=(e-3e4)/1e3,t=r.filter(e=>(e.timestamp??0)>=A);let n=0;for(const e of r){const A=e.timestamp??0;A>n&&(n=A)}if(d.current=n,t.length>0){t.sort((A,e)=>(A.timestamp??0)-(e.timestamp??0));const A=t.slice(-20);p.current.push(...A),k()}return}const n=r.filter(A=>(A.timestamp??0)>t);if(0===n.length)return;let o=0;for(const r of n){const A=r.timestamp??0;A>o&&(o=A)}d.current=o,p.current.push(...n),b.current&&clearTimeout(b.current),b.current=setTimeout(k,175)},[a,r,k,h]),A.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[])}({map:be,nodeCoordinates:oe,packets:ve,localHash:w,neighbors:e,meshTopology:u,enabled:zA});const{isExiting:xe,isAnimating:we,resetAnimationState:ye}=function({map:e,showTopology:t,validatedPolylines:r,weakPolylines:n,maxCertainCount:o,loopEdgeKeys:i,backboneEdgeKeys:a,highlightedEdgeKey:s,neighbors:l,validatedSourceId:c,weakSourceId:u,neighborPolylines:f=[],showNeighborLines:d=!0,neighborSourceId:g,neighborLinkScores:h=new Map,basemapMode:m}){const b=A.useRef(null);A.useEffect(()=>{const A=e&&"current"in e?e.current:e;b.current=A});const p=A.useRef(new Map),v=A.useRef(1),x=A.useRef(new Map),w=A.useRef(new Map),y=A.useRef(!1),k=A.useRef(null),C=A.useRef(t),B=A.useRef(new Set),M=A.useRef(""),D=A.useRef(new Map),E=A.useRef(""),Q=A.useRef(""),N=A.useRef(""),j=A.useRef(r),F=A.useRef(n),S=A.useRef(o),P=A.useRef(i),I=A.useRef(a),L=A.useRef(s),R=A.useRef(l),T=A.useRef(f),_=A.useRef(d),H=A.useRef(h),z=A.useRef(m);A.useEffect(()=>{j.current=r,F.current=n,S.current=o,P.current=i,I.current=a,L.current=s,R.current=l,T.current=f,_.current=d,H.current=h,z.current=m},[r,n,o,i,a,s,l,f,d,h,m]);const G=A.useCallback((A=!1)=>{var e,t,r,n,o,i,a,s,l,f;const d=b.current;if(!d)return;const h=d.getSource(c),m=d.getSource(u),y=d.getSource(g);if(h){const o=Le(j.current,!0,p.current,v.current,x.current,w.current,S.current,P.current,I.current,L.current,R.current,z.current),i=`${o.features.length}:${(null==(t=null==(e=o.features[0])?void 0:e.properties)?void 0:t.key)??""}:${(null==(n=null==(r=o.features[o.features.length-1])?void 0:r.properties)?void 0:n.key)??""}:${Array.from(p.current.values()).reduce((A,e)=>A+e,0).toFixed(2)}`;(A||i!==E.current)&&(h.setData(o),E.current=i)}if(m){const e=Le(F.current,!1,p.current,v.current,x.current,w.current,S.current,P.current,I.current,L.current,R.current,z.current),t=`${e.features.length}:${(null==(i=null==(o=e.features[0])?void 0:o.properties)?void 0:i.key)??""}:${(null==(s=null==(a=e.features[e.features.length-1])?void 0:a.properties)?void 0:s.key)??""}`;(A||t!==Q.current)&&(m.setData(e),Q.current=t)}if(y&&T.current.length>0){const e=Re(T.current,H.current),t=`${e.features.length}:${(null==(f=null==(l=e.features[0])?void 0:l.properties)?void 0:f.hash)??""}`;(A||t!==N.current)&&(y.setData(e),N.current=t)}},[c,u,g]),O=A.useCallback(()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null),p.current=new Map,v.current=1,x.current=new Map,w.current=new Map,y.current=!1,B.current=new Set,M.current="",D.current=new Map},[]);A.useEffect(()=>{const A=C.current,e=t;if(C.current=t,b.current){if(k.current&&(cancelAnimationFrame(k.current),k.current=null),A&&!e&&!y.current){y.current=!0;const A=new Map(p.current);let e=null;const t=r=>{e||(e=r);const n=r-e,o=Math.min(n/500,1),i=(a=o,1-Math.pow(1-a,3));var a;for(const[e,t]of A)p.current.set(e,t*(1-i));G(!0),o<1?k.current=requestAnimationFrame(t):(y.current=!1,p.current=new Map,B.current=new Set,M.current="",x.current=new Map,w.current=new Map,k.current=null,G(!0))};k.current=requestAnimationFrame(t)}!A&&e&&(p.current=new Map,B.current=new Set,M.current="")}},[t,G]),A.useEffect(()=>{const A=b.current;if(!t||y.current||!A)return;const e=[...r,...n],o=e.map(A=>`${A.edge.key}:${A.edge.certainCount}`).sort().join(","),i=0===B.current.size,a=""!==M.current&&M.current!==o;if(!i&&!a)return void G();const s=[],l=[];for(const{edge:t}of e)B.current.has(t.key)?l.push(t.key):s.push(t.key);a&&l.length>0&&(x.current=new Map(D.current),v.current=0),w.current=new Map;for(const{edge:t}of r){const A=wA(t.certainCount);w.current.set(t.key,A)}for(const t of s)p.current.set(t,0);for(const t of l)p.current.has(t)||p.current.set(t,1);if(s.length>0||a&&l.length>0){k.current&&(cancelAnimationFrame(k.current),k.current=null);let A=null;const e=Math.min(100,MA/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/MA,1);v.current=Ie(A)}G(!0);const o=MA+(s.length-1)*e;k.current=n{const A=b.current;if(!A||!g)return;const e=()=>{const e=A.getSource(g);if(!e)return!1;if(f.length>0){const A=Re(f,h);e.setData(A)}else e.setData({type:"FeatureCollection",features:[]});return!0};if(e())return;const t=r=>{r.sourceId===g&&e()&&A.off("sourcedata",t)};A.on("sourcedata",t);const r=()=>{e()&&(A.off("styledata",r),A.off("sourcedata",t))};return A.on("styledata",r),()=>{A.off("sourcedata",t),A.off("styledata",r)}},[g,f,h]);const U=A.useRef(m);return A.useEffect(()=>{m!==U.current&&(U.current=m,E.current="",Q.current="",N.current="",G(!0))},[m,G]),A.useEffect(()=>()=>{k.current&&(cancelAnimationFrame(k.current),k.current=null)},[]),{isExiting:y.current,isAnimating:null!==k.current,resetAnimationState:O,weightAnimProgress:v.current,animStartWeights:x.current,animTargetWeights:w.current}}({map:be,showTopology:Q,validatedPolylines:ue,weakPolylines:fe,maxCertainCount:me,loopEdgeKeys:ge,backboneEdgeKeys:he,highlightedEdgeKey:s,neighbors:e,validatedSourceId:vt,weakSourceId:xt,neighborPolylines:de,showNeighborLines:j,neighborSourceId:wt,neighborLinkScores:se,basemapMode:OA}),ke=A.useMemo(()=>{const A=new Set;for(const e of u.hubNodes){A.add(e);for(const t of u.validatedEdges)t.fromHash===e&&A.add(t.toHash),t.toHash===e&&A.add(t.fromHash)}return A},[u.hubNodes,u.validatedEdges]),Ce=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:Me}=function({soloDirect:e,soloHubs:t,neighborHashes:r,hubConnectedNodes:n,directNodeSet:o,localConnectedNodes:i,showTopology:a}){const[s,l]=A.useState(new Map),c=A.useRef(e),u=A.useRef(t),f=A.useRef(new Map),d=A.useRef(null),g=A.useRef(n),h=A.useRef(o),m=A.useRef(i),b=A.useRef(a);return A.useEffect(()=>{g.current=n,h.current=o,m.current=i,b.current=a},[n,o,i,a]),A.useEffect(()=>{const A=c.current,n=u.current,o=e,i=t;if(c.current=e,u.current=t,A===o&&n===i)return;d.current&&(cancelAnimationFrame(d.current),d.current=null);const a=g.current,s=h.current,p=m.current,v=b.current;for(const e of r)f.current.has(e)||f.current.set(e,Math.random());const x=(A,e,t)=>{const r=a.has(A),n=s.has(A),o=v&&p.has(A);return!e&&!t||(e&&t?r||n||o:t?r:!e||n||o)},w=[];for(const e of r){const t=x(e,A,n),r=x(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*(f.current.get(r)??0),a=Math.max(0,e-i),s=Math.min(a/500,1),l=n+(o-n)*Te(s);A.set(r,l),s<1&&(t=!1)}return A}),e<750&&!t?d.current=requestAnimationFrame(C):(d.current=null,l(new Map))};return d.current=requestAnimationFrame(C),()=>{d.current&&(cancelAnimationFrame(d.current),d.current=null)}},[e,t,r]),{nodeOpacities:s,getNodeOpacity:(A,e)=>s.has(A)?s.get(A):e?1:0}}({soloDirect:"direct"===R,soloHubs:"hubs"===R,neighborHashes:ne.map(([A])=>A),hubConnectedNodes:ke,directNodeSet:ae,localConnectedNodes:Ce,showTopology:Q}),{blinkingNodes:De,blinkColor:Ee}=function({neighbors:e,localHash:t,enabled:r=!0}){const[n,o]=A.useState(new Map),i=J(),a=A.useRef(X.getPackets());A.useEffect(()=>{a.current=X.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=$(t);e.has(A)||e.set(A,t)}return e}(e)},[e]);const f=A.useRef(null);return A.useEffect(()=>{f.current=()=>{const A=performance.now(),e=c.current;if(0===e.size)return l.current=null,void o(new Map);const t=new Map,r=[];for(const[n,{startTime:o,staggerDelay:i}]of e){const e=A-o-i;if(e<0);else if(e>=750)r.push(n);else{const A=_e(e,750);A>0&&t.set(n,A)}}for(const n of r)e.delete(n);o(t),e.size>0&&f.current?l.current=requestAnimationFrame(f.current):l.current=null}},[]),A.useEffect(()=>{if(!r)return;const A=a.current;if(0===A.length)return;const e=s.current,n=A.filter(A=>(A.timestamp??0)>e);if(0===e){const e=A.reduce((A,e)=>Math.max(A,e.timestamp??0),0);return void(s.current=e)}if(0===n.length)return;const o=n.reduce((A,e)=>Math.max(A,e.timestamp??0),0);s.current=o;const i=performance.now();let d=0;for(const r of n){const A=q(r,t);if(!A||0===A.original.length)continue;const e=He(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:zA}),Qe=A.useCallback(A=>{if("all"===R)return!0;if("direct"===R)return ae.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,ae,u.hubNodes,u.validatedEdges]);A.useEffect(()=>{"fetching"===dA&&(g.loadProgress?yA(g.loadProgress.loaded):g.packetCount>0&&yA(g.packetCount))},[dA,g.loadProgress,g.packetCount]);const Ne=A.useCallback(async()=>{vA(!0),fA(!0),gA("fetching"),yA(0),await f(),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)),fA(!1),vA(!1),ye(),BA(!0),setTimeout(()=>{N(!0)},150)},[f,ye]),Fe=A.useCallback(()=>{CA?N(A=>!A):Ne()},[CA,Ne]),Se=A.useCallback(A=>{B(A.viewState),(A.viewState.pitch??0)>10&&!I&&L(!0)},[I]),Pe=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})},[]),Ke=A.useCallback(A=>{T(A)},[]),Je=A.useCallback(()=>{F(A=>!A)},[]),Xe=A.useCallback(()=>{P(A=>!A)},[]),qe=A.useCallback(()=>{L(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})},[]),$e=A.useCallback(()=>{Q||N(!0)},[Q]),At=A.useCallback((A,e)=>{eA(A),cA(e)},[]),et=A.useCallback(()=>{K&&o&&o(K),eA(null),cA("")},[K,o]),tt=A.useMemo(()=>[...Qt,...pt],[]),rt=A.useRef(!1);A.useEffect(()=>{rt.current="ontouchstart"in window||navigator.maxTouchPoints>0},[]);const nt=A.useCallback(A=>{!rt.current||!VA||A.features&&0!==A.features.length||(ZA(null),G(null))},[VA]),ot=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),ZA(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&&ZA({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]),it=A.useCallback(()=>{var A;G(null),ZA(null);try{(null==(A=c.current)?void 0:A.getCanvas())&&(c.current.getCanvas().style.cursor="")}catch{}},[]),at=D?"map-container-fullscreen":"map-container-16-9",st=y.length>0||(null==r?void 0:r.latitude)&&(null==r?void 0:r.longitude),lt=!m||!st,ct=st;return t.jsxs("div",{className:`relative ${at}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":OA,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."}),lt&&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..."})]})}),ct&&t.jsx("div",{className:`relative w-full h-full ${D?"":"rounded-[1.125rem] overflow-hidden"} ${lt?"opacity-0":"opacity-100 transition-opacity duration-300"}`,children:t.jsxs(O,{ref:c,...C,onMove:Se,mapStyle:It,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:tt,onMouseMove:ot,onMouseLeave:it,onClick:nt,onError:A=>{},onIdle:()=>{if(!x&&!v&&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(U,{position:"bottom-right"}),t.jsx(pA,{mode:OA}),t.jsx(je,{enabled:I,exaggeration:4}),t.jsx(Be,{coveragePoints:PA,visible:PA.length>0&&LA,terrainEnabled:I,brightness:TA,basemapMode:OA}),t.jsx(Et,{showTopology:Q,isExiting:xe,hoveredEdgeKey:z,highlightedLoopEdges:null==JA?void 0:JA.highlightedEdgeKeys,onEdgeHover:Ae,onLoopHover:ee,loops:u.loops,neighborNames:re,opacityBias:Y,widthMultiplier:V,trafficFilter:Z,showNeighborLines:j,disableHover:we||hA}),i&&t.jsx(Nt,{targetHash:i,nodeCoordinates:oe,onComplete:a}),s&&t.jsx(jt,{highlightedEdgeKey:s,validatedPolylines:ue,weakPolylines:fe,onEnsureTopology:$e}),t.jsx(Pt,{ghost:l??null,neighborCoordinates:oe,onHighlightedNeighborsChange:SA}),t.jsx(bt,{neighborsWithLocation:ne,localNode:r,localHash:n,zeroHopNeighbors:ae,lastHopNeighborMap:ie,meshTopology:u,hoveredMarker:_,onMarkerHover:H,getNodeOpacity:Me,shouldShowNode:Qe,onRequestRemove:o?At:void 0,openPopupId:DA,onOpenPopup:NA,onClosePopup:FA,blinkingNodes:De,blinkColor:Ee})]})}),(()=>{const A=function(A,e,t){if(e){const A=e.loops[0],t=e.loops.length,r=[{label:"hops",value:A.size},{label:"seen",value:A.minCertainCount}],n=[];return A.includesLocal&&n.push({text:"★ Includes your node",color:"text-amber-400"}),t>1&&n.push({text:`+${t-1} overlapping`,color:"text-violet-400/70"}),{type:"loop",title:{icon:"⟳",text:"Redundant Path"+(t>1?"s":""),color:"text-violet-400"},subtitle:{text:`${e.nodeNames.join(" → ")} → ${e.nodeNames[0]}`,color:"text-text-secondary",mono:!0},stats:r,badges:n}}if("neighbor"===(null==A?void 0:A.type)){const e=A.properties,t=[];void 0!==e.rssi&&null!==e.rssi&&t.push({label:"RSSI",value:`${Math.round(e.rssi)} dBm`,unit:e.hasAvgRssi?"avg":void 0}),void 0!==e.snr&&null!==e.snr&&t.push({label:"SNR",value:`${Number(e.snr).toFixed(1)} dB`,unit:e.hasAvgSnr?"avg":void 0});const r=e.listenerScore??0,n=e.loudScore??0,o=r>0||n>0;return o&&(t.push({label:"listener",value:r,color:"text-accent-success"}),t.push({label:"loud",value:n,color:"text-accent-danger"})),void 0===e.packetCount||o||t.push({label:"packets",value:Number(e.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:e.prefix?`${e.name} (${e.prefix})`:e.name,color:"text-amber-400"},subtitle:{text:"Direct RF Neighbor",color:"text-amber-400/70"},stats:t,badges:[]}}if("topology"===(null==A?void 0:A.type)){const e=A.properties,r=t>0?Number(e.certainCount)/t:0,n=[{label:"validations",value:e.certainCount},{label:"of max traffic",value:`${Math.round(100*r)}%`},{label:"confidence",value:`${Math.round(100*Number(e.confidence))}%`}];if(void 0!==e.symmetryRatio&&e.symmetryRatio<1){const A="forward"===e.dominantDirection?"→":"reverse"===e.dominantDirection?"←":"↔";n.push({label:"symmetric",value:`${A} ${Math.round(100*e.symmetryRatio)}%`,color:"text-text-muted"})}const o=[];return e.isBackbone&&o.push({text:"Backbone",color:"text-gray-300"}),e.isLoopEdge&&o.push({text:"Redundant",color:"text-violet-400"}),e.isDirectPath&&o.push({text:"Direct Path",color:"text-teal-400"}),{type:"topology",title:{icon:"",text:`${e.fromName} ↔ ${e.toName}`,color:"text-text-primary"},stats:n,badges:o}}return null}(VA?{type:VA.type,properties:VA.properties}:null,JA,me);return A&&t.jsx("div",{className:"map-edge-tooltip",children:t.jsx("div",{className:"map-control-glass map-edge-tooltip-inner",children:t.jsx(Tt,{data:A})})})})(),t.jsx(jA,{mapRef:c,showNeighborLines:j,onToggleNeighborLines:Je,hasNeighborPolylines:de.length>0,nodeFilter:R,onNodeFilterChange:Ke,hasHubNodes:u.hubNodes.length>0,hasZeroHopNeighbors:ae.size>0,showCoverage:S,onToggleCoverage:Xe,show3DTerrain:I,onToggle3DTerrain:qe,basemapMode:OA,onToggleBasemap:UA,isFullscreen:D,onToggleFullscreen:Pe}),t.jsxs("div",{className:"map-legend-stack",children:[t.jsx(IA,{isActive:Q,hasAnalyzed:CA,isLoading:hA,onClick:Fe}),t.jsx(RA,{isActive:zA,onClick:GA}),t.jsx(_A,{isActive:PA.length>0&&LA,onClick:HA}),t.jsx(QA,{showTopology:Q,validatedPolylineCount:ue.length,filteredNeighborCount:ne.length,hasLocalNode:!(!(null==r?void 0:r.latitude)||!(null==r?void 0:r.longitude)),meshTopology:u,zeroHopNeighbors:ae,neighborsWithLocation:ne})]}),!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(sA,{isOpen:null!==K,onCancel:()=>eA(null),onConfirm:et,title:"Remove Node?",message:`Remove "${lA}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),t.jsx(kA,{isOpen:uA,currentStep:dA,packetCount:xA}),t.jsx(XA,{})]})}export{_t as default}; diff --git a/frontend/dist/assets/Dashboard-D0ZyJ9cS.js b/frontend/dist/assets/Dashboard-DPV4UcXa.js similarity index 99% rename from frontend/dist/assets/Dashboard-D0ZyJ9cS.js rename to frontend/dist/assets/Dashboard-DPV4UcXa.js index 40bbc138..dc9d88ca 100644 --- a/frontend/dist/assets/Dashboard-D0ZyJ9cS.js +++ b/frontend/dist/assets/Dashboard-DPV4UcXa.js @@ -1 +1 @@ -import{r as e,j as t,y as s,T as a,z as n,A as l,p as i,g as r,D as o,x as c,E as d,H as u,I as m,J as x,K as h,O as p,Q as f,Z as v,U as g,V as j,W as b,Y as N}from"./vendor-react-DtVWNgeu.js";import{u as y,a as k,b as w,c as M,w as _,d as S,L,e as C,f as R,h as D,D as F,j as B,k as T,T as A,m as $,n as P,o as I,p as H,q as E,F as W,v as q}from"./index-BIsccma_.js";import{u as O,a as z}from"./useThemeColors-DaJMJYCA.js";import{C as G,S as K,a as U,P as J,b as V,c as Q}from"./PageLayout-CG02PCA-.js";import{P as X,a as Y,b as Z}from"./PacketDetailModal-ZVXSkr9b.js";import{T as ee}from"./TimeRangeSelector-CzmnykND.js";import{D as te}from"./DataBox-Dl3NmnnB.js";import{s as se}from"./SignalIndicator-DagI_WOB.js";import{R as ae,L as ne,Y as le,a as ie,A as re,C as oe,X as ce,T as de,b as ue}from"./recharts-C9LxPobD.js";import{c as me}from"./link-scoring-v5IA77Bo.js";import{R as xe,C as he}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./useScientificColormap-nDz0kTVE.js";const pe={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)"}},fe={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function ve({buckets:s,colorType:a}){const n=pe[a].barBase,l=e.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=s.length/60,t=e<=1?s:Array.from({length:60},(t,a)=>{var n,l;const i=s.slice(Math.floor(a*e),Math.floor((a+1)*e)),r=i.reduce((e,t)=>e+t.count,0),o=i.length?i.reduce((e,t)=>e+t.avg_snr,0)/i.length:0;return{bucket:a,start:(null==(n=i[0])?void 0:n.start)??0,end:(null==(l=i.at(-1))?void 0:l.end)??0,count:r,airtime_ms:i.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),a=t.map(e=>e.count).filter(e=>e>0);if(0===a.length)return t.map(()=>({height:0,bottom:0,color:"transparent",count:0,snr:0}));const l=Math.max(...a),i=Math.min(...a),r=l-i;return 0===r?t.map(e=>({height:e.count>0?40:0,bottom:e.count>0?30:0,color:e.count>0?n:"transparent",count:e.count,snr:e.avg_snr})):t.map(e=>{if(0===e.count)return{height:0,bottom:0,color:"transparent",count:0,snr:e.avg_snr};const t=(e.count-i)/r,s=25*t;return{height:Math.max(15,25+60*t),bottom:s,color:n,count:e.count,snr:e.avg_snr}})},[s,n]);return(null==s?void 0:s.length)?t.jsx("div",{className:"w-full h-full relative",children:l.map((e,s)=>{var a;return t.jsx("div",{className:"absolute rounded-full",style:{height:`${e.height}%`,bottom:`${e.bottom}%`,left:7*s+"px",width:"5px",backgroundColor:e.color,opacity:e.count>0?.8:.1},title:e.count>0?`${e.count} packets, SNR: ${null==(a=e.snr)?void 0:a.toFixed(1)}dB`:"No packets"},s)})}):t.jsx("div",{className:"w-full h-full flex items-end justify-center gap-[2px] opacity-20",children:t.jsx("span",{className:"type-data-xs text-text-secondary",children:"No data"})})}function ge({title:s,value:a,color:n="neutral",subtitle:l,buckets:i,receivedCount:r,timeRangeLabel:o,icon:c,size:d="md",isLoaded:u=!0}){const m="string"==typeof a?a:a.toLocaleString(),x=e.useMemo(()=>function(e){if(!(null==e?void 0:e.length))return null;const t=e.reduce((e,t)=>e+t.count,0),s=e[0].start,a=e[e.length-1].end,n=Math.max((a-s)/3600,1),l=Math.round(t/n);let i=0,r=0;for(let d=0;dr&&(r=e[d].count,i=d);const o=new Date(1e3*e[i].start).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),c=e.filter(e=>e.count>0&&0!==e.avg_snr);return{total:t,ratePerHour:l,peakCount:r,peakHour:o,avgSnr:c.length>0?c.reduce((e,t)=>e+t.avg_snr,0)/c.length:null}}(i),[i]),h="number"==typeof a?a:(null==x?void 0:x.total)??0,p=r&&r>0?(h/r*100).toFixed(1):null;return u?t.jsxs("div",{className:`data-card flex flex-col relative ${fe[d]}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c&&t.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),t.jsx("span",{className:"type-micro",children:s}),o&&t.jsx("span",{className:"pill-tag",children:o})]}),t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:m}),t.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[60px]",children:i?t.jsx(ve,{buckets:i,colorType:n}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx("div",{className:"w-full h-0.5 rounded-full bg-text-muted/15"})})}),t.jsx("div",{className:"pt-2 mt-1",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Rate"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[(null==x?void 0:x.ratePerHour)??l??"—","/hr"]})]}),null!==p?t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"dropped"===n?"Drop %":"Ratio"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[p,"%"]})]}):(null==x?void 0:x.peakHour)?t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Peak"}),t.jsx("div",{className:"data-box data-box-fill data-box-left",children:x.peakHour})]}):null]})})]}):t.jsx("div",{className:`data-card flex flex-col relative ${fe[d]}`,children:t.jsx(G,{})})}const je=.2;function be(e,t=1){return Math.floor(5*t*e)}function Ne(e){const t=Math.round(e/je)*je;return Math.max(0,Math.min(5,t))}function ye({stats:e,receivedBuckets:i,droppedBuckets:r,forwardedBuckets:o,bucketDurationSeconds:c,timeRangeLabel:d,isLoaded:u=!0}){var m,x,h,p;if(!u)return t.jsx("div",{className:"data-card flex flex-col relative",children:t.jsx(G,{})});const f=function(e,t,s,a,n){var l,i;const r=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=r(t),c=r(s),d=r(a),u=o||(null==e?void 0:e.rx_count)||1,m=c||(null==e?void 0:e.dropped_count)||0,x=u>0?m/(u+m)*100:0;let h=0;if((null==a?void 0:a.length)&&n)h=100*d/(a.length*n*1e3)*100;else if(e){const t=1e3*(e.uptime_seconds||1);h=(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 v=1;x<3?v-=je:x>15?v+=.4:x>10&&(v+=je),h>5&&(v+=je),f>10&&(v+=je);const g=Ne(v),j=Ne(.28*g),b=be(g),N=be(j),y=be((null==(i=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:i.tx_delay_factor)??1);return{floodFactor:g,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b10?"text-accent-warning":""),children:[f.duplicateRate.toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"TX Util"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[f.txUtilization.toFixed(2),"%"]})]})]})}),t.jsxs("div",{className:"pt-2 mt-2",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:null!==v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"data-box",children:["×",v.toFixed(2)]}),t.jsxs("div",{className:"data-box",style:{color:"var(--accent-tertiary)"},children:["×",(null==g?void 0:g.toFixed(2))??"—"]})]}):t.jsx("span",{className:"text-sm text-text-muted",children:"No config"})})]})]})}function ke(){const s=y(),a=k(),n=w(),l=M(),[c,d]=e.useState(null),[u,m]=e.useState(null),[x,h]=e.useState([]),p=e.useRef(0);e.useEffect(()=>{const e=_.subscribe(e=>{h(e)});return h(_.getPendingPackets()),e},[]);const f=e.useMemo(()=>{const e=s.length<=100?s:s.slice(-100),t=new Set(e.map(e=>e.packet_hash));return[...x.filter(e=>!t.has(e.packet.packet_hash)).map(e=>({...e.packet,isPending:!0})),...e].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,x]),v=e.useMemo(()=>{const e=new Map;if(!(null==l?void 0:l.neighbors))return e;l.local_hash&&e.set(S(l.local_hash),l.local_hash);for(const t of Object.keys(l.neighbors)){const s=S(t);e.has(s)||e.set(s,t)}return e},[l]),g=e.useMemo(()=>f.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}),[f,v]);e.useEffect(()=>{var e;if(!f.length)return;const t=(null==(e=f[0])?void 0:e.timestamp)??0,s=t>p.current&&p.current>0;if(p.current=t,!s)return;const a=f[0];if(a){const e=requestAnimationFrame(()=>d(a.packet_hash)),t=setTimeout(()=>d(null),600);return()=>{cancelAnimationFrame(e),clearTimeout(t)}}},[f]);const j=()=>t.jsxs(t.Fragment,{children:[t.jsx(i,{className:"w-6 h-6 text-text-muted mx-auto mb-2"}),t.jsx("div",{className:"text-sm text-text-primary",children:"No packets received"}),t.jsx("div",{className:"text-xs text-text-muted",children:"Packets will appear here"})]});return t.jsxs("div",{className:"chart-container h-full flex flex-col",children:[t.jsxs("div",{className:"chart-header",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(i,{className:"chart-title-icon"}),"Recent Packets"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx(L,{showLabel:!0}),t.jsxs(r,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(o,{className:"w-3 h-3"})]})]})]}),t.jsxs("div",{className:"sm:hidden flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle/50 bg-bg-elevated/20",children:[t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Dir"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Time"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Src"}),t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Type"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Route"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Signal"})]}),t.jsx("div",{className:"hidden sm:block flex-1 overflow-hidden",children:t.jsx("div",{className:"h-full overflow-y-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elevated/95 backdrop-blur-sm",children:t.jsxs("tr",{className:"border-b border-border-subtle/50",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Dir"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Time"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Source"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Type"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Route"}),t.jsx("th",{className:"text-right py-1.5 px-3 pr-4 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Signal"})]})}),t.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:a&&0===f.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-8 text-text-muted",children:"Loading packets..."})}):0===g.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-8",children:j()})}):g.map((e,s)=>t.jsx(X,{packet:e,onClick:m,isFlashing:c===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))})]})})}),t.jsx("div",{className:"sm:hidden flex-1 overflow-y-auto divide-y divide-border-subtle/30",children:a&&0===f.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===g.length?t.jsx("div",{className:"p-8 text-center",children:j()}):g.map((e,s)=>t.jsx(Y,{packet:e,onClick:m,isFlashing:c===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))}),t.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 ",g.length," of ",f.length," packets"]}),u&&t.jsx(Z,{packet:u,onClose:()=>m(null)})]})}const we=e.memo(function({active:e,payload:s,label:a,formatValue:n,labelKey:l}){var i;if(!e||!(null==s?void 0:s.length))return null;const r=l&&(null==(i=s[0])?void 0:i.payload)?s[0].payload[l]:a;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[r&&t.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:r}),t.jsx("div",{className:"space-y-1.5",children:s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:e.name}),t.jsx("span",{className:"type-data-sm text-white tabular-nums",children:n?n(e.value,e.name):e.value.toLocaleString()})]},s))})]})});e.memo(function({active:e,payload:s,color:a,labelKey:n,unit:l=""}){var i,r;if(!e||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(i=null==o?void 0:o.payload)?void 0:i[n];return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[t.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a}}),t.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(r=null==o?void 0:o.value)?void 0:r.toLocaleString(),l]})]})]})}),e.memo(function({payload:e}){return(null==e?void 0:e.length)?t.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:e.value})]},s))}):null});const Me={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function _e({trend:e}){return t.jsx("span",{className:`mini-widget-trend ${e}`,children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Me[e]})})})}function Se(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Le({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function Ce({title:e,icon:s,value:a,unit:n,valueSize:l="md",status:i,subtitle:r,trend:o,children:c,isLoading:d=!1,error:u,className:m="",onClick:x}){const h=["mini-widget-value","lg"===l&&"mini-widget-value-lg","sm"===l&&"mini-widget-value-sm"].filter(Boolean).join(" "),p=["mini-widget",x&&"cursor-pointer",m].filter(Boolean).join(" ");return t.jsxs("div",{className:p,onClick:x,role:x?"button":void 0,children:[t.jsxs("div",{className:"mini-widget-header",children:[s,t.jsx("span",{className:"mini-widget-title",children:e}),i&&"unknown"!==i&&t.jsx("div",{className:`mini-widget-status-dot ${i}`}),o&&t.jsx(_e,{trend:o})]}),d?t.jsx(Se,{}):u?t.jsx(Le,{message:u}):t.jsxs(t.Fragment,{children:[void 0!==a&&t.jsxs("div",{className:h,children:[a,n&&t.jsx("span",{className:"mini-widget-unit",children:n})]}),r&&t.jsx("div",{className:"mini-widget-subtitle",children:r}),c]})]})}const Re={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},De={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 Fe(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),a=t/100*(s.length-1),n=Math.floor(a),l=Math.ceil(a);return n===l?s[n]:s[n]+(s[l]-s[n])*(a-n)}function Be(e){return Fe(e,50)}const Te={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:De,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Ae=e.createContext(Te);function $e(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 Pe(e){return null!=e&&0!==e&&!Object.is(e,-0)&&!(e>-50||e<-130)}function Ie(e,t,s=2,a=!1){if(null===t)return"stable";const n=e-t;return(0!==t?100*Math.abs(n/t):Math.abs(n))0?"up":"down":n>0?"down":"up"}function He({children:s}){var a;const n=M(),l=y(),i=C(),r=R(),o=D(),c=F[o],d=Math.max(1,c.minutes/60),u=null===n,m=e.useMemo(()=>function(e,t){const s=3600*t,a=Math.floor(Date.now()/1e3)-s,n=e.filter(e=>e.timestamp>=a&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),l=n.length,i=n.filter(e=>(e.lbt_attempts??0)>1).length,r=l>0?i/l*100:0,o=n.filter(e=>(e.lbt_attempts??0)>1),c=o.length>0?o.reduce((e,t)=>e+(t.lbt_attempts??0),0)/o.length:0,d=n.filter(e=>(e.lbt_attempts??0)>=5).length,u=l>0?d/l*100:0,m=[];for(const b of n){const e=$e(b.lbt_backoff_delays_ms);m.push(...e)}const x=m.reduce((e,t)=>e+t,0),h=m.length>0?x/m.length:0,p=m.length>0?Math.min(...m):0,f=m.length>0?Math.max(...m):0,v=s/24,g=[],j=[];for(let b=0;b<24;b++){const e=a+b*v,t=e+v,s=n.filter(s=>s.timestamp>=e&&s.timestamp(e.lbt_attempts??0)>1).length,i=s.length>0?l/s.length*100:0,r=[];for(const a of s){const e=$e(a.lbt_backoff_delays_ms);r.push(...e)}const o=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;if(g.push(o),0===s.length)j.push(0);else{const e=s.filter(e=>(e.lbt_attempts??0)>=5).length,t=r.length>0?Math.max(...r):0,a=Math.min(s.length/5,1),n=.15,l=Math.log(1+i*n)/Math.log(1+100*n)*40,c=e/s.length*100,d=Math.min(.5*c,25);let u=0;o>100&&(u=Math.min(8*Math.log10(o/100),15));let m=0;t>500&&o>0&&t>2*o&&(m=Math.min((t-500)/200,5));const x=l+d+u+m;j.push(Math.min(x*a,85))}}return{totalPacketsWithLBT:l,packetsWithRetries:i,retryRate:r,avgRetries:c,channelBusyCount:d,channelBusyRate:u,avgBackoffMs:h,minBackoffMs:p,maxBackoffMs:f,totalBackoffMs:x,sparklineBackoff:g,sparklineCollisionRisk:j,windowHours:t,packetCount:e.length}}(l,d),[l,d]),x=(null==n?void 0:n.noise_floor_dbm)??null,h=e.useMemo(()=>Pe(x)?x:null,[x]),p=e.useMemo(()=>{var e;const t=null==(e=null==n?void 0:n.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(a=null==n?void 0:n.config)?void 0:a.radio]),[f,v]=e.useState([]),g=e.useRef({time:0,hours:0});e.useEffect(()=>{const e=async()=>{var e;const t=Date.now(),s=Math.ceil(d);if(0===g.current.time||g.current.hours!==s||t-g.current.time>=6e4){g.current={time:t,hours:s};try{const t=await B(Math.max(s,24));t.success&&(null==(e=t.data)?void 0:e.history)&&v(t.data.history)}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[d]);const j=e.useMemo(()=>{if(0===f.length)return[];const e=f.reduce((e,t)=>Math.max(e,t.timestamp),0);if(0===e)return[];const t=3600*d,s=e-t,a=t/24,n=[];for(let l=0;l<24;l++){const e=s+l*a,t=e+a,i=f.filter(s=>s.timestamp>=e&&s.timestamp0){const e=i.reduce((e,t)=>e+t.noise_floor_dbm,0)/i.length;n.push(e)}else n.push(n.length>0?n[n.length-1]:-100)}return n},[f,d]),b=null==n?void 0:n.neighbors,N=e.useMemo(()=>{const e=b??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)))},[b,r]),k=e.useMemo(()=>i.filter(e=>!r.has(e.hash)),[i,r]),w=e.useMemo(()=>function(e){if(0===e.length)return{...De,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),a=e.length>0?[e[e.length-1]]:[],n=e.slice(-4).filter(e=>Number.isFinite(e)),l=Be(s),i=Fe(s,10),r=Fe(s,90),o=Be(a),c=null!==o&&null!==i?o-i:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,a=0,n=0,l=0;const i=e[0].timestamp;for(const o of e){const e=(o.timestamp-i)/3600,t=o.value;s+=e,a+=t,n+=e*t,l+=e*e}const r=t*l-s*s;return Math.abs(r)<1e-4?0:(t*n-s*a)/r}(n.map((e,s)=>({timestamp:t-3600*(n.length-1-s),value:e}))),u=function(e){if(e.length<2)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length,s=e.map(e=>Math.pow(e-t,2)).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(s)}(n),m=s.length>=12,[x,h]=m?function(e,t,s){const a=Re;return e>=a.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=a.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:i,baselineP90:r,currentMedian:o,currentSampleCount:a.length,delta:c,slope:d,jitter:u,penalty:x,penaltyReason:h,computedAt:t,isReliable:m}}(j),[j]),_=e.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const a=e.map(e=>{const a=function(e,t,s){const a=se(e,t,s,0);if(a)switch(a.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const n=void 0===e?50:e>=10?100:e>=5?80:e>=0?60:e>=-5?40:20,l=void 0===t?50:t>=-70?100:t>=-80?80:t>=-90?60:t>=-100?40:20;return Math.round(.6*n+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),n=t[e.hash];return{name:(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:a,advertCount:e.count}});a.sort((e,t)=>t.score-e.score);const n=a.length>0?a.reduce((e,t)=>e+t.score,0)/a.length:0;return{neighbors:a,networkScore:Math.round(n),neighborCount:a.length,bestLink:a.length>0?{name:a[0].name,score:a[0].score}:null,worstLink:a.length>0?{name:a[a.length-1].name,score:a[a.length-1].score}:null}}(k,N,p),[k,N,p]),S=e.useMemo(()=>function(e,t,s){const a=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let n=50;null!==t&&(n=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,i=Math.round(.35*a+.25*n+.4*l);let r;return r=i>=85?"excellent":i>=70?"good":i>=50?"fair":i>=30?"congested":"critical",{score:i,status:r,components:{lbtHealth:Math.round(a),noiseHealth:Math.round(n),linkHealth:Math.round(l)}}}(m,h,_),[m,h,_]),[L,T]=e.useState({noiseFloor:null,networkScore:null,channelHealth:null}),A=e.useRef(0);e.useEffect(()=>{const e=()=>{const e=Date.now();e-A.current>3e4&&(A.current=e,T({noiseFloor:h,networkScore:(null==_?void 0:_.networkScore)??null,channelHealth:(null==S?void 0:S.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[h,null==_?void 0:_.networkScore,null==S?void 0:S.score]);const $=e.useMemo(()=>({noiseFloor:{current:h,previous:L.noiseFloor,trend:null!==h?Ie(h,L.noiseFloor,2,!0):"stable"},networkScore:{current:(null==_?void 0:_.networkScore)??0,previous:L.networkScore,trend:Ie((null==_?void 0:_.networkScore)??0,L.networkScore,3,!1)},channelHealth:{current:(null==S?void 0:S.score)??0,previous:L.channelHealth,trend:Ie((null==S?void 0:S.score)??0,L.channelHealth,3,!1)}}),[h,null==_?void 0:_.networkScore,null==S?void 0:S.score,L]),P={lbtStats:m,noiseFloor:h,sparklineNoiseFloor:j,linkQuality:_,channelHealth:S,nfTrend:w,radioConfig:p,trends:$,stats:n,recentPackets:l,quickNeighbors:i,isLoading:u,error:null,refresh:async()=>{}};return t.jsx(Ae.Provider,{value:P,children:s})}function Ee(){const t=e.useContext(Ae);if(void 0===t)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function We(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function qe(){const{lbtStats:s,isLoading:a,error:n}=Ee(),l=c(),i=(null==s?void 0:s.avgBackoffMs)??0,r=(null==s?void 0:s.retryRate)??0,o=s?(u=i)<100?"excellent":u<250?"good":u<500?"fair":u<1e3?"congested":"critical":"unknown";var u;const m=null==s?void 0:s.sparklineBackoff,{chartData:x,yDomain:h}=e.useMemo(()=>{if(!m||m.length<2)return{chartData:[],yDomain:[0,100]};const e=m.map(e=>({value:e})),t=m.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,100]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,.1*a,10);return{chartData:e,yDomain:[Math.max(0,s-l),a+l]}},[m]);return t.jsx(Ce,{title:"LBT Backoff",icon:t.jsx(d,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:o,subtitle:s?We(i,r):void 0,isLoading:a,error:n,onClick:()=>l("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline",children:x.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:x,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:h,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Oe(e){return 0===e?"—":e<1?"<1":Math.round(e).toString()}function ze(){const{lbtStats:e,isLoading:s,error:a}=Ee(),n=c(),l=(null==e?void 0:e.channelBusyCount)??0,i=(null==e?void 0:e.totalPacketsWithLBT)??0,r=(null==e?void 0:e.channelBusyRate)??0,o=(null==e?void 0:e.retryRate)??0,d=(null==e?void 0:e.avgBackoffMs)??0,m=(null==e?void 0:e.minBackoffMs)??0,x=(null==e?void 0:e.maxBackoffMs)??0,h=o>0?Math.max(0,(o-r)/o*100):100;return t.jsx(Ce,{title:"Ch. Busy",icon:t.jsx(u,{className:"mini-widget-icon"}),isLoading:s,error:a,onClick:()=>n("/packets"),children:t.jsx("div",{className:"flex-1 flex items-end",children:t.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-2 w-full items-baseline",children:[t.jsx("span",{className:"data-box-label mb-0",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[l,t.jsx("span",{className:"text-text-muted",children:"/"}),i]}),t.jsx("span",{className:"data-box-label mb-0",title:`${h.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${h.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:[h.toFixed(0),"%"]}),t.jsx("span",{className:"data-box-label mb-0",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[Oe(d),t.jsx("span",{className:"text-text-muted text-xs",children:"ms"})]}),t.jsx("span",{className:"data-box-label mb-0",title:`Backoff range: ${m.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:"Range:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Backoff range: ${m.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:[Oe(m),t.jsx("span",{className:"text-text-muted",children:"/"}),Oe(x)]})]})})})}function Ge(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}function Ke(){const{noiseFloor:s,sparklineNoiseFloor:a,trends:n,isLoading:l,error:i}=Ee(),r=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==n?void 0:n.noiseFloor.trend,{chartData:d,yDomain:u}=e.useMemo(()=>{if(!a||a.length<2)return{chartData:[],yDomain:[-120,-90]};const e=a.map(e=>({value:e})),t=a.filter(e=>-100!==e&&e<-50);if(0===t.length)return{chartData:e,yDomain:[-120,-90]};const s=Math.min(...t),n=Math.max(...t),l=n-s,i=Math.max(.2*l,3);return{chartData:e,yDomain:[s-i,n+i]}},[a]);return t.jsx(Ce,{title:"Noise Floor",icon:t.jsx(m,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:r,trend:c,subtitle:Ge(s),isLoading:l,error:i,children:t.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:u,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ue(){const s=c(),a=C(),n=y(),l=M(),i=D(),r=60*F[i].minutes,o=T(),d=e.useMemo(()=>{if(0===o)return n;const e=o-r;return n.filter(t=>t.timestamp>=e)},[n,r,o]),u=null===l,m=(null==l?void 0:l.local_hash)?S(l.local_hash):"",v=(null==l?void 0:l.neighbors)??{},{neighborHashes:g,neighborNames:j}=e.useMemo(()=>{const e=new Set,t=new Map;for(const s of a){e.add(s.hash);const a=v[s.hash],n=(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||s.prefix;t.set(s.hash,n)}return{neighborHashes:e,neighborNames:t}},[a,v]),b=e.useMemo(()=>{if(0===g.size||0===d.length||!m)return{champion:null,listener:null,loudest:null};const{scores:e}=me(d,g,m),t=[];for(const[l,i]of e)0!==i.blendedScore&&t.push({...i,name:j.get(l)??S(l)});let s=null,a=null,n=null;for(const l of t)(!s||l.blendedScore>s.blendedScore)&&(s=l),(!a||l.listenerScore>a.listenerScore)&&(a=l),(!n||l.loudScore>n.loudScore)&&(n=l);return{champion:s,listener:a,loudest:n}},[d,g,m,j]),{champion:N,listener:k,loudest:w}=b,_=N||k||w?t.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[N&&t.jsx(A,{content:(L=N,t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",L.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",L.blendedScore,t.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",L.listenerScore,"/100 (",L.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",L.loudScore,"/100 (",L.loudCount," packets relayed)"]})]})]})),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(x,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),t.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:N.name}),t.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:N.blendedScore})]})}),k&&t.jsx(A,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.listenerCount," packets where they heard your transmissions"]})})]}))(k),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(h,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:k.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:k.listenerScore})]})}),w&&t.jsx(A,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.loudCount," packets they relayed directly to you"]})})]}))(w),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:w.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:w.loudScore})]})})]}):0===a.length?t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var L;return t.jsx(Ce,{title:"Link Leaders",icon:t.jsx(f,{className:"mini-widget-icon"}),isLoading:u,onClick:()=>s("/contacts"),children:_})}function Je(){const{lbtStats:s,isLoading:a,error:n}=Ee(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:a,avgBackoffMs:n,maxBackoffMs:l}=e;if(0===a)return 0;const i=Math.min(a/10,1),r=Math.log(1+.15*t)/Math.log(16)*40,o=s/a*100,c=Math.min(.5*o,25);let d=0;n>100&&(d=Math.min(8*Math.log10(n/100),15));let u=0;l>500&&n>0&&l>2*n&&(u=Math.min((l-500)/200,5));const m=(r+c+d+u)*i;return Math.min(m,85)}(s):0,i=s?(r=l)<15?"excellent":r<30?"good":r<45?"fair":r<60?"congested":"critical":"unknown";var r;const o=(null==s?void 0:s.maxBackoffMs)??0,c=s?o>200?`Max backoff: ${Math.round(o)}ms`:function(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}(l):void 0,d=null==s?void 0:s.sparklineCollisionRisk,{chartData:u,yDomain:m}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,85]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,85]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,5);return{chartData:e,yDomain:[Math.max(0,s-l),Math.min(85,a+l)]}},[d]);return t.jsx(Ce,{title:"Collision Risk",icon:t.jsx(v,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:i,subtitle:c,isLoading:a,error:n,children:t.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:m,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ve(){const[s,a]=e.useState(!1),[n]=e.useState(0),{stats:l,lbtStats:r,isLoading:o}=Ee(),c=e.useMemo(()=>{if(!l)return null;const e=l.airtime_used_ms??0,t=l.max_airtime_ms??1;return{usedMs:e,maxMs:t,remainingMs:l.airtime_remaining_ms??0,utilizationPercent:l.utilization_percent??(t>0?e/t*100:0)}},[l]),d=e.useMemo(()=>r&&0!==r.totalPacketsWithLBT?(r.totalPacketsWithLBT-r.packetsWithRetries)/r.totalPacketsWithLBT*100:100,[r]),u=(null==c?void 0:c.utilizationPercent)??0,m=(x=u)<30?"excellent":x<50?"good":x<70?"fair":x<90?"congested":"critical";var x;const h=(null==c?void 0:c.remainingMs)??0,p=d<95?`${d.toFixed(0)}% clean TX`:((f=h)<1e3?`${Math.round(f)}ms`:f<6e4?`${(f/1e3).toFixed(1)}s`:`${(f/6e4).toFixed(1)}m`)+" remaining";var f;const v=c?t.jsx("div",{className:"mini-widget-progress mt-auto",children:t.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return t.jsx(Ce,{title:"Duty Cycle",icon:t.jsx(i,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:p,isLoading:o,children:v})}function Qe(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(K,{className:"w-4 h-4"}),t.jsx(K,{className:"h-3 w-16"})]}),t.jsx(K,{className:"h-7 w-12 mt-2"}),t.jsx(K,{className:"h-3 w-20 mt-2"})]})}function Xe(){return t.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((e,s)=>t.jsx(Qe,{},s))})}function Ye({className:e="",isLoaded:s=!0}){return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(g,{className:"w-4 h-4 text-accent-primary"}),t.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?t.jsx(He,{children:t.jsxs("div",{className:"widget-row",children:[t.jsx(qe,{}),t.jsx(Je,{}),t.jsx(Ke,{}),t.jsx(Ve,{}),t.jsx(ze,{}),t.jsx(Ue,{})]})}):t.jsx(Xe,{})]})}function Ze(){var s,n;const l=M(),r=$(),o=y(),c=P(),d=D(),u=I(),m=H(),x=F[d],h=5===d&&!m.threeDayLoadComplete,p=6===d&&!m.sevenDayLoadComplete,f=7===d&&!m.fourteenDayLoadComplete,v=m.isBackgroundLoading&&(h||p||f),g=O(),k=z(),w=null==(s=null==l?void 0:l.config)?void 0:s.radio,_=e.useMemo(()=>w?{sf:w.spreading_factor??10,bw:w.bandwidth??25e4,cr:w.coding_rate??5,preamble:w.preamble_length??8}:null,[w]),S=o.length,L=e.useMemo(()=>S?E(x.minutes,x.buckets,o,l):null,[S,x.minutes,x.buckets,_]),C=e.useMemo(()=>function(e,t,s){if(!(null==e?void 0:e.length))return[];const a=s>1440?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{hour:"2-digit",minute:"2-digit",hour12:!1};return e.map((e,s)=>{var n;return{time:new Date(1e3*e.start).toLocaleString([],a),received:e.count,unique:(null==(n=null==t?void 0:t[s])?void 0:n.count)??0}})}(null==L?void 0:L.received,null==L?void 0:L.unique_received,x.minutes),[null==L?void 0:L.received,null==L?void 0:L.unique_received,x.minutes]),R=e.useMemo(()=>function(e){if(!e.length)return[0,"auto"];let t=e[0].received,s=e[0].received;for(const n of e)n.receiveds&&(s=n.received),n.uniques&&(s=n.unique);if(t===s)return[Math.max(0,t-1),s+1];const a=.1*(s-t);return[Math.max(0,Math.floor(t-a)),Math.ceil(s+a)]}(C),[C]),B=e.useMemo(()=>{return(e=C.length)<=12?0:e<=24?2:e<=48?5:e<=72?8:Math.floor(e/7);var e},[C.length]),T=e.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==L?void 0:L.received),s=e(null==L?void 0:L.unique_received),a=e(null==L?void 0:L.forwarded),n=e(null==L?void 0:L.dropped),l=e(null==L?void 0:L.transmitted),i=((null==L?void 0:L.time_range_minutes)??x.minutes)/60;return{received:t,uniqueReceived:s,forwarded:a,dropped:n,transmitted:l,rxPerHour:i>0?Math.round(t/i):0,fwdPerHour:i>0?Math.round(a/i):0}},[L,x.minutes]),A=(null==l?void 0:l.node_name)??(null==(n=null==l?void 0:l.config)?void 0:n.node_name)??"Unknown Node";return r?t.jsxs(U,{className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-white/50",children:r}),t.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(J,{children:[t.jsx(V,{title:A,icon:t.jsx(j,{}),controls:t.jsx(ee,{ranges:F,selectedIndex:d,onSelect:u,isPending:v})}),t.jsx(xe,{template:"hero",children:t.jsx(U,{isLoaded:c,skeletonType:"chart",compact:!0,children:c&&t.jsxs(t.Fragment,{children:[t.jsx(Q,{icon:t.jsx(a,{}),title:"RECEIVED",badge:x.label,actions:t.jsxs("div",{className:"data-box",children:[T.rxPerHour,"/hr"]})}),t.jsxs("div",{className:"flex gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary leading-none",style:{letterSpacing:"-0.05em"},children:T.received.toLocaleString()}),t.jsx("span",{className:"color-pill mb-1",style:{"--pill-color":g.received},children:"Total RF"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary leading-none",style:{letterSpacing:"-0.05em"},children:T.uniqueReceived.toLocaleString()}),t.jsx("span",{className:"color-pill mb-1",style:{"--pill-color":g.forwarded},children:"Unique"})]})]}),t.jsx("div",{className:"mt-8",children:C.length>0?t.jsx(ae,{width:"100%",height:216,children:t.jsxs(re,{data:C,margin:{left:0,right:8,top:0,bottom:0},children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"gradient-received",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"5%",stopColor:g.received,stopOpacity:.3}),t.jsx("stop",{offset:"95%",stopColor:g.received,stopOpacity:0})]}),t.jsxs("linearGradient",{id:"gradient-unique",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"5%",stopColor:g.forwarded,stopOpacity:.53}),t.jsx("stop",{offset:"95%",stopColor:g.forwarded,stopOpacity:0})]})]}),t.jsx(oe,{strokeDasharray:"3 3",stroke:k.grid,vertical:!1}),t.jsx(ce,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:k.axisTick,fontSize:10,fontFamily:W},dy:8,interval:B,minTickGap:20}),t.jsx(le,{domain:R,axisLine:!1,tickLine:!1,tick:{fill:k.axisTick,fontSize:10,fontFamily:W},dx:-4,width:28}),t.jsx(de,{content:t.jsx(we,{labelKey:"time"}),cursor:{stroke:k.cursor,strokeWidth:1}}),t.jsx(ue,{type:"stepAfter",dataKey:"received",name:"Total RF",stroke:g.received,fill:"url(#gradient-received)",strokeWidth:1.5,dot:!1,activeDot:{r:4,strokeWidth:0,fill:g.received},isAnimationActive:!1}),t.jsx(ue,{type:"stepAfter",dataKey:"unique",name:"Unique",stroke:g.forwarded,fill:"url(#gradient-unique)",strokeWidth:1.5,dot:!1,activeDot:{r:4,strokeWidth:0,fill:g.forwarded},isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),t.jsxs(xe,{template:"compact",children:[t.jsx(he,{span:12,md:6,lg:4,children:t.jsx(ge,{title:"FORWARDED",value:T.forwarded,color:"forwarded",buckets:null==L?void 0:L.forwarded,receivedCount:T.received,timeRangeLabel:x.label,icon:t.jsx(b,{className:"w-4 h-4"}),isLoaded:c})}),t.jsx(he,{span:12,md:6,lg:4,children:t.jsx(ge,{title:"DROPPED",value:T.dropped,color:"dropped",buckets:null==L?void 0:L.dropped,receivedCount:T.received,timeRangeLabel:x.label,icon:t.jsx(N,{className:"w-4 h-4"}),isLoaded:c})}),t.jsx(he,{span:12,md:12,lg:4,children:t.jsx(ye,{stats:l,receivedBuckets:null==L?void 0:L.received,droppedBuckets:null==L?void 0:L.dropped,forwardedBuckets:null==L?void 0:L.forwarded,bucketDurationSeconds:null==L?void 0:L.bucket_duration_seconds,timeRangeLabel:x.label,isLoaded:c})})]}),t.jsx(Ye,{isLoaded:c}),t.jsx(ke,{}),l&&t.jsx(xe,{template:"auto",children:t.jsxs(U,{children:[t.jsx(Q,{icon:t.jsx(i,{}),title:"Node Information",largeTitle:!0}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Node Name"}),t.jsx("p",{className:"type-body text-text-primary mt-1 truncate",title:A,children:A})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Repeater"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${l.version}`,children:["v",l.version]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Core"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${l.core_version}`,children:["v",l.core_version]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Console"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${q}`,children:["v",q]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Local Hash"}),t.jsx("div",{className:"mt-1",children:l.local_hash?t.jsx(te,{copy:!0,size:"compact",children:l.local_hash}):t.jsx("span",{className:"type-data-sm text-text-secondary",children:"N/A"})})]})]}),l.public_key&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Public Key"}),t.jsx("div",{className:"mt-1",children:t.jsx(te,{copy:!0,children:l.public_key})})]})]})})]})}export{Ze as default}; +import{r as e,j as t,y as s,T as a,z as n,A as l,p as i,g as r,D as o,x as c,E as d,H as u,I as m,J as x,K as h,O as p,Q as f,Z as v,U as g,V as j,W as b,Y as N}from"./vendor-react-DtVWNgeu.js";import{u as y,a as k,b as w,c as M,w as _,d as S,L,e as C,f as R,h as D,D as F,j as B,k as T,T as A,m as $,n as P,o as I,p as H,q as E,F as W,v as q}from"./index-Bmit1I8S.js";import{u as O,a as z}from"./useThemeColors-DaJMJYCA.js";import{C as G,S as K,a as U,P as J,b as V,c as Q}from"./PageLayout-CG02PCA-.js";import{P as X,a as Y,b as Z}from"./PacketDetailModal-I-Pe3tob.js";import{T as ee}from"./TimeRangeSelector-CzmnykND.js";import{D as te}from"./DataBox-Dl3NmnnB.js";import{s as se}from"./SignalIndicator-DagI_WOB.js";import{R as ae,L as ne,Y as le,a as ie,A as re,C as oe,X as ce,T as de,b as ue}from"./recharts-C9LxPobD.js";import{c as me}from"./link-scoring-t1Ov70gg.js";import{R as xe,C as he}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./useScientificColormap-n_Aivg5g.js";const pe={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)"}},fe={sm:"card-sm",md:"card-md",lg:"card-lg",hero:"card-hero",auto:""};function ve({buckets:s,colorType:a}){const n=pe[a].barBase,l=e.useMemo(()=>{if(!(null==s?void 0:s.length))return[];const e=s.length/60,t=e<=1?s:Array.from({length:60},(t,a)=>{var n,l;const i=s.slice(Math.floor(a*e),Math.floor((a+1)*e)),r=i.reduce((e,t)=>e+t.count,0),o=i.length?i.reduce((e,t)=>e+t.avg_snr,0)/i.length:0;return{bucket:a,start:(null==(n=i[0])?void 0:n.start)??0,end:(null==(l=i.at(-1))?void 0:l.end)??0,count:r,airtime_ms:i.reduce((e,t)=>e+t.airtime_ms,0),avg_snr:o,avg_rssi:0}}),a=t.map(e=>e.count).filter(e=>e>0);if(0===a.length)return t.map(()=>({height:0,bottom:0,color:"transparent",count:0,snr:0}));const l=Math.max(...a),i=Math.min(...a),r=l-i;return 0===r?t.map(e=>({height:e.count>0?40:0,bottom:e.count>0?30:0,color:e.count>0?n:"transparent",count:e.count,snr:e.avg_snr})):t.map(e=>{if(0===e.count)return{height:0,bottom:0,color:"transparent",count:0,snr:e.avg_snr};const t=(e.count-i)/r,s=25*t;return{height:Math.max(15,25+60*t),bottom:s,color:n,count:e.count,snr:e.avg_snr}})},[s,n]);return(null==s?void 0:s.length)?t.jsx("div",{className:"w-full h-full relative",children:l.map((e,s)=>{var a;return t.jsx("div",{className:"absolute rounded-full",style:{height:`${e.height}%`,bottom:`${e.bottom}%`,left:7*s+"px",width:"5px",backgroundColor:e.color,opacity:e.count>0?.8:.1},title:e.count>0?`${e.count} packets, SNR: ${null==(a=e.snr)?void 0:a.toFixed(1)}dB`:"No packets"},s)})}):t.jsx("div",{className:"w-full h-full flex items-end justify-center gap-[2px] opacity-20",children:t.jsx("span",{className:"type-data-xs text-text-secondary",children:"No data"})})}function ge({title:s,value:a,color:n="neutral",subtitle:l,buckets:i,receivedCount:r,timeRangeLabel:o,icon:c,size:d="md",isLoaded:u=!0}){const m="string"==typeof a?a:a.toLocaleString(),x=e.useMemo(()=>function(e){if(!(null==e?void 0:e.length))return null;const t=e.reduce((e,t)=>e+t.count,0),s=e[0].start,a=e[e.length-1].end,n=Math.max((a-s)/3600,1),l=Math.round(t/n);let i=0,r=0;for(let d=0;dr&&(r=e[d].count,i=d);const o=new Date(1e3*e[i].start).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),c=e.filter(e=>e.count>0&&0!==e.avg_snr);return{total:t,ratePerHour:l,peakCount:r,peakHour:o,avgSnr:c.length>0?c.reduce((e,t)=>e+t.avg_snr,0)/c.length:null}}(i),[i]),h="number"==typeof a?a:(null==x?void 0:x.total)??0,p=r&&r>0?(h/r*100).toFixed(1):null;return u?t.jsxs("div",{className:`data-card flex flex-col relative ${fe[d]}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c&&t.jsx("span",{className:"icon-sm text-icon-card-title",children:c}),t.jsx("span",{className:"type-micro",children:s}),o&&t.jsx("span",{className:"pill-tag",children:o})]}),t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:m}),t.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[60px]",children:i?t.jsx(ve,{buckets:i,colorType:n}):t.jsx("div",{className:"w-full h-full flex items-center justify-center",children:t.jsx("div",{className:"w-full h-0.5 rounded-full bg-text-muted/15"})})}),t.jsx("div",{className:"pt-2 mt-1",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Rate"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[(null==x?void 0:x.ratePerHour)??l??"—","/hr"]})]}),null!==p?t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"dropped"===n?"Drop %":"Ratio"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[p,"%"]})]}):(null==x?void 0:x.peakHour)?t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"Peak"}),t.jsx("div",{className:"data-box data-box-fill data-box-left",children:x.peakHour})]}):null]})})]}):t.jsx("div",{className:`data-card flex flex-col relative ${fe[d]}`,children:t.jsx(G,{})})}const je=.2;function be(e,t=1){return Math.floor(5*t*e)}function Ne(e){const t=Math.round(e/je)*je;return Math.max(0,Math.min(5,t))}function ye({stats:e,receivedBuckets:i,droppedBuckets:r,forwardedBuckets:o,bucketDurationSeconds:c,timeRangeLabel:d,isLoaded:u=!0}){var m,x,h,p;if(!u)return t.jsx("div",{className:"data-card flex flex-col relative",children:t.jsx(G,{})});const f=function(e,t,s,a,n){var l,i;const r=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,o=r(t),c=r(s),d=r(a),u=o||(null==e?void 0:e.rx_count)||1,m=c||(null==e?void 0:e.dropped_count)||0,x=u>0?m/(u+m)*100:0;let h=0;if((null==a?void 0:a.length)&&n)h=100*d/(a.length*n*1e3)*100;else if(e){const t=1e3*(e.uptime_seconds||1);h=(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 v=1;x<3?v-=je:x>15?v+=.4:x>10&&(v+=je),h>5&&(v+=je),f>10&&(v+=je);const g=Ne(v),j=Ne(.28*g),b=be(g),N=be(j),y=be((null==(i=null==(l=null==e?void 0:e.config)?void 0:l.delays)?void 0:i.tx_delay_factor)??1);return{floodFactor:g,directFactor:j,floodSlots:b,directSlots:N,adjustment:b>y?"increase":b10?"text-accent-warning":""),children:[f.duplicateRate.toFixed(1),"%"]})]}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"data-box-label",children:"TX Util"}),t.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[f.txUtilization.toFixed(2),"%"]})]})]})}),t.jsxs("div",{className:"pt-2 mt-2",children:[t.jsx("div",{className:"data-box-label",children:"Current"}),t.jsx("div",{className:"flex gap-2",children:null!==v?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"data-box",children:["×",v.toFixed(2)]}),t.jsxs("div",{className:"data-box",style:{color:"var(--accent-tertiary)"},children:["×",(null==g?void 0:g.toFixed(2))??"—"]})]}):t.jsx("span",{className:"text-sm text-text-muted",children:"No config"})})]})]})}function ke(){const s=y(),a=k(),n=w(),l=M(),[c,d]=e.useState(null),[u,m]=e.useState(null),[x,h]=e.useState([]),p=e.useRef(0);e.useEffect(()=>{const e=_.subscribe(e=>{h(e)});return h(_.getPendingPackets()),e},[]);const f=e.useMemo(()=>{const e=s.length<=100?s:s.slice(-100),t=new Set(e.map(e=>e.packet_hash));return[...x.filter(e=>!t.has(e.packet.packet_hash)).map(e=>({...e.packet,isPending:!0})),...e].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,x]),v=e.useMemo(()=>{const e=new Map;if(!(null==l?void 0:l.neighbors))return e;l.local_hash&&e.set(S(l.local_hash),l.local_hash);for(const t of Object.keys(l.neighbors)){const s=S(t);e.has(s)||e.set(s,t)}return e},[l]),g=e.useMemo(()=>f.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}),[f,v]);e.useEffect(()=>{var e;if(!f.length)return;const t=(null==(e=f[0])?void 0:e.timestamp)??0,s=t>p.current&&p.current>0;if(p.current=t,!s)return;const a=f[0];if(a){const e=requestAnimationFrame(()=>d(a.packet_hash)),t=setTimeout(()=>d(null),600);return()=>{cancelAnimationFrame(e),clearTimeout(t)}}},[f]);const j=()=>t.jsxs(t.Fragment,{children:[t.jsx(i,{className:"w-6 h-6 text-text-muted mx-auto mb-2"}),t.jsx("div",{className:"text-sm text-text-primary",children:"No packets received"}),t.jsx("div",{className:"text-xs text-text-muted",children:"Packets will appear here"})]});return t.jsxs("div",{className:"chart-container h-full flex flex-col",children:[t.jsxs("div",{className:"chart-header",children:[t.jsxs("div",{className:"chart-title",children:[t.jsx(i,{className:"chart-title-icon"}),"Recent Packets"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx(L,{showLabel:!0}),t.jsxs(r,{to:"/packets",className:"pill-subtle",children:["View all ",t.jsx(o,{className:"w-3 h-3"})]})]})]}),t.jsxs("div",{className:"sm:hidden flex items-center gap-2 px-3 py-1.5 border-b border-border-subtle/50 bg-bg-elevated/20",children:[t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Dir"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Time"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Src"}),t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Type"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Route"}),t.jsx("span",{className:"text-[9px] font-semibold text-text-muted uppercase tracking-wider flex-shrink-0",children:"Signal"})]}),t.jsx("div",{className:"hidden sm:block flex-1 overflow-hidden",children:t.jsx("div",{className:"h-full overflow-y-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elevated/95 backdrop-blur-sm",children:t.jsxs("tr",{className:"border-b border-border-subtle/50",children:[t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Dir"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Time"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Source"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Type"}),t.jsx("th",{className:"text-left py-1.5 px-3 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Route"}),t.jsx("th",{className:"text-right py-1.5 px-3 pr-4 text-[9px] font-semibold text-text-muted uppercase tracking-wider whitespace-nowrap",children:"Signal"})]})}),t.jsx("tbody",{className:"divide-y divide-border-subtle/30",children:a&&0===f.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-8 text-text-muted",children:"Loading packets..."})}):0===g.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-8",children:j()})}):g.map((e,s)=>t.jsx(X,{packet:e,onClick:m,isFlashing:c===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))})]})})}),t.jsx("div",{className:"sm:hidden flex-1 overflow-y-auto divide-y divide-border-subtle/30",children:a&&0===f.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===g.length?t.jsx("div",{className:"p-8 text-center",children:j()}):g.map((e,s)=>t.jsx(Y,{packet:e,onClick:m,isFlashing:c===e.packet_hash},`${e.packet_hash}_${e.timestamp}_${s}`))}),t.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 ",g.length," of ",f.length," packets"]}),u&&t.jsx(Z,{packet:u,onClose:()=>m(null)})]})}const we=e.memo(function({active:e,payload:s,label:a,formatValue:n,labelKey:l}){var i;if(!e||!(null==s?void 0:s.length))return null;const r=l&&(null==(i=s[0])?void 0:i.payload)?s[0].payload[l]:a;return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-4 py-3 shadow-xl",children:[r&&t.jsx("p",{className:"type-data-xs text-white/50 mb-2",children:r}),t.jsx("div",{className:"space-y-1.5",children:s.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/70 capitalize min-w-[60px]",children:e.name}),t.jsx("span",{className:"type-data-sm text-white tabular-nums",children:n?n(e.value,e.name):e.value.toLocaleString()})]},s))})]})});e.memo(function({active:e,payload:s,color:a,labelKey:n,unit:l=""}){var i,r;if(!e||!(null==s?void 0:s.length))return null;const o=s[0],c=null==(i=null==o?void 0:o.payload)?void 0:i[n];return t.jsxs("div",{className:"bg-tooltip-bg border border-border-subtle rounded-lg px-3 py-2 shadow-xl",children:[t.jsx("p",{className:"type-data-xs text-white/50 mb-1",children:c}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a}}),t.jsxs("span",{className:"type-data-sm text-white tabular-nums",children:[null==(r=null==o?void 0:o.value)?void 0:r.toLocaleString(),l]})]})]})}),e.memo(function({payload:e}){return(null==e?void 0:e.length)?t.jsx("div",{className:"flex items-center justify-center gap-6 mt-4 pt-4 border-t border-white/5",children:e.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e.color}}),t.jsx("span",{className:"type-body-sm text-white/60 capitalize",children:e.value})]},s))}):null});const Me={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function _e({trend:e}){return t.jsx("span",{className:`mini-widget-trend ${e}`,children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Me[e]})})})}function Se(){return t.jsx("div",{className:"mini-widget-loading",children:t.jsx("div",{className:"mini-widget-loading-spinner"})})}function Le({message:e}){return t.jsx("div",{className:"mini-widget-error",children:t.jsx("span",{title:e,children:"No data"})})}function Ce({title:e,icon:s,value:a,unit:n,valueSize:l="md",status:i,subtitle:r,trend:o,children:c,isLoading:d=!1,error:u,className:m="",onClick:x}){const h=["mini-widget-value","lg"===l&&"mini-widget-value-lg","sm"===l&&"mini-widget-value-sm"].filter(Boolean).join(" "),p=["mini-widget",x&&"cursor-pointer",m].filter(Boolean).join(" ");return t.jsxs("div",{className:p,onClick:x,role:x?"button":void 0,children:[t.jsxs("div",{className:"mini-widget-header",children:[s,t.jsx("span",{className:"mini-widget-title",children:e}),i&&"unknown"!==i&&t.jsx("div",{className:`mini-widget-status-dot ${i}`}),o&&t.jsx(_e,{trend:o})]}),d?t.jsx(Se,{}):u?t.jsx(Le,{message:u}):t.jsxs(t.Fragment,{children:[void 0!==a&&t.jsxs("div",{className:h,children:[a,n&&t.jsx("span",{className:"mini-widget-unit",children:n})]}),r&&t.jsx("div",{className:"mini-widget-subtitle",children:r}),c]})]})}const Re={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},De={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 Fe(e,t){if(0===e.length)return null;const s=[...e].sort((e,t)=>e-t),a=t/100*(s.length-1),n=Math.floor(a),l=Math.ceil(a);return n===l?s[n]:s[n]+(s[l]-s[n])*(a-n)}function Be(e){return Fe(e,50)}const Te={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],linkQuality:null,channelHealth:null,nfTrend:De,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Ae=e.createContext(Te);function $e(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 Pe(e){return null!=e&&0!==e&&!Object.is(e,-0)&&!(e>-50||e<-130)}function Ie(e,t,s=2,a=!1){if(null===t)return"stable";const n=e-t;return(0!==t?100*Math.abs(n/t):Math.abs(n))0?"up":"down":n>0?"down":"up"}function He({children:s}){var a;const n=M(),l=y(),i=C(),r=R(),o=D(),c=F[o],d=Math.max(1,c.minutes/60),u=null===n,m=e.useMemo(()=>function(e,t){const s=3600*t,a=Math.floor(Date.now()/1e3)-s,n=e.filter(e=>e.timestamp>=a&&void 0!==e.lbt_attempts&&e.lbt_attempts>0),l=n.length,i=n.filter(e=>(e.lbt_attempts??0)>1).length,r=l>0?i/l*100:0,o=n.filter(e=>(e.lbt_attempts??0)>1),c=o.length>0?o.reduce((e,t)=>e+(t.lbt_attempts??0),0)/o.length:0,d=n.filter(e=>(e.lbt_attempts??0)>=5).length,u=l>0?d/l*100:0,m=[];for(const b of n){const e=$e(b.lbt_backoff_delays_ms);m.push(...e)}const x=m.reduce((e,t)=>e+t,0),h=m.length>0?x/m.length:0,p=m.length>0?Math.min(...m):0,f=m.length>0?Math.max(...m):0,v=s/24,g=[],j=[];for(let b=0;b<24;b++){const e=a+b*v,t=e+v,s=n.filter(s=>s.timestamp>=e&&s.timestamp(e.lbt_attempts??0)>1).length,i=s.length>0?l/s.length*100:0,r=[];for(const a of s){const e=$e(a.lbt_backoff_delays_ms);r.push(...e)}const o=r.length>0?r.reduce((e,t)=>e+t,0)/r.length:0;if(g.push(o),0===s.length)j.push(0);else{const e=s.filter(e=>(e.lbt_attempts??0)>=5).length,t=r.length>0?Math.max(...r):0,a=Math.min(s.length/5,1),n=.15,l=Math.log(1+i*n)/Math.log(1+100*n)*40,c=e/s.length*100,d=Math.min(.5*c,25);let u=0;o>100&&(u=Math.min(8*Math.log10(o/100),15));let m=0;t>500&&o>0&&t>2*o&&(m=Math.min((t-500)/200,5));const x=l+d+u+m;j.push(Math.min(x*a,85))}}return{totalPacketsWithLBT:l,packetsWithRetries:i,retryRate:r,avgRetries:c,channelBusyCount:d,channelBusyRate:u,avgBackoffMs:h,minBackoffMs:p,maxBackoffMs:f,totalBackoffMs:x,sparklineBackoff:g,sparklineCollisionRisk:j,windowHours:t,packetCount:e.length}}(l,d),[l,d]),x=(null==n?void 0:n.noise_floor_dbm)??null,h=e.useMemo(()=>Pe(x)?x:null,[x]),p=e.useMemo(()=>{var e;const t=null==(e=null==n?void 0:n.config)?void 0:e.radio;return t?{sf:t.spreading_factor??7,bwHz:t.bandwidth??125e3}:null},[null==(a=null==n?void 0:n.config)?void 0:a.radio]),[f,v]=e.useState([]),g=e.useRef({time:0,hours:0});e.useEffect(()=>{const e=async()=>{var e;const t=Date.now(),s=Math.ceil(d);if(0===g.current.time||g.current.hours!==s||t-g.current.time>=6e4){g.current={time:t,hours:s};try{const t=await B(Math.max(s,24));t.success&&(null==(e=t.data)?void 0:e.history)&&v(t.data.history)}catch{}}};e();const t=setInterval(e,6e4);return()=>clearInterval(t)},[d]);const j=e.useMemo(()=>{if(0===f.length)return[];const e=f.reduce((e,t)=>Math.max(e,t.timestamp),0);if(0===e)return[];const t=3600*d,s=e-t,a=t/24,n=[];for(let l=0;l<24;l++){const e=s+l*a,t=e+a,i=f.filter(s=>s.timestamp>=e&&s.timestamp0){const e=i.reduce((e,t)=>e+t.noise_floor_dbm,0)/i.length;n.push(e)}else n.push(n.length>0?n[n.length-1]:-100)}return n},[f,d]),b=null==n?void 0:n.neighbors,N=e.useMemo(()=>{const e=b??{};return Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)))},[b,r]),k=e.useMemo(()=>i.filter(e=>!r.has(e.hash)),[i,r]),w=e.useMemo(()=>function(e){if(0===e.length)return{...De,computedAt:Math.floor(Date.now()/1e3)};const t=Math.floor(Date.now()/1e3),s=e.filter(e=>Number.isFinite(e)),a=e.length>0?[e[e.length-1]]:[],n=e.slice(-4).filter(e=>Number.isFinite(e)),l=Be(s),i=Fe(s,10),r=Fe(s,90),o=Be(a),c=null!==o&&null!==i?o-i:0,d=function(e){if(e.length<2)return 0;const t=e.length;let s=0,a=0,n=0,l=0;const i=e[0].timestamp;for(const o of e){const e=(o.timestamp-i)/3600,t=o.value;s+=e,a+=t,n+=e*t,l+=e*e}const r=t*l-s*s;return Math.abs(r)<1e-4?0:(t*n-s*a)/r}(n.map((e,s)=>({timestamp:t-3600*(n.length-1-s),value:e}))),u=function(e){if(e.length<2)return 0;const t=e.reduce((e,t)=>e+t,0)/e.length,s=e.map(e=>Math.pow(e-t,2)).reduce((e,t)=>e+t,0)/e.length;return Math.sqrt(s)}(n),m=s.length>=12,[x,h]=m?function(e,t,s){const a=Re;return e>=a.DELTA_CRITICAL?[2,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${s.toFixed(1)} dB)`]:e>=a.DELTA_WARNING?[1,`Noise floor ${e.toFixed(1)} dB above baseline`]:t>=a.SLOPE_WARNING?[1,`Noise floor rising ${t.toFixed(1)} dB/hour`]:s>=a.JITTER_WARNING?[1,`Noise floor variable (±${s.toFixed(1)} dB)`]:[0,null]}(c,d,u):[0,null];return{baselineMedian:l,baselineP10:i,baselineP90:r,currentMedian:o,currentSampleCount:a.length,delta:c,slope:d,jitter:u,penalty:x,penaltyReason:h,computedAt:t,isReliable:m}}(j),[j]),_=e.useMemo(()=>function(e,t,s){if(0===e.length)return{neighbors:[],networkScore:0,neighborCount:0,bestLink:null,worstLink:null};const a=e.map(e=>{const a=function(e,t,s){const a=se(e,t,s,0);if(a)switch(a.finalGrade){case"excellent":return 100;case"good":return 80;case"fair":return 60;case"poor":return 40;case"critical":return 20}const n=void 0===e?50:e>=10?100:e>=5?80:e>=0?60:e>=-5?40:20,l=void 0===t?50:t>=-70?100:t>=-80?80:t>=-90?60:t>=-100?40:20;return Math.round(.6*n+.4*l)}(e.avgSnr??void 0,e.avgRssi??void 0,s),n=t[e.hash];return{name:(null==n?void 0:n.name)||(null==n?void 0:n.node_name)||e.prefix,hash:e.hash,rssi:e.avgRssi??-100,snr:e.avgSnr??-10,score:a,advertCount:e.count}});a.sort((e,t)=>t.score-e.score);const n=a.length>0?a.reduce((e,t)=>e+t.score,0)/a.length:0;return{neighbors:a,networkScore:Math.round(n),neighborCount:a.length,bestLink:a.length>0?{name:a[0].name,score:a[0].score}:null,worstLink:a.length>0?{name:a[a.length-1].name,score:a[a.length-1].score}:null}}(k,N,p),[k,N,p]),S=e.useMemo(()=>function(e,t,s){const a=e?Math.max(0,Math.min(100,100-5*e.retryRate)):50;let n=50;null!==t&&(n=Math.max(0,Math.min(100,(t+120)/30*100)));const l=(null==s?void 0:s.networkScore)??50,i=Math.round(.35*a+.25*n+.4*l);let r;return r=i>=85?"excellent":i>=70?"good":i>=50?"fair":i>=30?"congested":"critical",{score:i,status:r,components:{lbtHealth:Math.round(a),noiseHealth:Math.round(n),linkHealth:Math.round(l)}}}(m,h,_),[m,h,_]),[L,T]=e.useState({noiseFloor:null,networkScore:null,channelHealth:null}),A=e.useRef(0);e.useEffect(()=>{const e=()=>{const e=Date.now();e-A.current>3e4&&(A.current=e,T({noiseFloor:h,networkScore:(null==_?void 0:_.networkScore)??null,channelHealth:(null==S?void 0:S.score)??null}))};e();const t=setInterval(e,5e3);return()=>clearInterval(t)},[h,null==_?void 0:_.networkScore,null==S?void 0:S.score]);const $=e.useMemo(()=>({noiseFloor:{current:h,previous:L.noiseFloor,trend:null!==h?Ie(h,L.noiseFloor,2,!0):"stable"},networkScore:{current:(null==_?void 0:_.networkScore)??0,previous:L.networkScore,trend:Ie((null==_?void 0:_.networkScore)??0,L.networkScore,3,!1)},channelHealth:{current:(null==S?void 0:S.score)??0,previous:L.channelHealth,trend:Ie((null==S?void 0:S.score)??0,L.channelHealth,3,!1)}}),[h,null==_?void 0:_.networkScore,null==S?void 0:S.score,L]),P={lbtStats:m,noiseFloor:h,sparklineNoiseFloor:j,linkQuality:_,channelHealth:S,nfTrend:w,radioConfig:p,trends:$,stats:n,recentPackets:l,quickNeighbors:i,isLoading:u,error:null,refresh:async()=>{}};return t.jsx(Ae.Provider,{value:P,children:s})}function Ee(){const t=e.useContext(Ae);if(void 0===t)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function We(e,t){return 0===e?"No backoffs":`${t.toFixed(0)}% retry rate`}function qe(){const{lbtStats:s,isLoading:a,error:n}=Ee(),l=c(),i=(null==s?void 0:s.avgBackoffMs)??0,r=(null==s?void 0:s.retryRate)??0,o=s?(u=i)<100?"excellent":u<250?"good":u<500?"fair":u<1e3?"congested":"critical":"unknown";var u;const m=null==s?void 0:s.sparklineBackoff,{chartData:x,yDomain:h}=e.useMemo(()=>{if(!m||m.length<2)return{chartData:[],yDomain:[0,100]};const e=m.map(e=>({value:e})),t=m.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,100]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,.1*a,10);return{chartData:e,yDomain:[Math.max(0,s-l),a+l]}},[m]);return t.jsx(Ce,{title:"LBT Backoff",icon:t.jsx(d,{className:"mini-widget-icon"}),value:Math.round(i),unit:"ms",status:o,subtitle:s?We(i,r):void 0,isLoading:a,error:n,onClick:()=>l("/packets"),children:t.jsx("div",{className:"mini-widget-sparkline",children:x.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:x,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:h,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Oe(e){return 0===e?"—":e<1?"<1":Math.round(e).toString()}function ze(){const{lbtStats:e,isLoading:s,error:a}=Ee(),n=c(),l=(null==e?void 0:e.channelBusyCount)??0,i=(null==e?void 0:e.totalPacketsWithLBT)??0,r=(null==e?void 0:e.channelBusyRate)??0,o=(null==e?void 0:e.retryRate)??0,d=(null==e?void 0:e.avgBackoffMs)??0,m=(null==e?void 0:e.minBackoffMs)??0,x=(null==e?void 0:e.maxBackoffMs)??0,h=o>0?Math.max(0,(o-r)/o*100):100;return t.jsx(Ce,{title:"Ch. Busy",icon:t.jsx(u,{className:"mini-widget-icon"}),isLoading:s,error:a,onClick:()=>n("/packets"),children:t.jsx("div",{className:"flex-1 flex items-end",children:t.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-2 w-full items-baseline",children:[t.jsx("span",{className:"data-box-label mb-0",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${l} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[l,t.jsx("span",{className:"text-text-muted",children:"/"}),i]}),t.jsx("span",{className:"data-box-label mb-0",title:`${h.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`${h.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:[h.toFixed(0),"%"]}),t.jsx("span",{className:"data-box-label mb-0",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[Oe(d),t.jsx("span",{className:"text-text-muted text-xs",children:"ms"})]}),t.jsx("span",{className:"data-box-label mb-0",title:`Backoff range: ${m.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:"Range:"}),t.jsxs("div",{className:"data-box justify-self-start",title:`Backoff range: ${m.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:[Oe(m),t.jsx("span",{className:"text-text-muted",children:"/"}),Oe(x)]})]})})})}function Ge(e){return null===e?"No reading":e<-115?"Very quiet":e<-105?"Quiet":e<-95?"Moderate":e<-85?"Elevated":"High interference"}function Ke(){const{noiseFloor:s,sparklineNoiseFloor:a,trends:n,isLoading:l,error:i}=Ee(),r=null===(o=s)||o<-110?"excellent":o<-100?"good":o<-90?"fair":o<-80?"congested":"critical";var o;const c=null==n?void 0:n.noiseFloor.trend,{chartData:d,yDomain:u}=e.useMemo(()=>{if(!a||a.length<2)return{chartData:[],yDomain:[-120,-90]};const e=a.map(e=>({value:e})),t=a.filter(e=>-100!==e&&e<-50);if(0===t.length)return{chartData:e,yDomain:[-120,-90]};const s=Math.min(...t),n=Math.max(...t),l=n-s,i=Math.max(.2*l,3);return{chartData:e,yDomain:[s-i,n+i]}},[a]);return t.jsx(Ce,{title:"Noise Floor",icon:t.jsx(m,{className:"mini-widget-icon"}),value:null!==s?Math.round(s):"—",unit:null!==s?"dBm":void 0,status:r,trend:c,subtitle:Ge(s),isLoading:l,error:i,children:t.jsx("div",{className:"mini-widget-sparkline",children:d.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:d,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:u,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ue(){const s=c(),a=C(),n=y(),l=M(),i=D(),r=60*F[i].minutes,o=T(),d=e.useMemo(()=>{if(0===o)return n;const e=o-r;return n.filter(t=>t.timestamp>=e)},[n,r,o]),u=null===l,m=(null==l?void 0:l.local_hash)?S(l.local_hash):"",v=(null==l?void 0:l.neighbors)??{},{neighborHashes:g,neighborNames:j}=e.useMemo(()=>{const e=new Set,t=new Map;for(const s of a){e.add(s.hash);const a=v[s.hash],n=(null==a?void 0:a.name)||(null==a?void 0:a.node_name)||s.prefix;t.set(s.hash,n)}return{neighborHashes:e,neighborNames:t}},[a,v]),b=e.useMemo(()=>{if(0===g.size||0===d.length||!m)return{champion:null,listener:null,loudest:null};const{scores:e}=me(d,g,m),t=[];for(const[l,i]of e)0!==i.blendedScore&&t.push({...i,name:j.get(l)??S(l)});let s=null,a=null,n=null;for(const l of t)(!s||l.blendedScore>s.blendedScore)&&(s=l),(!a||l.listenerScore>a.listenerScore)&&(a=l),(!n||l.loudScore>n.loudScore)&&(n=l);return{champion:s,listener:a,loudest:n}},[d,g,m,j]),{champion:N,listener:k,loudest:w}=b,_=N||k||w?t.jsxs("div",{className:"flex flex-col gap-0.5 mt-auto",children:[N&&t.jsx(A,{content:(L=N,t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",L.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Blended Score: ",L.blendedScore,t.jsx("span",{className:"text-text-muted/60 ml-1",children:"(Listener + Loud)"})]}),t.jsxs("div",{className:"border-t border-border-subtle pt-1 mt-1 space-y-0.5",children:[t.jsxs("div",{children:["Listener: ",L.listenerScore,"/100 (",L.listenerCount," shared paths)"]}),t.jsxs("div",{children:["Loud: ",L.loudScore,"/100 (",L.loudCount," packets relayed)"]})]})]})),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(x,{className:"w-3 h-3 text-map-neighbor-color flex-shrink-0"}),t.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:N.name}),t.jsx("span",{className:"text-map-neighbor-color pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:N.blendedScore})]})}),k&&t.jsx(A,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.listenerScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.listenerCount," packets where they heard your transmissions"]})})]}))(k),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(h,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:k.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:k.listenerScore})]})}),w&&t.jsx(A,{content:(e=>t.jsxs("div",{className:"max-w-[220px]",children:[t.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",e.name]}),t.jsxs("div",{className:"text-text-muted mb-1",children:["Score: ",e.loudScore,"/100"]}),t.jsx("div",{className:"border-t border-border-subtle pt-1 mt-1",children:t.jsxs("div",{children:[e.loudCount," packets they relayed directly to you"]})})]}))(w),children:t.jsxs("div",{className:"flex items-center gap-1 text-sm rounded px-1 -mx-1 hover:bg-white/5 transition-colors cursor-default",children:[t.jsx(p,{className:"w-3 h-3 text-text-muted flex-shrink-0"}),t.jsx("span",{className:"text-text-muted font-mono truncate flex-1 min-w-0",children:w.name}),t.jsx("span",{className:"text-text-muted pl-2 tabular-nums flex-shrink-0 w-9 text-right",children:w.loudScore})]})})]}):0===a.length?t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No direct neighbors"}):t.jsx("div",{className:"flex items-center justify-center text-sm text-text-muted mt-auto",children:"No routing data yet"});var L;return t.jsx(Ce,{title:"Link Leaders",icon:t.jsx(f,{className:"mini-widget-icon"}),isLoading:u,onClick:()=>s("/contacts"),children:_})}function Je(){const{lbtStats:s,isLoading:a,error:n}=Ee(),l=s?function(e){const{retryRate:t,channelBusyCount:s,totalPacketsWithLBT:a,avgBackoffMs:n,maxBackoffMs:l}=e;if(0===a)return 0;const i=Math.min(a/10,1),r=Math.log(1+.15*t)/Math.log(16)*40,o=s/a*100,c=Math.min(.5*o,25);let d=0;n>100&&(d=Math.min(8*Math.log10(n/100),15));let u=0;l>500&&n>0&&l>2*n&&(u=Math.min((l-500)/200,5));const m=(r+c+d+u)*i;return Math.min(m,85)}(s):0,i=s?(r=l)<15?"excellent":r<30?"good":r<45?"fair":r<60?"congested":"critical":"unknown";var r;const o=(null==s?void 0:s.maxBackoffMs)??0,c=s?o>200?`Max backoff: ${Math.round(o)}ms`:function(e){return e<15?"Clear channel":e<30?"Light traffic":e<45?"Moderate traffic":e<60?"Heavy traffic":e<75?"Congested":"Severe congestion"}(l):void 0,d=null==s?void 0:s.sparklineCollisionRisk,{chartData:u,yDomain:m}=e.useMemo(()=>{if(!d||d.length<2)return{chartData:[],yDomain:[0,85]};const e=d.map(e=>({value:e})),t=d.filter(e=>e>0);if(0===t.length)return{chartData:e,yDomain:[0,85]};const s=Math.min(...t),a=Math.max(...t),n=a-s,l=Math.max(.2*n,5);return{chartData:e,yDomain:[Math.max(0,s-l),Math.min(85,a+l)]}},[d]);return t.jsx(Ce,{title:"Collision Risk",icon:t.jsx(v,{className:"mini-widget-icon"}),value:l.toFixed(1),unit:"%",status:i,subtitle:c,isLoading:a,error:n,children:t.jsx("div",{className:"mini-widget-sparkline",children:u.length>0?t.jsx(ae,{width:"100%",height:24,children:t.jsxs(ne,{data:u,margin:{top:2,right:2,bottom:2,left:2},children:[t.jsx(le,{domain:m,hide:!0}),t.jsx(ie,{type:"monotone",dataKey:"value",stroke:"var(--accent-primary)",strokeWidth:2,dot:!1,isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full"})})})}function Ve(){const[s,a]=e.useState(!1),[n]=e.useState(0),{stats:l,lbtStats:r,isLoading:o}=Ee(),c=e.useMemo(()=>{if(!l)return null;const e=l.airtime_used_ms??0,t=l.max_airtime_ms??1;return{usedMs:e,maxMs:t,remainingMs:l.airtime_remaining_ms??0,utilizationPercent:l.utilization_percent??(t>0?e/t*100:0)}},[l]),d=e.useMemo(()=>r&&0!==r.totalPacketsWithLBT?(r.totalPacketsWithLBT-r.packetsWithRetries)/r.totalPacketsWithLBT*100:100,[r]),u=(null==c?void 0:c.utilizationPercent)??0,m=(x=u)<30?"excellent":x<50?"good":x<70?"fair":x<90?"congested":"critical";var x;const h=(null==c?void 0:c.remainingMs)??0,p=d<95?`${d.toFixed(0)}% clean TX`:((f=h)<1e3?`${Math.round(f)}ms`:f<6e4?`${(f/1e3).toFixed(1)}s`:`${(f/6e4).toFixed(1)}m`)+" remaining";var f;const v=c?t.jsx("div",{className:"mini-widget-progress mt-auto",children:t.jsx("div",{className:`mini-widget-progress-bar ${m}`,style:{width:`${Math.min(u,100)}%`}})}):null;return t.jsx(Ce,{title:"Duty Cycle",icon:t.jsx(i,{className:"mini-widget-icon"}),value:u.toFixed(1),unit:"%",status:m,subtitle:p,isLoading:o,children:v})}function Qe(){return t.jsxs("div",{className:"mini-widget",children:[t.jsxs("div",{className:"mini-widget-header",children:[t.jsx(K,{className:"w-4 h-4"}),t.jsx(K,{className:"h-3 w-16"})]}),t.jsx(K,{className:"h-7 w-12 mt-2"}),t.jsx(K,{className:"h-3 w-20 mt-2"})]})}function Xe(){return t.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((e,s)=>t.jsx(Qe,{},s))})}function Ye({className:e="",isLoaded:s=!0}){return t.jsxs("div",{className:`mesh-health-container relative ${e}`,children:[t.jsxs("div",{className:"mesh-health-header",children:[t.jsx(g,{className:"w-4 h-4 text-accent-primary"}),t.jsx("span",{className:"type-label text-text-muted",children:"MESH HEALTH"})]}),s?t.jsx(He,{children:t.jsxs("div",{className:"widget-row",children:[t.jsx(qe,{}),t.jsx(Je,{}),t.jsx(Ke,{}),t.jsx(Ve,{}),t.jsx(ze,{}),t.jsx(Ue,{})]})}):t.jsx(Xe,{})]})}function Ze(){var s,n;const l=M(),r=$(),o=y(),c=P(),d=D(),u=I(),m=H(),x=F[d],h=5===d&&!m.threeDayLoadComplete,p=6===d&&!m.sevenDayLoadComplete,f=7===d&&!m.fourteenDayLoadComplete,v=m.isBackgroundLoading&&(h||p||f),g=O(),k=z(),w=null==(s=null==l?void 0:l.config)?void 0:s.radio,_=e.useMemo(()=>w?{sf:w.spreading_factor??10,bw:w.bandwidth??25e4,cr:w.coding_rate??5,preamble:w.preamble_length??8}:null,[w]),S=o.length,L=e.useMemo(()=>S?E(x.minutes,x.buckets,o,l):null,[S,x.minutes,x.buckets,_]),C=e.useMemo(()=>function(e,t,s){if(!(null==e?void 0:e.length))return[];const a=s>1440?{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}:{hour:"2-digit",minute:"2-digit",hour12:!1};return e.map((e,s)=>{var n;return{time:new Date(1e3*e.start).toLocaleString([],a),received:e.count,unique:(null==(n=null==t?void 0:t[s])?void 0:n.count)??0}})}(null==L?void 0:L.received,null==L?void 0:L.unique_received,x.minutes),[null==L?void 0:L.received,null==L?void 0:L.unique_received,x.minutes]),R=e.useMemo(()=>function(e){if(!e.length)return[0,"auto"];let t=e[0].received,s=e[0].received;for(const n of e)n.receiveds&&(s=n.received),n.uniques&&(s=n.unique);if(t===s)return[Math.max(0,t-1),s+1];const a=.1*(s-t);return[Math.max(0,Math.floor(t-a)),Math.ceil(s+a)]}(C),[C]),B=e.useMemo(()=>{return(e=C.length)<=12?0:e<=24?2:e<=48?5:e<=72?8:Math.floor(e/7);var e},[C.length]),T=e.useMemo(()=>{const e=e=>(null==e?void 0:e.reduce((e,t)=>e+t.count,0))??0,t=e(null==L?void 0:L.received),s=e(null==L?void 0:L.unique_received),a=e(null==L?void 0:L.forwarded),n=e(null==L?void 0:L.dropped),l=e(null==L?void 0:L.transmitted),i=((null==L?void 0:L.time_range_minutes)??x.minutes)/60;return{received:t,uniqueReceived:s,forwarded:a,dropped:n,transmitted:l,rxPerHour:i>0?Math.round(t/i):0,fwdPerHour:i>0?Math.round(a/i):0}},[L,x.minutes]),A=(null==l?void 0:l.node_name)??(null==(n=null==l?void 0:l.config)?void 0:n.node_name)??"Unknown Node";return r?t.jsxs(U,{className:"p-8 text-center",children:[t.jsx("p",{className:"type-subheading text-accent-red mb-2",children:"Failed to connect to backend"}),t.jsx("p",{className:"type-body text-white/50",children:r}),t.jsx("p",{className:"type-data-sm text-white/40 mt-4",children:"Make sure the backend is running on port 8000"})]}):t.jsxs(J,{children:[t.jsx(V,{title:A,icon:t.jsx(j,{}),controls:t.jsx(ee,{ranges:F,selectedIndex:d,onSelect:u,isPending:v})}),t.jsx(xe,{template:"hero",children:t.jsx(U,{isLoaded:c,skeletonType:"chart",compact:!0,children:c&&t.jsxs(t.Fragment,{children:[t.jsx(Q,{icon:t.jsx(a,{}),title:"RECEIVED",badge:x.label,actions:t.jsxs("div",{className:"data-box",children:[T.rxPerHour,"/hr"]})}),t.jsxs("div",{className:"flex gap-8",children:[t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary leading-none",style:{letterSpacing:"-0.05em"},children:T.received.toLocaleString()}),t.jsx("span",{className:"color-pill mb-1",style:{"--pill-color":g.received},children:"Total RF"})]}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsx("div",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary leading-none",style:{letterSpacing:"-0.05em"},children:T.uniqueReceived.toLocaleString()}),t.jsx("span",{className:"color-pill mb-1",style:{"--pill-color":g.forwarded},children:"Unique"})]})]}),t.jsx("div",{className:"mt-8",children:C.length>0?t.jsx(ae,{width:"100%",height:216,children:t.jsxs(re,{data:C,margin:{left:0,right:8,top:0,bottom:0},children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"gradient-received",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"5%",stopColor:g.received,stopOpacity:.3}),t.jsx("stop",{offset:"95%",stopColor:g.received,stopOpacity:0})]}),t.jsxs("linearGradient",{id:"gradient-unique",x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"5%",stopColor:g.forwarded,stopOpacity:.53}),t.jsx("stop",{offset:"95%",stopColor:g.forwarded,stopOpacity:0})]})]}),t.jsx(oe,{strokeDasharray:"3 3",stroke:k.grid,vertical:!1}),t.jsx(ce,{dataKey:"time",axisLine:!1,tickLine:!1,tick:{fill:k.axisTick,fontSize:10,fontFamily:W},dy:8,interval:B,minTickGap:20}),t.jsx(le,{domain:R,axisLine:!1,tickLine:!1,tick:{fill:k.axisTick,fontSize:10,fontFamily:W},dx:-4,width:28}),t.jsx(de,{content:t.jsx(we,{labelKey:"time"}),cursor:{stroke:k.cursor,strokeWidth:1}}),t.jsx(ue,{type:"stepAfter",dataKey:"received",name:"Total RF",stroke:g.received,fill:"url(#gradient-received)",strokeWidth:1.5,dot:!1,activeDot:{r:4,strokeWidth:0,fill:g.received},isAnimationActive:!1}),t.jsx(ue,{type:"stepAfter",dataKey:"unique",name:"Unique",stroke:g.forwarded,fill:"url(#gradient-unique)",strokeWidth:1.5,dot:!1,activeDot:{r:4,strokeWidth:0,fill:g.forwarded},isAnimationActive:!1})]})}):t.jsx("div",{className:"h-full flex items-center justify-center text-text-muted",children:"No data available for this time range"})})]})})}),t.jsxs(xe,{template:"compact",children:[t.jsx(he,{span:12,md:6,lg:4,children:t.jsx(ge,{title:"FORWARDED",value:T.forwarded,color:"forwarded",buckets:null==L?void 0:L.forwarded,receivedCount:T.received,timeRangeLabel:x.label,icon:t.jsx(b,{className:"w-4 h-4"}),isLoaded:c})}),t.jsx(he,{span:12,md:6,lg:4,children:t.jsx(ge,{title:"DROPPED",value:T.dropped,color:"dropped",buckets:null==L?void 0:L.dropped,receivedCount:T.received,timeRangeLabel:x.label,icon:t.jsx(N,{className:"w-4 h-4"}),isLoaded:c})}),t.jsx(he,{span:12,md:12,lg:4,children:t.jsx(ye,{stats:l,receivedBuckets:null==L?void 0:L.received,droppedBuckets:null==L?void 0:L.dropped,forwardedBuckets:null==L?void 0:L.forwarded,bucketDurationSeconds:null==L?void 0:L.bucket_duration_seconds,timeRangeLabel:x.label,isLoaded:c})})]}),t.jsx(Ye,{isLoaded:c}),t.jsx(ke,{}),l&&t.jsx(xe,{template:"auto",children:t.jsxs(U,{children:[t.jsx(Q,{icon:t.jsx(i,{}),title:"Node Information",largeTitle:!0}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Node Name"}),t.jsx("p",{className:"type-body text-text-primary mt-1 truncate",title:A,children:A})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Repeater"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${l.version}`,children:["v",l.version]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Core"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${l.core_version}`,children:["v",l.core_version]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Console"}),t.jsxs("p",{className:"type-data text-text-primary mt-1 truncate",title:`v${q}`,children:["v",q]})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Local Hash"}),t.jsx("div",{className:"mt-1",children:l.local_hash?t.jsx(te,{copy:!0,size:"compact",children:l.local_hash}):t.jsx("span",{className:"type-data-sm text-text-secondary",children:"N/A"})})]})]}),l.public_key&&t.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:[t.jsx("span",{className:"type-label text-text-secondary",children:"Public Key"}),t.jsx("div",{className:"mt-1",children:t.jsx(te,{copy:!0,children:l.public_key})})]})]})})]})}export{Ze as default}; diff --git a/frontend/dist/assets/Login-DxQgqPyH.js b/frontend/dist/assets/Login-D81eBYn4.js similarity index 99% rename from frontend/dist/assets/Login-DxQgqPyH.js rename to frontend/dist/assets/Login-D81eBYn4.js index 9d7a17fe..7dfc5d44 100644 --- a/frontend/dist/assets/Login-DxQgqPyH.js +++ b/frontend/dist/assets/Login-D81eBYn4.js @@ -1 +1 @@ -import{r as e,j as s,x as t}from"./vendor-react-DtVWNgeu.js";import{g as r,i as a,P as n,s as l,l as o}from"./index-BIsccma_.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./recharts-C9LxPobD.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-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-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-sm 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-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-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-sm",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-sm",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-DtVWNgeu.js";import{g as r,i as a,P as n,s as l,l as o}from"./index-Bmit1I8S.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./recharts-C9LxPobD.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-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-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-sm 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-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-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-sm",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-sm",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-YP9BpQVI.js b/frontend/dist/assets/Logs-DmMC1IFZ.js similarity index 97% rename from frontend/dist/assets/Logs-YP9BpQVI.js rename to frontend/dist/assets/Logs-DmMC1IFZ.js index 5118a2f4..582bf29e 100644 --- a/frontend/dist/assets/Logs-YP9BpQVI.js +++ b/frontend/dist/assets/Logs-DmMC1IFZ.js @@ -1 +1 @@ -import{r as e,j as s,F as a,aZ as t,a_ as r}from"./vendor-react-DtVWNgeu.js";import{c as l}from"./recharts-C9LxPobD.js";import{ab as i,ac as c,b as n,ad as o,r as m,aa as x,ae as d}from"./index-BIsccma_.js";import{u as h}from"./usePolling-DXhhvgB-.js";import{P as p,b as j,a as g,c as u,L as v}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const f=e.memo(function({log:e}){return s.jsx("div",{className:"p-3 rounded-2xl bg-white/[0.02] hover:bg-white/[0.04] transition-colors",children:s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("span",{className:l("type-data-sm w-14 shrink-0",d(e.level)),children:e.level}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"type-data-sm text-text-primary break-words whitespace-pre-wrap",children:e.message}),s.jsx("p",{className:"type-data-xs text-text-muted mt-1",children:new Date(e.timestamp).toLocaleString()})]})]})})});function w({showDebug:e,onToggle:a}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:l("type-data-sm",e?"text-accent-tertiary":"text-accent-primary"),children:e?"DEBUG":"INFO"}),s.jsx("button",{onClick:a,className:l("relative w-10 h-5 rounded-full transition-colors duration-200",e?"bg-accent-tertiary":"bg-accent-primary"),role:"switch","aria-checked":e,children:s.jsx("span",{className:l("absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow-sm transition-transform duration-200",e?"translate-x-5":"translate-x-0")})})]})}function N(){const d=i(),N=c(),b=n(),y=o(),k=m(),[D,L]=e.useState(!1),P=e.useCallback(()=>{L(e=>!e)},[]),C=D?d:d.filter(e=>"DEBUG"!==e.level);return h(y,x.logs,b),s.jsxs(p,{children:[s.jsx(j,{title:"System Logs",icon:s.jsx(a,{}),controls:s.jsx(w,{showDebug:D,onToggle:P})}),s.jsxs(g,{noPadding:!0,children:[s.jsx(u,{listHeader:!0,icon:s.jsx(a,{className:"icon-sm"}),title:"Log Entries",actions:s.jsx("button",{onClick:()=>k(!b),className:l("transition-colors",b?"text-signal-critical hover:text-signal-critical/80":"text-accent-primary hover:text-accent-primary/80 animate-pulse-slow"),title:b?"Pause":"Resume",children:b?s.jsx(t,{className:"w-5 h-5"}):s.jsx(r,{className:"w-5 h-5"})})}),s.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:N&&0===d.length?s.jsx(v,{count:10}):0===C.length?s.jsx("div",{className:"text-center py-12 text-text-muted",children:0===d.length?"No logs available":"No logs match selected filters"}):C.map((e,a)=>s.jsx(f,{log:e},`${e.timestamp}-${a}`))})]})]})}export{N as default}; +import{r as e,j as s,F as a,aZ as t,a_ as r}from"./vendor-react-DtVWNgeu.js";import{c as l}from"./recharts-C9LxPobD.js";import{ab as i,ac as c,b as n,ad as o,r as m,aa as x,ae as d}from"./index-Bmit1I8S.js";import{u as h}from"./usePolling-DXhhvgB-.js";import{P as p,b as j,a as g,c as u,L as v}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const f=e.memo(function({log:e}){return s.jsx("div",{className:"p-3 rounded-2xl bg-white/[0.02] hover:bg-white/[0.04] transition-colors",children:s.jsxs("div",{className:"flex items-baseline gap-3",children:[s.jsx("span",{className:l("type-data-sm w-14 shrink-0",d(e.level)),children:e.level}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"type-data-sm text-text-primary break-words whitespace-pre-wrap",children:e.message}),s.jsx("p",{className:"type-data-xs text-text-muted mt-1",children:new Date(e.timestamp).toLocaleString()})]})]})})});function w({showDebug:e,onToggle:a}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:l("type-data-sm",e?"text-accent-tertiary":"text-accent-primary"),children:e?"DEBUG":"INFO"}),s.jsx("button",{onClick:a,className:l("relative w-10 h-5 rounded-full transition-colors duration-200",e?"bg-accent-tertiary":"bg-accent-primary"),role:"switch","aria-checked":e,children:s.jsx("span",{className:l("absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow-sm transition-transform duration-200",e?"translate-x-5":"translate-x-0")})})]})}function N(){const d=i(),N=c(),b=n(),y=o(),k=m(),[D,L]=e.useState(!1),P=e.useCallback(()=>{L(e=>!e)},[]),C=D?d:d.filter(e=>"DEBUG"!==e.level);return h(y,x.logs,b),s.jsxs(p,{children:[s.jsx(j,{title:"System Logs",icon:s.jsx(a,{}),controls:s.jsx(w,{showDebug:D,onToggle:P})}),s.jsxs(g,{noPadding:!0,children:[s.jsx(u,{listHeader:!0,icon:s.jsx(a,{className:"icon-sm"}),title:"Log Entries",actions:s.jsx("button",{onClick:()=>k(!b),className:l("transition-colors",b?"text-signal-critical hover:text-signal-critical/80":"text-accent-primary hover:text-accent-primary/80 animate-pulse-slow"),title:b?"Pause":"Resume",children:b?s.jsx(t,{className:"w-5 h-5"}):s.jsx(r,{className:"w-5 h-5"})})}),s.jsx("div",{className:"space-y-2 max-h-[calc(100vh-300px)] sm:max-h-[calc(100vh-250px)] overflow-y-auto p-4",children:N&&0===d.length?s.jsx(v,{count:10}):0===C.length?s.jsx("div",{className:"text-center py-12 text-text-muted",children:0===d.length?"No logs available":"No logs match selected filters"}):C.map((e,a)=>s.jsx(f,{log:e},`${e.timestamp}-${a}`))})]})]})}export{N as default}; diff --git a/frontend/dist/assets/PacketDetailModal-ZVXSkr9b.js b/frontend/dist/assets/PacketDetailModal-I-Pe3tob.js similarity index 99% rename from frontend/dist/assets/PacketDetailModal-ZVXSkr9b.js rename to frontend/dist/assets/PacketDetailModal-I-Pe3tob.js index b2ab4fbb..39210e9e 100644 --- a/frontend/dist/assets/PacketDetailModal-ZVXSkr9b.js +++ b/frontend/dist/assets/PacketDetailModal-I-Pe3tob.js @@ -1,2 +1,2 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-BJr4IqeH.js","assets/vendor-react-DtVWNgeu.js","assets/vendor-core-WoOfkQwm.js","assets/BasemapLayer-00O5HUtM.js","assets/maplibre-gl-B1CfjdFi.css"])))=>i.map(i=>d[i]); -import{r as e,$ as t,a3 as s,D as a,a4 as n,_ as r,j as o,a5 as c,a6 as i,a7 as l,a8 as d,b as p,X as x,h,a9 as u,k as m,aa as f,ab as g}from"./vendor-react-DtVWNgeu.js";import{c as b}from"./recharts-C9LxPobD.js";import{t as y,R as j,x as v,y as N,z as w,A as _,d as k,c as M,B as T,C,E as P,G as E}from"./index-BIsccma_.js";import{S,g as D}from"./SignalIndicator-DagI_WOB.js";import{D as R}from"./DataBox-Dl3NmnnB.js";import{g as A}from"./useScientificColormap-nDz0kTVE.js";import{_ as L}from"./deckgl-DTsmDcfs.js";function O(e){return null==e?"UNKNOWN":y[e]||`TYPE_${e}`}function F(e){return null==e?"UNKNOWN":j[e]||`ROUTE_${e}`}const V={REQ:v.REQ,RESPONSE:v.RESPONSE,TXT_MSG:v.TXT_MSG,ACK:v.ACK,ADVERT:v.ADVERT,GRP_TXT:v.GRP_TXT,GRP_DATA:v.GRP_DATA,ANON_REQ:v.ANON_REQ,PATH:v.PATH,TRACE:v.TRACE,MULTIPART:v.MULTIPART,RAW_CUSTOM:v.RAW_CUSTOM};function U(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function z(e){const t=function(e){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16)/255,a=parseInt(t.slice(2,4),16)/255,n=parseInt(t.slice(4,6),16)/255,r=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);return.2126*r(s)+.7152*r(a)+.0722*r(n)}(e);return U(t,1)>U(t,0)?"light":"dark"}const I={light:"rgba(255, 255, 255, 0.95)",dark:"rgba(0, 0, 0, 0.85)"};function H(e){const t=function(e){return A(V[e])}(e),s=z(t);return{bgColor:t,textColor:I[s]}}function $(e){return{FLOOD:"var(--route-flood)",DIRECT:"var(--route-direct)",TRANSPORT:"var(--route-transport)",T_FLOOD:"var(--route-flood)",T_DIRECT:"var(--route-direct)"}[e]||"var(--text-muted)"}function G(e){return 1===e||!0===e}const X={light:"rgba(255, 255, 255, 0.95)",dark:"rgba(0, 0, 0, 0.85)"},Q={rx:{icon:r,label:"RX",colorVar:"var(--accent-primary)"},tx:{icon:n,label:"TX",colorVar:"var(--accent-secondary)"},forward:{icon:a,label:"FWD",colorVar:"var(--accent-success)"},dropped:{icon:s,label:"DROP",colorVar:"var(--accent-danger)"},duplicate:{icon:t,label:"DUPE",colorVar:"var(--text-muted)"}},W={rx:"#719CDF",tx:"#DFBC72",forward:"#719872",dropped:"#E12672",duplicate:"#727272"},q={sm:"w-3.5 h-3.5",md:"w-4 h-4"};function K(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 B=e.memo(function({packet:t,showLabel:s=!0,size:a="sm"}){const n=K(t),r=Q[n],c=r.icon,i=e.useMemo(()=>{const e=z(W[n]);return X[e]},[n]);return o.jsxs("span",{className:"color-pill color-pill-filled",style:{"--pill-color":r.colorVar,"--pill-text":i},children:[o.jsx(c,{className:q[a]}),s&&r.label]})});function Y(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 J(e){return Q[K(e)].colorVar}function Z(e){const t=e.payload_type_name||O(e.payload_type??e.type);return{payloadType:t,routeType:e.route_type_name||F(e.route_type??e.route),typeColor:H(t)}}function ee({packet:e,onClick:t,isFlashing:s=!1,isPending:a}){const{payloadType:n,routeType:r,typeColor:i}=Z(e),l="tx_local"===e.packet_origin,d=a??e.isPending;return o.jsxs("tr",{onClick:()=>t(e),className:b("cursor-pointer","hover:bg-bg-subtle",G(e.is_duplicate)&&"opacity-50",s&&"flash-row",d&&"opacity-70 bg-accent-secondary/5",l&&"ring-1 ring-inset ring-accent-primary/60 bg-accent-primary/5"),children:[o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsxs("div",{className:"inline-flex items-center gap-1",children:[o.jsx(B,{packet:e,showLabel:!0}),o.jsx("span",{className:"w-3 h-3 inline-flex items-center justify-center",children:d&&o.jsx(c,{className:"w-3 h-3 text-accent-secondary animate-spin"})})]})}),o.jsx("td",{className:"py-2.5 px-3 text-sm font-mono text-text-secondary whitespace-nowrap",children:w(e.timestamp)}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:e.src_hash?o.jsx(R,{copy:!0,copyValue:e.src_hash_full,size:"compact",children:e.src_hash}):o.jsx("span",{className:"text-sm text-text-muted",children:"—"})}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsx("span",{className:"color-pill color-pill-filled",style:{"--pill-color":i.bgColor,"--pill-text":i.textColor},children:n})}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsx("span",{className:"color-pill",style:{"--pill-color":$(r)},children:r})}),o.jsx("td",{className:"py-2.5 px-3 pr-4 whitespace-nowrap",children:o.jsx("div",{className:"flex justify-end",children:o.jsx(S,{rssi:e.rssi,snr:e.snr,compact:!0,showValues:!0})})})]})}const te=e.memo(function(e){return o.jsx(ee,{...e})}),se=e.memo(function({packet:e,onClick:t,isFlashing:s=!1,isPending:a}){const{payloadType:n,routeType:r,typeColor:i}=Z(e),l="tx_local"===e.packet_origin,d=a??e.isPending;return o.jsx("div",{onClick:()=>t(e),className:b("packet-row px-3 py-2.5 cursor-pointer","hover:bg-bg-subtle","active:bg-bg-elevated",G(e.is_duplicate)&&"opacity-50",s&&"flash-row",d&&"opacity-70 bg-accent-secondary/5",l&&"ring-1 ring-inset ring-accent-primary/60 bg-accent-primary/5"),children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center gap-1",children:[o.jsx(B,{packet:e,showLabel:!0,size:"sm"}),o.jsx("span",{className:"w-3 h-3 inline-flex items-center justify-center",children:d&&o.jsx(c,{className:"w-3 h-3 text-accent-secondary animate-spin"})})]}),o.jsx("span",{className:"text-[10px] font-mono text-text-muted flex-shrink-0",children:N(e.timestamp)}),o.jsx("div",{className:"flex-shrink-0",children:e.src_hash?o.jsx(R,{copy:!0,copyValue:e.src_hash_full,size:"compact",children:e.src_hash}):o.jsx("span",{className:"text-[10px] text-text-muted",children:"—"})}),o.jsx("div",{className:"flex-1 min-w-0"}),o.jsx("span",{className:"color-pill color-pill-filled flex-shrink-0",style:{"--pill-color":i.bgColor,"--pill-text":i.textColor},children:n}),o.jsx("span",{className:"color-pill flex-shrink-0",style:{"--pill-color":$(r)},children:r}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(S,{rssi:e.rssi,compact:!0,showValues:!0})})]})})});function ae(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 ne=e.lazy(()=>L(()=>import("./PathMapMapLibre-BJr4IqeH.js"),__vite__mapDeps([0,1,2,3,4])));function re(e){return`${(100*e).toFixed(0)}%`}function oe(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 ce extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?o.jsxs("div",{className:"h-[200px] flex items-center justify-center text-text-muted",children:[o.jsx(d,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function ie({path:t,neighbors:s,localNode:a,localHash:n,srcHash:r,dstHash:c,neighborAffinity:d,prefixLookup:p,hubNodes:x}){const[h,u]=e.useState(null),m=e.useMemo(()=>{if(!r)return null;const e=k(r),t=s[r];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:r,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)||r.slice(0,8);return{prefix:e,candidates:[{hash:r,name:a,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[r,s]),f=e.useMemo(()=>{if(!c)return null;const e=k(c);if(n&&c===n&&a){const t=0!==a.latitude||0!==a.longitude;return{prefix:e,candidates:[{hash:c,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[c];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:c,name:t.node_name||t.name||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const r=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||c.slice(0,8);return{prefix:e,candidates:[{hash:c,name:r,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[c,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:p,totalMatches:x}=function(e,t,s,a,n=!1,r,o,c){const i=function(e){const t={};for(const[s,a]of Object.entries(e))ae(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:p}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),o=[],c=s&&_(r,s);c&&o.push(s);for(const h of Object.keys(t))_(r,h)&&o.push(h);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,p=-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>p&&(p=s,d=e)}d||(d=l[0])}else l.length>0&&(d=l[0]);let x=i;if(o.length>1&&a&&p>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&&(x=Math.min(.95,p/e))}return{matches:o,probability:x,bestMatch:d}}(e,i,a,r,n),x=d.length,h=[],u=e.toUpperCase(),m=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const g of d){if(a&&_(u,a)&&g===a&&m&&s){h.push({hash:g,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:p,isLocal:!0});continue}const e=i[g];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&h.push({hash:g,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:p,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const f=h.length;if(1===f)h[0].probability=l??1;else if(f>1)if(void 0!==l&&l>0){h[0].probability=l;const e=1-l,t=f-1;h.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=h.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;h.forEach(t=>t.probability=e)}}return{candidates:h,totalMatches:x}}(c,t,s,a,l,n,r,d),h=p.length>0?Math.max(...p.map(e=>e.probability)):0;return{prefix:c,candidates:p,confidence:h,totalMatches:x}}),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,p),[t,s,a,n,d,p]),y=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 y.hasValidPath?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-text-muted",children:"Path Confidence:"}),o.jsx("span",{className:(j=y.overallConfidence,j>=1?"text-accent-success":j>=.5?"text-accent-secondary":j>=.25?"text-signal-poor":j>0?"text-accent-danger":"text-text-muted"),children:re(y.overallConfidence)}),o.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:o.jsx(l,{className:"w-3 h-3"})})]}),o.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),o.jsx("span",{className:"text-text-muted",children:"Exact"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),o.jsx("span",{className:"text-text-muted",children:"Multi"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),o.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),o.jsx("div",{className:"rounded-lg overflow-hidden border border-border-subtle",children:o.jsx(ce,{children:o.jsx(e.Suspense,{fallback:o.jsx("div",{className:"h-[200px] bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:o.jsx(ne,{resolvedPath:y,localNode:a,hubNodes:x,hoveredHopIndex:h,onHoverHop:u})})})}),o.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:y.hops.map((e,t)=>{var s,a,n;const r=!0===e.isSource,c=!0===e.isDestination,i=h===t;let l;return l=r?`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)`,o.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",r&&"border border-accent-success/30",c&&"border border-accent-primary/30"),title:l,onMouseEnter:()=>u(t),onMouseLeave:()=>u(null),children:[r&&o.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),c&&o.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),o.jsx("span",{style:oe(e.confidence,e.totalMatches),children:e.prefix}),!r&&!c&&e.totalMatches>1&&o.jsxs("span",{className:"text-text-muted",children:["×",e.totalMatches]}),!r&&!c&&0===e.totalMatches&&o.jsx("span",{className:"text-text-muted",children:"?"})]},t)})})]}):o.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[o.jsx(i,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var j}function le(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function de({label:e,children:t,compact:s=!1}){return o.jsxs("div",{className:b("flex flex-col",s?"gap-0.5":"gap-1"),children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:e}),o.jsx("span",{className:b("text-text-primary","text-sm"),children:t})]})}function pe({originalPath:e,forwardedPath:t,ghostPrefixes:s}){const n=t.length>0?t:e;if(0===n.length)return o.jsx("span",{className:"text-sm text-text-muted",children:"No path data"});const r=e=>null==s?void 0:s.has(e.toUpperCase());return o.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n.map((e,t)=>o.jsxs("div",{className:"flex items-center gap-1",children:[r(e)?o.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-sm",children:[o.jsx(h,{className:"w-3 h-3"}),e.toUpperCase()]}):o.jsx(R,{copy:!0,size:"compact",children:e}),t{const e=e=>{"Escape"===e.key&&a()};window.addEventListener("keydown",e);const t=document.body.style.overflow,s=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=s,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,o)}},[a]);const j=M(),v=T(),N=C(),w=P(),_=e.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),k=s.payload_type_name||O(s.payload_type??s.type),A=s.route_type_name||F(s.route_type??s.route),L=s.payload_length??s.length??0,V=s.tx_delay_ms??0,U=le(s.original_path),z=le(s.forwarded_path),I=U.length>0||z.length>0,H=z.length>0?z:U,$=e.useMemo(()=>{var e;if(null==(e=null==j?void 0:j.config)?void 0:e.repeater)return{latitude:j.config.repeater.latitude,longitude:j.config.repeater.longitude,name:j.config.node_name||"Local Node"}},[j]),G=(null==j?void 0:j.neighbors)??{},X=N.size>0?N:void 0,Q=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}}(s.payload),W=s.payload&&s.payload.length>0,q=s.raw_packet&&s.raw_packet.length>0,K=e.useCallback(async(e,t)=>{try{await navigator.clipboard.writeText(e),y(t),setTimeout(()=>y(null),2e3)}catch{}},[]);return p.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:a,role:"dialog","aria-modal":"true","aria-labelledby":"packet-modal-title",children:o.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:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(B,{packet:s,showLabel:!0,size:"md"}),o.jsxs("div",{children:[o.jsx("h3",{id:"packet-modal-title",className:b("text-base font-semibold",(ee=k,{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)]"}[ee]||"text-[var(--pkt-unknown)]")),children:k}),o.jsx("p",{className:"text-sm text-text-muted",children:E(s.timestamp)})]})]}),o.jsx("button",{onClick:a,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:o.jsx(x,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4 overscroll-contain",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(de,{label:"Packet Hash",children:o.jsx(R,{copy:!0,size:"compact",children:s.packet_hash})}),o.jsx(de,{label:"Route",children:o.jsx("span",{className:b("px-2 py-0.5 rounded text-sm border font-medium",(Z=A,{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"}[Z]||"bg-bg-subtle text-text-muted border-border-subtle")),children:A})})]}),o.jsx("div",{className:"glass-card-inner p-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-text-muted mb-1",children:"Signal Quality"}),o.jsx("p",{className:"text-sm font-medium text-text-primary",children:D(s.rssi)})]}),o.jsx(S,{rssi:s.rssi,snr:s.snr,showValues:!0})]})}),(s.src_hash||s.dst_hash)&&o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.src_hash&&o.jsx(de,{label:"Source",children:o.jsx(R,{copy:!0,size:"compact",children:s.src_hash})}),s.dst_hash&&o.jsx(de,{label:"Destination",children:o.jsx(R,{copy:!0,size:"compact",children:s.dst_hash})})]}),I&&o.jsxs("div",{className:"glass-card-inner p-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("p",{className:"text-sm text-text-muted",children:"Packet Path"}),H.some(e=>_.has(e.toUpperCase()))&&o.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:[o.jsx(h,{className:"w-3 h-3"}),o.jsx("span",{children:"Ghost Detected"})]})]}),o.jsx(pe,{originalPath:U,forwardedPath:z,ghostPrefixes:_})]}),I&&H.length>0&&o.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[o.jsxs("button",{onClick:()=>l(!i),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(u,{className:"w-4 h-4 text-accent-primary"}),o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:"Path Map"})]}),i?o.jsx(m,{className:"w-4 h-4 text-text-muted"}):o.jsx(f,{className:"w-4 h-4 text-text-muted"})]}),i&&o.jsx("div",{className:"px-3 pb-3",children:o.jsx(ie,{path:H,neighbors:G,localNode:$,localHash:null==j?void 0:j.local_hash,srcHash:s.src_hash,dstHash:s.dst_hash,neighborAffinity:X,hubNodes:[...v]})})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsx(de,{label:"Size",compact:!0,children:o.jsxs("span",{className:"font-mono",children:[L,"B"]})}),o.jsx(de,{label:"TX Delay",compact:!0,children:o.jsxs("span",{className:"font-mono",children:[V.toFixed(1),"ms"]})}),o.jsx(de,{label:"Score",compact:!0,children:o.jsx("span",{className:"font-mono",children:void 0!==s.score?s.score.toFixed(3):"—"})})]}),o.jsx(de,{label:"Status",children:o.jsx("span",{className:J(s),children:Y(s)})}),W&&o.jsxs("div",{className:"glass-card-inner p-3",children:[o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"Payload"}),Q.isText&&Q.text?o.jsx("div",{className:"bg-bg-base rounded p-2",children:o.jsx("p",{className:"text-sm text-text-primary font-mono break-all",children:Q.text})}):o.jsxs("p",{className:"text-sm text-text-muted font-mono break-all",children:[null==(n=s.payload)?void 0:n.slice(0,100),s.payload&&s.payload.length>100&&"..."]})]}),q&&o.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[o.jsxs("button",{onClick:()=>c(!r),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[o.jsx("span",{className:"text-sm text-text-muted",children:"Raw Packet Hex"}),r?o.jsx(m,{className:"w-4 h-4 text-text-muted"}):o.jsx(f,{className:"w-4 h-4 text-text-muted"})]}),r&&o.jsx("div",{className:"px-3 pb-3",children:o.jsxs("div",{className:"bg-bg-base rounded p-2 relative",children:[o.jsx("pre",{className:"text-[10px] text-text-secondary font-mono break-all whitespace-pre-wrap",children:s.raw_packet}),o.jsx("button",{onClick:()=>K(s.raw_packet,"raw"),className:"absolute top-2 right-2 p-1 rounded bg-bg-elevated hover:bg-bg-subtle transition-colors",children:"raw"===d?o.jsx(g,{className:"w-3 h-3 text-accent-success"}):o.jsx(t,{className:"w-3 h-3 text-text-muted"})})]})})]})]})]})}),document.body);var Z,ee});export{te as P,se as a,xe as b,K as g}; +import{r as e,$ as t,a3 as s,D as a,a4 as n,_ as r,j as o,a5 as c,a6 as i,a7 as l,a8 as d,b as p,X as x,h,a9 as u,k as m,aa as f,ab as g}from"./vendor-react-DtVWNgeu.js";import{c as b}from"./recharts-C9LxPobD.js";import{t as y,R as j,x as v,y as N,z as w,A as _,d as k,c as M,B as T,C,E as P,G as E}from"./index-Bmit1I8S.js";import{S,g as D}from"./SignalIndicator-DagI_WOB.js";import{D as R}from"./DataBox-Dl3NmnnB.js";import{g as A}from"./useScientificColormap-n_Aivg5g.js";import{_ as L}from"./deckgl-DTsmDcfs.js";function O(e){return null==e?"UNKNOWN":y[e]||`TYPE_${e}`}function F(e){return null==e?"UNKNOWN":j[e]||`ROUTE_${e}`}const V={REQ:v.REQ,RESPONSE:v.RESPONSE,TXT_MSG:v.TXT_MSG,ACK:v.ACK,ADVERT:v.ADVERT,GRP_TXT:v.GRP_TXT,GRP_DATA:v.GRP_DATA,ANON_REQ:v.ANON_REQ,PATH:v.PATH,TRACE:v.TRACE,MULTIPART:v.MULTIPART,RAW_CUSTOM:v.RAW_CUSTOM};function U(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function z(e){const t=function(e){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16)/255,a=parseInt(t.slice(2,4),16)/255,n=parseInt(t.slice(4,6),16)/255,r=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);return.2126*r(s)+.7152*r(a)+.0722*r(n)}(e);return U(t,1)>U(t,0)?"light":"dark"}const I={light:"rgba(255, 255, 255, 0.95)",dark:"rgba(0, 0, 0, 0.85)"};function H(e){const t=function(e){return A(V[e])}(e),s=z(t);return{bgColor:t,textColor:I[s]}}function $(e){return{FLOOD:"var(--route-flood)",DIRECT:"var(--route-direct)",TRANSPORT:"var(--route-transport)",T_FLOOD:"var(--route-flood)",T_DIRECT:"var(--route-direct)"}[e]||"var(--text-muted)"}function G(e){return 1===e||!0===e}const X={light:"rgba(255, 255, 255, 0.95)",dark:"rgba(0, 0, 0, 0.85)"},Q={rx:{icon:r,label:"RX",colorVar:"var(--accent-primary)"},tx:{icon:n,label:"TX",colorVar:"var(--accent-secondary)"},forward:{icon:a,label:"FWD",colorVar:"var(--accent-success)"},dropped:{icon:s,label:"DROP",colorVar:"var(--accent-danger)"},duplicate:{icon:t,label:"DUPE",colorVar:"var(--text-muted)"}},W={rx:"#719CDF",tx:"#DFBC72",forward:"#719872",dropped:"#E12672",duplicate:"#727272"},q={sm:"w-3.5 h-3.5",md:"w-4 h-4"};function K(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 B=e.memo(function({packet:t,showLabel:s=!0,size:a="sm"}){const n=K(t),r=Q[n],c=r.icon,i=e.useMemo(()=>{const e=z(W[n]);return X[e]},[n]);return o.jsxs("span",{className:"color-pill color-pill-filled",style:{"--pill-color":r.colorVar,"--pill-text":i},children:[o.jsx(c,{className:q[a]}),s&&r.label]})});function Y(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 J(e){return Q[K(e)].colorVar}function Z(e){const t=e.payload_type_name||O(e.payload_type??e.type);return{payloadType:t,routeType:e.route_type_name||F(e.route_type??e.route),typeColor:H(t)}}function ee({packet:e,onClick:t,isFlashing:s=!1,isPending:a}){const{payloadType:n,routeType:r,typeColor:i}=Z(e),l="tx_local"===e.packet_origin,d=a??e.isPending;return o.jsxs("tr",{onClick:()=>t(e),className:b("cursor-pointer","hover:bg-bg-subtle",G(e.is_duplicate)&&"opacity-50",s&&"flash-row",d&&"opacity-70 bg-accent-secondary/5",l&&"ring-1 ring-inset ring-accent-primary/60 bg-accent-primary/5"),children:[o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsxs("div",{className:"inline-flex items-center gap-1",children:[o.jsx(B,{packet:e,showLabel:!0}),o.jsx("span",{className:"w-3 h-3 inline-flex items-center justify-center",children:d&&o.jsx(c,{className:"w-3 h-3 text-accent-secondary animate-spin"})})]})}),o.jsx("td",{className:"py-2.5 px-3 text-sm font-mono text-text-secondary whitespace-nowrap",children:w(e.timestamp)}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:e.src_hash?o.jsx(R,{copy:!0,copyValue:e.src_hash_full,size:"compact",children:e.src_hash}):o.jsx("span",{className:"text-sm text-text-muted",children:"—"})}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsx("span",{className:"color-pill color-pill-filled",style:{"--pill-color":i.bgColor,"--pill-text":i.textColor},children:n})}),o.jsx("td",{className:"py-2.5 px-3 whitespace-nowrap",children:o.jsx("span",{className:"color-pill",style:{"--pill-color":$(r)},children:r})}),o.jsx("td",{className:"py-2.5 px-3 pr-4 whitespace-nowrap",children:o.jsx("div",{className:"flex justify-end",children:o.jsx(S,{rssi:e.rssi,snr:e.snr,compact:!0,showValues:!0})})})]})}const te=e.memo(function(e){return o.jsx(ee,{...e})}),se=e.memo(function({packet:e,onClick:t,isFlashing:s=!1,isPending:a}){const{payloadType:n,routeType:r,typeColor:i}=Z(e),l="tx_local"===e.packet_origin,d=a??e.isPending;return o.jsx("div",{onClick:()=>t(e),className:b("packet-row px-3 py-2.5 cursor-pointer","hover:bg-bg-subtle","active:bg-bg-elevated",G(e.is_duplicate)&&"opacity-50",s&&"flash-row",d&&"opacity-70 bg-accent-secondary/5",l&&"ring-1 ring-inset ring-accent-primary/60 bg-accent-primary/5"),children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center gap-1",children:[o.jsx(B,{packet:e,showLabel:!0,size:"sm"}),o.jsx("span",{className:"w-3 h-3 inline-flex items-center justify-center",children:d&&o.jsx(c,{className:"w-3 h-3 text-accent-secondary animate-spin"})})]}),o.jsx("span",{className:"text-[10px] font-mono text-text-muted flex-shrink-0",children:N(e.timestamp)}),o.jsx("div",{className:"flex-shrink-0",children:e.src_hash?o.jsx(R,{copy:!0,copyValue:e.src_hash_full,size:"compact",children:e.src_hash}):o.jsx("span",{className:"text-[10px] text-text-muted",children:"—"})}),o.jsx("div",{className:"flex-1 min-w-0"}),o.jsx("span",{className:"color-pill color-pill-filled flex-shrink-0",style:{"--pill-color":i.bgColor,"--pill-text":i.textColor},children:n}),o.jsx("span",{className:"color-pill flex-shrink-0",style:{"--pill-color":$(r)},children:r}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(S,{rssi:e.rssi,compact:!0,showValues:!0})})]})})});function ae(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 ne=e.lazy(()=>L(()=>import("./PathMapMapLibre-BJr4IqeH.js"),__vite__mapDeps([0,1,2,3,4])));function re(e){return`${(100*e).toFixed(0)}%`}function oe(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 ce extends e.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?o.jsxs("div",{className:"h-[200px] flex items-center justify-center text-text-muted",children:[o.jsx(d,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function ie({path:t,neighbors:s,localNode:a,localHash:n,srcHash:r,dstHash:c,neighborAffinity:d,prefixLookup:p,hubNodes:x}){const[h,u]=e.useState(null),m=e.useMemo(()=>{if(!r)return null;const e=k(r),t=s[r];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:r,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)||r.slice(0,8);return{prefix:e,candidates:[{hash:r,name:a,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[r,s]),f=e.useMemo(()=>{if(!c)return null;const e=k(c);if(n&&c===n&&a){const t=0!==a.latitude||0!==a.longitude;return{prefix:e,candidates:[{hash:c,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[c];if((null==t?void 0:t.latitude)&&(null==t?void 0:t.longitude)&&(0!==t.latitude||0!==t.longitude))return{prefix:e,candidates:[{hash:c,name:t.node_name||t.name||"Destination",latitude:t.latitude,longitude:t.longitude,probability:1,isLocal:!1,isDirectNeighbor:!0===t.zero_hop}],confidence:1,totalMatches:1,isDestination:!0};const r=(null==t?void 0:t.node_name)||(null==t?void 0:t.name)||c.slice(0,8);return{prefix:e,candidates:[{hash:c,name:r,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[c,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:p,totalMatches:x}=function(e,t,s,a,n=!1,r,o,c){const i=function(e){const t={};for(const[s,a]of Object.entries(e))ae(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:p}=function(e,t,s,a,n=!1){const r=e.toUpperCase(),o=[],c=s&&_(r,s);c&&o.push(s);for(const h of Object.keys(t))_(r,h)&&o.push(h);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,p=-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>p&&(p=s,d=e)}d||(d=l[0])}else l.length>0&&(d=l[0]);let x=i;if(o.length>1&&a&&p>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&&(x=Math.min(.95,p/e))}return{matches:o,probability:x,bestMatch:d}}(e,i,a,r,n),x=d.length,h=[],u=e.toUpperCase(),m=s&&void 0!==s.latitude&&void 0!==s.longitude&&(0!==s.latitude||0!==s.longitude);for(const g of d){if(a&&_(u,a)&&g===a&&m&&s){h.push({hash:g,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:n?1:p,isLocal:!0});continue}const e=i[g];(null==e?void 0:e.latitude)&&(null==e?void 0:e.longitude)&&(0!==e.latitude||0!==e.longitude)&&h.push({hash:g,name:e.node_name||e.name||"Unknown",latitude:e.latitude,longitude:e.longitude,probability:p,isLocal:!1,isDirectNeighbor:!0===e.zero_hop})}const f=h.length;if(1===f)h[0].probability=l??1;else if(f>1)if(void 0!==l&&l>0){h[0].probability=l;const e=1-l,t=f-1;h.slice(1).forEach(s=>{s.probability=e/t})}else{let e=0;const t=h.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;h.forEach(t=>t.probability=e)}}return{candidates:h,totalMatches:x}}(c,t,s,a,l,n,r,d),h=p.length>0?Math.max(...p.map(e=>e.probability)):0;return{prefix:c,candidates:p,confidence:h,totalMatches:x}}),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,p),[t,s,a,n,d,p]),y=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 y.hasValidPath?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-text-muted",children:"Path Confidence:"}),o.jsx("span",{className:(j=y.overallConfidence,j>=1?"text-accent-success":j>=.5?"text-accent-secondary":j>=.25?"text-signal-poor":j>0?"text-accent-danger":"text-text-muted"),children:re(y.overallConfidence)}),o.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:o.jsx(l,{className:"w-3 h-3"})})]}),o.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-success"}),o.jsx("span",{className:"text-text-muted",children:"Exact"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-secondary"}),o.jsx("span",{className:"text-text-muted",children:"Multi"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-text-muted"}),o.jsx("span",{className:"text-text-muted",children:"Unknown"})]})]})]}),o.jsx("div",{className:"rounded-lg overflow-hidden border border-border-subtle",children:o.jsx(ce,{children:o.jsx(e.Suspense,{fallback:o.jsx("div",{className:"h-[200px] bg-bg-elevated flex items-center justify-center text-text-muted text-sm",children:"Loading map..."}),children:o.jsx(ne,{resolvedPath:y,localNode:a,hubNodes:x,hoveredHopIndex:h,onHoverHop:u})})})}),o.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:y.hops.map((e,t)=>{var s,a,n;const r=!0===e.isSource,c=!0===e.isDestination,i=h===t;let l;return l=r?`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)`,o.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",r&&"border border-accent-success/30",c&&"border border-accent-primary/30"),title:l,onMouseEnter:()=>u(t),onMouseLeave:()=>u(null),children:[r&&o.jsx("span",{className:"text-accent-success text-[8px] mr-0.5",children:"SRC"}),c&&o.jsx("span",{className:"text-accent-primary text-[8px] mr-0.5",children:"DST"}),o.jsx("span",{style:oe(e.confidence,e.totalMatches),children:e.prefix}),!r&&!c&&e.totalMatches>1&&o.jsxs("span",{className:"text-text-muted",children:["×",e.totalMatches]}),!r&&!c&&0===e.totalMatches&&o.jsx("span",{className:"text-text-muted",children:"?"})]},t)})})]}):o.jsxs("div",{className:"flex items-center justify-center text-text-muted text-xs py-4",children:[o.jsx(i,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]});var j}function le(e){if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function de({label:e,children:t,compact:s=!1}){return o.jsxs("div",{className:b("flex flex-col",s?"gap-0.5":"gap-1"),children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide",children:e}),o.jsx("span",{className:b("text-text-primary","text-sm"),children:t})]})}function pe({originalPath:e,forwardedPath:t,ghostPrefixes:s}){const n=t.length>0?t:e;if(0===n.length)return o.jsx("span",{className:"text-sm text-text-muted",children:"No path data"});const r=e=>null==s?void 0:s.has(e.toUpperCase());return o.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n.map((e,t)=>o.jsxs("div",{className:"flex items-center gap-1",children:[r(e)?o.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-sm",children:[o.jsx(h,{className:"w-3 h-3"}),e.toUpperCase()]}):o.jsx(R,{copy:!0,size:"compact",children:e}),t{const e=e=>{"Escape"===e.key&&a()};window.addEventListener("keydown",e);const t=document.body.style.overflow,s=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=s,document.body.style.width=n,document.body.style.top=r,window.scrollTo(0,o)}},[a]);const j=M(),v=T(),N=C(),w=P(),_=e.useMemo(()=>new Set(w.map(e=>e.prefix.toUpperCase())),[w]),k=s.payload_type_name||O(s.payload_type??s.type),A=s.route_type_name||F(s.route_type??s.route),L=s.payload_length??s.length??0,V=s.tx_delay_ms??0,U=le(s.original_path),z=le(s.forwarded_path),I=U.length>0||z.length>0,H=z.length>0?z:U,$=e.useMemo(()=>{var e;if(null==(e=null==j?void 0:j.config)?void 0:e.repeater)return{latitude:j.config.repeater.latitude,longitude:j.config.repeater.longitude,name:j.config.node_name||"Local Node"}},[j]),G=(null==j?void 0:j.neighbors)??{},X=N.size>0?N:void 0,Q=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}}(s.payload),W=s.payload&&s.payload.length>0,q=s.raw_packet&&s.raw_packet.length>0,K=e.useCallback(async(e,t)=>{try{await navigator.clipboard.writeText(e),y(t),setTimeout(()=>y(null),2e3)}catch{}},[]);return p.createPortal(o.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-md z-[10010] flex items-end sm:items-center justify-center",onClick:a,role:"dialog","aria-modal":"true","aria-labelledby":"packet-modal-title",children:o.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:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border-subtle flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(B,{packet:s,showLabel:!0,size:"md"}),o.jsxs("div",{children:[o.jsx("h3",{id:"packet-modal-title",className:b("text-base font-semibold",(ee=k,{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)]"}[ee]||"text-[var(--pkt-unknown)]")),children:k}),o.jsx("p",{className:"text-sm text-text-muted",children:E(s.timestamp)})]})]}),o.jsx("button",{onClick:a,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-subtle transition-colors",children:o.jsx(x,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"overflow-y-auto flex-1 p-4 space-y-4 overscroll-contain",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(de,{label:"Packet Hash",children:o.jsx(R,{copy:!0,size:"compact",children:s.packet_hash})}),o.jsx(de,{label:"Route",children:o.jsx("span",{className:b("px-2 py-0.5 rounded text-sm border font-medium",(Z=A,{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"}[Z]||"bg-bg-subtle text-text-muted border-border-subtle")),children:A})})]}),o.jsx("div",{className:"glass-card-inner p-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-text-muted mb-1",children:"Signal Quality"}),o.jsx("p",{className:"text-sm font-medium text-text-primary",children:D(s.rssi)})]}),o.jsx(S,{rssi:s.rssi,snr:s.snr,showValues:!0})]})}),(s.src_hash||s.dst_hash)&&o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[s.src_hash&&o.jsx(de,{label:"Source",children:o.jsx(R,{copy:!0,size:"compact",children:s.src_hash})}),s.dst_hash&&o.jsx(de,{label:"Destination",children:o.jsx(R,{copy:!0,size:"compact",children:s.dst_hash})})]}),I&&o.jsxs("div",{className:"glass-card-inner p-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("p",{className:"text-sm text-text-muted",children:"Packet Path"}),H.some(e=>_.has(e.toUpperCase()))&&o.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:[o.jsx(h,{className:"w-3 h-3"}),o.jsx("span",{children:"Ghost Detected"})]})]}),o.jsx(pe,{originalPath:U,forwardedPath:z,ghostPrefixes:_})]}),I&&H.length>0&&o.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[o.jsxs("button",{onClick:()=>l(!i),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(u,{className:"w-4 h-4 text-accent-primary"}),o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:"Path Map"})]}),i?o.jsx(m,{className:"w-4 h-4 text-text-muted"}):o.jsx(f,{className:"w-4 h-4 text-text-muted"})]}),i&&o.jsx("div",{className:"px-3 pb-3",children:o.jsx(ie,{path:H,neighbors:G,localNode:$,localHash:null==j?void 0:j.local_hash,srcHash:s.src_hash,dstHash:s.dst_hash,neighborAffinity:X,hubNodes:[...v]})})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsx(de,{label:"Size",compact:!0,children:o.jsxs("span",{className:"font-mono",children:[L,"B"]})}),o.jsx(de,{label:"TX Delay",compact:!0,children:o.jsxs("span",{className:"font-mono",children:[V.toFixed(1),"ms"]})}),o.jsx(de,{label:"Score",compact:!0,children:o.jsx("span",{className:"font-mono",children:void 0!==s.score?s.score.toFixed(3):"—"})})]}),o.jsx(de,{label:"Status",children:o.jsx("span",{className:J(s),children:Y(s)})}),W&&o.jsxs("div",{className:"glass-card-inner p-3",children:[o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"Payload"}),Q.isText&&Q.text?o.jsx("div",{className:"bg-bg-base rounded p-2",children:o.jsx("p",{className:"text-sm text-text-primary font-mono break-all",children:Q.text})}):o.jsxs("p",{className:"text-sm text-text-muted font-mono break-all",children:[null==(n=s.payload)?void 0:n.slice(0,100),s.payload&&s.payload.length>100&&"..."]})]}),q&&o.jsxs("div",{className:"glass-card-inner overflow-hidden",children:[o.jsxs("button",{onClick:()=>c(!r),className:"w-full p-3 flex items-center justify-between text-left hover:bg-bg-subtle transition-colors",children:[o.jsx("span",{className:"text-sm text-text-muted",children:"Raw Packet Hex"}),r?o.jsx(m,{className:"w-4 h-4 text-text-muted"}):o.jsx(f,{className:"w-4 h-4 text-text-muted"})]}),r&&o.jsx("div",{className:"px-3 pb-3",children:o.jsxs("div",{className:"bg-bg-base rounded p-2 relative",children:[o.jsx("pre",{className:"text-[10px] text-text-secondary font-mono break-all whitespace-pre-wrap",children:s.raw_packet}),o.jsx("button",{onClick:()=>K(s.raw_packet,"raw"),className:"absolute top-2 right-2 p-1 rounded bg-bg-elevated hover:bg-bg-subtle transition-colors",children:"raw"===d?o.jsx(g,{className:"w-3 h-3 text-accent-success"}):o.jsx(t,{className:"w-3 h-3 text-text-muted"})})]})})]})]})]})}),document.body);var Z,ee});export{te as P,se as a,xe as b,K as g}; diff --git a/frontend/dist/assets/Packets-paAuyZUE.js b/frontend/dist/assets/Packets-Dx7VKSq1.js similarity index 98% rename from frontend/dist/assets/Packets-paAuyZUE.js rename to frontend/dist/assets/Packets-Dx7VKSq1.js index 9b2808b0..b2ff95aa 100644 --- a/frontend/dist/assets/Packets-paAuyZUE.js +++ b/frontend/dist/assets/Packets-Dx7VKSq1.js @@ -1 +1 @@ -import{r as e,j as t,_ as s,D as a,Y as l,$ as r,a0 as i,a1 as c,a2 as n,p as o,X as d}from"./vendor-react-DtVWNgeu.js";import{c as m}from"./recharts-C9LxPobD.js";import{u as x,b as p,r as u,t as h,R as b,L as j}from"./index-BIsccma_.js";import{g,P as v,a as y,b as f}from"./PacketDetailModal-ZVXSkr9b.js";import{P as N,b as w,a as k,c as S}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./SignalIndicator-DagI_WOB.js";import"./DataBox-Dl3NmnnB.js";import"./useScientificColormap-nDz0kTVE.js";function R({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:m("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 _=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(g(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(R,{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(R,{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(R,{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(R,{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(R,{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 C(){const s=x(),a=p(),l=u(),[r,i]=e.useState(null),[R,C]=e.useState(!1),[M,P]=e.useState({limit:100,status:"all"}),[L,D]=e.useState(Date.now);e.useEffect(()=>{M.timeRange&&M.timeRange>0&&queueMicrotask(()=>D(Date.now()))},[M.timeRange,s]);const T=e.useMemo(()=>{const e=M.limit??100;return[...s.length<=e?s:s.slice(-e)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,M.limit]),$=0===s.length,A=e.useMemo(()=>{let e=T;if(void 0!==M.type){const t=h[M.type];e=e.filter(e=>{const s=e.type??e.payload_type,a=e.payload_type_name;return s===M.type||a===t})}if(void 0!==M.route){const t=b[M.route];e=e.filter(e=>{const s=e.route??e.route_type,a=e.route_type_name;return s===M.route||a===t})}if(M.status&&"all"!==M.status&&(e=e.filter(e=>g(e)===M.status)),void 0!==M.signalMin&&(e=e.filter(e=>e.rssi>=M.signalMin)),M.timeRange&&M.timeRange>0){const t=L/1e3-3600*M.timeRange;e=e.filter(e=>e.timestamp>=t)}return e},[T,M.type,M.route,M.status,M.signalMin,M.timeRange,L]),F=(e,t)=>P(s=>({...s,[e]:t})),q=void 0!==M.type||void 0!==M.route||M.status&&"all"!==M.status||void 0!==M.signalMin||M.timeRange&&M.timeRange>0;return t.jsxs(N,{children:[t.jsx(w,{title:"Packet History",icon:t.jsx(o,{}),controls:t.jsxs(t.Fragment,{children:[a&&t.jsx(j,{showLabel:!0}),t.jsxs("button",{onClick:()=>C(!R),className:m("sm:hidden px-3 py-1.5 rounded-lg text-sm font-medium transition-all","flex items-center gap-1.5 border",q?"bg-accent-primary/20 text-accent-primary border-accent-primary/30":"bg-bg-subtle text-text-muted border-border-subtle"),children:[t.jsx(c,{className:"w-4 h-4"}),q&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),t.jsxs("button",{onClick:()=>l(!a),className:m("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(n,{className:m("w-4 h-4",a&&"animate-spin")}),t.jsx("span",{className:"hidden xs:inline",children:a?"Live":"Paused"})]})]})}),t.jsxs(k,{noPadding:!0,className:m("overflow-hidden transition-all duration-200",R?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[t.jsx(S,{listHeader:!0,icon:t.jsx(c,{className:"icon-sm"}),title:"Filters",actions:q?t.jsxs("button",{onClick:()=>P({limit:M.limit,status:"all"}),className:"type-data-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[t.jsx(d,{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:M.type??"",onChange:e=>F("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(h).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:M.route??"",onChange:e=>F("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(b).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:M.status??"all",onChange:e=>F("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:M.timeRange??0,onChange:e=>F("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:M.signalMin??"",onChange:e=>F("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:M.limit??100,onChange:e=>F("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(_,{packets:A}),t.jsxs(k,{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:$&&0===T.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"Loading packets..."})}):0===A.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"No packets found"})}):A.map((e,s)=>t.jsx(v,{packet:e,onClick:i},`${e.packet_hash}_${e.timestamp}_${s}`))})]})}),t.jsx("div",{className:"sm:hidden divide-y divide-border-subtle/30",children:$&&0===T.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===A.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"No packets found"}):A.map((e,s)=>t.jsx(y,{packet:e,onClick:i},`${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 ",A.length," of ",T.length," packets"]})]}),r&&t.jsx(f,{packet:r,onClose:()=>i(null)})]})}export{C as default}; +import{r as e,j as t,_ as s,D as a,Y as l,$ as r,a0 as i,a1 as c,a2 as n,p as o,X as d}from"./vendor-react-DtVWNgeu.js";import{c as m}from"./recharts-C9LxPobD.js";import{u as x,b as p,r as u,t as h,R as b,L as j}from"./index-Bmit1I8S.js";import{g,P as v,a as y,b as f}from"./PacketDetailModal-I-Pe3tob.js";import{P as N,b as w,a as k,c as S}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./SignalIndicator-DagI_WOB.js";import"./DataBox-Dl3NmnnB.js";import"./useScientificColormap-n_Aivg5g.js";function R({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:m("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 _=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(g(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(R,{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(R,{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(R,{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(R,{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(R,{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 C(){const s=x(),a=p(),l=u(),[r,i]=e.useState(null),[R,C]=e.useState(!1),[M,P]=e.useState({limit:100,status:"all"}),[L,D]=e.useState(Date.now);e.useEffect(()=>{M.timeRange&&M.timeRange>0&&queueMicrotask(()=>D(Date.now()))},[M.timeRange,s]);const T=e.useMemo(()=>{const e=M.limit??100;return[...s.length<=e?s:s.slice(-e)].sort((e,t)=>(t.timestamp??0)-(e.timestamp??0))},[s,M.limit]),$=0===s.length,A=e.useMemo(()=>{let e=T;if(void 0!==M.type){const t=h[M.type];e=e.filter(e=>{const s=e.type??e.payload_type,a=e.payload_type_name;return s===M.type||a===t})}if(void 0!==M.route){const t=b[M.route];e=e.filter(e=>{const s=e.route??e.route_type,a=e.route_type_name;return s===M.route||a===t})}if(M.status&&"all"!==M.status&&(e=e.filter(e=>g(e)===M.status)),void 0!==M.signalMin&&(e=e.filter(e=>e.rssi>=M.signalMin)),M.timeRange&&M.timeRange>0){const t=L/1e3-3600*M.timeRange;e=e.filter(e=>e.timestamp>=t)}return e},[T,M.type,M.route,M.status,M.signalMin,M.timeRange,L]),F=(e,t)=>P(s=>({...s,[e]:t})),q=void 0!==M.type||void 0!==M.route||M.status&&"all"!==M.status||void 0!==M.signalMin||M.timeRange&&M.timeRange>0;return t.jsxs(N,{children:[t.jsx(w,{title:"Packet History",icon:t.jsx(o,{}),controls:t.jsxs(t.Fragment,{children:[a&&t.jsx(j,{showLabel:!0}),t.jsxs("button",{onClick:()=>C(!R),className:m("sm:hidden px-3 py-1.5 rounded-lg text-sm font-medium transition-all","flex items-center gap-1.5 border",q?"bg-accent-primary/20 text-accent-primary border-accent-primary/30":"bg-bg-subtle text-text-muted border-border-subtle"),children:[t.jsx(c,{className:"w-4 h-4"}),q&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),t.jsxs("button",{onClick:()=>l(!a),className:m("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(n,{className:m("w-4 h-4",a&&"animate-spin")}),t.jsx("span",{className:"hidden xs:inline",children:a?"Live":"Paused"})]})]})}),t.jsxs(k,{noPadding:!0,className:m("overflow-hidden transition-all duration-200",R?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[t.jsx(S,{listHeader:!0,icon:t.jsx(c,{className:"icon-sm"}),title:"Filters",actions:q?t.jsxs("button",{onClick:()=>P({limit:M.limit,status:"all"}),className:"type-data-xs text-text-muted hover:text-text-primary flex items-center gap-1",children:[t.jsx(d,{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:M.type??"",onChange:e=>F("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(h).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:M.route??"",onChange:e=>F("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(b).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:M.status??"all",onChange:e=>F("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:M.timeRange??0,onChange:e=>F("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:M.signalMin??"",onChange:e=>F("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:M.limit??100,onChange:e=>F("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(_,{packets:A}),t.jsxs(k,{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:$&&0===T.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"Loading packets..."})}):0===A.length?t.jsx("tr",{children:t.jsx("td",{colSpan:6,className:"text-center py-12 text-text-muted",children:"No packets found"})}):A.map((e,s)=>t.jsx(v,{packet:e,onClick:i},`${e.packet_hash}_${e.timestamp}_${s}`))})]})}),t.jsx("div",{className:"sm:hidden divide-y divide-border-subtle/30",children:$&&0===T.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"Loading packets..."}):0===A.length?t.jsx("div",{className:"p-8 text-center text-text-muted",children:"No packets found"}):A.map((e,s)=>t.jsx(y,{packet:e,onClick:i},`${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 ",A.length," of ",T.length," packets"]})]}),r&&t.jsx(f,{packet:r,onClose:()=>i(null)})]})}export{C as default}; diff --git a/frontend/dist/assets/Statistics-CjF2BXTB.js b/frontend/dist/assets/Statistics-rMuAOtUm.js similarity index 99% rename from frontend/dist/assets/Statistics-CjF2BXTB.js rename to frontend/dist/assets/Statistics-rMuAOtUm.js index 8bc8834f..281cfc3a 100644 --- a/frontend/dist/assets/Statistics-CjF2BXTB.js +++ b/frontend/dist/assets/Statistics-rMuAOtUm.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,o as i,aC as o,H as c,aD as m,aE as u,aF as d,aG as h,aH as x,aI as p,aJ as g,aK as f,aL as b,aM as y,aN as v,aO as j,aP as N,aQ as w,a8 as M,aR as k,aS as S,aT as C,aU as T,ac as F,aV as $,h as P,C as R,at as A,p as L}from"./vendor-react-DtVWNgeu.js";import{W as D,X as E,Y as B,Z as H,t as z,F as _,_ as O,$ as W,a0 as I,I as V,a1 as q,c as X,f as G,e as K,u as Y,n as U,p as Q,h as Z,o as J,a2 as ee,j as te,a3 as se}from"./index-BIsccma_.js";import{u as ae}from"./usePolling-DXhhvgB-.js";import{b as ne,c as re,a as le,d as ie,e as oe,s as ce}from"./useThemeColors-DaJMJYCA.js";import{a as me,b as ue,h as de,g as he}from"./useScientificColormap-nDz0kTVE.js";import{c as xe,R as pe,d as ge,L as fe,C as be,X as ye,Y as ve,T as je,a as Ne}from"./recharts-C9LxPobD.js";import{T as we}from"./TimeRangeSelector-CzmnykND.js";import{a as Me,c as ke,P as Se,b as Ce}from"./PageLayout-CG02PCA-.js";import{D as Te}from"./DataBox-Dl3NmnnB.js";import{C as Fe}from"./CollisionExplorerModal-CZ-TWl8d.js";import{R as $e,C as Pe}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./leaflet-D_ckmI2R.js";function Re({children:e,centered:t,className:s}){return n.jsx("div",{className:xe("flex-1 min-h-0",t&&"flex items-center justify-center",s),children:e})}const Ae={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Le(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 De(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:Le(t,50),p90:Le(t,90),p95:Le(t,95),p99:Le(t,99),max:t[t.length-1],min:t[0]}}function Ee(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 D({...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 Be=new Map;function He(e){var t;if(!e.startsWith("var("))return e;const s=Be.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 Be.set(e,l),l}function ze(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:m,cursor:u});r.useLayoutEffect(()=>{y.current={band:l,innerBand:i,mean:o,median:c,average:m,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,m=n.bbox,u=m.left,d=m.top,h=m.width,x=m.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=>d+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,M={band:He(o.band),innerBand:He(o.innerBand),mean:He(o.mean),median:He(o.median),average:He(o.average)};c.save(),c.strokeStyle=M.average,c.lineWidth=4,c.globalAlpha=w("average"),ze(c,j.average),c.stroke(),c.globalAlpha=N("minMax",.15),c.fillStyle=M.band,c.beginPath(),ze(c,j.max);const k=[...j.min].reverse();for(const e of k)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p5p95",.3),c.fillStyle=M.band,c.beginPath(),ze(c,j.p95);const S=[...j.p5].reverse();for(const e of S)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p25p75",.55),c.fillStyle=M.innerBand,c.beginPath(),ze(c,j.p75);const C=[...j.p25].reverse();for(const e of C)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=M.median,c.lineWidth=1.5,c.globalAlpha=w("median"),c.setLineDash([4,4]),ze(c,j.median),c.stroke(),c.strokeStyle=M.mean,c.lineWidth=1.5,c.globalAlpha=w("mean"),c.setLineDash([]),ze(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=d.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 D({...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=d.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:d,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:N})});const _e="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Oe(){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 We=["min","max","p75","p95","p99","mean","median","average","midpoint"];function Ie(e){const t=ue(e),s=de(t),a=`color(display-p3 ${(s.r/255).toFixed(3)} ${(s.g/255).toFixed(3)} ${(s.b/255).toFixed(3)})`;return{...s,p3:a}}function Ve(e,t,s,a,n,r,l,i,o,c=null,m=null,u=1,d=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],M=j[N-1],k=s,S="share"===h,C=S?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)}(k):5,T=getComputedStyle(document.documentElement),F=T.getPropertyValue("--signal-critical").trim()||"#EF4444",$=T.getPropertyValue("--bg-body").trim()||"#171717";p.save(),p.fillStyle="#000000";const P=8*v;p.beginPath(),p.roundRect(g,f,b,y,P),p.fill(),p.restore();const R=parseInt($.slice(1,3),16)||23,A=parseInt($.slice(3,5),16)||23,L=parseInt($.slice(5,7),16)||23;if(!S&&k>=20){p.save();const e=f+y*(1-20/k);p.fillStyle=`rgba(${R}, ${A}, ${L}, 0.5)`,p.fillRect(g,f,b,e-f),p.restore()}p.save(),p.lineWidth=1*v,p.setLineDash([4*v,4*v]);for(let E=C;Es+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,d,g,f,b,y,v),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:m,rawValues:u,count:d,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,m=.5){if(0===t.length)return;const u=o-i||1,d=function(e,t=1.3,s=.15){const a=function(e){const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);if(t){const e=parseFloat(t[1]),s=parseFloat(t[2]),a=parseFloat(t[3]);return{r:Math.round(255*e),g:Math.round(255*s),b:Math.round(255*a),p3r:e,p3g:s,p3b:a}}if(e.startsWith("#")){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return{r:s,g:a,b:n,p3r:s/255,p3g:a/255,p3b:n/255}}const s=e.match(/rgba?\(([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(s){const e=Math.round(parseFloat(s[1])),t=Math.round(parseFloat(s[2])),a=Math.round(parseFloat(s[3]));return{r:e,g:t,b:a,p3r:e/255,p3g:t/255,p3b:a/255}}return{r:255,g:255,b:255,p3r:1,p3g:1,p3b:1}}(e),n=function(e,t,s,a=1.25,n=.15){const r=(Math.max(e,t,s)+Math.min(e,t,s))/2;return{p3r:Math.min(1,r+(e-r)*a+n),p3g:Math.min(1,r+(t-r)*a+n),p3b:Math.min(1,r+(s-r)*a+n)}}(a.p3r,a.p3g,a.p3b,t,s);return{r:Math.round(255*Math.min(1,n.p3r)),g:Math.round(255*Math.min(1,n.p3g)),b:Math.round(255*Math.min(1,n.p3b)),p3r:Math.min(1,n.p3r),p3g:Math.min(1,n.p3g),p3b:Math.min(1,n.p3b)}}(getComputedStyle(document.documentElement).getPropertyValue("--signal-critical").trim()||"#EF4444");e.save(),e.globalAlpha=m,e.fillStyle=_e?`color(display-p3 ${d.p3r} ${d.p3g} ${d.p3b})`:`rgb(${d.r}, ${d.g}, ${d.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,m=Math.max(s-t,2*c);e.fillRect(t,n,m,l)}e.restore()}(p,i,0,g,f,b,y,w,M,v,m?Math.max(.03,.03*x):x)}const qe=r.memo(function({data:e,maxValue:t,visibleLines:s=We,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:m=.5,highlightedType:u=null,hoveredTimeRange:d=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),M=r.useRef(c),k=r.useRef(u),S=r.useRef(d),C=r.useRef(null),T=r.useRef(null),F=r.useRef(x),$=r.useRef(m),P=h<=12?1.2:1,R=r.useRef(P),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,M.current=c,k.current=u,S.current=d,R.current=P,F.current=x,$.current=m}),r.useEffect(()=>{C.current=Oe()},[]);const L=r.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),E=r.useMemo(()=>({hooks:{draw:e=>{const t=C.current||Oe();Ve(e,f.current,b.current,y.current,v.current,t,N.current,w.current,M.current,k.current,S.current,R.current,T.current,F.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:[E]}),[E]);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 D({...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,m,u,d,P]);const H=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,m=c.left/o,u=c.width/o;if(im+u)return T.current=null,r.redraw(),void(null==(s=j.current)||s.call(j,null));T.current=i*o;const d=(i-m)/u,h=e.length,x=Math.floor(d*h),f=Math.max(0,Math.min(h-1,x));r.redraw(),null==(a=j.current)||a.call(j,f)},[e.length]),z=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:H,onMouseLeave:z})}),Xe=he;function Ge({sortedTypes:e,highlightedType:t,onTypeHover:s,aggregateShares:a,hoverData:l}){const i=r.useMemo(()=>{if(!l)return null;const e=new Map;for(const t of l.items)e.set(t.key,t.value);return e},[l]),o=null!==i;return 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=Xe(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,m=o?l:c,u=m>1e-4,d=t===e.key,h=["legend-item",d&&"legend-item-active",(t&&!d||o&&l<=1e-4)&&"legend-item-dimmed",!t&&o&&l>1e-4&&"legend-item-chart-active"].filter(Boolean).join(" ");return n.jsxs("div",{className:h,onMouseEnter:()=>s(e.key),children:[n.jsx("div",{className:"flex-shrink-0",style:{backgroundColor:r,width:9,height:16,borderRadius:1}}),n.jsx("span",{className:"legend-label",children:e.label}),u&&n.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*m).toFixed(1),"%"]})]},e.key)})})})}const Ke='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';function Ye({x:e,y:t,width:s,height:a,name:r,size:l,index:i,depth:o,hoveredIndex:c,onHover:m,total:u,typeNum:d}){if(1!==o)return null;const h=null!==c&&!(c===i),x=Xe(d),p=u>0?l/u*100:0,g=s>36&&a>20,f=s>36&&a>32;return n.jsxs("g",{onMouseEnter:e=>m(i,e),onMouseLeave:()=>m(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:Ke,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:Ke,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 Qe({sortedTypes:e,aggregateShares:t}){var s,a,i;const[o,c]=r.useState(null),[m,u]=r.useState(null),[d,h]=r.useState(0),[x,p]=r.useState(null),g=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(c(e),t&&null!==e){const e=g.current;if(e){const s=e.getBoundingClientRect();h(s.width),u({x:t.clientX-s.left,y:t.clientY-s.top})}}else u(null)},[]),v=r.useCallback(e=>{if(p(e),e){const t=b.findIndex(t=>t.key===e);c(t>=0?t:null)}else c(null)},[b]),j=null!==o?{name:(null==(s=b[o])?void 0:s.name)??"",value:(null==(a=b[o])?void 0:a.size)??0}:null,N=null!==o?Xe(null==(i=b[o])?void 0:i.typeNum):"";return 0===e.length||0===f?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{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:g,children:[n.jsx(pe,{width:"100%",height:"100%",children:n.jsx(ge,{data:b,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:n.jsx(Ye,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:o,onHover:y,total:f,typeNum:0})})}),n.jsx(Ue,{data:j,total:f,color:N,position:m,containerWidth:d})]}),n.jsx(Ge,{sortedTypes:e,highlightedType:x,onTypeHover:v,aggregateShares:t})]})}function Ze(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 Je({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 et({packets:e,mode:t,startTs:s,endTs:a,radioConfig:o,bucketCount:c}){const m=ne(),u=re(),d=m.primary,h=m.tertiary,[x,p]=r.useState(null),{trendData:g,totals:f}=r.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const n=a-s,r=Math.min(Math.ceil(n/300),c),l=n/r,i=[];let m=0,u=0,d=0,h=0;for(const t of e){const e=t.timestamp;if(e=a)continue;const n=E(t),r=B(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble}),l={timestamp:e,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};t.transmitted?(l.txAirtime=r,l.txBytes=n,u+=n,h+=r):(l.rxAirtime=r,l.rxBytes=n,m+=n,d+=r),i.push(l)}i.sort((e,t)=>e.timestamp-t.timestamp);const x=new Float64Array(i.length+1),p=new Float64Array(i.length+1),g=new Float64Array(i.length+1),f=new Float64Array(i.length+1),b=new Float64Array(i.length);for(let e=0;e{let t=0,s=b.length;for(;t>>1;b[a]0?e:null,tx:t>0?t:null})}else{const e=(x[i]-x[r])/j*100,t=(p[i]-p[r])/j*100;v.push({timestamp:a,rx:e>0?e:null,tx:t>0?t:null})}}const N=2/31;let w=null;return{trendData:v.map(e=>{const t=e.rx;return null!==t&&t>0&&(w=null===w?t:N*t+(1-N)*w),{...e,rxSmooth:null!==w&&w>0?w:null}}),totals:{rxBytes:m,txBytes:u,rxAirtime:d,txAirtime:h}}},[e,s,a,c,t,o]),b=r.useMemo(()=>{if(0===g.length)return"share"===t?100:10;let e=0;for(const t of g){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))},[g,t]),y=r.useMemo(()=>{if(null!==x&&g[x]){const e=g[x],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:Ze(s),tx:Ze(a),total:Ze(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:Ze(f.rxBytes),tx:Ze(f.txBytes),total:Ze(f.rxBytes+f.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of g)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}}},[x,g,f,t]),v=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]),j=r.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;p("number"==typeof t?t:null)},[]),N=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===g.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{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-secondary",style:{height:20,paddingLeft:44,paddingRight:8},children:n.jsx("div",{className:"relative w-full h-full flex items-center",children:v.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(i,{className:"w-2.5 h-2.5 opacity-60"}),n.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),n.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:n.jsx(pe,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:n.jsxs(fe,{data:g,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:j,onMouseLeave:()=>p(null),children:[n.jsx(be,{strokeDasharray:"3 3",stroke:u.secondary,strokeOpacity:.3,vertical:!1}),n.jsx(ye,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),n.jsx(ve,{axisLine:!1,tickLine:!1,tick:{fill:u.secondary,fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},dx:-8,width:44,tickFormatter:N,domain:[0,b]}),n.jsx(je,{content:n.jsx(Je,{mode:t})}),n.jsx(Ne,{type:"linear",dataKey:"rx",name:"RX",stroke:d,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(Ne,{type:"linear",dataKey:"tx",name:"TX",stroke:h,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(Ne,{type:"basis",dataKey:"rxSmooth",name:"RX Avg",stroke:d,strokeWidth:24,strokeOpacity:.1,dot:!1,connectNulls:!0,isAnimationActive:!1,style:{mixBlendMode:"screen"},strokeLinecap:"round"})]})})}),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:d}}),n.jsx("span",{className:"text-text-secondary",children:"RX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:h}}),n.jsx("span",{className:"text-text-secondary",children:"TX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-1.5 rounded-sm opacity-25",style:{backgroundColor:d}}),n.jsx("span",{className:"text-text-secondary",children:"RX Avg"})]})]}),n.jsxs("div",{className:"flex items-center gap-4 text-right pr-2 font-mono",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium",style:{color:d},children:"RX"}),n.jsx("span",{className:"font-bold text-xl text-text-primary",children:y.rx})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium",style:{color:h},children:"TX"}),n.jsx("span",{className:"font-bold text-xl text-text-primary",children:y.tx})]}),y.isHovered&&n.jsx("span",{className:"text-xs text-text-muted",children:"bucket"})]})]})]})}function tt(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 st({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:i,radioConfig:o,sortedTypes:c,aggregateShares:m,noiseFloorAnomalies:u,showNoiseFloorOverlay:d,overlayOpacity:h=.5}){const[x,p]=r.useState(null),[g,f]=r.useState(null),b=r.useMemo(()=>(i-a)/3600,[a,i]),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=E(e);let o;if(o="airtime"===a?B(e,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}):1,r<=0)continue;const c=Math.floor((e.timestamp-t)/300),m={timestamp:e.timestamp,airtimeMs:o,byteSize:r,packetType:s,bucketIndex:c};l.push(m),i.has(c)||i.set(c,[]),i.get(c).push(m)}if(0===l.length)return null;const o=[],c=[],m=[],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;let s=0;for(const a of e)a.airtimeMs>s&&(s=a.airtimeMs);for(const a of e){const e=a.airtimeMs/s*t;u.set(a,e)}}for(const e of l){const t=u.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),m.push(e.packetType))}let d=c[0],h=c[0];for(let e=1;eh&&(h=c[e]);const x=h-d||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],M=new Map;for(const e of o){const t=Math.round(100*e)/100;M.set(t,(M.get(t)??0)+1)}const k=M.size,S=[...M.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let C;if("share"===a)C=200;else{const e=5,t=Math.ceil(f/e)*e;C=t<=10?10:t+e}const T=new Float32Array(2*o.length),F=new Float32Array(o.length),$=new Uint8Array(o.length),P=new Float32Array(o.length);for(let e=0;e=0?m[e]:255,P[e]=c[e]}return{points:T,rawValues:F,packetTypes:$,timestamps:P,count:o.length,minTime:d,maxTime:h,minValue:0,maxValue:C,rawMinValue:g,rawMaxValue:f,unit:"%",stats:{p5:j,p50:N,p95:w,uniqueValues:k,topValues:S}}},[e,t,s,a,n])}(s,a,i,"share"===t?"share":"airtime",o),{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 m=0;mj.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]),M=r.useCallback(e=>{p(e)},[]),k=r.useMemo(()=>{if(null===x||!j[x])return null;const e=j[x];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}},[x,j,b]),S=r.useMemo(()=>{if(null===x||!j[x]||!k)return null;const e=j[x].time,{start:a,end:n}=k,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:Xe(e.typeNum)}))};const l=new Map,i=new Map;let m=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),m++,o){const s=B(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble});i.set(e,(i.get(e)??0)+s),u+=s}}const d=c.map(e=>{let s;return s="airtime"===t?u>0?(i.get(e.key)??0)/u:0:m>0?(l.get(e.key)??0)/m:0,{key:e.key,label:e.label,value:s,color:Xe(e.typeNum)}});return{timestamp:j[x].timestamp,timeLabel:e,items:d}},[x,j,k,s,c,t,o]);if(0===j.length)return n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]});const C=(null==S?void 0:S.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(qe,{data:N,maxValue:w,onHover:M,scatterData:v,noiseFloorAnomalies:u,showNoiseFloorOverlay:d,overlayOpacity:h,highlightedType:g,hoveredTimeRange:k,timeRangeHours:b,yAxisMode:"share"===t?"share":"airtime"})}),C&&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:C})]}),n.jsx(Ge,{sortedTypes:c,highlightedType:g,onTypeHover:y,aggregateShares:m,hoverData:S})]})}const at=new class{constructor(){a(this,"buckets",new Map),a(this,"lastProcessedTimestamp",0),a(this,"processedPacketCount",0),a(this,"cacheKey",null),a(this,"bucketDuration",60),a(this,"bucketDurationMs",6e4)}getBuckets(e,t,s,a){const n={startTs:t,endTs:s,radioConfigHash:this.hashRadioConfig(a)};return this.isCacheValid(n)?this.processPackets(e,t,s,a,!1):(this.invalidate(n),this.processPackets(e,t,s,a,!0)),this.toBucketDataArray(t,s)}processPackets(e,t,s,a,n){const r=Math.ceil((s-t)/this.bucketDuration);let l=0;for(const i of e){const e=i.timestamp;if(e=s)continue;if(!n&&e<=this.lastProcessedTimestamp)continue;const o=Math.min(Math.floor((e-t)/this.bucketDuration),r-1),c=this.buckets.get(o)??{total:0,totalAirtime:0};c.total+=1,c.totalAirtime+=B(i,{spreadingFactor:a.sf,bandwidthHz:a.bw,codingRate:a.cr,preambleLength:a.preamble}),this.buckets.set(o,c),e>this.lastProcessedTimestamp&&(this.lastProcessedTimestamp=e),l++}this.processedPacketCount+=l}toBucketDataArray(e,t){const s=t-e,a=Math.ceil(s/this.bucketDuration),n=s/3600,r=[];for(let l=0;l24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),i=this.buckets.get(l)??{total:0,totalAirtime:0};r.push({timestamp:t,time:a,total:i.total,totalAirtime:i.totalAirtime,bucketDurationMs:this.bucketDurationMs})}return r}isCacheValid(e){return!!this.cacheKey&&this.cacheKey.startTs===e.startTs&&this.cacheKey.endTs===e.endTs&&this.cacheKey.radioConfigHash===e.radioConfigHash}invalidate(e){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=e}hashRadioConfig(e){return`${e.sf}-${e.bw}-${e.cr}-${e.preamble}`}clear(){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=null}getStats(){return{bucketCount:this.buckets.size,processedPackets:this.processedPacketCount,lastTimestamp:this.lastProcessedTimestamp,cacheKey:this.cacheKey}}};function 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({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(m,{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(u,{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:"Light smoothing",children:n.jsx(h,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"Moderate smoothing",children:n.jsx(x,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"Heavy smoothing",children:n.jsx(p,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"Ultra smoothing",children:n.jsx(g,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap)",children:n.jsx(f,{className:"w-3.5 h-3.5"})})]})}function lt({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(o,{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(c,{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})]})}const it={sf:10,bw:25e4,cr:5,preamble:8};function ot(e){return z[e]??`TYPE_${e.toString(16).toUpperCase()}`}function ct(e,t){if(0===e.length)return[];const s=Math.floor((t-1)/2),a=[];for(let n=0;n=s?e[n-s]:e[0];a.push(e[n]+(e[n]-t))}return function(e,t){if(0===e.length)return[];const s=2/(t+1),a=[e[0]];for(let n=1;n{const t=Math.abs(e.length-j.current);if(0===t&&b.length>0)return;v.current&&clearTimeout(v.current);const s=t>100?50:500;return v.current=setTimeout(()=>{j.current=e.length,y(e)},s),()=>{v.current&&clearTimeout(v.current)}},[e,b.length]);const N=r.useMemo(()=>function(e,t){const s=new Map;for(const n of e){const e=n.type??n.payload_type??-1,a=B(n,{spreadingFactor:t.sf,bandwidthHz:t.bw,codingRate:t.cr,preambleLength:t.preamble}),r=s.get(e)??{count:0,airtime:0};s.set(e,{count:r.count+1,airtime:r.airtime+a})}const a=[];for(const[n,r]of s)a.push({typeNum:n,key:`TYPE_${n}`,label:ot(n),totalCount:r.count,totalAirtime:r.airtime});return a.sort((e,t)=>t.totalCount-e.totalCount)}(b,i),[b,i]),w=r.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=l/3600,m=[];for(let u=0;u24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o};for(const t of r)a.counts[t.key]=0,a.airtimes[t.key]=0;m.push(a)}for(const u of e){const e=u.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${u.type??u.payload_type??-1}`;m[r].counts[l]=(m[r].counts[l]??0)+1,m[r].total++;const o=B(u,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});m[r].airtimes[l]=(m[r].airtimes[l]??0)+o,m[r].totalAirtime+=o}for(const u of m)for(const e of r)u.shares[e.key]=u.total>0?u.counts[e.key]/u.total*100:0;return m}(b,t,s,a,i,N),[b,t,s,a,i,N]),M=r.useMemo(()=>at.getBuckets(b,t,s,i),[b,t,s,i]),k=r.useMemo(()=>N.reduce((e,t)=>e+t.totalCount,0),[N]),S=r.useMemo(()=>N.reduce((e,t)=>e+t.totalAirtime,0),[N]),{sortedTypes:C,aggregateShares:T}=r.useMemo(()=>{const e=new Map,t="share"===o?k:S;if(t>0)for(const s of N){const a="share"===o?s.totalCount:s.totalAirtime;e.set(s.key,a/t)}return{sortedTypes:[...N].sort((t,s)=>(e.get(s.key)??0)-(e.get(t.key)??0)),aggregateShares:e}},[N,k,S,o]),F=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 d=0;d0?(e.counts[s[t].key]??0)/e.total:0;else{let t=0;for(let a=0;a0?(e.airtimes[s[a].key]??0)/t:0}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let d=0;dfunction(e,t){switch(t){case"zlema":return ct(e,6);case"ema":return ct(e,12);case"smooth":return ct(e,24);case"ultra":return ct(e,96);default:return e}}(e,a)),m=Array.from({length:l},()=>new Array(r).fill(0));for(let d=0;d0?c[d-1][e]:0;m[d][e]=Math.min(1,Math.max(0,c[d][e]-t))}for(let d=0;d0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;ep(e),[]),P=r.useCallback(e=>f(e),[]),R=r.useMemo(()=>{if(null===g||!F[g])return null;const e=F[g];return{timestamp:e.timestamp,timeLabel:e.time,items:C.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:Xe(t.typeNum)}))}},[g,F,C]),A=r.useMemo(()=>({timestamps:F.map(e=>e.timestamp),series:C.map(e=>({key:e.key,label:e.label,color:Xe(e.typeNum),values:F.map(t=>t[e.key]??0)}))}),[F,C]);return 0===b.length?0===e.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===c?n.jsx(Qe,{sortedTypes:C,aggregateShares:T}):"stats"===c?n.jsx(st,{statsBuckets:M,mode:o,packets:b,startTs:t,endTs:s,radioConfig:i,sortedTypes:C,aggregateShares:T,noiseFloorAnomalies:m,showNoiseFloorOverlay:u,overlayOpacity:d}):"trend"===c?n.jsx(et,{packets:b,mode:o,startTs:t,endTs:s,radioConfig:i,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(H,{timestamps:A.timestamps,series:A.series,highlightedKey:x,cursorColor:h.cursor,onHover:P})})}),n.jsx(Ge,{sortedTypes:C,highlightedType:x,onTypeHover:$,aggregateShares:T,hoverData:R})]})}),ut={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},dt=[1,5,10,25,50,100,150];function ht(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 xt(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 pt=[{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 gt(e,t){return t[ce(e)]||"#808080"}const ft=r.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=r.useState(null),[c,m]=r.useState(new Set),[u,d]=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=ie(),M=ne(),k=oe(),S=re();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&&d({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&d({width:s.width,height:s.height}),()=>t.disconnect()},[]);const C=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:F,maxDistance:$,totalNeighbors:P,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(!C.has(r))continue;const e=ht(s,a,l.latitude,l.longitude),n=xt(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,C,T]);r.useEffect(()=>{null==l||l({zeroHopCount:R,totalCount:P,maxDistanceKm:$})},[R,P,$]),r.useEffect(()=>{const e=ut[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(()=>dt.filter(e=>e<=1.1*A),[A]);r.useEffect(()=>{const e=[];for(const s of F){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(()=>{m(t=>new Set([...t,...e]))});const t=setTimeout(()=>{m(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[F]);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:H,centerX:z,centerY:O,maxRadiusX:W,maxRadiusY:I,labelRadiusX:V,labelRadiusY:q,cornerRadius:X}=E,G=r.useCallback((e,t=1)=>{const s=W*t,a=I*t,n=Math.min(X*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(z-s+n,Math.min(z+s-n,z+a*e*(s/a))),c=O-a}else if(r>45-i&&r<=45+i)o=z+s-n+n*Math.sin(l),c=O-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(O-a+n,Math.min(O+a-n,O-s*e*(a/s))),o=z+s}else if(r>135-i&&r<=135+i)o=z+s-n+n*Math.sin(l),c=O+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(z-s+n,Math.min(z+s-n,z-a*e*(s/a))),c=O+a}else if(r>225-i&&r<=225+i)o=z-s+n+n*Math.sin(l),c=O+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(O-a+n,Math.min(O+a-n,O-s*e*(a/s))),o=z-s}else o=z-s+n+n*Math.sin(l),c=O-a+n-n*Math.cos(l);return{x:o,y:c}},[z,O,W,I,X]),K=r.useCallback((e,t)=>{const s=G(e,1);return{x:z+(s.x-z)*t,y:O+(s.y-O)*t}},[G,z,O]),Y=r.useCallback(e=>({N:{x:z,y:O-q},S:{x:z,y:O+q},E:{x:z+V,y:O},W:{x:z-V,y:O},NE:{x:z+V,y:O-q},SE:{x:z+V,y:O+q},SW:{x:z-V,y:O+q},NW:{x:z-V,y:O-q}}[e]),[z,O,V,q]),U=r.useCallback(e=>{const t=W*e,s=I*e,a=Math.min(X*e,t,s),n=z-t,r=z+t,l=O-s,i=O+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(" ")},[z,O,W,I,X]),Q=r.useCallback(e=>{o(e)},[]),Z=r.useCallback(e=>{x(e)},[]),J=r.useCallback(e=>$<=0?0:e/$*p,[$,p]),ee=e=>`${e}km`,te=r.useMemo(()=>{const e=L.map(e=>{const t=e/$*p;return{km:e,scale:t,labelY:O-I*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,O,I]),se=u.width>0&&u.height>0;return D?0===P?n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-secondary",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:se&&n.jsxs("svg",{width:B,height:H,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:U(1)})})]}),L.map(e=>{const t=J(e);if(t>1.05||t<.02)return null;const s=te.some(t=>t.km===e),a=z+W*t*.71,r=O-I*t*.71;return n.jsxs("g",{children:[n.jsx("path",{d:U(t),fill:"none",stroke:S.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:_,children:ee(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?z:"E"===e?z+W:z-W,a=t?"N"===e?O-I:O+I:O;return n.jsx("line",{x1:z,y1:O,x2:s,y2:a,stroke:S.primary,strokeOpacity:.15,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=Y(e);return n.jsx("line",{x1:z,y1:O,x2:t.x,y2:t.y,stroke:S.primary,strokeOpacity:.08,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=Y(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:M.primary,fontSize:16,fontWeight:600,fontFamily:_,"aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=Y(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:M.primary,fontSize:16,fontWeight:600,fontFamily:_,"aria-hidden":"true",children:e},e)}),n.jsx("circle",{cx:z,cy:O,r:5,fill:k.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),n.jsx("g",{clipPath:"url(#radar-clip)",children:F.map(e=>{const t=$>0?e.distance/$*p:0;if(t>1)return null;const{x:s,y:a}=K(e.bearing,t),r=null!==e.snr?gt(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:()=>Z(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-secondary hover:bg-white/10 hover:text-text-primary"),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-secondary 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-secondary",children:"SNR:"})," ",n.jsxs("span",{className:"tabular-nums",style:{color:gt(i.snr,w)},children:[i.snr.toFixed(1)," dB"]}),n.jsxs("span",{className:"text-text-secondary ml-1",children:["(",(ae=i.snr,(null==(le=pt.find(e=>ae>=e.min))?void 0:le.label)??"Critical"),")"]})]})}):n.jsx("div",{className:"text-xs text-text-secondary 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-secondary",children:"Distance:"})," ",n.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.distance.toFixed(2)," km"]})]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary",children:"Bearing:"})," ",n.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-secondary",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 ae,le});function bt(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 yt=r.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const{theme:i}=O(),[o,c]=r.useState(!0),m=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:bt(n,5),p95:bt(n,95)}},[t]);r.useEffect(()=>{null==s||s(m)},[m]);const u=r.useCallback(()=>{c(e=>!e)},[]),{heatmapData:d,xLabels:h,yLabels:x}=r.useMemo(()=>{if(0===e.length||0===t.length||!m)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(m.p95-m.p5||1);s=m.p5-e,a=m.p95+e}else{const e=.1*(m.max-m.min||1);s=m.min-e,a=m.max+e}const n=a-s,r=e[0],l=e[e.length-1]-r||1,i=new Float32Array(2*e.length);for(let o=0;o{const e=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||!d||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 r=getComputedStyle(document.documentElement).getPropertyValue("--accent-primary").trim(),{r:l,g:i,b:o}=(e=>{const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\)/);if(t)return{r:Math.round(255*parseFloat(t[1])),g:Math.round(255*parseFloat(t[2])),b:Math.round(255*parseFloat(t[3]))};const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:{r:250,g:189,b:47}})(r),{points:c,count:m}=d,u=Math.max(3,Math.min(8,s/m*4));t.globalCompositeOperation="source-over";for(let d=0;dn.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),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-secondary 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"})}),vt={repeater:"var(--accent-primary)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function jt(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 Nt=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=jt(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:vt.repeater},{label:"Companions",count:t.companion,percent:0,color:vt.companion},{label:"Room Servers",count:t.room_server,percent:0,color:vt.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-secondary tabular-nums",children:[e.count," ",n.jsxs("span",{className:"text-text-secondary/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-secondary",children:"Total Nodes"}),n.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function wt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=r.useRef(null),[o,c]=r.useState(!1),[m,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 d=m||a&&o;return n.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:d?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 Mt={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-accent-primary"},kt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-accent-primary/10"};function St(){const e=W(),t=I(),[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(Me,{children:[n.jsx(ke,{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-secondary",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 m=(u=e.collisionRate)<=10?"excellent":u<=25?"good":"poor";var u;const d="poor"===o||"poor"===m?"poor":"fair"===o||"fair"===m?"fair":"good"===o||"good"===m?"good":"excellent",h="excellent"===d||"good"===d?w:M;return n.jsxs(Me,{className:"flex flex-col overflow-hidden",children:[n.jsx(ke,{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 ${kt[d]}`,children:[n.jsx(h,{className:`w-3.5 h-3.5 ${Mt[d]}`}),n.jsx("span",{className:`type-data-xs font-medium ${Mt[d]}`,children:"excellent"===d?"Excellent":"good"===d?"Good":"fair"===d?"Fair":"Needs Attention"})]})}),n.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[n.jsxs("div",{className:"grid grid-cols-3 gap-2 py-4",children:[n.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-xl py-3 px-2",title:"Total unique 2-character prefixes observed in packet paths.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.totalPrefixes}),n.jsx("span",{className:"type-data-sm text-text-secondary mt-1",children:"Prefixes"})]}),n.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-xl py-3 px-2",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.unambiguousPrefixes}),n.jsx("span",{className:"type-data-sm text-text-secondary mt-1",children:"Unique"})]}),n.jsxs("div",{className:"flex flex-col items-center cursor-help rounded-xl py-3 px-2 "+(e.collisionPrefixes>0?"bg-accent-primary/15":"bg-white/5"),title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-primary"),style:{letterSpacing:"-0.05em"},children:e.collisionPrefixes}),n.jsx("span",{className:"type-data-sm mt-1 "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-secondary"),children:"Conflicts"})]})]}),e.highCollisionPrefixes.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"type-data-xs text-text-secondary mb-1.5",children:"Problem Prefixes"}),n.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",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-0.5 group",title:`${t} candidates - click to explore`,children:[n.jsx(Te,{children:e}),n.jsxs("span",{className:"text-text-muted type-data-xs group-hover:text-text-secondary transition-colors",children:["×",t]})]},e))})]}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&n.jsx("div",{className:"flex-1 flex items-center",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.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-3",children:[n.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[n.jsx("span",{className:"type-data-xs text-text-secondary",children:"Confidence"}),n.jsxs("span",{className:`data-box ${Mt[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),n.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[n.jsx("span",{className:"type-data-xs text-text-secondary",children:"Collisions"}),n.jsxs("span",{className:`data-box ${Mt[m]}`,children:[e.collisionRate.toFixed(1),"%"]})]})]})]}),n.jsx(Fe,{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-1.5 "+(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-body-sm text-text-secondary",children:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"data-box",style:r?{"--data-box-color":"var(--accent-primary)"}:void 0,children:s}),a&&n.jsx("span",{className:"type-data-xs text-text-secondary",children:a})]})]})}function Tt(){const e=V(),t=q().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:r,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:m,echolocationEdgesInferred:u}=e,d=s>0?((s-a)/s*100).toFixed(1):"0",h=s>0?(r/s*100).toFixed(1):"0",x=l+i,p=x>0||o>0,g=c>0||u>0;return n.jsxs(Me,{children:[n.jsx(ke,{title:"Path Decoder",icon:n.jsx(k,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),n.jsxs(Re,{children:[n.jsxs("div",{children:[n.jsx(Ct,{icon:n.jsx(S,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${d}%`,sublabel:`of ${s.toLocaleString()} paths`,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),n.jsx(Ct,{icon:n.jsx(C,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${h}%`,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."})]}),p&&n.jsxs("div",{className:"mt-3",children:[n.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),n.jsxs("div",{children:[n.jsx(Ct,{icon:n.jsx(T,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:x.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(F,{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."})]})]}),g&&n.jsx(Ct,{icon:n.jsx($,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:m>0?`(${m} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),t>0&&n.jsx(Ct,{icon:n.jsx(P,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Ghost Repeaters",value:t,highlight:!0,tooltip:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map."})]})]})}function Ft(){var e,t,s,a,i,o,c,m,u,d,h,x,p,g,f,y,v;const j=X(),N=G(),w=K(),M=Y(),k=U(),S=Q(),C=Z(),T=J(),[F,$]=r.useState([]),[P,D]=r.useState(null),[E,B]=r.useState(null),[H,z]=r.useState(!0),[_,O]=r.useState(null),[W,I]=r.useState(()=>{const e=localStorage.getItem("statistics-view-mode");return"share"===e||"airtime"===e?e:"airtime"});r.useEffect(()=>{localStorage.setItem("statistics-view-mode",W)},[W]);const[V,q]=r.useState(()=>{const e=localStorage.getItem("statistics-smoothing-mode");return["raw","ema","zlema","smooth","ultra","mosaic","stats","trend"].includes(e)?e:"trend"});r.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",V)},[V]);const[ne,re]=r.useState(!1),[le,ie]=r.useState(!1),[oe,ce]=r.useState(Ae),[me,ue]=r.useState(.5),de=r.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6}[C]??3),[C]),he=ee[de].hours,xe=60*he,pe=ee[de],ge=se(he),fe=S.isBackgroundLoading,be=r.useCallback(e=>{T({0:1,1:2,2:3,3:4,4:5,5:6,6:7}[e]??4)},[T]),ye=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==(o=null==(i=null==j?void 0:j.config)?void 0:i.radio)?void 0:o.coding_rate,null==(m=null==(c=null==j?void 0:j.config)?void 0:c.radio)?void 0:m.preamble_length]);r.useEffect(()=>{!async function(){var e;O(null);try{const t=await te(he);t.success&&(null==(e=t.data)?void 0:e.history)&&$(t.data.history)}catch(t){O(t instanceof Error?t.message:"Failed to load chart data")}finally{z(!1)}}()},[he]);const ve=r.useMemo(()=>72===he?6e5:168===he?18e5:336===he?36e5:3e5,[he]),je=r.useCallback(async()=>{var e;try{const t=await te(he);t.success&&(null==(e=t.data)?void 0:e.history)&&$(t.data.history)}catch{}},[he]);ae(je,ve,!0,!0);const Ne=r.useMemo(()=>0===F.length?{timestamps:[],values:[]}:{timestamps:F.map(e=>e.timestamp),values:F.map(e=>e.noise_floor_dbm)},[F]),Te=r.useMemo(()=>{if(F.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Ae,...t};if(e.length<10)return{anomalies:[],thresholds:De([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=De(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=Le(r,s.baselinePercentile),i=Le(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let m=null,u=0;for(const d of o)if(d.noise_floor_dbm>l&&d.noise_floor_dbme+t,0)/m.values.length):(m.values.length>=s.minSequenceLength&&c.push(m),m={startTs:d.timestamp,endTs:d.timestamp,values:[d.noise_floor_dbm],timestamps:[d.timestamp],rollingAvg:d.noise_floor_dbm})}else m={startTs:d.timestamp,endTs:d.timestamp,values:[d.noise_floor_dbm],timestamps:[d.timestamp],rollingAvg:d.noise_floor_dbm};else m&&m.values.length>=s.minSequenceLength&&c.push(m),m=null;return m&&m.values.length>=s.minSequenceLength&&c.push(m),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:Ee(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}}(F,oe);return{anomalies:e.anomalies,debug:e.debug}},[F,oe]),Fe=Te.anomalies,Re=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]),Be=r.useMemo(()=>{const e=Date.now()/1e3-3600*he;return Object.fromEntries(Object.entries(Re).filter(([,t])=>t.last_seen>=e))},[Re,he]),He=r.useMemo(()=>{const e=60*xe/ge,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*xe,end:s}},[xe,ge]);return n.jsxs(Se,{children:[n.jsx(Ce,{title:"Statistics",icon:n.jsx(R,{}),controls:n.jsx(we,{ranges:ee,selectedIndex:de,onSelect:be,isPending:fe})}),_&&n.jsx(Me,{className:"border border-accent-red/50 bg-accent-red/10",children:n.jsx("p",{className:"text-accent-red",children:_})}),ne&&le&&n.jsxs(Me,{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:["(",pe.label,")"]})]}),n.jsx("button",{onClick:()=>ce(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(oe.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:oe.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),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==(d=null==(u=Te.debug)?void 0:u.baselineCutoff)?void 0:d.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==(x=null==(h=Te.debug)?void 0:h.spikeCutoff)?void 0:x.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==(p=Te.debug)?void 0:p.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:Fe.length})]})]}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[oe.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 (",oe.baselineDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-120",max:"-60",value:oe.baselineDbm,onChange:e=>ce(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",oe.spikeDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-100",max:"-20",value:oe.spikeDbm,onChange:e=>ce(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),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 (",oe.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*me),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:me,onChange:e=>ue(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",oe.baselinePercentile,")"]}),n.jsx("input",{type:"range",min:"1",max:"50",value:oe.baselinePercentile,onChange:e=>ce(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",oe.spikePercentile,")"]}),n.jsx("input",{type:"range",min:"50",max:"99",value:oe.spikePercentile,onChange:e=>ce(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),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 (",oe.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*me),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:me,onChange:e=>ue(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:[oe.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${oe.baselineDbm}, spikeDbm: ${oe.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${oe.baselinePercentile}, spikePercentile: ${oe.spikePercentile}`,", mergeGapSeconds: ",oe.mergeGapSeconds,", minSequenceLength: ",oe.minSequenceLength,", similarityToleranceDbm: ",oe.similarityToleranceDbm]})]})]})]}),fe&&n.jsx($e,{template:"auto",children:n.jsx(Me,{className:"border border-accent-primary/30 bg-accent-primary/5",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"relative flex h-3 w-3",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-3 w-3 bg-accent-primary"})]}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("p",{className:"type-body-sm text-text-primary",children:["Loading ",pe.label," data..."]}),S.loadProgress&&n.jsxs("p",{className:"type-data-xs text-text-muted mt-0.5",children:[S.loadProgress.loaded.toLocaleString()," packets (",S.loadProgress.percent,"%)"]})]})]})})}),H?n.jsx($e,{template:"auto",children:n.jsx(Me,{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($e,{template:"hero-auto",children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(l,{}),title:"Packet Analyzer",badge:pe.label,largeTitle:!0,actions:n.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&n.jsx(lt,{enabled:ne,onChange:re,anomalyCount:Fe.length,showTuning:le,onTuningChange:ie}),n.jsx(rt,{smoothing:V,onChange:q}),n.jsx(nt,{mode:W,onChange:I})]})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(mt,{packets:M,startTs:He.start,endTs:He.end,bucketCount:ge,radioConfig:ye??void 0,mode:W,smoothing:V,noiseFloorAnomalies:Fe,showNoiseFloorOverlay:ne,overlayOpacity:me})})]})})}),n.jsxs($e,{template:"panel",children:[n.jsx(Pe,{span:12,md:6,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(b,{}),title:"Link Quality",badge:pe.label,largeTitle:!0,actions:E?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:E.zeroHopCount})," nbr"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:E.totalCount})," obs"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:E.maxDistanceKm.toFixed(0)})," km"]})]}):null}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(wt,{children:n.jsx(ft,{neighbors:Be,quickNeighbors:w,localLat:(null==(f=null==(g=null==j?void 0:j.config)?void 0:g.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:B})})})]})})}),n.jsx(Pe,{span:12,md:6,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(A,{}),title:"Network Composition",badge:pe.label,largeTitle:!0}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(wt,{children:n.jsx(Nt,{neighbors:Be})})})]})})})]}),n.jsxs($e,{template:"panel",children:[n.jsx(Pe,{span:12,md:6,children:n.jsx(St,{})}),n.jsx(Pe,{span:12,md:6,children:n.jsx(Tt,{})})]}),n.jsx($e,{template:"panel",children:n.jsx(Pe,{span:12,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(L,{}),title:"RF Noise Floor",largeTitle:!0,actions:P?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:P.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:P.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:P.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(wt,{children:n.jsx(yt,{timestamps:Ne.timestamps,values:Ne.values,onStatsChange:D})})})]})})})})]})]})}export{Ft 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,o as i,aC as o,H as c,aD as m,aE as u,aF as d,aG as h,aH as x,aI as p,aJ as g,aK as f,aL as b,aM as y,aN as v,aO as j,aP as N,aQ as w,a8 as M,aR as k,aS as S,aT as C,aU as T,ac as F,aV as $,h as P,C as R,at as A,p as L}from"./vendor-react-DtVWNgeu.js";import{W as D,X as E,Y as B,Z as H,t as z,F as _,_ as O,$ as W,a0 as I,I as V,a1 as q,c as X,f as G,e as K,u as Y,n as U,p as Q,h as Z,o as J,a2 as ee,j as te,a3 as se}from"./index-Bmit1I8S.js";import{u as ae}from"./usePolling-DXhhvgB-.js";import{b as ne,c as re,a as le,d as ie,e as oe,s as ce}from"./useThemeColors-DaJMJYCA.js";import{a as me,b as ue,h as de,g as he}from"./useScientificColormap-n_Aivg5g.js";import{c as xe,R as pe,d as ge,L as fe,C as be,X as ye,Y as ve,T as je,a as Ne}from"./recharts-C9LxPobD.js";import{T as we}from"./TimeRangeSelector-CzmnykND.js";import{a as Me,c as ke,P as Se,b as Ce}from"./PageLayout-CG02PCA-.js";import{D as Te}from"./DataBox-Dl3NmnnB.js";import{C as Fe}from"./CollisionExplorerModal-gzC3uL5Q.js";import{R as $e,C as Pe}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";import"./leaflet-D_ckmI2R.js";function Re({children:e,centered:t,className:s}){return n.jsx("div",{className:xe("flex-1 min-h-0",t&&"flex items-center justify-center",s),children:e})}const Ae={useAbsoluteThresholds:!0,baselinePercentile:6,spikePercentile:50,baselineDbm:-107,spikeDbm:-100,mergeGapSeconds:45,minSequenceLength:16,similarityToleranceDbm:5};function Le(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 De(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:Le(t,50),p90:Le(t,90),p95:Le(t,95),p99:Le(t,99),max:t[t.length-1],min:t[0]}}function Ee(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 D({...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 Be=new Map;function He(e){var t;if(!e.startsWith("var("))return e;const s=Be.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 Be.set(e,l),l}function ze(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:m,cursor:u});r.useLayoutEffect(()=>{y.current={band:l,innerBand:i,mean:o,median:c,average:m,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,m=n.bbox,u=m.left,d=m.top,h=m.width,x=m.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=>d+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,M={band:He(o.band),innerBand:He(o.innerBand),mean:He(o.mean),median:He(o.median),average:He(o.average)};c.save(),c.strokeStyle=M.average,c.lineWidth=4,c.globalAlpha=w("average"),ze(c,j.average),c.stroke(),c.globalAlpha=N("minMax",.15),c.fillStyle=M.band,c.beginPath(),ze(c,j.max);const k=[...j.min].reverse();for(const e of k)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p5p95",.3),c.fillStyle=M.band,c.beginPath(),ze(c,j.p95);const S=[...j.p5].reverse();for(const e of S)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.globalAlpha=N("p25p75",.55),c.fillStyle=M.innerBand,c.beginPath(),ze(c,j.p75);const C=[...j.p25].reverse();for(const e of C)c.lineTo(e.x,e.y);c.closePath(),c.fill(),c.strokeStyle=M.median,c.lineWidth=1.5,c.globalAlpha=w("median"),c.setLineDash([4,4]),ze(c,j.median),c.stroke(),c.strokeStyle=M.mean,c.lineWidth=1.5,c.globalAlpha=w("mean"),c.setLineDash([]),ze(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=d.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 D({...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=d.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:d,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:N})});const _e="undefined"!=typeof window&&(null==(t=null==(e=window.matchMedia)?void 0:e.call(window,"(color-gamut: p3)"))?void 0:t.matches);function Oe(){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 We=["min","max","p75","p95","p99","mean","median","average","midpoint"];function Ie(e){const t=ue(e),s=de(t),a=`color(display-p3 ${(s.r/255).toFixed(3)} ${(s.g/255).toFixed(3)} ${(s.b/255).toFixed(3)})`;return{...s,p3:a}}function Ve(e,t,s,a,n,r,l,i,o,c=null,m=null,u=1,d=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],M=j[N-1],k=s,S="share"===h,C=S?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)}(k):5,T=getComputedStyle(document.documentElement),F=T.getPropertyValue("--signal-critical").trim()||"#EF4444",$=T.getPropertyValue("--bg-body").trim()||"#171717";p.save(),p.fillStyle="#000000";const P=8*v;p.beginPath(),p.roundRect(g,f,b,y,P),p.fill(),p.restore();const R=parseInt($.slice(1,3),16)||23,A=parseInt($.slice(3,5),16)||23,L=parseInt($.slice(5,7),16)||23;if(!S&&k>=20){p.save();const e=f+y*(1-20/k);p.fillStyle=`rgba(${R}, ${A}, ${L}, 0.5)`,p.fillRect(g,f,b,e-f),p.restore()}p.save(),p.lineWidth=1*v,p.setLineDash([4*v,4*v]);for(let E=C;Es+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,d,g,f,b,y,v),l){!function(e,t,s,a,n,r,l=null,i=null,o=1,c=25){const{points:m,rawValues:u,count:d,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,m=.5){if(0===t.length)return;const u=o-i||1,d=function(e,t=1.3,s=.15){const a=function(e){const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);if(t){const e=parseFloat(t[1]),s=parseFloat(t[2]),a=parseFloat(t[3]);return{r:Math.round(255*e),g:Math.round(255*s),b:Math.round(255*a),p3r:e,p3g:s,p3b:a}}if(e.startsWith("#")){const t=e.replace("#",""),s=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return{r:s,g:a,b:n,p3r:s/255,p3g:a/255,p3b:n/255}}const s=e.match(/rgba?\(([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(s){const e=Math.round(parseFloat(s[1])),t=Math.round(parseFloat(s[2])),a=Math.round(parseFloat(s[3]));return{r:e,g:t,b:a,p3r:e/255,p3g:t/255,p3b:a/255}}return{r:255,g:255,b:255,p3r:1,p3g:1,p3b:1}}(e),n=function(e,t,s,a=1.25,n=.15){const r=(Math.max(e,t,s)+Math.min(e,t,s))/2;return{p3r:Math.min(1,r+(e-r)*a+n),p3g:Math.min(1,r+(t-r)*a+n),p3b:Math.min(1,r+(s-r)*a+n)}}(a.p3r,a.p3g,a.p3b,t,s);return{r:Math.round(255*Math.min(1,n.p3r)),g:Math.round(255*Math.min(1,n.p3g)),b:Math.round(255*Math.min(1,n.p3b)),p3r:Math.min(1,n.p3r),p3g:Math.min(1,n.p3g),p3b:Math.min(1,n.p3b)}}(getComputedStyle(document.documentElement).getPropertyValue("--signal-critical").trim()||"#EF4444");e.save(),e.globalAlpha=m,e.fillStyle=_e?`color(display-p3 ${d.p3r} ${d.p3g} ${d.p3b})`:`rgb(${d.r}, ${d.g}, ${d.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,m=Math.max(s-t,2*c);e.fillRect(t,n,m,l)}e.restore()}(p,i,0,g,f,b,y,w,M,v,m?Math.max(.03,.03*x):x)}const qe=r.memo(function({data:e,maxValue:t,visibleLines:s=We,highlightedLine:a=null,onHover:l,scatterData:i=null,noiseFloorAnomalies:o=null,showNoiseFloorOverlay:c=!1,overlayOpacity:m=.5,highlightedType:u=null,hoveredTimeRange:d=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),M=r.useRef(c),k=r.useRef(u),S=r.useRef(d),C=r.useRef(null),T=r.useRef(null),F=r.useRef(x),$=r.useRef(m),P=h<=12?1.2:1,R=r.useRef(P),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,M.current=c,k.current=u,S.current=d,R.current=P,F.current=x,$.current=m}),r.useEffect(()=>{C.current=Oe()},[]);const L=r.useMemo(()=>[e.map(e=>e.timestamp),new Array(e.length).fill(1)],[e]),E=r.useMemo(()=>({hooks:{draw:e=>{const t=C.current||Oe();Ve(e,f.current,b.current,y.current,v.current,t,N.current,w.current,M.current,k.current,S.current,R.current,T.current,F.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:[E]}),[E]);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 D({...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,m,u,d,P]);const H=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,m=c.left/o,u=c.width/o;if(im+u)return T.current=null,r.redraw(),void(null==(s=j.current)||s.call(j,null));T.current=i*o;const d=(i-m)/u,h=e.length,x=Math.floor(d*h),f=Math.max(0,Math.min(h-1,x));r.redraw(),null==(a=j.current)||a.call(j,f)},[e.length]),z=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:H,onMouseLeave:z})}),Xe=he;function Ge({sortedTypes:e,highlightedType:t,onTypeHover:s,aggregateShares:a,hoverData:l}){const i=r.useMemo(()=>{if(!l)return null;const e=new Map;for(const t of l.items)e.set(t.key,t.value);return e},[l]),o=null!==i;return 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=Xe(e.typeNum),l=(null==i?void 0:i.get(e.key))??0,c=a.get(e.key)??0,m=o?l:c,u=m>1e-4,d=t===e.key,h=["legend-item",d&&"legend-item-active",(t&&!d||o&&l<=1e-4)&&"legend-item-dimmed",!t&&o&&l>1e-4&&"legend-item-chart-active"].filter(Boolean).join(" ");return n.jsxs("div",{className:h,onMouseEnter:()=>s(e.key),children:[n.jsx("div",{className:"flex-shrink-0",style:{backgroundColor:r,width:9,height:16,borderRadius:1}}),n.jsx("span",{className:"legend-label",children:e.label}),u&&n.jsxs("span",{className:"legend-value "+(o?"legend-value-live":""),children:[(100*m).toFixed(1),"%"]})]},e.key)})})})}const Ke='ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace';function Ye({x:e,y:t,width:s,height:a,name:r,size:l,index:i,depth:o,hoveredIndex:c,onHover:m,total:u,typeNum:d}){if(1!==o)return null;const h=null!==c&&!(c===i),x=Xe(d),p=u>0?l/u*100:0,g=s>36&&a>20,f=s>36&&a>32;return n.jsxs("g",{onMouseEnter:e=>m(i,e),onMouseLeave:()=>m(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:Ke,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:Ke,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 Qe({sortedTypes:e,aggregateShares:t}){var s,a,i;const[o,c]=r.useState(null),[m,u]=r.useState(null),[d,h]=r.useState(0),[x,p]=r.useState(null),g=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(c(e),t&&null!==e){const e=g.current;if(e){const s=e.getBoundingClientRect();h(s.width),u({x:t.clientX-s.left,y:t.clientY-s.top})}}else u(null)},[]),v=r.useCallback(e=>{if(p(e),e){const t=b.findIndex(t=>t.key===e);c(t>=0?t:null)}else c(null)},[b]),j=null!==o?{name:(null==(s=b[o])?void 0:s.name)??"",value:(null==(a=b[o])?void 0:a.size)??0}:null,N=null!==o?Xe(null==(i=b[o])?void 0:i.typeNum):"";return 0===e.length||0===f?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{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:g,children:[n.jsx(pe,{width:"100%",height:"100%",children:n.jsx(ge,{data:b,dataKey:"size",aspectRatio:4/3,stroke:"none",isAnimationActive:!1,content:n.jsx(Ye,{x:0,y:0,width:0,height:0,name:"",size:0,index:0,depth:0,hoveredIndex:o,onHover:y,total:f,typeNum:0})})}),n.jsx(Ue,{data:j,total:f,color:N,position:m,containerWidth:d})]}),n.jsx(Ge,{sortedTypes:e,highlightedType:x,onTypeHover:v,aggregateShares:t})]})}function Ze(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 Je({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 et({packets:e,mode:t,startTs:s,endTs:a,radioConfig:o,bucketCount:c}){const m=ne(),u=re(),d=m.primary,h=m.tertiary,[x,p]=r.useState(null),{trendData:g,totals:f}=r.useMemo(()=>{if(0===e.length)return{trendData:[],totals:{rxBytes:0,txBytes:0,rxAirtime:0,txAirtime:0}};const n=a-s,r=Math.min(Math.ceil(n/300),c),l=n/r,i=[];let m=0,u=0,d=0,h=0;for(const t of e){const e=t.timestamp;if(e=a)continue;const n=E(t),r=B(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble}),l={timestamp:e,rxAirtime:0,txAirtime:0,rxBytes:0,txBytes:0};t.transmitted?(l.txAirtime=r,l.txBytes=n,u+=n,h+=r):(l.rxAirtime=r,l.rxBytes=n,m+=n,d+=r),i.push(l)}i.sort((e,t)=>e.timestamp-t.timestamp);const x=new Float64Array(i.length+1),p=new Float64Array(i.length+1),g=new Float64Array(i.length+1),f=new Float64Array(i.length+1),b=new Float64Array(i.length);for(let e=0;e{let t=0,s=b.length;for(;t>>1;b[a]0?e:null,tx:t>0?t:null})}else{const e=(x[i]-x[r])/j*100,t=(p[i]-p[r])/j*100;v.push({timestamp:a,rx:e>0?e:null,tx:t>0?t:null})}}const N=2/31;let w=null;return{trendData:v.map(e=>{const t=e.rx;return null!==t&&t>0&&(w=null===w?t:N*t+(1-N)*w),{...e,rxSmooth:null!==w&&w>0?w:null}}),totals:{rxBytes:m,txBytes:u,rxAirtime:d,txAirtime:h}}},[e,s,a,c,t,o]),b=r.useMemo(()=>{if(0===g.length)return"share"===t?100:10;let e=0;for(const t of g){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))},[g,t]),y=r.useMemo(()=>{if(null!==x&&g[x]){const e=g[x],s=e.rx??0,a=e.tx??0;return"share"===t?{rx:Ze(s),tx:Ze(a),total:Ze(s+a),isHovered:!0}:{rx:`${s.toFixed(2)}%`,tx:`${a.toFixed(2)}%`,total:`${(s+a).toFixed(2)}%`,isHovered:!0}}if("share"===t)return{rx:Ze(f.rxBytes),tx:Ze(f.txBytes),total:Ze(f.rxBytes+f.txBytes),isHovered:!1};{let e=0,t=0,s=0;for(const r of g)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}}},[x,g,f,t]),v=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]),j=r.useCallback(e=>{const t=null==e?void 0:e.activeTooltipIndex;p("number"==typeof t?t:null)},[]),N=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===g.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{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-secondary",style:{height:20,paddingLeft:44,paddingRight:8},children:n.jsx("div",{className:"relative w-full h-full flex items-center",children:v.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(i,{className:"w-2.5 h-2.5 opacity-60"}),n.jsx("span",{className:"tabular-nums",children:e.label})]},t))})}),n.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:n.jsx(pe,{width:"100%",height:"100%",minWidth:1,minHeight:1,children:n.jsxs(fe,{data:g,margin:{top:4,right:8,bottom:4,left:0},onMouseMove:j,onMouseLeave:()=>p(null),children:[n.jsx(be,{strokeDasharray:"3 3",stroke:u.secondary,strokeOpacity:.3,vertical:!1}),n.jsx(ye,{dataKey:"timestamp",type:"number",domain:[s,a],axisLine:!1,tickLine:!1,tick:!1,height:0}),n.jsx(ve,{axisLine:!1,tickLine:!1,tick:{fill:u.secondary,fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace'},dx:-8,width:44,tickFormatter:N,domain:[0,b]}),n.jsx(je,{content:n.jsx(Je,{mode:t})}),n.jsx(Ne,{type:"linear",dataKey:"rx",name:"RX",stroke:d,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(Ne,{type:"linear",dataKey:"tx",name:"TX",stroke:h,strokeWidth:2.5,strokeOpacity:.9,dot:!1,connectNulls:!1,isAnimationActive:!1}),n.jsx(Ne,{type:"basis",dataKey:"rxSmooth",name:"RX Avg",stroke:d,strokeWidth:24,strokeOpacity:.1,dot:!1,connectNulls:!0,isAnimationActive:!1,style:{mixBlendMode:"screen"},strokeLinecap:"round"})]})})}),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:d}}),n.jsx("span",{className:"text-text-secondary",children:"RX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-0.5",style:{backgroundColor:h}}),n.jsx("span",{className:"text-text-secondary",children:"TX"})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:"w-4 h-1.5 rounded-sm opacity-25",style:{backgroundColor:d}}),n.jsx("span",{className:"text-text-secondary",children:"RX Avg"})]})]}),n.jsxs("div",{className:"flex items-center gap-4 text-right pr-2 font-mono",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium",style:{color:d},children:"RX"}),n.jsx("span",{className:"font-bold text-xl text-text-primary",children:y.rx})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-xs font-medium",style:{color:h},children:"TX"}),n.jsx("span",{className:"font-bold text-xl text-text-primary",children:y.tx})]}),y.isHovered&&n.jsx("span",{className:"text-xs text-text-muted",children:"bucket"})]})]})]})}function tt(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 st({statsBuckets:e,mode:t,packets:s,startTs:a,endTs:i,radioConfig:o,sortedTypes:c,aggregateShares:m,noiseFloorAnomalies:u,showNoiseFloorOverlay:d,overlayOpacity:h=.5}){const[x,p]=r.useState(null),[g,f]=r.useState(null),b=r.useMemo(()=>(i-a)/3600,[a,i]),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=E(e);let o;if(o="airtime"===a?B(e,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble}):1,r<=0)continue;const c=Math.floor((e.timestamp-t)/300),m={timestamp:e.timestamp,airtimeMs:o,byteSize:r,packetType:s,bucketIndex:c};l.push(m),i.has(c)||i.set(c,[]),i.get(c).push(m)}if(0===l.length)return null;const o=[],c=[],m=[],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;let s=0;for(const a of e)a.airtimeMs>s&&(s=a.airtimeMs);for(const a of e){const e=a.airtimeMs/s*t;u.set(a,e)}}for(const e of l){const t=u.get(e);void 0!==t&&(o.push(t),c.push(e.timestamp),m.push(e.packetType))}let d=c[0],h=c[0];for(let e=1;eh&&(h=c[e]);const x=h-d||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],M=new Map;for(const e of o){const t=Math.round(100*e)/100;M.set(t,(M.get(t)??0)+1)}const k=M.size,S=[...M.entries()].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({value:e,count:t,percent:t/o.length*100}));let C;if("share"===a)C=200;else{const e=5,t=Math.ceil(f/e)*e;C=t<=10?10:t+e}const T=new Float32Array(2*o.length),F=new Float32Array(o.length),$=new Uint8Array(o.length),P=new Float32Array(o.length);for(let e=0;e=0?m[e]:255,P[e]=c[e]}return{points:T,rawValues:F,packetTypes:$,timestamps:P,count:o.length,minTime:d,maxTime:h,minValue:0,maxValue:C,rawMinValue:g,rawMaxValue:f,unit:"%",stats:{p5:j,p50:N,p95:w,uniqueValues:k,topValues:S}}},[e,t,s,a,n])}(s,a,i,"share"===t?"share":"airtime",o),{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 m=0;mj.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]),M=r.useCallback(e=>{p(e)},[]),k=r.useMemo(()=>{if(null===x||!j[x])return null;const e=j[x];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}},[x,j,b]),S=r.useMemo(()=>{if(null===x||!j[x]||!k)return null;const e=j[x].time,{start:a,end:n}=k,r=s.filter(e=>e.timestamp>=a&&e.timestamp({key:e.key,label:e.label,value:0,color:Xe(e.typeNum)}))};const l=new Map,i=new Map;let m=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),m++,o){const s=B(t,{spreadingFactor:o.sf,bandwidthHz:o.bw,codingRate:o.cr,preambleLength:o.preamble});i.set(e,(i.get(e)??0)+s),u+=s}}const d=c.map(e=>{let s;return s="airtime"===t?u>0?(i.get(e.key)??0)/u:0:m>0?(l.get(e.key)??0)/m:0,{key:e.key,label:e.label,value:s,color:Xe(e.typeNum)}});return{timestamp:j[x].timestamp,timeLabel:e,items:d}},[x,j,k,s,c,t,o]);if(0===j.length)return n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]});const C=(null==S?void 0:S.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(qe,{data:N,maxValue:w,onHover:M,scatterData:v,noiseFloorAnomalies:u,showNoiseFloorOverlay:d,overlayOpacity:h,highlightedType:g,hoveredTimeRange:k,timeRangeHours:b,yAxisMode:"share"===t?"share":"airtime"})}),C&&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:C})]}),n.jsx(Ge,{sortedTypes:c,highlightedType:g,onTypeHover:y,aggregateShares:m,hoverData:S})]})}const at=new class{constructor(){a(this,"buckets",new Map),a(this,"lastProcessedTimestamp",0),a(this,"processedPacketCount",0),a(this,"cacheKey",null),a(this,"bucketDuration",60),a(this,"bucketDurationMs",6e4)}getBuckets(e,t,s,a){const n={startTs:t,endTs:s,radioConfigHash:this.hashRadioConfig(a)};return this.isCacheValid(n)?this.processPackets(e,t,s,a,!1):(this.invalidate(n),this.processPackets(e,t,s,a,!0)),this.toBucketDataArray(t,s)}processPackets(e,t,s,a,n){const r=Math.ceil((s-t)/this.bucketDuration);let l=0;for(const i of e){const e=i.timestamp;if(e=s)continue;if(!n&&e<=this.lastProcessedTimestamp)continue;const o=Math.min(Math.floor((e-t)/this.bucketDuration),r-1),c=this.buckets.get(o)??{total:0,totalAirtime:0};c.total+=1,c.totalAirtime+=B(i,{spreadingFactor:a.sf,bandwidthHz:a.bw,codingRate:a.cr,preambleLength:a.preamble}),this.buckets.set(o,c),e>this.lastProcessedTimestamp&&(this.lastProcessedTimestamp=e),l++}this.processedPacketCount+=l}toBucketDataArray(e,t){const s=t-e,a=Math.ceil(s/this.bucketDuration),n=s/3600,r=[];for(let l=0;l24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),i=this.buckets.get(l)??{total:0,totalAirtime:0};r.push({timestamp:t,time:a,total:i.total,totalAirtime:i.totalAirtime,bucketDurationMs:this.bucketDurationMs})}return r}isCacheValid(e){return!!this.cacheKey&&this.cacheKey.startTs===e.startTs&&this.cacheKey.endTs===e.endTs&&this.cacheKey.radioConfigHash===e.radioConfigHash}invalidate(e){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=e}hashRadioConfig(e){return`${e.sf}-${e.bw}-${e.cr}-${e.preamble}`}clear(){this.buckets.clear(),this.lastProcessedTimestamp=0,this.processedPacketCount=0,this.cacheKey=null}getStats(){return{bucketCount:this.buckets.size,processedPackets:this.processedPacketCount,lastTimestamp:this.lastProcessedTimestamp,cacheKey:this.cacheKey}}};function 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({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(m,{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(u,{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:"Light smoothing",children:n.jsx(h,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ema"),className:"toggle-group-item "+("ema"===e?"active":""),title:"Moderate smoothing",children:n.jsx(x,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("smooth"),className:"toggle-group-item "+("smooth"===e?"active":""),title:"Heavy smoothing",children:n.jsx(p,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("ultra"),className:"toggle-group-item "+("ultra"===e?"active":""),title:"Ultra smoothing",children:n.jsx(g,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>t("mosaic"),className:"toggle-group-item "+("mosaic"===e?"active":""),title:"Mosaic view (treemap)",children:n.jsx(f,{className:"w-3.5 h-3.5"})})]})}function lt({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(o,{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(c,{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})]})}const it={sf:10,bw:25e4,cr:5,preamble:8};function ot(e){return z[e]??`TYPE_${e.toString(16).toUpperCase()}`}function ct(e,t){if(0===e.length)return[];const s=Math.floor((t-1)/2),a=[];for(let n=0;n=s?e[n-s]:e[0];a.push(e[n]+(e[n]-t))}return function(e,t){if(0===e.length)return[];const s=2/(t+1),a=[e[0]];for(let n=1;n{const t=Math.abs(e.length-j.current);if(0===t&&b.length>0)return;v.current&&clearTimeout(v.current);const s=t>100?50:500;return v.current=setTimeout(()=>{j.current=e.length,y(e)},s),()=>{v.current&&clearTimeout(v.current)}},[e,b.length]);const N=r.useMemo(()=>function(e,t){const s=new Map;for(const n of e){const e=n.type??n.payload_type??-1,a=B(n,{spreadingFactor:t.sf,bandwidthHz:t.bw,codingRate:t.cr,preambleLength:t.preamble}),r=s.get(e)??{count:0,airtime:0};s.set(e,{count:r.count+1,airtime:r.airtime+a})}const a=[];for(const[n,r]of s)a.push({typeNum:n,key:`TYPE_${n}`,label:ot(n),totalCount:r.count,totalAirtime:r.airtime});return a.sort((e,t)=>t.totalCount-e.totalCount)}(b,i),[b,i]),w=r.useMemo(()=>function(e,t,s,a,n,r){const l=s-t,i=l/a,o=1e3*i,c=l/3600,m=[];for(let u=0;u24?s.toLocaleDateString([],{weekday:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),counts:{},shares:{},airtimes:{},total:0,totalAirtime:0,bucketDurationMs:o};for(const t of r)a.counts[t.key]=0,a.airtimes[t.key]=0;m.push(a)}for(const u of e){const e=u.timestamp;if(e=s)continue;const r=Math.min(Math.floor((e-t)/i),a-1),l=`TYPE_${u.type??u.payload_type??-1}`;m[r].counts[l]=(m[r].counts[l]??0)+1,m[r].total++;const o=B(u,{spreadingFactor:n.sf,bandwidthHz:n.bw,codingRate:n.cr,preambleLength:n.preamble});m[r].airtimes[l]=(m[r].airtimes[l]??0)+o,m[r].totalAirtime+=o}for(const u of m)for(const e of r)u.shares[e.key]=u.total>0?u.counts[e.key]/u.total*100:0;return m}(b,t,s,a,i,N),[b,t,s,a,i,N]),M=r.useMemo(()=>at.getBuckets(b,t,s,i),[b,t,s,i]),k=r.useMemo(()=>N.reduce((e,t)=>e+t.totalCount,0),[N]),S=r.useMemo(()=>N.reduce((e,t)=>e+t.totalAirtime,0),[N]),{sortedTypes:C,aggregateShares:T}=r.useMemo(()=>{const e=new Map,t="share"===o?k:S;if(t>0)for(const s of N){const a="share"===o?s.totalCount:s.totalAirtime;e.set(s.key,a/t)}return{sortedTypes:[...N].sort((t,s)=>(e.get(s.key)??0)-(e.get(t.key)??0)),aggregateShares:e}},[N,k,S,o]),F=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 d=0;d0?(e.counts[s[t].key]??0)/e.total:0;else{let t=0;for(let a=0;a0?(e.airtimes[s[a].key]??0)/t:0}}const o=Array.from({length:l},()=>new Array(r).fill(0));for(let d=0;dfunction(e,t){switch(t){case"zlema":return ct(e,6);case"ema":return ct(e,12);case"smooth":return ct(e,24);case"ultra":return ct(e,96);default:return e}}(e,a)),m=Array.from({length:l},()=>new Array(r).fill(0));for(let d=0;d0?c[d-1][e]:0;m[d][e]=Math.min(1,Math.max(0,c[d][e]-t))}for(let d=0;d0&&Math.abs(e-1)>1e-6){const t=1/e;for(let e=0;ep(e),[]),P=r.useCallback(e=>f(e),[]),R=r.useMemo(()=>{if(null===g||!F[g])return null;const e=F[g];return{timestamp:e.timestamp,timeLabel:e.time,items:C.map(t=>({key:t.key,label:t.label,value:e[t.key]??0,color:Xe(t.typeNum)}))}},[g,F,C]),A=r.useMemo(()=>({timestamps:F.map(e=>e.timestamp),series:C.map(e=>({key:e.key,label:e.label,color:Xe(e.typeNum),values:F.map(t=>t[e.key]??0)}))}),[F,C]);return 0===b.length?0===e.length?n.jsxs("div",{className:"h-full flex items-center justify-center text-text-muted",children:[n.jsx(l,{className:"w-6 h-6 mr-2 opacity-50"}),n.jsx("span",{children:"No packet data available"})]}):null:"mosaic"===c?n.jsx(Qe,{sortedTypes:C,aggregateShares:T}):"stats"===c?n.jsx(st,{statsBuckets:M,mode:o,packets:b,startTs:t,endTs:s,radioConfig:i,sortedTypes:C,aggregateShares:T,noiseFloorAnomalies:m,showNoiseFloorOverlay:u,overlayOpacity:d}):"trend"===c?n.jsx(et,{packets:b,mode:o,startTs:t,endTs:s,radioConfig:i,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(H,{timestamps:A.timestamps,series:A.series,highlightedKey:x,cursorColor:h.cursor,onHover:P})})}),n.jsx(Ge,{sortedTypes:C,highlightedType:x,onTypeHover:$,aggregateShares:T,hoverData:R})]})}),ut={"1x":1,"2x":2,"4x":4,"8x":8,"16x":16,"36x":36},dt=[1,5,10,25,50,100,150];function ht(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 xt(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 pt=[{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 gt(e,t){return t[ce(e)]||"#808080"}const ft=r.memo(function({neighbors:e,quickNeighbors:t,localLat:s,localLon:a,onStatsChange:l}){const[i,o]=r.useState(null),[c,m]=r.useState(new Set),[u,d]=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=ie(),M=ne(),k=oe(),S=re();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&&d({width:e,height:s})}});t.observe(e);const s=e.getBoundingClientRect();return s.width>0&&s.height>0&&d({width:s.width,height:s.height}),()=>t.disconnect()},[]);const C=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:F,maxDistance:$,totalNeighbors:P,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(!C.has(r))continue;const e=ht(s,a,l.latitude,l.longitude),n=xt(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,C,T]);r.useEffect(()=>{null==l||l({zeroHopCount:R,totalCount:P,maxDistanceKm:$})},[R,P,$]),r.useEffect(()=>{const e=ut[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(()=>dt.filter(e=>e<=1.1*A),[A]);r.useEffect(()=>{const e=[];for(const s of F){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(()=>{m(t=>new Set([...t,...e]))});const t=setTimeout(()=>{m(t=>{const s=new Set(t);return e.forEach(e=>s.delete(e)),s})},600);return()=>clearTimeout(t)},[F]);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:H,centerX:z,centerY:O,maxRadiusX:W,maxRadiusY:I,labelRadiusX:V,labelRadiusY:q,cornerRadius:X}=E,G=r.useCallback((e,t=1)=>{const s=W*t,a=I*t,n=Math.min(X*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(z-s+n,Math.min(z+s-n,z+a*e*(s/a))),c=O-a}else if(r>45-i&&r<=45+i)o=z+s-n+n*Math.sin(l),c=O-a+n-n*Math.cos(l);else if(r>45+i&&r<=135-i){const e=1/Math.tan(l);c=Math.max(O-a+n,Math.min(O+a-n,O-s*e*(a/s))),o=z+s}else if(r>135-i&&r<=135+i)o=z+s-n+n*Math.sin(l),c=O+a-n-n*Math.cos(l);else if(r>135+i&&r<=225-i){const e=Math.tan(l);o=Math.max(z-s+n,Math.min(z+s-n,z-a*e*(s/a))),c=O+a}else if(r>225-i&&r<=225+i)o=z-s+n+n*Math.sin(l),c=O+a-n-n*Math.cos(l);else if(r>225+i&&r<=315-i){const e=1/Math.tan(l);c=Math.max(O-a+n,Math.min(O+a-n,O-s*e*(a/s))),o=z-s}else o=z-s+n+n*Math.sin(l),c=O-a+n-n*Math.cos(l);return{x:o,y:c}},[z,O,W,I,X]),K=r.useCallback((e,t)=>{const s=G(e,1);return{x:z+(s.x-z)*t,y:O+(s.y-O)*t}},[G,z,O]),Y=r.useCallback(e=>({N:{x:z,y:O-q},S:{x:z,y:O+q},E:{x:z+V,y:O},W:{x:z-V,y:O},NE:{x:z+V,y:O-q},SE:{x:z+V,y:O+q},SW:{x:z-V,y:O+q},NW:{x:z-V,y:O-q}}[e]),[z,O,V,q]),U=r.useCallback(e=>{const t=W*e,s=I*e,a=Math.min(X*e,t,s),n=z-t,r=z+t,l=O-s,i=O+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(" ")},[z,O,W,I,X]),Q=r.useCallback(e=>{o(e)},[]),Z=r.useCallback(e=>{x(e)},[]),J=r.useCallback(e=>$<=0?0:e/$*p,[$,p]),ee=e=>`${e}km`,te=r.useMemo(()=>{const e=L.map(e=>{const t=e/$*p;return{km:e,scale:t,labelY:O-I*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,O,I]),se=u.width>0&&u.height>0;return D?0===P?n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-secondary",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:se&&n.jsxs("svg",{width:B,height:H,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:U(1)})})]}),L.map(e=>{const t=J(e);if(t>1.05||t<.02)return null;const s=te.some(t=>t.km===e),a=z+W*t*.71,r=O-I*t*.71;return n.jsxs("g",{children:[n.jsx("path",{d:U(t),fill:"none",stroke:S.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:_,children:ee(e)})]},`ring-${e}`)}),["N","E","S","W"].map(e=>{const t="N"===e||"S"===e,s=t?z:"E"===e?z+W:z-W,a=t?"N"===e?O-I:O+I:O;return n.jsx("line",{x1:z,y1:O,x2:s,y2:a,stroke:S.primary,strokeOpacity:.15,strokeWidth:1,strokeDasharray:"4 4"},e)}),["NE","SE","SW","NW"].map(e=>{const t=Y(e);return n.jsx("line",{x1:z,y1:O,x2:t.x,y2:t.y,stroke:S.primary,strokeOpacity:.08,strokeWidth:1,strokeDasharray:"4 4"},`diag-${e}`)}),["N","E","S","W"].map(e=>{const t=Y(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:M.primary,fontSize:16,fontWeight:600,fontFamily:_,"aria-hidden":"true",children:e},e)}),["NE","SE","SW","NW"].map(e=>{const t=Y(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:M.primary,fontSize:16,fontWeight:600,fontFamily:_,"aria-hidden":"true",children:e},e)}),n.jsx("circle",{cx:z,cy:O,r:5,fill:k.chart6,stroke:"rgba(255,255,255,0.3)",strokeWidth:1,role:"img","aria-label":"Local node"}),n.jsx("g",{clipPath:"url(#radar-clip)",children:F.map(e=>{const t=$>0?e.distance/$*p:0;if(t>1)return null;const{x:s,y:a}=K(e.bearing,t),r=null!==e.snr?gt(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:()=>Z(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-secondary hover:bg-white/10 hover:text-text-primary"),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-secondary 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-secondary",children:"SNR:"})," ",n.jsxs("span",{className:"tabular-nums",style:{color:gt(i.snr,w)},children:[i.snr.toFixed(1)," dB"]}),n.jsxs("span",{className:"text-text-secondary ml-1",children:["(",(ae=i.snr,(null==(le=pt.find(e=>ae>=e.min))?void 0:le.label)??"Critical"),")"]})]})}):n.jsx("div",{className:"text-xs text-text-secondary 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-secondary",children:"Distance:"})," ",n.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.distance.toFixed(2)," km"]})]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary",children:"Bearing:"})," ",n.jsxs("span",{className:"tabular-nums text-text-primary",children:[i.bearing.toFixed(0),"°"]})]})]})]})]}):n.jsxs("div",{ref:v,className:"flex flex-col items-center justify-center h-full text-text-secondary",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 ae,le});function bt(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 yt=r.memo(function({timestamps:e,values:t,onStatsChange:s}){var a,l;const{theme:i}=O(),[o,c]=r.useState(!0),m=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:bt(n,5),p95:bt(n,95)}},[t]);r.useEffect(()=>{null==s||s(m)},[m]);const u=r.useCallback(()=>{c(e=>!e)},[]),{heatmapData:d,xLabels:h,yLabels:x}=r.useMemo(()=>{if(0===e.length||0===t.length||!m)return{heatmapData:null,xLabels:[],yLabels:[]};let s,a;if(o){const e=.1*(m.p95-m.p5||1);s=m.p5-e,a=m.p95+e}else{const e=.1*(m.max-m.min||1);s=m.min-e,a=m.max+e}const n=a-s,r=e[0],l=e[e.length-1]-r||1,i=new Float32Array(2*e.length);for(let o=0;o{const e=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||!d||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 r=getComputedStyle(document.documentElement).getPropertyValue("--accent-primary").trim(),{r:l,g:i,b:o}=(e=>{const t=e.match(/color\(display-p3\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\)/);if(t)return{r:Math.round(255*parseFloat(t[1])),g:Math.round(255*parseFloat(t[2])),b:Math.round(255*parseFloat(t[3]))};const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:{r:250,g:189,b:47}})(r),{points:c,count:m}=d,u=Math.max(3,Math.min(8,s/m*4));t.globalCompositeOperation="source-over";for(let d=0;dn.jsx("span",{className:"type-data-xs text-text-secondary tabular-nums text-right pr-1.5",style:{position:"absolute",top:`${e.pos}%`,transform:"translateY(-50%)",right:0},children:e.label},t))}),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-secondary 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"})}),vt={repeater:"var(--accent-primary)",companion:"var(--accent-tertiary)",room_server:"var(--accent-secondary)"};function jt(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 Nt=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=jt(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:vt.repeater},{label:"Companions",count:t.companion,percent:0,color:vt.companion},{label:"Room Servers",count:t.room_server,percent:0,color:vt.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-secondary tabular-nums",children:[e.count," ",n.jsxs("span",{className:"text-text-secondary/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-secondary",children:"Total Nodes"}),n.jsx("span",{className:"type-data-sm text-text-primary font-medium tabular-nums",children:t.total})]})]})});function wt({children:e,minHeight:t="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:l=""}){const i=r.useRef(null),[o,c]=r.useState(!1),[m,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 d=m||a&&o;return n.jsx("div",{ref:i,className:`h-full w-full ${l}`,style:{minHeight:t},children:d?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 Mt={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-accent-primary"},kt={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-accent-primary/10"};function St(){const e=W(),t=I(),[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(Me,{children:[n.jsx(ke,{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-secondary",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 m=(u=e.collisionRate)<=10?"excellent":u<=25?"good":"poor";var u;const d="poor"===o||"poor"===m?"poor":"fair"===o||"fair"===m?"fair":"good"===o||"good"===m?"good":"excellent",h="excellent"===d||"good"===d?w:M;return n.jsxs(Me,{className:"flex flex-col overflow-hidden",children:[n.jsx(ke,{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 ${kt[d]}`,children:[n.jsx(h,{className:`w-3.5 h-3.5 ${Mt[d]}`}),n.jsx("span",{className:`type-data-xs font-medium ${Mt[d]}`,children:"excellent"===d?"Excellent":"good"===d?"Good":"fair"===d?"Fair":"Needs Attention"})]})}),n.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[n.jsxs("div",{className:"grid grid-cols-3 gap-2 py-4",children:[n.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-xl py-3 px-2",title:"Total unique 2-character prefixes observed in packet paths.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.totalPrefixes}),n.jsx("span",{className:"type-data-sm text-text-secondary mt-1",children:"Prefixes"})]}),n.jsxs("div",{className:"flex flex-col items-center cursor-help bg-white/5 rounded-xl py-3 px-2",title:"Prefixes that map to exactly one known node. No disambiguation needed.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums text-text-primary",style:{letterSpacing:"-0.05em"},children:e.unambiguousPrefixes}),n.jsx("span",{className:"type-data-sm text-text-secondary mt-1",children:"Unique"})]}),n.jsxs("div",{className:"flex flex-col items-center cursor-help rounded-xl py-3 px-2 "+(e.collisionPrefixes>0?"bg-accent-primary/15":"bg-white/5"),title:"Prefixes matching multiple known nodes. Click a prefix below to explore candidates.",children:[n.jsx("span",{className:"font-mono text-3xl font-semibold tabular-nums "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-primary"),style:{letterSpacing:"-0.05em"},children:e.collisionPrefixes}),n.jsx("span",{className:"type-data-sm mt-1 "+(e.collisionPrefixes>0?"text-accent-primary":"text-text-secondary"),children:"Conflicts"})]})]}),e.highCollisionPrefixes.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"type-data-xs text-text-secondary mb-1.5",children:"Problem Prefixes"}),n.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",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-0.5 group",title:`${t} candidates - click to explore`,children:[n.jsx(Te,{children:e}),n.jsxs("span",{className:"text-text-muted type-data-xs group-hover:text-text-secondary transition-colors",children:["×",t]})]},e))})]}),0===e.lowConfidencePrefixes.length&&0===e.collisionPrefixes&&n.jsx("div",{className:"flex-1 flex items-center",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.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-3",children:[n.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[n.jsx("span",{className:"type-data-xs text-text-secondary",children:"Confidence"}),n.jsxs("span",{className:`data-box ${Mt[o]}`,children:[(100*e.avgConfidence).toFixed(1),"%"]})]}),n.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[n.jsx("span",{className:"type-data-xs text-text-secondary",children:"Collisions"}),n.jsxs("span",{className:`data-box ${Mt[m]}`,children:[e.collisionRate.toFixed(1),"%"]})]})]})]}),n.jsx(Fe,{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-1.5 "+(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-body-sm text-text-secondary",children:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"data-box",style:r?{"--data-box-color":"var(--accent-primary)"}:void 0,children:s}),a&&n.jsx("span",{className:"type-data-xs text-text-secondary",children:a})]})]})}function Tt(){const e=V(),t=q().length;if(!e||0===e.totalPaths)return null;const{totalPaths:s,pathsWithGhosts:a,observationOverrideCount:r,tracePacketsProcessed:l,pathPacketsProcessed:i,distantEdgesDiscovered:o,duplicateGroupsFound:c,duplicatePathsUnique:m,echolocationEdgesInferred:u}=e,d=s>0?((s-a)/s*100).toFixed(1):"0",h=s>0?(r/s*100).toFixed(1):"0",x=l+i,p=x>0||o>0,g=c>0||u>0;return n.jsxs(Me,{children:[n.jsx(ke,{title:"Path Decoder",icon:n.jsx(k,{}),largeTitle:!0,badge:t>0?`${t} hidden`:void 0}),n.jsxs(Re,{children:[n.jsxs("div",{children:[n.jsx(Ct,{icon:n.jsx(S,{className:"w-3.5 h-3.5"}),label:"Traceable",value:`${d}%`,sublabel:`of ${s.toLocaleString()} paths`,tooltip:"Percentage of packet journeys where every hop was identified. Higher = better visibility into how traffic flows through your mesh."}),n.jsx(Ct,{icon:n.jsx(C,{className:"w-3.5 h-3.5"}),label:"Learning Rate",value:`${h}%`,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."})]}),p&&n.jsxs("div",{className:"mt-3",children:[n.jsx("p",{className:"type-micro mb-2",children:"Beyond Line-of-Sight"}),n.jsxs("div",{children:[n.jsx(Ct,{icon:n.jsx(T,{className:"w-3.5 h-3.5"}),label:"Route Reports",value:x.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(F,{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."})]})]}),g&&n.jsx(Ct,{icon:n.jsx($,{className:"w-3.5 h-3.5"}),label:"Multi-Path Packets",value:c.toLocaleString(),sublabel:m>0?`(${m} routes)`:void 0,tooltip:"Packets received via multiple paths simultaneously. Like sonar, these 'echoes' reveal redundant routes — important for understanding mesh resilience."}),t>0&&n.jsx(Ct,{icon:n.jsx(P,{className:"w-3.5 h-3.5 text-accent-primary"}),label:"Ghost Repeaters",value:t,highlight:!0,tooltip:"High-confidence hidden repeaters: appear in 10+ paths, have 2+ known neighbors, ≥30% confidence, and plausible location. View them on the Contacts map."})]})]})}function Ft(){var e,t,s,a,i,o,c,m,u,d,h,x,p,g,f,y,v;const j=X(),N=G(),w=K(),M=Y(),k=U(),S=Q(),C=Z(),T=J(),[F,$]=r.useState([]),[P,D]=r.useState(null),[E,B]=r.useState(null),[H,z]=r.useState(!0),[_,O]=r.useState(null),[W,I]=r.useState(()=>{const e=localStorage.getItem("statistics-view-mode");return"share"===e||"airtime"===e?e:"airtime"});r.useEffect(()=>{localStorage.setItem("statistics-view-mode",W)},[W]);const[V,q]=r.useState(()=>{const e=localStorage.getItem("statistics-smoothing-mode");return["raw","ema","zlema","smooth","ultra","mosaic","stats","trend"].includes(e)?e:"trend"});r.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",V)},[V]);const[ne,re]=r.useState(!1),[le,ie]=r.useState(!1),[oe,ce]=r.useState(Ae),[me,ue]=r.useState(.5),de=r.useMemo(()=>({0:0,1:0,2:1,3:2,4:3,5:4,6:5,7:6}[C]??3),[C]),he=ee[de].hours,xe=60*he,pe=ee[de],ge=se(he),fe=S.isBackgroundLoading,be=r.useCallback(e=>{T({0:1,1:2,2:3,3:4,4:5,5:6,6:7}[e]??4)},[T]),ye=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==(o=null==(i=null==j?void 0:j.config)?void 0:i.radio)?void 0:o.coding_rate,null==(m=null==(c=null==j?void 0:j.config)?void 0:c.radio)?void 0:m.preamble_length]);r.useEffect(()=>{!async function(){var e;O(null);try{const t=await te(he);t.success&&(null==(e=t.data)?void 0:e.history)&&$(t.data.history)}catch(t){O(t instanceof Error?t.message:"Failed to load chart data")}finally{z(!1)}}()},[he]);const ve=r.useMemo(()=>72===he?6e5:168===he?18e5:336===he?36e5:3e5,[he]),je=r.useCallback(async()=>{var e;try{const t=await te(he);t.success&&(null==(e=t.data)?void 0:e.history)&&$(t.data.history)}catch{}},[he]);ae(je,ve,!0,!0);const Ne=r.useMemo(()=>0===F.length?{timestamps:[],values:[]}:{timestamps:F.map(e=>e.timestamp),values:F.map(e=>e.noise_floor_dbm)},[F]),Te=r.useMemo(()=>{if(F.length<10)return{anomalies:[],debug:void 0};const e=function(e,t={}){const s={...Ae,...t};if(e.length<10)return{anomalies:[],thresholds:De([]),totalSamples:e.length,anomalySamples:0};const a=e.map(e=>e.noise_floor_dbm),n=De(a),r=[...a].sort((e,t)=>e-t);let l,i;s.useAbsoluteThresholds?(l=s.baselineDbm,i=s.spikeDbm):(l=Le(r,s.baselinePercentile),i=Le(r,s.spikePercentile));const o=[...e].sort((e,t)=>e.timestamp-t.timestamp),c=[];let m=null,u=0;for(const d of o)if(d.noise_floor_dbm>l&&d.noise_floor_dbme+t,0)/m.values.length):(m.values.length>=s.minSequenceLength&&c.push(m),m={startTs:d.timestamp,endTs:d.timestamp,values:[d.noise_floor_dbm],timestamps:[d.timestamp],rollingAvg:d.noise_floor_dbm})}else m={startTs:d.timestamp,endTs:d.timestamp,values:[d.noise_floor_dbm],timestamps:[d.timestamp],rollingAvg:d.noise_floor_dbm};else m&&m.values.length>=s.minSequenceLength&&c.push(m),m=null;return m&&m.values.length>=s.minSequenceLength&&c.push(m),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:Ee(s,l,i),sampleCount:e.values.length}}),thresholds:n,totalSamples:e.length,anomalySamples:u,debug:{baselineCutoff:l,spikeCutoff:i,midBandSamples:u}}}(F,oe);return{anomalies:e.anomalies,debug:e.debug}},[F,oe]),Fe=Te.anomalies,Re=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]),Be=r.useMemo(()=>{const e=Date.now()/1e3-3600*he;return Object.fromEntries(Object.entries(Re).filter(([,t])=>t.last_seen>=e))},[Re,he]),He=r.useMemo(()=>{const e=60*xe/ge,t=Math.floor(Date.now()/1e3),s=Math.floor(t/e)*e;return{start:s-60*xe,end:s}},[xe,ge]);return n.jsxs(Se,{children:[n.jsx(Ce,{title:"Statistics",icon:n.jsx(R,{}),controls:n.jsx(we,{ranges:ee,selectedIndex:de,onSelect:be,isPending:fe})}),_&&n.jsx(Me,{className:"border border-accent-red/50 bg-accent-red/10",children:n.jsx("p",{className:"text-accent-red",children:_})}),ne&&le&&n.jsxs(Me,{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:["(",pe.label,")"]})]}),n.jsx("button",{onClick:()=>ce(e=>({...e,useAbsoluteThresholds:!e.useAbsoluteThresholds})),className:"type-data-xs px-2 py-1 rounded transition-colors "+(oe.useAbsoluteThresholds?"bg-accent-purple/30 text-accent-purple":"bg-glass-elevated text-text-muted hover:text-text-secondary"),children:oe.useAbsoluteThresholds?"Absolute dBm":"Percentile"})]}),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==(d=null==(u=Te.debug)?void 0:u.baselineCutoff)?void 0:d.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==(x=null==(h=Te.debug)?void 0:h.spikeCutoff)?void 0:x.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==(p=Te.debug)?void 0:p.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:Fe.length})]})]}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-border-subtle space-y-4",children:[oe.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 (",oe.baselineDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-120",max:"-60",value:oe.baselineDbm,onChange:e=>ce(t=>({...t,baselineDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (",oe.spikeDbm," dBm)"]}),n.jsx("input",{type:"range",min:"-100",max:"-20",value:oe.spikeDbm,onChange:e=>ce(t=>({...t,spikeDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),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 (",oe.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*me),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:me,onChange:e=>ue(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",oe.baselinePercentile,")"]}),n.jsx("input",{type:"range",min:"1",max:"50",value:oe.baselinePercentile,onChange:e=>ce(t=>({...t,baselinePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Spike (P",oe.spikePercentile,")"]}),n.jsx("input",{type:"range",min:"50",max:"99",value:oe.spikePercentile,onChange:e=>ce(t=>({...t,spikePercentile:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Merge Gap (",oe.mergeGapSeconds,"s)"]}),n.jsx("input",{type:"range",min:"5",max:"120",step:"5",value:oe.mergeGapSeconds,onChange:e=>ce(t=>({...t,mergeGapSeconds:Number(e.target.value)})),className:"w-full accent-accent-purple"})]})]}),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 (",oe.minSequenceLength,")"]}),n.jsx("input",{type:"range",min:"2",max:"20",value:oe.minSequenceLength,onChange:e=>ce(t=>({...t,minSequenceLength:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Similarity (±",oe.similarityToleranceDbm," dBm)"]}),n.jsx("input",{type:"range",min:"1",max:"15",value:oe.similarityToleranceDbm,onChange:e=>ce(t=>({...t,similarityToleranceDbm:Number(e.target.value)})),className:"w-full accent-accent-purple"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"type-micro block mb-1",children:["Opacity (",Math.round(100*me),"%)"]}),n.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:me,onChange:e=>ue(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:[oe.useAbsoluteThresholds?`useAbsoluteThresholds: true, baselineDbm: ${oe.baselineDbm}, spikeDbm: ${oe.spikeDbm}`:`useAbsoluteThresholds: false, baselinePercentile: ${oe.baselinePercentile}, spikePercentile: ${oe.spikePercentile}`,", mergeGapSeconds: ",oe.mergeGapSeconds,", minSequenceLength: ",oe.minSequenceLength,", similarityToleranceDbm: ",oe.similarityToleranceDbm]})]})]})]}),fe&&n.jsx($e,{template:"auto",children:n.jsx(Me,{className:"border border-accent-primary/30 bg-accent-primary/5",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"relative flex h-3 w-3",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-3 w-3 bg-accent-primary"})]}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("p",{className:"type-body-sm text-text-primary",children:["Loading ",pe.label," data..."]}),S.loadProgress&&n.jsxs("p",{className:"type-data-xs text-text-muted mt-0.5",children:[S.loadProgress.loaded.toLocaleString()," packets (",S.loadProgress.percent,"%)"]})]})]})})}),H?n.jsx($e,{template:"auto",children:n.jsx(Me,{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($e,{template:"hero-auto",children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(l,{}),title:"Packet Analyzer",badge:pe.label,largeTitle:!0,actions:n.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:["stats"===V&&n.jsx(lt,{enabled:ne,onChange:re,anomalyCount:Fe.length,showTuning:le,onTuningChange:ie}),n.jsx(rt,{smoothing:V,onChange:q}),n.jsx(nt,{mode:W,onChange:I})]})}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(mt,{packets:M,startTs:He.start,endTs:He.end,bucketCount:ge,radioConfig:ye??void 0,mode:W,smoothing:V,noiseFloorAnomalies:Fe,showNoiseFloorOverlay:ne,overlayOpacity:me})})]})})}),n.jsxs($e,{template:"panel",children:[n.jsx(Pe,{span:12,md:6,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(b,{}),title:"Link Quality",badge:pe.label,largeTitle:!0,actions:E?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:E.zeroHopCount})," nbr"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:E.totalCount})," obs"]}),n.jsxs("span",{children:[n.jsx("span",{className:"text-text-secondary tabular-nums font-medium",children:E.maxDistanceKm.toFixed(0)})," km"]})]}):null}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(wt,{children:n.jsx(ft,{neighbors:Be,quickNeighbors:w,localLat:(null==(f=null==(g=null==j?void 0:j.config)?void 0:g.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:B})})})]})})}),n.jsx(Pe,{span:12,md:6,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(A,{}),title:"Network Composition",badge:pe.label,largeTitle:!0}),n.jsx("div",{className:"flex-1 min-h-0",children:n.jsx(wt,{children:n.jsx(Nt,{neighbors:Be})})})]})})})]}),n.jsxs($e,{template:"panel",children:[n.jsx(Pe,{span:12,md:6,children:n.jsx(St,{})}),n.jsx(Pe,{span:12,md:6,children:n.jsx(Tt,{})})]}),n.jsx($e,{template:"panel",children:n.jsx(Pe,{span:12,children:n.jsx(Me,{isLoaded:k,skeletonType:"chart",children:k&&n.jsxs(n.Fragment,{children:[n.jsx(ke,{icon:n.jsx(L,{}),title:"RF Noise Floor",largeTitle:!0,actions:P?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:P.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:P.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:P.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(wt,{children:n.jsx(yt,{timestamps:Ne.timestamps,values:Ne.values,onStatsChange:D})})})]})})})})]})]})}export{Ft as default}; diff --git a/frontend/dist/assets/System-Bl3LqV-u.js b/frontend/dist/assets/System-CfbhqMgy.js similarity index 99% rename from frontend/dist/assets/System-Bl3LqV-u.js rename to frontend/dist/assets/System-CfbhqMgy.js index 7734b835..3d67477d 100644 --- a/frontend/dist/assets/System-Bl3LqV-u.js +++ b/frontend/dist/assets/System-CfbhqMgy.js @@ -1 +1 @@ -import{r as e,j as t,a2 as s,aW as a,af as r,aX as l,aY as n}from"./vendor-react-DtVWNgeu.js";import{c,R as o,A as i,C as d,X as m,Y as x,T as p,e as u,b as h}from"./recharts-C9LxPobD.js";import{a7 as j,a8 as y,a9 as f,aa as g,F as v}from"./index-BIsccma_.js";import{a as b,b as N}from"./useThemeColors-DaJMJYCA.js";import{P as w,b as k,a as C,c as F}from"./PageLayout-CG02PCA-.js";import{R as _,C as M}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const S=Math.floor(12e5/g.system),G={primary:"bg-accent-primary",secondary:"bg-accent-secondary",green:"bg-accent-success",red:"bg-accent-danger",yellow:"bg-accent-secondary"},L=[{threshold:30,color:"var(--accent-tertiary)",next:"var(--accent-primary)"},{threshold:50,color:"var(--accent-primary)",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 O(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-primary)"},{pos:r.normal,color:"var(--accent-primary)"},{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":G[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-primary"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=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:O(l,a,r),width:`${l}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:L.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 $({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 A({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 W=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:r}){const l=function(e){const t=[],s=Math.max(0,S-e.length),a=Date.now(),r=g.system;for(let n=0;n`${e}%`}),t.jsx(p,{content:t.jsx(A,{})}),t.jsx(u,{content:t.jsx($,{})}),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,p]=e.useState(null),[u,h]=e.useState(!1),v=j(),G=y(),L=b(),O=N(),$=O.primary,A=O.tertiary,P=e.useCallback(async()=>{try{const e=await f();e.success&&e.data?(i(e.data),p(null),G(e.data.cpu.usage_percent,e.data.memory.usage_percent,S)):p(e.error??"Failed to fetch hardware stats")}catch(e){p(e instanceof Error?e.message:"Failed to fetch hardware stats")}},[G]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await P(),e&&m(!1))})(),"undefined"==typeof Worker){const t=setInterval(P,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&&P()}}return()=>{e=!1,null==t||t.terminate()}},[P]),t.jsxs(w,{children:[t.jsx(k,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{h(!0),await P(),h(!1)},disabled:u,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",u&&"animate-spin")}),"Refresh"]})}),x&&t.jsx(C,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:x})}),d?t.jsx(C,{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(_,{template:"hero",children:t.jsxs(C,{children:[t.jsx(F,{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:A},children:[o.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(W,{data:v,cpuColor:$,memoryColor:A,chartGridColors:L})}),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(_,{template:"compact",children:[t.jsx(M,{span:12,md:6,children:t.jsxs(C,{children:[t.jsx(F,{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:"primary"}),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(M,{span:12,md:6,children:t.jsxs(C,{children:[t.jsx(F,{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,aW as a,af as r,aX as l,aY as n}from"./vendor-react-DtVWNgeu.js";import{c,R as o,A as i,C as d,X as m,Y as x,T as p,e as u,b as h}from"./recharts-C9LxPobD.js";import{a7 as j,a8 as y,a9 as f,aa as g,F as v}from"./index-Bmit1I8S.js";import{a as b,b as N}from"./useThemeColors-DaJMJYCA.js";import{P as w,b as k,a as C,c as F}from"./PageLayout-CG02PCA-.js";import{R as _,C as M}from"./Grid-Cva3lgGW.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const S=Math.floor(12e5/g.system),G={primary:"bg-accent-primary",secondary:"bg-accent-secondary",green:"bg-accent-success",red:"bg-accent-danger",yellow:"bg-accent-secondary"},L=[{threshold:30,color:"var(--accent-tertiary)",next:"var(--accent-primary)"},{threshold:50,color:"var(--accent-primary)",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 O(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-primary)"},{pos:r.normal,color:"var(--accent-primary)"},{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":G[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-primary"}:e<65?{text:"Warm",color:"text-accent-secondary"}:e<80?{text:"Hot",color:"text-signal-poor"}:{text:"Danger",color:"text-accent-danger"}}(e),c=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:O(l,a,r),width:`${l}%`}}),t.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:L.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 $({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 A({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 W=e.memo(function({data:e,cpuColor:s,memoryColor:a,chartGridColors:r}){const l=function(e){const t=[],s=Math.max(0,S-e.length),a=Date.now(),r=g.system;for(let n=0;n`${e}%`}),t.jsx(p,{content:t.jsx(A,{})}),t.jsx(u,{content:t.jsx($,{})}),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,p]=e.useState(null),[u,h]=e.useState(!1),v=j(),G=y(),L=b(),O=N(),$=O.primary,A=O.tertiary,P=e.useCallback(async()=>{try{const e=await f();e.success&&e.data?(i(e.data),p(null),G(e.data.cpu.usage_percent,e.data.memory.usage_percent,S)):p(e.error??"Failed to fetch hardware stats")}catch(e){p(e instanceof Error?e.message:"Failed to fetch hardware stats")}},[G]);return e.useEffect(()=>{let e=!0,t=null;if((async()=>{e&&(await P(),e&&m(!1))})(),"undefined"==typeof Worker){const t=setInterval(P,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&&P()}}return()=>{e=!1,null==t||t.terminate()}},[P]),t.jsxs(w,{children:[t.jsx(k,{title:"System Stats",icon:t.jsx(a,{}),controls:t.jsxs("button",{onClick:async()=>{h(!0),await P(),h(!1)},disabled:u,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",u&&"animate-spin")}),"Refresh"]})}),x&&t.jsx(C,{className:"border border-accent-danger/50 bg-accent-danger/10",children:t.jsx("p",{className:"text-accent-danger",children:x})}),d?t.jsx(C,{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(_,{template:"hero",children:t.jsxs(C,{children:[t.jsx(F,{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:A},children:[o.memory.usage_percent.toFixed(0),"%"]})]})]})}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(W,{data:v,cpuColor:$,memoryColor:A,chartGridColors:L})}),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(_,{template:"compact",children:[t.jsx(M,{span:12,md:6,children:t.jsxs(C,{children:[t.jsx(F,{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:"primary"}),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(M,{span:12,md:6,children:t.jsxs(C,{children:[t.jsx(F,{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-CLPRu8Bc.js b/frontend/dist/assets/Terminal-D4B4ypGn.js similarity index 99% rename from frontend/dist/assets/Terminal-CLPRu8Bc.js rename to frontend/dist/assets/Terminal-D4B4ypGn.js index f50cd2ea..c8363f98 100644 --- a/frontend/dist/assets/Terminal-CLPRu8Bc.js +++ b/frontend/dist/assets/Terminal-D4B4ypGn.js @@ -1 +1 @@ -import{c as e,r as a,j as t,S as r}from"./vendor-react-DtVWNgeu.js";import{c as s}from"./recharts-C9LxPobD.js";import{c as n,af as i,ag as o,ah as l,ai as c,aj as m,ak as d}from"./index-BIsccma_.js";import{a as p}from"./ping-SvrcEczO.js";import{P as y,b as u,a as g}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const h=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"]),v=["gps","sensor"],x=[{cmd:"help",desc:"Show available commands"},{cmd:"clear",desc:"Clear terminal screen"},{cmd:"status",desc:"Get repeater status summary"},{cmd:"uptime",desc:"Show system uptime"},{cmd:"packets",desc:"Show packet statistics"},{cmd:"board",desc:"Show board/platform info"},{cmd:"ping",desc:"Ping neighbor (name or 0xXX)",params:"{target} [timeout]",required:!0},...[{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)&&!v.some(a=>e.name.startsWith(a))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],b={"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 w(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 O=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",w(e.outputType||"system")),children:e.content}):e.content.includes("██")?t.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",w(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 i=[{text:` ${s}`,color:`${n} font-semibold`}];r.length>1&&i.push({text:` ${r.slice(1).join(" ")}`,color:"text-accent-primary"});const o=" ".repeat(Math.max(1,22-e.length));return i.push({text:`${o}${a}`,color:"text-text-muted"}),i}if("error"===a||"warning"===a)return[{text:e,color:w(a)}];if("value"===a)return[{text:e,color:w("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:w("success")}]:[{text:e,color:w(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 P(){const e=n(),f=h(e=>e.entries),v=h(e=>e.commandHistory),w=h(e=>e.isInitialized),{addEntry:P,updateEntry:k,addCommand:S,clearEntries:$,setInitialized:_}=h(),[N,E]=a.useState(""),[j,G]=a.useState(-1),[T,C]=a.useState(!1),[F,I]=a.useState([]),[W,D]=a.useState(0),[L,R]=a.useState(0),[q,M]=a.useState(!1),X=a.useRef(null),A=a.useRef(null),H=a.useRef(null);a.useEffect(()=>{w||(async()=>{P({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=P({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),k(e,{content:"✓ Initializing terminal...",outputType:"success"});const a=P({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),k(a,{content:"✓ Connected to repeater",outputType:"success"}),P({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),_(!0)})()},[w,P,k,_]),a.useEffect(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[f]);const K=a.useCallback(()=>{var e;null==(e=X.current)||e.focus()},[]),z=a.useMemo(()=>(null==e?void 0:e.neighbors)?Object.values(e.neighbors).map(e=>e.node_name||e.name).filter(e=>!!e).sort():[],[null==e?void 0:e.neighbors]),U=a.useCallback(e=>{const a=e.trim().toLowerCase();if(!a)return C(!1),void I([]);const t=x.filter(e=>e.cmd.toLowerCase().startsWith(a));if(t.length>0)return I(t),D(0),void C(!0);if(a.includes(" ")){const e=a.lastIndexOf(" "),t=a.substring(0,e),r=a.substring(e+1);if("ping"===t&&z.length>0){const e=z.filter(e=>e.toLowerCase().startsWith(r)).slice(0,10).map(e=>({cmd:`ping ${e}`,desc:`→ ${e}`}));if(e.length>0)return I(e),D(0),void C(!0)}const s=x.find(e=>e.cmd.toLowerCase()===t);if(s&&b[s.cmd]){const e=b[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return I(e),D(0),void C(!0)}}C(!1),I([])},[z]),B=a.useCallback(e=>{var a;const t=F[e];t&&(t.required&&t.params?(E(t.cmd+" "),U(t.cmd+" ")):(E(t.cmd),C(!1)),null==(a=X.current)||a.focus())},[F,U]),V=a.useCallback(async e=>{var a,t,r,s,n,y,u,g,h;const f=e.trim();if(!f)return;const v=f.toLowerCase();if(S(f),P({type:"command",content:f}),"clear"===v)return void $();if("help"===v){const e=x.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void P({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const b=P({type:"output",content:"processing...",outputType:"system"});try{const e=await i();let x="",O="info";const P=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"===v){x=`Mode: ${(null==(t=null==(a=e.config)?void 0:a.repeater)?void 0:t.mode)||"unknown"} | Neighbors: ${Object.keys(e.neighbors||{}).length} | Uptime: ${P(e.uptime_seconds||0)}`}else if("uptime"===v)x=P(e.uptime_seconds||0),O="value";else if("packets"===v)x=`rx: ${e.rx_count??0}\ntx: ${e.tx_count??0}\nfwd: ${e.forwarded_count??0}\ndrop: ${e.dropped_count??0}`;else if("neighbors"===v){const a=e.neighbors||{},t=Object.entries(a);if(0===t.length)x="No neighbors discovered yet.",O="warning";else{const e=t.map(([e,a])=>{const t=a.name||a.node_name||"Unknown";return` ${e.slice(0,8)} ${t}`});x=`Neighbors (${t.length}):\n${e.join("\n")}`}}else if("board"===v)x="pyMC_Repeater (Linux/RPi)",O="value";else if(v.startsWith("get ")){const a=v.slice(4).trim(),t=null==(r=e.config)?void 0:r.delays,i=null==(s=e.config)?void 0:s.radio,o=null==(n=e.config)?void 0:n.repeater,l=null==(y=e.config)?void 0:y.duty_cycle;switch(a){case"name":x=(null==(u=e.config)?void 0:u.node_name)||"Unknown";break;case"role":x="repeater";break;case"lat":x=null!=(null==o?void 0:o.latitude)?String(o.latitude):"not set";break;case"lon":x=null!=(null==o?void 0:o.longitude)?String(o.longitude):"not set";break;case"freq":x=(null==i?void 0:i.frequency)?(i.frequency/1e6).toFixed(3):"?";break;case"tx":x=String((null==i?void 0:i.tx_power)??"?");break;case"bw":x=(null==i?void 0:i.bandwidth)?String(i.bandwidth/1e3):"?";break;case"sf":x=String((null==i?void 0:i.spreading_factor)??"?");break;case"cr":x=String((null==i?void 0:i.coding_rate)??"?");break;case"radio":x=i?`freq: ${(i.frequency/1e6).toFixed(3)} MHz\nbw: ${i.bandwidth/1e3} kHz\nsf: ${i.spreading_factor}\ncr: 4/${i.coding_rate}`:"?";break;case"af":case"txdelay":x=String((null==t?void 0:t.tx_delay_factor)??"1.0");break;case"direct.txdelay":x=String((null==t?void 0:t.direct_tx_delay_factor)??"0.5");break;case"mode":x=(null==o?void 0:o.mode)||"forward";break;case"repeat":x="forward"===(null==o?void 0:o.mode)?"on":"off";break;case"flood.max":x=String((null==o?void 0:o.max_flood_hops)??"3");break;case"flood.advert.interval":x=null!=(null==o?void 0:o.send_advert_interval_hours)?`${o.send_advert_interval_hours}h`:"?";break;case"advert.interval":x=null!=(null==o?void 0:o.advert_interval_minutes)?`${o.advert_interval_minutes}m`:"120m";break;case"rxdelay":x=String((null==t?void 0:t.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":x=(null==l?void 0:l.enforcement_enabled)?"on":"off";break;case"duty.max":x=null!=(null==l?void 0:l.max_airtime_percent)?`${l.max_airtime_percent}%`:"?";break;case"public.key":x=e.public_key||"not available";break;case"prv.key":x="Private keys not available via CLI.\nUse /api/identities endpoint or config.yaml",O="warning";break;case"guest.password":case"allow.read.only":x="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",O="warning";break;default:x=`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`,O="error"}"error"!==O&&(O="value")}else if("advert"===v){const e=await o();x=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,O=e.success?"success":"error"}else if(v.startsWith("set mode ")){const e=v.split(" ")[2];if("forward"!==e&&"monitor"!==e)x='Error: Mode must be "forward" or "monitor"',O="error";else{const a=await l(e);x=a.success?`OK - Mode set to ${e}`:"Error: Failed",O=a.success?"success":"error"}}else if(v.startsWith("set duty ")){const e=v.split(" ")[2],a="on"===e||"1"===e,t=await c(a);x=t.success?"OK - Duty cycle "+(a?"enabled":"disabled"):"Error: Failed",O=t.success?"success":"error"}else if(v.startsWith("set tx ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||e<2||e>22)x="Error: TX power must be 2-22 dBm (SX1262 chip max)",O="error";else{const a=await m({tx_power:e});x=a.success?`OK - TX power set to ${e}dBm`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set af ")||v.startsWith("set txdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0||e>5)x="Error: TX delay factor must be 0.0-5.0",O="error";else{const a=await m({tx_delay_factor:e});x=a.success?`OK - TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set direct.txdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0||e>5)x="Error: Direct TX delay must be 0.0-5.0",O="error";else{const a=await m({direct_tx_delay_factor:e});x=a.success?`OK - Direct TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set log ")){const e=null==(g=v.split(" ")[2])?void 0:g.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const a=await d(e);x=a.success?`OK - Log level set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}else x="Error: Level must be debug, info, warning, or error",O="error"}else if(v.startsWith("set rxdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0)x="Error: RX delay must be >= 0",O="error";else{const a=await m({rx_delay_base:e});x=a.success?`OK - RX delay base set to ${e}s`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set name ")){const e=f.substring(9).trim();if(e){const a=await m({node_name:e});x=a.success?`OK - Node name set to "${e}"`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}else x="Error: Node name cannot be empty",O="error"}else if(v.startsWith("set lat ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<-90||e>90)x="Error: Latitude must be -90 to 90",O="error";else{const a=await m({latitude:e});x=a.success?`OK - Latitude set to ${e}°`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set lon ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<-180||e>180)x="Error: Longitude must be -180 to 180",O="error";else{const a=await m({longitude:e});x=a.success?`OK - Longitude set to ${e}°`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set flood.max ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||e<0||e>64)x="Error: Max flood hops must be 0-64",O="error";else{const a=await m({max_flood_hops:e});x=a.success?`OK - Max flood hops set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set flood.advert.interval ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))x="Error: Flood advert interval must be 0 (off) or 3-48 hours",O="error";else{const a=await m({flood_advert_interval_hours:e});x=a.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set advert.interval ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))x="Error: Advert interval must be 0 (off) or 1-10080 minutes",O="error";else{const a=await m({advert_interval_minutes:e});x=a.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("ping ")){const e=f.substring(5).trim(),a=e.split(/\s+/),t=a[a.length-1],r=parseInt(t),s=a.length>1&&!isNaN(r)&&r>0,n=s?a.slice(0,-1).join(" "):e,i=s?r:30;if(n){let e=1;const a=setInterval(()=>{e=e%3+1,k(b,{content:`Pinging ${n}${".".repeat(e)}`,outputType:"system"})},800);try{const e=await p(n,i);if(clearInterval(a),e.success&&e.data){const a=e.data,t=(null==(h=a.path)?void 0:h.length)?a.path.join(" → "):"direct";x=`Reply from ${a.target_id}\n RTT: ${a.rtt_ms.toFixed(1)}ms\n RSSI: ${a.rssi}dBm\n SNR: ${a.snr_db}dB\n Path: ${t}\n Quality: ${a.quality}`,O="success"}else x=e.error||"Ping failed",O="error"}catch(w){throw clearInterval(a),w}}else x="Usage: ping [timeout]",O="error"}else x=`Unknown command: ${f}\nType 'help' for available commands.`,O="error";k(b,{content:x,outputType:O})}catch(O){k(b,{content:`Error: ${O instanceof Error?O.message:"Command failed"}`,outputType:"error"})}},[P,S,k,$]),Q=a.useCallback(e=>{var a,t,r,s,n,i;if(T&&F.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(W+1,F.length-1);return D(s),void(null==(r=null==(t=null==(a=H.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(W-1,0);return D(a),void(null==(i=null==(n=null==(s=H.current)?void 0:s.children[0])?void 0:n.children[a])||i.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void B(W);if("Escape"===e.key)return e.preventDefault(),void C(!1)}if("Enter"===e.key){if(e.preventDefault(),T&&F.length>0){const e=F[W].cmd;return E(""),G(-1),C(!1),void V(e)}const a=N;return E(""),G(-1),C(!1),void V(a)}if("ArrowUp"!==e.key||T)if("ArrowDown"!==e.key||T);else if(e.preventDefault(),j>0){const e=j-1;G(e),E(v[v.length-1-e]||"")}else 0===j&&(G(-1),E(""));else if(e.preventDefault(),v.length>0&&j{E(e.target.value),R(e.target.selectionStart||e.target.value.length),U(e.target.value)},[U]),Y=a.useCallback(e=>{const a=e.target;R(a.selectionStart||0)},[]);return t.jsxs(y,{children:[t.jsx(u,{title:"Terminal",icon:t.jsx(r,{})}),t.jsxs(g,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:K,children:[t.jsx("div",{ref:A,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(O,{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:X,type:"text",value:N,onChange:J,onKeyDown:Q,onSelect:Y,onFocus:()=>M(!0),onBlur:()=>M(!1),disabled:!w,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:w?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-text-primary",children:N.slice(0,L)}),t.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",q?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:t.jsx("span",{className:"text-bg-primary",children:N[L]||""})}),t.jsx("span",{className:"text-text-primary",children:N.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]})]})]}),T&&F.length>0&&t.jsxs("div",{ref:H,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:F.map((e,a)=>t.jsxs("div",{onClick:()=>B(a),className:s("px-4 py-2.5 cursor-pointer border-b border-white/10 last:border-b-0 transition-colors",a===W?"bg-accent-primary/25":"hover:bg-white/10"),children:[t.jsx("span",{className:s("font-mono text-sm",a===W?"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{P as default}; +import{c as e,r as a,j as t,S as r}from"./vendor-react-DtVWNgeu.js";import{c as s}from"./recharts-C9LxPobD.js";import{c as n,af as i,ag as o,ah as l,ai as c,aj as m,ak as d}from"./index-Bmit1I8S.js";import{a as p}from"./ping-BBb1dLdC.js";import{P as y,b as u,a as g}from"./PageLayout-CG02PCA-.js";import"./vendor-core-WoOfkQwm.js";import"./deckgl-DTsmDcfs.js";const h=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"]),v=["gps","sensor"],x=[{cmd:"help",desc:"Show available commands"},{cmd:"clear",desc:"Clear terminal screen"},{cmd:"status",desc:"Get repeater status summary"},{cmd:"uptime",desc:"Show system uptime"},{cmd:"packets",desc:"Show packet statistics"},{cmd:"board",desc:"Show board/platform info"},{cmd:"ping",desc:"Ping neighbor (name or 0xXX)",params:"{target} [timeout]",required:!0},...[{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)&&!v.some(a=>e.name.startsWith(a))).map(e=>({cmd:e.name,desc:e.description,params:e.hasParam?"{value}":void 0,required:e.hasParam}))],b={"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 w(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 O=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",w(e.outputType||"system")),children:e.content}):e.content.includes("██")?t.jsx("pre",{className:s("terminal-ascii font-mono leading-none py-2 whitespace-pre",w(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 i=[{text:` ${s}`,color:`${n} font-semibold`}];r.length>1&&i.push({text:` ${r.slice(1).join(" ")}`,color:"text-accent-primary"});const o=" ".repeat(Math.max(1,22-e.length));return i.push({text:`${o}${a}`,color:"text-text-muted"}),i}if("error"===a||"warning"===a)return[{text:e,color:w(a)}];if("value"===a)return[{text:e,color:w("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:w("success")}]:[{text:e,color:w(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 P(){const e=n(),f=h(e=>e.entries),v=h(e=>e.commandHistory),w=h(e=>e.isInitialized),{addEntry:P,updateEntry:k,addCommand:S,clearEntries:$,setInitialized:_}=h(),[N,E]=a.useState(""),[j,G]=a.useState(-1),[T,C]=a.useState(!1),[F,I]=a.useState([]),[W,D]=a.useState(0),[L,R]=a.useState(0),[q,M]=a.useState(!1),X=a.useRef(null),A=a.useRef(null),H=a.useRef(null);a.useEffect(()=>{w||(async()=>{P({type:"output",content:"██████ ██ ██ ███ ███ ██████\n██ ██ ██ ██ ████ ████ ██ \n██████ ████ ██ ████ ██ ██ \n██ ██ ██ ██ ██ ██ \n██ ██ ██ ██ ██████",outputType:"value"}),await new Promise(e=>setTimeout(e,200));const e=P({type:"system",content:"● Initializing terminal...",outputType:"system"});await new Promise(e=>setTimeout(e,400)),k(e,{content:"✓ Initializing terminal...",outputType:"success"});const a=P({type:"system",content:"● Connecting to repeater...",outputType:"system"});await new Promise(e=>setTimeout(e,600)),k(a,{content:"✓ Connected to repeater",outputType:"success"}),P({type:"system",content:"Ready. Type 'help' for commands.",outputType:"system"}),_(!0)})()},[w,P,k,_]),a.useEffect(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[f]);const K=a.useCallback(()=>{var e;null==(e=X.current)||e.focus()},[]),z=a.useMemo(()=>(null==e?void 0:e.neighbors)?Object.values(e.neighbors).map(e=>e.node_name||e.name).filter(e=>!!e).sort():[],[null==e?void 0:e.neighbors]),U=a.useCallback(e=>{const a=e.trim().toLowerCase();if(!a)return C(!1),void I([]);const t=x.filter(e=>e.cmd.toLowerCase().startsWith(a));if(t.length>0)return I(t),D(0),void C(!0);if(a.includes(" ")){const e=a.lastIndexOf(" "),t=a.substring(0,e),r=a.substring(e+1);if("ping"===t&&z.length>0){const e=z.filter(e=>e.toLowerCase().startsWith(r)).slice(0,10).map(e=>({cmd:`ping ${e}`,desc:`→ ${e}`}));if(e.length>0)return I(e),D(0),void C(!0)}const s=x.find(e=>e.cmd.toLowerCase()===t);if(s&&b[s.cmd]){const e=b[s.cmd].filter(e=>e.toLowerCase().startsWith(r)).map(e=>({cmd:`${s.cmd} ${e}`,desc:`→ ${e}`}));if(e.length>0)return I(e),D(0),void C(!0)}}C(!1),I([])},[z]),B=a.useCallback(e=>{var a;const t=F[e];t&&(t.required&&t.params?(E(t.cmd+" "),U(t.cmd+" ")):(E(t.cmd),C(!1)),null==(a=X.current)||a.focus())},[F,U]),V=a.useCallback(async e=>{var a,t,r,s,n,y,u,g,h;const f=e.trim();if(!f)return;const v=f.toLowerCase();if(S(f),P({type:"command",content:f}),"clear"===v)return void $();if("help"===v){const e=x.map(e=>`${e.cmd}:::${e.desc}`).join("\n");return void P({type:"output",content:`HELP_HEADER:::Available commands\n${e}\nHELP_NOTE:::Some MeshCore commands not available via HTTP.`,outputType:"default"})}const b=P({type:"output",content:"processing...",outputType:"system"});try{const e=await i();let x="",O="info";const P=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"===v){x=`Mode: ${(null==(t=null==(a=e.config)?void 0:a.repeater)?void 0:t.mode)||"unknown"} | Neighbors: ${Object.keys(e.neighbors||{}).length} | Uptime: ${P(e.uptime_seconds||0)}`}else if("uptime"===v)x=P(e.uptime_seconds||0),O="value";else if("packets"===v)x=`rx: ${e.rx_count??0}\ntx: ${e.tx_count??0}\nfwd: ${e.forwarded_count??0}\ndrop: ${e.dropped_count??0}`;else if("neighbors"===v){const a=e.neighbors||{},t=Object.entries(a);if(0===t.length)x="No neighbors discovered yet.",O="warning";else{const e=t.map(([e,a])=>{const t=a.name||a.node_name||"Unknown";return` ${e.slice(0,8)} ${t}`});x=`Neighbors (${t.length}):\n${e.join("\n")}`}}else if("board"===v)x="pyMC_Repeater (Linux/RPi)",O="value";else if(v.startsWith("get ")){const a=v.slice(4).trim(),t=null==(r=e.config)?void 0:r.delays,i=null==(s=e.config)?void 0:s.radio,o=null==(n=e.config)?void 0:n.repeater,l=null==(y=e.config)?void 0:y.duty_cycle;switch(a){case"name":x=(null==(u=e.config)?void 0:u.node_name)||"Unknown";break;case"role":x="repeater";break;case"lat":x=null!=(null==o?void 0:o.latitude)?String(o.latitude):"not set";break;case"lon":x=null!=(null==o?void 0:o.longitude)?String(o.longitude):"not set";break;case"freq":x=(null==i?void 0:i.frequency)?(i.frequency/1e6).toFixed(3):"?";break;case"tx":x=String((null==i?void 0:i.tx_power)??"?");break;case"bw":x=(null==i?void 0:i.bandwidth)?String(i.bandwidth/1e3):"?";break;case"sf":x=String((null==i?void 0:i.spreading_factor)??"?");break;case"cr":x=String((null==i?void 0:i.coding_rate)??"?");break;case"radio":x=i?`freq: ${(i.frequency/1e6).toFixed(3)} MHz\nbw: ${i.bandwidth/1e3} kHz\nsf: ${i.spreading_factor}\ncr: 4/${i.coding_rate}`:"?";break;case"af":case"txdelay":x=String((null==t?void 0:t.tx_delay_factor)??"1.0");break;case"direct.txdelay":x=String((null==t?void 0:t.direct_tx_delay_factor)??"0.5");break;case"mode":x=(null==o?void 0:o.mode)||"forward";break;case"repeat":x="forward"===(null==o?void 0:o.mode)?"on":"off";break;case"flood.max":x=String((null==o?void 0:o.max_flood_hops)??"3");break;case"flood.advert.interval":x=null!=(null==o?void 0:o.send_advert_interval_hours)?`${o.send_advert_interval_hours}h`:"?";break;case"advert.interval":x=null!=(null==o?void 0:o.advert_interval_minutes)?`${o.advert_interval_minutes}m`:"120m";break;case"rxdelay":x=String((null==t?void 0:t.rx_delay_base)??"0.0");break;case"duty":case"duty.enabled":x=(null==l?void 0:l.enforcement_enabled)?"on":"off";break;case"duty.max":x=null!=(null==l?void 0:l.max_airtime_percent)?`${l.max_airtime_percent}%`:"?";break;case"public.key":x=e.public_key||"not available";break;case"prv.key":x="Private keys not available via CLI.\nUse /api/identities endpoint or config.yaml",O="warning";break;case"guest.password":case"allow.read.only":x="Security settings not exposed via stats API.\nCheck /etc/pymc_repeater/config.yaml",O="warning";break;default:x=`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`,O="error"}"error"!==O&&(O="value")}else if("advert"===v){const e=await o();x=e.success?"OK - Advert sent":`Error: ${e.error||"Failed"}`,O=e.success?"success":"error"}else if(v.startsWith("set mode ")){const e=v.split(" ")[2];if("forward"!==e&&"monitor"!==e)x='Error: Mode must be "forward" or "monitor"',O="error";else{const a=await l(e);x=a.success?`OK - Mode set to ${e}`:"Error: Failed",O=a.success?"success":"error"}}else if(v.startsWith("set duty ")){const e=v.split(" ")[2],a="on"===e||"1"===e,t=await c(a);x=t.success?"OK - Duty cycle "+(a?"enabled":"disabled"):"Error: Failed",O=t.success?"success":"error"}else if(v.startsWith("set tx ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||e<2||e>22)x="Error: TX power must be 2-22 dBm (SX1262 chip max)",O="error";else{const a=await m({tx_power:e});x=a.success?`OK - TX power set to ${e}dBm`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set af ")||v.startsWith("set txdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0||e>5)x="Error: TX delay factor must be 0.0-5.0",O="error";else{const a=await m({tx_delay_factor:e});x=a.success?`OK - TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set direct.txdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0||e>5)x="Error: Direct TX delay must be 0.0-5.0",O="error";else{const a=await m({direct_tx_delay_factor:e});x=a.success?`OK - Direct TX delay set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set log ")){const e=null==(g=v.split(" ")[2])?void 0:g.toUpperCase();if(["DEBUG","INFO","WARNING","ERROR"].includes(e)){const a=await d(e);x=a.success?`OK - Log level set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}else x="Error: Level must be debug, info, warning, or error",O="error"}else if(v.startsWith("set rxdelay ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<0)x="Error: RX delay must be >= 0",O="error";else{const a=await m({rx_delay_base:e});x=a.success?`OK - RX delay base set to ${e}s`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set name ")){const e=f.substring(9).trim();if(e){const a=await m({node_name:e});x=a.success?`OK - Node name set to "${e}"`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}else x="Error: Node name cannot be empty",O="error"}else if(v.startsWith("set lat ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<-90||e>90)x="Error: Latitude must be -90 to 90",O="error";else{const a=await m({latitude:e});x=a.success?`OK - Latitude set to ${e}°`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set lon ")){const e=parseFloat(v.split(" ")[2]);if(isNaN(e)||e<-180||e>180)x="Error: Longitude must be -180 to 180",O="error";else{const a=await m({longitude:e});x=a.success?`OK - Longitude set to ${e}°`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set flood.max ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||e<0||e>64)x="Error: Max flood hops must be 0-64",O="error";else{const a=await m({max_flood_hops:e});x=a.success?`OK - Max flood hops set to ${e}`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set flood.advert.interval ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||0!==e&&(e<3||e>48))x="Error: Flood advert interval must be 0 (off) or 3-48 hours",O="error";else{const a=await m({flood_advert_interval_hours:e});x=a.success?0===e?"OK - Flood adverts disabled":`OK - Flood advert interval set to ${e}h`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("set advert.interval ")){const e=parseInt(v.split(" ")[2]);if(isNaN(e)||0!==e&&(e<1||e>10080))x="Error: Advert interval must be 0 (off) or 1-10080 minutes",O="error";else{const a=await m({advert_interval_minutes:e});x=a.success?0===e?"OK - Local adverts disabled":`OK - Local advert interval set to ${e}m`:`Error: ${a.error||"Failed"}`,O=a.success?"success":"error"}}else if(v.startsWith("ping ")){const e=f.substring(5).trim(),a=e.split(/\s+/),t=a[a.length-1],r=parseInt(t),s=a.length>1&&!isNaN(r)&&r>0,n=s?a.slice(0,-1).join(" "):e,i=s?r:30;if(n){let e=1;const a=setInterval(()=>{e=e%3+1,k(b,{content:`Pinging ${n}${".".repeat(e)}`,outputType:"system"})},800);try{const e=await p(n,i);if(clearInterval(a),e.success&&e.data){const a=e.data,t=(null==(h=a.path)?void 0:h.length)?a.path.join(" → "):"direct";x=`Reply from ${a.target_id}\n RTT: ${a.rtt_ms.toFixed(1)}ms\n RSSI: ${a.rssi}dBm\n SNR: ${a.snr_db}dB\n Path: ${t}\n Quality: ${a.quality}`,O="success"}else x=e.error||"Ping failed",O="error"}catch(w){throw clearInterval(a),w}}else x="Usage: ping [timeout]",O="error"}else x=`Unknown command: ${f}\nType 'help' for available commands.`,O="error";k(b,{content:x,outputType:O})}catch(O){k(b,{content:`Error: ${O instanceof Error?O.message:"Command failed"}`,outputType:"error"})}},[P,S,k,$]),Q=a.useCallback(e=>{var a,t,r,s,n,i;if(T&&F.length>0){if("ArrowDown"===e.key){e.preventDefault();const s=Math.min(W+1,F.length-1);return D(s),void(null==(r=null==(t=null==(a=H.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(W-1,0);return D(a),void(null==(i=null==(n=null==(s=H.current)?void 0:s.children[0])?void 0:n.children[a])||i.scrollIntoView({block:"nearest"}))}if("Tab"===e.key)return e.preventDefault(),void B(W);if("Escape"===e.key)return e.preventDefault(),void C(!1)}if("Enter"===e.key){if(e.preventDefault(),T&&F.length>0){const e=F[W].cmd;return E(""),G(-1),C(!1),void V(e)}const a=N;return E(""),G(-1),C(!1),void V(a)}if("ArrowUp"!==e.key||T)if("ArrowDown"!==e.key||T);else if(e.preventDefault(),j>0){const e=j-1;G(e),E(v[v.length-1-e]||"")}else 0===j&&(G(-1),E(""));else if(e.preventDefault(),v.length>0&&j{E(e.target.value),R(e.target.selectionStart||e.target.value.length),U(e.target.value)},[U]),Y=a.useCallback(e=>{const a=e.target;R(a.selectionStart||0)},[]);return t.jsxs(y,{children:[t.jsx(u,{title:"Terminal",icon:t.jsx(r,{})}),t.jsxs(g,{noPadding:!0,className:"terminal-card overflow-hidden flex flex-col isolate",onClick:K,children:[t.jsx("div",{ref:A,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(O,{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:X,type:"text",value:N,onChange:J,onKeyDown:Q,onSelect:Y,onFocus:()=>M(!0),onBlur:()=>M(!1),disabled:!w,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:w?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-text-primary",children:N.slice(0,L)}),t.jsx("span",{className:s("inline-block w-[0.6em] h-[1.2em] align-text-bottom",q?"bg-accent-primary":"bg-text-muted/30"),style:{marginBottom:"-0.1em"},children:t.jsx("span",{className:"text-bg-primary",children:N[L]||""})}),t.jsx("span",{className:"text-text-primary",children:N.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]})]})]}),T&&F.length>0&&t.jsxs("div",{ref:H,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:F.map((e,a)=>t.jsxs("div",{onClick:()=>B(a),className:s("px-4 py-2.5 cursor-pointer border-b border-white/10 last:border-b-0 transition-colors",a===W?"bg-accent-primary/25":"hover:bg-white/10"),children:[t.jsx("span",{className:s("font-mono text-sm",a===W?"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{P as default}; diff --git a/frontend/dist/assets/index-BIsccma_.js b/frontend/dist/assets/index-Bmit1I8S.js similarity index 99% rename from frontend/dist/assets/index-BIsccma_.js rename to frontend/dist/assets/index-Bmit1I8S.js index a0c28dab..0bc390b7 100644 --- a/frontend/dist/assets/index-BIsccma_.js +++ b/frontend/dist/assets/index-Bmit1I8S.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-DxQgqPyH.js","assets/vendor-react-DtVWNgeu.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-D0ZyJ9cS.js","assets/useThemeColors-DaJMJYCA.js","assets/PageLayout-CG02PCA-.js","assets/PacketDetailModal-ZVXSkr9b.js","assets/SignalIndicator-DagI_WOB.js","assets/DataBox-Dl3NmnnB.js","assets/useScientificColormap-nDz0kTVE.js","assets/TimeRangeSelector-CzmnykND.js","assets/link-scoring-v5IA77Bo.js","assets/Grid-Cva3lgGW.js","assets/Packets-paAuyZUE.js","assets/Contacts-D7dmBQTJ.js","assets/ping-SvrcEczO.js","assets/CollisionExplorerModal-CZ-TWl8d.js","assets/ConfirmModal-Dq3wq7Fw.js","assets/leaflet-CIGW-MKW.css","assets/Statistics-CjF2BXTB.js","assets/usePolling-DXhhvgB-.js","assets/System-Bl3LqV-u.js","assets/Logs-YP9BpQVI.js","assets/Terminal-CLPRu8Bc.js","assets/Configuration-koaN0oYB.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 r,L as l,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 b,k as x,l as w,m as k,n as v,o as S,p as C,q as T,b as M,t as L,v as _,N as j,w as P,B as E}from"./vendor-react-DtVWNgeu.js";import{_ as N}from"./deckgl-DTsmDcfs.js";import{c as D}from"./recharts-C9LxPobD.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 I={surfaces:{glass:{tint:"#252525",light:"#ffffff",dark:"#000000",reflexLight:.15,reflexDark:.8,blur:6,blurElevated:8,brightness:1,opacity:8,opacityElevated:12},card:{radius:"1.125rem",padding:"1.25rem",paddingCompact:"0.75rem"},sidebar:{tint:"rgba(113, 156, 223, 0.06)",width:"16rem",drawerWidth:"85vw"},modal:{radius:"1.125rem",backdropBlur:"8px",backdropColor:"rgba(0, 0, 0, 0.6)"}},colors:{bg:{body:"#171717",surface:"#252525",elevated:"#333233",subtle:"#3F3F3F"},border:{subtle:"#4B4B4B",strong:"#616161"},text:{primary:"#E1E1E1",secondary:"#BFBFBF",muted:"#727272",inverse:"#171717"},accent:{primary:"#719CDF",secondary:"#DFBC72",tertiary:"#6FBCBD",success:"#719872",danger:"#E12672"},signal:{excellent:"#00FF00",good:"#8CE619",fair:"#FFD900",poor:"#FF8C26",critical:"#FF3333",unknown:"#616161"},status:{success:"#719872",warning:"#DFBC72",danger:"#E12672",info:"#6FBCBD",muted:"#616161"},chart:{c1:"#719CDF",c2:"#0074BE",c3:"#6FBCBD",c4:"#DFBC72",c5:"#719872",c6:"#E12672",c7:"#E17899",c8:"#999ABD",grid:"rgba(255, 255, 255, 0.06)",axis:"rgba(255, 255, 255, 0.4)",cursor:"rgba(255, 255, 255, 0.2)"},metric:{received:"#719872",forwarded:"#0074BE",transmitted:"#DFBC72",dropped:"#E12672"},map:{nodeFill:"#F5F5F0",nodeStroke:"#4A5568",hub:"#8B7BAD",local:"#FBBF24",neighbor:"#FBBF24",mobile:"#F97316",room:"#E17899",edge:"#4B4B4B",edgeHover:"#6FBCBD"}},typography:{font:{title:"'Inter', system-ui, sans-serif",display:"'Inter', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xs:"0.64rem",sm:"0.8rem",base:"1rem",md:"1.125rem",lg:"1.25rem",xl:"1.563rem",xxl:"1.953rem",hero:"3.052rem"},weight:{normal:400,medium:500,semibold:600,bold:700},leading:{tight:1.1,snug:1.25,normal:1.5},tracking:{tight:"-0.02em",normal:"0",wide:"0.05em"}},spacing:{space:{gap:"1.5rem",gapMobile:"0.75rem",page:"1.5rem",pageMobile:"1rem",section:"2rem"},radius:{sm:"0.5rem",md:"0.875rem",lg:"1.125rem",xl:"1.5rem",pill:"9999px"}},motion:{fast:"0.1s",normal:"0.15s",slow:"0.4s",easing:"ease-out"}};function F(e){const t=e.replace("#","");if(6!==t.length&&3!==t.length)return e;let s,n,a;return 3===t.length?(s=parseInt(t[0]+t[0],16)/255,n=parseInt(t[1]+t[1],16)/255,a=parseInt(t[2]+t[2],16)/255):(s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255),`color(display-p3 ${s.toFixed(3)} ${n.toFixed(3)} ${a.toFixed(3)})`}function A(){return"undefined"!=typeof window&&CSS.supports("color","color(display-p3 1 1 1)")}function R(e){return A()?F(e):e}function z(e,t){const s={...e};for(const n of Object.keys(t)){const a=t[n],o=e[n];void 0!==a&&("object"!=typeof a||null===a||Array.isArray(a)||"object"!=typeof o||null===o||Array.isArray(o)?s[n]=a:s[n]=z(o,a))}return s}function B(e){return{meta:e.meta,display:e.display,surfaces:e.surfaces?z(I.surfaces,e.surfaces):I.surfaces,colors:e.colors?z(I.colors,e.colors):I.colors,typography:e.typography?z(I.typography,e.typography):I.typography,spacing:e.spacing?z(I.spacing,e.spacing):I.spacing,motion:e.motion?z(I.motion,e.motion):I.motion}}function O(e){const t=e.replace("#","");return 6===t.length?`${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}`:"255, 255, 255"}function $(e){return{id:e.meta.id,colorScheme:{name:e.meta.name,dataTheme:e.meta.dataTheme,previewColor:e.meta.previewColor},background:{src:e.meta.backgroundImage,suggestedBrightness:e.meta.backgroundBrightness},display:{font:e.display.font,color:e.display.color,size:e.display.size,paletteColors:e.display.palette}}}const W=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#58b99d",backgroundImage:"",backgroundBrightness:100,isDark:!0},display:{font:"'JetBrains Mono', monospace",color:"#58b99d",size:1,palette:[["#58b99d","#4997ec","#60ce41","#e67b2f","#da3529"],["#242627","#818c8d","#925cb1","#5face4","#fcfcfc"]]},typography:{font:{title:"'JetBrains Mono', monospace",display:"'Noto Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},weight:{normal:400,medium:500,semibold:600,bold:700},tracking:{tight:"-0.04em",normal:"0",wide:"0.05em"}},surfaces:{glass:{tint:"#242627",light:"#4997ec",dark:"#000000",reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:95,opacityElevated:98},sidebar:{tint:"rgba(88, 185, 157, 0.04)"},card:{radius:"4px"},modal:{radius:"6px"}},colors:{bg:{body:"#1a1c1d",surface:"#242627",elevated:"#2e3133",subtle:"#383b3d"},border:{subtle:"#383b3d",strong:"#4a4e50"},text:{primary:"#fcfcfc",secondary:"#c8c8c8",muted:"#818c8d",inverse:"#242627"},accent:{primary:"#58b99d",secondary:"#e67b2f",tertiary:"#4997ec",success:"#60ce41",danger:"#da3529"},signal:{excellent:"#60ce41",good:"#67d99f",fair:"#e67b2f",poor:"#b14434",critical:"#da3529",unknown:"#818c8d"},status:{success:"#60ce41",warning:"#e67b2f",danger:"#da3529",info:"#58b99d",muted:"#818c8d"},chart:{c1:"#58b99d",c2:"#4997ec",c3:"#60ce41",c4:"#e67b2f",c5:"#da3529",c6:"#925cb1",c7:"#67d99f",c8:"#818c8d",grid:"rgba(252, 252, 252, 0.06)",axis:"rgba(252, 252, 252, 0.3)",cursor:"rgba(88, 185, 157, 0.2)"},metric:{received:"#58b99d",forwarded:"#4997ec",transmitted:"#e67b2f",dropped:"#da3529"},map:{nodeFill:"#fcfcfc",nodeStroke:"#4a4e50",hub:"#925cb1",local:"#58b99d",neighbor:"#58b99d",mobile:"#e67b2f",room:"#58b99d",edge:"#4a4e50",edgeHover:"#58b99d"}}}),H=W;$(W);const U=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#B39DF3",backgroundImage:"/assets/sand.jpg",backgroundBrightness:80,isDark:!0},display:{font:"'Rubik Mono One', monospace",color:"#4A4A52",size:.8,palette:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]]},typography:{font:{title:"'Rubik Mono One', monospace"}},surfaces:{glass:{tint:"#252525",blur:6,blurElevated:8},sidebar:{tint:"rgba(113, 156, 223, 0.06)"}}}),q=U;$(U);const G=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#fabd2f",backgroundImage:"/assets/magma.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Jacquard 12', serif",color:"#fe8019",size:1.75,palette:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]]},typography:{font:{title:"'Jacquard 12', serif"},size:{xxl:"2.344rem"}},surfaces:{glass:{tint:"#282828"},sidebar:{tint:"rgba(250, 189, 47, 0.06)"}},colors:{accent:{primary:"#fabd2f",secondary:"#fb4934",tertiary:"#8ec07c",success:"#b8bb26",danger:"#fb4934"},signal:{excellent:"#b8bb26",good:"#8ec07c",fair:"#fabd2f",poor:"#fe8019",critical:"#fb4934",unknown:"#928374"},status:{success:"#b8bb26",warning:"#fabd2f",danger:"#fb4934",info:"#83a598",muted:"#928374"},chart:{c1:"#fabd2f",c2:"#fe8019",c3:"#fb4934",c4:"#d3869b",c5:"#b8bb26",c6:"#8ec07c",c7:"#83a598",c8:"#d65d0e",grid:"rgba(251, 241, 199, 0.06)",axis:"rgba(251, 241, 199, 0.4)",cursor:"rgba(251, 241, 199, 0.2)"},metric:{received:"#b8bb26",forwarded:"#83a598",transmitted:"#fabd2f",dropped:"#fb4934"},map:{nodeFill:"#fbf1c7",nodeStroke:"#504945",hub:"#b16286",local:"#fabd2f",neighbor:"#fabd2f",mobile:"#fe8019",room:"#d3869b",edge:"#665c54",edgeHover:"#8ec07c"}}}),J=G;$(G);const Y=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#83a598",backgroundImage:"/assets/water.webp",backgroundBrightness:40,isDark:!0},display:{font:"'Cantora One', sans-serif",color:"#83a598",size:1.25,palette:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]]},typography:{font:{title:"'Cantora One', sans-serif"},size:{xxl:"2.148rem"},weight:{semibold:500}},surfaces:{glass:{tint:"#1e1e1e"},sidebar:{tint:"rgba(131, 165, 152, 0.06)"}},colors:{accent:{primary:"#83a598",secondary:"#a89984",tertiary:"#8ec07c",success:"#8ec07c",danger:"#cc241d"},signal:{excellent:"#8ec07c",good:"#b8bb26",fair:"#d79921",poor:"#fe8019",critical:"#cc241d",unknown:"#7c6f64"},status:{success:"#8ec07c",warning:"#d79921",danger:"#cc241d",info:"#83a598",muted:"#7c6f64"},chart:{c1:"#83a598",c2:"#8ec07c",c3:"#d79921",c4:"#b16286",c5:"#fe8019",c6:"#cc241d",c7:"#a89984",c8:"#7c6f64",grid:"rgba(213, 196, 161, 0.06)",axis:"rgba(213, 196, 161, 0.4)",cursor:"rgba(213, 196, 161, 0.2)"},metric:{received:"#8ec07c",forwarded:"#83a598",transmitted:"#d79921",dropped:"#cc241d"},map:{nodeFill:"#ebdbb2",nodeStroke:"#504945",hub:"#b16286",local:"#d79921",neighbor:"#d79921",mobile:"#fe8019",room:"#b16286",edge:"#504945",edgeHover:"#83a598"}}}),V=Y;$(Y);const K=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#33859d",backgroundImage:"/assets/stars.jpg",backgroundBrightness:100,isDark:!0},display:{font:"'IBM Plex Mono', monospace",color:"#c23127",size:1.25,palette:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]]},typography:{font:{title:"'IBM Plex Mono', monospace"}},surfaces:{glass:{tint:"#0a0e14",blur:1,blurElevated:2},sidebar:{tint:"rgba(51, 133, 157, 0.06)"}},colors:{accent:{primary:"#33859d",secondary:"#edb54b",tertiary:"#26a98b",success:"#26a98b",danger:"#c33027"},signal:{excellent:"#26a98b",good:"#7ec07c",fair:"#edb54b",poor:"#d26939",critical:"#c33027",unknown:"#195465"},status:{success:"#26a98b",warning:"#edb54b",danger:"#c33027",info:"#599caa",muted:"#195465"},chart:{c1:"#33859d",c2:"#edb54b",c3:"#26a98b",c4:"#599caa",c5:"#d26939",c6:"#c33027",c7:"#888ba5",c8:"#195465",grid:"rgba(153, 209, 206, 0.06)",axis:"rgba(153, 209, 206, 0.4)",cursor:"rgba(153, 209, 206, 0.2)"},metric:{received:"#26a98b",forwarded:"#33859d",transmitted:"#edb54b",dropped:"#c33027"},map:{nodeFill:"#edf5f4",nodeStroke:"#195465",hub:"#888ba5",local:"#edb54b",neighbor:"#edb54b",mobile:"#d26939",room:"#888ba5",edge:"#245361",edgeHover:"#26a98b"}}}),X=K;$(K);const Q=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#9ed072",backgroundImage:"/assets/ribbons.webp",backgroundBrightness:75,isDark:!0},display:{font:"'Instrument Serif', serif",color:"#E2E2E3",size:1.4,palette:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]]},typography:{font:{title:"'Instrument Serif', Georgia, serif",display:"'Instrument Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xxl:"3.25rem",xl:"2.5rem",lg:"1.875rem",md:"1.25rem"},weight:{normal:400,medium:500,semibold:600,bold:600}},surfaces:{glass:{tint:"#23212d"},sidebar:{tint:"rgba(158, 208, 114, 0.06)"}},colors:{accent:{primary:"#9ed072",secondary:"#e7c664",tertiary:"#76cce0",success:"#9ed072",danger:"#fc5d7c"},signal:{excellent:"#9ed072",good:"#c5d93d",fair:"#e7c664",poor:"#f39660",critical:"#fc5d7c",unknown:"#7f8490"},status:{success:"#9ed072",warning:"#e7c664",danger:"#fc5d7c",info:"#76cce0",muted:"#7f8490"},chart:{c1:"#9ed072",c2:"#fc5d7c",c3:"#e7c664",c4:"#76cce0",c5:"#b39df3",c6:"#f39660",c7:"#7f8490",c8:"#e2e2e3",grid:"rgba(226, 226, 227, 0.06)",axis:"rgba(226, 226, 227, 0.4)",cursor:"rgba(226, 226, 227, 0.2)"},metric:{received:"#9ed072",forwarded:"#76cce0",transmitted:"#e7c664",dropped:"#fc5d7c"},map:{nodeFill:"#e2e2e3",nodeStroke:"#33353f",hub:"#b39df3",local:"#e7c664",neighbor:"#e7c664",mobile:"#f39660",room:"#fc5d7c",edge:"#444751",edgeHover:"#76cce0"}}}),Z=Q;$(Q);const ee=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#7E9CD8",backgroundImage:"/assets/folds.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Inter', sans-serif",color:"#7E9CD8",size:1.25,palette:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]]},typography:{font:{title:"'Inter', sans-serif"}},surfaces:{glass:{tint:"#1F1F28"},sidebar:{tint:"rgba(126, 156, 216, 0.06)"}},colors:{accent:{primary:"#7E9CD8",secondary:"#E6C384",tertiary:"#7FB4CA",success:"#98BB6C",danger:"#E46876"},signal:{excellent:"#98BB6C",good:"#B8CC5C",fair:"#E6C384",poor:"#FFA066",critical:"#E46876",unknown:"#54546D"},status:{success:"#98BB6C",warning:"#E6C384",danger:"#E46876",info:"#7FB4CA",muted:"#727169"},chart:{c1:"#7E9CD8",c2:"#E6C384",c3:"#98BB6C",c4:"#957FB8",c5:"#7FB4CA",c6:"#E46876",c7:"#FFA066",c8:"#D27E99",grid:"rgba(220, 215, 186, 0.06)",axis:"rgba(220, 215, 186, 0.4)",cursor:"rgba(220, 215, 186, 0.2)"},metric:{received:"#98BB6C",forwarded:"#7E9CD8",transmitted:"#E6C384",dropped:"#E46876"},map:{nodeFill:"#DCD7BA",nodeStroke:"#363646",hub:"#957FB8",local:"#E6C384",neighbor:"#E6C384",mobile:"#FFA066",room:"#D27E99",edge:"#54546D",edgeHover:"#7AA89F"}}}),te=ee;$(ee);const se={"KDE Breeze":H,Magma:J,Folds:te,Ribbon:Z,BLKSAND:q,Waves:V,Stars:X};function ne(e,t){const s=e.toLowerCase();return{...t,meta:{...t.meta,id:s,name:e,dataTheme:s}}}const ae=Object.fromEntries(Object.entries(se).map(([e,t])=>[e,ne(e,t)])),oe=Object.fromEntries(Object.entries(ae).map(([e,t])=>[e,$(t)])),ie=Object.values(ae);function re(e){return ie.find(t=>t.meta.id===e)}new Map(Object.entries(ae));const le=Object.values(oe);new Map(Object.entries(oe));const ce=Object.entries(oe).map(([e,t])=>function(e,t){return{id:e.id,name:e.colorScheme.name,displayName:t,colorScheme:e.id,backgroundImage:e.background.src,paletteColors:e.display.paletteColors,displayFont:e.display.font,displayColor:e.display.color,displaySize:e.display.size}}(t,e)),ue=le.map(function(e){return{id:e.id,name:e.colorScheme.name,dataTheme:e.colorScheme.dataTheme,previewColor:e.colorScheme.previewColor}}),de=le.map(function(e){return{id:e.id,src:e.background.src,suggestedScheme:e.id,suggestedBrightness:e.background.suggestedBrightness}}),he=ae["KDE Breeze"];oe["KDE Breeze"];const fe=he.meta.id,pe=he.meta.backgroundImage,me=he.meta.backgroundBrightness,ge=ue,ye=de,be=ce,xe={colorScheme:fe,backgroundImage:pe,brightness:me},we="pymc-color-scheme",ke="pymc-background-image",ve="pymc-bg-brightness",Se="pymc-background";function Ce(e){(new Image).src=e}const Te={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},Me=[50,100,200,300,400,500,600,700,800,900],Le=["red","orange","yellow","green","aqua","blue","purple"];function _e(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 je(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Pe(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function Ee(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,r=e-.1055613458*a-.0638541728*o,l=e-.0894841775*a-1.291485548*o,c=i*i*i,u=r*r*r,d=l*l*l,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,f=-.0041960863*c-.7034186147*u+1.707614701*d;return[Pe(4.0767416621*c-3.3077115913*u+.2309699292*d),Pe(h),Pe(f)]}function Ne(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=je(e),a=je(t),o=je(s),i=.4122214708*n+.5363325363*a+.0514459929*o,r=.2119034982*n+.6806995451*a+.1073969566*o,l=.0883024619*n+.2817188376*a+.6299787005*o,c=Math.cbrt(i),u=Math.cbrt(r),d=Math.cbrt(l),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 r of Me){const e=Te[r],t=a*(1-.3*Math.abs(e-.5)),[s,n,l]=Ee(e,t,o);i[r]=_e(s,n,l)}return i}function De(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Ie(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const Fe="u-off",Ae="u-label",Re="width",ze="height",Be="top",Oe="bottom",$e="left",We="right",He="#000",Ue=He+"0",qe="mousemove",Ge="mousedown",Je="mouseup",Ye="mouseenter",Ve="mouseleave",Ke="dblclick",Xe="change",Qe="dppxchange",Ze="--",et="undefined"!=typeof window,tt=et?document:null,st=et?window:null,nt=et?navigator:null;let at,ot;function it(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function rt(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function lt(e,t,s){e.style[t]=s+"px"}function ct(e,t,s,n){let a=tt.createElement(e);return null!=t&&it(a,t),null!=s&&s.insertBefore(a,n),a}function ut(e,t){return ct("div",e,t)}const dt=new WeakMap;function ht(e,t,s,n,a){let o="translate("+t+"px,"+s+"px)";o!=dt.get(e)&&(e.style.transform=o,dt.set(e,o),t<0||s<0||t>n||s>a?it(e,Fe):rt(e,Fe))}const ft=new WeakMap;function pt(e,t,s){let n=t+s;n!=ft.get(e)&&(ft.set(e,n),e.style.background=t,e.style.borderColor=s)}const mt=new WeakMap;function gt(e,t,s,n){let a=t+""+s;a!=mt.get(e)&&(mt.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 yt={passive:!0},bt={...yt,capture:!0};function xt(e,t,s,n){t.addEventListener(e,s,n?bt:yt)}function wt(e,t,s,n){t.removeEventListener(e,s,yt)}function kt(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:Ot((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]}}et&&function e(){let t=devicePixelRatio;at!=t&&(at=t,ot&&wt(Xe,ot,e),ot=matchMedia(`(min-resolution: ${at-.001}dppx) and (max-resolution: ${at+.001}dppx)`),xt(Xe,ot,e),st.dispatchEvent(new CustomEvent(Qe)))}();const St=e=>null!=e,Ct=e=>null!=e&&e>0,Tt=vt(St),Mt=vt(Ct);function Lt(e,t,s,n){let a=Gt(e),o=Gt(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let i=10==s?Jt:Yt,r=1==o?Wt:Ot,l=(1==a?Ot:Wt)(i(Bt(e))),c=r(i(Bt(t))),u=qt(s,l),d=qt(s,c);return 10==s&&(l<0&&(u=ds(u,-l)),c<0&&(d=ds(d,-c))),n||2==s?(e=u*a,t=d*o):(e=us(e,u),t=cs(t,d)),[e,t]}function _t(e,t,s,n){let a=Lt(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const jt={mode:3,pad:.1},Pt={pad:0,soft:null,mode:0},Et={min:Pt,max:Pt};function Nt(e,t,s,n){return ks(s)?It(e,t,s):(Pt.pad=s,Pt.soft=n?0:null,Pt.mode=n?3:0,It(e,t,Et))}function Dt(e,t){return null==e?t:e}function It(e,t,s){let n=s.min,a=s.max,o=Dt(n.pad,0),i=Dt(a.pad,0),r=Dt(n.hard,-Kt),l=Dt(a.hard,Kt),c=Dt(n.soft,Kt),u=Dt(a.soft,-Kt),d=Dt(n.mode,0),h=Dt(a.mode,0),f=t-e,p=Jt(f),m=Ut(Bt(e),Bt(t)),g=Jt(m),y=Bt(g-p);(f<1e-24||y>10)&&(f=0,0!=e&&0!=t||(f=1e-24,2==d&&c!=Kt&&(o=0),2==h&&u!=-Kt&&(i=0)));let b=f||m||1e3,x=Jt(b),w=qt(10,Ot(x)),k=ds(us(e-b*(0==f?0==e?.1:1:o),w/10),24),v=e>=c&&(1==d||3==d&&k<=c||2==d&&k>=c)?c:Kt,S=Ut(r,k=v?v:Ht(v,k)),C=ds(cs(t+b*(0==f?0==t?.1:1:i),w/10),24),T=t<=u&&(1==h||3==h&&C>=u||2==h&&C<=u)?u:-Kt,M=Ht(l,C>T&&t<=T?T:Ut(T,C));return S==M&&0==S&&(M=100),[S,M]}const Ft=new Intl.NumberFormat(et?nt.language:"en-US"),At=e=>Ft.format(e),Rt=Math,zt=Rt.PI,Bt=Rt.abs,Ot=Rt.floor,$t=Rt.round,Wt=Rt.ceil,Ht=Rt.min,Ut=Rt.max,qt=Rt.pow,Gt=Rt.sign,Jt=Rt.log10,Yt=Rt.log2,Vt=(e,t=1)=>Rt.asinh(e/t),Kt=1/0;function Xt(e){return 1+(0|Jt((e^e>>31)-(e>>31)))}function Qt(e,t,s){return Ht(Ut(e,t),s)}function Zt(e){return"function"==typeof e}function es(e){return Zt(e)?e:()=>e}const ts=e=>e,ss=(e,t)=>t,ns=e=>null,as=e=>!0,os=(e,t)=>e==t,is=/\.\d*?(?=9{6,}|0{6,})/gm,rs=e=>{if(xs(e)||hs.has(e))return e;const t=`${e}`,s=t.match(is);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${rs(e)}e${s}`}return ds(e,n)};function ls(e,t){return rs(ds(rs(e/t))*t)}function cs(e,t){return rs(Wt(rs(e/t))*t)}function us(e,t){return rs(Ot(rs(e/t))*t)}function ds(e,t=0){if(xs(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return $t(n)/s}const hs=new Map;function fs(e){return((""+e).split(".")[1]||"").length}function ps(e,t,s,n){let a=[],o=n.map(fs);for(let i=t;i=0?0:t)+(i>=o[r]?0:o[r]),u=10==e?l:ds(l,c);a.push(u),hs.set(u,c)}}return a}const ms={},gs=[],ys=[null,null],bs=Array.isArray,xs=Number.isInteger;function ws(e){return"string"==typeof e}function ks(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function vs(e){return null!=e&&"object"==typeof e}const Ss=Object.getPrototypeOf(Uint8Array),Cs="__proto__";function Ts(e,t=ks){let s;if(bs(e)){let n=e.find(e=>null!=e);if(bs(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,js=["January","February","March","April","May","June","July","August","September","October","November","December"],Ps=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Es(e){return e.slice(0,3)}const Ns=Ps.map(Es),Ds=js.map(Es),Is={MMMM:js,MMM:Ds,WWWW:Ps,WWW:Ns};function Fs(e){return(e<10?"0":"")+e}const As={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=>Fs(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Fs(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>Fs(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=>Fs(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Fs(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function Rs(e,t){t=t||Is;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?As[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,Os=[1,2,2.5,5],$s=ps(10,-32,0,Os),Ws=ps(10,0,32,Os),Hs=Ws.filter(Bs),Us=$s.concat(Ws),qs="{YYYY}",Gs="\n"+qs,Js="{M}/{D}",Ys="\n"+Js,Vs=Ys+"/{YY}",Ks="{aa}",Xs="{h}:{mm}"+Ks,Qs="\n"+Xs,Zs=":{ss}",en=null;function tn(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,o=30*a,i=365*a;return[(1==e?ps(10,0,3,Os).filter(Bs):ps(10,-3,0,Os)).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,qs,en,en,en,en,en,en,1],[28*a,"{MMM}",Gs,en,en,en,en,en,1],[a,Js,Gs,en,en,en,en,en,1],[n,"{h}"+Ks,Vs,en,Ys,en,en,en,1],[s,Xs,Vs,en,Ys,en,en,en,1],[t,Zs,Vs+" "+Xs,en,Ys+" "+Xs,en,Qs,en,1],[e,Zs+".{fff}",Vs+" "+Xs,en,Ys+" "+Xs,en,Qs,en,1]],function(t){return(r,l,c,u,d,h)=>{let f=[],p=d>=i,m=d>=o&&d=a?a:d,i=x+(Ot(c)-Ot(y))+cs(y-x,o);f.push(i);let p=t(i),m=p.getHours()+p.getMinutes()/s+p.getSeconds()/n,g=d/n,b=h/r.axes[l]._space;for(;i=ds(i+d,1==e?0:3),!(i>u);)if(g>1){let e=Ot(ds(m+g,6))%24,s=t(i).getHours()-e;s>1&&(s=-1),i-=s*n,m=(m+g)%24,ds((i-f[f.length-1])/d,3)*b>=.7&&f.push(i)}else f.push(i)}return f}}]}const[sn,nn,an]=tn(1),[on,rn,ln]=tn(.001);function cn(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 un(e,t){return(s,n,a,o,i)=>{let r,l,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!=r&&f[2]||a!=l&&f[3]||o!=c&&f[4]||i!=u&&f[5]||p!=d&&f[6]||m!=h&&f[7]||f[1];return r=n,l=a,c=o,u=i,d=p,h=m,g(s)})}}function dn(e,t,s){return new Date(e,t,s)}function hn(e,t){return t(e)}function fn(e,t){return(s,n,a,o)=>null==o?Ze:t(e(n))}ps(2,-53,53,[1]);const pn={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:[]},mn=[0,0];function gn(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function yn(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const bn={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return mn[0]=t,mn[1]=s,mn},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=ut(),a=s.size(e,t);lt(n,Re,a),lt(n,ze,a);let o=a/-2;lt(n,"marginLeft",o),lt(n,"marginTop",o);let i=s.width(e,t,a);return i&<(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:gn,mouseup:gn,click:gn,dblclick:gn,mousemove:yn,mouseleave:yn,mouseenter:yn},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},xn={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},wn=Ms({},xn,{filter:ss}),kn=Ms({},wn,{size:10}),vn=Ms({},xn,{show:!1}),Sn='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"',Cn="bold "+Sn,Tn={show:!0,scale:"x",stroke:He,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Cn,side:2,grid:wn,ticks:kn,border:vn,font:Sn,lineGap:1.5,rotate:0},Mn={show:!0,scale:"x",auto:!1,sorted:1,min:Kt,max:-Kt,idxs:[]};function Ln(e,t,s,n,a){return t.map(e=>null==e?"":At(e))}function _n(e,t,s,n,a,o,i){let r=[],l=hs.get(a)||0;for(let c=s=i?s:ds(cs(s,a),l);c<=n;c=ds(c+a,l))r.push(Object.is(c,-0)?0:c);return r}function jn(e,t,s,n,a,o,i){const r=[],l=e.scales[e.axes[t].scale].log,c=Ot((10==l?Jt:Yt)(s));a=qt(l,c),10==l&&(a=Us[kt(a,Us)]);let u=s,d=a*l;10==l&&(d=Us[kt(d,Us)]);do{r.push(u),u+=a,10!=l||hs.has(u)||(u=ds(u,hs.get(a))),u>=d&&(d=(a=u)*l,10==l&&(d=Us[kt(d,Us)]))}while(u<=n);return r}function Pn(e,t,s,n,a,o,i){let r=e.scales[e.axes[t].scale].asinh,l=n>r?jn(e,t,Ut(r,s),n,a):[r],c=n>=0&&s<=0?[0]:[];return(s<-r?jn(e,t,Ut(r,-n),-s,a):[r]).reverse().map(e=>-e).concat(c,l)}const En=/./,Nn=/[12357]/,Dn=/[125]/,In=/1/,Fn=(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 An(e,t,s,n,a){let o=e.axes[s],i=o.scale,r=e.scales[i],l=e.valToPos,c=o._space,u=l(10,i),d=l(9,i)-u>=c?En:l(7,i)-u>=c?Nn:l(5,i)-u>=c?Dn:In;if(d==In){let e=Bt(l(1,i)-u);if(ea,Wn={show:!0,auto:!0,sorted:0,gaps:$n,alpha:1,facets:[Ms({},On,{scale:"x"}),Ms({},On,{scale:"y"})]},Hn={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:$n,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),r=Bt(i-o)/(e.series[t].points.space*at);return n[1]-n[0]<=r},filter:null},values:null,min:Kt,max:-Kt,idxs:[],path:null,clip:null};function Un(e,t,s,n,a){return s/10}const qn={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},Gn=Ms({},qn,{time:!1,ori:1}),Jn={};function Yn(e,t){let s=Jn[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,r){for(let l=0;l{let m=e.pxRound;const g=r.dir*(0==r.ori?1:-1),y=0==r.ori?oa:ia;let b,x;1==g?(b=s,x=n):(b=n,x=s);let w=m(c(t[b],r,f,d)),k=m(u(i[b],l,p,h)),v=m(c(t[x],r,f,d)),S=m(u(1==o?l.max:l.min,l,p,h)),C=new Path2D(a);return y(C,v,S),y(C,w,S),y(C,w,k),C})}function Zn(e,t,s,n,a,o){let i=null;if(e.length>0){i=new Path2D;const r=0==t?ra:la;let l=s;for(let t=0;ts[0]){let e=s[0]-l;e>0&&r(i,l,n,e,n+o),l=s[1]}}let c=s+a-l,u=10;c>0&&r(i,l,n-u/2,c,n+o+u)}return i}function ea(e,t,s,n,a,o,i){let r=[],l=e.length;for(let c=1==a?s:n;c>=s&&c<=n;c+=a)if(null===t[c]){let u=c,d=c;if(1==a)for(;++c<=n&&null===t[c];)d=c;else for(;--c>=s&&null===t[c];)d=c;let h=o(e[u]),f=d==u?h:o(e[d]),p=u-a;h=i<=0&&p>=0&&p=0&&m>=0&&m=h&&r.push([h,f])}return r}function ta(e){return 0==e?ts:1==e?$t:t=>ls(t,e)}function sa(e){let t=0==e?na:aa,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,r,l=0,c=0)=>{0==l&&0==c?n(e,a,o,i,r):(l=Ht(l,i/2,r/2),c=Ht(c,i/2,r/2),t(e,a+l,o),s(e,a+i,o,a+i,o+r,l),s(e,a+i,o+r,a,o+r,c),s(e,a,o+r,a,o,c),s(e,a,o,a+i,o,l),e.closePath())}}const na=(e,t,s)=>{e.moveTo(t,s)},aa=(e,t,s)=>{e.moveTo(s,t)},oa=(e,t,s)=>{e.lineTo(t,s)},ia=(e,t,s)=>{e.lineTo(s,t)},ra=sa(0),la=sa(1),ca=(e,t,s,n,a,o)=>{e.arc(t,s,n,a,o)},ua=(e,t,s,n,a,o)=>{e.arc(s,t,n,a,o)},da=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(t,s,n,a,o,i)},ha=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(s,t,a,n,i,o)};function fa(e){return(e,t,s,n,a)=>Vn(e,t,(t,o,i,r,l,c,u,d,h,f,p)=>{let m,g,{pxRound:y,points:b}=t;0==r.ori?(m=na,g=ca):(m=aa,g=ua);const x=ds(b.width*at,3);let w=(b.size-b.width)/2*at,k=ds(2*w,3),v=new Path2D,S=new Path2D,{left:C,top:T,width:M,height:L}=e.bbox;ra(S,C-k,T-k,M+2*k,L+2*k);const _=e=>{if(null!=i[e]){let t=y(c(o[e],r,f,d)),s=y(u(i[e],l,p,h));m(v,t+w,s),g(v,t,s,w,0,2*zt)}};if(a)a.forEach(_);else for(let e=s;e<=n;e++)_(e);return{stroke:x>0?v:null,fill:v,clip:S,flags:3}})}function pa(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 ma=pa(oa),ga=pa(ia);function ya(e){const t=Dt(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>Vn(e,s,(o,i,r,l,c,u,d,h,f,p,m)=>{[n,a]=Tt(r,n,a);let g,y,b=o.pxRound,x=e=>b(u(e,l,p,h)),w=e=>b(d(e,c,m,f));0==l.ori?(g=oa,y=ma):(g=ia,y=ga);const k=l.dir*(0==l.ori?1:-1),v={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=v.stroke;let C=!1;if(a-n>=4*p){let t,s,o,c=t=>e.posToVal(t,l.key,!0),u=null,d=null,h=x(i[1==k?n:a]),f=x(i[n]),p=x(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:x(n),o=r[e];a==h?null!=o?(s=o,null==u?(g(S,a,w(s)),t=u=d=s):sd&&(d=s)):null===o&&(C=!0):(null!=u&&y(S,h,w(u),w(d),w(t),w(s)),null!=o?(s=o,g(S,a,w(s)),u=d=t=s):(u=d=null,null===o&&(C=!0)),h=a,m=c(h+k))}null!=u&&u!=d&&o!=h&&y(S,h,w(u),w(d),w(t),w(s))}else for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let t=r[e];null===t?C=!0:null!=t&&g(S,x(i[e]),w(t))}let[T,M]=Kn(e,s);if(null!=o.fill||0!=T){let t=v.fill=new Path2D(S),r=w(o.fillTo(e,s,o.min,o.max,T)),l=x(i[n]),c=x(i[a]);-1==k&&([c,l]=[l,c]),g(t,c,r),g(t,l,r)}if(!o.spanGaps){let c=[];C&&c.push(...ea(i,r,n,a,k,x,t)),v.gaps=c=o.gaps(e,s,n,a,c),v.clip=Zn(c,l.ori,h,f,p,m)}return 0!=M&&(v.band=2==M?[Qn(e,s,n,a,S,-1),Qn(e,s,n,a,S,1)]:Qn(e,s,n,a,S,M)),v})}function ba(e,t,s,n,a,o,i=Kt){if(e.length>1){let r=null;for(let l=0,c=1/0;l0!=n[e]>0?s[e]=0:(s[e]=3*(l[e-1]+l[e])/((2*l[e]+l[e-1])/n[e-1]+(l[e]+2*l[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[i-1]=n[i-2];for(let c=0;c{Fa.pxRatio=at}));const va=ya(),Sa=fa();function Ca(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>Ta(e,n,t,s))}function Ta(e,t,s,n){return Ms({},0==t?s:n,e)}function Ma(e,t,s){return null==t?ys:[t,s]}const La=Ma;function _a(e,t,s){return null==t?ys:Nt(t,s,.1,!0)}function ja(e,t,s,n){return null==t?ys:Lt(t,s,e.scales[n].log,!1)}const Pa=ja;function Ea(e,t,s,n){return null==t?ys:_t(t,s,e.scales[n].log,!1)}const Na=Ea;function Da(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=$t((s=+n)*at))+"px"),t,s]}function Ia(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=ds(e[2]*at,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function Fa(e,t,s){const n={mode:Dt(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 r(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 l=!1;n.status=0;const c=n.root=ut("uplot");null!=e.id&&(c.id=e.id),it(c,e.class),e.title&&(ut("u-title",c).textContent=e.title);const u=ct("canvas"),d=n.ctx=u.getContext("2d"),h=ut("u-wrap",c);xt("click",h,e=>{e.target===p&&(Qs!=Ys||Zs!=Vs)&&kn.click(n,e)},!0);const f=n.under=ut("u-under",h);h.appendChild(u);const p=n.over=ut("u-over",h),m=+Dt((e=Ts(e)).pxAlign,1),g=ta(m);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const y=e.ms||.001,b=n.series=1==a?Ca(e.series||[],Mn,Hn,!1):(x=e.series||[null],w=Wn,x.map((e,t)=>0==t?{}:Ms({},w,e)));var x,w;const k=n.axes=Ca(e.axes||[],Tn,Bn,!0),v=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=es(e.fill||null),e.dir=Dt(e.dir,-1)});const C=2==a?b[1].facets[0].scale:b[0].scale,T={axes:function(){for(let e=0;ers[e]):y,x=2==f.distr?rs[y[1]]-rs[y[0]]:u,w=t.ticks,S=t.border,C=w.show?w.size:0,T=$t(C*at),M=$t((2==t.alignTo?t._size-C-t.gap:t.gap)*at),L=t._rotate*-zt/180,_=g(t._pos*at),j=_+(T+M)*c;a=0==i?j:0,s=1==i?j:0,Ss(t.font[0],l,1==t.align?$e:2==t.align?We:L>0?$e:L<0?We:0==i?"center":3==o?We:$e,L||1==i?"middle":2==o?Be:Oe);let P=t.font[1]*t.lineGap,E=y.map(e=>g(r(e,f,p,m))),N=t._values;for(let e=0;e0){let e=b.some(e=>e._focus)&&is!=Pe.alpha;e&&(d.globalAlpha=is=Pe.alpha),b.forEach((e,s)=>{if(s>0&&e.show&&(js(s,!1),js(s,!0),null==e._paths)){let o=is;is!=e.alpha&&(d.globalAlpha=is=e.alpha);let i=2==a?[0,t[s][0].length-1]:function(e){let t=Qt(yt-1,0,mt-1),s=Qt(bt+1,0,mt-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=is;is!=e.alpha&&(d.globalAlpha=is=e.alpha),null!=e._paths&&Ps(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,yt,bt,s),o=e.points.filter(n,t,a,s);(a||o)&&(e.points._paths=e.points.paths(n,t,yt,bt,o),Ps(t,!0))}is!=s&&(d.globalAlpha=is=s),Fa("drawSeries",t)}}),e&&(d.globalAlpha=is=1)}}},M=(e.drawOrder||["axes","series"]).map(e=>T[e]);function L(e){const t=3==e.distr?t=>Jt(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>Vt(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 _(t){let s=v[t];if(null==s){let n=(e.scales||ms)[t]||ms;if(null!=n.from){_(n.from);let e=Ms({},v[n.from],n,{key:t});e.valToPct=L(e),v[t]=e}else{s=v[t]=Ms({},t==C?qn:Gn,n),s.key=t;let e=s.time,o=s.range,i=bs(o);if((t!=C||2==a&&!e)&&(!i||null!=o[0]&&null!=o[1]||(o={min:null==o[0]?jt:{mode:1,hard:o[0],soft:o[0]},max:null==o[1]?jt:{mode:1,hard:o[1],soft:o[1]}},i=!1),!i&&ks(o))){let e=o;o=(t,s,n)=>null==s?ys:Nt(s,n,e)}s.range=es(o||(e?La:t==C?3==s.distr?Pa:4==s.distr?Na:Ma:3==s.distr?ja:4==s.distr?Ea:_a)),s.auto=es(!i&&s.auto),s.clamp=es(s.clamp||Un),s._min=s._max=null,s.valToPct=L(s)}}}_("x"),_("y"),1==a&&b.forEach(e=>{_(e.scale)}),k.forEach(e=>{_(e.scale)});for(let Fe in e.scales)_(Fe);const j=v[C],P=j.distr;let E,N;0==j.ori?(it(c,"u-hz"),E=o,N=i):(it(c,"u-vt"),E=i,N=o);const D={};for(let Fe in v){let e=v[Fe];null==e.min&&null==e.max||(D[Fe]={min:e.min,max:e.max},e.min=e.max=null)}const I=e.tzDate||(e=>new Date($t(e/y))),F=e.fmtDate||Rs,A=1==y?an(I):ln(I),R=un(I,cn(1==y?nn:rn,F)),z=fn(I,hn("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",F)),B=[],O=n.legend=Ms({},pn,e.legend),$=n.cursor=Ms({},bn,{drag:{y:2==a}},e.cursor),W=O.show,H=$.show,U=O.markers;let q,G,J;O.idxs=B,U.width=es(U.width),U.dash=es(U.dash),U.stroke=es(U.stroke),U.fill=es(U.fill);let Y,V=[],K=[],X=!1,Q={};if(O.live){const e=b[1]?b[1].values:null;X=null!=e,Y=X?e(n,1,0):{_:0};for(let t in Y)Q[t]=Ze}if(W)if(q=ct("table","u-legend",c),J=ct("tbody",null,q),O.mount(n,q),X){G=ct("thead",null,q,J);let e=ct("tr",null,G);for(var Z in ct("th",null,e),Y)ct("th",Ae,e).textContent=Z}else it(q,"u-inline"),O.live&&it(q,"u-live");const ee={show:!0},te={show:!1},se=new Map;function ne(e,t,s,a=!0){const o=se.get(t)||{},i=$.bind[e](n,t,s,a);i&&(xt(e,t,o[e]=i),se.set(t,o))}function ae(e,t,s){const n=se.get(t)||{};for(let a in n)null!=e&&a!=e||(wt(a,t,n[a]),delete n[a]);null==e&&se.delete(t)}let oe=0,ie=0,re=0,le=0,ce=0,ue=0,de=ce,he=ue,fe=re,pe=le,me=0,ge=0,ye=0,be=0;n.bbox={};let xe=!1,we=!1,ke=!1,ve=!1,Se=!1,Ce=!1;function Te(e,t,s){(s||e!=n.width||t!=n.height)&&Me(e,t),Bs(!1),ke=!0,we=!0,gn()}function Me(e,t){n.width=oe=re=e,n.height=ie=le=t,ce=ue=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,r=o%2,l=i+(null!=a.label?a.labelSize:0);l>0&&(r?(re-=l,3==o?(ce+=l,n=!0):s=!0):(le-=l,0==o?(ue+=l,e=!0):t=!0))}}),nt[0]=e,nt[1]=s,nt[2]=t,nt[3]=n,re-=ft[1]+ft[3],ce+=ft[3],le-=ft[2]+ft[0],ue+=ft[0]}(),function(){let e=ce+re,t=ue+le,s=ce,n=ue;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;me=s.left=ls(ce*at,.5),ge=s.top=ls(ue*at,.5),ye=s.width=ls(re*at,.5),be=s.height=ls(le*at,.5)}const Le=3;if(n.setSize=function({width:e,height:t}){Te(e,t)},null==$.dataIdx){let e=$.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=es(e.prox),a=e.bias??(e.bias=0);$.dataIdx=(e,o,i,r)=>{if(0==o)return i;let l=i,c=n(e,o,i,r)??Kt,u=c>=0&&c0;)s.has(p[e])||(t=e);if(0==a||1==a)for(e=i;null==n&&e++c&&(l=null);return l}}const _e=e=>{$.event=e};$.idxs=B,$._lock=!1;let je=$.points;je.show=es(je.show),je.size=es(je.size),je.stroke=es(je.stroke),je.width=es(je.width),je.fill=es(je.fill);const Pe=n.focus=Ms({},e.focus||{alpha:.3},$.focus),Ee=Pe.prox>=0,Ne=Ee&&je.one;let De=[],Ie=[],He=[];function Xe(e,t){let s=je.show(n,t);if(s instanceof HTMLElement)return it(s,"u-cursor-pt"),it(s,e.class),ht(s,-10,-10,re,le),p.insertBefore(s,De[t]),s}function et(e,t){if(1==a||t>0){let t=1==a&&v[e.scale].time,s=e.value;e.value=t?ws(s)?fn(I,hn(s,F)):s||z:s||zn,e.label=e.label||(t?"Time":"Value")}if(Ne||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||va||ns,e.fillTo=es(e.fillTo||Xn),e.pxAlign=+Dt(e.pxAlign,m),e.pxRound=ta(e.pxAlign),e.stroke=es(e.stroke||null),e.fill=es(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=ds(1*(3+2*(Ut(1,e.width)||1)),3),s=e.points=Ms({},{size:t,width:Ut(1,.2*t),stroke:e.stroke,space:2*t,paths:Sa,_stroke:null,_fill:null},e.points);s.show=es(s.show),s.filter=es(s.filter),s.fill=es(s.fill),s.stroke=es(s.stroke),s.paths=es(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(X||!O.live||2==a))return ys;let s=[],o=ct("tr","u-series",J,J.childNodes[t]);it(o,e.class),e.show||it(o,Fe);let i=ct("th",null,o);if(U.show){let e=ut("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 r=ut(Ae,i);for(var l in e.label instanceof HTMLElement?r.appendChild(e.label):r.textContent=e.label,t>0&&(U.show||(r.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),ne("click",i,t=>{if($._lock)return;_e(t);let s=b.indexOf(e);if((t.ctrlKey||t.metaKey)!=O.isolate){let e=b.some((e,t)=>t>0&&t!=s&&e.show);b.forEach((t,n)=>{n>0&&In(n,e?n==s?ee:te:ee,!0,Ra.setSeries)})}else In(s,{show:!e.show},!0,Ra.setSeries)},!1),Ee&&ne(Ye,i,t=>{$._lock||(_e(t),In(b.indexOf(e),Jn,!0,Ra.setSeries))},!1)),Y){let e=ct("td","u-value",o);e.textContent="--",s.push(e)}return[o,s]}(e,t);V.splice(t,0,s[0]),K.splice(t,0,s[1]),O.values.push(null)}if(H){B.splice(t,0,null);let s=null;Ne?0==t&&(s=Xe(e,t)):t>0&&(s=Xe(e,t)),De.splice(t,0,s),Ie.splice(t,0,0),He.splice(t,0,0)}Fa("addSeries",t)}n.addSeries=function(e,t){t=null==t?b.length:t,e=1==a?Ta(e,t,Mn,Hn):Ta(e,t,{},Wn),b.splice(t,0,e),et(b[t],t)},n.delSeries=function(e){if(b.splice(e,1),W){O.values.splice(e,1),K.splice(e,1);let t=V.splice(e,1)[0];ae(null,t.firstChild),t.remove()}H&&(B.splice(e,1),De.splice(e,1)[0].remove(),Ie.splice(e,1),He.splice(e,1)),Fa("delSeries",e)};const nt=[!1,!1,!1,!1];function ot(e,t,s,n){let[a,o,i,r]=s,l=t%2,c=0;return 0==l&&(r||o)&&(c=0==t&&!a||2==t&&!i?$t(Tn.size/3):0),1==l&&(a||i)&&(c=1==t&&!o||3==t&&!r?$t(Bn.size/2):0),c}const dt=n.padding=(e.padding||[ot,ot,ot,ot]).map(e=>es(Dt(e,ot))),ft=n._padding=dt.map((e,t)=>e(n,t,nt,0));let mt,yt=null,bt=null;const vt=1==a?b[0].idxs:null;let Pt,Et,It,Ft,At,Ot,Gt,Yt,ts,is,rs=null,cs=!1;function us(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){mt=0;for(let e=1;e=0,Ce=!0,gn()}}function ps(){let e,s;cs=!0,1==a&&(mt>0?(yt=vt[0]=0,bt=vt[1]=mt-1,e=t[0][yt],s=t[0][bt],2==P?(e=yt,s=bt):e==s&&(3==P?[e,s]=Lt(e,e,j.log,!1):4==P?[e,s]=_t(e,e,j.log,!1):j.time?s=e+$t(86400/y):[e,s]=Nt(e,s,.1,!0))):(yt=vt[0]=e=null,bt=vt[1]=s=null)),Dn(C,e,s)}function xs(e,t,s,n,a,o){e??(e=Ue),s??(s=gs),n??(n="butt"),a??(a=Ue),o??(o="round"),e!=Pt&&(d.strokeStyle=Pt=e),a!=Et&&(d.fillStyle=Et=a),t!=It&&(d.lineWidth=It=t),o!=At&&(d.lineJoin=At=o),n!=Ot&&(d.lineCap=Ot=n),s!=Ft&&d.setLineDash(Ft=s)}function Ss(e,t,s,n){t!=Et&&(d.fillStyle=Et=t),e!=Gt&&(d.font=Gt=e),s!=Yt&&(d.textAlign=Yt=s),n!=ts&&(d.textBaseline=ts=n)}function Cs(e,t,s,a,o=0){if(a.length>0&&e.auto(n,cs)&&(null==t||null==t.min)){let t=Dt(yt,0),n=Dt(bt,a.length-1),i=null==s.min?function(e,t,s,n=0,a=!1){let o=a?Mt:Tt,i=a?Ct:St;[t,s]=o(e,t,s);let r=e[t],l=e[t];if(t>-1)if(1==n)r=e[t],l=e[s];else if(-1==n)r=e[s],l=e[t];else for(let c=t;c<=s;c++){let t=e[c];i(t)&&(tl&&(l=t))}return[r??Kt,l??-Kt]}(a,t,n,o,3==e.distr):[s.min,s.max];e.min=Ht(e.min,s.min=i[0]),e.max=Ut(e.max,s.max=i[1])}}n.setData=us;const Ls={min:null,max:null};function js(e,t){let s=t?b[e].points:b[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function Ps(e,s){let a=s?b[e].points:b[e],{stroke:o,fill:i,clip:r,flags:l,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=ds(h*at,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=me-h/2,t=ge-h/2,s=ye+h,n=be+h;f=new Path2D,f.rect(e,t,s,n)}s?Ns(c,h,a.dash,a.cap,u,o,i,l,r):function(e,s,a,o,i,r,l,c,u,d,h){let f=!1;0!=u&&S.forEach((p,m)=>{if(p.series[0]==e){let e,g=b[p.series[1]],y=t[p.series[1]],x=(g._paths||ms).band;bs(x)&&(x=1==p.dir?x[0]:x[1]);let w=null;g.show&&x&&function(e,t,s){for(t=Dt(t,0),s=Dt(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(y,yt,bt)?(w=p.fill(n,m)||r,e=g._paths.clip):x=null,Ns(s,a,o,i,w,l,c,u,d,h,e,x),f=!0}}),f||Ns(s,a,o,i,r,l,c,u,d,h)}(e,c,h,a.dash,a.cap,u,o,i,l,f,r),m&&d.translate(-p,-p)}const Es=3;function Ns(e,t,s,n,a,o,i,r,l,c,u,h){xs(e,t,s,n,a),(l||c||h)&&(d.save(),l&&d.clip(l),c&&d.clip(c)),h?(r&Es)==Es?(d.clip(h),u&&d.clip(u),Is(a,i),Ds(e,o,t)):2&r?(Is(a,i),d.clip(h),Ds(e,o,t)):1&r&&(d.save(),d.clip(h),u&&d.clip(u),Is(a,i),d.restore(),Ds(e,o,t)):(Is(a,i),Ds(e,o,t)),(l||c||h)&&d.restore()}function Ds(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=Pt=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function Is(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=Et=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function Fs(e,t,s,n,a,o,i,r,l,c){let u=i%2/2;1==m&&d.translate(u,u),xs(r,i,l,c,r),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,Bs(!1)));s._show||(t=!1,s._show=!0,Bs(!1));let i=s.side,r=i%2,{min:l,max:c}=o,[u,d]=function(e,t,s,a){let o,i=k[e];if(a<=0)o=[0,0];else{let r=i._space=i.space(n,e,t,s,a);o=function(e,t,s,n,a){let o=Ut(Xt(e),Xt(t)),i=t-e,r=kt(a/n*i,s);do{let e=s[r],t=n*e/i;if(t>=a&&o+(e<5?hs.get(e):0)<=17)return[e,t]}while(++rrs[e]):f,m=2==o.distr?rs[f[1]]-rs[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=Wt(s.size(n,g,a,e)),null!=y&&s._size!=y&&(t=!1)}),t}function zs(e){let t=!0;return dt.forEach((s,a)=>{let o=s(n,a,nt,e);o!=ft[a]&&(t=!1),ft[a]=o}),t}function Bs(e){b.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 Os,$s,Ws,qs,Gs,Js,Ys,Vs,Ks,Xs,Qs,Zs,en=!1,tn=!1,dn=[];function mn(){tn=!1;for(let e=0;e0){b.forEach((s,o)=>{if(1==a){let a=s.scale,i=D[a];if(null==i)return;let r=e[a];if(0==o){let e=r.range(n,r.min,r.max,a);r.min=e[0],r.max=e[1],yt=kt(r.min,t[0]),bt=kt(r.max,t[0]),bt-yt>1&&(t[0][yt]r.max&&bt--),s.min=rs[yt],s.max=rs[bt]}else s.show&&s.auto&&Cs(r,i,s,t[o],s.sorted);s.idxs[0]=yt,s.idxs[1]=bt}else if(o>0&&s.show&&s.auto){let[n,a]=s.facets,i=n.scale,r=a.scale,[l,c]=t[o],u=e[i],d=e[r];null!=u&&Cs(u,D[i],n,l,n.sorted),null!=d&&Cs(d,D[r],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=D[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==Kt?null:s.min,s.max==-Kt?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?Jt(a.min):4==e?Vt(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?Jt(a.max):4==e?Vt(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=o=!0}}if(o){b.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)ke=!0,Fa("setScale",e);H&&$.left>=0&&(ve=Ce=!0)}for(let t in D)D[t]=null}(),xe=!1),ke&&(function(){let e=!1,t=0;for(;!e;){t++;let s=As(t),a=zs(t);e=t==Le||s&&a,e||(Me(n.width,n.height),we=!0)}}(),ke=!1),we){if(lt(f,$e,ce),lt(f,Be,ue),lt(f,Re,re),lt(f,ze,le),lt(p,$e,ce),lt(p,Be,ue),lt(p,Re,re),lt(p,ze,le),lt(h,Re,oe),lt(h,ze,ie),u.width=$t(oe*at),u.height=$t(ie*at),k.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;lt(e,t?"left":"top",n-(3===a||0===a?s:0)),lt(e,t?"width":"height",s),lt(e,t?"top":"left",t?ue:ce),lt(e,t?"height":"width",t?le:re),rt(e,Fe)}else it(e,Fe)}),Pt=Et=It=At=Ot=Gt=Yt=ts=Ft=null,is=1,ia(!0),ce!=de||ue!=he||re!=fe||le!=pe){Bs(!1);let e=re/fe,t=le/pe;if(H&&!ve&&$.left>=0){$.left*=e,$.top*=t,Ws&&ht(Ws,$t($.left),0,re,le),qs&&ht(qs,0,$t($.top),re,le);for(let s=0;s=0&&Cn.width>0){Cn.left*=e,Cn.width*=e,Cn.top*=t,Cn.height*=t;for(let e in ca)lt(En,e,Cn[e])}de=ce,he=ue,fe=re,pe=le}Fa("setSize"),we=!1}oe>0&&ie>0&&(d.clearRect(0,0,u.width,u.height),Fa("drawClear"),M.forEach(e=>e()),Fa("draw")),Cn.show&&Se&&(Nn(Cn),Se=!1),H&&ve&&(aa(null,!0,!1),ve=!1),O.show&&O.live&&Ce&&(sa(),Ce=!1),l||(l=!0,n.status=1,Fa("ready")),cs=!1,en=!1}function xn(e,s){let a=v[e];if(null==a.from){if(0==mt){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(mt>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==C&&2==a.distr&&mt>0&&(s.min=kt(s.min,t[0]),s.max=kt(s.max,t[0]),s.min==s.max&&s.max++),D[e]=s,xe=!0,gn()}}n.batch=function(e,t=!1){en=!0,tn=t,e(n),yn(),t&&dn.length>0&&queueMicrotask(mn)},n.redraw=(e,t)=>{ke=t||!1,!1!==e?Dn(C,j.min,j.max):gn()},n.setScale=xn;let wn=!1;const kn=$.drag;let vn=kn.x,Sn=kn.y;H&&($.x&&(Os=ut("u-cursor-x",p)),$.y&&($s=ut("u-cursor-y",p)),0==j.ori?(Ws=Os,qs=$s):(Ws=$s,qs=Os),Qs=$.left,Zs=$.top);const Cn=n.select=Ms({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),En=Cn.show?ut("u-select",Cn.over?p:f):null;function Nn(e,t){if(Cn.show){for(let t in e)Cn[t]=e[t],t in ca&<(En,t,e[t]);!1!==t&&Fa("setSelect")}}function Dn(e,t,s){xn(e,{min:t,max:s})}function In(e,t,s,o){null!=t.focus&&function(e){if(e!=$n){let t=null==e,s=1!=Pe.alpha;b.forEach((n,o)=>{if(1==a||o>0){let a=t||0==o||o==e;n._focus=t?null:a,s&&function(e,t){b[e].alpha=t,H&&null!=De[e]&&(De[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(o,a?1:Pe.alpha)}}),$n=e,s&&gn()}}(e),null!=t.show&&b.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(b[e].show)W&&rt(V[e],Fe);else if(W&&it(V[e],Fe),H){let t=Ne?De[0]:De[e];null!=t&&ht(t,-10,-10,re,le)}}(n),2==a?(Dn(s.facets[0].scale,null,null),Dn(s.facets[1].scale,null,null)):Dn(s.scale,null,null),gn())}),!1!==s&&Fa("setSeries",e,t),o&&Oa("setSeries",n,e,t)}let Fn,On,$n;n.setSelect=Nn,n.setSeries=In,n.addBand=function(e,t){e.fill=es(e.fill||null),e.dir=Dt(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){Ms(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const Jn={focus:!0};function Vn(e,t,s){let n=v[t];s&&(e=e/at-(1==n.ori?ue:ce));let a=re;1==n.ori&&(a=le,e=a-e),-1==n.dir&&(e=a-e);let o=n._min,i=o+(n._max-o)*(e/a),r=n.distr;return 3==r?qt(10,i):4==r?((e,t=1)=>Rt.sinh(e)*t)(i,n.asinh):100==r?n.bwd(i):i}function Kn(e,t){lt(En,$e,Cn.left=e),lt(En,Re,Cn.width=t)}function Qn(e,t){lt(En,Be,Cn.top=e),lt(En,ze,Cn.height=t)}W&&Ee&&ne(Ve,q,e=>{$._lock||(_e(e),null!=$n&&In(null,Jn,!0,Ra.setSeries))}),n.valToIdx=e=>kt(e,t[0]),n.posToIdx=function(e,s){return kt(Vn(e,C,s),t[0],yt,bt)},n.posToVal=Vn,n.valToPos=(e,t,s)=>0==v[t].ori?o(e,v[t],s?ye:re,s?me:0):i(e,v[t],s?be:le,s?ge:0),n.setCursor=(e,t,s)=>{Qs=e.left,Zs=e.top,aa(null,t,s)};let Zn=0==j.ori?Kn:Qn,ea=1==j.ori?Kn:Qn;function sa(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{B[t]=e}):void 0!==e.idx&&B.fill(e.idx),O.idx=B[0]),W&&O.live){for(let e=0;e0||1==a&&!X)&&na(e,B[e]);!function(){if(W&&O.live)for(let e=2==a?1:0;ebt;Fn=Kt,On=null;let l=0==j.ori?re:le,c=1==j.ori?re:le;if(Qs<0||0==mt||r){i=$.idx=null;for(let e=0;e0&&e.show){let s=null==w?-10:w==i?o:E(1==a?t[0][w]:t[g][0][w],j,l,0),y=null==k?-10:N(k,1==a?v[e.scale]:v[e.facets[1].scale],c,0);if(Ee&&null!=k){let t=1==j.ori?Qs:Zs,s=Bt(Pe.dist(n,g,w,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)&&(Fn=s,On=g)}else Fn=s,On=g}}if(Ce||Ne){let e,t;0==j.ori?(e=s,t=y):(e=y,t=s);let a,o,i,l,c,b,x=!0,w=je.bbox;if(null!=w){x=!1;let e=w(n,g);i=e.left,l=e.top,a=e.width,o=e.height}else i=e,l=t,a=o=je.size(n,g);if(b=je.fill(n,g),c=je.stroke(n,g),Ne)g==On&&Fn<=Pe.prox&&(r=i,u=l,d=a,h=o,f=x,p=b,m=c);else{let e=De[g];null!=e&&(Ie[g]=i,He[g]=l,gt(e,a,o,x),pt(e,b,c),ht(e,Wt(i),Wt(l),re,le))}}}}if(Ne){let e=Pe.prox;if(Ce||(null==$n?Fn<=e:Fn>e||On!=$n)){let e=De[0];null!=e&&(Ie[0]=r,He[0]=u,gt(e,d,h,f),pt(e,p,m),ht(e,Wt(r),Wt(u),re,le))}}}if(Cn.show&&wn)if(null!=e){let[t,s]=Ra.scales,[n,a]=Ra.match,[o,i]=e.cursor.sync.scales,r=e.cursor.drag;if(vn=r._x,Sn=r._y,vn||Sn){let r,u,d,h,f,{left:p,top:m,width:g,height:y}=e.select,b=e.scales[o].ori,x=e.posToVal,w=null!=t&&n(t,o),k=null!=s&&a(s,i);w&&vn?(0==b?(r=p,u=g):(r=m,u=y),d=v[t],h=E(x(r,o),d,l,0),f=E(x(r+u,o),d,l,0),Zn(Ht(h,f),Bt(f-h))):Zn(0,l),k&&Sn?(1==b?(r=p,u=g):(r=m,u=y),d=v[s],h=N(x(r,i),d,c,0),f=N(x(r+u,i),d,c,0),ea(Ht(h,f),Bt(f-h))):ea(0,c)}else ua()}else{let e=Bt(Ks-Gs),t=Bt(Xs-Js);if(1==j.ori){let s=e;e=t,t=s}vn=kn.x&&e>=kn.dist,Sn=kn.y&&t>=kn.dist;let s,n,a=kn.uni;null!=a?vn&&Sn&&(vn=e>=a,Sn=t>=a,vn||Sn||(t>e?Sn=!0:vn=!0)):kn.x&&kn.y&&(vn||Sn)&&(vn=Sn=!0),vn&&(0==j.ori?(s=Ys,n=Qs):(s=Vs,n=Zs),Zn(Ht(s,n),Bt(n-s)),Sn||ea(0,c)),Sn&&(1==j.ori?(s=Ys,n=Qs):(s=Vs,n=Zs),ea(Ht(s,n),Bt(n-s)),vn||Zn(0,l)),vn||Sn||(Zn(0,0),ea(0,0))}if(kn._x=vn,kn._y=Sn,null==e){if(o){if(null!=za){let[e,t]=Ra.scales;Ra.values[0]=null!=e?Vn(0==j.ori?Qs:Zs,e):null,Ra.values[1]=null!=t?Vn(1==j.ori?Qs:Zs,t):null}Oa(qe,n,Qs,Zs,re,le,i)}if(Ee){let e=o&&Ra.setSeries,t=Pe.prox;null==$n?Fn<=t&&In(On,Jn,!0,e):Fn>t?In(null,Jn,!0,e):On!=$n&&In(On,Jn,!0,e)}}Ce&&(O.idx=i,sa()),!1!==s&&Fa("setCursor")}n.setLegend=sa;let oa=null;function ia(e=!1){e?oa=null:(oa=p.getBoundingClientRect(),Fa("syncRect",oa))}function ra(e,t,s,n,a,o,i){$._lock||wn&&null!=e&&0==e.movementX&&0==e.movementY||(la(e,t,s,n,a,o,0,!1,null!=e),null!=e?aa(null,!0,!0):aa(t,!0,!1))}function la(e,t,s,a,o,i,l,c,u){if(null==oa&&ia(!1),_e(e),null!=e)s=e.clientX-oa.left,a=e.clientY-oa.top;else{if(s<0||a<0)return Qs=-10,void(Zs=-10);let[e,n]=Ra.scales,l=t.cursor.sync,[c,u]=l.values,[d,h]=l.scales,[f,p]=Ra.match,m=t.axes[0].side%2==1,g=0==j.ori?re:le,y=1==j.ori?re:le,b=m?i:o,x=m?o:i,w=m?a:s,k=m?s:a;if(s=null!=d?f(e,d)?r(c,v[e],g,0):-10:g*(w/b),a=null!=h?p(n,h)?r(u,v[n],y,0):-10:y*(k/x),1==j.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=qe||((s<=1||s>=re-1)&&(s=ls(s,re)),(a<=1||a>=le-1)&&(a=ls(a,le))),c?(Gs=s,Js=a,[Ys,Vs]=$.move(n,s,a)):(Qs=s,Zs=a)}Object.defineProperty(n,"rect",{get:()=>(null==oa&&ia(!1),oa)});const ca={width:0,height:0,left:0,top:0};function ua(){Nn(ca,!1)}let da,ha,fa,pa;function ma(e,t,s,a,o,i,r){wn=!0,vn=Sn=kn._x=kn._y=!1,la(e,t,s,a,o,i,0,!0,!1),null!=e&&(ne(Je,tt,ga,!1),Oa(Ge,n,Ys,Vs,re,le,null));let{left:l,top:c,width:u,height:d}=Cn;da=l,ha=c,fa=u,pa=d}function ga(e,t,s,a,o,i,r){wn=kn._x=kn._y=!1,la(e,t,s,a,o,i,0,!1,!0);let{left:l,top:c,width:u,height:d}=Cn,h=u>0||d>0,f=da!=l||ha!=c||fa!=u||pa!=d;if(h&&f&&Nn(Cn),kn.setScale&&h&&f){let e=l,t=u,s=c,n=d;if(1==j.ori&&(e=c,t=d,s=l,n=u),vn&&Dn(C,Vn(e,C),Vn(e+t,C)),Sn)for(let a in v){let e=v[a];a!=C&&null==e.from&&e.min!=Kt&&Dn(a,Vn(s+n,a),Vn(s,a))}ua()}else $.lock&&($._lock=!$._lock,aa(t,!0,null!=e));null!=e&&(ae(Je,tt),Oa(Je,n,Qs,Zs,re,le,null))}function ya(e,t,s,a,o,i,r){$._lock||(_e(e),ps(),ua(),null!=e&&Oa(Ke,n,Qs,Zs,re,le,null))}function ba(){k.forEach(Ia),Te(n.width,n.height,!0)}xt(Qe,st,ba);const xa={};xa.mousedown=ma,xa.mousemove=ra,xa.mouseup=ga,xa.dblclick=ya,xa.setSeries=(e,t,s,a)=>{-1!=(s=(0,Ra.match[2])(n,t,s))&&In(s,a,!0,!1)},H&&(ne(Ge,p,ma),ne(qe,p,ra),ne(Ye,p,e=>{_e(e),ia(!1)}),ne(Ve,p,function(e,t,s,n,a,o,i){if($._lock)return;_e(e);let r=wn;if(wn){let e,t,s=!0,n=!0,a=10;0==j.ori?(e=vn,t=Sn):(e=Sn,t=vn),e&&t&&(s=Qs<=a||Qs>=re-a,n=Zs<=a||Zs>=le-a),e&&s&&(Qs=Qs{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)ka[t]=(ka[t]||[]).concat(e.hooks[t])});const Aa=(e,t,s)=>s,Ra=Ms({key:null,setSeries:!1,filters:{pub:as,sub:as},scales:[C,b[1]?b[1].scale:null],match:[os,os,Aa],values:[null,null]},$.sync);2==Ra.match.length&&Ra.match.push(Aa),$.sync=Ra;const za=Ra.key,Ba=Yn(za);function Oa(e,t,s,n,a,o,i){Ra.filters.pub(e,t,s,n,a,o,i)&&Ba.pub(e,t,s,n,a,o,i)}function $a(){Fa("init",e,t),us(t||e.data,!1),D[C]?xn(C,D[C]):ps(),Se=Cn.show&&(Cn.width>0||Cn.height>0),ve=Ce=!0,Te(e.width,e.height)}return Ba.sub(n),n.pub=function(e,t,s,n,a,o,i){Ra.filters.sub(e,t,s,n,a,o,i)&&xa[e](null,t,s,n,a,o,i)},n.destroy=function(){Ba.unsub(n),wa.delete(n),se.clear(),wt(Qe,st,ba),c.remove(),null==q||q.remove(),Fa("destroy")},b.forEach(et),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?b[1].scale:C,a=v[e.scale]);let o=a.time;e.size=es(e.size),e.space=es(e.space),e.rotate=es(e.rotate),bs(e.incrs)&&e.incrs.forEach(e=>{!hs.has(e)&&hs.set(e,fs(e))}),e.incrs=es(e.incrs||(2==a.distr?Hs:o?1==y?sn:on:Us)),e.splits=es(e.splits||(o&&1==a.distr?A:3==a.distr?jn:4==a.distr?Pn:_n)),e.stroke=es(e.stroke),e.grid.stroke=es(e.grid.stroke),e.ticks.stroke=es(e.ticks.stroke),e.border.stroke=es(e.border.stroke);let i=e.values;e.values=bs(i)&&!bs(i[0])?es(i):o?bs(i)?un(I,cn(i,F)):ws(i)?function(e,t){let s=Rs(t);return(t,n,a,o,i)=>n.map(t=>s(e(t)))}(I,i):i||R:i||Ln,e.filter=es(e.filter||(a.distr>=3&&10==a.log?An:3==a.distr&&2==a.log?Rn:ss)),e.font=Da(e.font),e.labelFont=Da(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&&(nt[t]=!0,e._el=ut("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),$a()):s(n,$a):$a(),n}Fa.assign=Ms,Fa.fmtNum=At,Fa.rangeNum=Nt,Fa.rangeLog=Lt,Fa.rangeAsinh=_t,Fa.orient=Vn,Fa.pxRatio=at,Fa.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=Ut(1,Ot((a-n+1)/t));for(let i=e[n],r=n+o;r<=a;r+=o){const t=e[r];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;iVn(e,o,(l,c,u,d,h,f,p,m,g,y,b)=>{[i,r]=Tt(u,i,r);let x=l.pxRound,{left:w,width:k}=e.bbox,v=e=>x(f(e,d,y,m)),S=e=>x(p(e,h,b,g)),C=0==d.ori?oa:ia;const T={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},M=T.stroke,L=d.dir*(0==d.ori?1:-1);let _=S(u[1==L?i:r]),j=v(c[1==L?i:r]),P=j,E=j;a&&-1==t&&(E=w,C(M,E,_)),C(M,j,_);for(let e=1==L?i:r;e>=i&&e<=r;e+=L){let s=u[e];if(null==s)continue;let n=v(c[e]),a=S(s);1==t?C(M,n,_):C(M,P,a),C(M,n,a),_=a,P=n}let N=P;a&&1==t&&(N=w+k,C(M,N,_));let[D,I]=Kn(e,o);if(null!=l.fill||0!=D){let t=T.fill=new Path2D(M),s=S(l.fillTo(e,o,l.min,l.max,D));C(t,N,s),C(t,E,s)}if(!l.spanGaps){let a=[];a.push(...ea(c,u,i,r,L,v,n));let h=l.width*at/2,f=s||1==t?h:-h,p=s||-1==t?-h:h;a.forEach(e=>{e[0]+=f,e[1]+=p}),T.gaps=a=l.gaps(e,o,i,r,a),T.clip=Zn(a,d.ori,m,g,y,b)}return 0!=I&&(T.band=2==I?[Qn(e,o,i,r,M,-1),Qn(e,o,i,r,M,1)]:Qn(e,o,i,r,M,I)),T})},e.bars=function(e){const t=Dt((e=e||ms).size,[.6,Kt,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=es(a),i=1-t[0],r=Dt(t[1],Kt),l=Dt(t[2],1),c=Dt(e.disp,ms),u=Dt(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,f)=>Vn(e,t,(p,m,g,y,b,x,w,k,v,S,C)=>{let T,M,L=p.pxRound,_=s,j=n*at,P=r*at,E=l*at;0==y.ori?[T,M]=o(e,t):[M,T]=o(e,t);const N=y.dir*(0==y.ori?1:-1);let D,I,F,A=0==y.ori?ra:la,R=0==y.ori?u:(e,t,s,n,a,o,i)=>{u(e,t,s,a,n,i,o)},z=Dt(e.bands,gs).find(e=>e.series[0]==t),B=null!=z?z.dir:0,O=p.fillTo(e,t,p.min,p.max,B),$=L(w(O,b,C,v)),W=S,H=L(p.width*at),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:K}=c;if(null!=V&&null!=K){_=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=K.values(e,t,a,f);I=2==K.unit?s[0]*S:x(s[0],y,S,k)-x(0,y,S,k),W=ba(m,g,x,y,S,k,W),F=W-I+j}else W=ba(m,g,x,y,S,k,W),F=W*i+j,I=W-F;F<1&&(F=0),H>=I/2&&(H=0),F<5&&(L=ts);let X=F>0;I=L(Qt(W-F-(X?H:0),E,P)),D=(0==_?I/2:_==N?0:I)-_*N*((0==_?j/2:0)+(X?H/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Z=U?null:new Path2D;let ee=null;if(null!=z)ee=e.data[z.series[1]];else{let{y0:s,y1:n}=c;null!=s&&null!=n&&(g=n.values(e,t,a,f),ee=s.values(e,t,a,f))}let te=T*I,se=M*I;for(let s=1==N?a:f;s>=a&&s<=f;s+=N){let n=g[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;$=w(e,b,C,v)}let a=x(2!=y.distr||null!=c?m[s]:s,y,S,k),o=w(Dt(n,O),b,C,v),i=L(a-D),r=L(Ut(o,$)),l=L(Ht(o,$)),u=r-l;if(null!=n){let a=n<0?se:te,o=n<0?te:se;U?(H>0&&null!=J[s]&&A(Y.get(J[s]),i,l+Ot(H/2),I,Ut(0,u-H),a,o),null!=q[s]&&A(G.get(q[s]),i,l+Ot(H/2),I,Ut(0,u-H),a,o)):A(Z,i,l+Ot(H/2),I,Ut(0,u-H),a,o),R(e,t,s,i-H/2,l,I+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=Dt(null==t?void 0:t.alignGaps,0);return(t,n,a,o)=>Vn(t,n,(i,r,l,c,u,d,h,f,p,m,g)=>{[a,o]=Tt(l,a,o);let y,b,x,w=i.pxRound,k=e=>w(d(e,c,m,f)),v=e=>w(h(e,u,g,p));0==c.ori?(y=na,x=oa,b=da):(y=aa,x=ia,b=ha);const S=c.dir*(0==c.ori?1:-1);let C=k(r[1==S?a:o]),T=C,M=[],L=[];for(let e=1==S?a:o;e>=a&&e<=o;e+=S)if(null!=l[e]){let t=k(r[e]);M.push(T=t),L.push(v(l[e]))}const _={stroke:e(M,L,y,x,b,w),fill:null,clip:null,band:null,gaps:null,flags:1},j=_.stroke;let[P,E]=Kn(t,n);if(null!=i.fill||0!=P){let e=_.fill=new Path2D(j),s=v(i.fillTo(t,n,i.min,i.max,P));x(e,T,s),x(e,C,s)}if(!i.spanGaps){let e=[];e.push(...ea(r,l,a,o,S,k,s)),_.gaps=e=i.gaps(t,n,a,o,e),_.clip=Zn(e,c.ori,f,p,m,g)}return 0!=E&&(_.band=2==E?[Qn(t,n,a,o,j,-1),Qn(t,n,a,o,j,1)]:Qn(t,n,a,o,j,E)),_})}(xa,e)}}const Aa=new Map;function Ra(e){var t;if(!e.startsWith("var("))return e;const s=Aa.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 Aa.set(e,i),i}const za=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:o=null,cursorColor:i="rgba(255,255,255,0.5)"}){const r=s.useRef(null),l=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,r=a.width,l=a.height;if(r<=0||l<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,f=e=>{const t=c[e];return o+(t-d)/h*r},p=e=>i+l*(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,r=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=r.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 ${r.fontFamily}`,t.fillStyle=r.textPrimary,t.textBaseline="middle",t.textAlign="left";const l=8*i;for(const c of[0,20,40,60,80,100]){const e=n+o*(1-c/100),s=Math.max(n+l,Math.min(n+o-l,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=r.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!l.current||a>100||s>0&&a/s>.1)&&l.current)return l.current.setData(f),void(h.current=n);l.current&&l.current.destroy();const o=t.getBoundingClientRect(),i=Math.floor(o.width)||400,c=Math.floor(o.height)||200,u=new Fa({...m,width:i,height:c},f,t);return l.current=u,h.current=n,()=>{u.destroy(),l.current=null}},[m,f,e.length]),s.useEffect(()=>{const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!l.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&l.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{l.current&&l.current.redraw()},[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:r,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})}),Ba=s.createContext(null);function Oa(e){const t=re(e);t&&function(e){if("undefined"==typeof document)return;const t=function(e){const t={},s=e.surfaces.glass;t["--glass-tint"]=s.tint,t["--glass-light"]=s.light,t["--glass-dark"]=s.dark,t["--glass-reflex-light"]=String(s.reflexLight),t["--glass-reflex-dark"]=String(s.reflexDark),t["--glass-blur"]=`${s.blur}px`,t["--glass-blur-elevated"]=`${s.blurElevated}px`,t["--glass-brightness"]=String(s.brightness),t["--glass-bg-opacity"]=`${s.opacity}%`,t["--glass-bg-opacity-elevated"]=`${s.opacityElevated}%`,t["--sidebar-tint"]=e.surfaces.sidebar.tint,t["--tooltip-bg"]=e.colors.bg.surface,t["--hover-tint"]=`rgba(${O(e.colors.accent.primary)}, 0.08)`,t["--shadow-tint"]=`rgba(${O(e.colors.accent.primary)}, 0.35)`,t["--bg-body"]=e.colors.bg.body,t["--bg-surface"]=e.colors.bg.surface,t["--bg-elevated"]=e.colors.bg.elevated,t["--bg-subtle"]=e.colors.bg.subtle,t["--border-subtle"]=e.colors.border.subtle,t["--border-strong"]=e.colors.border.strong,t["--text-primary"]=e.colors.text.primary,t["--text-secondary"]=e.colors.text.secondary,t["--text-muted"]=e.colors.text.muted,t["--text-invert"]=e.colors.text.inverse,t["--accent-primary"]=e.colors.accent.primary,t["--accent-secondary"]=e.colors.accent.secondary,t["--accent-tertiary"]=e.colors.accent.tertiary,t["--accent-success"]=e.colors.accent.success,t["--accent-danger"]=e.colors.accent.danger,t["--signal-excellent"]=e.colors.signal.excellent,t["--signal-good"]=e.colors.signal.good,t["--signal-fair"]=e.colors.signal.fair,t["--signal-poor"]=e.colors.signal.poor,t["--signal-critical"]=e.colors.signal.critical,t["--signal-unknown"]=e.colors.signal.unknown,t["--sparkline-excellent"]=e.colors.signal.excellent,t["--sparkline-good"]=e.colors.signal.good,t["--sparkline-fair"]=e.colors.signal.fair,t["--sparkline-poor"]=e.colors.signal.poor,t["--sparkline-critical"]=e.colors.signal.critical,t["--status-success"]=e.colors.status.success,t["--status-warning"]=e.colors.status.warning,t["--status-danger"]=e.colors.status.danger,t["--status-info"]=e.colors.status.info,t["--status-muted"]=e.colors.status.muted;const n=e.colors.chart;t["--pkt-advert"]=e.colors.accent.secondary,t["--pkt-flood"]=e.colors.accent.tertiary,t["--pkt-txt-msg"]=e.colors.accent.success,t["--pkt-ack"]=n.c8,t["--pkt-trace"]=n.c3,t["--pkt-req"]=n.c2,t["--pkt-response"]=n.c5,t["--pkt-grp-txt"]=e.colors.map.room,t["--pkt-grp-data"]=e.colors.accent.danger,t["--pkt-path"]=n.c3,t["--pkt-anon"]=e.colors.accent.secondary,t["--pkt-unknown"]=e.colors.status.muted,t["--route-flood"]=e.colors.accent.primary,t["--route-direct"]=e.colors.accent.secondary,t["--route-transport"]=n.c8,t["--chart-1"]=n.c1,t["--chart-2"]=n.c2,t["--chart-3"]=n.c3,t["--chart-4"]=n.c4,t["--chart-5"]=n.c5,t["--chart-6"]=n.c6,t["--chart-7"]=n.c7,t["--chart-8"]=n.c8,t["--chart-grid"]=n.grid,t["--chart-axis-tick"]=n.axis,t["--chart-cursor"]=n.cursor,t["--metric-received"]=e.colors.metric.received,t["--metric-forwarded"]=e.colors.metric.forwarded,t["--metric-transmitted"]=e.colors.metric.transmitted,t["--metric-dropped"]=e.colors.metric.dropped,t["--metric-neutral"]=e.colors.text.secondary,t["--log-debug"]=e.colors.status.muted,t["--log-info"]=e.colors.status.info,t["--log-warning"]=e.colors.status.warning,t["--log-error"]=e.colors.accent.danger,t["--log-critical"]=e.colors.accent.danger;const a=e.colors.map;t["--map-node-fill"]=a.nodeFill,t["--map-node-stroke"]=a.nodeStroke,t["--map-hub-color"]=a.hub,t["--map-local-color"]=a.local,t["--map-neighbor-color"]=a.neighbor,t["--map-mobile-color"]=a.mobile,t["--map-room-color"]=a.room,t["--map-edge-rest"]=a.edge,t["--map-edge-rest-bright"]=e.colors.border.strong,t["--map-edge-rest-dim"]=e.colors.bg.subtle,t["--map-edge-hover-direct"]=a.edgeHover,t["--map-edge-hover-loop"]=a.hub,t["--map-edge-hover-standard"]=e.colors.text.muted,t["--map-edge-hover-neighbor"]=a.local,t["--link-strong"]=e.colors.accent.success,t["--link-medium"]=e.colors.accent.secondary,t["--link-weak"]=e.colors.accent.danger,t["--hop-0"]=e.colors.accent.tertiary,t["--hop-1"]=e.colors.accent.success,t["--hop-2"]=n.c3,t["--hop-3"]=e.colors.accent.secondary,t["--hop-distant"]=e.colors.text.muted,t["--hop-hub"]=a.local,t["--icon-page-title"]=e.colors.accent.primary,t["--icon-card-title"]=e.colors.accent.primary,t["--icon-widget"]=e.colors.text.secondary,t["--icon-action"]=e.colors.text.secondary,t["--icon-nav"]=e.colors.text.muted,t["--icon-nav-active"]=e.colors.accent.primary,t["--toggle-on"]=e.colors.accent.success,t["--toggle-off"]=e.colors.bg.elevated,t["--font-title"]=e.typography.font.title,t["--font-display"]=e.typography.font.display,t["--font-data"]=e.typography.font.mono,t["--font-normal"]=String(e.typography.weight.normal),t["--font-medium"]=String(e.typography.weight.medium),t["--font-semibold"]=String(e.typography.weight.semibold),t["--font-bold"]=String(e.typography.weight.bold);const o=e.typography.size;o.xxl&&(t["--text-2xl"]=o.xxl),o.xl&&(t["--text-xl"]=o.xl),o.lg&&(t["--text-lg"]=o.lg),o.md&&(t["--text-md"]=o.md),o.base&&(t["--text-base"]=o.base),o.sm&&(t["--text-sm"]=o.sm),o.xs&&(t["--text-xs"]=o.xs),o.hero&&(t["--text-5xl"]=o.hero);const i=e.typography.tracking;return i&&(t["--tracking-tight"]=i.tight,t["--tracking-normal"]=i.normal,t["--tracking-wide"]=i.wide),t["--theme-transition"]=`${e.motion.slow} ${e.motion.easing}`,function(e){if(!A())return e;const t={},s=/^#[0-9A-Fa-f]{3,6}$/;for(const[n,a]of Object.entries(e))t[n]=s.test(a)?F(a):a;return t}(t)}(e),s=document.documentElement;for(const[n,a]of Object.entries(t))s.style.setProperty(n,a)}(t),document.documentElement.dataset.colorScheme=e}function $a({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return xe;try{let s=localStorage.getItem(we),n=localStorage.getItem(ke);const a=localStorage.getItem(ve);if(!s&&!n){const e=localStorage.getItem(Se);if(e){const t=be.find(t=>t.id===e);t&&(s=t.colorScheme,n=t.backgroundImage,localStorage.setItem(we,s),localStorage.setItem(ke,n),localStorage.removeItem(Se))}}const o=s&&"string"==typeof(t=s)&&ge.some(e=>e.id===t)?s:xe.colorScheme;let i=xe.backgroundImage;""===n?i="":n&&"string"==typeof(e=n)&&ye.some(t=>t.src===e)&&(i=n);let r=xe.brightness;if(a){const e=parseInt(a,10);!isNaN(e)&&e>=0&&e<=100&&(r=e)}return{colorScheme:o,backgroundImage:i,brightness:r}}catch{return xe}var e,t}());s.useEffect(()=>{Oa(t.colorScheme),Aa.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of Le){const e=De(`--palette-${t}-bright`),s=De(`--palette-${t}`),n=e||s;if(!n)continue;const a=Ne(n);for(const o of Me)Ie(`--palette-${t}-${o}`,a[o])}const e=De("--palette-bg-4");if(e){const t=Ne(e);for(const e of Me)Ie(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(we,e.colorScheme),localStorage.setItem(ke,e.backgroundImage),localStorage.setItem(ve,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{ye.forEach(e=>{(new Image).src=e.src})},[]);const o=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),i=s.useCallback(e=>{const t=ye.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),r=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),l=s.useCallback(e=>{const t=be.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:r,setThemePreset:l}),[t,o,i,r,l]);return n.jsx(Ba.Provider,{value:c,children:e})}function Wa(){const e=s.useContext(Ba);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const Ha="0.9.168",Ua="'JetBrains Mono', monospace",qa=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: ${Ua};\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,r={fontFamily:Ua,fontSize:.8*i+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:r,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"})]})}),Ga={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"},Ja={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},Ya={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 Va(e){return 1===e||0===e}const Ka="pymc_jwt_token",Xa="pymc_client_id",Qa="pymc_remember_me",Za=new Set;function eo(e){return Za.add(e),()=>Za.delete(e)}function to(e){for(const s of Za)try{s(e)}catch(t){}}function so(){let e=localStorage.getItem(Xa);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(Xa,e)),e}function no(){return"true"===localStorage.getItem(Qa)}function ao(e){e?localStorage.setItem(Qa,"true"):localStorage.removeItem(Qa)}function oo(){return no()?localStorage:sessionStorage}function io(){return oo().getItem(Ka)||localStorage.getItem(Ka)||sessionStorage.getItem(Ka)}function ro(e){oo().setItem(Ka,e),no()?sessionStorage.removeItem(Ka):localStorage.removeItem(Ka),to(e)}function lo(){localStorage.removeItem(Ka),sessionStorage.removeItem(Ka),to(null)}function co(){return!(!io()||ho()&&(lo(),1))}function uo(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 ho(){const e=io();if(!e)return!0;const t=uo(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function fo(){const e=io();if(!e)return 0;const t=uo(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function po(){const e=io();if(!e)return!1;const t=uo(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function mo(){const e=io();if(!e)return null;const t=uo(e);return t&&t.sub?t.sub:null}async function go(e,t,s=!1){ao(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:so()})}),n=s.headers.get("content-type");if(!n||!n.includes("application/json"))return{success:!1,error:`Server error: ${s.status}`};const a=await s.json();return a.success&&a.token?(ro(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function yo(){const e=io();if(!e)return!1;const t=uo(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:so()})});if(!t.ok){let e="";try{const s=await t.json();e=s.error||JSON.stringify(s)}catch{e=t.statusText}return!1}const s=await t.json();if(s.success&&s.token){ro(s.token);const e=uo(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 bo=null;async function xo(){const e=io();if(!e)return!1;const t=uo(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!po()||bo||(bo=yo().finally(()=>{bo=null}),bo)}function wo(){lo()}let ko=!1;function vo(){if(ko)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!io())return;if(ho())return lo(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=fo();e>0&&e<300&&await yo()};document.addEventListener("visibilitychange",e),ko=!0,"visible"===document.visibilityState&&e()}const So=Object.freeze(Object.defineProperty({__proto__:null,clearToken:lo,getClientId:so,getRememberMe:no,getToken:io,getTokenTimeRemaining:fo,getUsername:mo,isAuthenticated:co,isTokenExpired:ho,login:go,logout:wo,onTokenChange:eo,parseJWT:uo,refreshToken:yo,refreshTokenIfNeeded:xo,setRememberMe:ao,setToken:ro,shouldRefreshToken:po,startVisibilityBasedRefresh:vo},Symbol.toStringTag,{value:"Module"})),Co=new Map;let To=!1;async function Mo(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=Co.get(n);if(e)return e}const a=`${e}`;!s&&po()&&await yo();const o=io();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 r=(async()=>{const n=await fetch(a,{...t,headers:i});if(401===n.status){if(!s&&!To&&await yo())return Mo(e,t,!0);throw To||(To=!0,lo(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText} (${e})`);return n.json()})();return n&&(Co.set(n,r),r.finally(()=>{Co.delete(n)})),r}const Lo={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function _o(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 jo(e,t={}){return void 0!==e.airtime_ms&&e.airtime_ms>0?e.airtime_ms:function(e,t={}){const s=t.spreadingFactor??Lo.spreadingFactor,n=t.bandwidthHz??Lo.bandwidthHz,a=t.codingRate??Lo.codingRate,o=t.preambleLength??Lo.preambleLength??8,i=t.crcEnabled??Lo.crcEnabled?1:0,r=t.explicitHeader??Lo.explicitHeader?0:1,l=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*r,0),f=4*(s-2*l);return d+(8+Math.ceil(h/f)*a)*u}(_o(e),t)}function Po(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function Eo(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=Po(t.contact_type);return e}(await Mo("/api/stats"))}async function No(){return Mo("/api/logs")}async function Do(e=24){return Mo(`/api/noise_floor_history?hours=${e}`)}const Io=new Map;function Fo(e=!1){if(e)Io.clear();else for(const[t]of Io)parseInt(t.split("-")[0],10)<=60&&Io.delete(t)}function Ao(e,t,s,n){const a=60*e/t,o=Math.floor(Date.now()/1e3),i=Math.floor(o/a)*a,r=i-60*e,l=s.filter(e=>e.timestamp>=r&&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)??Lo.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??Lo.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??Lo.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??Lo.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):Lo,u=function(e,t,s,n,a){const o=new Array(t),i=new Array(t),r=new Array(t),l=new Array(t),c=new Array(t),u=new Array(t),d=new Array(t);for(let f=0;f=t)continue;const m=jo(h,a),g=h.packet_origin;if("tx_local"===g?(r[p].count++,r[p].airtime_ms+=m):"tx_forward"===g||h.transmitted?(l[p].count++,l[p].airtime_ms+=m):h.drop_reason&&(c[p].count++,c[p].airtime_ms+=m),"tx_local"!==g){o[p].count++,o[p].airtime_ms+=m,u[p].snr+=h.snr||0,u[p].rssi+=h.rssi||0,u[p].count++;const e=h.packet_hash;e&&!d[p].has(e)&&(d[p].add(e),i[p].count++,i[p].airtime_ms+=m)}}for(let f=0;f0&&(o[f].avg_snr=u[f].snr/u[f].count,o[f].avg_rssi=u[f].rssi/u[f].count);return{received:o,unique_received:i,transmitted:r,forwarded:l,dropped:c}}(l,t,r,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:r,end_time:i,...u}}async function Ro(){return Mo("/api/hardware_stats")}async function zo(e){return Mo("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function Bo(){return Mo("/api/send_advert",{method:"POST",body:"{}"})}async function Oo(e){return Mo("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function $o(e){return Mo("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}async function Wo(e){try{return await Mo("/api/log_level",{method:"POST",body:JSON.stringify({level:e})})}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}const Ho="pymc-packet-cache",Uo="pymc-packet-cache-meta",qo=36e5,Go=2592e5,Jo=6048e5,Yo=12096e5,Vo=5e3,Ko=5e5,Xo=new class{constructor(){t(this,"packets",new Map),t(this,"sortedPackets",[]),t(this,"sortedDirty",!0),t(this,"meta",{oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1}),t(this,"isLoading",!1),t(this,"isBackgroundLoading",!1),t(this,"isTopologyLoading",!1),t(this,"listeners",new Set),t(this,"loadProgress",null),t(this,"statusMessage",""),this.loadFromStorage()}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getState(){return{isLoading:this.isLoading,isBackgroundLoading:this.isBackgroundLoading,isTopologyLoading:this.isTopologyLoading,backgroundLoadComplete:this.meta.backgroundLoadComplete,topologyLoadComplete:this.meta.topologyLoadComplete,packetCount:this.packets.size,statusMessage:this.statusMessage,loadProgress:this.loadProgress,dataTier:this.meta.dataTier,threeDayLoadComplete:this.meta.threeDayLoadComplete,sevenDayLoadComplete:this.meta.sevenDayLoadComplete,fourteenDayLoadComplete:this.meta.fourteenDayLoadComplete}}getDataTier(){return this.meta.dataTier}getPackets(){return this.sortedDirty&&(this.sortedPackets=Array.from(this.packets.values()).sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),this.sortedDirty=!1),this.sortedPackets}isStale(){return 0===this.packets.size||Date.now()-this.meta.lastUpdated>qo}isHeavyLoadInProgress(){return this.isBackgroundLoading||this.isTopologyLoading}async initialLoad(e){if(this.isStale()&&this.packets.size>0&&this.clear(),this.meta.backgroundLoadComplete&&this.packets.size>0)return this.getPackets();this.isLoading=!0;const t=Date.now(),s=Math.floor((t-864e5)/1e3),n=3e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 24h history...",this.notifyListeners();try{let t;this.packets.size>0&&(this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta.oldestTimestamp=0,this.meta.newestTimestamp=0);let a=0,o=0,i=0;const r=Math.ceil(100);for(let l=0;l0))break;{const n=this.packets.size;this.mergePackets(u.data);const i=this.packets.size-n;a+=i;const r=Math.min(...u.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===t||r=2)break}else o=0;if(u.data.length=Ko)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,this.meta.dataTier="24h",this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.saveToStorage()}catch(a){this.statusMessage="Load failed"}finally{this.isLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}return this.getPackets()}async quickLoad(){return this.initialLoad()}async backgroundLoad(){await this.initialLoad()}async loadThreeDays(e){this.meta.threeDayLoadComplete||this.isBackgroundLoading||await this.loadExtendedData("3d",Go,e)}async loadSevenDays(e){this.meta.sevenDayLoadComplete||this.isBackgroundLoading||(this.meta.threeDayLoadComplete||await this.loadThreeDays(e),await this.loadExtendedData("7d",Jo,e))}async loadFourteenDays(e){this.meta.fourteenDayLoadComplete||this.isBackgroundLoading||(this.meta.sevenDayLoadComplete||await this.loadSevenDays(e),await this.loadExtendedData("14d",Yo,e))}async loadExtendedData(e,t,s){this.isBackgroundLoading=!0;const n=Date.now(),a=Math.floor((n-t)/1e3),o=3e4*("3d"===e?2:"7d"===e?4:7);this.loadProgress={loaded:0,target:o,percent:0},this.statusMessage=`Loading ${e} history...`,this.notifyListeners();try{let t=this.meta.oldestTimestamp||void 0,n=0,i=0,r=0;const l=Math.ceil(100);for(let u=0;u0))break;{const e=this.packets.size;this.mergePackets(d.data);const o=this.packets.size-e;n+=o;const r=Math.min(...d.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===t||r=2)break}else i=0;if(d.data.length=Ko)break}u=5)break;await this.delay(2e3)}}this.enforceMemoryCap();const c=Date.now()-1e3*this.meta.oldestTimestamp;"3d"===e?(this.meta.threeDayLoadComplete=c>=Go,this.meta.threeDayLoadComplete&&(this.meta.dataTier="3d")):"7d"===e?(this.meta.sevenDayLoadComplete=c>=Jo,this.meta.sevenDayLoadComplete&&(this.meta.dataTier="7d")):(this.meta.fourteenDayLoadComplete=c>=Yo,this.meta.fourteenDayLoadComplete&&(this.meta.dataTier="14d")),this.loadProgress={loaded:n,target:n,percent:100},this.notifyListeners(),this.saveToStorage()}catch(i){this.statusMessage=`${e} load failed`}finally{this.isBackgroundLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}isDataTierAvailable(e){switch(e){case"24h":return this.meta.backgroundLoadComplete;case"3d":return this.meta.threeDayLoadComplete;case"7d":return this.meta.sevenDayLoadComplete;case"14d":return this.meta.fourteenDayLoadComplete;default:return!1}}async topologyLoad(){if(!this.meta.topologyLoadComplete&&!this.isTopologyLoading)return this.doTopologyLoad()}async forceTopologyLoad(){if(!this.isTopologyLoading)return this.meta.topologyLoadComplete=!1,this.doTopologyLoad()}async forceDeepLoad(){return this.forceTopologyLoad()}async doTopologyLoad(){this.isTopologyLoading=!0;const e=Date.now(),t=Math.floor((e-Yo)/1e3),s=42e4;this.statusMessage="Loading topology data...",this.loadProgress={loaded:this.packets.size,target:s,percent:0},this.notifyListeners();try{let e=this.meta.oldestTimestamp||void 0,n=0,a=0;const o=Math.ceil(100);for(let i=0;i0))break;{const s=this.packets.size;this.mergePackets(l.data);const a=this.packets.size-s,o=Math.min(...l.data.map(e=>e.timestamp??1/0));if(o!==1/0&&(void 0===e||o=2)break}else n=0;if(this.packets.size>=Ko)break}i=5)break;await this.delay(2e3)}}this.enforceMemoryCap(),this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.meta.topologyLoadComplete=!0,this.meta.threeDayLoadComplete=!0,this.meta.sevenDayLoadComplete=!0,this.meta.fourteenDayLoadComplete=!0,this.meta.dataTier="14d",this.saveToStorage()}catch(n){this.statusMessage="Load failed"}finally{this.isTopologyLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}async poll(){try{const e=await this.fetchRecentPackets(100);if(e.success&&e.data){const t=this.packets.size;this.mergePackets(e.data),this.packets.size>t&&(this.saveToStorage(),this.notifyListeners())}}catch(e){}return this.getPackets()}clear(){this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta={oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1},this.clearStorage(),this.notifyListeners()}mergePacketsDirectly(e){const t=this.packets.size;this.mergePackets(e);const s=this.packets.size-t;return s>0&&(this.enforceMemoryCap(),this.saveToStorage(),this.notifyListeners()),s}mergePackets(e){let t=!1;for(const s of e){const e=s.packet_hash;if(!e)continue;const n=s.timestamp??0,a=`${e}:${n}`;this.packets.has(a)||(this.packets.set(a,s),t=!0),(0===this.meta.oldestTimestamp||nthis.meta.newestTimestamp&&(this.meta.newestTimestamp=n)}t&&(this.sortedDirty=!0),this.meta.lastUpdated=Date.now(),this.meta.packetCount=this.packets.size}notifyListeners(){const e=this.getState();for(const t of this.listeners)t(e)}delay(e){return new Promise(t=>setTimeout(t,e))}async fetchChunkWithRetry(e,t,s,n,a){for(let 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<=Ko)return;const e=this.getPackets(),t=e.length-Ko;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Uo);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(Ho);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>qo)return void this.clear();this.meta.backgroundLoadComplete=!1,this.meta.threeDayLoadComplete=!1,this.meta.sevenDayLoadComplete=!1,this.meta.fourteenDayLoadComplete=!1,this.meta.dataTier="24h";const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(Ho,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(Ho),localStorage.setItem(Uo,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(Ho),localStorage.removeItem(Uo)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await N(async()=>{const{getToken:e}=await Promise.resolve().then(()=>So);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 N(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>So);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 N(async()=>{const{getToken:e}=await Promise.resolve().then(()=>So);return{getToken:e}},void 0),r=i(),l={};r&&(l.Authorization=`Bearer ${r}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(o,{headers:l,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await N(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>So);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 Qo(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Zo(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const ei=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:Zo(),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?Qo(t.pathRegistry):Zo(),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,r){const l={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:o,zeroHopNeighbors:i,terrainGrid:r,enableTerrainAware:void 0!==r};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=l:this.computeInternal(l)},this.debounceMs)}subscribe(e){return this.listeners.add(e),this.currentTopology.edges.length>0&&e(this.currentTopology,0),()=>{this.listeners.delete(e)}}getTopology(){return this.currentTopology}isWorking(){return this.isComputing}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},ti=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()}},si=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=eo(e=>{this.setAuthToken(e)}),await this.readyPromise}catch(t){throw t}}}handleMessage(e){var t;const s=e.data;switch(s.type){case"ready":null==(t=this.readyResolve)||t.call(this);break;case"stats":for(const e of this.statsListeners)try{e(s.data,s.timestamp)}catch(n){}break;case"packets":for(const e of this.packetsListeners)try{e(s.newPackets,s.totalCount,s.newestTimestamp)}catch(n){}break;case"packetsReset":for(const e of this.packetsListeners)try{e([],0,s.newestTimestamp)}catch(n){}break;case"error":for(const e of this.errorListeners)try{e(s.source,s.error)}catch(n){}}}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onPackets(e){return this.packetsListeners.add(e),()=>this.packetsListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}setAuthToken(e){if(!this.worker)return;const t={type:"setAuth",token:e};this.worker.postMessage(t)}setLiveMode(e){if(!this.worker)return;const t={type:"setLiveMode",enabled:e};this.worker.postMessage(t)}forceRefresh(){this.worker&&this.worker.postMessage({type:"forceRefresh"})}clearCache(){this.worker&&this.worker.postMessage({type:"clearCache"})}setTimeWindow(e){if(!this.worker)return;const t={type:"setTimeWindow",hours:e};this.worker.postMessage(t)}terminate(){if(this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.worker){const e={type:"stop"};this.worker.postMessage(e),this.worker.terminate(),this.worker=null}this.isInitialized=!1,this.statsListeners.clear(),this.packetsListeners.clear(),this.errorListeners.clear()}isReady(){return this.isInitialized}},ni=new class{constructor(){t(this,"ws",null),t(this,"connectionState","disconnected"),t(this,"reconnectAttempts",0),t(this,"pingIntervalId",null),t(this,"lastPongTime",Date.now()),t(this,"reconnectTimeoutId",null),t(this,"packetListeners",new Set),t(this,"statsListeners",new Set),t(this,"systemStatsListeners",new Set),t(this,"packetStatsListeners",new Set),t(this,"connectionListeners",new Set),t(this,"unsubscribeTokenChange",null),t(this,"wsSupported",!0)}buildWsUrl(){const e=io(),t=so(),s=new URLSearchParams;e&&s.set("token",e),t&&s.set("client_id",t);const n=s.toString()?`?${s.toString()}`:"";return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws/packets${n}`}connect(){var e,t;if((null==(e=this.ws)?void 0:e.readyState)!==WebSocket.OPEN&&(null==(t=this.ws)?void 0:t.readyState)!==WebSocket.CONNECTING&&this.wsSupported){this.setConnectionState("connecting");try{const e=this.buildWsUrl();this.ws=new WebSocket(e),this.ws.onopen=this.handleOpen.bind(this),this.ws.onmessage=this.handleMessage.bind(this),this.ws.onerror=this.handleError.bind(this),this.ws.onclose=this.handleClose.bind(this),this.unsubscribeTokenChange||(this.unsubscribeTokenChange=eo(e=>{e&&"connected"===this.connectionState&&(this.disconnect(),this.connect())}))}catch(s){this.wsSupported=!1,this.setConnectionState("disconnected")}}}disconnect(){this.clearPingInterval(),this.clearReconnectTimeout(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING||this.ws.close(1e3,"Client disconnect"),this.ws=null),this.setConnectionState("disconnected"),this.reconnectAttempts=0}isConnected(){var e;return(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}isSupported(){return this.wsSupported}send(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return!1}}onPacket(e){return this.packetListeners.add(e),()=>this.packetListeners.delete(e)}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onSystemStats(e){return this.systemStatsListeners.add(e),()=>this.systemStatsListeners.delete(e)}onPacketStats(e){return this.packetStatsListeners.add(e),()=>this.packetStatsListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),e(this.connectionState,this.reconnectAttempts),()=>this.connectionListeners.delete(e)}handleOpen(){this.setConnectionState("connected"),this.reconnectAttempts=0,this.lastPongTime=Date.now();const e=io();e&&this.ws&&this.ws.send(JSON.stringify({type:"auth",token:e})),this.startPingInterval()}handleMessage(e){try{const t=JSON.parse(e.data);switch(t.type){case"packet":this.notifyPacketListeners(t.data);break;case"stats":{const e=t.data;e&&"noise_floor_dbm"in e&&this.notifyStatsListeners(e),(null==e?void 0:e.packet_stats)&&this.notifyPacketStatsListeners(e.packet_stats),(null==e?void 0:e.system_stats)&&this.notifySystemStatsListeners(e.system_stats);break}case"packet_stats":{const e=t.data;this.notifyPacketStatsListeners(e);break}case"system_stats":this.notifySystemStatsListeners(t.data);break;case"ping":this.lastPongTime=Date.now(),this.send({type:"pong"});break;case"pong":this.lastPongTime=Date.now()}}catch(t){}}handleError(e){}handleClose(e){this.clearPingInterval(),1e3!==e.code?(1006===e.code&&this.reconnectAttempts,this.scheduleReconnect()):this.setConnectionState("disconnected")}setConnectionState(e){if(this.connectionState!==e){this.connectionState=e;for(const s of this.connectionListeners)try{s(e,this.reconnectAttempts)}catch(t){}}}notifyPacketListeners(e){for(const s of this.packetListeners)try{s(e)}catch(t){}}notifyStatsListeners(e){for(const s of this.statsListeners)try{s(e)}catch(t){}}notifySystemStatsListeners(e){for(const s of this.systemStatsListeners)try{s(e)}catch(t){}}notifyPacketStatsListeners(e){for(const s of this.packetStatsListeners)try{s(e)}catch(t){}}startPingInterval(){this.clearPingInterval(),this.pingIntervalId=setInterval(()=>{var e;(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN&&(this.send({type:"ping"}),Date.now()-this.lastPongTime>6e4&&(this.disconnect(),this.connect()))},3e4)}clearPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null)}scheduleReconnect(){if(this.reconnectAttempts>=20)return this.wsSupported=!1,void this.setConnectionState("disconnected");this.setConnectionState("reconnecting");const e=Math.min(1e3*Math.pow(2,Math.min(this.reconnectAttempts,5)),3e4);this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout(()=>{this.reconnectTimeoutId=null,this.connect()},e)}clearReconnectTimeout(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)}terminate(){this.disconnect(),this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.packetListeners.clear(),this.statsListeners.clear(),this.systemStatsListeners.clear(),this.packetStatsListeners.clear(),this.connectionListeners.clear()}},ai=3e4,oi=new class{constructor(){t(this,"staged",new Map),t(this,"recentlyConfirmed",new Map),t(this,"listeners",new Set),t(this,"pruneIntervalId",null),this.startPruneInterval()}stage(e){const t=e.packet_hash;if(!t)return;if(this.staged.has(t))return;const s=this.recentlyConfirmed.get(t);s&&Date.now()-s=100&&this.removeOldest(),this.staged.set(t,{packet:e,stagedAt:Date.now()}),this.notifyListeners())}confirm(e){this.staged.delete(e)&&this.notifyListeners()}confirmBatch(e){let t=!1;const s=Date.now();for(const n of e)this.recentlyConfirmed.set(n,s),this.staged.delete(n)&&(t=!0);if(this.recentlyConfirmed.size>200){const e=s-ai;for(const[t,s]of this.recentlyConfirmed)s(t.packet.timestamp??0)-(e.packet.timestamp??0))}isPending(e){return!!e&&this.staged.has(e)}getPendingCount(){return this.staged.size}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clear(){this.staged.size>0&&(this.staged.clear(),this.notifyListeners())}terminate(){this.stopPruneInterval(),this.staged.clear(),this.listeners.clear()}notifyListeners(){const e=this.getPendingPackets();for(const s of this.listeners)try{s(e)}catch(t){}}pruneExpired(){const e=Date.now();let t=!1;for(const[s,n]of this.staged)e-n.stagedAt>ai&&(this.staged.delete(s),t=!0);t&&this.notifyListeners()}removeOldest(){let e=null,t=1/0;for(const[s,n]of this.staged)n.stagedAtthis.pruneExpired(),1e4))}stopPruneInterval(){this.pruneIntervalId&&(clearInterval(this.pruneIntervalId),this.pruneIntervalId=null)}},ii=a(e=>({connectionState:"disconnected",isSupported:!0,reconnectAttempt:0,lastConnected:null,initialize:()=>{ni.onConnectionChange((t,s)=>{e(e=>({connectionState:t,reconnectAttempt:s??0,isSupported:ni.isSupported(),lastConnected:"connected"===t?Date.now():e.lastConnected}))}),ni.connect()}})),ri=.05,li=1e3,ci="terrarium";function ui(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const di=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(ci)||(n.addSource(ci,{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===ci&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:ci}),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),r=Math.ceil((n-s)/.001);i>li&&(i=li),r>li&&(r=li);const l=(o-a)/i,c=(n-s)/r,u=Math.max(l,c),d=new Float32Array(i*r);let h=0;for(let f=0;fsetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:i,height:r,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(r){const t=r instanceof Error?r.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-ri,maxLat:n+ri,minLng:a-ri,maxLng:o+ri}}(e);n&&await t().loadTerrain(n,s)},clearTerrain:()=>{e({terrainGrid:null,cachedBounds:null,lastLoadedAt:null,error:null})},setTerrainDisambiguationEnabled:t=>{e({terrainDisambiguationEnabled:t})},getTerrainGridForDisambiguation:()=>{const e=t();return e.terrainDisambiguationEnabled?e.terrainGrid:null}}));function hi(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function fi(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?hi(t):null,o=n[n.length-1],i=null!==a&&o===a,r=i?n.slice(0,-1):[...n];return{effective:r,original:n,hadLocal:i,effectiveLength:r.length}}function pi(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const mi=[{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},{label:"14d",minutes:20160,buckets:168}],gi=[{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 yi(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 bi="'JetBrains Mono', 'SF Mono', Monaco, monospace",xi={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},wi={DEBUG:"text-accent-tertiary",INFO:"text-accent-primary",WARNING:"text-signal-critical",ERROR:"text-accent-danger",CRITICAL:"text-signal-poor"};function ki(e){return wi[e]??"text-text-muted border-border-subtle"}const vi="pymc-resource-history",Si="pymc-resource-last-fetch",Ci="pymc-hidden-contacts",Ti="pymc-quick-neighbors",Mi="pymc-local-hash",Li="pymc-global-time-range";let _i=null,ji=null;function Pi(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function Ei(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:Va(s)?t.length<=1:0===t.length;var n}(e)}function Ni(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 Di(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 Ii(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function Fi(e,t){const s=Pi(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:hi(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 Ai(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Ti);if(e)return JSON.parse(e)}catch{}return[]}function Ri(e){"undefined"!=typeof window&&(ji&&clearTimeout(ji),ji=setTimeout(()=>{try{localStorage.setItem(Ti,JSON.stringify(e))}catch{}ji=null},1e3))}function zi(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Mi);if(e)return e}catch{}}function Bi(e){if("undefined"!=typeof window)try{localStorage.setItem(Mi,e)}catch{}}function Oi(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(vi);if(e)return JSON.parse(e)}catch{}return[]}function $i(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(Ci);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Wi(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(Si);if(e)return parseInt(e,10)||0}catch{}return 0}function Hi(){if("undefined"==typeof window)return 4;try{const e=localStorage.getItem(Li);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<=7)return t}}catch{}return 4}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,pendingAdvertLocalHash:null,pendingAdvertTimestamp:null,resourceHistory:Oi(),lastResourceFetch:Wi(),hiddenContacts:$i(),quickNeighbors:Ai(),cachedLocalHash:zi(),initialized:!1,packetCacheState:Xo.getState(),mutationsInFlight:new Set,globalTimeRangeIndex:Hi(),initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),Xo.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await Eo(),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=Pi(t.last_seen??0,o);"expired"!==n&&i.push({hash:e,prefix:hi(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 r=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:i,cachedLocalHash:r}),Ri(i),r&&Bi(r);const l=()=>{const s=Xo.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 Xo.initialLoad(l);if(c.length>0){const s=c.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...c],packetsLoading:!1,lastPacketTimestamp:s}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}else e({packetsLoading:!1})}catch(n){e({statsError:n instanceof Error?n.message:"Failed to initialize",statsLoading:!1,packetsLoading:!1})}ii.getState().initialize(),ni.onPacket(s=>{const{lastPacketTimestamp:n,mutationsInFlight:a}=t();if(a.size>0)return;oi.stage(s);const o=s.timestamp??0;o>n&&e({flashReceived:t().flashReceived+1,lastPacketTimestamp:o})}),ni.onStats(s=>{const{mutationsInFlight:n,hiddenContacts:a}=t();if(n.size>0)return;const o=s.neighbors??{},i=Date.now(),r=[];for(const[e,t]of Object.entries(o)){if(a.has(e))continue;if(!t.zero_hop)continue;const s=Pi(t.last_seen??0,i);"expired"!==s&&r.push({hash:e,prefix:hi(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 l=s.local_hash;e({stats:s,statsLoading:!1,quickNeighbors:r,cachedLocalHash:l}),Ri(r),l&&Bi(l)}),ni.onPacketStats(s=>{const{stats:n,mutationsInFlight:a}=t();if(!n||a.size>0)return;const o={...n,rx_count:s.rx_count??n.rx_count,tx_count:s.tx_count??n.tx_count,forwarded_count:s.forwarded_count??n.forwarded_count,dropped_count:s.dropped_count??n.dropped_count};e({stats:o})});try{await si.init({apiBaseUrl:"",authToken:io()??void 0,statsIntervalMs:xi.stats,packetsIntervalMs:xi.packets}),si.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:o}=t();if(a.size>0)return;const i=s.neighbors??{},r=Date.now(),l=[];for(const[e,t]of Object.entries(i)){if(o.has(e))continue;if(!t.zero_hop)continue;const s=Pi(t.last_seen??0,r);"expired"!==s&&l.push({hash:e,prefix:hi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const c=s.local_hash;e({stats:s,statsLoading:!1,quickNeighbors:l,cachedLocalHash:c}),Ri(l),c&&Bi(c)}),si.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:o}=t(),i=s.map(e=>e.packet_hash).filter(e=>!!e);oi.confirmBatch(i),Xo.mergePacketsDirectly(s);const r=a>o;r&&Fo();const l=Xo.getPackets();e({packets:l,packetsLoading:!1,lastPacketTimestamp:a}),r&&t().triggerTopologyCompute()}),si.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||si.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},xi.stats),setInterval(()=>{e().liveMode&&!Xo.isHeavyLoadInProgress()&&e().fetchPackets()},xi.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":No().catch(()=>{});break;case"/system":Ro().catch(()=>{});break;case"/statistics":(async function(e=24){return Mo(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),Do(3).catch(()=>{});break;case"/settings":(async function(){return Mo("/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 Eo(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,r]of Object.entries(s)){if(o.has(e))continue;if(!r.zero_hop)continue;const t=Pi(r.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:hi(e),count:r.advert_count??0,avgRssi:r.rssi??null,avgSnr:r.snr??null,lastSeen:r.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}),Ri(a),i&&Bi(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 Xo.poll(),o=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,i=o>a&&a>0,r=s.length!==n.length||i;i&&(e({flashReceived:t().flashReceived+1}),Fo()),e(r?{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 No();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),si.isReady()&&si.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Oo(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 $o(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 Mo("/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(r){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),r}},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 Bo();return s.success?(e({flashAdvert:t().flashAdvert+1}),{success:!0}):{success:!1,error:s.error||"Failed to send advert"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Unknown error"}}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const o=Date.now(),{lastResourceFetch:i,resourceHistory:r}=t();if(o-i<1e3)return;const l=[...r,{timestamp:o,time:new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=l.length>a?l.slice(-a):l;var u,d;e({resourceHistory:c,lastResourceFetch:o}),u=c,d=o,"undefined"!=typeof window&&(_i&&clearTimeout(_i),_i=setTimeout(()=>{try{localStorage.setItem(vi,JSON.stringify(u)),localStorage.setItem(Si,d.toString())}catch{}_i=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(Ci,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{Xo.clear(),e({packets:[],lastPacketTimestamp:0}),Xo.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:r}=t();if(0===o.length||!i)return;const l=i.neighbors??{},c=Object.fromEntries(Object.entries(l).filter(([e])=>!r.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=di.getState().getTerrainGridForDisambiguation();ei.compute(o,c,u,d,h,void 0,f,p??void 0)},triggerDeepAnalysis:async()=>{await Xo.forceDeepLoad();const s=Xo.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=hi(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=hi(a),i=n.get(o);if(i){const r=null==(t=e[i])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!r&&n.set(o,a)}else n.set(o,a)}return n}(t),r=new Map;for(const c of e){if(!Ei(c))continue;const e=Ni(c.src_hash,a,i,o,s);if(!e)continue;let t=r.get(e);t||(t=Ii(e),r.set(e,t)),Di(t,c)}for(const[c,u]of Object.entries(t))u.zero_hop&&!r.has(c)&&r.set(c,{hash:c,count:u.advert_count??0,rssiSum:u.rssi??0,rssiCount:void 0!==u.rssi?1:0,snrSum:u.snr??0,snrCount:void 0!==u.snr?1:0,lastSeen:u.last_seen??0});const l=[];for(const c of r.values()){const e=Fi(c,n);e&&l.push(e)}return l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),l}(s,Object.fromEntries(Object.entries(o).filter(([e])=>!a.has(e))),n.local_hash),r=t().quickNeighbors;(i.length!==r.length||i.some((e,t)=>{var s,n;return e.hash!==(null==(s=r[t])?void 0:s.hash)||e.count!==(null==(n=r[t])?void 0:n.count)}))&&(e({quickNeighbors:i}),Ri(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&&ti.compute(e,o)},requestSevenDayData:async()=>{await Xo.loadSevenDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestThreeDayData:async()=>{await Xo.loadThreeDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestFourteenDayData:async()=>{await Xo.loadFourteenDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},setGlobalTimeRange:s=>{e({globalTimeRangeIndex:s}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(Li,e.toString())}catch{}}(s);const n={0:1,1:1,2:3,3:12,4:24,5:72,6:168,7:336}[s]??24;si.setTimeWindow(n);const{packetCacheState:a,requestThreeDayData:o,requestSevenDayData:i,requestFourteenDayData:r,triggerTopologyCompute:l,triggerSparklineCompute:c}=t();let u=!1;5!==s||a.threeDayLoadComplete||a.isBackgroundLoading||(o(),u=!0),6!==s||a.sevenDayLoadComplete||a.isBackgroundLoading||(i(),u=!0),7!==s||a.fourteenDayLoadComplete||a.isBackgroundLoading||(r(),u=!0),!u&&s>=5&&(l(),c())}})),qi=Ui,Gi=()=>Ui(e=>e.stats),Ji=()=>Ui(e=>e.statsError),Yi=()=>Ui(e=>e.packets),Vi=()=>Ui(e=>e.packetsLoading),Ki=()=>Ui(e=>e.logs),Xi=()=>Ui(e=>e.logsLoading),Qi=()=>Ui(e=>e.liveMode),Zi=()=>Ui(e=>e.fetchLogs),er=()=>Ui(e=>e.setLiveMode),tr=()=>Ui(e=>e.resourceHistory),sr=()=>Ui(e=>e.addResourceDataPoint),nr=()=>Ui(e=>e.hiddenContacts),ar=()=>Ui(e=>e.hideContact),or=()=>Ui(e=>e.packetCacheState),ir=()=>Ui(e=>e.triggerDeepAnalysis),rr=()=>Ui(e=>e.quickNeighbors),lr=()=>Ui(e=>e.cachedLocalHash),cr=()=>Ui(e=>e.lastPacketTimestamp),ur=()=>Ui(e=>e.globalTimeRangeIndex),dr=()=>Ui(e=>e.setGlobalTimeRange),hr=()=>Ui(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete),fr={rx:{p3:"color(display-p3 0.2 1 0.4)",fallback:"#00FF66"},tx:{p3:"color(display-p3 1 0.9 0.2)",fallback:"#FFDD00"},idle:{p3:"color(display-p3 0.4 0.4 0.45)",fallback:"#666677"}};function pr({showLabel:e=!1,className:t}){var a;const o=Ui(e=>e.flashReceived),i=Ui(e=>e.flashAdvert),r=ii(e=>"connected"===e.connectionState),[l,c]=s.useState("idle"),u=s.useRef(0),d=s.useRef(0);s.useEffect(()=>{if(o<=0)return;const e=Date.now();if(e-u.current<50)return;u.current=e,c("rx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[o]),s.useEffect(()=>{if(i<=0)return;const e=Date.now();if(e-d.current<50)return;d.current=e,c("tx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[i]);const h="rx"===l?fr.rx:"tx"===l?fr.tx:fr.idle;return n.jsxs("span",{className:D("inline-flex items-center gap-2",t),title:r?"Real-time (WebSocket)":"Database polling",children:[n.jsx("span",{className:"inline-flex rounded-full w-1.5 h-1.5",style:{backgroundColor:h.fallback,...(null==(a=CSS.supports)?void 0:a.call(CSS,"color","color(display-p3 1 1 1)"))&&{backgroundColor:h.p3}}}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:r?"Live":"DB"})]})}function mr({children:e,isLoading:t=!0,className:s,borderRadius:a=12}){return n.jsxs("div",{className:D("relative overflow-hidden",s),style:{borderRadius:a},children:[t&&n.jsx("div",{className:"shimmer-border",style:{borderRadius:a}}),n.jsx("div",{className:"relative z-10",children:e})]})}function gr({className:e}){return n.jsx("div",{className:D("shimmer-indicator",e),children:n.jsx("div",{className:"shimmer-indicator-inner"})})}const yr=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(()=>{ti.subscribe((e,t)=>{const s=yr.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const br=()=>yr(e=>e.isComputing),xr=[],wr=new Map;function kr(e){return yr(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return xr;const n=wr.get(e);return n===s?n:(wr.set(e,s),s)})}const vr=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:Zo(),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&&ei.subscribe((e,t)=>{vr.getState().setTopology(e,t)});const Sr=()=>vr(e=>e.topology),Cr=()=>vr(e=>e.topology.hubNodes),Tr=()=>vr(e=>e.topology.centrality),Mr=()=>vr(e=>e.topology.fullAffinity);let Lr=null,_r=null,jr=null,Pr=null;const Er=()=>vr(e=>(e.topology.hubNodes!==_r&&(_r=e.topology.hubNodes,Lr=new Set(e.topology.hubNodes)),Lr)),Nr=()=>vr(e=>e.topology.pathHealth),Dr=()=>vr(e=>e.topology.disambiguationStats),Ir=()=>vr(e=>e.topology.disambiguationStats.highCollisionPrefixes),Fr=()=>vr(e=>e.topology.disambiguationStats.totalPrefixes>0),Ar=()=>vr(e=>e.topology.discoveredNodes),Rr=()=>vr(e=>e.topology.viterbiStats),zr=()=>vr(e=>(e.topology.discoveredNodes!==Pr&&(Pr=e.topology.discoveredNodes,jr=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),jr));function Br(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 Or(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 $r(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 Wr(e){return new Date(1e3*e).toLocaleString()}function Hr(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 Ur(e){return`${(e/1e6).toFixed(3)} MHz`}function qr(e){return`${(e/1e3).toFixed(1)} kHz`}function Gr(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),r=Math.floor(i/24);return r>0?`${r} day${1!==r?"s":""}`:i>0?`${i} hour${1!==i?"s":""}`:o>0?`${o} minute${1!==o?"s":""}`:`${a} second${1!==a?"s":""}`}const Jr=[{name:"Dashboard",to:"/",icon:l},{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}],Yr="pymc-controls-expanded";function Vr(){var e,t,a,l;const{pathname:c}=o(),{stats:u,setMode:d,setDutyCycle:f,sendAdvert:p}=qi(),m=mo(),M=Ui(e=>e.prefetchForRoute),L=or(),_=Ui(e=>e.packetCacheState.dataTier),j=br(),P=vr(e=>e.isComputing),E=zr(),[N,I]=s.useState(!1),[F,A]=s.useState(!0),[R,z]=s.useState(!1),[B,O]=s.useState("idle"),[$,W]=s.useState(null),H=s.useRef(null),U=s.useCallback(e=>{e!==c&&(H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{M(e)},100))},[c,M]),q=s.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]);s.useEffect(()=>{const e=localStorage.getItem(Yr);null!==e&&queueMicrotask(()=>A("true"===e))},[]);const G=()=>{const e=!F;A(e),localStorage.setItem(Yr,String(e))};s.useEffect(()=>{queueMicrotask(()=>I(!1))},[c]),s.useEffect(()=>(document.body.style.overflow=N?"hidden":"",()=>{document.body.style.overflow=""}),[N]);const J=null==u?void 0:u.noise_floor_dbm,Y=(null==(t=null==(e=null==u?void 0:u.config)?void 0:e.repeater)?void 0:t.mode)??"forward",V=(null==(l=null==(a=null==u?void 0:u.config)?void 0:a.duty_cycle)?void 0:l.enforcement_enabled)??!1,K=async()=>{z(!0),O("idle"),W(null);const e=await p();z(!1),e.success?(O("success"),setTimeout(()=>O("idle"),1500)):(O("error"),W(e.error||"Failed to send"),setTimeout(()=>{O("idle"),W(null)},3e3))},X=()=>{d("forward"===Y?"monitor":"forward")},Q=()=>{f(!V)},Z=()=>{wo(),window.location.href="/login"},ee=L.isLoading||L.isBackgroundLoading||L.isTopologyLoading,te=ee||j||P,se=L.loadProgress,ne=e=>{switch(e){case"24h":return"24 hours";case"3d":return"3 days";case"7d":return"7 days";case"14d":return"14 days";default:return e}},ae=()=>{if(!te)return null;let e="Analyzing database";L.isLoading&&se?e="Loading 24h history...":L.isBackgroundLoading&&se?e=L.statusMessage||`Loading ${_} history...`:L.isTopologyLoading?e="Loading topology data...":j?e="Computing sparklines":P&&(e="Building topology");const t=(null==se?void 0:se.percent)??null,s=null!==t&ⅇreturn n.jsx("div",{className:"px-3 pb-2",children:n.jsx(mr,{isLoading:ee,borderRadius:12,children:n.jsxs("div",{className:"bg-glass-surface/50 rounded-xl p-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[n.jsxs("div",{className:"relative flex h-2 w-2",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-accent-primary"})]}),n.jsx("span",{className:"type-data-xs text-text-muted flex-1 truncate",children:e}),s&&n.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[t,"%"]})]}),n.jsx("div",{className:"mt-1.5 h-1 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/40 rounded-full",style:{width:"100%"}})}),!ee&&n.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"type-micro text-text-muted",children:"Data:"}),n.jsx("span",{className:"type-data-xs text-accent-primary",children:ne(_)})]})]})})})},oe=()=>n.jsx("nav",{className:"flex-1 px-3 py-4 space-y-1 overflow-y-auto",children:Jr.map(e=>{const t=c===e.to;return n.jsxs(g,{to:e.to,onClick:()=>I(!1),onMouseEnter:()=>U(e.to),onMouseLeave:q,className:D("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:D("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&&E.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:E.length})]})]},e.name)})}),ie=()=>n.jsxs("div",{className:"px-3 py-3",children:[n.jsxs("button",{onClick:G,className:"w-full flex items-center justify-between px-3 py-1.5 mb-2 rounded-lg hover:bg-white/5 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(b,{className:"w-5 h-5 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Controls"})]}),n.jsx(x,{className:D("w-4 h-4 text-text-muted transition-transform duration-200",F?"rotate-0":"-rotate-90")})]}),n.jsx("div",{className:D("overflow-hidden transition-all duration-300 ease-out",F?"max-h-96 opacity-100":"max-h-0 opacity-0"),children:n.jsxs("div",{className:"control-panel-skeuo",children:[n.jsxs("button",{onClick:K,disabled:R,className:D("control-btn control-btn-primary w-full transition-all duration-300",R&&"opacity-70","success"===B&&"ring-2 ring-accent-success ring-offset-1 ring-offset-transparent","error"===B&&"ring-2 ring-accent-danger ring-offset-1 ring-offset-transparent"),children:[n.jsx(w,{className:D("w-4 h-4",R&&"animate-pulse")}),n.jsx("span",{children:R?"Sending...":"success"===B?"Sent!":"error"===B?"Failed":"Send Advert"})]}),$&&n.jsx("div",{className:"text-accent-danger type-data-xs px-2 py-1 text-center",children:$}),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:D("control-toggle-status","forward"===Y?"text-accent-success":"text-accent-secondary"),children:"forward"===Y?"FWD":"MON"})]}),n.jsx("button",{onClick:X,className:D("control-btn w-full","forward"===Y?"control-btn-success":"control-btn-warning"),children:"forward"===Y?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:D("control-toggle-status",V?"text-accent-success":"text-text-muted"),children:V?"ON":"OFF"})]}),n.jsxs("button",{onClick:Q,className:D("control-btn w-full",V?"control-btn-success":"control-btn-neutral"),children:[n.jsx(h,{className:"w-4 h-4"}),n.jsx("span",{children:V?"Enabled":"Disabled"})]})]})]})})]}),re=()=>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-6 py-3 flex items-center gap-3",children:[n.jsx(S,{className:"w-5 h-5 text-text-muted flex-shrink-0"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[Br(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(C,{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!=J?`${J.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3 border-t border-white/5",children:[n.jsx(pr,{showLabel:!0}),(null==u?void 0:u.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted truncate max-w-[140px]",title:`v${u.version}`,children:["v",u.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:Z,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(T,{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 gap-2",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(qa,{height:26,className:"block"}),ee&&n.jsx(gr,{className:"ml-2"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",Ha]}),n.jsx(pr,{}),n.jsx("button",{onClick:()=>I(!N),className:"w-10 h-10 flex items-center justify-center rounded-xl hover:bg-white/5 active:bg-white/10 transition-colors","aria-label":N?"Close menu":"Open menu",children:N?n.jsx(i,{className:"w-5 h-5 text-text-primary"}):n.jsx(r,{className:"w-5 h-5 text-text-primary"})})]})]})}),n.jsx("div",{className:D("lg:hidden fixed inset-0 z-[10002] bg-black/60 backdrop-blur-sm transition-opacity duration-300",N?"opacity-100":"opacity-0 pointer-events-none"),onClick:()=>I(!1),"aria-hidden":"true"}),n.jsxs("aside",{className:D("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",N?"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(qa,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",Ha]})]}),oe(),ae(),ie(),re()]}),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(qa,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",Ha]})]}),oe(),ae(),ie(),re()]})]})}const Kr=s.memo(function(){const{theme:e}=Wa(),{backgroundImage:t,brightness:a}=e,[o,i]=s.useState(t),[r,l]=s.useState(!1);s.useEffect(()=>{if(t===o)return;if(!t)return void i("");const e=new Image;e.onload=()=>{l(!0),requestAnimationFrame(()=>{i(t),setTimeout(()=>l(!1),300)})},e.onerror=()=>{i(t)},e.src=t},[t,o]);const c=(100-a)/100;return n.jsxs(n.Fragment,{children:[o&&n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint",willChange:r?"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:r?.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"})]})}),Xr=20,Qr=12,Zr=s.createContext(null);function el({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),o=s.useRef(null),[i,r]=s.useState({x:0,y:0}),l=s.useCallback((e,t,s)=>{a({content:e,mouseX:t,mouseY:s,visible:!0})},[]),c=s.useCallback(()=>{a(e=>({...e,visible:!1}))},[]),u=s.useCallback((e,t)=>{a(s=>s.visible?{...s,mouseX:e,mouseY:t}:s)},[]);s.useEffect(()=>{if(!t.visible||!o.current)return;const e=o.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,i=window.innerHeight;let l,c;l=s+Xr+e.width+Qr>a?s-Xr-e.width:s+Xr,l=Math.max(Qr,Math.min(l,a-e.width-Qr)),c=n-Xr-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&&r(e.clientX,e.clientY)},[r]),p=s.useCallback(()=>{d(),u.current=!1,i()},[i]),m=s.useCallback(()=>{if(d(),!l.current)return;const t=l.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:l,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,onFocus:m,onBlur:g,className:"contents",children:t})}function sl({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function nl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-48"}),n.jsx(sl,{className:"h-8 w-32"})]}),n.jsx(sl,{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(sl,{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(sl,{className:"h-44"},t))}),n.jsx(sl,{className:"h-96"})]})}function al(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-40"}),n.jsx(sl,{className:"h-8 w-24"})]}),n.jsx(sl,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(sl,{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(sl,{className:"h-6"})},t))})]})]})}function ol(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-32"}),n.jsx(sl,{className:"h-6 w-48"})]}),n.jsx(sl,{className:"h-[500px]"}),n.jsx(sl,{className:"h-64"})]})}function il(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-36"}),n.jsx(sl,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(sl,{className:"h-80"}),n.jsx(sl,{className:"h-80"})]}),n.jsx(sl,{className:"h-64"})]})}function rl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(sl,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(sl,{className:"h-48"}),n.jsx(sl,{className:"h-64"}),n.jsx(sl,{className:"h-32"})]})]})}function ll(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(sl,{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(sl,{className:"h-28"},t))}),n.jsx(sl,{className:"h-64"}),n.jsx(sl,{className:"h-48"})]})}const cl=s.lazy(()=>N(()=>import("./Login-DxQgqPyH.js"),__vite__mapDeps([0,1,2]))),ul=s.lazy(()=>N(()=>import("./Dashboard-D0ZyJ9cS.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12]))),dl=s.lazy(()=>N(()=>import("./Packets-paAuyZUE.js"),__vite__mapDeps([13,1,2,6,7,8,9,5]))),hl=s.lazy(()=>N(()=>import("./Contacts-D7dmBQTJ.js").then(e=>e.C),__vite__mapDeps([14,1,2,15,5,8,7,16,17,18]))),fl=s.lazy(()=>N(()=>import("./Statistics-CjF2BXTB.js"),__vite__mapDeps([19,1,2,20,4,9,10,5,8,16,12,18]))),pl=s.lazy(()=>N(()=>import("./System-Bl3LqV-u.js"),__vite__mapDeps([21,1,2,4,5,12]))),ml=s.lazy(()=>N(()=>import("./Logs-YP9BpQVI.js"),__vite__mapDeps([22,1,2,20,5]))),gl=s.lazy(()=>N(()=>import("./Terminal-CLPRu8Bc.js"),__vite__mapDeps([23,1,2,15,5]))),yl=s.lazy(()=>N(()=>import("./Configuration-koaN0oYB.js"),__vite__mapDeps([24,1,2,8,17,5,12])));function bl({children:e}){const t=o();return co()?n.jsx(n.Fragment,{children:e}):n.jsx(j,{to:"/login",state:{from:t},replace:!0})}class xl 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 wl(){const e=Ui(e=>e.initializeApp),t=co();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{xo()},3e4);return xo(),vo(),()=>clearInterval(s)},[e,t]),n.jsxs(el,{children:[n.jsx(Kr,{}),n.jsxs(L,{children:[n.jsx(_,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(cl,{})})}),n.jsx(_,{path:"/*",element:n.jsx(bl,{children:n.jsxs("div",{className:"flex h-screen overflow-hidden",children:[n.jsx(Vr,{}),n.jsx("main",{className:"flex-1 w-full min-w-0 pt-14 lg:pt-0 overflow-y-auto",children:n.jsx("div",{className:"px-4 sm:px-6 lg:px-8 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:n.jsx(xl,{children:n.jsxs(L,{children:[n.jsx(_,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(nl,{}),children:n.jsx(ul,{})})}),n.jsx(_,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(dl,{})})}),n.jsx(_,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(ol,{}),children:n.jsx(hl,{})})}),n.jsx(_,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(il,{}),children:n.jsx(fl,{})})}),n.jsx(_,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(ll,{}),children:n.jsx(pl,{})})}),n.jsx(_,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(ml,{})})}),n.jsx(_,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(gl,{})})}),n.jsx(_,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(rl,{}),children:n.jsx(yl,{})})})]})})})})]})})})]})]})}const kl=console.warn;console.warn=(...e)=>{const t=e[0];if("string"==typeof t){if(t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0"))return;if(t.includes("Unable to load glyph range"))return}kl.apply(console,e)},P.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx($a,{children:n.jsx(E,{children:n.jsx(wl,{})})})}));export{Dr as $,pi as A,Er as B,Mr as C,mi as D,Ar as E,bi as F,Wr as G,Nr as H,Rr as I,Gr as J,kr as K,pr as L,br as M,Ir as N,qi as O,qa as P,ar as Q,Ja as R,Cr as S,tl as T,Tr as U,Or as V,Fa as W,_o as X,jo as Y,za as Z,Wa as _,Vi as a,Fr as a0,zr as a1,gi as a2,yi as a3,R as a4,A as a5,re as a6,tr as a7,sr as a8,Ro as a9,xi as aa,Ki as ab,Xi as ac,Zi as ad,ki as ae,Eo as af,Bo as ag,Oo as ah,$o as ai,zo as aj,Wo as ak,Mo as al,be as am,Ce as an,Ur as ao,qr as ap,Xo as aq,fi as ar,Va as as,Sr as at,ir as au,lr as av,di as aw,Qi as b,Gi as c,hi as d,rr as e,nr as f,no as g,ur as h,co as i,Do as j,cr as k,go as l,Ji as m,hr as n,dr as o,or as p,Ao as q,er as r,ao as s,Ga as t,Yi as u,Ha as v,oi as w,Ya as x,$r as y,Hr as z}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-D81eBYn4.js","assets/vendor-react-DtVWNgeu.js","assets/vendor-core-WoOfkQwm.js","assets/Dashboard-DPV4UcXa.js","assets/useThemeColors-DaJMJYCA.js","assets/PageLayout-CG02PCA-.js","assets/PacketDetailModal-I-Pe3tob.js","assets/SignalIndicator-DagI_WOB.js","assets/DataBox-Dl3NmnnB.js","assets/useScientificColormap-n_Aivg5g.js","assets/TimeRangeSelector-CzmnykND.js","assets/link-scoring-t1Ov70gg.js","assets/Grid-Cva3lgGW.js","assets/Packets-Dx7VKSq1.js","assets/Contacts-Dm2Yh1zu.js","assets/ping-BBb1dLdC.js","assets/CollisionExplorerModal-gzC3uL5Q.js","assets/ConfirmModal-Dq3wq7Fw.js","assets/leaflet-CIGW-MKW.css","assets/Statistics-rMuAOtUm.js","assets/usePolling-DXhhvgB-.js","assets/System-CfbhqMgy.js","assets/Logs-DmMC1IFZ.js","assets/Terminal-D4B4ypGn.js","assets/Configuration-mzUD-v3l.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 r,L as l,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 b,k as x,l as w,m as k,n as v,o as S,p as C,q as T,b as M,t as L,v as _,N as j,w as P,B as E}from"./vendor-react-DtVWNgeu.js";import{_ as N}from"./deckgl-DTsmDcfs.js";import{c as D}from"./recharts-C9LxPobD.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 I={surfaces:{glass:{tint:"#252525",light:"#ffffff",dark:"#000000",reflexLight:.15,reflexDark:.8,blur:6,blurElevated:8,brightness:1,opacity:8,opacityElevated:12},card:{radius:"1.125rem",padding:"1.25rem",paddingCompact:"0.75rem"},sidebar:{tint:"rgba(113, 156, 223, 0.06)",width:"16rem",drawerWidth:"85vw"},modal:{radius:"1.125rem",backdropBlur:"8px",backdropColor:"rgba(0, 0, 0, 0.6)"}},colors:{bg:{body:"#171717",surface:"#252525",elevated:"#333233",subtle:"#3F3F3F"},border:{subtle:"#4B4B4B",strong:"#616161"},text:{primary:"#E1E1E1",secondary:"#BFBFBF",muted:"#727272",inverse:"#171717"},accent:{primary:"#719CDF",secondary:"#DFBC72",tertiary:"#6FBCBD",success:"#719872",danger:"#E12672"},signal:{excellent:"#00FF00",good:"#8CE619",fair:"#FFD900",poor:"#FF8C26",critical:"#FF3333",unknown:"#616161"},status:{success:"#719872",warning:"#DFBC72",danger:"#E12672",info:"#6FBCBD",muted:"#616161"},chart:{c1:"#719CDF",c2:"#0074BE",c3:"#6FBCBD",c4:"#DFBC72",c5:"#719872",c6:"#E12672",c7:"#E17899",c8:"#999ABD",grid:"rgba(255, 255, 255, 0.06)",axis:"rgba(255, 255, 255, 0.4)",cursor:"rgba(255, 255, 255, 0.2)"},metric:{received:"#719872",forwarded:"#0074BE",transmitted:"#DFBC72",dropped:"#E12672"},map:{nodeFill:"#F5F5F0",nodeStroke:"#4A5568",hub:"#8B7BAD",local:"#FBBF24",neighbor:"#FBBF24",mobile:"#F97316",room:"#E17899",edge:"#4B4B4B",edgeHover:"#6FBCBD"}},typography:{font:{title:"'Inter', system-ui, sans-serif",display:"'Inter', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xs:"0.64rem",sm:"0.8rem",base:"1rem",md:"1.125rem",lg:"1.25rem",xl:"1.563rem",xxl:"1.953rem",hero:"3.052rem"},weight:{normal:400,medium:500,semibold:600,bold:700},leading:{tight:1.1,snug:1.25,normal:1.5},tracking:{tight:"-0.02em",normal:"0",wide:"0.05em"}},spacing:{space:{gap:"1.5rem",gapMobile:"0.75rem",page:"1.5rem",pageMobile:"1rem",section:"2rem"},radius:{sm:"0.5rem",md:"0.875rem",lg:"1.125rem",xl:"1.5rem",pill:"9999px"}},motion:{fast:"0.1s",normal:"0.15s",slow:"0.4s",easing:"ease-out"}};function F(e){const t=e.replace("#","");if(6!==t.length&&3!==t.length)return e;let s,n,a;return 3===t.length?(s=parseInt(t[0]+t[0],16)/255,n=parseInt(t[1]+t[1],16)/255,a=parseInt(t[2]+t[2],16)/255):(s=parseInt(t.slice(0,2),16)/255,n=parseInt(t.slice(2,4),16)/255,a=parseInt(t.slice(4,6),16)/255),`color(display-p3 ${s.toFixed(3)} ${n.toFixed(3)} ${a.toFixed(3)})`}function A(){return"undefined"!=typeof window&&CSS.supports("color","color(display-p3 1 1 1)")}function R(e){return A()?F(e):e}function z(e,t){const s={...e};for(const n of Object.keys(t)){const a=t[n],o=e[n];void 0!==a&&("object"!=typeof a||null===a||Array.isArray(a)||"object"!=typeof o||null===o||Array.isArray(o)?s[n]=a:s[n]=z(o,a))}return s}function B(e){return{meta:e.meta,display:e.display,surfaces:e.surfaces?z(I.surfaces,e.surfaces):I.surfaces,colors:e.colors?z(I.colors,e.colors):I.colors,typography:e.typography?z(I.typography,e.typography):I.typography,spacing:e.spacing?z(I.spacing,e.spacing):I.spacing,motion:e.motion?z(I.motion,e.motion):I.motion}}function O(e){const t=e.replace("#","");return 6===t.length?`${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}`:"255, 255, 255"}function $(e){return{id:e.meta.id,colorScheme:{name:e.meta.name,dataTheme:e.meta.dataTheme,previewColor:e.meta.previewColor},background:{src:e.meta.backgroundImage,suggestedBrightness:e.meta.backgroundBrightness},display:{font:e.display.font,color:e.display.color,size:e.display.size,paletteColors:e.display.palette}}}const W=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#58b99d",backgroundImage:"",backgroundBrightness:100,isDark:!0},display:{font:"'JetBrains Mono', monospace",color:"#58b99d",size:1,palette:[["#58b99d","#4997ec","#60ce41","#e67b2f","#da3529"],["#242627","#818c8d","#925cb1","#5face4","#fcfcfc"]]},typography:{font:{title:"'JetBrains Mono', monospace",display:"'Noto Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},weight:{normal:400,medium:500,semibold:600,bold:700},tracking:{tight:"-0.04em",normal:"0",wide:"0.05em"}},surfaces:{glass:{tint:"#242627",light:"#4997ec",dark:"#000000",reflexLight:0,reflexDark:0,blur:0,blurElevated:0,brightness:1,opacity:95,opacityElevated:98},sidebar:{tint:"rgba(88, 185, 157, 0.04)"},card:{radius:"4px"},modal:{radius:"6px"}},colors:{bg:{body:"#1a1c1d",surface:"#242627",elevated:"#2e3133",subtle:"#383b3d"},border:{subtle:"#383b3d",strong:"#4a4e50"},text:{primary:"#fcfcfc",secondary:"#c8c8c8",muted:"#818c8d",inverse:"#242627"},accent:{primary:"#58b99d",secondary:"#e67b2f",tertiary:"#4997ec",success:"#60ce41",danger:"#da3529"},signal:{excellent:"#60ce41",good:"#67d99f",fair:"#e67b2f",poor:"#b14434",critical:"#da3529",unknown:"#818c8d"},status:{success:"#60ce41",warning:"#e67b2f",danger:"#da3529",info:"#58b99d",muted:"#818c8d"},chart:{c1:"#58b99d",c2:"#4997ec",c3:"#60ce41",c4:"#e67b2f",c5:"#da3529",c6:"#925cb1",c7:"#67d99f",c8:"#818c8d",grid:"rgba(252, 252, 252, 0.06)",axis:"rgba(252, 252, 252, 0.3)",cursor:"rgba(88, 185, 157, 0.2)"},metric:{received:"#58b99d",forwarded:"#4997ec",transmitted:"#e67b2f",dropped:"#da3529"},map:{nodeFill:"#fcfcfc",nodeStroke:"#4a4e50",hub:"#925cb1",local:"#58b99d",neighbor:"#58b99d",mobile:"#e67b2f",room:"#58b99d",edge:"#4a4e50",edgeHover:"#58b99d"}}}),H=W;$(W);const U=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#B39DF3",backgroundImage:"/assets/sand.jpg",backgroundBrightness:80,isDark:!0},display:{font:"'Rubik Mono One', monospace",color:"#4A4A52",size:.8,palette:[["#B49DFF","#F9D26F","#71F8E5","#39D98A","#FF5C7A"],["#4CFFB5","#FF8A5C","#A78BFA","#60A5FA","#F472B6"]]},typography:{font:{title:"'Rubik Mono One', monospace"}},surfaces:{glass:{tint:"#252525",blur:6,blurElevated:8},sidebar:{tint:"rgba(113, 156, 223, 0.06)"}}}),q=U;$(U);const G=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#fabd2f",backgroundImage:"/assets/magma.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Jacquard 12', serif",color:"#fe8019",size:1.75,palette:[["#fabd2f","#fb4934","#8ec07c","#b8bb26","#d3869b"],["#fe8019","#83a598","#d65d0e","#928374","#ebdbb2"]]},typography:{font:{title:"'Jacquard 12', serif"},size:{xxl:"2.344rem"}},surfaces:{glass:{tint:"#282828"},sidebar:{tint:"rgba(250, 189, 47, 0.06)"}},colors:{accent:{primary:"#fabd2f",secondary:"#fb4934",tertiary:"#8ec07c",success:"#b8bb26",danger:"#fb4934"},signal:{excellent:"#b8bb26",good:"#8ec07c",fair:"#fabd2f",poor:"#fe8019",critical:"#fb4934",unknown:"#928374"},status:{success:"#b8bb26",warning:"#fabd2f",danger:"#fb4934",info:"#83a598",muted:"#928374"},chart:{c1:"#fabd2f",c2:"#fe8019",c3:"#fb4934",c4:"#d3869b",c5:"#b8bb26",c6:"#8ec07c",c7:"#83a598",c8:"#d65d0e",grid:"rgba(251, 241, 199, 0.06)",axis:"rgba(251, 241, 199, 0.4)",cursor:"rgba(251, 241, 199, 0.2)"},metric:{received:"#b8bb26",forwarded:"#83a598",transmitted:"#fabd2f",dropped:"#fb4934"},map:{nodeFill:"#fbf1c7",nodeStroke:"#504945",hub:"#b16286",local:"#fabd2f",neighbor:"#fabd2f",mobile:"#fe8019",room:"#d3869b",edge:"#665c54",edgeHover:"#8ec07c"}}}),J=G;$(G);const Y=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#83a598",backgroundImage:"/assets/water.webp",backgroundBrightness:40,isDark:!0},display:{font:"'Cantora One', sans-serif",color:"#83a598",size:1.25,palette:[["#83a598","#a89984","#8ec07c","#d79921","#b16286"],["#fe8019","#cc241d","#7c6f64","#bdae93","#ebdbb2"]]},typography:{font:{title:"'Cantora One', sans-serif"},size:{xxl:"2.148rem"},weight:{semibold:500}},surfaces:{glass:{tint:"#1e1e1e"},sidebar:{tint:"rgba(131, 165, 152, 0.06)"}},colors:{accent:{primary:"#83a598",secondary:"#a89984",tertiary:"#8ec07c",success:"#8ec07c",danger:"#cc241d"},signal:{excellent:"#8ec07c",good:"#b8bb26",fair:"#d79921",poor:"#fe8019",critical:"#cc241d",unknown:"#7c6f64"},status:{success:"#8ec07c",warning:"#d79921",danger:"#cc241d",info:"#83a598",muted:"#7c6f64"},chart:{c1:"#83a598",c2:"#8ec07c",c3:"#d79921",c4:"#b16286",c5:"#fe8019",c6:"#cc241d",c7:"#a89984",c8:"#7c6f64",grid:"rgba(213, 196, 161, 0.06)",axis:"rgba(213, 196, 161, 0.4)",cursor:"rgba(213, 196, 161, 0.2)"},metric:{received:"#8ec07c",forwarded:"#83a598",transmitted:"#d79921",dropped:"#cc241d"},map:{nodeFill:"#ebdbb2",nodeStroke:"#504945",hub:"#b16286",local:"#d79921",neighbor:"#d79921",mobile:"#fe8019",room:"#b16286",edge:"#504945",edgeHover:"#83a598"}}}),V=Y;$(Y);const K=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#33859d",backgroundImage:"/assets/stars.jpg",backgroundBrightness:100,isDark:!0},display:{font:"'IBM Plex Mono', monospace",color:"#c23127",size:1.25,palette:[["#33859d","#edb54b","#26a98b","#c23127","#888ca6"],["#195465","#d26939","#99d1ce","#4e5165","#0c1014"]]},typography:{font:{title:"'IBM Plex Mono', monospace"}},surfaces:{glass:{tint:"#0a0e14",blur:1,blurElevated:2},sidebar:{tint:"rgba(51, 133, 157, 0.06)"}},colors:{accent:{primary:"#33859d",secondary:"#edb54b",tertiary:"#26a98b",success:"#26a98b",danger:"#c33027"},signal:{excellent:"#26a98b",good:"#7ec07c",fair:"#edb54b",poor:"#d26939",critical:"#c33027",unknown:"#195465"},status:{success:"#26a98b",warning:"#edb54b",danger:"#c33027",info:"#599caa",muted:"#195465"},chart:{c1:"#33859d",c2:"#edb54b",c3:"#26a98b",c4:"#599caa",c5:"#d26939",c6:"#c33027",c7:"#888ba5",c8:"#195465",grid:"rgba(153, 209, 206, 0.06)",axis:"rgba(153, 209, 206, 0.4)",cursor:"rgba(153, 209, 206, 0.2)"},metric:{received:"#26a98b",forwarded:"#33859d",transmitted:"#edb54b",dropped:"#c33027"},map:{nodeFill:"#edf5f4",nodeStroke:"#195465",hub:"#888ba5",local:"#edb54b",neighbor:"#edb54b",mobile:"#d26939",room:"#888ba5",edge:"#245361",edgeHover:"#26a98b"}}}),X=K;$(K);const Q=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#9ed072",backgroundImage:"/assets/ribbons.webp",backgroundBrightness:75,isDark:!0},display:{font:"'Instrument Serif', serif",color:"#E2E2E3",size:1.4,palette:[["#9ed072","#fc5d7c","#76cce0","#e7c664","#b39df3"],["#f39660","#7f8490","#e2e2e3","#55575e","#2c2e34"]]},typography:{font:{title:"'Instrument Serif', Georgia, serif",display:"'Instrument Sans', system-ui, sans-serif",mono:"'JetBrains Mono', 'SF Mono', Monaco, monospace"},size:{xxl:"3.25rem",xl:"2.5rem",lg:"1.875rem",md:"1.25rem"},weight:{normal:400,medium:500,semibold:600,bold:600}},surfaces:{glass:{tint:"#23212d"},sidebar:{tint:"rgba(158, 208, 114, 0.06)"}},colors:{accent:{primary:"#9ed072",secondary:"#e7c664",tertiary:"#76cce0",success:"#9ed072",danger:"#fc5d7c"},signal:{excellent:"#9ed072",good:"#c5d93d",fair:"#e7c664",poor:"#f39660",critical:"#fc5d7c",unknown:"#7f8490"},status:{success:"#9ed072",warning:"#e7c664",danger:"#fc5d7c",info:"#76cce0",muted:"#7f8490"},chart:{c1:"#9ed072",c2:"#fc5d7c",c3:"#e7c664",c4:"#76cce0",c5:"#b39df3",c6:"#f39660",c7:"#7f8490",c8:"#e2e2e3",grid:"rgba(226, 226, 227, 0.06)",axis:"rgba(226, 226, 227, 0.4)",cursor:"rgba(226, 226, 227, 0.2)"},metric:{received:"#9ed072",forwarded:"#76cce0",transmitted:"#e7c664",dropped:"#fc5d7c"},map:{nodeFill:"#e2e2e3",nodeStroke:"#33353f",hub:"#b39df3",local:"#e7c664",neighbor:"#e7c664",mobile:"#f39660",room:"#fc5d7c",edge:"#444751",edgeHover:"#76cce0"}}}),Z=Q;$(Q);const ee=B({meta:{id:"",name:"",dataTheme:"",previewColor:"#7E9CD8",backgroundImage:"/assets/folds.webp",backgroundBrightness:50,isDark:!0},display:{font:"'Inter', sans-serif",color:"#7E9CD8",size:1.25,palette:[["#7E9CD8","#E46876","#7AA89F","#DCA561","#957FB8"],["#7FB4CA","#D27E99","#98BB6C","#727169","#1F1F28"]]},typography:{font:{title:"'Inter', sans-serif"}},surfaces:{glass:{tint:"#1F1F28"},sidebar:{tint:"rgba(126, 156, 216, 0.06)"}},colors:{accent:{primary:"#7E9CD8",secondary:"#E6C384",tertiary:"#7FB4CA",success:"#98BB6C",danger:"#E46876"},signal:{excellent:"#98BB6C",good:"#B8CC5C",fair:"#E6C384",poor:"#FFA066",critical:"#E46876",unknown:"#54546D"},status:{success:"#98BB6C",warning:"#E6C384",danger:"#E46876",info:"#7FB4CA",muted:"#727169"},chart:{c1:"#7E9CD8",c2:"#E6C384",c3:"#98BB6C",c4:"#957FB8",c5:"#7FB4CA",c6:"#E46876",c7:"#FFA066",c8:"#D27E99",grid:"rgba(220, 215, 186, 0.06)",axis:"rgba(220, 215, 186, 0.4)",cursor:"rgba(220, 215, 186, 0.2)"},metric:{received:"#98BB6C",forwarded:"#7E9CD8",transmitted:"#E6C384",dropped:"#E46876"},map:{nodeFill:"#DCD7BA",nodeStroke:"#363646",hub:"#957FB8",local:"#E6C384",neighbor:"#E6C384",mobile:"#FFA066",room:"#D27E99",edge:"#54546D",edgeHover:"#7AA89F"}}}),te=ee;$(ee);const se={"KDE Breeze":H,Magma:J,Folds:te,Ribbon:Z,BLKSAND:q,Waves:V,Stars:X};function ne(e,t){const s=e.toLowerCase();return{...t,meta:{...t.meta,id:s,name:e,dataTheme:s}}}const ae=Object.fromEntries(Object.entries(se).map(([e,t])=>[e,ne(e,t)])),oe=Object.fromEntries(Object.entries(ae).map(([e,t])=>[e,$(t)])),ie=Object.values(ae);function re(e){return ie.find(t=>t.meta.id===e)}new Map(Object.entries(ae));const le=Object.values(oe);new Map(Object.entries(oe));const ce=Object.entries(oe).map(([e,t])=>function(e,t){return{id:e.id,name:e.colorScheme.name,displayName:t,colorScheme:e.id,backgroundImage:e.background.src,paletteColors:e.display.paletteColors,displayFont:e.display.font,displayColor:e.display.color,displaySize:e.display.size}}(t,e)),ue=le.map(function(e){return{id:e.id,name:e.colorScheme.name,dataTheme:e.colorScheme.dataTheme,previewColor:e.colorScheme.previewColor}}),de=le.map(function(e){return{id:e.id,src:e.background.src,suggestedScheme:e.id,suggestedBrightness:e.background.suggestedBrightness}}),he=ae["KDE Breeze"];oe["KDE Breeze"];const fe=he.meta.id,pe=he.meta.backgroundImage,me=he.meta.backgroundBrightness,ge=ue,ye=de,be=ce,xe={colorScheme:fe,backgroundImage:pe,brightness:me},we="pymc-color-scheme",ke="pymc-background-image",ve="pymc-bg-brightness",Se="pymc-background";function Ce(e){(new Image).src=e}const Te={50:.97,100:.92,200:.84,300:.73,400:.62,500:.5,600:.4,700:.32,800:.24,900:.16},Me=[50,100,200,300,400,500,600,700,800,900],Le=["red","orange","yellow","green","aqua","blue","purple"];function _e(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 je(e){const t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Pe(e){const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.round(255*t)}function Ee(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,r=e-.1055613458*a-.0638541728*o,l=e-.0894841775*a-1.291485548*o,c=i*i*i,u=r*r*r,d=l*l*l,h=-1.2684380046*c+2.6097574011*u-.3413193965*d,f=-.0041960863*c-.7034186147*u+1.707614701*d;return[Pe(4.0767416621*c-3.3077115913*u+.2309699292*d),Pe(h),Pe(f)]}function Ne(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=je(e),a=je(t),o=je(s),i=.4122214708*n+.5363325363*a+.0514459929*o,r=.2119034982*n+.6806995451*a+.1073969566*o,l=.0883024619*n+.2817188376*a+.6299787005*o,c=Math.cbrt(i),u=Math.cbrt(r),d=Math.cbrt(l),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 r of Me){const e=Te[r],t=a*(1-.3*Math.abs(e-.5)),[s,n,l]=Ee(e,t,o);i[r]=_e(s,n,l)}return i}function De(e){return"undefined"==typeof window?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function Ie(e,t){"undefined"!=typeof document&&document.documentElement.style.setProperty(e,t)}const Fe="u-off",Ae="u-label",Re="width",ze="height",Be="top",Oe="bottom",$e="left",We="right",He="#000",Ue=He+"0",qe="mousemove",Ge="mousedown",Je="mouseup",Ye="mouseenter",Ve="mouseleave",Ke="dblclick",Xe="change",Qe="dppxchange",Ze="--",et="undefined"!=typeof window,tt=et?document:null,st=et?window:null,nt=et?navigator:null;let at,ot;function it(e,t){if(null!=t){let s=e.classList;!s.contains(t)&&s.add(t)}}function rt(e,t){let s=e.classList;s.contains(t)&&s.remove(t)}function lt(e,t,s){e.style[t]=s+"px"}function ct(e,t,s,n){let a=tt.createElement(e);return null!=t&&it(a,t),null!=s&&s.insertBefore(a,n),a}function ut(e,t){return ct("div",e,t)}const dt=new WeakMap;function ht(e,t,s,n,a){let o="translate("+t+"px,"+s+"px)";o!=dt.get(e)&&(e.style.transform=o,dt.set(e,o),t<0||s<0||t>n||s>a?it(e,Fe):rt(e,Fe))}const ft=new WeakMap;function pt(e,t,s){let n=t+s;n!=ft.get(e)&&(ft.set(e,n),e.style.background=t,e.style.borderColor=s)}const mt=new WeakMap;function gt(e,t,s,n){let a=t+""+s;a!=mt.get(e)&&(mt.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 yt={passive:!0},bt={...yt,capture:!0};function xt(e,t,s,n){t.addEventListener(e,s,n?bt:yt)}function wt(e,t,s,n){t.removeEventListener(e,s,yt)}function kt(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:Ot((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]}}et&&function e(){let t=devicePixelRatio;at!=t&&(at=t,ot&&wt(Xe,ot,e),ot=matchMedia(`(min-resolution: ${at-.001}dppx) and (max-resolution: ${at+.001}dppx)`),xt(Xe,ot,e),st.dispatchEvent(new CustomEvent(Qe)))}();const St=e=>null!=e,Ct=e=>null!=e&&e>0,Tt=vt(St),Mt=vt(Ct);function Lt(e,t,s,n){let a=Gt(e),o=Gt(t);e==t&&(-1==a?(e*=s,t/=s):(e/=s,t*=s));let i=10==s?Jt:Yt,r=1==o?Wt:Ot,l=(1==a?Ot:Wt)(i(Bt(e))),c=r(i(Bt(t))),u=qt(s,l),d=qt(s,c);return 10==s&&(l<0&&(u=ds(u,-l)),c<0&&(d=ds(d,-c))),n||2==s?(e=u*a,t=d*o):(e=us(e,u),t=cs(t,d)),[e,t]}function _t(e,t,s,n){let a=Lt(e,t,s,n);return 0==e&&(a[0]=0),0==t&&(a[1]=0),a}const jt={mode:3,pad:.1},Pt={pad:0,soft:null,mode:0},Et={min:Pt,max:Pt};function Nt(e,t,s,n){return ks(s)?It(e,t,s):(Pt.pad=s,Pt.soft=n?0:null,Pt.mode=n?3:0,It(e,t,Et))}function Dt(e,t){return null==e?t:e}function It(e,t,s){let n=s.min,a=s.max,o=Dt(n.pad,0),i=Dt(a.pad,0),r=Dt(n.hard,-Kt),l=Dt(a.hard,Kt),c=Dt(n.soft,Kt),u=Dt(a.soft,-Kt),d=Dt(n.mode,0),h=Dt(a.mode,0),f=t-e,p=Jt(f),m=Ut(Bt(e),Bt(t)),g=Jt(m),y=Bt(g-p);(f<1e-24||y>10)&&(f=0,0!=e&&0!=t||(f=1e-24,2==d&&c!=Kt&&(o=0),2==h&&u!=-Kt&&(i=0)));let b=f||m||1e3,x=Jt(b),w=qt(10,Ot(x)),k=ds(us(e-b*(0==f?0==e?.1:1:o),w/10),24),v=e>=c&&(1==d||3==d&&k<=c||2==d&&k>=c)?c:Kt,S=Ut(r,k=v?v:Ht(v,k)),C=ds(cs(t+b*(0==f?0==t?.1:1:i),w/10),24),T=t<=u&&(1==h||3==h&&C>=u||2==h&&C<=u)?u:-Kt,M=Ht(l,C>T&&t<=T?T:Ut(T,C));return S==M&&0==S&&(M=100),[S,M]}const Ft=new Intl.NumberFormat(et?nt.language:"en-US"),At=e=>Ft.format(e),Rt=Math,zt=Rt.PI,Bt=Rt.abs,Ot=Rt.floor,$t=Rt.round,Wt=Rt.ceil,Ht=Rt.min,Ut=Rt.max,qt=Rt.pow,Gt=Rt.sign,Jt=Rt.log10,Yt=Rt.log2,Vt=(e,t=1)=>Rt.asinh(e/t),Kt=1/0;function Xt(e){return 1+(0|Jt((e^e>>31)-(e>>31)))}function Qt(e,t,s){return Ht(Ut(e,t),s)}function Zt(e){return"function"==typeof e}function es(e){return Zt(e)?e:()=>e}const ts=e=>e,ss=(e,t)=>t,ns=e=>null,as=e=>!0,os=(e,t)=>e==t,is=/\.\d*?(?=9{6,}|0{6,})/gm,rs=e=>{if(xs(e)||hs.has(e))return e;const t=`${e}`,s=t.match(is);if(null==s)return e;let n=s[0].length-1;if(-1!=t.indexOf("e-")){let[e,s]=t.split("e");return+`${rs(e)}e${s}`}return ds(e,n)};function ls(e,t){return rs(ds(rs(e/t))*t)}function cs(e,t){return rs(Wt(rs(e/t))*t)}function us(e,t){return rs(Ot(rs(e/t))*t)}function ds(e,t=0){if(xs(e))return e;let s=10**t,n=e*s*(1+Number.EPSILON);return $t(n)/s}const hs=new Map;function fs(e){return((""+e).split(".")[1]||"").length}function ps(e,t,s,n){let a=[],o=n.map(fs);for(let i=t;i=0?0:t)+(i>=o[r]?0:o[r]),u=10==e?l:ds(l,c);a.push(u),hs.set(u,c)}}return a}const ms={},gs=[],ys=[null,null],bs=Array.isArray,xs=Number.isInteger;function ws(e){return"string"==typeof e}function ks(e){let t=!1;if(null!=e){let s=e.constructor;t=null==s||s==Object}return t}function vs(e){return null!=e&&"object"==typeof e}const Ss=Object.getPrototypeOf(Uint8Array),Cs="__proto__";function Ts(e,t=ks){let s;if(bs(e)){let n=e.find(e=>null!=e);if(bs(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,js=["January","February","March","April","May","June","July","August","September","October","November","December"],Ps=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Es(e){return e.slice(0,3)}const Ns=Ps.map(Es),Ds=js.map(Es),Is={MMMM:js,MMM:Ds,WWWW:Ps,WWW:Ns};function Fs(e){return(e<10?"0":"")+e}const As={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=>Fs(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Fs(e.getDate()),D:e=>e.getDate(),WWWW:(e,t)=>t.WWWW[e.getDay()],WWW:(e,t)=>t.WWW[e.getDay()],HH:e=>Fs(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=>Fs(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Fs(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>{return((t=e.getMilliseconds())<10?"00":t<100?"0":"")+t;var t}};function Rs(e,t){t=t||Is;let s,n=[],a=/\{([a-z]+)\}|[^{]+/gi;for(;s=a.exec(e);)n.push("{"==s[0][0]?As[s[1]]:s[0]);return e=>{let s="";for(let a=0;ae%1==0,Os=[1,2,2.5,5],$s=ps(10,-32,0,Os),Ws=ps(10,0,32,Os),Hs=Ws.filter(Bs),Us=$s.concat(Ws),qs="{YYYY}",Gs="\n"+qs,Js="{M}/{D}",Ys="\n"+Js,Vs=Ys+"/{YY}",Ks="{aa}",Xs="{h}:{mm}"+Ks,Qs="\n"+Xs,Zs=":{ss}",en=null;function tn(e){let t=1e3*e,s=60*t,n=60*s,a=24*n,o=30*a,i=365*a;return[(1==e?ps(10,0,3,Os).filter(Bs):ps(10,-3,0,Os)).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,qs,en,en,en,en,en,en,1],[28*a,"{MMM}",Gs,en,en,en,en,en,1],[a,Js,Gs,en,en,en,en,en,1],[n,"{h}"+Ks,Vs,en,Ys,en,en,en,1],[s,Xs,Vs,en,Ys,en,en,en,1],[t,Zs,Vs+" "+Xs,en,Ys+" "+Xs,en,Qs,en,1],[e,Zs+".{fff}",Vs+" "+Xs,en,Ys+" "+Xs,en,Qs,en,1]],function(t){return(r,l,c,u,d,h)=>{let f=[],p=d>=i,m=d>=o&&d=a?a:d,i=x+(Ot(c)-Ot(y))+cs(y-x,o);f.push(i);let p=t(i),m=p.getHours()+p.getMinutes()/s+p.getSeconds()/n,g=d/n,b=h/r.axes[l]._space;for(;i=ds(i+d,1==e?0:3),!(i>u);)if(g>1){let e=Ot(ds(m+g,6))%24,s=t(i).getHours()-e;s>1&&(s=-1),i-=s*n,m=(m+g)%24,ds((i-f[f.length-1])/d,3)*b>=.7&&f.push(i)}else f.push(i)}return f}}]}const[sn,nn,an]=tn(1),[on,rn,ln]=tn(.001);function cn(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 un(e,t){return(s,n,a,o,i)=>{let r,l,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!=r&&f[2]||a!=l&&f[3]||o!=c&&f[4]||i!=u&&f[5]||p!=d&&f[6]||m!=h&&f[7]||f[1];return r=n,l=a,c=o,u=i,d=p,h=m,g(s)})}}function dn(e,t,s){return new Date(e,t,s)}function hn(e,t){return t(e)}function fn(e,t){return(s,n,a,o)=>null==o?Ze:t(e(n))}ps(2,-53,53,[1]);const pn={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:[]},mn=[0,0];function gn(e,t,s,n=!0){return e=>{0==e.button&&(!n||e.target==t)&&s(e)}}function yn(e,t,s,n=!0){return e=>{(!n||e.target==t)&&s(e)}}const bn={show:!0,x:!0,y:!0,lock:!1,move:function(e,t,s){return mn[0]=t,mn[1]=s,mn},points:{one:!1,show:function(e,t){let s=e.cursor.points,n=ut(),a=s.size(e,t);lt(n,Re,a),lt(n,ze,a);let o=a/-2;lt(n,"marginLeft",o),lt(n,"marginTop",o);let i=s.width(e,t,a);return i&<(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:gn,mouseup:gn,click:gn,dblclick:gn,mousemove:yn,mouseleave:yn,mouseenter:yn},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},xn={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},wn=Ms({},xn,{filter:ss}),kn=Ms({},wn,{size:10}),vn=Ms({},xn,{show:!1}),Sn='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"',Cn="bold "+Sn,Tn={show:!0,scale:"x",stroke:He,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:Cn,side:2,grid:wn,ticks:kn,border:vn,font:Sn,lineGap:1.5,rotate:0},Mn={show:!0,scale:"x",auto:!1,sorted:1,min:Kt,max:-Kt,idxs:[]};function Ln(e,t,s,n,a){return t.map(e=>null==e?"":At(e))}function _n(e,t,s,n,a,o,i){let r=[],l=hs.get(a)||0;for(let c=s=i?s:ds(cs(s,a),l);c<=n;c=ds(c+a,l))r.push(Object.is(c,-0)?0:c);return r}function jn(e,t,s,n,a,o,i){const r=[],l=e.scales[e.axes[t].scale].log,c=Ot((10==l?Jt:Yt)(s));a=qt(l,c),10==l&&(a=Us[kt(a,Us)]);let u=s,d=a*l;10==l&&(d=Us[kt(d,Us)]);do{r.push(u),u+=a,10!=l||hs.has(u)||(u=ds(u,hs.get(a))),u>=d&&(d=(a=u)*l,10==l&&(d=Us[kt(d,Us)]))}while(u<=n);return r}function Pn(e,t,s,n,a,o,i){let r=e.scales[e.axes[t].scale].asinh,l=n>r?jn(e,t,Ut(r,s),n,a):[r],c=n>=0&&s<=0?[0]:[];return(s<-r?jn(e,t,Ut(r,-n),-s,a):[r]).reverse().map(e=>-e).concat(c,l)}const En=/./,Nn=/[12357]/,Dn=/[125]/,In=/1/,Fn=(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 An(e,t,s,n,a){let o=e.axes[s],i=o.scale,r=e.scales[i],l=e.valToPos,c=o._space,u=l(10,i),d=l(9,i)-u>=c?En:l(7,i)-u>=c?Nn:l(5,i)-u>=c?Dn:In;if(d==In){let e=Bt(l(1,i)-u);if(ea,Wn={show:!0,auto:!0,sorted:0,gaps:$n,alpha:1,facets:[Ms({},On,{scale:"x"}),Ms({},On,{scale:"y"})]},Hn={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:$n,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),r=Bt(i-o)/(e.series[t].points.space*at);return n[1]-n[0]<=r},filter:null},values:null,min:Kt,max:-Kt,idxs:[],path:null,clip:null};function Un(e,t,s,n,a){return s/10}const qn={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},Gn=Ms({},qn,{time:!1,ori:1}),Jn={};function Yn(e,t){let s=Jn[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,r){for(let l=0;l{let m=e.pxRound;const g=r.dir*(0==r.ori?1:-1),y=0==r.ori?oa:ia;let b,x;1==g?(b=s,x=n):(b=n,x=s);let w=m(c(t[b],r,f,d)),k=m(u(i[b],l,p,h)),v=m(c(t[x],r,f,d)),S=m(u(1==o?l.max:l.min,l,p,h)),C=new Path2D(a);return y(C,v,S),y(C,w,S),y(C,w,k),C})}function Zn(e,t,s,n,a,o){let i=null;if(e.length>0){i=new Path2D;const r=0==t?ra:la;let l=s;for(let t=0;ts[0]){let e=s[0]-l;e>0&&r(i,l,n,e,n+o),l=s[1]}}let c=s+a-l,u=10;c>0&&r(i,l,n-u/2,c,n+o+u)}return i}function ea(e,t,s,n,a,o,i){let r=[],l=e.length;for(let c=1==a?s:n;c>=s&&c<=n;c+=a)if(null===t[c]){let u=c,d=c;if(1==a)for(;++c<=n&&null===t[c];)d=c;else for(;--c>=s&&null===t[c];)d=c;let h=o(e[u]),f=d==u?h:o(e[d]),p=u-a;h=i<=0&&p>=0&&p=0&&m>=0&&m=h&&r.push([h,f])}return r}function ta(e){return 0==e?ts:1==e?$t:t=>ls(t,e)}function sa(e){let t=0==e?na:aa,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,r,l=0,c=0)=>{0==l&&0==c?n(e,a,o,i,r):(l=Ht(l,i/2,r/2),c=Ht(c,i/2,r/2),t(e,a+l,o),s(e,a+i,o,a+i,o+r,l),s(e,a+i,o+r,a,o+r,c),s(e,a,o+r,a,o,c),s(e,a,o,a+i,o,l),e.closePath())}}const na=(e,t,s)=>{e.moveTo(t,s)},aa=(e,t,s)=>{e.moveTo(s,t)},oa=(e,t,s)=>{e.lineTo(t,s)},ia=(e,t,s)=>{e.lineTo(s,t)},ra=sa(0),la=sa(1),ca=(e,t,s,n,a,o)=>{e.arc(t,s,n,a,o)},ua=(e,t,s,n,a,o)=>{e.arc(s,t,n,a,o)},da=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(t,s,n,a,o,i)},ha=(e,t,s,n,a,o,i)=>{e.bezierCurveTo(s,t,a,n,i,o)};function fa(e){return(e,t,s,n,a)=>Vn(e,t,(t,o,i,r,l,c,u,d,h,f,p)=>{let m,g,{pxRound:y,points:b}=t;0==r.ori?(m=na,g=ca):(m=aa,g=ua);const x=ds(b.width*at,3);let w=(b.size-b.width)/2*at,k=ds(2*w,3),v=new Path2D,S=new Path2D,{left:C,top:T,width:M,height:L}=e.bbox;ra(S,C-k,T-k,M+2*k,L+2*k);const _=e=>{if(null!=i[e]){let t=y(c(o[e],r,f,d)),s=y(u(i[e],l,p,h));m(v,t+w,s),g(v,t,s,w,0,2*zt)}};if(a)a.forEach(_);else for(let e=s;e<=n;e++)_(e);return{stroke:x>0?v:null,fill:v,clip:S,flags:3}})}function pa(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 ma=pa(oa),ga=pa(ia);function ya(e){const t=Dt(null==e?void 0:e.alignGaps,0);return(e,s,n,a)=>Vn(e,s,(o,i,r,l,c,u,d,h,f,p,m)=>{[n,a]=Tt(r,n,a);let g,y,b=o.pxRound,x=e=>b(u(e,l,p,h)),w=e=>b(d(e,c,m,f));0==l.ori?(g=oa,y=ma):(g=ia,y=ga);const k=l.dir*(0==l.ori?1:-1),v={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},S=v.stroke;let C=!1;if(a-n>=4*p){let t,s,o,c=t=>e.posToVal(t,l.key,!0),u=null,d=null,h=x(i[1==k?n:a]),f=x(i[n]),p=x(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:x(n),o=r[e];a==h?null!=o?(s=o,null==u?(g(S,a,w(s)),t=u=d=s):sd&&(d=s)):null===o&&(C=!0):(null!=u&&y(S,h,w(u),w(d),w(t),w(s)),null!=o?(s=o,g(S,a,w(s)),u=d=t=s):(u=d=null,null===o&&(C=!0)),h=a,m=c(h+k))}null!=u&&u!=d&&o!=h&&y(S,h,w(u),w(d),w(t),w(s))}else for(let e=1==k?n:a;e>=n&&e<=a;e+=k){let t=r[e];null===t?C=!0:null!=t&&g(S,x(i[e]),w(t))}let[T,M]=Kn(e,s);if(null!=o.fill||0!=T){let t=v.fill=new Path2D(S),r=w(o.fillTo(e,s,o.min,o.max,T)),l=x(i[n]),c=x(i[a]);-1==k&&([c,l]=[l,c]),g(t,c,r),g(t,l,r)}if(!o.spanGaps){let c=[];C&&c.push(...ea(i,r,n,a,k,x,t)),v.gaps=c=o.gaps(e,s,n,a,c),v.clip=Zn(c,l.ori,h,f,p,m)}return 0!=M&&(v.band=2==M?[Qn(e,s,n,a,S,-1),Qn(e,s,n,a,S,1)]:Qn(e,s,n,a,S,M)),v})}function ba(e,t,s,n,a,o,i=Kt){if(e.length>1){let r=null;for(let l=0,c=1/0;l0!=n[e]>0?s[e]=0:(s[e]=3*(l[e-1]+l[e])/((2*l[e]+l[e-1])/n[e-1]+(l[e]+2*l[e-1])/n[e]),isFinite(s[e])||(s[e]=0));s[i-1]=n[i-2];for(let c=0;c{Fa.pxRatio=at}));const va=ya(),Sa=fa();function Ca(e,t,s,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,n)=>Ta(e,n,t,s))}function Ta(e,t,s,n){return Ms({},0==t?s:n,e)}function Ma(e,t,s){return null==t?ys:[t,s]}const La=Ma;function _a(e,t,s){return null==t?ys:Nt(t,s,.1,!0)}function ja(e,t,s,n){return null==t?ys:Lt(t,s,e.scales[n].log,!1)}const Pa=ja;function Ea(e,t,s,n){return null==t?ys:_t(t,s,e.scales[n].log,!1)}const Na=Ea;function Da(e){let t,s;return[e=e.replace(/(\d+)px/,(e,n)=>(t=$t((s=+n)*at))+"px"),t,s]}function Ia(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=ds(e[2]*at,1);e[0]=e[0].replace(/[0-9.]+px/,t+"px"),e[1]=t})}function Fa(e,t,s){const n={mode:Dt(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 r(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 l=!1;n.status=0;const c=n.root=ut("uplot");null!=e.id&&(c.id=e.id),it(c,e.class),e.title&&(ut("u-title",c).textContent=e.title);const u=ct("canvas"),d=n.ctx=u.getContext("2d"),h=ut("u-wrap",c);xt("click",h,e=>{e.target===p&&(Qs!=Ys||Zs!=Vs)&&kn.click(n,e)},!0);const f=n.under=ut("u-under",h);h.appendChild(u);const p=n.over=ut("u-over",h),m=+Dt((e=Ts(e)).pxAlign,1),g=ta(m);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(n,e)||e)});const y=e.ms||.001,b=n.series=1==a?Ca(e.series||[],Mn,Hn,!1):(x=e.series||[null],w=Wn,x.map((e,t)=>0==t?{}:Ms({},w,e)));var x,w;const k=n.axes=Ca(e.axes||[],Tn,Bn,!0),v=n.scales={},S=n.bands=e.bands||[];S.forEach(e=>{e.fill=es(e.fill||null),e.dir=Dt(e.dir,-1)});const C=2==a?b[1].facets[0].scale:b[0].scale,T={axes:function(){for(let e=0;ers[e]):y,x=2==f.distr?rs[y[1]]-rs[y[0]]:u,w=t.ticks,S=t.border,C=w.show?w.size:0,T=$t(C*at),M=$t((2==t.alignTo?t._size-C-t.gap:t.gap)*at),L=t._rotate*-zt/180,_=g(t._pos*at),j=_+(T+M)*c;a=0==i?j:0,s=1==i?j:0,Ss(t.font[0],l,1==t.align?$e:2==t.align?We:L>0?$e:L<0?We:0==i?"center":3==o?We:$e,L||1==i?"middle":2==o?Be:Oe);let P=t.font[1]*t.lineGap,E=y.map(e=>g(r(e,f,p,m))),N=t._values;for(let e=0;e0){let e=b.some(e=>e._focus)&&is!=Pe.alpha;e&&(d.globalAlpha=is=Pe.alpha),b.forEach((e,s)=>{if(s>0&&e.show&&(js(s,!1),js(s,!0),null==e._paths)){let o=is;is!=e.alpha&&(d.globalAlpha=is=e.alpha);let i=2==a?[0,t[s][0].length-1]:function(e){let t=Qt(yt-1,0,mt-1),s=Qt(bt+1,0,mt-1);for(;null==e[t]&&t>0;)t--;for(;null==e[s]&&s{if(t>0&&e.show){let s=is;is!=e.alpha&&(d.globalAlpha=is=e.alpha),null!=e._paths&&Ps(t,!1);{let s=null!=e._paths?e._paths.gaps:null,a=e.points.show(n,t,yt,bt,s),o=e.points.filter(n,t,a,s);(a||o)&&(e.points._paths=e.points.paths(n,t,yt,bt,o),Ps(t,!0))}is!=s&&(d.globalAlpha=is=s),Fa("drawSeries",t)}}),e&&(d.globalAlpha=is=1)}}},M=(e.drawOrder||["axes","series"]).map(e=>T[e]);function L(e){const t=3==e.distr?t=>Jt(t>0?t:e.clamp(n,t,e.min,e.max,e.key)):4==e.distr?t=>Vt(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 _(t){let s=v[t];if(null==s){let n=(e.scales||ms)[t]||ms;if(null!=n.from){_(n.from);let e=Ms({},v[n.from],n,{key:t});e.valToPct=L(e),v[t]=e}else{s=v[t]=Ms({},t==C?qn:Gn,n),s.key=t;let e=s.time,o=s.range,i=bs(o);if((t!=C||2==a&&!e)&&(!i||null!=o[0]&&null!=o[1]||(o={min:null==o[0]?jt:{mode:1,hard:o[0],soft:o[0]},max:null==o[1]?jt:{mode:1,hard:o[1],soft:o[1]}},i=!1),!i&&ks(o))){let e=o;o=(t,s,n)=>null==s?ys:Nt(s,n,e)}s.range=es(o||(e?La:t==C?3==s.distr?Pa:4==s.distr?Na:Ma:3==s.distr?ja:4==s.distr?Ea:_a)),s.auto=es(!i&&s.auto),s.clamp=es(s.clamp||Un),s._min=s._max=null,s.valToPct=L(s)}}}_("x"),_("y"),1==a&&b.forEach(e=>{_(e.scale)}),k.forEach(e=>{_(e.scale)});for(let Fe in e.scales)_(Fe);const j=v[C],P=j.distr;let E,N;0==j.ori?(it(c,"u-hz"),E=o,N=i):(it(c,"u-vt"),E=i,N=o);const D={};for(let Fe in v){let e=v[Fe];null==e.min&&null==e.max||(D[Fe]={min:e.min,max:e.max},e.min=e.max=null)}const I=e.tzDate||(e=>new Date($t(e/y))),F=e.fmtDate||Rs,A=1==y?an(I):ln(I),R=un(I,cn(1==y?nn:rn,F)),z=fn(I,hn("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",F)),B=[],O=n.legend=Ms({},pn,e.legend),$=n.cursor=Ms({},bn,{drag:{y:2==a}},e.cursor),W=O.show,H=$.show,U=O.markers;let q,G,J;O.idxs=B,U.width=es(U.width),U.dash=es(U.dash),U.stroke=es(U.stroke),U.fill=es(U.fill);let Y,V=[],K=[],X=!1,Q={};if(O.live){const e=b[1]?b[1].values:null;X=null!=e,Y=X?e(n,1,0):{_:0};for(let t in Y)Q[t]=Ze}if(W)if(q=ct("table","u-legend",c),J=ct("tbody",null,q),O.mount(n,q),X){G=ct("thead",null,q,J);let e=ct("tr",null,G);for(var Z in ct("th",null,e),Y)ct("th",Ae,e).textContent=Z}else it(q,"u-inline"),O.live&&it(q,"u-live");const ee={show:!0},te={show:!1},se=new Map;function ne(e,t,s,a=!0){const o=se.get(t)||{},i=$.bind[e](n,t,s,a);i&&(xt(e,t,o[e]=i),se.set(t,o))}function ae(e,t,s){const n=se.get(t)||{};for(let a in n)null!=e&&a!=e||(wt(a,t,n[a]),delete n[a]);null==e&&se.delete(t)}let oe=0,ie=0,re=0,le=0,ce=0,ue=0,de=ce,he=ue,fe=re,pe=le,me=0,ge=0,ye=0,be=0;n.bbox={};let xe=!1,we=!1,ke=!1,ve=!1,Se=!1,Ce=!1;function Te(e,t,s){(s||e!=n.width||t!=n.height)&&Me(e,t),Bs(!1),ke=!0,we=!0,gn()}function Me(e,t){n.width=oe=re=e,n.height=ie=le=t,ce=ue=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,r=o%2,l=i+(null!=a.label?a.labelSize:0);l>0&&(r?(re-=l,3==o?(ce+=l,n=!0):s=!0):(le-=l,0==o?(ue+=l,e=!0):t=!0))}}),nt[0]=e,nt[1]=s,nt[2]=t,nt[3]=n,re-=ft[1]+ft[3],ce+=ft[3],le-=ft[2]+ft[0],ue+=ft[0]}(),function(){let e=ce+re,t=ue+le,s=ce,n=ue;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;me=s.left=ls(ce*at,.5),ge=s.top=ls(ue*at,.5),ye=s.width=ls(re*at,.5),be=s.height=ls(le*at,.5)}const Le=3;if(n.setSize=function({width:e,height:t}){Te(e,t)},null==$.dataIdx){let e=$.hover,s=e.skip=new Set(e.skip??[]);s.add(void 0);let n=e.prox=es(e.prox),a=e.bias??(e.bias=0);$.dataIdx=(e,o,i,r)=>{if(0==o)return i;let l=i,c=n(e,o,i,r)??Kt,u=c>=0&&c0;)s.has(p[e])||(t=e);if(0==a||1==a)for(e=i;null==n&&e++c&&(l=null);return l}}const _e=e=>{$.event=e};$.idxs=B,$._lock=!1;let je=$.points;je.show=es(je.show),je.size=es(je.size),je.stroke=es(je.stroke),je.width=es(je.width),je.fill=es(je.fill);const Pe=n.focus=Ms({},e.focus||{alpha:.3},$.focus),Ee=Pe.prox>=0,Ne=Ee&&je.one;let De=[],Ie=[],He=[];function Xe(e,t){let s=je.show(n,t);if(s instanceof HTMLElement)return it(s,"u-cursor-pt"),it(s,e.class),ht(s,-10,-10,re,le),p.insertBefore(s,De[t]),s}function et(e,t){if(1==a||t>0){let t=1==a&&v[e.scale].time,s=e.value;e.value=t?ws(s)?fn(I,hn(s,F)):s||z:s||zn,e.label=e.label||(t?"Time":"Value")}if(Ne||t>0){e.width=null==e.width?1:e.width,e.paths=e.paths||va||ns,e.fillTo=es(e.fillTo||Xn),e.pxAlign=+Dt(e.pxAlign,m),e.pxRound=ta(e.pxAlign),e.stroke=es(e.stroke||null),e.fill=es(e.fill||null),e._stroke=e._fill=e._paths=e._focus=null;let t=ds(1*(3+2*(Ut(1,e.width)||1)),3),s=e.points=Ms({},{size:t,width:Ut(1,.2*t),stroke:e.stroke,space:2*t,paths:Sa,_stroke:null,_fill:null},e.points);s.show=es(s.show),s.filter=es(s.filter),s.fill=es(s.fill),s.stroke=es(s.stroke),s.paths=es(s.paths),s.pxAlign=e.pxAlign}if(W){let s=function(e,t){if(0==t&&(X||!O.live||2==a))return ys;let s=[],o=ct("tr","u-series",J,J.childNodes[t]);it(o,e.class),e.show||it(o,Fe);let i=ct("th",null,o);if(U.show){let e=ut("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 r=ut(Ae,i);for(var l in e.label instanceof HTMLElement?r.appendChild(e.label):r.textContent=e.label,t>0&&(U.show||(r.style.color=e.width>0?U.stroke(n,t):U.fill(n,t)),ne("click",i,t=>{if($._lock)return;_e(t);let s=b.indexOf(e);if((t.ctrlKey||t.metaKey)!=O.isolate){let e=b.some((e,t)=>t>0&&t!=s&&e.show);b.forEach((t,n)=>{n>0&&In(n,e?n==s?ee:te:ee,!0,Ra.setSeries)})}else In(s,{show:!e.show},!0,Ra.setSeries)},!1),Ee&&ne(Ye,i,t=>{$._lock||(_e(t),In(b.indexOf(e),Jn,!0,Ra.setSeries))},!1)),Y){let e=ct("td","u-value",o);e.textContent="--",s.push(e)}return[o,s]}(e,t);V.splice(t,0,s[0]),K.splice(t,0,s[1]),O.values.push(null)}if(H){B.splice(t,0,null);let s=null;Ne?0==t&&(s=Xe(e,t)):t>0&&(s=Xe(e,t)),De.splice(t,0,s),Ie.splice(t,0,0),He.splice(t,0,0)}Fa("addSeries",t)}n.addSeries=function(e,t){t=null==t?b.length:t,e=1==a?Ta(e,t,Mn,Hn):Ta(e,t,{},Wn),b.splice(t,0,e),et(b[t],t)},n.delSeries=function(e){if(b.splice(e,1),W){O.values.splice(e,1),K.splice(e,1);let t=V.splice(e,1)[0];ae(null,t.firstChild),t.remove()}H&&(B.splice(e,1),De.splice(e,1)[0].remove(),Ie.splice(e,1),He.splice(e,1)),Fa("delSeries",e)};const nt=[!1,!1,!1,!1];function ot(e,t,s,n){let[a,o,i,r]=s,l=t%2,c=0;return 0==l&&(r||o)&&(c=0==t&&!a||2==t&&!i?$t(Tn.size/3):0),1==l&&(a||i)&&(c=1==t&&!o||3==t&&!r?$t(Bn.size/2):0),c}const dt=n.padding=(e.padding||[ot,ot,ot,ot]).map(e=>es(Dt(e,ot))),ft=n._padding=dt.map((e,t)=>e(n,t,nt,0));let mt,yt=null,bt=null;const vt=1==a?b[0].idxs:null;let Pt,Et,It,Ft,At,Ot,Gt,Yt,ts,is,rs=null,cs=!1;function us(e,s){if(t=null==e?[]:e,n.data=n._data=t,2==a){mt=0;for(let e=1;e=0,Ce=!0,gn()}}function ps(){let e,s;cs=!0,1==a&&(mt>0?(yt=vt[0]=0,bt=vt[1]=mt-1,e=t[0][yt],s=t[0][bt],2==P?(e=yt,s=bt):e==s&&(3==P?[e,s]=Lt(e,e,j.log,!1):4==P?[e,s]=_t(e,e,j.log,!1):j.time?s=e+$t(86400/y):[e,s]=Nt(e,s,.1,!0))):(yt=vt[0]=e=null,bt=vt[1]=s=null)),Dn(C,e,s)}function xs(e,t,s,n,a,o){e??(e=Ue),s??(s=gs),n??(n="butt"),a??(a=Ue),o??(o="round"),e!=Pt&&(d.strokeStyle=Pt=e),a!=Et&&(d.fillStyle=Et=a),t!=It&&(d.lineWidth=It=t),o!=At&&(d.lineJoin=At=o),n!=Ot&&(d.lineCap=Ot=n),s!=Ft&&d.setLineDash(Ft=s)}function Ss(e,t,s,n){t!=Et&&(d.fillStyle=Et=t),e!=Gt&&(d.font=Gt=e),s!=Yt&&(d.textAlign=Yt=s),n!=ts&&(d.textBaseline=ts=n)}function Cs(e,t,s,a,o=0){if(a.length>0&&e.auto(n,cs)&&(null==t||null==t.min)){let t=Dt(yt,0),n=Dt(bt,a.length-1),i=null==s.min?function(e,t,s,n=0,a=!1){let o=a?Mt:Tt,i=a?Ct:St;[t,s]=o(e,t,s);let r=e[t],l=e[t];if(t>-1)if(1==n)r=e[t],l=e[s];else if(-1==n)r=e[s],l=e[t];else for(let c=t;c<=s;c++){let t=e[c];i(t)&&(tl&&(l=t))}return[r??Kt,l??-Kt]}(a,t,n,o,3==e.distr):[s.min,s.max];e.min=Ht(e.min,s.min=i[0]),e.max=Ut(e.max,s.max=i[1])}}n.setData=us;const Ls={min:null,max:null};function js(e,t){let s=t?b[e].points:b[e];s._stroke=s.stroke(n,e),s._fill=s.fill(n,e)}function Ps(e,s){let a=s?b[e].points:b[e],{stroke:o,fill:i,clip:r,flags:l,_stroke:c=a._stroke,_fill:u=a._fill,_width:h=a.width}=a._paths;h=ds(h*at,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=me-h/2,t=ge-h/2,s=ye+h,n=be+h;f=new Path2D,f.rect(e,t,s,n)}s?Ns(c,h,a.dash,a.cap,u,o,i,l,r):function(e,s,a,o,i,r,l,c,u,d,h){let f=!1;0!=u&&S.forEach((p,m)=>{if(p.series[0]==e){let e,g=b[p.series[1]],y=t[p.series[1]],x=(g._paths||ms).band;bs(x)&&(x=1==p.dir?x[0]:x[1]);let w=null;g.show&&x&&function(e,t,s){for(t=Dt(t,0),s=Dt(s,e.length-1);t<=s;){if(null!=e[t])return!0;t++}return!1}(y,yt,bt)?(w=p.fill(n,m)||r,e=g._paths.clip):x=null,Ns(s,a,o,i,w,l,c,u,d,h,e,x),f=!0}}),f||Ns(s,a,o,i,r,l,c,u,d,h)}(e,c,h,a.dash,a.cap,u,o,i,l,f,r),m&&d.translate(-p,-p)}const Es=3;function Ns(e,t,s,n,a,o,i,r,l,c,u,h){xs(e,t,s,n,a),(l||c||h)&&(d.save(),l&&d.clip(l),c&&d.clip(c)),h?(r&Es)==Es?(d.clip(h),u&&d.clip(u),Is(a,i),Ds(e,o,t)):2&r?(Is(a,i),d.clip(h),Ds(e,o,t)):1&r&&(d.save(),d.clip(h),u&&d.clip(u),Is(a,i),d.restore(),Ds(e,o,t)):(Is(a,i),Ds(e,o,t)),(l||c||h)&&d.restore()}function Ds(e,t,s){s>0&&(t instanceof Map?t.forEach((e,t)=>{d.strokeStyle=Pt=t,d.stroke(e)}):null!=t&&e&&d.stroke(t))}function Is(e,t){t instanceof Map?t.forEach((e,t)=>{d.fillStyle=Et=t,d.fill(e)}):null!=t&&e&&d.fill(t)}function Fs(e,t,s,n,a,o,i,r,l,c){let u=i%2/2;1==m&&d.translate(u,u),xs(r,i,l,c,r),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,Bs(!1)));s._show||(t=!1,s._show=!0,Bs(!1));let i=s.side,r=i%2,{min:l,max:c}=o,[u,d]=function(e,t,s,a){let o,i=k[e];if(a<=0)o=[0,0];else{let r=i._space=i.space(n,e,t,s,a);o=function(e,t,s,n,a){let o=Ut(Xt(e),Xt(t)),i=t-e,r=kt(a/n*i,s);do{let e=s[r],t=n*e/i;if(t>=a&&o+(e<5?hs.get(e):0)<=17)return[e,t]}while(++rrs[e]):f,m=2==o.distr?rs[f[1]]-rs[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=Wt(s.size(n,g,a,e)),null!=y&&s._size!=y&&(t=!1)}),t}function zs(e){let t=!0;return dt.forEach((s,a)=>{let o=s(n,a,nt,e);o!=ft[a]&&(t=!1),ft[a]=o}),t}function Bs(e){b.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 Os,$s,Ws,qs,Gs,Js,Ys,Vs,Ks,Xs,Qs,Zs,en=!1,tn=!1,dn=[];function mn(){tn=!1;for(let e=0;e0){b.forEach((s,o)=>{if(1==a){let a=s.scale,i=D[a];if(null==i)return;let r=e[a];if(0==o){let e=r.range(n,r.min,r.max,a);r.min=e[0],r.max=e[1],yt=kt(r.min,t[0]),bt=kt(r.max,t[0]),bt-yt>1&&(t[0][yt]r.max&&bt--),s.min=rs[yt],s.max=rs[bt]}else s.show&&s.auto&&Cs(r,i,s,t[o],s.sorted);s.idxs[0]=yt,s.idxs[1]=bt}else if(o>0&&s.show&&s.auto){let[n,a]=s.facets,i=n.scale,r=a.scale,[l,c]=t[o],u=e[i],d=e[r];null!=u&&Cs(u,D[i],n,l,n.sorted),null!=d&&Cs(d,D[r],a,c,a.sorted),s.min=a.min,s.max=a.max}});for(let t in e){let s=e[t],a=D[t];if(null==s.from&&(null==a||null==a.min)){let e=s.range(n,s.min==Kt?null:s.min,s.max==-Kt?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?Jt(a.min):4==e?Vt(a.min,a.asinh):100==e?a.fwd(a.min):a.min,a._max=3==e?Jt(a.max):4==e?Vt(a.max,a.asinh):100==e?a.fwd(a.max):a.max,s[t]=o=!0}}if(o){b.forEach((e,t)=>{2==a?t>0&&s.y&&(e._paths=null):s[e.scale]&&(e._paths=null)});for(let e in s)ke=!0,Fa("setScale",e);H&&$.left>=0&&(ve=Ce=!0)}for(let t in D)D[t]=null}(),xe=!1),ke&&(function(){let e=!1,t=0;for(;!e;){t++;let s=As(t),a=zs(t);e=t==Le||s&&a,e||(Me(n.width,n.height),we=!0)}}(),ke=!1),we){if(lt(f,$e,ce),lt(f,Be,ue),lt(f,Re,re),lt(f,ze,le),lt(p,$e,ce),lt(p,Be,ue),lt(p,Re,re),lt(p,ze,le),lt(h,Re,oe),lt(h,ze,ie),u.width=$t(oe*at),u.height=$t(ie*at),k.forEach(({_el:e,_show:t,_size:s,_pos:n,side:a})=>{if(null!=e)if(t){let t=a%2==1;lt(e,t?"left":"top",n-(3===a||0===a?s:0)),lt(e,t?"width":"height",s),lt(e,t?"top":"left",t?ue:ce),lt(e,t?"height":"width",t?le:re),rt(e,Fe)}else it(e,Fe)}),Pt=Et=It=At=Ot=Gt=Yt=ts=Ft=null,is=1,ia(!0),ce!=de||ue!=he||re!=fe||le!=pe){Bs(!1);let e=re/fe,t=le/pe;if(H&&!ve&&$.left>=0){$.left*=e,$.top*=t,Ws&&ht(Ws,$t($.left),0,re,le),qs&&ht(qs,0,$t($.top),re,le);for(let s=0;s=0&&Cn.width>0){Cn.left*=e,Cn.width*=e,Cn.top*=t,Cn.height*=t;for(let e in ca)lt(En,e,Cn[e])}de=ce,he=ue,fe=re,pe=le}Fa("setSize"),we=!1}oe>0&&ie>0&&(d.clearRect(0,0,u.width,u.height),Fa("drawClear"),M.forEach(e=>e()),Fa("draw")),Cn.show&&Se&&(Nn(Cn),Se=!1),H&&ve&&(aa(null,!0,!1),ve=!1),O.show&&O.live&&Ce&&(sa(),Ce=!1),l||(l=!0,n.status=1,Fa("ready")),cs=!1,en=!1}function xn(e,s){let a=v[e];if(null==a.from){if(0==mt){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(mt>1&&null!=s.min&&null!=s.max&&s.max-s.min<1e-16)return;e==C&&2==a.distr&&mt>0&&(s.min=kt(s.min,t[0]),s.max=kt(s.max,t[0]),s.min==s.max&&s.max++),D[e]=s,xe=!0,gn()}}n.batch=function(e,t=!1){en=!0,tn=t,e(n),yn(),t&&dn.length>0&&queueMicrotask(mn)},n.redraw=(e,t)=>{ke=t||!1,!1!==e?Dn(C,j.min,j.max):gn()},n.setScale=xn;let wn=!1;const kn=$.drag;let vn=kn.x,Sn=kn.y;H&&($.x&&(Os=ut("u-cursor-x",p)),$.y&&($s=ut("u-cursor-y",p)),0==j.ori?(Ws=Os,qs=$s):(Ws=$s,qs=Os),Qs=$.left,Zs=$.top);const Cn=n.select=Ms({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),En=Cn.show?ut("u-select",Cn.over?p:f):null;function Nn(e,t){if(Cn.show){for(let t in e)Cn[t]=e[t],t in ca&<(En,t,e[t]);!1!==t&&Fa("setSelect")}}function Dn(e,t,s){xn(e,{min:t,max:s})}function In(e,t,s,o){null!=t.focus&&function(e){if(e!=$n){let t=null==e,s=1!=Pe.alpha;b.forEach((n,o)=>{if(1==a||o>0){let a=t||0==o||o==e;n._focus=t?null:a,s&&function(e,t){b[e].alpha=t,H&&null!=De[e]&&(De[e].style.opacity=t),W&&V[e]&&(V[e].style.opacity=t)}(o,a?1:Pe.alpha)}}),$n=e,s&&gn()}}(e),null!=t.show&&b.forEach((s,n)=>{n>0&&(e==n||null==e)&&(s.show=t.show,function(e){if(b[e].show)W&&rt(V[e],Fe);else if(W&&it(V[e],Fe),H){let t=Ne?De[0]:De[e];null!=t&&ht(t,-10,-10,re,le)}}(n),2==a?(Dn(s.facets[0].scale,null,null),Dn(s.facets[1].scale,null,null)):Dn(s.scale,null,null),gn())}),!1!==s&&Fa("setSeries",e,t),o&&Oa("setSeries",n,e,t)}let Fn,On,$n;n.setSelect=Nn,n.setSeries=In,n.addBand=function(e,t){e.fill=es(e.fill||null),e.dir=Dt(e.dir,-1),t=null==t?S.length:t,S.splice(t,0,e)},n.setBand=function(e,t){Ms(S[e],t)},n.delBand=function(e){null==e?S.length=0:S.splice(e,1)};const Jn={focus:!0};function Vn(e,t,s){let n=v[t];s&&(e=e/at-(1==n.ori?ue:ce));let a=re;1==n.ori&&(a=le,e=a-e),-1==n.dir&&(e=a-e);let o=n._min,i=o+(n._max-o)*(e/a),r=n.distr;return 3==r?qt(10,i):4==r?((e,t=1)=>Rt.sinh(e)*t)(i,n.asinh):100==r?n.bwd(i):i}function Kn(e,t){lt(En,$e,Cn.left=e),lt(En,Re,Cn.width=t)}function Qn(e,t){lt(En,Be,Cn.top=e),lt(En,ze,Cn.height=t)}W&&Ee&&ne(Ve,q,e=>{$._lock||(_e(e),null!=$n&&In(null,Jn,!0,Ra.setSeries))}),n.valToIdx=e=>kt(e,t[0]),n.posToIdx=function(e,s){return kt(Vn(e,C,s),t[0],yt,bt)},n.posToVal=Vn,n.valToPos=(e,t,s)=>0==v[t].ori?o(e,v[t],s?ye:re,s?me:0):i(e,v[t],s?be:le,s?ge:0),n.setCursor=(e,t,s)=>{Qs=e.left,Zs=e.top,aa(null,t,s)};let Zn=0==j.ori?Kn:Qn,ea=1==j.ori?Kn:Qn;function sa(e,t){if(null!=e&&(e.idxs?e.idxs.forEach((e,t)=>{B[t]=e}):void 0!==e.idx&&B.fill(e.idx),O.idx=B[0]),W&&O.live){for(let e=0;e0||1==a&&!X)&&na(e,B[e]);!function(){if(W&&O.live)for(let e=2==a?1:0;ebt;Fn=Kt,On=null;let l=0==j.ori?re:le,c=1==j.ori?re:le;if(Qs<0||0==mt||r){i=$.idx=null;for(let e=0;e0&&e.show){let s=null==w?-10:w==i?o:E(1==a?t[0][w]:t[g][0][w],j,l,0),y=null==k?-10:N(k,1==a?v[e.scale]:v[e.facets[1].scale],c,0);if(Ee&&null!=k){let t=1==j.ori?Qs:Zs,s=Bt(Pe.dist(n,g,w,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)&&(Fn=s,On=g)}else Fn=s,On=g}}if(Ce||Ne){let e,t;0==j.ori?(e=s,t=y):(e=y,t=s);let a,o,i,l,c,b,x=!0,w=je.bbox;if(null!=w){x=!1;let e=w(n,g);i=e.left,l=e.top,a=e.width,o=e.height}else i=e,l=t,a=o=je.size(n,g);if(b=je.fill(n,g),c=je.stroke(n,g),Ne)g==On&&Fn<=Pe.prox&&(r=i,u=l,d=a,h=o,f=x,p=b,m=c);else{let e=De[g];null!=e&&(Ie[g]=i,He[g]=l,gt(e,a,o,x),pt(e,b,c),ht(e,Wt(i),Wt(l),re,le))}}}}if(Ne){let e=Pe.prox;if(Ce||(null==$n?Fn<=e:Fn>e||On!=$n)){let e=De[0];null!=e&&(Ie[0]=r,He[0]=u,gt(e,d,h,f),pt(e,p,m),ht(e,Wt(r),Wt(u),re,le))}}}if(Cn.show&&wn)if(null!=e){let[t,s]=Ra.scales,[n,a]=Ra.match,[o,i]=e.cursor.sync.scales,r=e.cursor.drag;if(vn=r._x,Sn=r._y,vn||Sn){let r,u,d,h,f,{left:p,top:m,width:g,height:y}=e.select,b=e.scales[o].ori,x=e.posToVal,w=null!=t&&n(t,o),k=null!=s&&a(s,i);w&&vn?(0==b?(r=p,u=g):(r=m,u=y),d=v[t],h=E(x(r,o),d,l,0),f=E(x(r+u,o),d,l,0),Zn(Ht(h,f),Bt(f-h))):Zn(0,l),k&&Sn?(1==b?(r=p,u=g):(r=m,u=y),d=v[s],h=N(x(r,i),d,c,0),f=N(x(r+u,i),d,c,0),ea(Ht(h,f),Bt(f-h))):ea(0,c)}else ua()}else{let e=Bt(Ks-Gs),t=Bt(Xs-Js);if(1==j.ori){let s=e;e=t,t=s}vn=kn.x&&e>=kn.dist,Sn=kn.y&&t>=kn.dist;let s,n,a=kn.uni;null!=a?vn&&Sn&&(vn=e>=a,Sn=t>=a,vn||Sn||(t>e?Sn=!0:vn=!0)):kn.x&&kn.y&&(vn||Sn)&&(vn=Sn=!0),vn&&(0==j.ori?(s=Ys,n=Qs):(s=Vs,n=Zs),Zn(Ht(s,n),Bt(n-s)),Sn||ea(0,c)),Sn&&(1==j.ori?(s=Ys,n=Qs):(s=Vs,n=Zs),ea(Ht(s,n),Bt(n-s)),vn||Zn(0,l)),vn||Sn||(Zn(0,0),ea(0,0))}if(kn._x=vn,kn._y=Sn,null==e){if(o){if(null!=za){let[e,t]=Ra.scales;Ra.values[0]=null!=e?Vn(0==j.ori?Qs:Zs,e):null,Ra.values[1]=null!=t?Vn(1==j.ori?Qs:Zs,t):null}Oa(qe,n,Qs,Zs,re,le,i)}if(Ee){let e=o&&Ra.setSeries,t=Pe.prox;null==$n?Fn<=t&&In(On,Jn,!0,e):Fn>t?In(null,Jn,!0,e):On!=$n&&In(On,Jn,!0,e)}}Ce&&(O.idx=i,sa()),!1!==s&&Fa("setCursor")}n.setLegend=sa;let oa=null;function ia(e=!1){e?oa=null:(oa=p.getBoundingClientRect(),Fa("syncRect",oa))}function ra(e,t,s,n,a,o,i){$._lock||wn&&null!=e&&0==e.movementX&&0==e.movementY||(la(e,t,s,n,a,o,0,!1,null!=e),null!=e?aa(null,!0,!0):aa(t,!0,!1))}function la(e,t,s,a,o,i,l,c,u){if(null==oa&&ia(!1),_e(e),null!=e)s=e.clientX-oa.left,a=e.clientY-oa.top;else{if(s<0||a<0)return Qs=-10,void(Zs=-10);let[e,n]=Ra.scales,l=t.cursor.sync,[c,u]=l.values,[d,h]=l.scales,[f,p]=Ra.match,m=t.axes[0].side%2==1,g=0==j.ori?re:le,y=1==j.ori?re:le,b=m?i:o,x=m?o:i,w=m?a:s,k=m?s:a;if(s=null!=d?f(e,d)?r(c,v[e],g,0):-10:g*(w/b),a=null!=h?p(n,h)?r(u,v[n],y,0):-10:y*(k/x),1==j.ori){let e=s;s=a,a=e}}!u||null!=t&&t.cursor.event.type!=qe||((s<=1||s>=re-1)&&(s=ls(s,re)),(a<=1||a>=le-1)&&(a=ls(a,le))),c?(Gs=s,Js=a,[Ys,Vs]=$.move(n,s,a)):(Qs=s,Zs=a)}Object.defineProperty(n,"rect",{get:()=>(null==oa&&ia(!1),oa)});const ca={width:0,height:0,left:0,top:0};function ua(){Nn(ca,!1)}let da,ha,fa,pa;function ma(e,t,s,a,o,i,r){wn=!0,vn=Sn=kn._x=kn._y=!1,la(e,t,s,a,o,i,0,!0,!1),null!=e&&(ne(Je,tt,ga,!1),Oa(Ge,n,Ys,Vs,re,le,null));let{left:l,top:c,width:u,height:d}=Cn;da=l,ha=c,fa=u,pa=d}function ga(e,t,s,a,o,i,r){wn=kn._x=kn._y=!1,la(e,t,s,a,o,i,0,!1,!0);let{left:l,top:c,width:u,height:d}=Cn,h=u>0||d>0,f=da!=l||ha!=c||fa!=u||pa!=d;if(h&&f&&Nn(Cn),kn.setScale&&h&&f){let e=l,t=u,s=c,n=d;if(1==j.ori&&(e=c,t=d,s=l,n=u),vn&&Dn(C,Vn(e,C),Vn(e+t,C)),Sn)for(let a in v){let e=v[a];a!=C&&null==e.from&&e.min!=Kt&&Dn(a,Vn(s+n,a),Vn(s,a))}ua()}else $.lock&&($._lock=!$._lock,aa(t,!0,null!=e));null!=e&&(ae(Je,tt),Oa(Je,n,Qs,Zs,re,le,null))}function ya(e,t,s,a,o,i,r){$._lock||(_e(e),ps(),ua(),null!=e&&Oa(Ke,n,Qs,Zs,re,le,null))}function ba(){k.forEach(Ia),Te(n.width,n.height,!0)}xt(Qe,st,ba);const xa={};xa.mousedown=ma,xa.mousemove=ra,xa.mouseup=ga,xa.dblclick=ya,xa.setSeries=(e,t,s,a)=>{-1!=(s=(0,Ra.match[2])(n,t,s))&&In(s,a,!0,!1)},H&&(ne(Ge,p,ma),ne(qe,p,ra),ne(Ye,p,e=>{_e(e),ia(!1)}),ne(Ve,p,function(e,t,s,n,a,o,i){if($._lock)return;_e(e);let r=wn;if(wn){let e,t,s=!0,n=!0,a=10;0==j.ori?(e=vn,t=Sn):(e=Sn,t=vn),e&&t&&(s=Qs<=a||Qs>=re-a,n=Zs<=a||Zs>=le-a),e&&s&&(Qs=Qs{e.call(null,n,t,s)})}(e.plugins||[]).forEach(e=>{for(let t in e.hooks)ka[t]=(ka[t]||[]).concat(e.hooks[t])});const Aa=(e,t,s)=>s,Ra=Ms({key:null,setSeries:!1,filters:{pub:as,sub:as},scales:[C,b[1]?b[1].scale:null],match:[os,os,Aa],values:[null,null]},$.sync);2==Ra.match.length&&Ra.match.push(Aa),$.sync=Ra;const za=Ra.key,Ba=Yn(za);function Oa(e,t,s,n,a,o,i){Ra.filters.pub(e,t,s,n,a,o,i)&&Ba.pub(e,t,s,n,a,o,i)}function $a(){Fa("init",e,t),us(t||e.data,!1),D[C]?xn(C,D[C]):ps(),Se=Cn.show&&(Cn.width>0||Cn.height>0),ve=Ce=!0,Te(e.width,e.height)}return Ba.sub(n),n.pub=function(e,t,s,n,a,o,i){Ra.filters.sub(e,t,s,n,a,o,i)&&xa[e](null,t,s,n,a,o,i)},n.destroy=function(){Ba.unsub(n),wa.delete(n),se.clear(),wt(Qe,st,ba),c.remove(),null==q||q.remove(),Fa("destroy")},b.forEach(et),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?b[1].scale:C,a=v[e.scale]);let o=a.time;e.size=es(e.size),e.space=es(e.space),e.rotate=es(e.rotate),bs(e.incrs)&&e.incrs.forEach(e=>{!hs.has(e)&&hs.set(e,fs(e))}),e.incrs=es(e.incrs||(2==a.distr?Hs:o?1==y?sn:on:Us)),e.splits=es(e.splits||(o&&1==a.distr?A:3==a.distr?jn:4==a.distr?Pn:_n)),e.stroke=es(e.stroke),e.grid.stroke=es(e.grid.stroke),e.ticks.stroke=es(e.ticks.stroke),e.border.stroke=es(e.border.stroke);let i=e.values;e.values=bs(i)&&!bs(i[0])?es(i):o?bs(i)?un(I,cn(i,F)):ws(i)?function(e,t){let s=Rs(t);return(t,n,a,o,i)=>n.map(t=>s(e(t)))}(I,i):i||R:i||Ln,e.filter=es(e.filter||(a.distr>=3&&10==a.log?An:3==a.distr&&2==a.log?Rn:ss)),e.font=Da(e.font),e.labelFont=Da(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&&(nt[t]=!0,e._el=ut("u-axis",h))}}),s?s instanceof HTMLElement?(s.appendChild(c),$a()):s(n,$a):$a(),n}Fa.assign=Ms,Fa.fmtNum=At,Fa.rangeNum=Nt,Fa.rangeLog=Lt,Fa.rangeAsinh=_t,Fa.orient=Vn,Fa.pxRatio=at,Fa.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=Ut(1,Ot((a-n+1)/t));for(let i=e[n],r=n+o;r<=a;r+=o){const t=e[r];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;iVn(e,o,(l,c,u,d,h,f,p,m,g,y,b)=>{[i,r]=Tt(u,i,r);let x=l.pxRound,{left:w,width:k}=e.bbox,v=e=>x(f(e,d,y,m)),S=e=>x(p(e,h,b,g)),C=0==d.ori?oa:ia;const T={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},M=T.stroke,L=d.dir*(0==d.ori?1:-1);let _=S(u[1==L?i:r]),j=v(c[1==L?i:r]),P=j,E=j;a&&-1==t&&(E=w,C(M,E,_)),C(M,j,_);for(let e=1==L?i:r;e>=i&&e<=r;e+=L){let s=u[e];if(null==s)continue;let n=v(c[e]),a=S(s);1==t?C(M,n,_):C(M,P,a),C(M,n,a),_=a,P=n}let N=P;a&&1==t&&(N=w+k,C(M,N,_));let[D,I]=Kn(e,o);if(null!=l.fill||0!=D){let t=T.fill=new Path2D(M),s=S(l.fillTo(e,o,l.min,l.max,D));C(t,N,s),C(t,E,s)}if(!l.spanGaps){let a=[];a.push(...ea(c,u,i,r,L,v,n));let h=l.width*at/2,f=s||1==t?h:-h,p=s||-1==t?-h:h;a.forEach(e=>{e[0]+=f,e[1]+=p}),T.gaps=a=l.gaps(e,o,i,r,a),T.clip=Zn(a,d.ori,m,g,y,b)}return 0!=I&&(T.band=2==I?[Qn(e,o,i,r,M,-1),Qn(e,o,i,r,M,1)]:Qn(e,o,i,r,M,I)),T})},e.bars=function(e){const t=Dt((e=e||ms).size,[.6,Kt,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=es(a),i=1-t[0],r=Dt(t[1],Kt),l=Dt(t[2],1),c=Dt(e.disp,ms),u=Dt(e.each,e=>{}),{fill:d,stroke:h}=c;return(e,t,a,f)=>Vn(e,t,(p,m,g,y,b,x,w,k,v,S,C)=>{let T,M,L=p.pxRound,_=s,j=n*at,P=r*at,E=l*at;0==y.ori?[T,M]=o(e,t):[M,T]=o(e,t);const N=y.dir*(0==y.ori?1:-1);let D,I,F,A=0==y.ori?ra:la,R=0==y.ori?u:(e,t,s,n,a,o,i)=>{u(e,t,s,a,n,i,o)},z=Dt(e.bands,gs).find(e=>e.series[0]==t),B=null!=z?z.dir:0,O=p.fillTo(e,t,p.min,p.max,B),$=L(w(O,b,C,v)),W=S,H=L(p.width*at),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:K}=c;if(null!=V&&null!=K){_=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=K.values(e,t,a,f);I=2==K.unit?s[0]*S:x(s[0],y,S,k)-x(0,y,S,k),W=ba(m,g,x,y,S,k,W),F=W-I+j}else W=ba(m,g,x,y,S,k,W),F=W*i+j,I=W-F;F<1&&(F=0),H>=I/2&&(H=0),F<5&&(L=ts);let X=F>0;I=L(Qt(W-F-(X?H:0),E,P)),D=(0==_?I/2:_==N?0:I)-_*N*((0==_?j/2:0)+(X?H/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Z=U?null:new Path2D;let ee=null;if(null!=z)ee=e.data[z.series[1]];else{let{y0:s,y1:n}=c;null!=s&&null!=n&&(g=n.values(e,t,a,f),ee=s.values(e,t,a,f))}let te=T*I,se=M*I;for(let s=1==N?a:f;s>=a&&s<=f;s+=N){let n=g[s];if(null==n)continue;if(null!=ee){let e=ee[s]??0;if(n-e==0)continue;$=w(e,b,C,v)}let a=x(2!=y.distr||null!=c?m[s]:s,y,S,k),o=w(Dt(n,O),b,C,v),i=L(a-D),r=L(Ut(o,$)),l=L(Ht(o,$)),u=r-l;if(null!=n){let a=n<0?se:te,o=n<0?te:se;U?(H>0&&null!=J[s]&&A(Y.get(J[s]),i,l+Ot(H/2),I,Ut(0,u-H),a,o),null!=q[s]&&A(G.get(q[s]),i,l+Ot(H/2),I,Ut(0,u-H),a,o)):A(Z,i,l+Ot(H/2),I,Ut(0,u-H),a,o),R(e,t,s,i-H/2,l,I+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=Dt(null==t?void 0:t.alignGaps,0);return(t,n,a,o)=>Vn(t,n,(i,r,l,c,u,d,h,f,p,m,g)=>{[a,o]=Tt(l,a,o);let y,b,x,w=i.pxRound,k=e=>w(d(e,c,m,f)),v=e=>w(h(e,u,g,p));0==c.ori?(y=na,x=oa,b=da):(y=aa,x=ia,b=ha);const S=c.dir*(0==c.ori?1:-1);let C=k(r[1==S?a:o]),T=C,M=[],L=[];for(let e=1==S?a:o;e>=a&&e<=o;e+=S)if(null!=l[e]){let t=k(r[e]);M.push(T=t),L.push(v(l[e]))}const _={stroke:e(M,L,y,x,b,w),fill:null,clip:null,band:null,gaps:null,flags:1},j=_.stroke;let[P,E]=Kn(t,n);if(null!=i.fill||0!=P){let e=_.fill=new Path2D(j),s=v(i.fillTo(t,n,i.min,i.max,P));x(e,T,s),x(e,C,s)}if(!i.spanGaps){let e=[];e.push(...ea(r,l,a,o,S,k,s)),_.gaps=e=i.gaps(t,n,a,o,e),_.clip=Zn(e,c.ori,f,p,m,g)}return 0!=E&&(_.band=2==E?[Qn(t,n,a,o,j,-1),Qn(t,n,a,o,j,1)]:Qn(t,n,a,o,j,E)),_})}(xa,e)}}const Aa=new Map;function Ra(e){var t;if(!e.startsWith("var("))return e;const s=Aa.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 Aa.set(e,i),i}const za=s.memo(function({timestamps:e,series:t,onHover:a,highlightedKey:o=null,cursorColor:i="rgba(255,255,255,0.5)"}){const r=s.useRef(null),l=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,r=a.width,l=a.height;if(r<=0||l<=0)return;const c=e.data[0],u=c.length;if(0===u)return;const d=c[0],h=c[u-1]-d||1,f=e=>{const t=c[e];return o+(t-d)/h*r},p=e=>i+l*(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,r=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=r.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 ${r.fontFamily}`,t.fillStyle=r.textPrimary,t.textBaseline="middle",t.textAlign="left";const l=8*i;for(const c of[0,20,40,60,80,100]){const e=n+o*(1-c/100),s=Math.max(n+l,Math.min(n+o-l,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=r.current;if(!t||0===e.length)return;const s=h.current,n=e.length,a=Math.abs(n-s);if(!(!l.current||a>100||s>0&&a/s>.1)&&l.current)return l.current.setData(f),void(h.current=n);l.current&&l.current.destroy();const o=t.getBoundingClientRect(),i=Math.floor(o.width)||400,c=Math.floor(o.height)||200,u=new Fa({...m,width:i,height:c},f,t);return l.current=u,h.current=n,()=>{u.destroy(),l.current=null}},[m,f,e.length]),s.useEffect(()=>{const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{const t=e[0];if(!t||!l.current)return;const{width:s,height:n}=t.contentRect;s>0&&n>0&&l.current.setSize({width:Math.floor(s),height:Math.floor(n)})});return t.observe(e),()=>{t.disconnect()}},[]),s.useEffect(()=>{l.current&&l.current.redraw()},[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:r,className:"w-full h-full rounded-2xl overflow-hidden",onMouseLeave:g})}),Ba=s.createContext(null);function Oa(e){const t=re(e);t&&function(e){if("undefined"==typeof document)return;const t=function(e){const t={},s=e.surfaces.glass;t["--glass-tint"]=s.tint,t["--glass-light"]=s.light,t["--glass-dark"]=s.dark,t["--glass-reflex-light"]=String(s.reflexLight),t["--glass-reflex-dark"]=String(s.reflexDark),t["--glass-blur"]=`${s.blur}px`,t["--glass-blur-elevated"]=`${s.blurElevated}px`,t["--glass-brightness"]=String(s.brightness),t["--glass-bg-opacity"]=`${s.opacity}%`,t["--glass-bg-opacity-elevated"]=`${s.opacityElevated}%`,t["--sidebar-tint"]=e.surfaces.sidebar.tint,t["--tooltip-bg"]=e.colors.bg.surface,t["--hover-tint"]=`rgba(${O(e.colors.accent.primary)}, 0.08)`,t["--shadow-tint"]=`rgba(${O(e.colors.accent.primary)}, 0.35)`,t["--bg-body"]=e.colors.bg.body,t["--bg-surface"]=e.colors.bg.surface,t["--bg-elevated"]=e.colors.bg.elevated,t["--bg-subtle"]=e.colors.bg.subtle,t["--border-subtle"]=e.colors.border.subtle,t["--border-strong"]=e.colors.border.strong,t["--text-primary"]=e.colors.text.primary,t["--text-secondary"]=e.colors.text.secondary,t["--text-muted"]=e.colors.text.muted,t["--text-invert"]=e.colors.text.inverse,t["--accent-primary"]=e.colors.accent.primary,t["--accent-secondary"]=e.colors.accent.secondary,t["--accent-tertiary"]=e.colors.accent.tertiary,t["--accent-success"]=e.colors.accent.success,t["--accent-danger"]=e.colors.accent.danger,t["--signal-excellent"]=e.colors.signal.excellent,t["--signal-good"]=e.colors.signal.good,t["--signal-fair"]=e.colors.signal.fair,t["--signal-poor"]=e.colors.signal.poor,t["--signal-critical"]=e.colors.signal.critical,t["--signal-unknown"]=e.colors.signal.unknown,t["--sparkline-excellent"]=e.colors.signal.excellent,t["--sparkline-good"]=e.colors.signal.good,t["--sparkline-fair"]=e.colors.signal.fair,t["--sparkline-poor"]=e.colors.signal.poor,t["--sparkline-critical"]=e.colors.signal.critical,t["--status-success"]=e.colors.status.success,t["--status-warning"]=e.colors.status.warning,t["--status-danger"]=e.colors.status.danger,t["--status-info"]=e.colors.status.info,t["--status-muted"]=e.colors.status.muted;const n=e.colors.chart;t["--pkt-advert"]=e.colors.accent.secondary,t["--pkt-flood"]=e.colors.accent.tertiary,t["--pkt-txt-msg"]=e.colors.accent.success,t["--pkt-ack"]=n.c8,t["--pkt-trace"]=n.c3,t["--pkt-req"]=n.c2,t["--pkt-response"]=n.c5,t["--pkt-grp-txt"]=e.colors.map.room,t["--pkt-grp-data"]=e.colors.accent.danger,t["--pkt-path"]=n.c3,t["--pkt-anon"]=e.colors.accent.secondary,t["--pkt-unknown"]=e.colors.status.muted,t["--route-flood"]=e.colors.accent.primary,t["--route-direct"]=e.colors.accent.secondary,t["--route-transport"]=n.c8,t["--chart-1"]=n.c1,t["--chart-2"]=n.c2,t["--chart-3"]=n.c3,t["--chart-4"]=n.c4,t["--chart-5"]=n.c5,t["--chart-6"]=n.c6,t["--chart-7"]=n.c7,t["--chart-8"]=n.c8,t["--chart-grid"]=n.grid,t["--chart-axis-tick"]=n.axis,t["--chart-cursor"]=n.cursor,t["--metric-received"]=e.colors.metric.received,t["--metric-forwarded"]=e.colors.metric.forwarded,t["--metric-transmitted"]=e.colors.metric.transmitted,t["--metric-dropped"]=e.colors.metric.dropped,t["--metric-neutral"]=e.colors.text.secondary,t["--log-debug"]=e.colors.status.muted,t["--log-info"]=e.colors.status.info,t["--log-warning"]=e.colors.status.warning,t["--log-error"]=e.colors.accent.danger,t["--log-critical"]=e.colors.accent.danger;const a=e.colors.map;t["--map-node-fill"]=a.nodeFill,t["--map-node-stroke"]=a.nodeStroke,t["--map-hub-color"]=a.hub,t["--map-local-color"]=a.local,t["--map-neighbor-color"]=a.neighbor,t["--map-mobile-color"]=a.mobile,t["--map-room-color"]=a.room,t["--map-edge-rest"]=a.edge,t["--map-edge-rest-bright"]=e.colors.border.strong,t["--map-edge-rest-dim"]=e.colors.bg.subtle,t["--map-edge-hover-direct"]=a.edgeHover,t["--map-edge-hover-loop"]=a.hub,t["--map-edge-hover-standard"]=e.colors.text.muted,t["--map-edge-hover-neighbor"]=a.local,t["--link-strong"]=e.colors.accent.success,t["--link-medium"]=e.colors.accent.secondary,t["--link-weak"]=e.colors.accent.danger,t["--hop-0"]=e.colors.accent.tertiary,t["--hop-1"]=e.colors.accent.success,t["--hop-2"]=n.c3,t["--hop-3"]=e.colors.accent.secondary,t["--hop-distant"]=e.colors.text.muted,t["--hop-hub"]=a.local,t["--icon-page-title"]=e.colors.accent.primary,t["--icon-card-title"]=e.colors.accent.primary,t["--icon-widget"]=e.colors.text.secondary,t["--icon-action"]=e.colors.text.secondary,t["--icon-nav"]=e.colors.text.muted,t["--icon-nav-active"]=e.colors.accent.primary,t["--toggle-on"]=e.colors.accent.success,t["--toggle-off"]=e.colors.bg.elevated,t["--font-title"]=e.typography.font.title,t["--font-display"]=e.typography.font.display,t["--font-data"]=e.typography.font.mono,t["--font-normal"]=String(e.typography.weight.normal),t["--font-medium"]=String(e.typography.weight.medium),t["--font-semibold"]=String(e.typography.weight.semibold),t["--font-bold"]=String(e.typography.weight.bold);const o=e.typography.size;o.xxl&&(t["--text-2xl"]=o.xxl),o.xl&&(t["--text-xl"]=o.xl),o.lg&&(t["--text-lg"]=o.lg),o.md&&(t["--text-md"]=o.md),o.base&&(t["--text-base"]=o.base),o.sm&&(t["--text-sm"]=o.sm),o.xs&&(t["--text-xs"]=o.xs),o.hero&&(t["--text-5xl"]=o.hero);const i=e.typography.tracking;return i&&(t["--tracking-tight"]=i.tight,t["--tracking-normal"]=i.normal,t["--tracking-wide"]=i.wide),t["--theme-transition"]=`${e.motion.slow} ${e.motion.easing}`,function(e){if(!A())return e;const t={},s=/^#[0-9A-Fa-f]{3,6}$/;for(const[n,a]of Object.entries(e))t[n]=s.test(a)?F(a):a;return t}(t)}(e),s=document.documentElement;for(const[n,a]of Object.entries(t))s.style.setProperty(n,a)}(t),document.documentElement.dataset.colorScheme=e}function $a({children:e}){const[t,a]=s.useState(()=>function(){if("undefined"==typeof window)return xe;try{let s=localStorage.getItem(we),n=localStorage.getItem(ke);const a=localStorage.getItem(ve);if(!s&&!n){const e=localStorage.getItem(Se);if(e){const t=be.find(t=>t.id===e);t&&(s=t.colorScheme,n=t.backgroundImage,localStorage.setItem(we,s),localStorage.setItem(ke,n),localStorage.removeItem(Se))}}const o=s&&"string"==typeof(t=s)&&ge.some(e=>e.id===t)?s:xe.colorScheme;let i=xe.backgroundImage;""===n?i="":n&&"string"==typeof(e=n)&&ye.some(t=>t.src===e)&&(i=n);let r=xe.brightness;if(a){const e=parseInt(a,10);!isNaN(e)&&e>=0&&e<=100&&(r=e)}return{colorScheme:o,backgroundImage:i,brightness:r}}catch{return xe}var e,t}());s.useEffect(()=>{Oa(t.colorScheme),Aa.clear(),requestAnimationFrame(()=>{!function(){if("undefined"==typeof window)return;for(const t of Le){const e=De(`--palette-${t}-bright`),s=De(`--palette-${t}`),n=e||s;if(!n)continue;const a=Ne(n);for(const o of Me)Ie(`--palette-${t}-${o}`,a[o])}const e=De("--palette-bg-4");if(e){const t=Ne(e);for(const e of Me)Ie(`--palette-neutral-${e}`,t[e])}}()})},[t.colorScheme]),s.useEffect(()=>{!function(e){if("undefined"!=typeof window)try{localStorage.setItem(we,e.colorScheme),localStorage.setItem(ke,e.backgroundImage),localStorage.setItem(ve,String(e.brightness))}catch{}}(t)},[t]),s.useEffect(()=>{ye.forEach(e=>{(new Image).src=e.src})},[]);const o=s.useCallback(e=>{a(t=>({...t,colorScheme:e}))},[]),i=s.useCallback(e=>{const t=ye.find(t=>t.src===e);a(s=>({...s,backgroundImage:e,brightness:(null==t?void 0:t.suggestedBrightness)??s.brightness}))},[]),r=s.useCallback(e=>{const t=Math.max(0,Math.min(100,Math.round(e)));a(e=>({...e,brightness:t}))},[]),l=s.useCallback(e=>{const t=be.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:r,setThemePreset:l}),[t,o,i,r,l]);return n.jsx(Ba.Provider,{value:c,children:e})}function Wa(){const e=s.useContext(Ba);if(!e)throw new Error("useTheme must be used within a ThemeProvider. Wrap your app with in App.tsx.");return e}const Ha="0.9.169",Ua="'JetBrains Mono', monospace",qa=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: ${Ua};\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,r={fontFamily:Ua,fontSize:.8*i+"px",fontWeight:400,lineHeight:1,letterSpacing:"-0.02em",whiteSpace:"nowrap"};return n.jsxs("span",{className:s,style:r,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"})]})}),Ga={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"},Ja={0:"T_FLOOD",1:"FLOOD",2:"DIRECT",3:"T_DIRECT"},Ya={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 Va(e){return 1===e||0===e}const Ka="pymc_jwt_token",Xa="pymc_client_id",Qa="pymc_remember_me",Za=new Set;function eo(e){return Za.add(e),()=>Za.delete(e)}function to(e){for(const s of Za)try{s(e)}catch(t){}}function so(){let e=localStorage.getItem(Xa);return e||(e=`${Date.now()}-${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(Xa,e)),e}function no(){return"true"===localStorage.getItem(Qa)}function ao(e){e?localStorage.setItem(Qa,"true"):localStorage.removeItem(Qa)}function oo(){return no()?localStorage:sessionStorage}function io(){return oo().getItem(Ka)||localStorage.getItem(Ka)||sessionStorage.getItem(Ka)}function ro(e){oo().setItem(Ka,e),no()?sessionStorage.removeItem(Ka):localStorage.removeItem(Ka),to(e)}function lo(){localStorage.removeItem(Ka),sessionStorage.removeItem(Ka),to(null)}function co(){return!(!io()||ho()&&(lo(),1))}function uo(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 ho(){const e=io();if(!e)return!0;const t=uo(e);return!t||!t.exp||Date.now()>=1e3*t.exp-6e4}function fo(){const e=io();if(!e)return 0;const t=uo(e);return t&&t.exp?Math.max(0,Math.floor((1e3*t.exp-Date.now())/1e3)):0}function po(){const e=io();if(!e)return!1;const t=uo(e);if(!t||!t.exp)return!1;const s=1e3*t.exp-Date.now();return s>0&&s<3e5}function mo(){const e=io();if(!e)return null;const t=uo(e);return t&&t.sub?t.sub:null}async function go(e,t,s=!1){ao(s);try{const s=await fetch("/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,client_id:so()})}),n=s.headers.get("content-type");if(!n||!n.includes("application/json"))return{success:!1,error:`Server error: ${s.status}`};const a=await s.json();return a.success&&a.token?(ro(a.token),{success:!0}):{success:!1,error:a.error||"Login failed"}}catch(n){return{success:!1,error:"Connection error. Please try again."}}}async function yo(){const e=io();if(!e)return!1;const t=uo(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:so()})});if(!t.ok){let e="";try{const s=await t.json();e=s.error||JSON.stringify(s)}catch{e=t.statusText}return!1}const s=await t.json();if(s.success&&s.token){ro(s.token);const e=uo(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 bo=null;async function xo(){const e=io();if(!e)return!1;const t=uo(e);return(null==t?void 0:t.exp)&&Math.floor((1e3*t.exp-Date.now())/1e3),!po()||bo||(bo=yo().finally(()=>{bo=null}),bo)}function wo(){lo()}let ko=!1;function vo(){if(ko)return;if("undefined"==typeof document)return;const e=async()=>{if("visible"!==document.visibilityState)return;if(!io())return;if(ho())return lo(),void("undefined"==typeof window||window.location.pathname.includes("/login")||(window.location.href="/login"));const e=fo();e>0&&e<300&&await yo()};document.addEventListener("visibilitychange",e),ko=!0,"visible"===document.visibilityState&&e()}const So=Object.freeze(Object.defineProperty({__proto__:null,clearToken:lo,getClientId:so,getRememberMe:no,getToken:io,getTokenTimeRemaining:fo,getUsername:mo,isAuthenticated:co,isTokenExpired:ho,login:go,logout:wo,onTokenChange:eo,parseJWT:uo,refreshToken:yo,refreshTokenIfNeeded:xo,setRememberMe:ao,setToken:ro,shouldRefreshToken:po,startVisibilityBasedRefresh:vo},Symbol.toStringTag,{value:"Module"})),Co=new Map;let To=!1;async function Mo(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=Co.get(n);if(e)return e}const a=`${e}`;!s&&po()&&await yo();const o=io();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 r=(async()=>{const n=await fetch(a,{...t,headers:i});if(401===n.status){if(!s&&!To&&await yo())return Mo(e,t,!0);throw To||(To=!0,lo(),window.location.replace("/login")),new Error("Session expired. Please log in again.")}if(!n.ok)throw new Error(`API error: ${n.status} ${n.statusText} (${e})`);return n.json()})();return n&&(Co.set(n,r),r.finally(()=>{Co.delete(n)})),r}const Lo={spreadingFactor:7,bandwidthHz:125e3,codingRate:5,preambleLength:8,crcEnabled:!0,explicitHeader:!0};function _o(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 jo(e,t={}){return void 0!==e.airtime_ms&&e.airtime_ms>0?e.airtime_ms:function(e,t={}){const s=t.spreadingFactor??Lo.spreadingFactor,n=t.bandwidthHz??Lo.bandwidthHz,a=t.codingRate??Lo.codingRate,o=t.preambleLength??Lo.preambleLength??8,i=t.crcEnabled??Lo.crcEnabled?1:0,r=t.explicitHeader??Lo.explicitHeader?0:1,l=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*r,0),f=4*(s-2*l);return d+(8+Math.ceil(h/f)*a)*u}(_o(e),t)}function Po(e){return e&&"chat node"===e.toLowerCase()?"Companion":e}async function Eo(){return function(e){if(e.neighbors)for(const t of Object.values(e.neighbors))t.contact_type=Po(t.contact_type);return e}(await Mo("/api/stats"))}async function No(){return Mo("/api/logs")}async function Do(e=24){return Mo(`/api/noise_floor_history?hours=${e}`)}const Io=new Map;function Fo(e=!1){if(e)Io.clear();else for(const[t]of Io)parseInt(t.split("-")[0],10)<=60&&Io.delete(t)}function Ao(e,t,s,n){const a=60*e/t,o=Math.floor(Date.now()/1e3),i=Math.floor(o/a)*a,r=i-60*e,l=s.filter(e=>e.timestamp>=r&&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)??Lo.spreadingFactor,bandwidthHz:(null==s?void 0:s.bandwidth)??Lo.bandwidthHz,codingRate:(null==s?void 0:s.coding_rate)??Lo.codingRate,preambleLength:(null==s?void 0:s.preamble_length)??Lo.preambleLength,crcEnabled:!0,explicitHeader:!0}}(n):Lo,u=function(e,t,s,n,a){const o=new Array(t),i=new Array(t),r=new Array(t),l=new Array(t),c=new Array(t),u=new Array(t),d=new Array(t);for(let f=0;f=t)continue;const m=jo(h,a),g=h.packet_origin;if("tx_local"===g?(r[p].count++,r[p].airtime_ms+=m):"tx_forward"===g||h.transmitted?(l[p].count++,l[p].airtime_ms+=m):h.drop_reason&&(c[p].count++,c[p].airtime_ms+=m),"tx_local"!==g){o[p].count++,o[p].airtime_ms+=m,u[p].snr+=h.snr||0,u[p].rssi+=h.rssi||0,u[p].count++;const e=h.packet_hash;e&&!d[p].has(e)&&(d[p].add(e),i[p].count++,i[p].airtime_ms+=m)}}for(let f=0;f0&&(o[f].avg_snr=u[f].snr/u[f].count,o[f].avg_rssi=u[f].rssi/u[f].count);return{received:o,unique_received:i,transmitted:r,forwarded:l,dropped:c}}(l,t,r,a,c);return{time_range_minutes:e,bucket_count:t,bucket_duration_seconds:a,start_time:r,end_time:i,...u}}async function Ro(){return Mo("/api/hardware_stats")}async function zo(e){return Mo("/api/update_radio_config",{method:"POST",body:JSON.stringify(e)})}async function Bo(){return Mo("/api/send_advert",{method:"POST",body:"{}"})}async function Oo(e){return Mo("/api/set_mode",{method:"POST",body:JSON.stringify({mode:e})})}async function $o(e){return Mo("/api/set_duty_cycle",{method:"POST",body:JSON.stringify({enabled:e})})}async function Wo(e){try{return await Mo("/api/log_level",{method:"POST",body:JSON.stringify({level:e})})}catch(t){return{success:!1,error:t instanceof Error?t.message:"Unknown error"}}}const Ho="pymc-packet-cache",Uo="pymc-packet-cache-meta",qo=36e5,Go=2592e5,Jo=6048e5,Yo=12096e5,Vo=5e3,Ko=5e5,Xo=new class{constructor(){t(this,"packets",new Map),t(this,"sortedPackets",[]),t(this,"sortedDirty",!0),t(this,"meta",{oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1}),t(this,"isLoading",!1),t(this,"isBackgroundLoading",!1),t(this,"isTopologyLoading",!1),t(this,"listeners",new Set),t(this,"loadProgress",null),t(this,"statusMessage",""),this.loadFromStorage()}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getState(){return{isLoading:this.isLoading,isBackgroundLoading:this.isBackgroundLoading,isTopologyLoading:this.isTopologyLoading,backgroundLoadComplete:this.meta.backgroundLoadComplete,topologyLoadComplete:this.meta.topologyLoadComplete,packetCount:this.packets.size,statusMessage:this.statusMessage,loadProgress:this.loadProgress,dataTier:this.meta.dataTier,threeDayLoadComplete:this.meta.threeDayLoadComplete,sevenDayLoadComplete:this.meta.sevenDayLoadComplete,fourteenDayLoadComplete:this.meta.fourteenDayLoadComplete}}getDataTier(){return this.meta.dataTier}getPackets(){return this.sortedDirty&&(this.sortedPackets=Array.from(this.packets.values()).sort((e,t)=>(e.timestamp??0)-(t.timestamp??0)),this.sortedDirty=!1),this.sortedPackets}isStale(){return 0===this.packets.size||Date.now()-this.meta.lastUpdated>qo}isHeavyLoadInProgress(){return this.isBackgroundLoading||this.isTopologyLoading}async initialLoad(e){if(this.isStale()&&this.packets.size>0&&this.clear(),this.meta.backgroundLoadComplete&&this.packets.size>0)return this.getPackets();this.isLoading=!0;const t=Date.now(),s=Math.floor((t-864e5)/1e3),n=3e4;this.loadProgress={loaded:0,target:n,percent:0},this.statusMessage="Loading 24h history...",this.notifyListeners();try{let t;this.packets.size>0&&(this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta.oldestTimestamp=0,this.meta.newestTimestamp=0);let a=0,o=0,i=0;const r=Math.ceil(100);for(let l=0;l0))break;{const n=this.packets.size;this.mergePackets(u.data);const i=this.packets.size-n;a+=i;const r=Math.min(...u.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===t||r=2)break}else o=0;if(u.data.length=Ko)break}l=5){this.statusMessage="Connection issues, loaded partial data",this.notifyListeners();break}await this.delay(2e3)}}this.enforceMemoryCap(),this.meta.backgroundLoadComplete=!0,this.meta.dataTier="24h",this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.saveToStorage()}catch(a){this.statusMessage="Load failed"}finally{this.isLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}return this.getPackets()}async quickLoad(){return this.initialLoad()}async backgroundLoad(){await this.initialLoad()}async loadThreeDays(e){this.meta.threeDayLoadComplete||this.isBackgroundLoading||await this.loadExtendedData("3d",Go,e)}async loadSevenDays(e){this.meta.sevenDayLoadComplete||this.isBackgroundLoading||(this.meta.threeDayLoadComplete||await this.loadThreeDays(e),await this.loadExtendedData("7d",Jo,e))}async loadFourteenDays(e){this.meta.fourteenDayLoadComplete||this.isBackgroundLoading||(this.meta.sevenDayLoadComplete||await this.loadSevenDays(e),await this.loadExtendedData("14d",Yo,e))}async loadExtendedData(e,t,s){this.isBackgroundLoading=!0;const n=Date.now(),a=Math.floor((n-t)/1e3),o=3e4*("3d"===e?2:"7d"===e?4:7);this.loadProgress={loaded:0,target:o,percent:0},this.statusMessage=`Loading ${e} history...`,this.notifyListeners();try{let t=this.meta.oldestTimestamp||void 0,n=0,i=0,r=0;const l=Math.ceil(100);for(let u=0;u0))break;{const e=this.packets.size;this.mergePackets(d.data);const o=this.packets.size-e;n+=o;const r=Math.min(...d.data.map(e=>e.timestamp??1/0));if(r!==1/0&&(void 0===t||r=2)break}else i=0;if(d.data.length=Ko)break}u=5)break;await this.delay(2e3)}}this.enforceMemoryCap();const c=Date.now()-1e3*this.meta.oldestTimestamp;"3d"===e?(this.meta.threeDayLoadComplete=c>=Go,this.meta.threeDayLoadComplete&&(this.meta.dataTier="3d")):"7d"===e?(this.meta.sevenDayLoadComplete=c>=Jo,this.meta.sevenDayLoadComplete&&(this.meta.dataTier="7d")):(this.meta.fourteenDayLoadComplete=c>=Yo,this.meta.fourteenDayLoadComplete&&(this.meta.dataTier="14d")),this.loadProgress={loaded:n,target:n,percent:100},this.notifyListeners(),this.saveToStorage()}catch(i){this.statusMessage=`${e} load failed`}finally{this.isBackgroundLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}isDataTierAvailable(e){switch(e){case"24h":return this.meta.backgroundLoadComplete;case"3d":return this.meta.threeDayLoadComplete;case"7d":return this.meta.sevenDayLoadComplete;case"14d":return this.meta.fourteenDayLoadComplete;default:return!1}}async topologyLoad(){if(!this.meta.topologyLoadComplete&&!this.isTopologyLoading)return this.doTopologyLoad()}async forceTopologyLoad(){if(!this.isTopologyLoading)return this.meta.topologyLoadComplete=!1,this.doTopologyLoad()}async forceDeepLoad(){return this.forceTopologyLoad()}async doTopologyLoad(){this.isTopologyLoading=!0;const e=Date.now(),t=Math.floor((e-Yo)/1e3),s=42e4;this.statusMessage="Loading topology data...",this.loadProgress={loaded:this.packets.size,target:s,percent:0},this.notifyListeners();try{let e=this.meta.oldestTimestamp||void 0,n=0,a=0;const o=Math.ceil(100);for(let i=0;i0))break;{const s=this.packets.size;this.mergePackets(l.data);const a=this.packets.size-s,o=Math.min(...l.data.map(e=>e.timestamp??1/0));if(o!==1/0&&(void 0===e||o=2)break}else n=0;if(this.packets.size>=Ko)break}i=5)break;await this.delay(2e3)}}this.enforceMemoryCap(),this.statusMessage=`Processing ${this.packets.size.toLocaleString()} packets...`,this.loadProgress={loaded:this.packets.size,target:this.packets.size,percent:100},this.notifyListeners(),this.meta.topologyLoadComplete=!0,this.meta.threeDayLoadComplete=!0,this.meta.sevenDayLoadComplete=!0,this.meta.fourteenDayLoadComplete=!0,this.meta.dataTier="14d",this.saveToStorage()}catch(n){this.statusMessage="Load failed"}finally{this.isTopologyLoading=!1,this.statusMessage="",this.loadProgress=null,this.notifyListeners()}}async poll(){try{const e=await this.fetchRecentPackets(100);if(e.success&&e.data){const t=this.packets.size;this.mergePackets(e.data),this.packets.size>t&&(this.saveToStorage(),this.notifyListeners())}}catch(e){}return this.getPackets()}clear(){this.packets.clear(),this.sortedPackets=[],this.sortedDirty=!0,this.meta={oldestTimestamp:0,newestTimestamp:0,lastUpdated:0,packetCount:0,backgroundLoadComplete:!1,topologyLoadComplete:!1,dataTier:"24h",threeDayLoadComplete:!1,sevenDayLoadComplete:!1,fourteenDayLoadComplete:!1},this.clearStorage(),this.notifyListeners()}mergePacketsDirectly(e){const t=this.packets.size;this.mergePackets(e);const s=this.packets.size-t;return s>0&&(this.enforceMemoryCap(),this.saveToStorage(),this.notifyListeners()),s}mergePackets(e){let t=!1;for(const s of e){const e=s.packet_hash;if(!e)continue;const n=s.timestamp??0,a=`${e}:${n}`;this.packets.has(a)||(this.packets.set(a,s),t=!0),(0===this.meta.oldestTimestamp||nthis.meta.newestTimestamp&&(this.meta.newestTimestamp=n)}t&&(this.sortedDirty=!0),this.meta.lastUpdated=Date.now(),this.meta.packetCount=this.packets.size}notifyListeners(){const e=this.getState();for(const t of this.listeners)t(e)}delay(e){return new Promise(t=>setTimeout(t,e))}async fetchChunkWithRetry(e,t,s,n,a){for(let 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<=Ko)return;const e=this.getPackets(),t=e.length-Ko;for(let s=0;st&&(this.meta.oldestTimestamp=e[t].timestamp??0)}loadFromStorage(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Uo);e&&(this.meta=JSON.parse(e));const t=localStorage.getItem(Ho);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>qo)return void this.clear();this.meta.backgroundLoadComplete=!1,this.meta.threeDayLoadComplete=!1,this.meta.sevenDayLoadComplete=!1,this.meta.fourteenDayLoadComplete=!1,this.meta.dataTier="24h";const s=37500;this.meta.topologyLoadComplete&&this.packets.size3e3?e.slice(-3e3):e;localStorage.setItem(Ho,JSON.stringify(t))}catch(e){if(e instanceof DOMException&&"QuotaExceededError"===e.name)try{localStorage.removeItem(Ho),localStorage.setItem(Uo,JSON.stringify(this.meta))}catch{}}}clearStorage(){if("undefined"!=typeof window)try{localStorage.removeItem(Ho),localStorage.removeItem(Uo)}catch(e){}}async fetchRecentPackets(e=1e3,t=!1){const s=`/api/recent_packets?limit=${e}`,{getToken:n}=await N(async()=>{const{getToken:e}=await Promise.resolve().then(()=>So);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 N(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>So);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 N(async()=>{const{getToken:e}=await Promise.resolve().then(()=>So);return{getToken:e}},void 0),r=i(),l={};r&&(l.Authorization=`Bearer ${r}`);const c=new AbortController,u=setTimeout(()=>c.abort(),3e4);try{const n=await fetch(o,{headers:l,signal:c.signal});if(401===n.status&&!s){const{refreshToken:s}=await N(async()=>{const{refreshToken:e}=await Promise.resolve().then(()=>So);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 Qo(e){return{paths:e.paths,byEndpoints:new Map(e.byEndpointsEntries),canonicalPaths:new Map(e.canonicalPathsEntries),totalObservations:e.totalObservations,uniquePathCount:e.uniquePathCount}}function Zo(){return{paths:[],byEndpoints:new Map,canonicalPaths:new Map,totalObservations:0,uniquePathCount:0}}const ei=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:Zo(),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?Qo(t.pathRegistry):Zo(),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,r){const l={packets:e,neighbors:t,localHash:s,localLat:n,localLon:a,airtimeMs:o,zeroHopNeighbors:i,terrainGrid:r,enableTerrainAware:void 0!==r};this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.isComputing?this.pendingRequest=l:this.computeInternal(l)},this.debounceMs)}subscribe(e){return this.listeners.add(e),this.currentTopology.edges.length>0&&e(this.currentTopology,0),()=>{this.listeners.delete(e)}}getTopology(){return this.currentTopology}isWorking(){return this.isComputing}terminate(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.worker&&(this.worker.terminate(),this.worker=null),this.listeners.clear()}},ti=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()}},si=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=eo(e=>{this.setAuthToken(e)}),await this.readyPromise}catch(t){throw t}}}handleMessage(e){var t;const s=e.data;switch(s.type){case"ready":null==(t=this.readyResolve)||t.call(this);break;case"stats":for(const e of this.statsListeners)try{e(s.data,s.timestamp)}catch(n){}break;case"packets":for(const e of this.packetsListeners)try{e(s.newPackets,s.totalCount,s.newestTimestamp)}catch(n){}break;case"packetsReset":for(const e of this.packetsListeners)try{e([],0,s.newestTimestamp)}catch(n){}break;case"error":for(const e of this.errorListeners)try{e(s.source,s.error)}catch(n){}}}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onPackets(e){return this.packetsListeners.add(e),()=>this.packetsListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}setAuthToken(e){if(!this.worker)return;const t={type:"setAuth",token:e};this.worker.postMessage(t)}setLiveMode(e){if(!this.worker)return;const t={type:"setLiveMode",enabled:e};this.worker.postMessage(t)}forceRefresh(){this.worker&&this.worker.postMessage({type:"forceRefresh"})}clearCache(){this.worker&&this.worker.postMessage({type:"clearCache"})}setTimeWindow(e){if(!this.worker)return;const t={type:"setTimeWindow",hours:e};this.worker.postMessage(t)}terminate(){if(this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.worker){const e={type:"stop"};this.worker.postMessage(e),this.worker.terminate(),this.worker=null}this.isInitialized=!1,this.statsListeners.clear(),this.packetsListeners.clear(),this.errorListeners.clear()}isReady(){return this.isInitialized}},ni=new class{constructor(){t(this,"ws",null),t(this,"connectionState","disconnected"),t(this,"reconnectAttempts",0),t(this,"pingIntervalId",null),t(this,"lastPongTime",Date.now()),t(this,"reconnectTimeoutId",null),t(this,"packetListeners",new Set),t(this,"statsListeners",new Set),t(this,"systemStatsListeners",new Set),t(this,"packetStatsListeners",new Set),t(this,"connectionListeners",new Set),t(this,"unsubscribeTokenChange",null),t(this,"wsSupported",!0)}buildWsUrl(){const e=io(),t=so(),s=new URLSearchParams;e&&s.set("token",e),t&&s.set("client_id",t);const n=s.toString()?`?${s.toString()}`:"";return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws/packets${n}`}connect(){var e,t;if((null==(e=this.ws)?void 0:e.readyState)!==WebSocket.OPEN&&(null==(t=this.ws)?void 0:t.readyState)!==WebSocket.CONNECTING&&this.wsSupported){this.setConnectionState("connecting");try{const e=this.buildWsUrl();this.ws=new WebSocket(e),this.ws.onopen=this.handleOpen.bind(this),this.ws.onmessage=this.handleMessage.bind(this),this.ws.onerror=this.handleError.bind(this),this.ws.onclose=this.handleClose.bind(this),this.unsubscribeTokenChange||(this.unsubscribeTokenChange=eo(e=>{e&&"connected"===this.connectionState&&(this.disconnect(),this.connect())}))}catch(s){this.wsSupported=!1,this.setConnectionState("disconnected")}}}disconnect(){this.clearPingInterval(),this.clearReconnectTimeout(),this.ws&&(this.ws.onopen=null,this.ws.onmessage=null,this.ws.onerror=null,this.ws.onclose=null,this.ws.readyState!==WebSocket.OPEN&&this.ws.readyState!==WebSocket.CONNECTING||this.ws.close(1e3,"Client disconnect"),this.ws=null),this.setConnectionState("disconnected"),this.reconnectAttempts=0}isConnected(){var e;return(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN}getConnectionState(){return this.connectionState}isSupported(){return this.wsSupported}send(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return!1}}onPacket(e){return this.packetListeners.add(e),()=>this.packetListeners.delete(e)}onStats(e){return this.statsListeners.add(e),()=>this.statsListeners.delete(e)}onSystemStats(e){return this.systemStatsListeners.add(e),()=>this.systemStatsListeners.delete(e)}onPacketStats(e){return this.packetStatsListeners.add(e),()=>this.packetStatsListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),e(this.connectionState,this.reconnectAttempts),()=>this.connectionListeners.delete(e)}handleOpen(){this.setConnectionState("connected"),this.reconnectAttempts=0,this.lastPongTime=Date.now();const e=io();e&&this.ws&&this.ws.send(JSON.stringify({type:"auth",token:e})),this.startPingInterval()}handleMessage(e){try{const t=JSON.parse(e.data);switch(t.type){case"packet":this.notifyPacketListeners(t.data);break;case"stats":{const e=t.data;e&&"noise_floor_dbm"in e&&this.notifyStatsListeners(e),(null==e?void 0:e.packet_stats)&&this.notifyPacketStatsListeners(e.packet_stats),(null==e?void 0:e.system_stats)&&this.notifySystemStatsListeners(e.system_stats);break}case"packet_stats":{const e=t.data;this.notifyPacketStatsListeners(e);break}case"system_stats":this.notifySystemStatsListeners(t.data);break;case"ping":this.lastPongTime=Date.now(),this.send({type:"pong"});break;case"pong":this.lastPongTime=Date.now()}}catch(t){}}handleError(e){}handleClose(e){this.clearPingInterval(),1e3!==e.code?(1006===e.code&&this.reconnectAttempts,this.scheduleReconnect()):this.setConnectionState("disconnected")}setConnectionState(e){if(this.connectionState!==e){this.connectionState=e;for(const s of this.connectionListeners)try{s(e,this.reconnectAttempts)}catch(t){}}}notifyPacketListeners(e){for(const s of this.packetListeners)try{s(e)}catch(t){}}notifyStatsListeners(e){for(const s of this.statsListeners)try{s(e)}catch(t){}}notifySystemStatsListeners(e){for(const s of this.systemStatsListeners)try{s(e)}catch(t){}}notifyPacketStatsListeners(e){for(const s of this.packetStatsListeners)try{s(e)}catch(t){}}startPingInterval(){this.clearPingInterval(),this.pingIntervalId=setInterval(()=>{var e;(null==(e=this.ws)?void 0:e.readyState)===WebSocket.OPEN&&(this.send({type:"ping"}),Date.now()-this.lastPongTime>6e4&&(this.disconnect(),this.connect()))},3e4)}clearPingInterval(){this.pingIntervalId&&(clearInterval(this.pingIntervalId),this.pingIntervalId=null)}scheduleReconnect(){if(this.reconnectAttempts>=20)return this.wsSupported=!1,void this.setConnectionState("disconnected");this.setConnectionState("reconnecting");const e=Math.min(1e3*Math.pow(2,Math.min(this.reconnectAttempts,5)),3e4);this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout(()=>{this.reconnectTimeoutId=null,this.connect()},e)}clearReconnectTimeout(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)}terminate(){this.disconnect(),this.unsubscribeTokenChange&&(this.unsubscribeTokenChange(),this.unsubscribeTokenChange=null),this.packetListeners.clear(),this.statsListeners.clear(),this.systemStatsListeners.clear(),this.packetStatsListeners.clear(),this.connectionListeners.clear()}},ai=3e4,oi=new class{constructor(){t(this,"staged",new Map),t(this,"recentlyConfirmed",new Map),t(this,"listeners",new Set),t(this,"pruneIntervalId",null),this.startPruneInterval()}stage(e){const t=e.packet_hash;if(!t)return;if(this.staged.has(t))return;const s=this.recentlyConfirmed.get(t);s&&Date.now()-s=100&&this.removeOldest(),this.staged.set(t,{packet:e,stagedAt:Date.now()}),this.notifyListeners())}confirm(e){this.staged.delete(e)&&this.notifyListeners()}confirmBatch(e){let t=!1;const s=Date.now();for(const n of e)this.recentlyConfirmed.set(n,s),this.staged.delete(n)&&(t=!0);if(this.recentlyConfirmed.size>200){const e=s-ai;for(const[t,s]of this.recentlyConfirmed)s(t.packet.timestamp??0)-(e.packet.timestamp??0))}isPending(e){return!!e&&this.staged.has(e)}getPendingCount(){return this.staged.size}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clear(){this.staged.size>0&&(this.staged.clear(),this.notifyListeners())}terminate(){this.stopPruneInterval(),this.staged.clear(),this.listeners.clear()}notifyListeners(){const e=this.getPendingPackets();for(const s of this.listeners)try{s(e)}catch(t){}}pruneExpired(){const e=Date.now();let t=!1;for(const[s,n]of this.staged)e-n.stagedAt>ai&&(this.staged.delete(s),t=!0);t&&this.notifyListeners()}removeOldest(){let e=null,t=1/0;for(const[s,n]of this.staged)n.stagedAtthis.pruneExpired(),1e4))}stopPruneInterval(){this.pruneIntervalId&&(clearInterval(this.pruneIntervalId),this.pruneIntervalId=null)}},ii=a(e=>({connectionState:"disconnected",isSupported:!0,reconnectAttempt:0,lastConnected:null,initialize:()=>{ni.onConnectionChange((t,s)=>{e(e=>({connectionState:t,reconnectAttempt:s??0,isSupported:ni.isSupported(),lastConnected:"connected"===t?Date.now():e.lastConnected}))}),ni.connect()}})),ri=.05,li=1e3,ci="terrarium";function ui(e,t,s){try{return e.queryTerrainElevation({lng:t,lat:s})??0}catch{return 0}}const di=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(ci)||(n.addSource(ci,{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===ci&&t.isSourceLoaded&&(clearTimeout(s),n.off("sourcedata",a),e())};n.on("sourcedata",a)})),n.setTerrain({source:ci}),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),r=Math.ceil((n-s)/.001);i>li&&(i=li),r>li&&(r=li);const l=(o-a)/i,c=(n-s)/r,u=Math.max(l,c),d=new Float32Array(i*r);let h=0;for(let f=0;fsetTimeout(e,0))}}return{origin:[s,a],cellSize:u,width:i,height:r,elevations:d}}(n,s);e({terrainGrid:t,isLoading:!1,lastLoadedAt:Date.now(),cachedBounds:s})}catch(r){const t=r instanceof Error?r.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-ri,maxLat:n+ri,minLng:a-ri,maxLng:o+ri}}(e);n&&await t().loadTerrain(n,s)},clearTerrain:()=>{e({terrainGrid:null,cachedBounds:null,lastLoadedAt:null,error:null})},setTerrainDisambiguationEnabled:t=>{e({terrainDisambiguationEnabled:t})},getTerrainGridForDisambiguation:()=>{const e=t();return e.terrainDisambiguationEnabled?e.terrainGrid:null}}));function hi(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2,4).toUpperCase():e.slice(0,2).toUpperCase()}function fi(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?hi(t):null,o=n[n.length-1],i=null!==a&&o===a,r=i?n.slice(0,-1):[...n];return{effective:r,original:n,hadLocal:i,effectiveLength:r.length}}function pi(e,t){const s=e.toUpperCase();return t.startsWith("0x")||t.startsWith("0X")?t.slice(2).toUpperCase().startsWith(s):t.toUpperCase().startsWith(s)}const mi=[{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},{label:"14d",minutes:20160,buckets:168}],gi=[{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 yi(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 bi="'JetBrains Mono', 'SF Mono', Monaco, monospace",xi={stats:3e3,packets:3e3,charts:3e4,logs:2e3,system:3e3},wi={DEBUG:"text-accent-tertiary",INFO:"text-accent-primary",WARNING:"text-signal-critical",ERROR:"text-accent-danger",CRITICAL:"text-signal-poor"};function ki(e){return wi[e]??"text-text-muted border-border-subtle"}const vi="pymc-resource-history",Si="pymc-resource-last-fetch",Ci="pymc-hidden-contacts",Ti="pymc-quick-neighbors",Mi="pymc-local-hash",Li="pymc-global-time-range";let _i=null,ji=null;function Pi(e,t){const s=t-1e3*e;return s<=6048e5?"active":s<=12096e5?"stale":"expired"}function Ei(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:Va(s)?t.length<=1:0===t.length;var n}(e)}function Ni(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 Di(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 Ii(e){return{hash:e,count:0,rssiSum:0,rssiCount:0,snrSum:0,snrCount:0,lastSeen:0}}function Fi(e,t){const s=Pi(e.lastSeen,t);return"expired"===s?null:{hash:e.hash,prefix:hi(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 Ai(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(Ti);if(e)return JSON.parse(e)}catch{}return[]}function Ri(e){"undefined"!=typeof window&&(ji&&clearTimeout(ji),ji=setTimeout(()=>{try{localStorage.setItem(Ti,JSON.stringify(e))}catch{}ji=null},1e3))}function zi(){if("undefined"!=typeof window)try{const e=localStorage.getItem(Mi);if(e)return e}catch{}}function Bi(e){if("undefined"!=typeof window)try{localStorage.setItem(Mi,e)}catch{}}function Oi(){if("undefined"==typeof window)return[];try{const e=localStorage.getItem(vi);if(e)return JSON.parse(e)}catch{}return[]}function $i(){if("undefined"==typeof window)return new Set;try{const e=localStorage.getItem(Ci);if(e)return new Set(JSON.parse(e))}catch{}return new Set}function Wi(){if("undefined"==typeof window)return 0;try{const e=localStorage.getItem(Si);if(e)return parseInt(e,10)||0}catch{}return 0}function Hi(){if("undefined"==typeof window)return 4;try{const e=localStorage.getItem(Li);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>=0&&t<=7)return t}}catch{}return 4}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,pendingAdvertLocalHash:null,pendingAdvertTimestamp:null,resourceHistory:Oi(),lastResourceFetch:Wi(),hiddenContacts:$i(),quickNeighbors:Ai(),cachedLocalHash:zi(),initialized:!1,packetCacheState:Xo.getState(),mutationsInFlight:new Set,globalTimeRangeIndex:Hi(),initializeApp:async()=>{const{initialized:s}=t();if(!s){e({initialized:!0,statsLoading:!0,packetsLoading:!0}),Xo.subscribe(t=>{e({packetCacheState:t})});try{const{hiddenContacts:s}=t(),n=await Eo(),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=Pi(t.last_seen??0,o);"expired"!==n&&i.push({hash:e,prefix:hi(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 r=n.local_hash;e({stats:n,statsLoading:!1,quickNeighbors:i,cachedLocalHash:r}),Ri(i),r&&Bi(r);const l=()=>{const s=Xo.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 Xo.initialLoad(l);if(c.length>0){const s=c.reduce((e,t)=>{const s=t.timestamp??0;return s>e?s:e},0);e({packets:[...c],packetsLoading:!1,lastPacketTimestamp:s}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}else e({packetsLoading:!1})}catch(n){e({statsError:n instanceof Error?n.message:"Failed to initialize",statsLoading:!1,packetsLoading:!1})}ii.getState().initialize(),ni.onPacket(s=>{const{lastPacketTimestamp:n,mutationsInFlight:a}=t();if(a.size>0)return;oi.stage(s);const o=s.timestamp??0;o>n&&e({flashReceived:t().flashReceived+1,lastPacketTimestamp:o})}),ni.onStats(s=>{const{mutationsInFlight:n,hiddenContacts:a}=t();if(n.size>0)return;const o=s.neighbors??{},i=Date.now(),r=[];for(const[e,t]of Object.entries(o)){if(a.has(e))continue;if(!t.zero_hop)continue;const s=Pi(t.last_seen??0,i);"expired"!==s&&r.push({hash:e,prefix:hi(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 l=s.local_hash;e({stats:s,statsLoading:!1,quickNeighbors:r,cachedLocalHash:l}),Ri(r),l&&Bi(l)}),ni.onPacketStats(s=>{const{stats:n,mutationsInFlight:a}=t();if(!n||a.size>0)return;const o={...n,rx_count:s.rx_count??n.rx_count,tx_count:s.tx_count??n.tx_count,forwarded_count:s.forwarded_count??n.forwarded_count,dropped_count:s.dropped_count??n.dropped_count};e({stats:o})});try{await si.init({apiBaseUrl:"",authToken:io()??void 0,statsIntervalMs:xi.stats,packetsIntervalMs:xi.packets}),si.onStats((s,n)=>{const{mutationsInFlight:a,hiddenContacts:o}=t();if(a.size>0)return;const i=s.neighbors??{},r=Date.now(),l=[];for(const[e,t]of Object.entries(i)){if(o.has(e))continue;if(!t.zero_hop)continue;const s=Pi(t.last_seen??0,r);"expired"!==s&&l.push({hash:e,prefix:hi(e),count:t.advert_count??0,avgRssi:t.rssi??null,avgSnr:t.snr??null,lastSeen:t.last_seen??0,status:s})}l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen);const c=s.local_hash;e({stats:s,statsLoading:!1,quickNeighbors:l,cachedLocalHash:c}),Ri(l),c&&Bi(c)}),si.onPackets((s,n,a)=>{if(0===s.length)return;const{lastPacketTimestamp:o}=t(),i=s.map(e=>e.packet_hash).filter(e=>!!e);oi.confirmBatch(i),Xo.mergePacketsDirectly(s);const r=a>o;r&&Fo();const l=Xo.getPackets();e({packets:l,packetsLoading:!1,lastPacketTimestamp:a}),r&&t().triggerTopologyCompute()}),si.onError((t,s)=>{e("stats"===t?{statsError:s}:{packetsError:s})}),"undefined"!=typeof document&&document.addEventListener("visibilitychange",()=>{document.hidden||si.forceRefresh()})}catch(n){!function(e){setInterval(()=>{e().fetchStats()},xi.stats),setInterval(()=>{e().liveMode&&!Xo.isHeavyLoadInProgress()&&e().fetchPackets()},xi.packets)}(t)}}},prefetchForRoute:e=>{switch(e){case"/logs":No().catch(()=>{});break;case"/system":Ro().catch(()=>{});break;case"/statistics":(async function(e=24){return Mo(`/api/packet_type_graph_data?hours=${e}`)})(3).catch(()=>{}),Do(3).catch(()=>{});break;case"/settings":(async function(){return Mo("/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 Eo(),s=t.neighbors??{},n=Date.now(),a=[];for(const[e,r]of Object.entries(s)){if(o.has(e))continue;if(!r.zero_hop)continue;const t=Pi(r.last_seen??0,n);"expired"!==t&&a.push({hash:e,prefix:hi(e),count:r.advert_count??0,avgRssi:r.rssi??null,avgSnr:r.snr??null,lastSeen:r.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}),Ri(a),i&&Bi(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 Xo.poll(),o=s.length>0?s.reduce((e,t)=>Math.max(e,t.timestamp??0),0):0,i=o>a&&a>0,r=s.length!==n.length||i;i&&(e({flashReceived:t().flashReceived+1}),Fo()),e(r?{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 No();e({logs:t.logs,logsLoading:!1})}catch{e({logsLoading:!1})}},setLiveMode:t=>{e({liveMode:t}),si.isReady()&&si.setLiveMode(t)},setMode:async s=>{const n="setMode",{mutationsInFlight:a}=t(),o=new Set(a);o.add(n),e({mutationsInFlight:o});try{if(!(await Oo(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 $o(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 Mo("/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(r){const{mutationsInFlight:s}=t(),n=new Set(s);throw n.delete(a),e({mutationsInFlight:n}),r}},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 Bo();return s.success?(e({flashAdvert:t().flashAdvert+1}),{success:!0}):{success:!1,error:s.error||"Failed to send advert"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Unknown error"}}},triggerFlashReceived:()=>{e({flashReceived:t().flashReceived+1})},triggerFlashAdvert:()=>{e({flashAdvert:t().flashAdvert+1})},addResourceDataPoint:(s,n,a)=>{const o=Date.now(),{lastResourceFetch:i,resourceHistory:r}=t();if(o-i<1e3)return;const l=[...r,{timestamp:o,time:new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),cpu:s,memory:n}],c=l.length>a?l.slice(-a):l;var u,d;e({resourceHistory:c,lastResourceFetch:o}),u=c,d=o,"undefined"!=typeof window&&(_i&&clearTimeout(_i),_i=setTimeout(()=>{try{localStorage.setItem(vi,JSON.stringify(u)),localStorage.setItem(Si,d.toString())}catch{}_i=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(Ci,JSON.stringify([...e]))}catch{}}(a)},clearPacketCache:()=>{Xo.clear(),e({packets:[],lastPacketTimestamp:0}),Xo.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:r}=t();if(0===o.length||!i)return;const l=i.neighbors??{},c=Object.fromEntries(Object.entries(l).filter(([e])=>!r.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=di.getState().getTerrainGridForDisambiguation();ei.compute(o,c,u,d,h,void 0,f,p??void 0)},triggerDeepAnalysis:async()=>{await Xo.forceDeepLoad();const s=Xo.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=hi(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=hi(a),i=n.get(o);if(i){const r=null==(t=e[i])?void 0:t.zero_hop;(null==(s=e[a])?void 0:s.zero_hop)&&!r&&n.set(o,a)}else n.set(o,a)}return n}(t),r=new Map;for(const c of e){if(!Ei(c))continue;const e=Ni(c.src_hash,a,i,o,s);if(!e)continue;let t=r.get(e);t||(t=Ii(e),r.set(e,t)),Di(t,c)}for(const[c,u]of Object.entries(t))u.zero_hop&&!r.has(c)&&r.set(c,{hash:c,count:u.advert_count??0,rssiSum:u.rssi??0,rssiCount:void 0!==u.rssi?1:0,snrSum:u.snr??0,snrCount:void 0!==u.snr?1:0,lastSeen:u.last_seen??0});const l=[];for(const c of r.values()){const e=Fi(c,n);e&&l.push(e)}return l.sort((e,t)=>t.count!==e.count?t.count-e.count:t.lastSeen-e.lastSeen),l}(s,Object.fromEntries(Object.entries(o).filter(([e])=>!a.has(e))),n.local_hash),r=t().quickNeighbors;(i.length!==r.length||i.some((e,t)=>{var s,n;return e.hash!==(null==(s=r[t])?void 0:s.hash)||e.count!==(null==(n=r[t])?void 0:n.count)}))&&(e({quickNeighbors:i}),Ri(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&&ti.compute(e,o)},requestSevenDayData:async()=>{await Xo.loadSevenDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestThreeDayData:async()=>{await Xo.loadThreeDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},requestFourteenDayData:async()=>{await Xo.loadFourteenDays(()=>{const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}});const s=Xo.getPackets();if(s.length>0){const n=s.reduce((e,t)=>Math.max(e,t.timestamp??0),0);e({packets:[...s],lastPacketTimestamp:n}),t().triggerTopologyCompute(),t().triggerSparklineCompute()}},setGlobalTimeRange:s=>{e({globalTimeRangeIndex:s}),function(e){if("undefined"!=typeof window)try{localStorage.setItem(Li,e.toString())}catch{}}(s);const n={0:1,1:1,2:3,3:12,4:24,5:72,6:168,7:336}[s]??24;si.setTimeWindow(n);const{packetCacheState:a,requestThreeDayData:o,requestSevenDayData:i,requestFourteenDayData:r,triggerTopologyCompute:l,triggerSparklineCompute:c}=t();let u=!1;5!==s||a.threeDayLoadComplete||a.isBackgroundLoading||(o(),u=!0),6!==s||a.sevenDayLoadComplete||a.isBackgroundLoading||(i(),u=!0),7!==s||a.fourteenDayLoadComplete||a.isBackgroundLoading||(r(),u=!0),!u&&s>=5&&(l(),c())}})),qi=Ui,Gi=()=>Ui(e=>e.stats),Ji=()=>Ui(e=>e.statsError),Yi=()=>Ui(e=>e.packets),Vi=()=>Ui(e=>e.packetsLoading),Ki=()=>Ui(e=>e.logs),Xi=()=>Ui(e=>e.logsLoading),Qi=()=>Ui(e=>e.liveMode),Zi=()=>Ui(e=>e.fetchLogs),er=()=>Ui(e=>e.setLiveMode),tr=()=>Ui(e=>e.resourceHistory),sr=()=>Ui(e=>e.addResourceDataPoint),nr=()=>Ui(e=>e.hiddenContacts),ar=()=>Ui(e=>e.hideContact),or=()=>Ui(e=>e.packetCacheState),ir=()=>Ui(e=>e.triggerDeepAnalysis),rr=()=>Ui(e=>e.quickNeighbors),lr=()=>Ui(e=>e.cachedLocalHash),cr=()=>Ui(e=>e.lastPacketTimestamp),ur=()=>Ui(e=>e.globalTimeRangeIndex),dr=()=>Ui(e=>e.setGlobalTimeRange),hr=()=>Ui(e=>null!==e.stats&&e.packetCacheState.backgroundLoadComplete),fr={rx:{p3:"color(display-p3 0.2 1 0.4)",fallback:"#00FF66"},tx:{p3:"color(display-p3 1 0.9 0.2)",fallback:"#FFDD00"},idle:{p3:"color(display-p3 0.4 0.4 0.45)",fallback:"#666677"}};function pr({showLabel:e=!1,className:t}){var a;const o=Ui(e=>e.flashReceived),i=Ui(e=>e.flashAdvert),r=ii(e=>"connected"===e.connectionState),[l,c]=s.useState("idle"),u=s.useRef(0),d=s.useRef(0);s.useEffect(()=>{if(o<=0)return;const e=Date.now();if(e-u.current<50)return;u.current=e,c("rx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[o]),s.useEffect(()=>{if(i<=0)return;const e=Date.now();if(e-d.current<50)return;d.current=e,c("tx");const t=setTimeout(()=>c("idle"),100);return()=>clearTimeout(t)},[i]);const h="rx"===l?fr.rx:"tx"===l?fr.tx:fr.idle;return n.jsxs("span",{className:D("inline-flex items-center gap-2",t),title:r?"Real-time (WebSocket)":"Database polling",children:[n.jsx("span",{className:"inline-flex rounded-full w-1.5 h-1.5",style:{backgroundColor:h.fallback,...(null==(a=CSS.supports)?void 0:a.call(CSS,"color","color(display-p3 1 1 1)"))&&{backgroundColor:h.p3}}}),e&&n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:r?"Live":"DB"})]})}function mr({children:e,isLoading:t=!0,className:s,borderRadius:a=12}){return n.jsxs("div",{className:D("relative overflow-hidden",s),style:{borderRadius:a},children:[t&&n.jsx("div",{className:"shimmer-border",style:{borderRadius:a}}),n.jsx("div",{className:"relative z-10",children:e})]})}function gr({className:e}){return n.jsx("div",{className:D("shimmer-indicator",e),children:n.jsx("div",{className:"shimmer-indicator-inner"})})}const yr=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(()=>{ti.subscribe((e,t)=>{const s=yr.getState();t&&!s.isComputing?s.setComputing(!0):!t&&e.size>0?s.setSparklines(e):!t&&s.isComputing&&s.setComputing(!1)})},0);const br=()=>yr(e=>e.isComputing),xr=[],wr=new Map;function kr(e){return yr(t=>{const s=t.sparklines.get(e);if(!s||0===s.length)return xr;const n=wr.get(e);return n===s?n:(wr.set(e,s),s)})}const vr=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:Zo(),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&&ei.subscribe((e,t)=>{vr.getState().setTopology(e,t)});const Sr=()=>vr(e=>e.topology),Cr=()=>vr(e=>e.topology.hubNodes),Tr=()=>vr(e=>e.topology.centrality),Mr=()=>vr(e=>e.topology.fullAffinity);let Lr=null,_r=null,jr=null,Pr=null;const Er=()=>vr(e=>(e.topology.hubNodes!==_r&&(_r=e.topology.hubNodes,Lr=new Set(e.topology.hubNodes)),Lr)),Nr=()=>vr(e=>e.topology.pathHealth),Dr=()=>vr(e=>e.topology.disambiguationStats),Ir=()=>vr(e=>e.topology.disambiguationStats.highCollisionPrefixes),Fr=()=>vr(e=>e.topology.disambiguationStats.totalPrefixes>0),Ar=()=>vr(e=>e.topology.discoveredNodes),Rr=()=>vr(e=>e.topology.viterbiStats),zr=()=>vr(e=>(e.topology.discoveredNodes!==Pr&&(Pr=e.topology.discoveredNodes,jr=e.topology.discoveredNodes.filter(e=>e.isLikelyReal)),jr));function Br(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 Or(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 $r(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 Wr(e){return new Date(1e3*e).toLocaleString()}function Hr(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 Ur(e){return`${(e/1e6).toFixed(3)} MHz`}function qr(e){return`${(e/1e3).toFixed(1)} kHz`}function Gr(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),r=Math.floor(i/24);return r>0?`${r} day${1!==r?"s":""}`:i>0?`${i} hour${1!==i?"s":""}`:o>0?`${o} minute${1!==o?"s":""}`:`${a} second${1!==a?"s":""}`}const Jr=[{name:"Dashboard",to:"/",icon:l},{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}],Yr="pymc-controls-expanded";function Vr(){var e,t,a,l;const{pathname:c}=o(),{stats:u,setMode:d,setDutyCycle:f,sendAdvert:p}=qi(),m=mo(),M=Ui(e=>e.prefetchForRoute),L=or(),_=Ui(e=>e.packetCacheState.dataTier),j=br(),P=vr(e=>e.isComputing),E=zr(),[N,I]=s.useState(!1),[F,A]=s.useState(!0),[R,z]=s.useState(!1),[B,O]=s.useState("idle"),[$,W]=s.useState(null),H=s.useRef(null),U=s.useCallback(e=>{e!==c&&(H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{M(e)},100))},[c,M]),q=s.useCallback(()=>{H.current&&(clearTimeout(H.current),H.current=null)},[]);s.useEffect(()=>{const e=localStorage.getItem(Yr);null!==e&&queueMicrotask(()=>A("true"===e))},[]);const G=()=>{const e=!F;A(e),localStorage.setItem(Yr,String(e))};s.useEffect(()=>{queueMicrotask(()=>I(!1))},[c]),s.useEffect(()=>(document.body.style.overflow=N?"hidden":"",()=>{document.body.style.overflow=""}),[N]);const J=null==u?void 0:u.noise_floor_dbm,Y=(null==(t=null==(e=null==u?void 0:u.config)?void 0:e.repeater)?void 0:t.mode)??"forward",V=(null==(l=null==(a=null==u?void 0:u.config)?void 0:a.duty_cycle)?void 0:l.enforcement_enabled)??!1,K=async()=>{z(!0),O("idle"),W(null);const e=await p();z(!1),e.success?(O("success"),setTimeout(()=>O("idle"),1500)):(O("error"),W(e.error||"Failed to send"),setTimeout(()=>{O("idle"),W(null)},3e3))},X=()=>{d("forward"===Y?"monitor":"forward")},Q=()=>{f(!V)},Z=()=>{wo(),window.location.href="/login"},ee=L.isLoading||L.isBackgroundLoading||L.isTopologyLoading,te=ee||j||P,se=L.loadProgress,ne=e=>{switch(e){case"24h":return"24 hours";case"3d":return"3 days";case"7d":return"7 days";case"14d":return"14 days";default:return e}},ae=()=>{if(!te)return null;let e="Analyzing database";L.isLoading&&se?e="Loading 24h history...":L.isBackgroundLoading&&se?e=L.statusMessage||`Loading ${_} history...`:L.isTopologyLoading?e="Loading topology data...":j?e="Computing sparklines":P&&(e="Building topology");const t=(null==se?void 0:se.percent)??null,s=null!==t&ⅇreturn n.jsx("div",{className:"px-3 pb-2",children:n.jsx(mr,{isLoading:ee,borderRadius:12,children:n.jsxs("div",{className:"bg-glass-surface/50 rounded-xl p-2",children:[n.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[n.jsxs("div",{className:"relative flex h-2 w-2",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-accent-primary"})]}),n.jsx("span",{className:"type-data-xs text-text-muted flex-1 truncate",children:e}),s&&n.jsxs("span",{className:"type-data-xs text-text-muted tabular-nums",children:[t,"%"]})]}),n.jsx("div",{className:"mt-1.5 h-1 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/40 rounded-full",style:{width:"100%"}})}),!ee&&n.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"type-micro text-text-muted",children:"Data:"}),n.jsx("span",{className:"type-data-xs text-accent-primary",children:ne(_)})]})]})})})},oe=()=>n.jsx("nav",{className:"flex-1 px-3 py-4 space-y-1 overflow-y-auto",children:Jr.map(e=>{const t=c===e.to;return n.jsxs(g,{to:e.to,onClick:()=>I(!1),onMouseEnter:()=>U(e.to),onMouseLeave:q,className:D("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:D("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&&E.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:E.length})]})]},e.name)})}),ie=()=>n.jsxs("div",{className:"px-3 py-3",children:[n.jsxs("button",{onClick:G,className:"w-full flex items-center justify-between px-3 py-1.5 mb-2 rounded-lg hover:bg-white/5 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(b,{className:"w-5 h-5 text-accent-primary"}),n.jsx("span",{className:"type-data-xs text-text-muted uppercase tracking-wide",children:"Controls"})]}),n.jsx(x,{className:D("w-4 h-4 text-text-muted transition-transform duration-200",F?"rotate-0":"-rotate-90")})]}),n.jsx("div",{className:D("overflow-hidden transition-all duration-300 ease-out",F?"max-h-96 opacity-100":"max-h-0 opacity-0"),children:n.jsxs("div",{className:"control-panel-skeuo",children:[n.jsxs("button",{onClick:K,disabled:R,className:D("control-btn control-btn-primary w-full transition-all duration-300",R&&"opacity-70","success"===B&&"ring-2 ring-accent-success ring-offset-1 ring-offset-transparent","error"===B&&"ring-2 ring-accent-danger ring-offset-1 ring-offset-transparent"),children:[n.jsx(w,{className:D("w-4 h-4",R&&"animate-pulse")}),n.jsx("span",{children:R?"Sending...":"success"===B?"Sent!":"error"===B?"Failed":"Send Advert"})]}),$&&n.jsx("div",{className:"text-accent-danger type-data-xs px-2 py-1 text-center",children:$}),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:D("control-toggle-status","forward"===Y?"text-accent-success":"text-accent-secondary"),children:"forward"===Y?"FWD":"MON"})]}),n.jsx("button",{onClick:X,className:D("control-btn w-full","forward"===Y?"control-btn-success":"control-btn-warning"),children:"forward"===Y?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:D("control-toggle-status",V?"text-accent-success":"text-text-muted"),children:V?"ON":"OFF"})]}),n.jsxs("button",{onClick:Q,className:D("control-btn w-full",V?"control-btn-success":"control-btn-neutral"),children:[n.jsx(h,{className:"w-4 h-4"}),n.jsx("span",{children:V?"Enabled":"Disabled"})]})]})]})})]}),re=()=>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-6 py-3 flex items-center gap-3",children:[n.jsx(S,{className:"w-5 h-5 text-text-muted flex-shrink-0"}),n.jsxs("span",{className:"type-data-xs text-text-secondary tabular-nums",children:[Br(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(C,{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!=J?`${J.toFixed(0)} dBm`:"—"})]})})}),n.jsxs("div",{className:"px-6 py-3 flex items-center gap-3 border-t border-white/5",children:[n.jsx(pr,{showLabel:!0}),(null==u?void 0:u.version)&&n.jsxs("span",{className:"type-data-xs text-text-muted truncate max-w-[140px]",title:`v${u.version}`,children:["v",u.version]})]}),n.jsx("div",{className:"px-3 pb-3",children:n.jsxs("button",{onClick:Z,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(T,{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 gap-2",children:[n.jsx("h1",{className:"sr-only",children:"pyMC Console"}),n.jsx(qa,{height:26,className:"block"}),ee&&n.jsx(gr,{className:"ml-2"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("p",{className:"type-data-xs text-text-muted",children:["v",Ha]}),n.jsx(pr,{}),n.jsx("button",{onClick:()=>I(!N),className:"w-10 h-10 flex items-center justify-center rounded-xl hover:bg-white/5 active:bg-white/10 transition-colors","aria-label":N?"Close menu":"Open menu",children:N?n.jsx(i,{className:"w-5 h-5 text-text-primary"}):n.jsx(r,{className:"w-5 h-5 text-text-primary"})})]})]})}),n.jsx("div",{className:D("lg:hidden fixed inset-0 z-[10002] bg-black/60 backdrop-blur-sm transition-opacity duration-300",N?"opacity-100":"opacity-0 pointer-events-none"),onClick:()=>I(!1),"aria-hidden":"true"}),n.jsxs("aside",{className:D("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",N?"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(qa,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",Ha]})]}),oe(),ae(),ie(),re()]}),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(qa,{responsive:!0,className:"block"}),n.jsxs("p",{className:"type-data-xs text-text-muted mt-1.5",children:["v",Ha]})]}),oe(),ae(),ie(),re()]})]})}const Kr=s.memo(function(){const{theme:e}=Wa(),{backgroundImage:t,brightness:a}=e,[o,i]=s.useState(t),[r,l]=s.useState(!1);s.useEffect(()=>{if(t===o)return;if(!t)return void i("");const e=new Image;e.onload=()=>{l(!0),requestAnimationFrame(()=>{i(t),setTimeout(()=>l(!1),300)})},e.onerror=()=>{i(t)},e.src=t},[t,o]);const c=(100-a)/100;return n.jsxs(n.Fragment,{children:[o&&n.jsx("div",{className:"fixed inset-0 -z-20",style:{contain:"paint",willChange:r?"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:r?.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"})]})}),Xr=20,Qr=12,Zr=s.createContext(null);function el({children:e}){const[t,a]=s.useState({content:null,mouseX:0,mouseY:0,visible:!1}),o=s.useRef(null),[i,r]=s.useState({x:0,y:0}),l=s.useCallback((e,t,s)=>{a({content:e,mouseX:t,mouseY:s,visible:!0})},[]),c=s.useCallback(()=>{a(e=>({...e,visible:!1}))},[]),u=s.useCallback((e,t)=>{a(s=>s.visible?{...s,mouseX:e,mouseY:t}:s)},[]);s.useEffect(()=>{if(!t.visible||!o.current)return;const e=o.current.getBoundingClientRect(),{mouseX:s,mouseY:n}=t,a=window.innerWidth,i=window.innerHeight;let l,c;l=s+Xr+e.width+Qr>a?s-Xr-e.width:s+Xr,l=Math.max(Qr,Math.min(l,a-e.width-Qr)),c=n-Xr-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&&r(e.clientX,e.clientY)},[r]),p=s.useCallback(()=>{d(),u.current=!1,i()},[i]),m=s.useCallback(()=>{if(d(),!l.current)return;const t=l.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:l,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,onFocus:m,onBlur:g,className:"contents",children:t})}function sl({className:e=""}){return n.jsx("div",{className:`bg-white/5 animate-pulse rounded-lg ${e}`,"aria-hidden":"true"})}function nl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading dashboard",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-48"}),n.jsx(sl,{className:"h-8 w-32"})]}),n.jsx(sl,{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(sl,{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(sl,{className:"h-44"},t))}),n.jsx(sl,{className:"h-96"})]})}function al(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading list",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-40"}),n.jsx(sl,{className:"h-8 w-24"})]}),n.jsx(sl,{className:"h-20"}),n.jsxs("div",{className:"glass-card overflow-hidden",children:[n.jsx(sl,{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(sl,{className:"h-6"})},t))})]})]})}function ol(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading map",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-32"}),n.jsx(sl,{className:"h-6 w-48"})]}),n.jsx(sl,{className:"h-[500px]"}),n.jsx(sl,{className:"h-64"})]})}function il(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading charts",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(sl,{className:"h-8 w-36"}),n.jsx(sl,{className:"h-8 w-40"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[n.jsx(sl,{className:"h-80"}),n.jsx(sl,{className:"h-80"})]}),n.jsx(sl,{className:"h-64"})]})}function rl(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading settings",children:[n.jsx(sl,{className:"h-8 w-32"}),n.jsxs("div",{className:"space-y-6",children:[n.jsx(sl,{className:"h-48"}),n.jsx(sl,{className:"h-64"}),n.jsx(sl,{className:"h-32"})]})]})}function ll(){return n.jsxs("div",{className:"section-gap","aria-label":"Loading system info",children:[n.jsx(sl,{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(sl,{className:"h-28"},t))}),n.jsx(sl,{className:"h-64"}),n.jsx(sl,{className:"h-48"})]})}const cl=s.lazy(()=>N(()=>import("./Login-D81eBYn4.js"),__vite__mapDeps([0,1,2]))),ul=s.lazy(()=>N(()=>import("./Dashboard-DPV4UcXa.js"),__vite__mapDeps([3,1,2,4,5,6,7,8,9,10,11,12]))),dl=s.lazy(()=>N(()=>import("./Packets-Dx7VKSq1.js"),__vite__mapDeps([13,1,2,6,7,8,9,5]))),hl=s.lazy(()=>N(()=>import("./Contacts-Dm2Yh1zu.js").then(e=>e.C),__vite__mapDeps([14,1,2,15,5,8,7,16,17,18]))),fl=s.lazy(()=>N(()=>import("./Statistics-rMuAOtUm.js"),__vite__mapDeps([19,1,2,20,4,9,10,5,8,16,12,18]))),pl=s.lazy(()=>N(()=>import("./System-CfbhqMgy.js"),__vite__mapDeps([21,1,2,4,5,12]))),ml=s.lazy(()=>N(()=>import("./Logs-DmMC1IFZ.js"),__vite__mapDeps([22,1,2,20,5]))),gl=s.lazy(()=>N(()=>import("./Terminal-D4B4ypGn.js"),__vite__mapDeps([23,1,2,15,5]))),yl=s.lazy(()=>N(()=>import("./Configuration-mzUD-v3l.js"),__vite__mapDeps([24,1,2,8,17,5,12])));function bl({children:e}){const t=o();return co()?n.jsx(n.Fragment,{children:e}):n.jsx(j,{to:"/login",state:{from:t},replace:!0})}class xl 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 wl(){const e=Ui(e=>e.initializeApp),t=co();return s.useEffect(()=>{if(!t)return;e();const s=setInterval(()=>{xo()},3e4);return xo(),vo(),()=>clearInterval(s)},[e,t]),n.jsxs(el,{children:[n.jsx(Kr,{}),n.jsxs(L,{children:[n.jsx(_,{path:"/login",element:n.jsx(s.Suspense,{fallback:n.jsx("div",{className:"min-h-screen bg-bg-body"}),children:n.jsx(cl,{})})}),n.jsx(_,{path:"/*",element:n.jsx(bl,{children:n.jsxs("div",{className:"flex h-screen overflow-hidden",children:[n.jsx(Vr,{}),n.jsx("main",{className:"flex-1 w-full min-w-0 pt-14 lg:pt-0 overflow-y-auto",children:n.jsx("div",{className:"px-4 sm:px-6 lg:px-8 pt-5 pb-4 sm:pb-6 lg:pb-8 max-w-7xl mx-auto",children:n.jsx(xl,{children:n.jsxs(L,{children:[n.jsx(_,{path:"/",element:n.jsx(s.Suspense,{fallback:n.jsx(nl,{}),children:n.jsx(ul,{})})}),n.jsx(_,{path:"/packets",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(dl,{})})}),n.jsx(_,{path:"/contacts",element:n.jsx(s.Suspense,{fallback:n.jsx(ol,{}),children:n.jsx(hl,{})})}),n.jsx(_,{path:"/statistics",element:n.jsx(s.Suspense,{fallback:n.jsx(il,{}),children:n.jsx(fl,{})})}),n.jsx(_,{path:"/system",element:n.jsx(s.Suspense,{fallback:n.jsx(ll,{}),children:n.jsx(pl,{})})}),n.jsx(_,{path:"/logs",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(ml,{})})}),n.jsx(_,{path:"/terminal",element:n.jsx(s.Suspense,{fallback:n.jsx(al,{}),children:n.jsx(gl,{})})}),n.jsx(_,{path:"/configuration",element:n.jsx(s.Suspense,{fallback:n.jsx(rl,{}),children:n.jsx(yl,{})})})]})})})})]})})})]})]})}const kl=console.warn;console.warn=(...e)=>{const t=e[0];if("string"==typeof t){if(t.includes("width")&&t.includes("height")&&t.includes("chart should be greater than 0"))return;if(t.includes("Unable to load glyph range"))return}kl.apply(console,e)},P.createRoot(document.getElementById("root")).render(n.jsx(s.StrictMode,{children:n.jsx($a,{children:n.jsx(E,{children:n.jsx(wl,{})})})}));export{Dr as $,pi as A,Er as B,Mr as C,mi as D,Ar as E,bi as F,Wr as G,Nr as H,Rr as I,Gr as J,kr as K,pr as L,br as M,Ir as N,qi as O,qa as P,ar as Q,Ja as R,Cr as S,tl as T,Tr as U,Or as V,Fa as W,_o as X,jo as Y,za as Z,Wa as _,Vi as a,Fr as a0,zr as a1,gi as a2,yi as a3,R as a4,A as a5,re as a6,tr as a7,sr as a8,Ro as a9,xi as aa,Ki as ab,Xi as ac,Zi as ad,ki as ae,Eo as af,Bo as ag,Oo as ah,$o as ai,zo as aj,Wo as ak,Mo as al,be as am,Ce as an,Ur as ao,qr as ap,Xo as aq,fi as ar,Va as as,Sr as at,ir as au,lr as av,di as aw,Qi as b,Gi as c,hi as d,rr as e,nr as f,no as g,ur as h,co as i,Do as j,cr as k,go as l,Ji as m,hr as n,dr as o,or as p,Ao as q,er as r,ao as s,Ga as t,Yi as u,Ha as v,oi as w,Ya as x,$r as y,Hr as z}; diff --git a/frontend/dist/assets/link-scoring-v5IA77Bo.js b/frontend/dist/assets/link-scoring-t1Ov70gg.js similarity index 94% rename from frontend/dist/assets/link-scoring-v5IA77Bo.js rename to frontend/dist/assets/link-scoring-t1Ov70gg.js index 5a562b44..cadeca8b 100644 --- a/frontend/dist/assets/link-scoring-v5IA77Bo.js +++ b/frontend/dist/assets/link-scoring-t1Ov70gg.js @@ -1 +1 @@ -import{d as t,as as e}from"./index-BIsccma_.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 d=0,g=0,l=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}),d=Math.max(d,n),g=Math.max(g,r),l=Math.max(l,s)}return{scores:h,maxListenerScore:d,maxLoudScore:g,maxBlendedScore:l}}const r={YELLOW:"#FBBF24",GREEN:"#719872",RED:"#E12672",GRAY:"#505050"};export{r as L,n as c}; +import{d as t,as as e}from"./index-Bmit1I8S.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 d=0,g=0,l=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}),d=Math.max(d,n),g=Math.max(g,r),l=Math.max(l,s)}return{scores:h,maxListenerScore:d,maxLoudScore:g,maxBlendedScore:l}}const r={YELLOW:"#FBBF24",GREEN:"#719872",RED:"#E12672",GRAY:"#505050"};export{r as L,n as c}; diff --git a/frontend/dist/assets/ping-SvrcEczO.js b/frontend/dist/assets/ping-BBb1dLdC.js similarity index 94% rename from frontend/dist/assets/ping-SvrcEczO.js rename to frontend/dist/assets/ping-BBb1dLdC.js index 4b766ce3..c55ef869 100644 --- a/frontend/dist/assets/ping-SvrcEczO.js +++ b/frontend/dist/assets/ping-BBb1dLdC.js @@ -1 +1 @@ -import{al as t}from"./index-BIsccma_.js";async function e(e,r=10){return t("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:r})})}const r=["Chat Node","Repeater","Room Server","Hybrid Node","Unknown"];async function s(s,o=10){if(o<1||o>60)return{success:!1,error:"Timeout must be 1-60 seconds"};let n;const a=s.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(a)n=`0x${a[2].padStart(2,"0")}`;else{const e=await async function(e){const s=e.toLowerCase();for(const o of r)try{const e=await t(`/api/adverts_by_contact_type?contact_type=${encodeURIComponent(o)}&hours=168`),r=e.success&&e.data?e.data:e,n=(Array.isArray(r)?r:[]).find(t=>t.node_name&&t.node_name.toLowerCase()===s);if(n&&n.pubkey)return`0x${n.pubkey.substring(0,2)}`}catch{continue}return null}(s);if(!e)return{success:!1,error:`Node '${s}' not found`};n=e}const c=await e(n,o);if(!c.success||!c.data)return{success:!1,error:c.error||"Ping failed"};const i=(u=c.data).rtt_ms>500||u.rssi<-120?"Poor":u.rtt_ms>250||u.rssi<-100?"Fair":u.rtt_ms>100||u.rssi<-80?"Good":"Excellent";var u;return{success:!0,data:{...c.data,quality:i}}}export{s as a,e as p}; +import{al as t}from"./index-Bmit1I8S.js";async function e(e,r=10){return t("/api/ping_neighbor",{method:"POST",body:JSON.stringify({target_id:e,timeout:r})})}const r=["Chat Node","Repeater","Room Server","Hybrid Node","Unknown"];async function s(s,o=10){if(o<1||o>60)return{success:!1,error:"Timeout must be 1-60 seconds"};let n;const a=s.match(/^(0x)?([0-9a-fA-F]{1,2})$/);if(a)n=`0x${a[2].padStart(2,"0")}`;else{const e=await async function(e){const s=e.toLowerCase();for(const o of r)try{const e=await t(`/api/adverts_by_contact_type?contact_type=${encodeURIComponent(o)}&hours=168`),r=e.success&&e.data?e.data:e,n=(Array.isArray(r)?r:[]).find(t=>t.node_name&&t.node_name.toLowerCase()===s);if(n&&n.pubkey)return`0x${n.pubkey.substring(0,2)}`}catch{continue}return null}(s);if(!e)return{success:!1,error:`Node '${s}' not found`};n=e}const c=await e(n,o);if(!c.success||!c.data)return{success:!1,error:c.error||"Ping failed"};const i=(u=c.data).rtt_ms>500||u.rssi<-120?"Poor":u.rtt_ms>250||u.rssi<-100?"Fair":u.rtt_ms>100||u.rssi<-80?"Good":"Excellent";var u;return{success:!0,data:{...c.data,quality:i}}}export{s as a,e as p}; diff --git a/frontend/dist/assets/useScientificColormap-nDz0kTVE.js b/frontend/dist/assets/useScientificColormap-n_Aivg5g.js similarity index 99% rename from frontend/dist/assets/useScientificColormap-nDz0kTVE.js rename to frontend/dist/assets/useScientificColormap-n_Aivg5g.js index 0002bc8b..af67286b 100644 --- a/frontend/dist/assets/useScientificColormap-nDz0kTVE.js +++ b/frontend/dist/assets/useScientificColormap-n_Aivg5g.js @@ -1 +1 @@ -import"./vendor-react-DtVWNgeu.js";import{a4 as A,a5 as C,a6 as D,x as B}from"./index-BIsccma_.js";const F=["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"],E=["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"],e=["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"],a=["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"],c=["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"],t=["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"],r=["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"],i=["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"],o=["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"],l=["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"],s=["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"],n=["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"],d=["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"],g=["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"],m=["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"],b=["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"],u=["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"],f=["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"],w={acton:{discrete:["#260D40","#2B1345","#2F194B","#342152","#382657","#3C2C5C","#403261","#443766","#483E6C","#4C4371","#504876","#544D7B","#57527F","#5D5884","#625C88","#685F8A","#6E618C","#74628D","#7B638D","#81638E","#88648E","#8E648E","#95658F","#9D658F","#A4668F","#AB6690","#B26790","#BB6992","#C26B94","#C86F97","#CD749B","#D07AA0","#D382A7","#D688AC","#D88FB2","#D995B8","#DB9CBD","#DEA4C4","#DFABC9","#E1B1CE","#E3B7D3","#E5BED8","#E6C5DE","#E8CBE2","#E9D0E6","#EBD6EA","#ECDBEE","#EDE1F3","#EFE6F6","#F0EAFA"],categorical:["#260D40","#F0EAFA","#A76690","#DDA1C2","#585380","#7D638E","#E8CAE1","#CF789E","#403261","#4C4371","#ECDBEE","#69608B","#E3B6D2","#D78CB0","#91648F","#BE6A92","#342152","#EAD3E8","#524B79","#73628D","#463A69","#605B86","#E5C0DA","#D382A7","#C86F97","#86648E","#EEE3F4","#DA97B9","#9B658F","#B26790","#2D1749","#E0ACCA","#3A2959","#8B648E","#311C4D","#EBD7EB","#EDDFF1","#AC6790","#A1668F","#6E618C","#E6C5DE","#78628D","#433665","#DEA7C6","#81638E","#554F7C","#B86891","#3D2D5D","#4F4775","#EFE7F7","#E9CEE4","#D27DA3","#2A1244","#655D89","#C36C94","#E1B1CE","#493F6D","#5C5783","#CC739A","#DB9CBD","#D892B4","#D587AB","#96658F","#E4BBD6","#362455","#4E4573","#7F638E","#D37FA5","#E1AECC","#382657","#EBD9ED","#DFA9C8","#A4668F","#8E648E","#99658F","#675F8A","#B56891","#BB6992","#E5BED8","#E2B4D0","#D07AA0","#71618C","#E6C2DC","#AA6690","#625C88","#EDE1F3","#E8CCE3","#AF6790","#CA7199","#C16B93","#453867","#57517E","#84638E","#4B416F","#E7C7DF","#423463","#514977","#3E2F5F","#544D7B","#93658F"]},bam:{discrete:F,categorical:F},bamako:{discrete:["#003B47","#023C46","#053E45","#083F43","#0A4141","#0D4340","#0F443E","#12463C","#16483A","#194A38","#1C4D36","#204F34","#235132","#28542F","#2C572C","#305A2A","#355C27","#395F24","#3F6321","#44661E","#49691A","#4E6D17","#537014","#5A7410","#5F780D","#657C09","#6A7F05","#718302","#788501","#7F8700","#858800","#8C8A00","#948C01","#9B8E04","#A1920B","#A89713","#AE9C1B","#B7A225","#BEA82E","#C5AD37","#CBB341","#D2B84D","#D9BF5B","#DEC567","#E4CA73","#E9D07E","#EFD58A","#F5DB97","#FAE0A3","#FFE5AD"],categorical:["#003B47","#FFE5AD","#61790B","#B4A022","#245231","#406420","#898900","#DDC464","#0F443E","#EFD58A","#CAB23F","#194A38","#748401","#506E16","#9E9108","#315A29","#083F43","#A99815","#948C01","#6A7F05","#BFA930","#7F8700","#14473B","#1E4E35","#F7DD9C","#2A562D","#043D45","#597411","#E6CC77","#385F25","#48691B","#D4BB51","#0B4241","#8F8A00","#44661E","#1B4C37","#547113","#6F8203","#12463D","#998E03","#27542F","#4C6B18","#A4940E","#2E582B","#355C27","#B9A529","#215033","#EAD181","#FBE1A5","#C5AD37","#3C6122","#848800","#063E44","#E2C86E","#D9BF5B","#CFB648","#16493A","#798600","#023C46","#667C08","#5D770E","#0D433F","#AE9C1B","#F3D993","#094042","#A69611","#8C8A00","#053E45","#0C4240","#365E26","#6D8004","#9C8F05","#4A6A1A","#D6BD56","#B19E1F","#F9DFA0","#647B0A","#2F592A","#10453D","#818800","#C7AF3B","#46681C","#0E443F","#265330","#174A39","#335B28","#5B750F","#778501","#5F780D","#E8CF7C","#718302","#F1D78E","#978D02","#F5DB97","#204F34","#AC9A18","#29552E","#A1920B","#B7A225","#033C46"]},bamo:{discrete:E,categorical:E},batlow:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144D62","#165162","#195662","#1C5A62","#205E61","#26635F","#2C665D","#33695A","#3A6C57","#416F53","#4A724E","#52744A","#5A7745","#627941","#6A7B3D","#747E38","#7D8134","#868330","#8F862D","#9B892B","#A58B2C","#AF8D2E","#B98F32","#C29037","#CD923F","#D69446","#DE964F","#E69858","#ED9A62","#F39E70","#F8A17B","#FAA587","#FCA993","#FDAC9E","#FDB1AB","#FDB4B6","#FDB8C0","#FDBCCB","#FCBFD6","#FCC4E3","#FBC8EF","#FACCFA"],categorical:["#011959","#FACCFA","#828231","#226061","#F29D6D","#4D734D","#114360","#C09036","#FDB4B4","#DD954D","#356A59","#FCBFD6","#175262","#677B3E","#A18A2B","#0D315D","#FCA890","#FBC6E8","#2B655E","#B18D2F","#5A7745","#FDAEA2","#CF9340","#0F3B5F","#E9995C","#FDBAC4","#416F53","#91862D","#1B5962","#08255B","#747E38","#134B61","#F9A380","#8A842F","#0E365E","#124761","#154F62","#E39754","#7B8034","#1E5D62","#99882C","#195662","#0B2B5C","#FDB7BC","#C8913B","#FCC3DF","#EE9B64","#A98C2C","#FDB1AB","#FDBCCD","#FBC9F1","#051F5A","#F6A077","#607942","#FDAB9A","#477150","#3B6D56","#B98F32","#26635F","#537549","#D69446","#6D7C3B","#30685C","#103F60","#FBA689","#BD8F34","#CB923E","#EB9A60","#FDB8C0","#FBC7EC","#F09C69","#8E852E","#FDBBC9","#7F8133","#031C5A","#114160","#FDAC9E","#5D7844","#FCA995","#185462","#787F36","#A58B2C","#0A285C","#9D892B","#33695A","#0D335E","#637A40","#165062","#124561","#205E61","#144D62","#1D5B62","#0C2E5D","#D9954A","#3E6E55","#AD8C2D","#F49F72","#868330","#B58E30","#577647"]},batlowk:{discrete:["#04050A","#0A0D15","#0F141E","#121B29","#152233","#18293D","#1C3146","#21384F","#274156","#2C485B","#314E5E","#36535F","#3B575F","#405C5E","#445F5D","#49625B","#4D6558","#526756","#586B52","#5E6E4F","#63724B","#6A7548","#717845","#797D41","#81813E","#8A853B","#938839","#9F8D38","#A99139","#B3943B","#BE973E","#C89A43","#D39D4C","#DB9F54","#E2A15D","#E8A366","#EEA570","#F3A77C","#F6A986","#F8AC91","#FAAE9A","#FCB1A4","#FDB4B0","#FDB7B9","#FDBAC3","#FDBDCD","#FDC1D8","#FCC5E4","#FBC8EF","#FACCFA"],categorical:["#04050A","#FDC0D6","#787C41","#38555F","#E5A160","#536855","#AF933A","#FAAE9A","#1A2E43","#FDB6B7","#294458","#455F5C","#63724B","#CD9B47","#91883A","#F3A77E","#111A27","#F7AB8D","#FDBBC5","#FCB2AA","#D99E52","#A18E38","#4C6459","#21384F","#3F5B5E","#152335","#0C1019","#EEA570","#5B6D50","#6C7647","#314E5E","#85823D","#BE973E","#7E7F3F","#FBB0A2","#49625B","#576A53","#0F151F","#2D495B","#DFA059","#727944","#FDBDCD","#253E54","#EAA368","#C69942","#3C585F","#998B38","#677449","#F1A678","#F9AC92","#141F2F","#1D3248","#506657","#090C13","#A99139","#5F6F4E","#35525F","#435D5D","#FDB8BD","#F5A984","#B5953B","#FDB5B2","#17273B","#D39D4C","#8C853B","#9D8C38","#415C5E","#1F354B","#33505E","#FCB1A6","#101723","#3E595F","#121C2B","#757B43","#06080F","#FCB3AE","#3A565F","#274156","#61704D","#88843C","#2B475A","#FDBED1","#6A7548","#596C51","#192B3F","#6F7845","#233B51","#C99A45","#F0A574","#DC9F55","#2F4B5D","#47615C","#F6AA88","#FDB9C1","#C29840","#4A635A","#FAAD96","#81813E","#7B7E40","#E7A264"]},batloww:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144C62","#165062","#185562","#1B5962","#1F5D62","#246261","#2A665F","#30695D","#366C5A","#3D7056","#467352","#4E764E","#56794A","#5E7C46","#667F42","#70823D","#798539","#828936","#8C8C33","#989032","#A29433","#AD9738","#B79B3F","#C19E48","#CBA154","#D3A45E","#D9A669","#DFA872","#E4AA7C","#E9AC88","#EEAF91","#F2B39C","#F6B9A8","#F9C0B5","#FCCAC4","#FED3CF","#FFDBDA","#FFE3E2","#FFEAEA","#FFF2F2","#FFF8F8","#FFFEFE"],categorical:["#FFFEFE","#011959","#7E8737","#205F61","#E7AB84","#497451","#114360","#FED1CD","#BF9D46","#637E44","#9E9233","#FFEAEA","#0D315D","#326B5C","#F5B7A6","#165162","#D7A564","#0F3B5F","#1A5862","#3D7056","#FFF5F5","#FFDFDD","#FAC3BA","#134A61","#08255B","#70823D","#EEB094","#56794A","#E0A874","#8E8D33","#28655F","#AF9839","#CBA154","#EBAD8B","#1D5C62","#051F5A","#124761","#FFE5E4","#B79B3F","#A79535","#386D59","#5C7B47","#185562","#DBA76D","#F8BDAF","#FFF0F0","#246261","#F2B39C","#868A35","#4F774D","#E4AA7C","#2D685E","#77853A","#FED8D6","#103F60","#FFFAF9","#968F32","#D1A35C","#144E62","#FCCAC4","#437254","#698040","#0E365E","#0B2B5C","#C59F4C","#30695D","#1C5A62","#A29433","#407155","#FFDBDA","#0C2E5D","#F7BAAA","#E5AB80","#175362","#828936","#1F5D62","#BB9C42","#E9AC88","#FFF7F7","#3A6E58","#9A9132","#8A8B34","#4C754F","#FFEDED","#D9A669","#144C62","#266460","#FDCDC9","#FCC6BF","#FFE2E1","#FFFCFC","#7B8639","#2B675E","#155062","#5F7C45","#F9C0B5","#356C5A","#F3B5A1","#EDAF8F","#FED5D2"]},berlin:{discrete:e,categorical:e},bilbao:{discrete:["#4C0001","#54070B","#5B0E13","#64161A","#6B1D20","#712227","#77282D","#7D2E34","#84343B","#8A3A41","#8F4047","#94464B","#984C4F","#9B5253","#9D5754","#9E5C56","#A06057","#A16458","#A26959","#A36D5A","#A4715B","#A5745B","#A6785C","#A77C5D","#A8805E","#A9845F","#AA875F","#AC8C60","#AD9061","#AE9463","#AF9864","#B19D68","#B3A36E","#B6A975","#B8AD7E","#BBB287","#BDB590","#C0B99A","#C2BCA3","#C4BFAA","#C6C2B2","#C8C5B9","#CBCAC1","#CFCEC9","#D5D4D1","#DBDBDA","#E3E3E2","#EDEDED","#F6F6F6","#FFFFFF"],categorical:["#4C0001","#F8F8F8","#A9815E","#984D50","#BEB794","#AF9965","#CCCAC3","#78292F","#A26A59","#9F5D56","#64161A","#B6AA77","#C4C0AC","#A6765C","#8A3A41","#AC8C60","#DDDDDB","#A16358","#C7C5B7","#B3A16B","#A4705A","#6E2024","#EAEAE9","#92434A","#BAB185","#9C5554","#AD9262","#580B10","#813137","#C1BCA1","#AA865F","#D2D2CE","#A77C5D","#D7D7D4","#BCB48D","#B4A571","#C0B99A","#9E5955","#AB8960","#A6795C","#A36D5A","#8E3F46","#85353C","#A16758","#732529","#CAC7BD","#F1F1F0","#520509","#AC8F61","#5E1115","#C6C2B2","#E3E3E2","#691B1F","#B8AD7E","#95484D","#AE9663","#B19D68","#A5735B","#A06057","#9A5152","#A87E5D","#7D2E34","#A9835E","#C3BEA6","#CFCEC9","#A46E5A","#F4F4F4","#DADAD8","#B29F69","#EDEDED","#BBB289","#9D5754","#AF9764","#904148","#994F51","#B3A36E","#A87F5E","#A26859","#AC8D61","#BDB590","#AA875F","#A77A5D","#AB8A60","#A4715B","#611418","#BFB897","#E6E6E6","#9B5353","#D5D4D1","#974A4F","#C8C6BA","#A16558","#9F5E56","#76272C","#67191D","#8C3C43","#B9AF82","#C3BFA9","#B5A874","#4F0205"]},broc:{discrete:a,categorical:a},broco:{discrete:c,categorical:c},buda:{discrete:["#B301B3","#B30BAE","#B314AA","#B31CA6","#B323A2","#B3289F","#B32E9D","#B4339A","#B53998","#B63E96","#B84394","#B94892","#BB4C91","#BD528F","#BE568D","#C05B8C","#C15F8A","#C36389","#C46987","#C66D86","#C77184","#C97583","#CA7982","#CB7E80","#CD837F","#CE877E","#CF8B7D","#D0917B","#D1957A","#D29979","#D49E78","#D5A277","#D6A776","#D7AC75","#D8B073","#D9B572","#DAB971","#DCBF70","#DDC36F","#DEC86E","#DFCC6C","#E0D16B","#E2D76A","#E4DC69","#E6E168","#E9E667","#EDEC67","#F3F366","#F9F966","#FFFF66"],categorical:["#B301B3","#FFFF66","#CD857E","#BC4E90","#DBBD70","#C56A87","#B32F9C","#E3DB69","#D4A177","#EDEC67","#D1937B","#B73F95","#C05C8B","#DFCB6D","#C97882","#B31CA6","#D8AE74","#E7E368","#DAB572","#B311AC","#D39A79","#C36389","#C77184","#B53798","#E1D36B","#BE558E","#B94793","#CB7E80","#CF8C7C","#DDC46E","#B326A0","#F6F566","#D6A875","#DAB971","#C66E86","#E2D76A","#B32B9E","#B317A9","#B4339A","#BA4B91","#C46788","#C2608A","#B309AF","#D49E78","#B63B97","#BD528F","#DCC06F","#EAE767","#FAFA66","#D2977A","#F1F066","#D0907C","#CE897D","#C87483","#CC827F","#D5A576","#B321A3","#E5DF68","#B84394","#D9B273","#E0CF6C","#CA7B81","#DEC86E","#BF598C","#D7AB75","#E6E168","#D1957A","#CC8080","#D39C78","#E0CD6C","#CD847F","#B63D96","#C87384","#C66C86","#F8F866","#D49F78","#D9B473","#DAB772","#BF578D","#CB7D81","#CF8A7D","#B32D9D","#D08E7C","#DBBB71","#C2628A","#E2D56A","#DCBF70","#BC508F","#C46987","#C05B8C","#DFCA6D","#DDC26F","#C15E8B","#D7AD74","#F3F366","#DEC66E","#D5A377","#B31AA7","#BA4992","#CE877E"]},bukavu:{discrete:t,categorical:t},cork:{discrete:r,categorical:r},corko:{discrete:i,categorical:i},davos:{discrete:["#00054A","#010E51","#041459","#081C61","#0C2368","#102A6F","#133075","#17377C","#1C3F83","#204588","#244C8D","#295291","#2D5895","#335F98","#38649A","#3C699C","#416E9D","#46729D","#4C779D","#517B9C","#567F9B","#5A829A","#5F8598","#658996","#698C94","#6E8F92","#739290","#78968D","#7D998C","#829D8A","#88A089","#8DA488","#95AA87","#9BAF88","#A3B489","#ABBB8C","#B4C190","#BFCA96","#C9D29E","#D2D9A6","#DBE0AF","#E3E7B8","#EBEDC4","#F0F1CD","#F4F4D6","#F7F7DE","#FAF9E6","#FCFCF0","#FDFDF7","#FEFEFE"],categorical:["#00054A","#FDFDF4","#688B94","#2D5895","#B2C08F","#E8EBC0","#87A089","#133075","#4B769D","#5A829A","#204588","#76958E","#D0D8A4","#99AD88","#F6F6DB","#3C699C","#081C61","#031256","#1A3B7F","#537C9C","#A4B68A","#C1CC98","#7E9A8B","#FAFAE8","#356199","#0E266B","#DEE3B3","#274F90","#6F9091","#618697","#8FA588","#F0F1CD","#43709D","#1D4084","#47739D","#F3F4D4","#658996","#567F9B","#17367A","#FCFBEE","#4F799D","#C9D29E","#93A987","#39659B","#D8DEAB","#ABBB8C","#739290","#B9C693","#F8F8E1","#234A8C","#112B70","#7A978D","#9EB188","#315C97","#829D8A","#05175B","#010C50","#3F6C9D","#0B2065","#5D8499","#2A5392","#8BA388","#6B8D93","#EDEFC7","#E3E7B8","#22488A","#638897","#122E73","#00094D","#AEBD8D","#4D789D","#CDD5A1","#5F8598","#58819A","#071A5E","#0C2368","#18387D","#91A787","#37639A","#EBEDC4","#F2F2D0","#FBFBEB","#74938F","#2F5A96","#335F98","#809B8B","#BDC995","#49759D","#719191","#9BAF88","#F7F7DE","#1B3E82","#A8B88B","#849E89","#557E9B","#E6E9BC","#45719D","#1E4386","#96AB87","#89A188"]},devon:{discrete:["#2C1A4C","#2B1E51","#2B2356","#2A295B","#2A2D60","#293265","#29376A","#283B6E","#274174","#27467A","#274C7F","#275186","#28568C","#2A5C95","#2D609C","#3064A3","#3468AA","#396BB1","#3F70B9","#4774C0","#4F79C6","#597DCC","#6382D1","#6F88D7","#798CDB","#8290DF","#8C95E2","#969AE6","#9E9EE9","#A6A3EB","#ACA7ED","#B1ACEF","#B7B1F0","#BBB5F1","#BFB9F2","#C3BEF3","#C7C2F4","#CCC7F4","#D0CCF5","#D4D0F6","#D8D4F7","#DCD9F8","#E1DEF9","#E5E3FA","#E9E7FB","#EDECFB","#F2F0FC","#F7F6FD","#FBFAFE","#FFFFFF"],categorical:["#2C1A4C","#F8F8FE","#758AD9","#C6C0F3","#28568C","#29376A","#AAA5ED","#DEDCF8","#3D6EB7","#EBE9FB","#9197E4","#3063A2","#274579","#577CCB","#D2CEF6","#2A285A","#BAB3F1","#B2ADEF","#F2F0FC","#274E82","#2A2F62","#CCC7F4","#9E9EE9","#4875C1","#C0BAF2","#2B5D98","#3669AD","#2B2154","#E4E2FA","#8290DF","#D8D4F7","#6784D3","#283E71","#C9C4F4","#BDB7F1","#DBD8F8","#283A6D","#4F79C6","#A4A2EB","#EEEDFC","#CFCBF5","#E8E5FA","#5F80CF","#4272BC","#B6B0F0","#2B1D50","#AEA9EE","#275287","#2A2B5E","#989BE7","#293366","#27497D","#8A94E1","#295A92","#3266A7","#F5F4FD","#7B8DDC","#274174","#2D609C","#2B2558","#6F88D7","#E1DEF9","#3A6CB2","#D5D1F6","#C3BEF3","#2E629F","#3165A4","#8D95E3","#3468AA","#DAD6F7","#D1CDF5","#9B9CE8","#275084","#B8B2F0","#27477B","#6382D1","#4573BF","#A2A0EA","#F7F6FD","#C7C2F4","#F3F2FD","#274376","#8692E0","#2B1F52","#CAC6F4","#ACA7ED","#E3E0F9","#F0EEFC","#E6E4FA","#386AB0","#2C1C4E","#6B86D5","#28396B","#283C6F","#2A5C95","#2A2D60","#BEB9F2","#C2BCF2","#7E8FDD","#3F70B9"]},fes:{discrete:o,categorical:o},glasgow:{discrete:["#361338","#3B1434","#401530","#45172C","#491828","#4D1924","#511B21","#561C1D","#5B1E18","#602014","#662210","#6B260B","#6F2B07","#723203","#743802","#743E01","#754300","#744900","#744F01","#745402","#735905","#725F0B","#716413","#70691E","#6E6E27","#6C7231","#6B763A","#697B46","#677F4F","#658359","#648763","#628B6C","#618F78","#609381","#60978A","#619B94","#659F9D","#6CA5A8","#74A9B0","#7DADB8","#86B1BF","#8EB4C6","#99B9CE","#A1BCD5","#AABFDB","#B2C3E1","#BBC6E7","#C6CBF0","#D0CFF7","#DBD3FF"],categorical:["#361338","#DBD3FF","#6D702B","#69A3A5","#702D06","#A0BBD3","#638968","#521B20","#745101","#84B0BE","#754001","#5F9587","#BBC6E7","#612013","#45172C","#687D4A","#726210","#618F78","#4B1926","#3E1532","#629C96","#658359","#CACCF3","#76AAB2","#6B763A","#744900","#6A250C","#ADC1DD","#735905","#92B6C9","#591D1A","#743702","#70681C","#4F1A23","#754400","#6D2909","#60998E","#41162F","#744D00","#745503","#B4C3E2","#697A42","#7DADB8","#628C70","#8BB3C3","#561C1D","#D2D0F9","#99B9CE","#3A1435","#6F6C23","#743B01","#60927F","#662210","#648661","#659F9D","#678051","#725E0A","#481829","#6FA6AB","#6C7332","#5D1E17","#A6BED8","#C2C9ED","#723203","#716617","#68240E","#6F6A20","#C6CBF0","#79ABB5","#72600D","#754200","#43162D","#67A1A1","#6B7536","#5F1F15","#735B07","#571C1B","#72A8AF","#744F01","#BEC8EA","#381337","#8EB4C6","#628B6C","#677E4D","#60917B","#639E9A","#4A1827","#A3BDD6","#3C1433","#743901","#632112","#B7C5E5","#4D1924","#65845D","#618E74","#609483","#9CBAD1","#46172A","#87B1C1","#6D712F"]},grayc:{discrete:["#000000","#090909","#111111","#171717","#1C1C1C","#212121","#252525","#2A2A2A","#303030","#343434","#393939","#3D3D3D","#424242","#474747","#4B4B4B","#505050","#545454","#585858","#5D5D5D","#616161","#656565","#696969","#6D6D6D","#717171","#757575","#797979","#7D7D7D","#818181","#858585","#898989","#8E8E8E","#929292","#979797","#9C9C9C","#A1A1A1","#A6A6A6","#ABABAB","#B1B1B1","#B6B6B6","#BCBCBC","#C1C1C1","#C7C7C7","#CECECE","#D5D5D5","#DBDBDB","#E2E2E2","#E8E8E8","#F1F1F1","#F8F8F8","#FFFFFF"],categorical:["#070707","#F9F9F9","#777777","#454545","#AEAEAE","#909090","#292929","#5F5F5F","#D1D1D1","#9E9E9E","#525252","#E4E4E4","#6C6C6C","#BFBFBF","#1A1A1A","#373737","#848484","#595959","#222222","#B6B6B6","#A6A6A6","#3E3E3E","#7D7D7D","#666666","#969696","#8A8A8A","#4B4B4B","#DADADA","#C8C8C8","#313131","#717171","#131313","#EFEFEF","#C4C4C4","#A2A2A2","#424242","#878787","#252525","#2D2D2D","#4F4F4F","#3B3B3B","#808080","#1E1E1E","#BBBBBB","#AAAAAA","#EAEAEA","#696969","#7A7A7A","#DFDFDF","#636363","#565656","#B2B2B2","#0E0E0E","#9A9A9A","#5C5C5C","#747474","#F3F3F3","#333333","#6E6E6E","#D5D5D5","#8D8D8D","#939393","#494949","#CCCCCC","#171717","#BDBDBD","#575757","#C1C1C1","#404040","#828282","#E2E2E2","#151515","#1C1C1C","#0B0B0B","#9C9C9C","#858585","#2F2F2F","#B4B4B4","#888888","#242424","#272727","#3C3C3C","#B0B0B0","#353535","#545454","#5B5B5B","#393939","#D7D7D7","#A4A4A4","#A8A8A8","#959595","#767676","#646464","#989898","#444444","#474747","#111111","#F6F6F6","#ECECEC","#4D4D4D"]},hawaii:{discrete:["#8C0273","#8E0D6E","#8F1569","#901D63","#91235F","#91285A","#922D56","#933252","#94384D","#943D4A","#954246","#964742","#964C3F","#97523B","#985638","#985C34","#996131","#9A662E","#9B6C2A","#9B7226","#9C7823","#9C7E20","#9D841E","#9D8C1C","#9C921C","#9B991D","#9AA021","#97A828","#94AE30","#91B439","#8CB942","#88BE4C","#82C359","#7EC663","#79CA6E","#74CE79","#70D183","#6AD591","#66D89C","#62DCA7","#60DFB2","#5FE2BD","#61E6CA","#67E9D5","#6FEBDE","#7AEEE7","#87EFEE","#98F1F5","#A6F1F9","#B3F2FD"],categorical:["#8C0273","#B3F2FD","#9C951C","#6CD48C","#964D3E","#8ABC48","#9B6D29","#66E8D3","#922E55","#9C801F","#87EFEE","#995D34","#7BC969","#901D63","#60DEB0","#96AA2B","#943D4A","#975439","#82C359","#5FE4C2","#9AA021","#73CE7B","#65D99E","#954544","#9D8A1C","#8E126B","#91B439","#9DF1F7","#73ECE2","#91265C","#9C7724","#9A652E","#93364F","#922A59","#996131","#9D851D","#9D901C","#9A692C","#68D695","#902160","#9B9A1E","#985836","#9B7226","#933252","#77CC72","#9C7B21","#954147","#8D0A6F","#93AF32","#62DCA7","#92F0F3","#8F1867","#7DEEE8","#97513C","#6CEBDB","#61E6CA","#A8F2FA","#964941","#7FC661","#86BF50","#98A526","#70D183","#5FE1B9","#8DB840","#94394D","#9C7923","#8F1569","#985A35","#60E0B4","#9A6B2A","#91245E","#97A828","#9B7425","#6AD591","#95AD2E","#5FE2BD","#60E5C6","#953F48","#933054","#63E7CF","#84C154","#8D0671","#82EFEB","#9B9D1F","#99A323","#88BE4C","#6ED288","#6FEBDE","#9A672D","#91285A","#75CD76","#995F32","#68E9D7","#9B7028","#61DDAB","#943B4B","#933450","#8DF0F0","#8F1A65","#81C45D"]},imola:{discrete:["#1A33B3","#1C37B1","#1E3AAF","#203EAD","#2242AB","#2345AA","#2548A8","#274CA6","#2950A4","#2A53A3","#2C56A1","#2E599F","#2F5D9E","#32609B","#346499","#366797","#386A95","#3B6C92","#3E708F","#41738C","#44768A","#467987","#4A7C85","#4E8082","#518480","#56887E","#5A8C7D","#5F927B","#64967A","#689B79","#6DA078","#72A576","#78AB75","#7DB074","#82B572","#87BA71","#8CBF70","#93C66E","#98CB6D","#9ED06C","#A4D66A","#ACDB69","#B5E268","#BFE767","#C8EB67","#D3F066","#DDF466","#EAF866","#F5FB66","#FFFF66"],categorical:["#1A33B3","#FFFF66","#54867F","#305E9D","#91C36F","#3F718E","#2549A8","#BDE667","#70A377","#2B53A2","#376896","#80B373","#A3D56B","#DDF466","#203EAD","#487B86","#62947A","#2D59A0","#88BB71","#5B8D7D","#CDED66","#4E8082","#EEF966","#33639A","#284EA5","#44768A","#2344AA","#AFDE69","#3B6C92","#78AB75","#1D39B0","#99CC6D","#699C79","#3D6F90","#2C56A1","#2F5B9E","#5E917B","#4B7D84","#9ED06C","#1F3CAE","#C4EA67","#84B772","#274CA6","#D5F066","#2951A4","#74A776","#578A7E","#2446A9","#1C36B1","#A9D96A","#95C86E","#467888","#2141AC","#7CAF74","#356598","#B5E268","#66987A","#396A94","#F7FC66","#8CBF70","#E6F666","#32609B","#518380","#41738C","#6DA078","#6B9E78","#B9E468","#7AAD74","#528580","#32629B","#86B971","#3C6E91","#5C8F7C","#C8EB67","#ACDB69","#D1EF66","#E2F566","#97CA6D","#1B35B2","#1C37B0","#2345AA","#2F5D9E","#1F3DAE","#457789","#3A6B93","#598B7D","#D9F266","#346499","#386995","#A6D76A","#366797","#274DA6","#56887E","#A1D36B","#42748B","#7EB173","#72A576","#477987","#4C7F83","#F2FB66"]},lajolla:{discrete:["#191900","#1E1B02","#221C05","#271E08","#2C200B","#31220E","#362411","#3C2614","#442817","#4B2B1B","#532D1F","#5B3023","#633328","#6E362D","#783932","#813C37","#8B3F3B","#96423F","#A24543","#AD4746","#B74A48","#C04D49","#C9514B","#D1564C","#D75C4D","#DB634E","#DD694F","#E0714F","#E17750","#E37D50","#E48351","#E58951","#E79052","#E89652","#E99C52","#EAA253","#EBA853","#EDAF54","#EEB555","#F0BC57","#F1C25A","#F3CA5F","#F5D369","#F7DA74","#F9E282","#FBE890","#FCEF9F","#FDF5B0","#FEFABE","#FFFECB"],categorical:["#191900","#FFFECB","#D85F4D","#ECAC54","#653329","#F7D971","#A44544","#E58751","#362411","#E1744F","#C44E4A","#E99A52","#4B2B1B","#833D38","#F1C159","#FCEF9F","#271E08","#FEF7B6","#402716","#D0554C","#FAE587","#E79052","#EFB655","#B54947","#201C04","#E37D50","#743830","#DD694F","#EBA353","#94413E","#572F21","#F4CD61","#2E210C","#FDF3AB","#32220F","#241D06","#F5D369","#7B3B34","#1D1B02","#F0BC57","#5E3125","#F8DF7C","#512D1E","#CA514B","#E48251","#E68C51","#EA9E53","#E89552","#BC4C49","#6C362C","#EDB154","#9C4341","#E27950","#FBEA93","#3B2513","#FEFBC0","#452918","#EBA853","#F2C75C","#8B3F3B","#DB644E","#AD4746","#DF6E4F","#D55A4D","#2B200A","#783932","#E79352","#D75C4D","#FEF9BB","#EDAF54","#E0714F","#7F3C36","#613227","#F7DC77","#C7504B","#F1C45A","#30210D","#F4D065","#1E1B03","#FAE78D","#F9E282","#DA614E","#392412","#4E2C1D","#E99C52","#EFB956","#221C05","#EBA553","#FDF5B0","#984240","#E38050","#8F403D","#542E20","#ECAA54","#E68E51","#70372E","#DE6C4F","#B94A48","#291F09","#1B1A01"]},lapaz:{discrete:["#1A0C64","#1C1368","#1E196D","#202071","#212675","#222B79","#23317D","#253681","#263C85","#274189","#29478C","#2A4C8F","#2C5192","#2E5795","#305C98","#32609A","#35659C","#386A9E","#3C70A0","#3F74A1","#4379A2","#487DA3","#4D81A3","#5386A4","#588AA3","#5E8EA3","#6591A2","#6C95A1","#7398A0","#7A9A9E","#809D9D","#879F9B","#90A199","#97A397","#9EA596","#A5A795","#ADAA95","#B7AD96","#BFB199","#C8B69C","#D2BBA2","#DAC1A8","#E4C9B2","#EBCFBB","#F1D5C4","#F5DBCD","#F9E1D6","#FBE8E1","#FDEDEA","#FEF2F3"],categorical:["#1A0C64","#FEF2F3","#5B8BA3","#B3AC96","#2C5292","#3C70A0","#EACEB9","#859E9C","#24327E","#6F96A1","#33619A","#202071","#D0BAA0","#9BA496","#F9E1D6","#4A7FA3","#284289","#90A199","#FCEAE5","#1D176B","#37699D","#F3D8C8","#A7A895","#5285A4","#7A9A9E","#2F5A97","#4278A2","#263A84","#6591A2","#C1B299","#DEC3AB","#222978","#2A4B8E","#5688A4","#D7BEA6","#FDEEEC","#608EA3","#EFD3C0","#A1A696","#6A94A1","#FBE6DD","#ADAA95","#F6DDCF","#4E82A3","#2E5695","#3A6D9F","#C8B69C","#1C1268","#232D7B","#3F74A1","#467BA3","#1E1C6E","#7F9C9D","#BAAF97","#253681","#315E99","#29478C","#E4C9B2","#74989F","#273E87","#212575","#95A398","#8AA09A","#35659C","#2B4F91","#23307C","#E7CBB5","#F1D5C4","#2B4D90","#202373","#588AA3","#D3BCA3","#5487A4","#447AA2","#6792A2","#24347F","#253882","#ECD0BD","#879F9B","#305C98","#E1C6AF","#1E196D","#5D8DA3","#AAA995","#386B9E","#487DA3","#77999F","#F7DFD3","#BEB098","#1F1E70","#325F99","#4176A2","#F4DACB","#4C80A3","#2D5494","#8DA099","#6C95A1","#FAE3DA","#FDECE8","#B7AD96"]},lipari:{discrete:["#031326","#05192F","#062038","#092844","#0C2E4D","#103557","#163C5F","#1E4368","#294B70","#345075","#3E5578","#47587A","#4F5B7B","#575C7A","#5D5D79","#635E78","#695E76","#6E5F75","#765F73","#7C6071","#826070","#89606E","#90616C","#98616A","#A06268","#A86266","#B06364","#BA6462","#C36660","#CB685F","#D46B5E","#DB705F","#E27760","#E77E63","#E98567","#EA8D6B","#EA946F","#E89C75","#E7A279","#E6A87E","#E5AF84","#E5B58A","#E6BD92","#E7C49A","#EACCA3","#EDD3AD","#F0DBB7","#F5E5C4","#F9EDCF","#FDF5DA"],categorical:["#031326","#FDF5DA","#A56267","#525B7A","#E99B74","#785F72","#DA6F5E","#183E61","#E7C398","#8D616D","#365176","#092844","#655E77","#E98466","#BF6561","#F0DBB7","#E5AD82","#B26364","#EBCFA7","#5C5D79","#061D35","#25486D","#0E3353","#EA906D","#98616A","#E37861","#E5B88C","#826070","#CD685F","#6E5F75","#45587A","#F6E8C9","#E7A37A","#615E78","#E77E63","#D46B5E","#9F6268","#E99570","#93616B","#87606E","#7D6071","#F3E1C0","#575C7A","#0B2D4B","#2D4D72","#E6A87E","#E9C99F","#FAEED1","#1E4368","#EA8A69","#B86462","#6A5E76","#AB6365","#735F74","#DF735F","#E5B287","#13385A","#05182D","#E6BD92","#3E5578","#EDD5AF","#07223C","#C6665F","#4C5A7A","#E8A077","#B56363","#FBF1D6","#A26267","#E6C095","#0A2A48","#F8EBCD","#EACCA3","#AE6364","#7A5F72","#635E78","#E98768","#041629","#715F74","#ECD2AB","#A86266","#8A606E","#96616B","#545C7A","#EFD8B3","#F5E5C4","#9B6169","#F2DEBB","#765F73","#6C5F75","#294B70","#22466B","#E89D76","#E88165","#BC6461","#E6A67C","#85606F","#C36660","#1B4064","#D06A5E","#103557"]},lisbon:{discrete:l,categorical:l},managua:{discrete:s,categorical:s},navia:{discrete:["#031327","#041930","#051E3A","#052546","#062B50","#06315A","#073764","#083E6D","#0B4578","#0E4C80","#115286","#15588B","#195E8E","#1E6491","#216991","#246D91","#27718F","#2A748E","#2D788C","#307A8A","#337D89","#368087","#398385","#3C8683","#3F8981","#428C7F","#468F7D","#4A937A","#4E9678","#529A76","#579E73","#5BA271","#62A86E","#67AD6B","#6EB269","#76B768","#7FBD68","#8CC56A","#98CB6F","#A4D176","#B1D67F","#BCDB89","#C9E096","#D3E3A1","#DCE7AC","#E3EAB6","#EAEDBF","#F1F0CA","#F7F2D2","#FCF4D9"],categorical:["#031327","#FCF4D9","#408A80","#87C269","#1B608F","#59A072","#073966","#D1E39F","#2F798B","#EAEDBF","#052546","#266F90","#6BB06A","#0E4D81","#AED57D","#4C947A","#378186","#DFE8B0","#337D89","#2A748E","#14578A","#051C36","#9ACC70","#0A4374","#468F7D","#529A76","#F4F1CD","#062F56","#C1DC8D","#206891","#78B968","#62A86E","#3C8583","#569D74","#236C91","#F8F3D3","#D8E5A8","#0C487B","#04182E","#71B469","#B8D985","#07345E","#05213E","#4F9778","#5DA470","#3E8882","#062A4E","#7FBD68","#EFEFC6","#C9E096","#115286","#2C768D","#1E6491","#49917B","#66AC6C","#28718F","#A4D176","#90C76C","#438C7F","#175C8D","#083E6D","#E5EAB8","#317B8A","#357F87","#398385","#B3D781","#0D4A7E","#1C6290","#052342","#579F73","#9FCE73","#448D7E","#051A32","#FAF3D6","#428B7F","#29738F","#104F84","#5FA66F","#509877","#8CC56A","#094071","#2D788C","#083B6A","#D5E4A3","#2B758D","#226A91","#04162B","#BCDB89","#47907C","#4D9579","#E2E9B4","#7BBB68","#6EB269","#135488","#4A937A","#F1F0CA","#5BA271","#C5DE92","#F6F2D0","#CDE19B"]},naviaw:{discrete:["#041427","#051A31","#05203B","#062747","#072D52","#08345C","#0A3A66","#0C416F","#0F4979","#135080","#175686","#1B5D8A","#1F628D","#23698F","#276D8F","#2A728F","#2D758E","#30798D","#347D8B","#378089","#3A8388","#3D8686","#408984","#448C82","#489080","#4B937E","#50977C","#559C79","#5AA077","#5FA575","#65AA73","#6CAF71","#76B671","#7FBD71","#89C474","#95CB78","#A2D27F","#B1D98A","#BEDF95","#C9E5A1","#D3E9AD","#DBEDB9","#E4F1C6","#E9F4D0","#EEF6D9","#F2F8E1","#F6FAE9","#F9FCF1","#FCFDF7","#FEFEFD"],categorical:["#041427","#FBFDF6","#478F80","#9FD07D","#1F628D","#64A973","#E3F0C4","#0A3A66","#337C8B","#C7E49E","#7DBC71","#549B7A","#2A718F","#135080","#F2F8E1","#3C8586","#062747","#D7EBB2","#418A83","#B4DB8C","#2E778D","#6FB271","#EBF5D4","#0E4574","#051D37","#4D957D","#256B8F","#195A88","#388189","#F7FAEC","#5CA276","#8CC574","#073056","#31798C","#367E8A","#69AD72","#E7F3CC","#104A7A","#95CB78","#EFF6DB","#0B406D","#2C748E","#4A927F","#DDEEBB","#50987C","#165584","#589E78","#76B671","#3F8785","#05192F","#BEDF95","#448C82","#22678E","#06223F","#A9D684","#08355E","#CFE8A8","#F9FCF1","#286E8F","#85C172","#072C50","#F5F9E7","#1C5F8B","#3A8387","#60A675","#F3F9E4","#0C4271","#266D8F","#81BE72","#0A3D6A","#4B937E","#9ACD7B","#EDF5D7","#90C876","#A4D381","#378089","#1B5D8A","#489080","#145282","#DAECB6","#67AB73","#CBE6A3","#B9DD90","#3D8686","#23698F","#6CAF71","#FAFCF3","#79B971","#D3E9AD","#5AA077","#458E81","#72B471","#327B8C","#E5F1C8","#051B33","#F8FBEE","#062443","#398288","#2B728F","#06294C"]},nuuk:{discrete:["#05598C","#0E5B8B","#155C89","#1C5E87","#226085","#276184","#2C6383","#326682","#386982","#3E6C82","#446F82","#4A7283","#517584","#587A86","#5F7D88","#66818A","#6C858C","#73898E","#7B8E91","#819192","#879594","#8D9996","#939C97","#99A097","#9EA498","#A2A798","#A6AA97","#ABAD96","#AEAF95","#B1B194","#B3B492","#B6B690","#B8B88E","#BABA8C","#BDBC8A","#BFBE88","#C1C187","#C4C385","#C7C684","#CAC983","#CDCD83","#D2D184","#D7D787","#DDDD8B","#E3E290","#E8E895","#EEEE9C","#F4F4A4","#F9F9AB","#FEFEB2"],categorical:["#05598C","#FEFEB2","#A1A698","#537785","#C3C385","#B5B591","#7D8F91","#2D6483","#DDDD8B","#919B96","#BCBC8B","#3F6C82","#CDCD83","#1C5E87","#ADAE95","#68838B","#EEEE9C","#A7AA97","#879594","#C8C783","#F6F6A7","#135C89","#B9B98E","#497183","#73898E","#366882","#C0BF88","#D4D486","#99A097","#B1B293","#5E7D88","#256185","#E6E693","#829293","#788C90","#9DA398","#AAAC96","#E1E18F","#3B6A82","#638089","#B3B492","#A4A897","#446F82","#BABA8C","#D8D888","#185D88","#8C9895","#215F86","#BEBD89","#B7B78F","#CACA83","#4E7484","#C1C186","#959E97","#F2F2A1","#AFB094","#326682","#587A86","#296284","#FAFAAD","#6E868C","#C5C584","#D1D084","#0D5B8B","#E9E997","#DFDF8D","#66818A","#B0B194","#5B7B87","#2B6383","#859493","#CCCB83","#F8F8AA","#D2D285","#1F5F86","#70878D","#4B7383","#768B8F","#FCFCAF","#A9AB97","#BFBE88","#C9C983","#346782","#DBDA89","#236085","#BDBD8A","#BAB98D","#B8B88E","#2F6583","#939C97","#9FA498","#A2A798","#CFCF84","#B4B591","#C4C485","#979F97","#F0F09E","#155C89","#9BA298","#517584"]},oleron:{discrete:n,categorical:n},oslo:{discrete:["#010101","#04070B","#060C13","#0A121B","#0C1620","#0D1927","#0E1D2D","#0F2133","#10263C","#112A43","#122E4A","#133251","#153758","#173C61","#194169","#1B4670","#1E4A78","#214F80","#255589","#295A91","#2E5F99","#3364A1","#3A6AA9","#4371B2","#4B77B9","#537DBE","#5B83C3","#6489C6","#6B8EC8","#7292C9","#7896C9","#7E9ACA","#859ECA","#8BA2C9","#91A6C9","#97A9C9","#9DADC9","#A4B2CA","#AAB6CA","#B1BBCB","#B8BFCD","#BFC5CF","#C7CCD3","#CFD2D8","#D7D9DD","#DEE0E2","#E6E7E9","#EFF0F1","#F7F7F8","#FFFFFF"],categorical:["#030609","#F9F9F9","#507BBC","#163B5E","#A0AFC9","#7B98CA","#27588E","#0E2032","#CACED5","#122D48","#3767A6","#1D4875","#8DA3C9","#E2E3E5","#678BC7","#B4BDCC","#0C151F","#BFC5CF","#97A9C9","#4371B2","#10263D","#080E16","#7292C9","#215081","#2E5F99","#AAB6CA","#ECEDEE","#0D1A28","#143454","#D5D8DC","#5B83C3","#19426A","#859ECA","#13314E","#0E1D2D","#3D6CAC","#6C8FC8","#7795C9","#F3F3F4","#4976B8","#245488","#DBDDE0","#112A43","#92A6C9","#C5C9D2","#809BCA","#0F2337","#3263A0","#050A10","#B9C1CD","#1F4C7B","#183E64","#A5B3CA","#0A121B","#9CACC9","#6187C5","#0D1824","#8AA1CA","#2A5B93","#547EBF","#D1D3D9","#E6E7E9","#1B456F","#B0BACB","#153758","#7494C9","#D8DADE","#6A8DC8","#90A5C9","#99ABC9","#235285","#133251","#060C13","#406EAF","#7E9ACA","#173C61","#4C78BA","#122F4B","#1C4772","#87A0CA","#CED1D7","#C2C7D1","#0F253A","#2C5D96","#C7CCD3","#112B45","#EFF0F1","#6F90C9","#0E1E2F","#ADB8CB","#7997CA","#4673B5","#15395B","#091018","#194067","#30619C","#94A8C9","#F6F6F6","#0F2135","#A3B1CA"]},roma:{discrete:d,categorical:d},romao:{discrete:g,categorical:g},tofino:{discrete:m,categorical:m},tokyo:{discrete:["#1C0E34","#241036","#2D1339","#37163D","#3F1A40","#481E43","#4F2345","#562948","#5D304A","#62354C","#663B4D","#69404E","#6B454F","#6D4B50","#6E4F50","#6F5251","#6F5651","#705951","#715C52","#715F52","#716252","#726452","#726753","#736B53","#736E53","#747153","#757554","#757A54","#767E55","#778355","#788856","#798E57","#7B9558","#7C9B5A","#7EA25C","#81A95E","#84B062","#88B968","#8DC16E","#93CA76","#9BD27F","#A4DA8A","#AFE398","#BAEAA4","#C5EFB0","#CFF4BB","#D8F7C5","#E2F9CF","#E9FBD7","#EFFCDD"],categorical:["#1C0E34","#EFFCDD","#747053","#6C4750","#87B666","#B8E8A1","#512446","#715D52","#798B56","#7D9F5B","#37163D","#726653","#99D07D","#63374C","#6F5451","#D8F7C5","#767C54","#705951","#5B2D49","#7B9558","#441D41","#291238","#E5FAD2","#C9F1B4","#716252","#81AA5F","#683F4E","#736B53","#6E4E50","#757654","#8EC370","#A7DD8E","#778455","#747354","#84B062","#231036","#93CA76","#DFF9CC","#30143A","#A0D785","#7FA45D","#EAFBD8","#6A434F","#C1EDAB","#736D53","#562948","#6D4B50","#7A9057","#7C9A59","#4B2044","#715F52","#663B4D","#D1F4BD","#705651","#8ABD6A","#6E5151","#AFE398","#5F324B","#757954","#3E193F","#726853","#726452","#778055","#705B52","#788756","#61344C","#746E53","#ABE093","#532747","#85B364","#7EA25C","#261137","#736C53","#E8FBD5","#4E2245","#88B968","#798E57","#767E55","#726753","#757754","#715E52","#3A183E","#6E4F51","#778255","#7B9759","#DCF8C9","#EDFCDA","#411B40","#7D9C5A","#767B54","#726352","#6F5551","#726552","#82AD60","#D5F6C1","#34153C","#9CD481","#747454","#C5EFB0","#481E43"]},turku:{discrete:["#000000","#090908","#111110","#181816","#1D1D1A","#22221F","#272723","#2C2C27","#33322B","#38382F","#3D3D32","#424235","#474738","#4E4D3C","#53523E","#585841","#5D5D43","#626246","#686848","#6E6D4B","#73724D","#797750","#7F7D52","#878356","#8E8859","#968E5C","#9D9360","#A79864","#AF9C68","#B69F6C","#BEA270","#C4A474","#CCA579","#D1A67D","#D7A781","#DBA886","#E0A98B","#E6AB92","#EAAD98","#EFB09F","#F2B4A7","#F6B9AE","#F9BFB7","#FBC4BF","#FDC9C6","#FECFCC","#FED4D3","#FFDBDA","#FFE0E0","#FFE6E6"],categorical:["#070707","#FFE6E6","#948D5B","#E5AA90","#4D4C3B","#2C2C27","#C3A374","#6D6C4A","#FBC4BF","#D6A780","#F2B4A7","#1C1C19","#3D3D32","#AC9A67","#7E7C52","#FED6D4","#5D5D43","#35342D","#DDA888","#141312","#55543F","#242420","#FDCDCA","#F7BCB3","#898456","#B8A06D","#ECAE9B","#CDA57A","#FFDEDD","#646447","#454537","#9F9461","#76744E","#71704C","#30302A","#414135","#181816","#FCC8C4","#EFB1A1","#838054","#F5B8AD","#E1A98C","#C8A477","#686848","#595941","#20201D","#8E8859","#D1A67D","#B29D6A","#E9AC95","#BEA270","#FED1CF","#0E0E0D","#A59764","#DAA784","#282823","#F9C0B9","#51503D","#393930","#FFDAD9","#49493A","#606045","#FFE2E1","#9A915E","#797750","#F4B6AA","#F6BAB0","#CBA578","#FFD8D6","#FECFCC","#262622","#C0A272","#868255","#1A1A18","#FAC2BC","#8B8658","#E3AA8E","#161614","#4F4E3C","#C6A475","#2E2E28","#BBA16F","#6B6A49","#E7AB93","#CFA67C","#626246","#53523E","#5B5B42","#FED3D1","#7C7A51","#817E53","#73724D","#FFDCDB","#37372E","#F8BEB6","#0B0B0A","#575740","#DFA98A","#474738","#B59F6C"]},vanimo:{discrete:b,categorical:b},vik:{discrete:u,categorical:u},viko:{discrete:f,categorical:f}};function p(A){const C=A.replace("#","");return{r:parseInt(C.slice(0,2),16),g:parseInt(C.slice(2,4),16),b:parseInt(C.slice(4,6),16)}}const h={waves:"batlow",blksand:"tokyo",breeze:"imola",magma:"batlow",ribbon:"hawaii",stars:"batlow",folds:"imola"},k={[B.ADVERT]:1,[B.TXT_MSG]:4,[B.GRP_TXT]:2,[B.RESPONSE]:8,[B.REQ]:13,[B.ANON_REQ]:7,[B.ACK]:11,[B.PATH]:24,[B.TRACE]:16,[B.GRP_DATA]:34,[B.MULTIPART]:52,[B.RAW_CUSTOM]:14};function v(){let A="waves",C=!0;if("undefined"!=typeof window){A=localStorage.getItem("pymc-color-scheme")||"waves";const B=D(A);C=(null==B?void 0:B.meta.isDark)??!0}const B=h[A]??"batlow",F=w[B],E=F.discrete.length,e=Math.floor(E/2);return{colormap:F,colormapName:B,isDark:C,baseIndex:C?e:0,halfSize:e}}let T=null;function M(A){const{colormap:C,isDark:D}=v();if("number"!=typeof A)return D?"#A5A5A5":"#666666";const B=k[A];if(void 0===B)return D?"#A5A5A5":"#666666";const F=C.categorical;return F[Math.min(B,F.length-1)]}function R(D){const B=M(D);return null===T&&(T=C()),T?A(B):B}function I(A){return p(M(A))}function S(A){const{colormap:C,baseIndex:D,halfSize:B}=v(),F=Math.max(0,Math.min(1,A)),E=Math.min(D+Math.floor(F*(B-1)),C.discrete.length-1);return C.discrete[E]}export{I as a,S as b,R as g,p as h}; +import"./vendor-react-DtVWNgeu.js";import{a4 as A,a5 as C,a6 as D,x as B}from"./index-Bmit1I8S.js";const F=["#65024B","#701057","#7B1B61","#88276E","#923078","#9B3881","#A4418A","#AC4993","#B5549C","#BC5CA3","#C266AB","#C970B2","#CF7AB9","#D587C1","#DA93C8","#DF9ECE","#E3AAD4","#E7B5DA","#EBC2E0","#EECCE5","#F1D5E9","#F3DDED","#F5E4F0","#F6EBF1","#F6EFF1","#F5F2F0","#F3F3ED","#EFF3E6","#EBF1DF","#E5EFD5","#DDEBCA","#D4E6BD","#C8DEAB","#BCD79B","#B0CE8C","#A3C67D","#97BC6F","#88B161","#7CA856","#72A04D","#679845","#5E903D","#538735","#4B7F2E","#427827","#397021","#306819","#245D10","#195507","#0D4C00"],E=["#4F3043","#56304B","#603354","#6D3961","#793F6B","#834675","#8D4E7E","#965587","#A05E91","#A86698","#B06EA0","#B877A7","#BF81AF","#C78DB8","#CD98BE","#D2A3C4","#D6ADC8","#D9B5CB","#DABECC","#DAC3CC","#D9C7CA","#D8CAC8","#D6CBC6","#D4CDC2","#D1CDBE","#CCCDB9","#C6CBB1","#BCC5A4","#B2BE97","#A7B58A","#9CAB7E","#92A174","#889669","#808D62","#79855C","#737D56","#6D7552","#666C4C","#616548","#5C5D45","#575642","#54503F","#50493D","#4D453C","#4B403B","#4A3C3A","#49393A","#49343B","#4A313E","#4E3042"],e=["#9EB0FF","#93AFFA","#87ADF4","#79ABED","#6CA9E6","#60A5DF","#54A0D5","#489ACA","#3E90BC","#3787AF","#327EA3","#2D7597","#296B8B","#25607C","#225771","#1E4E65","#1B465A","#183D4F","#153342","#122C38","#11242E","#101D25","#11181C","#121214","#160E0D","#1B0B07","#210B03","#270D01","#2D0E00","#340F00","#3B1100","#421301","#4B1602","#541905","#5D1E09","#68240F","#732B16","#803620","#8A3F2A","#944834","#9E513F","#A85A4A","#B46658","#BE6F63","#C8796F","#D2837A","#DD8D86","#EA9995","#F4A3A1","#FFADAD"],a=["#2C1A4C","#2B2154","#2B295B","#2A3164","#29396C","#284174","#29497C","#2A5183","#305C8C","#376593","#416D9A","#4B76A0","#567FA6","#6489AD","#6F92B3","#7B9BBA","#86A3C0","#92ACC6","#A0B7CD","#ACC0D3","#B8C9DA","#C4D2E0","#D0DBE6","#DEE5EC","#E7ECED","#EDEFE9","#EDEEE1","#E9E9D4","#E4E4C8","#DEDEBD","#D8D8B1","#D2D2A5","#C9C996","#C1C18A","#B8B87E","#AEAE73","#A3A369","#97975E","#8D8D56","#83834D","#797945","#70703D","#646434","#5B5B2C","#525224","#49491D","#404016","#36360F","#2E2E08","#262600"],c=["#372F38","#36303D","#363144","#36354E","#363957","#373F60","#39456A","#3C4D75","#415780","#47608A","#4D6992","#55729A","#5D7BA2","#6886AA","#728FB1","#7C97B7","#86A0BD","#91A8C2","#9DB2C8","#A7BACC","#B1C1CE","#BAC8D0","#C2CDD0","#CAD1CD","#CED3C8","#CFD3C2","#CFD1B9","#CBCCAD","#C6C6A2","#BFBF96","#B8B78B","#AFAF7F","#A4A472","#9B9A68","#91915E","#888755","#7E7E4C","#737243","#6B693D","#626137","#5B5932","#54512E","#4C482B","#474229","#423D29","#3F3829","#3C352B","#39322E","#383032","#372F37"],t=["#1A3333","#1B373D","#1C3C47","#1E4255","#1F4762","#214E71","#235582","#255E92","#2969A1","#2C73AD","#2F7CB8","#3485C2","#3B8EC7","#4799C8","#50A1C9","#59AAC9","#62B2CA","#6BBACB","#76C3CB","#81CCCD","#92D5D1","#A4DED5","#B6E7DA","#CCF2DF","#DDFBE3","#034224","#08491F","#115119","#1C5914","#2B6212","#3D6915","#4E6E1B","#617224","#6F742B","#7B7631","#867836","#917B3C","#9E7E45","#AA844F","#B48D5D","#BC976C","#C3A27C","#CAB08F","#CFBBA0","#D5C6B0","#DACFC1","#DFD7D0","#E4DFE0","#E9E6ED","#EDEDFC"],r=["#2C194C","#2B2254","#2B295C","#2A3265","#293A6D","#284275","#284A7C","#2A5284","#2F5C8D","#366493","#3F6C99","#49749F","#527CA4","#5E85AA","#688DB0","#7395B6","#7E9DBB","#8AA6C2","#99B1C9","#A5BBD0","#B2C5D7","#C0CFDE","#CDD9E5","#DCE5EB","#E5ECED","#E6EEEA","#E0EAE1","#D4E2D4","#C8DBC8","#BCD3BC","#B0CAB0","#A4C2A3","#95B895","#89B088","#7DA87D","#71A071","#669966","#599059","#4F894E","#458244","#3B7B3A","#317430","#266A25","#1F611D","#1A5816","#174E12","#14450E","#123A0A","#103107","#0F2903"],i=["#3F3E3A","#3E3D3F","#3E3D44","#3E3D4B","#3E3F52","#3E425A","#3F4762","#414C6C","#445578","#485D82","#4E658B","#546E94","#5C779C","#6581A5","#6E8AAC","#7792B2","#809BB8","#89A3BD","#94ACC2","#9CB3C5","#A3BAC7","#A9C0C8","#AEC5C7","#B0C9C4","#B0CABF","#ADCAB9","#A9C9B2","#A2C5A8","#9BC19F","#93BC95","#8BB68B","#82B081","#78A775","#709F6A","#689760","#608E56","#5A864C","#537B42","#4F733B","#4B6B35","#486431","#465D2E","#44562C","#43512C","#424D2D","#42492E","#414630","#404333","#404036","#3F3E3A"],o=["#0D0D0D","#181818","#212121","#2B2B2B","#343434","#3C3C3C","#454545","#4D4D4D","#565656","#5E5E5E","#656565","#6D6D6D","#747474","#7C7C7C","#848484","#8B8B8B","#939393","#9C9C9C","#A7A7A7","#B1B1B1","#BBBBBB","#C5C5C5","#D1D1D1","#DFDFDF","#ECECEC","#094225","#184822","#2B4F20","#3A5420","#485822","#555B24","#615E26","#6F6229","#7A652B","#86682E","#926B30","#9F7035","#AD7940","#B6834D","#BD8E5C","#C2996C","#C6A47C","#CCB18F","#D1BCA0","#D5C6B0","#DACFC1","#DFD7CF","#E4DFE0","#E8E6ED","#EDEDFC"],l=["#E6E5FF","#D8DCF7","#CBD2EF","#BBC6E5","#ADBCDE","#A0B3D6","#93A9CE","#86A0C6","#7794BD","#6A8BB5","#5E81AC","#5177A4","#456E9B","#38628F","#2F5984","#274F78","#20476D","#1B3F61","#173653","#142E48","#12283E","#112233","#111D2A","#121921","#15181B","#181A18","#1E1D17","#252419","#2D2B1C","#353220","#3E3A25","#46422A","#514C31","#5A5536","#645E3C","#6D6741","#777047","#837B4F","#8D8556","#988F5E","#A29A67","#ADA470","#B9B17D","#C3BC89","#CDC795","#D7D2A2","#E0DCAF","#ECE9BE","#F5F4CB","#FFFFD9"],s=["#FFCF67","#F9C564","#F3BB60","#EBB05D","#E5A659","#DF9D56","#D99554","#D38C51","#CC824D","#C67B4B","#C07348","#B96C46","#B36444","#AB5C41","#A4553F","#9D4F3D","#95483C","#8E423A","#843B39","#7C3639","#743139","#6D2D3A","#662A3D","#5F2941","#5A2846","#552A4C","#522C53","#4F315D","#4D3566","#4C3B6F","#4C4179","#4C4883","#4D518E","#4F5897","#51609F","#5367A7","#556FAE","#5878B6","#5B80BC","#5E88C2","#6190C8","#6498CE","#68A3D5","#6BACDB","#6FB5E1","#72BEE6","#76C7EC","#7AD3F3","#7DDDF9","#81E7FF"],n=["#1A2659","#212E61","#293568","#323F72","#3A477A","#424F82","#4A578A","#535F92","#5D699C","#6572A5","#6E7BAE","#7784B7","#808DC0","#8B97CA","#94A1D3","#9DAADC","#A6B3E5","#AFBCEC","#B9C6F2","#C0CDF5","#C7D4F7","#CEDAF9","#D4E1FB","#DCE9FD","#E3F0FE","#1F4E00","#2C5100","#3A5600","#445900","#4F5C02","#5A6005","#65660C","#736D18","#7E7423","#8A7B2E","#94823A","#9F8945","#AC9253","#B79A5E","#C3A36A","#CEAC75","#D9B581","#E5C090","#EDC99D","#F2D2A9","#F6DAB5","#F8E2C0","#FAECCE","#FBF4DA","#FDFDE6"],d=["#7E1700","#832504","#883008","#8F3C0C","#934610","#984E14","#9C5717","#A05F1B","#A5681F","#A97023","#AD7826","#B0802B","#B58930","#BA9437","#BE9D3E","#C2A647","#C7B051","#CBBA5D","#CFC66D","#D1CF7B","#D2D78A","#D2DE98","#D0E4A6","#CBE8B4","#C4EABE","#BDEAC6","#B3E9CD","#A6E6D2","#9BE2D5","#8EDDD7","#81D7D7","#74CFD6","#64C6D5","#59BDD2","#4FB5D0","#46ACCC","#3EA4C9","#379AC5","#3292C2","#2E8ABF","#2B82BB","#287AB8","#2471B4","#2269B0","#1F60AD","#1C58A9","#194FA5","#1344A0","#0C3B9C","#033198"],g=["#733957","#773850","#7A3849","#7E3942","#823C3D","#863F38","#8A4334","#8E4831","#94502E","#98572C","#9D5F2B","#A3672C","#A8712E","#AF7D32","#B58837","#BB933F","#C19F47","#C6AA52","#CDB761","#D1C26E","#D4CB7B","#D6D388","#D5D995","#D3DEA3","#CEE0AD","#C8E1B6","#C1E1BE","#B6DEC5","#ABDBC9","#A0D6CC","#94D0CE","#88C9CF","#7BC0CE","#70B8CD","#67AFCA","#5FA6C7","#589CC4","#5291BE","#4F88B9","#4E7EB3","#4F75AC","#516BA4","#55609A","#595891","#5D5087","#62497D","#664474","#6B3F69","#6F3B60","#723959"],m=["#DED9FF","#D0CFF9","#C3C6F3","#B3BBEC","#A6B1E6","#98A8E1","#8B9FDB","#7E95D4","#6E89CB","#617FC3","#5575B8","#4A6BAC","#4262A0","#395790","#334F83","#2E4776","#293F6A","#24385D","#1F304F","#1B2943","#172338","#141D2E","#111824","#0F151B","#0D1516","#0D1712","#0F1B12","#112113","#142716","#162F19","#1A361C","#1D3E20","#224825","#26512A","#2A5A2E","#2E6233","#336C38","#39773E","#3F8144","#488B4A","#529551","#5FA059","#70AB63","#7FB46B","#8EBD73","#9DC57B","#ACCD83","#BDD68C","#CCDE94","#DBE69B"],b=["#FFCDFD","#F7BEF2","#F0B0E8","#E6A0DC","#DE93D2","#D786C8","#CF7ABF","#C76FB5","#BD63AA","#B45AA1","#AB5198","#A1498E","#964184","#883977","#7C326B","#6E2C60","#612654","#542148","#451C3B","#391931","#2F1728","#281521","#22141C","#1D1417","#1A1414","#191612","#191811","#1B1D11","#1D2212","#212913","#253014","#2B3916","#324419","#384D1B","#3F561E","#456021","#4C6924","#547427","#5A7C2A","#60852E","#678E32","#6E9737","#77A33F","#7FAE47","#88BA51","#92C65D","#9CD26B","#A9E27F","#B3EF92","#BEFDA5"],u=["#001261","#011A66","#02226B","#022B71","#023376","#023A7B","#034280","#034A85","#06548B","#0B5D91","#136697","#1E6F9D","#2B79A4","#3C85AC","#4B90B3","#5A9ABA","#6AA4C1","#7AAEC8","#8DBAD0","#9DC4D6","#ADCDDD","#BDD6E3","#CCDFE8","#DEE6E9","#E8E7E5","#EEE3DC","#EEDBD0","#EBD0C0","#E7C6B2","#E3BCA5","#DFB298","#DBA88B","#D69D7C","#D29470","#CE8B64","#CA8258","#C6794C","#C26E3F","#BE6533","#B85C28","#B2511D","#A94512","#9C3709","#912D06","#872406","#7E1D06","#741506","#6A0D07","#620607","#590008"],f=["#4F1A3D","#4B1D43","#48214A","#432653","#3F2C5B","#3C3263","#38396C","#354174","#334B7F","#345487","#365E8F","#3B6797","#42719E","#4D7DA6","#5787AD","#6391B4","#709ABA","#7DA4BF","#8EAEC4","#9BB5C7","#A9BBC8","#B5C0C8","#C0C2C5","#CBC2BF","#D2C0B8","#D6BDAF","#D9B7A6","#D9AF99","#D8A88D","#D6A082","#D39776","#CF8D6B","#C8825D","#C27752","#BB6D47","#B3623D","#AA5633","#9F492A","#953E25","#8C3521","#822C1F","#7A251E","#721F1F","#6B1A21","#661824","#611627","#5C152B","#571631","#531736","#50193C"],w={acton:{discrete:["#260D40","#2B1345","#2F194B","#342152","#382657","#3C2C5C","#403261","#443766","#483E6C","#4C4371","#504876","#544D7B","#57527F","#5D5884","#625C88","#685F8A","#6E618C","#74628D","#7B638D","#81638E","#88648E","#8E648E","#95658F","#9D658F","#A4668F","#AB6690","#B26790","#BB6992","#C26B94","#C86F97","#CD749B","#D07AA0","#D382A7","#D688AC","#D88FB2","#D995B8","#DB9CBD","#DEA4C4","#DFABC9","#E1B1CE","#E3B7D3","#E5BED8","#E6C5DE","#E8CBE2","#E9D0E6","#EBD6EA","#ECDBEE","#EDE1F3","#EFE6F6","#F0EAFA"],categorical:["#260D40","#F0EAFA","#A76690","#DDA1C2","#585380","#7D638E","#E8CAE1","#CF789E","#403261","#4C4371","#ECDBEE","#69608B","#E3B6D2","#D78CB0","#91648F","#BE6A92","#342152","#EAD3E8","#524B79","#73628D","#463A69","#605B86","#E5C0DA","#D382A7","#C86F97","#86648E","#EEE3F4","#DA97B9","#9B658F","#B26790","#2D1749","#E0ACCA","#3A2959","#8B648E","#311C4D","#EBD7EB","#EDDFF1","#AC6790","#A1668F","#6E618C","#E6C5DE","#78628D","#433665","#DEA7C6","#81638E","#554F7C","#B86891","#3D2D5D","#4F4775","#EFE7F7","#E9CEE4","#D27DA3","#2A1244","#655D89","#C36C94","#E1B1CE","#493F6D","#5C5783","#CC739A","#DB9CBD","#D892B4","#D587AB","#96658F","#E4BBD6","#362455","#4E4573","#7F638E","#D37FA5","#E1AECC","#382657","#EBD9ED","#DFA9C8","#A4668F","#8E648E","#99658F","#675F8A","#B56891","#BB6992","#E5BED8","#E2B4D0","#D07AA0","#71618C","#E6C2DC","#AA6690","#625C88","#EDE1F3","#E8CCE3","#AF6790","#CA7199","#C16B93","#453867","#57517E","#84638E","#4B416F","#E7C7DF","#423463","#514977","#3E2F5F","#544D7B","#93658F"]},bam:{discrete:F,categorical:F},bamako:{discrete:["#003B47","#023C46","#053E45","#083F43","#0A4141","#0D4340","#0F443E","#12463C","#16483A","#194A38","#1C4D36","#204F34","#235132","#28542F","#2C572C","#305A2A","#355C27","#395F24","#3F6321","#44661E","#49691A","#4E6D17","#537014","#5A7410","#5F780D","#657C09","#6A7F05","#718302","#788501","#7F8700","#858800","#8C8A00","#948C01","#9B8E04","#A1920B","#A89713","#AE9C1B","#B7A225","#BEA82E","#C5AD37","#CBB341","#D2B84D","#D9BF5B","#DEC567","#E4CA73","#E9D07E","#EFD58A","#F5DB97","#FAE0A3","#FFE5AD"],categorical:["#003B47","#FFE5AD","#61790B","#B4A022","#245231","#406420","#898900","#DDC464","#0F443E","#EFD58A","#CAB23F","#194A38","#748401","#506E16","#9E9108","#315A29","#083F43","#A99815","#948C01","#6A7F05","#BFA930","#7F8700","#14473B","#1E4E35","#F7DD9C","#2A562D","#043D45","#597411","#E6CC77","#385F25","#48691B","#D4BB51","#0B4241","#8F8A00","#44661E","#1B4C37","#547113","#6F8203","#12463D","#998E03","#27542F","#4C6B18","#A4940E","#2E582B","#355C27","#B9A529","#215033","#EAD181","#FBE1A5","#C5AD37","#3C6122","#848800","#063E44","#E2C86E","#D9BF5B","#CFB648","#16493A","#798600","#023C46","#667C08","#5D770E","#0D433F","#AE9C1B","#F3D993","#094042","#A69611","#8C8A00","#053E45","#0C4240","#365E26","#6D8004","#9C8F05","#4A6A1A","#D6BD56","#B19E1F","#F9DFA0","#647B0A","#2F592A","#10453D","#818800","#C7AF3B","#46681C","#0E443F","#265330","#174A39","#335B28","#5B750F","#778501","#5F780D","#E8CF7C","#718302","#F1D78E","#978D02","#F5DB97","#204F34","#AC9A18","#29552E","#A1920B","#B7A225","#033C46"]},bamo:{discrete:E,categorical:E},batlow:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144D62","#165162","#195662","#1C5A62","#205E61","#26635F","#2C665D","#33695A","#3A6C57","#416F53","#4A724E","#52744A","#5A7745","#627941","#6A7B3D","#747E38","#7D8134","#868330","#8F862D","#9B892B","#A58B2C","#AF8D2E","#B98F32","#C29037","#CD923F","#D69446","#DE964F","#E69858","#ED9A62","#F39E70","#F8A17B","#FAA587","#FCA993","#FDAC9E","#FDB1AB","#FDB4B6","#FDB8C0","#FDBCCB","#FCBFD6","#FCC4E3","#FBC8EF","#FACCFA"],categorical:["#011959","#FACCFA","#828231","#226061","#F29D6D","#4D734D","#114360","#C09036","#FDB4B4","#DD954D","#356A59","#FCBFD6","#175262","#677B3E","#A18A2B","#0D315D","#FCA890","#FBC6E8","#2B655E","#B18D2F","#5A7745","#FDAEA2","#CF9340","#0F3B5F","#E9995C","#FDBAC4","#416F53","#91862D","#1B5962","#08255B","#747E38","#134B61","#F9A380","#8A842F","#0E365E","#124761","#154F62","#E39754","#7B8034","#1E5D62","#99882C","#195662","#0B2B5C","#FDB7BC","#C8913B","#FCC3DF","#EE9B64","#A98C2C","#FDB1AB","#FDBCCD","#FBC9F1","#051F5A","#F6A077","#607942","#FDAB9A","#477150","#3B6D56","#B98F32","#26635F","#537549","#D69446","#6D7C3B","#30685C","#103F60","#FBA689","#BD8F34","#CB923E","#EB9A60","#FDB8C0","#FBC7EC","#F09C69","#8E852E","#FDBBC9","#7F8133","#031C5A","#114160","#FDAC9E","#5D7844","#FCA995","#185462","#787F36","#A58B2C","#0A285C","#9D892B","#33695A","#0D335E","#637A40","#165062","#124561","#205E61","#144D62","#1D5B62","#0C2E5D","#D9954A","#3E6E55","#AD8C2D","#F49F72","#868330","#B58E30","#577647"]},batlowk:{discrete:["#04050A","#0A0D15","#0F141E","#121B29","#152233","#18293D","#1C3146","#21384F","#274156","#2C485B","#314E5E","#36535F","#3B575F","#405C5E","#445F5D","#49625B","#4D6558","#526756","#586B52","#5E6E4F","#63724B","#6A7548","#717845","#797D41","#81813E","#8A853B","#938839","#9F8D38","#A99139","#B3943B","#BE973E","#C89A43","#D39D4C","#DB9F54","#E2A15D","#E8A366","#EEA570","#F3A77C","#F6A986","#F8AC91","#FAAE9A","#FCB1A4","#FDB4B0","#FDB7B9","#FDBAC3","#FDBDCD","#FDC1D8","#FCC5E4","#FBC8EF","#FACCFA"],categorical:["#04050A","#FDC0D6","#787C41","#38555F","#E5A160","#536855","#AF933A","#FAAE9A","#1A2E43","#FDB6B7","#294458","#455F5C","#63724B","#CD9B47","#91883A","#F3A77E","#111A27","#F7AB8D","#FDBBC5","#FCB2AA","#D99E52","#A18E38","#4C6459","#21384F","#3F5B5E","#152335","#0C1019","#EEA570","#5B6D50","#6C7647","#314E5E","#85823D","#BE973E","#7E7F3F","#FBB0A2","#49625B","#576A53","#0F151F","#2D495B","#DFA059","#727944","#FDBDCD","#253E54","#EAA368","#C69942","#3C585F","#998B38","#677449","#F1A678","#F9AC92","#141F2F","#1D3248","#506657","#090C13","#A99139","#5F6F4E","#35525F","#435D5D","#FDB8BD","#F5A984","#B5953B","#FDB5B2","#17273B","#D39D4C","#8C853B","#9D8C38","#415C5E","#1F354B","#33505E","#FCB1A6","#101723","#3E595F","#121C2B","#757B43","#06080F","#FCB3AE","#3A565F","#274156","#61704D","#88843C","#2B475A","#FDBED1","#6A7548","#596C51","#192B3F","#6F7845","#233B51","#C99A45","#F0A574","#DC9F55","#2F4B5D","#47615C","#F6AA88","#FDB9C1","#C29840","#4A635A","#FAAD96","#81813E","#7B7E40","#E7A264"]},batloww:{discrete:["#011959","#06215B","#0A285C","#0D315D","#0E375E","#103D5F","#114260","#124761","#144C62","#165062","#185562","#1B5962","#1F5D62","#246261","#2A665F","#30695D","#366C5A","#3D7056","#467352","#4E764E","#56794A","#5E7C46","#667F42","#70823D","#798539","#828936","#8C8C33","#989032","#A29433","#AD9738","#B79B3F","#C19E48","#CBA154","#D3A45E","#D9A669","#DFA872","#E4AA7C","#E9AC88","#EEAF91","#F2B39C","#F6B9A8","#F9C0B5","#FCCAC4","#FED3CF","#FFDBDA","#FFE3E2","#FFEAEA","#FFF2F2","#FFF8F8","#FFFEFE"],categorical:["#FFFEFE","#011959","#7E8737","#205F61","#E7AB84","#497451","#114360","#FED1CD","#BF9D46","#637E44","#9E9233","#FFEAEA","#0D315D","#326B5C","#F5B7A6","#165162","#D7A564","#0F3B5F","#1A5862","#3D7056","#FFF5F5","#FFDFDD","#FAC3BA","#134A61","#08255B","#70823D","#EEB094","#56794A","#E0A874","#8E8D33","#28655F","#AF9839","#CBA154","#EBAD8B","#1D5C62","#051F5A","#124761","#FFE5E4","#B79B3F","#A79535","#386D59","#5C7B47","#185562","#DBA76D","#F8BDAF","#FFF0F0","#246261","#F2B39C","#868A35","#4F774D","#E4AA7C","#2D685E","#77853A","#FED8D6","#103F60","#FFFAF9","#968F32","#D1A35C","#144E62","#FCCAC4","#437254","#698040","#0E365E","#0B2B5C","#C59F4C","#30695D","#1C5A62","#A29433","#407155","#FFDBDA","#0C2E5D","#F7BAAA","#E5AB80","#175362","#828936","#1F5D62","#BB9C42","#E9AC88","#FFF7F7","#3A6E58","#9A9132","#8A8B34","#4C754F","#FFEDED","#D9A669","#144C62","#266460","#FDCDC9","#FCC6BF","#FFE2E1","#FFFCFC","#7B8639","#2B675E","#155062","#5F7C45","#F9C0B5","#356C5A","#F3B5A1","#EDAF8F","#FED5D2"]},berlin:{discrete:e,categorical:e},bilbao:{discrete:["#4C0001","#54070B","#5B0E13","#64161A","#6B1D20","#712227","#77282D","#7D2E34","#84343B","#8A3A41","#8F4047","#94464B","#984C4F","#9B5253","#9D5754","#9E5C56","#A06057","#A16458","#A26959","#A36D5A","#A4715B","#A5745B","#A6785C","#A77C5D","#A8805E","#A9845F","#AA875F","#AC8C60","#AD9061","#AE9463","#AF9864","#B19D68","#B3A36E","#B6A975","#B8AD7E","#BBB287","#BDB590","#C0B99A","#C2BCA3","#C4BFAA","#C6C2B2","#C8C5B9","#CBCAC1","#CFCEC9","#D5D4D1","#DBDBDA","#E3E3E2","#EDEDED","#F6F6F6","#FFFFFF"],categorical:["#4C0001","#F8F8F8","#A9815E","#984D50","#BEB794","#AF9965","#CCCAC3","#78292F","#A26A59","#9F5D56","#64161A","#B6AA77","#C4C0AC","#A6765C","#8A3A41","#AC8C60","#DDDDDB","#A16358","#C7C5B7","#B3A16B","#A4705A","#6E2024","#EAEAE9","#92434A","#BAB185","#9C5554","#AD9262","#580B10","#813137","#C1BCA1","#AA865F","#D2D2CE","#A77C5D","#D7D7D4","#BCB48D","#B4A571","#C0B99A","#9E5955","#AB8960","#A6795C","#A36D5A","#8E3F46","#85353C","#A16758","#732529","#CAC7BD","#F1F1F0","#520509","#AC8F61","#5E1115","#C6C2B2","#E3E3E2","#691B1F","#B8AD7E","#95484D","#AE9663","#B19D68","#A5735B","#A06057","#9A5152","#A87E5D","#7D2E34","#A9835E","#C3BEA6","#CFCEC9","#A46E5A","#F4F4F4","#DADAD8","#B29F69","#EDEDED","#BBB289","#9D5754","#AF9764","#904148","#994F51","#B3A36E","#A87F5E","#A26859","#AC8D61","#BDB590","#AA875F","#A77A5D","#AB8A60","#A4715B","#611418","#BFB897","#E6E6E6","#9B5353","#D5D4D1","#974A4F","#C8C6BA","#A16558","#9F5E56","#76272C","#67191D","#8C3C43","#B9AF82","#C3BFA9","#B5A874","#4F0205"]},broc:{discrete:a,categorical:a},broco:{discrete:c,categorical:c},buda:{discrete:["#B301B3","#B30BAE","#B314AA","#B31CA6","#B323A2","#B3289F","#B32E9D","#B4339A","#B53998","#B63E96","#B84394","#B94892","#BB4C91","#BD528F","#BE568D","#C05B8C","#C15F8A","#C36389","#C46987","#C66D86","#C77184","#C97583","#CA7982","#CB7E80","#CD837F","#CE877E","#CF8B7D","#D0917B","#D1957A","#D29979","#D49E78","#D5A277","#D6A776","#D7AC75","#D8B073","#D9B572","#DAB971","#DCBF70","#DDC36F","#DEC86E","#DFCC6C","#E0D16B","#E2D76A","#E4DC69","#E6E168","#E9E667","#EDEC67","#F3F366","#F9F966","#FFFF66"],categorical:["#B301B3","#FFFF66","#CD857E","#BC4E90","#DBBD70","#C56A87","#B32F9C","#E3DB69","#D4A177","#EDEC67","#D1937B","#B73F95","#C05C8B","#DFCB6D","#C97882","#B31CA6","#D8AE74","#E7E368","#DAB572","#B311AC","#D39A79","#C36389","#C77184","#B53798","#E1D36B","#BE558E","#B94793","#CB7E80","#CF8C7C","#DDC46E","#B326A0","#F6F566","#D6A875","#DAB971","#C66E86","#E2D76A","#B32B9E","#B317A9","#B4339A","#BA4B91","#C46788","#C2608A","#B309AF","#D49E78","#B63B97","#BD528F","#DCC06F","#EAE767","#FAFA66","#D2977A","#F1F066","#D0907C","#CE897D","#C87483","#CC827F","#D5A576","#B321A3","#E5DF68","#B84394","#D9B273","#E0CF6C","#CA7B81","#DEC86E","#BF598C","#D7AB75","#E6E168","#D1957A","#CC8080","#D39C78","#E0CD6C","#CD847F","#B63D96","#C87384","#C66C86","#F8F866","#D49F78","#D9B473","#DAB772","#BF578D","#CB7D81","#CF8A7D","#B32D9D","#D08E7C","#DBBB71","#C2628A","#E2D56A","#DCBF70","#BC508F","#C46987","#C05B8C","#DFCA6D","#DDC26F","#C15E8B","#D7AD74","#F3F366","#DEC66E","#D5A377","#B31AA7","#BA4992","#CE877E"]},bukavu:{discrete:t,categorical:t},cork:{discrete:r,categorical:r},corko:{discrete:i,categorical:i},davos:{discrete:["#00054A","#010E51","#041459","#081C61","#0C2368","#102A6F","#133075","#17377C","#1C3F83","#204588","#244C8D","#295291","#2D5895","#335F98","#38649A","#3C699C","#416E9D","#46729D","#4C779D","#517B9C","#567F9B","#5A829A","#5F8598","#658996","#698C94","#6E8F92","#739290","#78968D","#7D998C","#829D8A","#88A089","#8DA488","#95AA87","#9BAF88","#A3B489","#ABBB8C","#B4C190","#BFCA96","#C9D29E","#D2D9A6","#DBE0AF","#E3E7B8","#EBEDC4","#F0F1CD","#F4F4D6","#F7F7DE","#FAF9E6","#FCFCF0","#FDFDF7","#FEFEFE"],categorical:["#00054A","#FDFDF4","#688B94","#2D5895","#B2C08F","#E8EBC0","#87A089","#133075","#4B769D","#5A829A","#204588","#76958E","#D0D8A4","#99AD88","#F6F6DB","#3C699C","#081C61","#031256","#1A3B7F","#537C9C","#A4B68A","#C1CC98","#7E9A8B","#FAFAE8","#356199","#0E266B","#DEE3B3","#274F90","#6F9091","#618697","#8FA588","#F0F1CD","#43709D","#1D4084","#47739D","#F3F4D4","#658996","#567F9B","#17367A","#FCFBEE","#4F799D","#C9D29E","#93A987","#39659B","#D8DEAB","#ABBB8C","#739290","#B9C693","#F8F8E1","#234A8C","#112B70","#7A978D","#9EB188","#315C97","#829D8A","#05175B","#010C50","#3F6C9D","#0B2065","#5D8499","#2A5392","#8BA388","#6B8D93","#EDEFC7","#E3E7B8","#22488A","#638897","#122E73","#00094D","#AEBD8D","#4D789D","#CDD5A1","#5F8598","#58819A","#071A5E","#0C2368","#18387D","#91A787","#37639A","#EBEDC4","#F2F2D0","#FBFBEB","#74938F","#2F5A96","#335F98","#809B8B","#BDC995","#49759D","#719191","#9BAF88","#F7F7DE","#1B3E82","#A8B88B","#849E89","#557E9B","#E6E9BC","#45719D","#1E4386","#96AB87","#89A188"]},devon:{discrete:["#2C1A4C","#2B1E51","#2B2356","#2A295B","#2A2D60","#293265","#29376A","#283B6E","#274174","#27467A","#274C7F","#275186","#28568C","#2A5C95","#2D609C","#3064A3","#3468AA","#396BB1","#3F70B9","#4774C0","#4F79C6","#597DCC","#6382D1","#6F88D7","#798CDB","#8290DF","#8C95E2","#969AE6","#9E9EE9","#A6A3EB","#ACA7ED","#B1ACEF","#B7B1F0","#BBB5F1","#BFB9F2","#C3BEF3","#C7C2F4","#CCC7F4","#D0CCF5","#D4D0F6","#D8D4F7","#DCD9F8","#E1DEF9","#E5E3FA","#E9E7FB","#EDECFB","#F2F0FC","#F7F6FD","#FBFAFE","#FFFFFF"],categorical:["#2C1A4C","#F8F8FE","#758AD9","#C6C0F3","#28568C","#29376A","#AAA5ED","#DEDCF8","#3D6EB7","#EBE9FB","#9197E4","#3063A2","#274579","#577CCB","#D2CEF6","#2A285A","#BAB3F1","#B2ADEF","#F2F0FC","#274E82","#2A2F62","#CCC7F4","#9E9EE9","#4875C1","#C0BAF2","#2B5D98","#3669AD","#2B2154","#E4E2FA","#8290DF","#D8D4F7","#6784D3","#283E71","#C9C4F4","#BDB7F1","#DBD8F8","#283A6D","#4F79C6","#A4A2EB","#EEEDFC","#CFCBF5","#E8E5FA","#5F80CF","#4272BC","#B6B0F0","#2B1D50","#AEA9EE","#275287","#2A2B5E","#989BE7","#293366","#27497D","#8A94E1","#295A92","#3266A7","#F5F4FD","#7B8DDC","#274174","#2D609C","#2B2558","#6F88D7","#E1DEF9","#3A6CB2","#D5D1F6","#C3BEF3","#2E629F","#3165A4","#8D95E3","#3468AA","#DAD6F7","#D1CDF5","#9B9CE8","#275084","#B8B2F0","#27477B","#6382D1","#4573BF","#A2A0EA","#F7F6FD","#C7C2F4","#F3F2FD","#274376","#8692E0","#2B1F52","#CAC6F4","#ACA7ED","#E3E0F9","#F0EEFC","#E6E4FA","#386AB0","#2C1C4E","#6B86D5","#28396B","#283C6F","#2A5C95","#2A2D60","#BEB9F2","#C2BCF2","#7E8FDD","#3F70B9"]},fes:{discrete:o,categorical:o},glasgow:{discrete:["#361338","#3B1434","#401530","#45172C","#491828","#4D1924","#511B21","#561C1D","#5B1E18","#602014","#662210","#6B260B","#6F2B07","#723203","#743802","#743E01","#754300","#744900","#744F01","#745402","#735905","#725F0B","#716413","#70691E","#6E6E27","#6C7231","#6B763A","#697B46","#677F4F","#658359","#648763","#628B6C","#618F78","#609381","#60978A","#619B94","#659F9D","#6CA5A8","#74A9B0","#7DADB8","#86B1BF","#8EB4C6","#99B9CE","#A1BCD5","#AABFDB","#B2C3E1","#BBC6E7","#C6CBF0","#D0CFF7","#DBD3FF"],categorical:["#361338","#DBD3FF","#6D702B","#69A3A5","#702D06","#A0BBD3","#638968","#521B20","#745101","#84B0BE","#754001","#5F9587","#BBC6E7","#612013","#45172C","#687D4A","#726210","#618F78","#4B1926","#3E1532","#629C96","#658359","#CACCF3","#76AAB2","#6B763A","#744900","#6A250C","#ADC1DD","#735905","#92B6C9","#591D1A","#743702","#70681C","#4F1A23","#754400","#6D2909","#60998E","#41162F","#744D00","#745503","#B4C3E2","#697A42","#7DADB8","#628C70","#8BB3C3","#561C1D","#D2D0F9","#99B9CE","#3A1435","#6F6C23","#743B01","#60927F","#662210","#648661","#659F9D","#678051","#725E0A","#481829","#6FA6AB","#6C7332","#5D1E17","#A6BED8","#C2C9ED","#723203","#716617","#68240E","#6F6A20","#C6CBF0","#79ABB5","#72600D","#754200","#43162D","#67A1A1","#6B7536","#5F1F15","#735B07","#571C1B","#72A8AF","#744F01","#BEC8EA","#381337","#8EB4C6","#628B6C","#677E4D","#60917B","#639E9A","#4A1827","#A3BDD6","#3C1433","#743901","#632112","#B7C5E5","#4D1924","#65845D","#618E74","#609483","#9CBAD1","#46172A","#87B1C1","#6D712F"]},grayc:{discrete:["#000000","#090909","#111111","#171717","#1C1C1C","#212121","#252525","#2A2A2A","#303030","#343434","#393939","#3D3D3D","#424242","#474747","#4B4B4B","#505050","#545454","#585858","#5D5D5D","#616161","#656565","#696969","#6D6D6D","#717171","#757575","#797979","#7D7D7D","#818181","#858585","#898989","#8E8E8E","#929292","#979797","#9C9C9C","#A1A1A1","#A6A6A6","#ABABAB","#B1B1B1","#B6B6B6","#BCBCBC","#C1C1C1","#C7C7C7","#CECECE","#D5D5D5","#DBDBDB","#E2E2E2","#E8E8E8","#F1F1F1","#F8F8F8","#FFFFFF"],categorical:["#070707","#F9F9F9","#777777","#454545","#AEAEAE","#909090","#292929","#5F5F5F","#D1D1D1","#9E9E9E","#525252","#E4E4E4","#6C6C6C","#BFBFBF","#1A1A1A","#373737","#848484","#595959","#222222","#B6B6B6","#A6A6A6","#3E3E3E","#7D7D7D","#666666","#969696","#8A8A8A","#4B4B4B","#DADADA","#C8C8C8","#313131","#717171","#131313","#EFEFEF","#C4C4C4","#A2A2A2","#424242","#878787","#252525","#2D2D2D","#4F4F4F","#3B3B3B","#808080","#1E1E1E","#BBBBBB","#AAAAAA","#EAEAEA","#696969","#7A7A7A","#DFDFDF","#636363","#565656","#B2B2B2","#0E0E0E","#9A9A9A","#5C5C5C","#747474","#F3F3F3","#333333","#6E6E6E","#D5D5D5","#8D8D8D","#939393","#494949","#CCCCCC","#171717","#BDBDBD","#575757","#C1C1C1","#404040","#828282","#E2E2E2","#151515","#1C1C1C","#0B0B0B","#9C9C9C","#858585","#2F2F2F","#B4B4B4","#888888","#242424","#272727","#3C3C3C","#B0B0B0","#353535","#545454","#5B5B5B","#393939","#D7D7D7","#A4A4A4","#A8A8A8","#959595","#767676","#646464","#989898","#444444","#474747","#111111","#F6F6F6","#ECECEC","#4D4D4D"]},hawaii:{discrete:["#8C0273","#8E0D6E","#8F1569","#901D63","#91235F","#91285A","#922D56","#933252","#94384D","#943D4A","#954246","#964742","#964C3F","#97523B","#985638","#985C34","#996131","#9A662E","#9B6C2A","#9B7226","#9C7823","#9C7E20","#9D841E","#9D8C1C","#9C921C","#9B991D","#9AA021","#97A828","#94AE30","#91B439","#8CB942","#88BE4C","#82C359","#7EC663","#79CA6E","#74CE79","#70D183","#6AD591","#66D89C","#62DCA7","#60DFB2","#5FE2BD","#61E6CA","#67E9D5","#6FEBDE","#7AEEE7","#87EFEE","#98F1F5","#A6F1F9","#B3F2FD"],categorical:["#8C0273","#B3F2FD","#9C951C","#6CD48C","#964D3E","#8ABC48","#9B6D29","#66E8D3","#922E55","#9C801F","#87EFEE","#995D34","#7BC969","#901D63","#60DEB0","#96AA2B","#943D4A","#975439","#82C359","#5FE4C2","#9AA021","#73CE7B","#65D99E","#954544","#9D8A1C","#8E126B","#91B439","#9DF1F7","#73ECE2","#91265C","#9C7724","#9A652E","#93364F","#922A59","#996131","#9D851D","#9D901C","#9A692C","#68D695","#902160","#9B9A1E","#985836","#9B7226","#933252","#77CC72","#9C7B21","#954147","#8D0A6F","#93AF32","#62DCA7","#92F0F3","#8F1867","#7DEEE8","#97513C","#6CEBDB","#61E6CA","#A8F2FA","#964941","#7FC661","#86BF50","#98A526","#70D183","#5FE1B9","#8DB840","#94394D","#9C7923","#8F1569","#985A35","#60E0B4","#9A6B2A","#91245E","#97A828","#9B7425","#6AD591","#95AD2E","#5FE2BD","#60E5C6","#953F48","#933054","#63E7CF","#84C154","#8D0671","#82EFEB","#9B9D1F","#99A323","#88BE4C","#6ED288","#6FEBDE","#9A672D","#91285A","#75CD76","#995F32","#68E9D7","#9B7028","#61DDAB","#943B4B","#933450","#8DF0F0","#8F1A65","#81C45D"]},imola:{discrete:["#1A33B3","#1C37B1","#1E3AAF","#203EAD","#2242AB","#2345AA","#2548A8","#274CA6","#2950A4","#2A53A3","#2C56A1","#2E599F","#2F5D9E","#32609B","#346499","#366797","#386A95","#3B6C92","#3E708F","#41738C","#44768A","#467987","#4A7C85","#4E8082","#518480","#56887E","#5A8C7D","#5F927B","#64967A","#689B79","#6DA078","#72A576","#78AB75","#7DB074","#82B572","#87BA71","#8CBF70","#93C66E","#98CB6D","#9ED06C","#A4D66A","#ACDB69","#B5E268","#BFE767","#C8EB67","#D3F066","#DDF466","#EAF866","#F5FB66","#FFFF66"],categorical:["#1A33B3","#FFFF66","#54867F","#305E9D","#91C36F","#3F718E","#2549A8","#BDE667","#70A377","#2B53A2","#376896","#80B373","#A3D56B","#DDF466","#203EAD","#487B86","#62947A","#2D59A0","#88BB71","#5B8D7D","#CDED66","#4E8082","#EEF966","#33639A","#284EA5","#44768A","#2344AA","#AFDE69","#3B6C92","#78AB75","#1D39B0","#99CC6D","#699C79","#3D6F90","#2C56A1","#2F5B9E","#5E917B","#4B7D84","#9ED06C","#1F3CAE","#C4EA67","#84B772","#274CA6","#D5F066","#2951A4","#74A776","#578A7E","#2446A9","#1C36B1","#A9D96A","#95C86E","#467888","#2141AC","#7CAF74","#356598","#B5E268","#66987A","#396A94","#F7FC66","#8CBF70","#E6F666","#32609B","#518380","#41738C","#6DA078","#6B9E78","#B9E468","#7AAD74","#528580","#32629B","#86B971","#3C6E91","#5C8F7C","#C8EB67","#ACDB69","#D1EF66","#E2F566","#97CA6D","#1B35B2","#1C37B0","#2345AA","#2F5D9E","#1F3DAE","#457789","#3A6B93","#598B7D","#D9F266","#346499","#386995","#A6D76A","#366797","#274DA6","#56887E","#A1D36B","#42748B","#7EB173","#72A576","#477987","#4C7F83","#F2FB66"]},lajolla:{discrete:["#191900","#1E1B02","#221C05","#271E08","#2C200B","#31220E","#362411","#3C2614","#442817","#4B2B1B","#532D1F","#5B3023","#633328","#6E362D","#783932","#813C37","#8B3F3B","#96423F","#A24543","#AD4746","#B74A48","#C04D49","#C9514B","#D1564C","#D75C4D","#DB634E","#DD694F","#E0714F","#E17750","#E37D50","#E48351","#E58951","#E79052","#E89652","#E99C52","#EAA253","#EBA853","#EDAF54","#EEB555","#F0BC57","#F1C25A","#F3CA5F","#F5D369","#F7DA74","#F9E282","#FBE890","#FCEF9F","#FDF5B0","#FEFABE","#FFFECB"],categorical:["#191900","#FFFECB","#D85F4D","#ECAC54","#653329","#F7D971","#A44544","#E58751","#362411","#E1744F","#C44E4A","#E99A52","#4B2B1B","#833D38","#F1C159","#FCEF9F","#271E08","#FEF7B6","#402716","#D0554C","#FAE587","#E79052","#EFB655","#B54947","#201C04","#E37D50","#743830","#DD694F","#EBA353","#94413E","#572F21","#F4CD61","#2E210C","#FDF3AB","#32220F","#241D06","#F5D369","#7B3B34","#1D1B02","#F0BC57","#5E3125","#F8DF7C","#512D1E","#CA514B","#E48251","#E68C51","#EA9E53","#E89552","#BC4C49","#6C362C","#EDB154","#9C4341","#E27950","#FBEA93","#3B2513","#FEFBC0","#452918","#EBA853","#F2C75C","#8B3F3B","#DB644E","#AD4746","#DF6E4F","#D55A4D","#2B200A","#783932","#E79352","#D75C4D","#FEF9BB","#EDAF54","#E0714F","#7F3C36","#613227","#F7DC77","#C7504B","#F1C45A","#30210D","#F4D065","#1E1B03","#FAE78D","#F9E282","#DA614E","#392412","#4E2C1D","#E99C52","#EFB956","#221C05","#EBA553","#FDF5B0","#984240","#E38050","#8F403D","#542E20","#ECAA54","#E68E51","#70372E","#DE6C4F","#B94A48","#291F09","#1B1A01"]},lapaz:{discrete:["#1A0C64","#1C1368","#1E196D","#202071","#212675","#222B79","#23317D","#253681","#263C85","#274189","#29478C","#2A4C8F","#2C5192","#2E5795","#305C98","#32609A","#35659C","#386A9E","#3C70A0","#3F74A1","#4379A2","#487DA3","#4D81A3","#5386A4","#588AA3","#5E8EA3","#6591A2","#6C95A1","#7398A0","#7A9A9E","#809D9D","#879F9B","#90A199","#97A397","#9EA596","#A5A795","#ADAA95","#B7AD96","#BFB199","#C8B69C","#D2BBA2","#DAC1A8","#E4C9B2","#EBCFBB","#F1D5C4","#F5DBCD","#F9E1D6","#FBE8E1","#FDEDEA","#FEF2F3"],categorical:["#1A0C64","#FEF2F3","#5B8BA3","#B3AC96","#2C5292","#3C70A0","#EACEB9","#859E9C","#24327E","#6F96A1","#33619A","#202071","#D0BAA0","#9BA496","#F9E1D6","#4A7FA3","#284289","#90A199","#FCEAE5","#1D176B","#37699D","#F3D8C8","#A7A895","#5285A4","#7A9A9E","#2F5A97","#4278A2","#263A84","#6591A2","#C1B299","#DEC3AB","#222978","#2A4B8E","#5688A4","#D7BEA6","#FDEEEC","#608EA3","#EFD3C0","#A1A696","#6A94A1","#FBE6DD","#ADAA95","#F6DDCF","#4E82A3","#2E5695","#3A6D9F","#C8B69C","#1C1268","#232D7B","#3F74A1","#467BA3","#1E1C6E","#7F9C9D","#BAAF97","#253681","#315E99","#29478C","#E4C9B2","#74989F","#273E87","#212575","#95A398","#8AA09A","#35659C","#2B4F91","#23307C","#E7CBB5","#F1D5C4","#2B4D90","#202373","#588AA3","#D3BCA3","#5487A4","#447AA2","#6792A2","#24347F","#253882","#ECD0BD","#879F9B","#305C98","#E1C6AF","#1E196D","#5D8DA3","#AAA995","#386B9E","#487DA3","#77999F","#F7DFD3","#BEB098","#1F1E70","#325F99","#4176A2","#F4DACB","#4C80A3","#2D5494","#8DA099","#6C95A1","#FAE3DA","#FDECE8","#B7AD96"]},lipari:{discrete:["#031326","#05192F","#062038","#092844","#0C2E4D","#103557","#163C5F","#1E4368","#294B70","#345075","#3E5578","#47587A","#4F5B7B","#575C7A","#5D5D79","#635E78","#695E76","#6E5F75","#765F73","#7C6071","#826070","#89606E","#90616C","#98616A","#A06268","#A86266","#B06364","#BA6462","#C36660","#CB685F","#D46B5E","#DB705F","#E27760","#E77E63","#E98567","#EA8D6B","#EA946F","#E89C75","#E7A279","#E6A87E","#E5AF84","#E5B58A","#E6BD92","#E7C49A","#EACCA3","#EDD3AD","#F0DBB7","#F5E5C4","#F9EDCF","#FDF5DA"],categorical:["#031326","#FDF5DA","#A56267","#525B7A","#E99B74","#785F72","#DA6F5E","#183E61","#E7C398","#8D616D","#365176","#092844","#655E77","#E98466","#BF6561","#F0DBB7","#E5AD82","#B26364","#EBCFA7","#5C5D79","#061D35","#25486D","#0E3353","#EA906D","#98616A","#E37861","#E5B88C","#826070","#CD685F","#6E5F75","#45587A","#F6E8C9","#E7A37A","#615E78","#E77E63","#D46B5E","#9F6268","#E99570","#93616B","#87606E","#7D6071","#F3E1C0","#575C7A","#0B2D4B","#2D4D72","#E6A87E","#E9C99F","#FAEED1","#1E4368","#EA8A69","#B86462","#6A5E76","#AB6365","#735F74","#DF735F","#E5B287","#13385A","#05182D","#E6BD92","#3E5578","#EDD5AF","#07223C","#C6665F","#4C5A7A","#E8A077","#B56363","#FBF1D6","#A26267","#E6C095","#0A2A48","#F8EBCD","#EACCA3","#AE6364","#7A5F72","#635E78","#E98768","#041629","#715F74","#ECD2AB","#A86266","#8A606E","#96616B","#545C7A","#EFD8B3","#F5E5C4","#9B6169","#F2DEBB","#765F73","#6C5F75","#294B70","#22466B","#E89D76","#E88165","#BC6461","#E6A67C","#85606F","#C36660","#1B4064","#D06A5E","#103557"]},lisbon:{discrete:l,categorical:l},managua:{discrete:s,categorical:s},navia:{discrete:["#031327","#041930","#051E3A","#052546","#062B50","#06315A","#073764","#083E6D","#0B4578","#0E4C80","#115286","#15588B","#195E8E","#1E6491","#216991","#246D91","#27718F","#2A748E","#2D788C","#307A8A","#337D89","#368087","#398385","#3C8683","#3F8981","#428C7F","#468F7D","#4A937A","#4E9678","#529A76","#579E73","#5BA271","#62A86E","#67AD6B","#6EB269","#76B768","#7FBD68","#8CC56A","#98CB6F","#A4D176","#B1D67F","#BCDB89","#C9E096","#D3E3A1","#DCE7AC","#E3EAB6","#EAEDBF","#F1F0CA","#F7F2D2","#FCF4D9"],categorical:["#031327","#FCF4D9","#408A80","#87C269","#1B608F","#59A072","#073966","#D1E39F","#2F798B","#EAEDBF","#052546","#266F90","#6BB06A","#0E4D81","#AED57D","#4C947A","#378186","#DFE8B0","#337D89","#2A748E","#14578A","#051C36","#9ACC70","#0A4374","#468F7D","#529A76","#F4F1CD","#062F56","#C1DC8D","#206891","#78B968","#62A86E","#3C8583","#569D74","#236C91","#F8F3D3","#D8E5A8","#0C487B","#04182E","#71B469","#B8D985","#07345E","#05213E","#4F9778","#5DA470","#3E8882","#062A4E","#7FBD68","#EFEFC6","#C9E096","#115286","#2C768D","#1E6491","#49917B","#66AC6C","#28718F","#A4D176","#90C76C","#438C7F","#175C8D","#083E6D","#E5EAB8","#317B8A","#357F87","#398385","#B3D781","#0D4A7E","#1C6290","#052342","#579F73","#9FCE73","#448D7E","#051A32","#FAF3D6","#428B7F","#29738F","#104F84","#5FA66F","#509877","#8CC56A","#094071","#2D788C","#083B6A","#D5E4A3","#2B758D","#226A91","#04162B","#BCDB89","#47907C","#4D9579","#E2E9B4","#7BBB68","#6EB269","#135488","#4A937A","#F1F0CA","#5BA271","#C5DE92","#F6F2D0","#CDE19B"]},naviaw:{discrete:["#041427","#051A31","#05203B","#062747","#072D52","#08345C","#0A3A66","#0C416F","#0F4979","#135080","#175686","#1B5D8A","#1F628D","#23698F","#276D8F","#2A728F","#2D758E","#30798D","#347D8B","#378089","#3A8388","#3D8686","#408984","#448C82","#489080","#4B937E","#50977C","#559C79","#5AA077","#5FA575","#65AA73","#6CAF71","#76B671","#7FBD71","#89C474","#95CB78","#A2D27F","#B1D98A","#BEDF95","#C9E5A1","#D3E9AD","#DBEDB9","#E4F1C6","#E9F4D0","#EEF6D9","#F2F8E1","#F6FAE9","#F9FCF1","#FCFDF7","#FEFEFD"],categorical:["#041427","#FBFDF6","#478F80","#9FD07D","#1F628D","#64A973","#E3F0C4","#0A3A66","#337C8B","#C7E49E","#7DBC71","#549B7A","#2A718F","#135080","#F2F8E1","#3C8586","#062747","#D7EBB2","#418A83","#B4DB8C","#2E778D","#6FB271","#EBF5D4","#0E4574","#051D37","#4D957D","#256B8F","#195A88","#388189","#F7FAEC","#5CA276","#8CC574","#073056","#31798C","#367E8A","#69AD72","#E7F3CC","#104A7A","#95CB78","#EFF6DB","#0B406D","#2C748E","#4A927F","#DDEEBB","#50987C","#165584","#589E78","#76B671","#3F8785","#05192F","#BEDF95","#448C82","#22678E","#06223F","#A9D684","#08355E","#CFE8A8","#F9FCF1","#286E8F","#85C172","#072C50","#F5F9E7","#1C5F8B","#3A8387","#60A675","#F3F9E4","#0C4271","#266D8F","#81BE72","#0A3D6A","#4B937E","#9ACD7B","#EDF5D7","#90C876","#A4D381","#378089","#1B5D8A","#489080","#145282","#DAECB6","#67AB73","#CBE6A3","#B9DD90","#3D8686","#23698F","#6CAF71","#FAFCF3","#79B971","#D3E9AD","#5AA077","#458E81","#72B471","#327B8C","#E5F1C8","#051B33","#F8FBEE","#062443","#398288","#2B728F","#06294C"]},nuuk:{discrete:["#05598C","#0E5B8B","#155C89","#1C5E87","#226085","#276184","#2C6383","#326682","#386982","#3E6C82","#446F82","#4A7283","#517584","#587A86","#5F7D88","#66818A","#6C858C","#73898E","#7B8E91","#819192","#879594","#8D9996","#939C97","#99A097","#9EA498","#A2A798","#A6AA97","#ABAD96","#AEAF95","#B1B194","#B3B492","#B6B690","#B8B88E","#BABA8C","#BDBC8A","#BFBE88","#C1C187","#C4C385","#C7C684","#CAC983","#CDCD83","#D2D184","#D7D787","#DDDD8B","#E3E290","#E8E895","#EEEE9C","#F4F4A4","#F9F9AB","#FEFEB2"],categorical:["#05598C","#FEFEB2","#A1A698","#537785","#C3C385","#B5B591","#7D8F91","#2D6483","#DDDD8B","#919B96","#BCBC8B","#3F6C82","#CDCD83","#1C5E87","#ADAE95","#68838B","#EEEE9C","#A7AA97","#879594","#C8C783","#F6F6A7","#135C89","#B9B98E","#497183","#73898E","#366882","#C0BF88","#D4D486","#99A097","#B1B293","#5E7D88","#256185","#E6E693","#829293","#788C90","#9DA398","#AAAC96","#E1E18F","#3B6A82","#638089","#B3B492","#A4A897","#446F82","#BABA8C","#D8D888","#185D88","#8C9895","#215F86","#BEBD89","#B7B78F","#CACA83","#4E7484","#C1C186","#959E97","#F2F2A1","#AFB094","#326682","#587A86","#296284","#FAFAAD","#6E868C","#C5C584","#D1D084","#0D5B8B","#E9E997","#DFDF8D","#66818A","#B0B194","#5B7B87","#2B6383","#859493","#CCCB83","#F8F8AA","#D2D285","#1F5F86","#70878D","#4B7383","#768B8F","#FCFCAF","#A9AB97","#BFBE88","#C9C983","#346782","#DBDA89","#236085","#BDBD8A","#BAB98D","#B8B88E","#2F6583","#939C97","#9FA498","#A2A798","#CFCF84","#B4B591","#C4C485","#979F97","#F0F09E","#155C89","#9BA298","#517584"]},oleron:{discrete:n,categorical:n},oslo:{discrete:["#010101","#04070B","#060C13","#0A121B","#0C1620","#0D1927","#0E1D2D","#0F2133","#10263C","#112A43","#122E4A","#133251","#153758","#173C61","#194169","#1B4670","#1E4A78","#214F80","#255589","#295A91","#2E5F99","#3364A1","#3A6AA9","#4371B2","#4B77B9","#537DBE","#5B83C3","#6489C6","#6B8EC8","#7292C9","#7896C9","#7E9ACA","#859ECA","#8BA2C9","#91A6C9","#97A9C9","#9DADC9","#A4B2CA","#AAB6CA","#B1BBCB","#B8BFCD","#BFC5CF","#C7CCD3","#CFD2D8","#D7D9DD","#DEE0E2","#E6E7E9","#EFF0F1","#F7F7F8","#FFFFFF"],categorical:["#030609","#F9F9F9","#507BBC","#163B5E","#A0AFC9","#7B98CA","#27588E","#0E2032","#CACED5","#122D48","#3767A6","#1D4875","#8DA3C9","#E2E3E5","#678BC7","#B4BDCC","#0C151F","#BFC5CF","#97A9C9","#4371B2","#10263D","#080E16","#7292C9","#215081","#2E5F99","#AAB6CA","#ECEDEE","#0D1A28","#143454","#D5D8DC","#5B83C3","#19426A","#859ECA","#13314E","#0E1D2D","#3D6CAC","#6C8FC8","#7795C9","#F3F3F4","#4976B8","#245488","#DBDDE0","#112A43","#92A6C9","#C5C9D2","#809BCA","#0F2337","#3263A0","#050A10","#B9C1CD","#1F4C7B","#183E64","#A5B3CA","#0A121B","#9CACC9","#6187C5","#0D1824","#8AA1CA","#2A5B93","#547EBF","#D1D3D9","#E6E7E9","#1B456F","#B0BACB","#153758","#7494C9","#D8DADE","#6A8DC8","#90A5C9","#99ABC9","#235285","#133251","#060C13","#406EAF","#7E9ACA","#173C61","#4C78BA","#122F4B","#1C4772","#87A0CA","#CED1D7","#C2C7D1","#0F253A","#2C5D96","#C7CCD3","#112B45","#EFF0F1","#6F90C9","#0E1E2F","#ADB8CB","#7997CA","#4673B5","#15395B","#091018","#194067","#30619C","#94A8C9","#F6F6F6","#0F2135","#A3B1CA"]},roma:{discrete:d,categorical:d},romao:{discrete:g,categorical:g},tofino:{discrete:m,categorical:m},tokyo:{discrete:["#1C0E34","#241036","#2D1339","#37163D","#3F1A40","#481E43","#4F2345","#562948","#5D304A","#62354C","#663B4D","#69404E","#6B454F","#6D4B50","#6E4F50","#6F5251","#6F5651","#705951","#715C52","#715F52","#716252","#726452","#726753","#736B53","#736E53","#747153","#757554","#757A54","#767E55","#778355","#788856","#798E57","#7B9558","#7C9B5A","#7EA25C","#81A95E","#84B062","#88B968","#8DC16E","#93CA76","#9BD27F","#A4DA8A","#AFE398","#BAEAA4","#C5EFB0","#CFF4BB","#D8F7C5","#E2F9CF","#E9FBD7","#EFFCDD"],categorical:["#1C0E34","#EFFCDD","#747053","#6C4750","#87B666","#B8E8A1","#512446","#715D52","#798B56","#7D9F5B","#37163D","#726653","#99D07D","#63374C","#6F5451","#D8F7C5","#767C54","#705951","#5B2D49","#7B9558","#441D41","#291238","#E5FAD2","#C9F1B4","#716252","#81AA5F","#683F4E","#736B53","#6E4E50","#757654","#8EC370","#A7DD8E","#778455","#747354","#84B062","#231036","#93CA76","#DFF9CC","#30143A","#A0D785","#7FA45D","#EAFBD8","#6A434F","#C1EDAB","#736D53","#562948","#6D4B50","#7A9057","#7C9A59","#4B2044","#715F52","#663B4D","#D1F4BD","#705651","#8ABD6A","#6E5151","#AFE398","#5F324B","#757954","#3E193F","#726853","#726452","#778055","#705B52","#788756","#61344C","#746E53","#ABE093","#532747","#85B364","#7EA25C","#261137","#736C53","#E8FBD5","#4E2245","#88B968","#798E57","#767E55","#726753","#757754","#715E52","#3A183E","#6E4F51","#778255","#7B9759","#DCF8C9","#EDFCDA","#411B40","#7D9C5A","#767B54","#726352","#6F5551","#726552","#82AD60","#D5F6C1","#34153C","#9CD481","#747454","#C5EFB0","#481E43"]},turku:{discrete:["#000000","#090908","#111110","#181816","#1D1D1A","#22221F","#272723","#2C2C27","#33322B","#38382F","#3D3D32","#424235","#474738","#4E4D3C","#53523E","#585841","#5D5D43","#626246","#686848","#6E6D4B","#73724D","#797750","#7F7D52","#878356","#8E8859","#968E5C","#9D9360","#A79864","#AF9C68","#B69F6C","#BEA270","#C4A474","#CCA579","#D1A67D","#D7A781","#DBA886","#E0A98B","#E6AB92","#EAAD98","#EFB09F","#F2B4A7","#F6B9AE","#F9BFB7","#FBC4BF","#FDC9C6","#FECFCC","#FED4D3","#FFDBDA","#FFE0E0","#FFE6E6"],categorical:["#070707","#FFE6E6","#948D5B","#E5AA90","#4D4C3B","#2C2C27","#C3A374","#6D6C4A","#FBC4BF","#D6A780","#F2B4A7","#1C1C19","#3D3D32","#AC9A67","#7E7C52","#FED6D4","#5D5D43","#35342D","#DDA888","#141312","#55543F","#242420","#FDCDCA","#F7BCB3","#898456","#B8A06D","#ECAE9B","#CDA57A","#FFDEDD","#646447","#454537","#9F9461","#76744E","#71704C","#30302A","#414135","#181816","#FCC8C4","#EFB1A1","#838054","#F5B8AD","#E1A98C","#C8A477","#686848","#595941","#20201D","#8E8859","#D1A67D","#B29D6A","#E9AC95","#BEA270","#FED1CF","#0E0E0D","#A59764","#DAA784","#282823","#F9C0B9","#51503D","#393930","#FFDAD9","#49493A","#606045","#FFE2E1","#9A915E","#797750","#F4B6AA","#F6BAB0","#CBA578","#FFD8D6","#FECFCC","#262622","#C0A272","#868255","#1A1A18","#FAC2BC","#8B8658","#E3AA8E","#161614","#4F4E3C","#C6A475","#2E2E28","#BBA16F","#6B6A49","#E7AB93","#CFA67C","#626246","#53523E","#5B5B42","#FED3D1","#7C7A51","#817E53","#73724D","#FFDCDB","#37372E","#F8BEB6","#0B0B0A","#575740","#DFA98A","#474738","#B59F6C"]},vanimo:{discrete:b,categorical:b},vik:{discrete:u,categorical:u},viko:{discrete:f,categorical:f}};function p(A){const C=A.replace("#","");return{r:parseInt(C.slice(0,2),16),g:parseInt(C.slice(2,4),16),b:parseInt(C.slice(4,6),16)}}const h={waves:"batlow",blksand:"tokyo",breeze:"imola",magma:"batlow",ribbon:"hawaii",stars:"batlow",folds:"imola"},k={[B.ADVERT]:1,[B.TXT_MSG]:4,[B.GRP_TXT]:2,[B.RESPONSE]:8,[B.REQ]:13,[B.ANON_REQ]:7,[B.ACK]:11,[B.PATH]:24,[B.TRACE]:16,[B.GRP_DATA]:34,[B.MULTIPART]:52,[B.RAW_CUSTOM]:14};function v(){let A="waves",C=!0;if("undefined"!=typeof window){A=localStorage.getItem("pymc-color-scheme")||"waves";const B=D(A);C=(null==B?void 0:B.meta.isDark)??!0}const B=h[A]??"batlow",F=w[B],E=F.discrete.length,e=Math.floor(E/2);return{colormap:F,colormapName:B,isDark:C,baseIndex:C?e:0,halfSize:e}}let T=null;function M(A){const{colormap:C,isDark:D}=v();if("number"!=typeof A)return D?"#A5A5A5":"#666666";const B=k[A];if(void 0===B)return D?"#A5A5A5":"#666666";const F=C.categorical;return F[Math.min(B,F.length-1)]}function R(D){const B=M(D);return null===T&&(T=C()),T?A(B):B}function I(A){return p(M(A))}function S(A){const{colormap:C,baseIndex:D,halfSize:B}=v(),F=Math.max(0,Math.min(1,A)),E=Math.min(D+Math.floor(F*(B-1)),C.discrete.length-1);return C.discrete[E]}export{I as a,S as b,R as g,p as h}; diff --git a/frontend/dist/index.html b/frontend/dist/index.html index 59f427bf..0bcc52b2 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -39,7 +39,7 @@ --font-data: 'JetBrains Mono', 'SF Mono', Monaco, monospace; } - + diff --git a/frontend/package.json b/frontend/package.json index 2c95b042..719d6d95 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "pymc_console", - "version": "0.9.168", + "version": "0.9.169", "description": "Vite + React Dashboard for pyMC_Repeater", "private": true, "type": "module",