import{e as we,fs as N,ft as Ke,r as d,j as e,I as K,B as te,c as C,f8 as Fe,f9 as ze,aB as be,fa as Ve,ab as pe,$ as I,a4 as ne,bK as xe,fu as Se,d3 as ye,fv as Le,fw as me,bE as We,fx as $e,R as le,f as Pe,h as Ye,fy as O,fz as Ze,fA as Je,fB as Me,fC as Xe,fD as qe,fE as _e,a6 as Ae,cb as fe,fF as Qe,cN as ke,fG as et,bY as tt}from"./index-C4inJ1rU.js";import{C as Q,P as st,a as at,B as nt}from"./PageLayout-CdGXajgM.js";import{L as Re,a as ge}from"./listbox-C-kqERsa.js";import{S as rt}from"./settings-2-BHdXfxPS.js";import{P as re}from"./plus-BvSKm1y6.js";import{M as lt}from"./map-pin-DlTTkXK_.js";import{C as ot}from"./check-check-Baz1DFjd.js";import{Z as se}from"./zap-NBmxZJvi.js";import{S as Te}from"./search-qUivGgU1.js";import{C as de}from"./chevron-right-CU8UihKL.js";import{H as it}from"./hash-v3bMIFKt.js";import{u as ct,C as dt}from"./chevron-up-DRV4Id7V.js";import{F as ut}from"./funnel-MRZBOee_.js";import{a as mt,C as ht}from"./circle-stop-WDsdIdPd.js";import{T as pt}from"./trash-2-1fU70LRT.js";import{M as xt}from"./message-square-0NHS7JT6.js";import{S as je}from"./satellite-DHi4stvW.js";import{R as ue,C as Ne}from"./Grid-rJkrpDAP.js";import{W as ft}from"./wifi-CrCnex2M.js";import{W as gt}from"./wifi-off-DcMGHQmj.js";import{C as Nt}from"./clock-BOSF_clE.js";import"./element-movement-Dl45gerR.js";import"./floating-4TW7J4UF.js";import"./use-text-value-BO4BQQts.js";import"./frozen-BB9d2dXD.js";/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const bt=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Be=we("plug",bt);/**
 * @license lucide-react v0.559.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const St=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],De=we("unplug",St),yt=[["ATL","Atlanta","GA","United States","US","North America"],["AUS","Austin","TX","United States","US","North America"],["BDL","Hartford","CT","United States","US","North America"],["BNA","Nashville","TN","United States","US","North America"],["BOS","Boston","MA","United States","US","North America"],["BUF","Buffalo","NY","United States","US","North America"],["BWI","Baltimore","MD","United States","US","North America"],["CHS","Charleston","SC","United States","US","North America"],["CLE","Cleveland","OH","United States","US","North America"],["CLT","Charlotte","NC","United States","US","North America"],["CMH","Columbus","OH","United States","US","North America"],["CVG","Cincinnati","OH","United States","US","North America"],["DAL","Dallas Love","TX","United States","US","North America"],["DCA","Washington Natl","VA","United States","US","North America"],["DEN","Denver","CO","United States","US","North America"],["DFW","Dallas/Ft Worth","TX","United States","US","North America"],["DTW","Detroit","MI","United States","US","North America"],["EWR","Newark","NJ","United States","US","North America"],["FLL","Ft Lauderdale","FL","United States","US","North America"],["HNL","Honolulu","HI","United States","US","North America"],["HOU","Houston Hobby","TX","United States","US","North America"],["IAD","Washington Dulles","VA","United States","US","North America"],["IAH","Houston Intercon","TX","United States","US","North America"],["IND","Indianapolis","IN","United States","US","North America"],["JAX","Jacksonville","FL","United States","US","North America"],["JFK","New York JFK","NY","United States","US","North America"],["LAS","Las Vegas","NV","United States","US","North America"],["LAX","Los Angeles","CA","United States","US","North America"],["LGA","New York LaGuardia","NY","United States","US","North America"],["MCI","Kansas City","MO","United States","US","North America"],["MCO","Orlando","FL","United States","US","North America"],["MDW","Chicago Midway","IL","United States","US","North America"],["MEM","Memphis","TN","United States","US","North America"],["MIA","Miami","FL","United States","US","North America"],["MKE","Milwaukee","WI","United States","US","North America"],["MSP","Minneapolis","MN","United States","US","North America"],["MSY","New Orleans","LA","United States","US","North America"],["OAK","Oakland","CA","United States","US","North America"],["ONT","Ontario","CA","United States","US","North America"],["ORD","Chicago O'Hare","IL","United States","US","North America"],["PBI","West Palm Beach","FL","United States","US","North America"],["PDX","Portland","OR","United States","US","North America"],["PHL","Philadelphia","PA","United States","US","North America"],["PHX","Phoenix","AZ","United States","US","North America"],["PIT","Pittsburgh","PA","United States","US","North America"],["PVD","Providence","RI","United States","US","North America"],["RDU","Raleigh-Durham","NC","United States","US","North America"],["RNO","Reno","NV","United States","US","North America"],["RSW","Ft Myers","FL","United States","US","North America"],["SAN","San Diego","CA","United States","US","North America"],["SAT","San Antonio","TX","United States","US","North America"],["SEA","Seattle","WA","United States","US","North America"],["SFO","San Francisco","CA","United States","US","North America"],["SJC","San Jose","CA","United States","US","North America"],["SLC","Salt Lake City","UT","United States","US","North America"],["SMF","Sacramento","CA","United States","US","North America"],["SNA","Orange County","CA","United States","US","North America"],["STL","St Louis","MO","United States","US","North America"],["TPA","Tampa","FL","United States","US","North America"],["TUS","Tucson","AZ","United States","US","North America"],["ABQ","Albuquerque","NM","United States","US","North America"],["AGC","Allegheny County","PA","United States","US","North America"],["AGS","Augusta","GA","United States","US","North America"],["ALB","Albany","NY","United States","US","North America"],["AVL","Asheville","NC","United States","US","North America"],["BHM","Birmingham","AL","United States","US","North America"],["BLI","Bellingham","WA","United States","US","North America"],["BOI","Boise","ID","United States","US","North America"],["CHA","Chattanooga","TN","United States","US","North America"],["CON","Concord","NH","United States","US","North America"],["CVO","Corvallis","OR","United States","US","North America"],["EAT","Wenatchee","WA","United States","US","North America"],["ELP","El Paso","TX","United States","US","North America"],["EUG","Eugene","OR","United States","US","North America"],["FAR","Fargo","ND","United States","US","North America"],["FNL","Fort Collins","CO","United States","US","North America"],["GDW","Gladwin","MI","United States","US","North America"],["GSO","Greensboro","NC","United States","US","North America"],["HTS","Huntington","WV","United States","US","North America"],["IDA","Idaho Falls","ID","United States","US","North America"],["LFT","Lafayette","LA","United States","US","North America"],["LOZ","London/Corbin","KY","United States","US","North America"],["MDT","Harrisburg","PA","United States","US","North America"],["MFR","Medford","OR","United States","US","North America"],["MGE","Marietta/Dobbins","GA","United States","US","North America"],["MSN","Madison","WI","United States","US","North America"],["NYC","New York City","NY","United States","US","North America"],["OKC","Oklahoma City","OK","United States","US","North America"],["OLM","Olympia","WA","United States","US","North America"],["OMA","Omaha","NE","United States","US","North America"],["OXR","Oxnard/Ventura","CA","United States","US","North America"],["PDK","DeKalb-Peachtree","GA","United States","US","North America"],["PGD","Punta Gorda","FL","United States","US","North America"],["PIH","Pocatello","ID","United States","US","North America"],["PKB","Parkersburg","WV","United States","US","North America"],["POU","Poughkeepsie","NY","United States","US","North America"],["PRC","Prescott","AZ","United States","US","North America"],["PSP","Palm Springs","CA","United States","US","North America"],["RST","Rochester","MN","United States","US","North America"],["SBP","San Luis Obispo","CA","United States","US","North America"],["SCE","State College","PA","United States","US","North America"],["SJT","San Angelo","TX","United States","US","North America"],["SRQ","Sarasota","FL","United States","US","North America"],["TUL","Tulsa","OK","United States","US","North America"],["TYS","Knoxville","TN","United States","US","North America"],["VPZ","Valparaiso","IN","United States","US","North America"],["SBA","Santa Barbara","CA","United States","US","North America"],["YEG","Edmonton","AB","Canada","CA","North America"],["YHZ","Halifax","NS","Canada","CA","North America"],["YOW","Ottawa","ON","Canada","CA","North America"],["YQB","Quebec City","QC","Canada","CA","North America"],["YUL","Montreal","QC","Canada","CA","North America"],["YVR","Vancouver","BC","Canada","CA","North America"],["YWG","Winnipeg","MB","Canada","CA","North America"],["YYC","Calgary","AB","Canada","CA","North America"],["YYZ","Toronto","ON","Canada","CA","North America"],["YCD","Nanaimo","BC","Canada","CA","North America"],["YKA","Kamloops","BC","Canada","CA","North America"],["YKF","Kitchener","ON","Canada","CA","North America"],["YQA","Muskoka","ON","Canada","CA","North America"],["YQL","Lethbridge","AB","Canada","CA","North America"],["YYJ","Victoria","BC","Canada","CA","North America"],["AMS","Amsterdam",null,"Netherlands","NL","Europe"],["ARN","Stockholm",null,"Sweden","SE","Europe"],["ATH","Athens",null,"Greece","GR","Europe"],["BCN","Barcelona",null,"Spain","ES","Europe"],["BER","Berlin",null,"Germany","DE","Europe"],["BRU","Brussels",null,"Belgium","BE","Europe"],["BUD","Budapest",null,"Hungary","HU","Europe"],["CDG","Paris CDG",null,"France","FR","Europe"],["CPH","Copenhagen",null,"Denmark","DK","Europe"],["DUB","Dublin",null,"Ireland","IE","Europe"],["DUS","Düsseldorf",null,"Germany","DE","Europe"],["EDI","Edinburgh",null,"United Kingdom","GB","Europe"],["FCO","Rome",null,"Italy","IT","Europe"],["FRA","Frankfurt",null,"Germany","DE","Europe"],["GVA","Geneva",null,"Switzerland","CH","Europe"],["HAM","Hamburg",null,"Germany","DE","Europe"],["HEL","Helsinki",null,"Finland","FI","Europe"],["IST","Istanbul",null,"Turkey","TR","Europe"],["KEF","Reykjavik",null,"Iceland","IS","Europe"],["LGW","London Gatwick",null,"United Kingdom","GB","Europe"],["LHR","London Heathrow",null,"United Kingdom","GB","Europe"],["LIS","Lisbon",null,"Portugal","PT","Europe"],["MAD","Madrid",null,"Spain","ES","Europe"],["MAN","Manchester",null,"United Kingdom","GB","Europe"],["MIL","Milan",null,"Italy","IT","Europe"],["MUC","Munich",null,"Germany","DE","Europe"],["MXP","Milan Malpensa",null,"Italy","IT","Europe"],["NCE","Nice",null,"France","FR","Europe"],["ORY","Paris Orly",null,"France","FR","Europe"],["OSL","Oslo",null,"Norway","NO","Europe"],["OTP","Bucharest",null,"Romania","RO","Europe"],["PMI","Palma Mallorca",null,"Spain","ES","Europe"],["PRG","Prague",null,"Czech Republic","CZ","Europe"],["RIX","Riga",null,"Latvia","LV","Europe"],["STN","London Stansted",null,"United Kingdom","GB","Europe"],["TXL","Berlin Tegel",null,"Germany","DE","Europe"],["VIE","Vienna",null,"Austria","AT","Europe"],["VNO","Vilnius",null,"Lithuania","LT","Europe"],["WAW","Warsaw",null,"Poland","PL","Europe"],["ZRH","Zürich",null,"Switzerland","CH","Europe"],["BHD","Belfast City",null,"United Kingdom","GB","Europe"],["BHX","Birmingham",null,"United Kingdom","GB","Europe"],["BOH","Bournemouth",null,"United Kingdom","GB","Europe"],["BRS","Bristol",null,"United Kingdom","GB","Europe"],["BSH","Brighton",null,"United Kingdom","GB","Europe"],["CAX","Carlisle",null,"United Kingdom","GB","Europe"],["CBG","Cambridge",null,"United Kingdom","GB","Europe"],["CEG","Chester",null,"United Kingdom","GB","Europe"],["DSA","Doncaster",null,"United Kingdom","GB","Europe"],["LCY","London City",null,"United Kingdom","GB","Europe"],["LON","London",null,"United Kingdom","GB","Europe"],["LPL","Liverpool",null,"United Kingdom","GB","Europe"],["LTN","London Luton",null,"United Kingdom","GB","Europe"],["MME","Durham Tees Valley",null,"United Kingdom","GB","Europe"],["NWI","Norwich",null,"United Kingdom","GB","Europe"],["VLY","Valley/Anglesey",null,"United Kingdom","GB","Europe"],["BWE","Braunschweig",null,"Germany","DE","Europe"],["BYU","Bayreuth",null,"Germany","DE","Europe"],["CGN","Cologne/Bonn",null,"Germany","DE","Europe"],["DRS","Dresden",null,"Germany","DE","Europe"],["DTM","Dortmund",null,"Germany","DE","Europe"],["ERF","Erfurt",null,"Germany","DE","Europe"],["ESS","Essen/Mülheim",null,"Germany","DE","Europe"],["FKB","Karlsruhe/Baden",null,"Germany","DE","Europe"],["HAJ","Hannover",null,"Germany","DE","Europe"],["HDB","Heidelberg",null,"Germany","DE","Europe"],["HOQ","Hof",null,"Germany","DE","Europe"],["KEL","Kiel",null,"Germany","DE","Europe"],["KSF","Kassel",null,"Germany","DE","Europe"],["KZG","Kitzingen",null,"Germany","DE","Europe"],["LEJ","Leipzig/Halle",null,"Germany","DE","Europe"],["MGL","Mönchengladbach",null,"Germany","DE","Europe"],["NRN","Weeze/Niederrhein",null,"Germany","DE","Europe"],["NUE","Nuremberg",null,"Germany","DE","Europe"],["SCN","Saarbrücken",null,"Germany","DE","Europe"],["SPM","Spangdahlem",null,"Germany","DE","Europe"],["STR","Stuttgart",null,"Germany","DE","Europe"],["WIE","Wiesbaden",null,"Germany","DE","Europe"],["EIN","Eindhoven",null,"Netherlands","NL","Europe"],["ENS","Enschede",null,"Netherlands","NL","Europe"],["GLZ","Gilze-Rijen",null,"Netherlands","NL","Europe"],["GRQ","Groningen",null,"Netherlands","NL","Europe"],["LEY","Lelystad",null,"Netherlands","NL","Europe"],["LWR","Leeuwarden",null,"Netherlands","NL","Europe"],["MST","Maastricht",null,"Netherlands","NL","Europe"],["RTM","Rotterdam",null,"Netherlands","NL","Europe"],["UDE","Volkel/Uden",null,"Netherlands","NL","Europe"],["BZG","Bydgoszcz",null,"Poland","PL","Europe"],["GDN","Gdańsk",null,"Poland","PL","Europe"],["KRK","Kraków",null,"Poland","PL","Europe"],["KTW","Katowice",null,"Poland","PL","Europe"],["LCJ","Łódź",null,"Poland","PL","Europe"],["POZ","Poznań",null,"Poland","PL","Europe"],["RDO","Radom",null,"Poland","PL","Europe"],["RZE","Rzeszów",null,"Poland","PL","Europe"],["SZZ","Szczecin",null,"Poland","PL","Europe"],["WRO","Wrocław",null,"Poland","PL","Europe"],["EBU","Saint-Étienne",null,"France","FR","Europe"],["LRT","Lorient",null,"France","FR","Europe"],["LYS","Lyon",null,"France","FR","Europe"],["NTE","Nantes",null,"France","FR","Europe"],["PAR","Paris",null,"France","FR","Europe"],["SXB","Strasbourg",null,"France","FR","Europe"],["TNF","Toussus-le-Noble",null,"France","FR","Europe"],["VAF","Valence",null,"France","FR","Europe"],["ANR","Antwerp",null,"Belgium","BE","Europe"],["LGG","Liège",null,"Belgium","BE","Europe"],["OBL","Oostmalle",null,"Belgium","BE","Europe"],["OST","Ostend",null,"Belgium","BE","Europe"],["XBK","Bourg-Léopold",null,"Belgium","BE","Europe"],["BRQ","Brno",null,"Czech Republic","CZ","Europe"],["OSR","Ostrava",null,"Czech Republic","CZ","Europe"],["PED","Pardubice",null,"Czech Republic","CZ","Europe"],["BTS","Bratislava",null,"Slovakia","SK","Europe"],["ILZ","Žilina",null,"Slovakia","SK","Europe"],["TAT","Poprad-Tatry",null,"Slovakia","SK","Europe"],["BIO","Bilbao",null,"Spain","ES","Europe"],["BLL","Billund",null,"Denmark","DK","Europe"],["BRN","Bern",null,"Switzerland","CH","Europe"],["KID","Kristianstad",null,"Sweden","SE","Europe"],["LIN","Milan Linate",null,"Italy","IT","Europe"],["LUX","Luxembourg",null,"Luxembourg","LU","Europe"],["OPO","Porto",null,"Portugal","PT","Europe"],["RKV","Reykjavik City",null,"Iceland","IS","Europe"],["SOF","Sofia",null,"Bulgaria","BG","Europe"],["STO","Stockholm",null,"Sweden","SE","Europe"],["TAY","Tartu",null,"Estonia","EE","Europe"],["TLL","Tallinn",null,"Estonia","EE","Europe"],["IWA","Ivanovo",null,"Russia","RU","Europe"],["KGD","Kaliningrad",null,"Russia","RU","Europe"],["KZN","Kazan",null,"Russia","RU","Europe"],["MOW","Moscow",null,"Russia","RU","Europe"],["ROV","Rostov-on-Don",null,"Russia","RU","Europe"],["RZN","Ryazan",null,"Russia","RU","Europe"],["VOG","Volgograd",null,"Russia","RU","Europe"],["BKK","Bangkok",null,"Thailand","TH","Asia Pacific"],["CAN","Guangzhou",null,"China","CN","Asia Pacific"],["CEB","Cebu",null,"Philippines","PH","Asia Pacific"],["CGK","Jakarta",null,"Indonesia","ID","Asia Pacific"],["CTU","Chengdu",null,"China","CN","Asia Pacific"],["DAD","Da Nang",null,"Vietnam","VN","Asia Pacific"],["DEL","Delhi",null,"India","IN","Asia Pacific"],["DPS","Bali Denpasar",null,"Indonesia","ID","Asia Pacific"],["HAN","Hanoi",null,"Vietnam","VN","Asia Pacific"],["HGH","Hangzhou",null,"China","CN","Asia Pacific"],["HKG","Hong Kong",null,"Hong Kong","HK","Asia Pacific"],["HND","Tokyo Haneda",null,"Japan","JP","Asia Pacific"],["ICN","Seoul Incheon",null,"South Korea","KR","Asia Pacific"],["KIX","Osaka Kansai",null,"Japan","JP","Asia Pacific"],["KUL","Kuala Lumpur",null,"Malaysia","MY","Asia Pacific"],["MNL","Manila",null,"Philippines","PH","Asia Pacific"],["BOM","Mumbai",null,"India","IN","Asia Pacific"],["NRT","Tokyo Narita",null,"Japan","JP","Asia Pacific"],["PEK","Beijing",null,"China","CN","Asia Pacific"],["PVG","Shanghai",null,"China","CN","Asia Pacific"],["SGN","Ho Chi Minh",null,"Vietnam","VN","Asia Pacific"],["SHA","Shanghai Hongqiao",null,"China","CN","Asia Pacific"],["SIN","Singapore",null,"Singapore","SG","Asia Pacific"],["SZX","Shenzhen",null,"China","CN","Asia Pacific"],["TPE","Taipei",null,"Taiwan","TW","Asia Pacific"],["KHV","Khabarovsk",null,"Russia","RU","Asia Pacific"],["AKL","Auckland",null,"New Zealand","NZ","Oceania"],["BNE","Brisbane","QLD","Australia","AU","Oceania"],["CBR","Canberra","ACT","Australia","AU","Oceania"],["CHC","Christchurch",null,"New Zealand","NZ","Oceania"],["MEL","Melbourne","VIC","Australia","AU","Oceania"],["PER","Perth","WA","Australia","AU","Oceania"],["SYD","Sydney","NSW","Australia","AU","Oceania"],["WLG","Wellington",null,"New Zealand","NZ","Oceania"],["ABX","Albury","NSW","Australia","AU","Oceania"],["ADL","Adelaide","SA","Australia","AU","Oceania"],["BHS","Bathurst","NSW","Australia","AU","Oceania"],["BUY","Bunbury","WA","Australia","AU","Oceania"],["NTL","Newcastle","NSW","Australia","AU","Oceania"],["PQQ","Port Macquarie","NSW","Australia","AU","Oceania"],["HLZ","Hamilton",null,"New Zealand","NZ","Oceania"],["NPE","Napier",null,"New Zealand","NZ","Oceania"],["TRG","Tauranga",null,"New Zealand","NZ","Oceania"],["TIJ","Tijuana",null,"Mexico","MX","Latin America"],["BOG","Bogotá",null,"Colombia","CO","Latin America"],["BSB","Brasília",null,"Brazil","BR","Latin America"],["CUN","Cancún",null,"Mexico","MX","Latin America"],["EZE","Buenos Aires",null,"Argentina","AR","Latin America"],["GDL","Guadalajara",null,"Mexico","MX","Latin America"],["GIG","Rio de Janeiro",null,"Brazil","BR","Latin America"],["GRU","São Paulo",null,"Brazil","BR","Latin America"],["HAV","Havana",null,"Cuba","CU","Latin America"],["LIM","Lima",null,"Peru","PE","Latin America"],["MEX","Mexico City",null,"Mexico","MX","Latin America"],["MDE","Medellín",null,"Colombia","CO","Latin America"],["MVD","Montevideo",null,"Uruguay","UY","Latin America"],["PTY","Panama City",null,"Panama","PA","Latin America"],["SCL","Santiago",null,"Chile","CL","Latin America"],["SJO","San José",null,"Costa Rica","CR","Latin America"],["UIO","Quito",null,"Ecuador","EC","Latin America"],["AUH","Abu Dhabi",null,"UAE","AE","Middle East"],["BAH","Bahrain",null,"Bahrain","BH","Middle East"],["DOH","Doha",null,"Qatar","QA","Middle East"],["DXB","Dubai",null,"UAE","AE","Middle East"],["JED","Jeddah",null,"Saudi Arabia","SA","Middle East"],["KWI","Kuwait City",null,"Kuwait","KW","Middle East"],["MCT","Muscat",null,"Oman","OM","Middle East"],["RUH","Riyadh",null,"Saudi Arabia","SA","Middle East"],["TLV","Tel Aviv",null,"Israel","IL","Middle East"],["ABJ","Abidjan",null,"Ivory Coast","CI","Africa"],["ACC","Accra",null,"Ghana","GH","Africa"],["ADD","Addis Ababa",null,"Ethiopia","ET","Africa"],["ALG","Algiers",null,"Algeria","DZ","Africa"],["CAI","Cairo",null,"Egypt","EG","Africa"],["CMN","Casablanca",null,"Morocco","MA","Africa"],["CPT","Cape Town",null,"South Africa","ZA","Africa"],["DAR","Dar es Salaam",null,"Tanzania","TZ","Africa"],["JNB","Johannesburg",null,"South Africa","ZA","Africa"],["LOS","Lagos",null,"Nigeria","NG","Africa"],["NBO","Nairobi",null,"Kenya","KE","Africa"],["BSK","Biskra",null,"Algeria","DZ","Africa"]],Ce=new Map;for(const[s,t,r,l,i,a]of yt)Ce.set(s,{code:s,city:t,...r?{state:r}:{},country:l,countryCode:i,continent:a});const Ct={city:"Unknown",country:"Unknown",countryCode:"??",continent:"Unknown"};function ee(s){return Ce.get(s.toUpperCase())??{code:s.toUpperCase(),...Ct}}function At(s){const t=Ce.get(s.toUpperCase());return t?t.state?`${t.city}, ${t.state}`:t.city:s.toUpperCase()}function jt(s){const t=new Map;for(const l of s){const i=ee(l);let a=t.get(i.continent);a||(a=new Map,t.set(i.continent,a));let x=a.get(i.country);x||(x={countryCode:i.countryCode,codes:[]},a.set(i.country,x)),x.codes.push(l.toUpperCase())}return["North America","Europe","Asia Pacific","Oceania","Latin America","Middle East","Africa","Unknown"].filter(l=>t.has(l)).map(l=>({continent:l,countries:[...t.get(l).entries()].sort(([i],[a])=>i.localeCompare(a)).map(([i,{countryCode:a,codes:x}])=>({country:i,countryCode:a,codes:x.sort()}))}))}const vt=[{name:"West Coast Mesh",emoji:"🏄",continent:"North America",frequencyMHz:"927.875",codes:["SBP","SBA","OXR","LAX","SNA","ONT","PSP","SAN","TIJ"]}];function Ut(s){const t=s.toUpperCase();return t.length!==2||t==="??"?"🏳️":String.fromCodePoint(...[...t].map(r=>127462+r.charCodeAt(0)-65))}const Et={"North America":"🌎","Latin America":"🌎",Europe:"🌍",Africa:"🌍","Middle East":"🌍","Asia Pacific":"🌏",Oceania:"🌏",Unknown:"🏳️"};function wt(s){return Et[s]??"🏳️"}function Lt(s){const t=s.children.get("meshcore");if(!t)return[];const r=[];for(const[l,i]of t.children){if(l.length>4||l.length<2)continue;let a=0,x=0,p=0;for(const[,U]of i.children){x++,a+=U.messageCount;for(const[,v]of U.children)a+=v.messageCount,v.lastReceived>p&&(p=v.lastReceived);U.lastReceived>p&&(p=U.lastReceived)}a>0&&r.push({prefix:`meshcore/${l}`,iata:l,messageCount:a,observerCount:x,lastSeen:p})}return r.sort((l,i)=>i.messageCount-l.messageCount)}function _({label:s,children:t,className:r}){return e.jsxs("div",{className:C("flex flex-col gap-1",r),children:[e.jsx("label",{className:"type-data-xs text-fg-muted uppercase tracking-wider",children:s}),t]})}const Pt={connected:"green",connecting:"amber",error:"red",disconnected:"zinc"},ve=[{topic:"meshcore/#",label:"All MeshCore",description:"All traffic under meshcore/"},{topic:"meshcore/+/+/packets",label:"Packets",description:"Packet data from all observers"},{topic:"meshcore/+/+/status",label:"Status",description:"Observer status updates"},{topic:"#",label:"Everything",description:"All topics on broker"}];function Mt(){const[s,t]=d.useState(""),[r,l]=d.useState(!1),i=N(m=>m.subscribe),a=N(m=>m.unsubscribe),x=N(m=>m.subscriptions),U=N(m=>m.status)==="connected",v=d.useMemo(()=>new Set(ve.map(m=>m.topic)),[]),L=d.useMemo(()=>x.filter(m=>!v.has(m)),[x,v]),P=d.useCallback(m=>{x.includes(m)?a(m):i(m)},[x,i,a]),M=d.useCallback(m=>{m.preventDefault();const A=s.trim();A&&(i(A),t(""),l(!1))},[s,i]);return e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wider shrink-0 mr-1",children:"Topics"}),ve.map(({topic:m,label:A,description:S})=>{const E=x.includes(m);return e.jsxs("button",{onClick:()=>P(m),disabled:!U,title:`${E?"Unsubscribe from":"Subscribe to"} ${m}
${S}`,className:C("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full","font-mono text-[11px] font-medium tracking-wide","border transition-all select-none","disabled:opacity-40 disabled:cursor-not-allowed",E?"border-sys-blue/50 bg-sys-blue/15 text-sys-blue":"border-edge-subtle/50 text-fg-muted hover:border-edge-subtle hover:text-fg-secondary hover:bg-subtle-fill/30"),children:[E&&e.jsx(ne,{className:"w-3 h-3"}),A]},m)}),(L.length>0||r)&&e.jsx("div",{className:"h-4 w-px bg-edge-subtle/40 mx-0.5"}),L.map(m=>e.jsxs("button",{onClick:()=>a(m),title:`Unsubscribe from ${m}`,className:C("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full","font-mono text-[11px] font-medium tracking-wide","border border-sys-indigo/50 bg-sys-indigo/15 text-sys-indigo","hover:border-sys-red/50 hover:bg-sys-red/10 hover:text-sys-red","transition-all select-none group"),children:[e.jsx("span",{children:m}),e.jsx(xe,{className:"w-3 h-3 opacity-50 group-hover:opacity-100"})]},m)),r?e.jsxs("form",{onSubmit:M,className:"inline-flex items-center gap-1",children:[e.jsx(K,{size:"sm",value:s,onChange:m=>t(m.target.value),placeholder:"topic/filter/#",className:"w-44 font-mono text-[11px]",autoFocus:!0,onBlur:()=>{s.trim()||l(!1)},onKeyDown:m=>{m.key==="Escape"&&(l(!1),t(""))}}),e.jsx(te,{type:"submit",plain:!0,disabled:!s.trim(),title:"Subscribe",children:e.jsx(re,{"data-slot":"icon",className:"!w-3.5 !h-3.5"})})]}):e.jsxs("button",{onClick:()=>l(!0),disabled:!U,title:"Subscribe to a custom topic",className:C("inline-flex items-center gap-1 px-2 py-1 rounded-full","font-mono text-[11px] text-fg-muted","border border-dashed border-edge-subtle/50","hover:border-edge-subtle hover:text-fg-secondary hover:bg-subtle-fill/20","transition-all disabled:opacity-40 disabled:cursor-not-allowed"),children:[e.jsx(re,{className:"w-3 h-3"}),"Custom"]})]})})}function Ue({ch:s,selected:t,streaming:r,onToggle:l}){const i=ee(s.iata),a=At(s.iata),x=t&&r?se:ne;return e.jsxs("button",{onClick:()=>l(s.iata),title:`${t?"Deselect":"Select"} ${s.iata} — ${a}, ${i.country}
${s.messageCount.toLocaleString()} msgs, ${s.observerCount} observer${s.observerCount!==1?"s":""}`,className:C("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full","font-mono text-[11px] font-medium tracking-wide","border transition-all select-none",t?r?"border-sys-amber/50 bg-sys-amber/15 text-sys-amber":"border-sys-cyan/50 bg-sys-cyan/15 text-sys-cyan":"border-edge-subtle/40 text-fg-muted hover:border-edge-subtle hover:text-fg-secondary hover:bg-subtle-fill/30"),children:[t&&e.jsx(x,{className:"w-3 h-3"}),s.iata,e.jsx("span",{className:C("tabular-nums text-[10px]",t?"text-sys-cyan/60":"text-fg-muted/50"),children:s.messageCount.toLocaleString()}),s.observerCount>1&&e.jsxs("span",{className:C("text-[10px]",t?"text-sys-cyan/40":"text-fg-muted/30"),children:["×",s.observerCount]})]})}const kt=d.memo(function(){const t=N(c=>c.topicTree),r=N(c=>c.startStreaming),l=N(c=>c.stopStreaming),i=N(c=>c.toggleIata),a=N(c=>c.selectAllIatas),x=N(c=>c.deselectAllIatas),p=Se(),U=ye(),v=Le(),[L,P]=d.useState(""),[M,m]=d.useState(()=>new Set),A=d.useRef(new Set),S=d.useMemo(()=>Lt(t),[t]),E=d.useMemo(()=>{const c=new Map;for(const w of S)c.set(w.iata.toUpperCase(),w);return c},[S]),j=d.useMemo(()=>S.map(c=>c.iata),[S]),F=d.useMemo(()=>{if(!L)return S;const c=L.toLowerCase();return S.filter(w=>{var T;if(w.iata.toLowerCase().includes(c))return!0;const g=ee(w.iata);return g.city.toLowerCase().includes(c)||g.country.toLowerCase().includes(c)||g.continent.toLowerCase().includes(c)||(((T=g.state)==null?void 0:T.toLowerCase().includes(c))??!1)})},[S,L]),z=d.useMemo(()=>jt(F.map(c=>c.iata)),[F]),Y=d.useMemo(()=>{const c=[...v.values()],w=new Set(S.map(g=>g.iata.toUpperCase()));return vt.map(g=>{var G;const T=new Set;if(g.codes)for(const H of g.codes)w.has(H)&&T.add(H);if(g.frequencyMHz){for(const H of c)if((G=H.radioConfig)!=null&&G.includes(g.frequencyMHz)){const Z=H.iata.toUpperCase();w.has(Z)&&T.add(Z)}}return{...g,resolvedCodes:[...T].sort()}}).filter(g=>g.resolvedCodes.length>0)},[v,S]);d.useEffect(()=>{if(z.length===0)return;const c=A.current,w=z.map(g=>g.continent).filter(g=>!c.has(g));if(w.length!==0){for(const g of w)c.add(g);m(g=>{const T=new Set(g);for(const G of w)T.add(G);return T})}},[z]);const h=d.useMemo(()=>new Set(p),[p]),n=j.length>0&&j.every(c=>h.has(c)),f=p.length>0,y=U.active&&U.streaming,k=d.useRef(new Set),R=d.useRef(h);R.current=h;const V=d.useRef(p);V.current=p;const u=d.useRef(Y);u.current=Y,d.useEffect(()=>{const c=k.current;if(k.current=new Set(j),c.size===0||V.current.length===0)return;const w=j.filter(G=>!c.has(G));if(w.length===0)return;const g=R.current,T=[];for(const G of w){const H=ee(G);let Z=!1;for(const B of u.current)if(B.resolvedCodes.includes(G.toUpperCase())){const D=B.resolvedCodes.filter(W=>c.has(W));if(D.length>0&&D.every(W=>g.has(W))){T.push(G),Z=!0;break}}if(Z)continue;const ie=[...c].filter(B=>{const D=ee(B);return D.continent===H.continent&&D.country===H.country});if(ie.length>0&&ie.every(B=>g.has(B))){T.push(G);continue}const b=[...c].filter(B=>ee(B).continent===H.continent);b.length>0&&b.every(B=>g.has(B))&&T.push(G)}T.length>0&&a([...new Set([...V.current,...T])])},[j,a]);const o=d.useCallback(c=>{m(w=>{const g=new Set(w);return g.has(c)?g.delete(c):g.add(c),g})},[]),oe=d.useCallback(c=>{if(c.every(g=>h.has(g))){const g=new Set(c);a(p.filter(T=>!g.has(T)))}else{const g=[...new Set([...p,...c])];a(g)}},[h,p,a]);return S.length===0?e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-fg-muted type-data-xs",children:[e.jsx(lt,{className:"w-3.5 h-3.5"}),"Channels appear as messages arrive…"]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wider shrink-0",children:"Channels"}),e.jsx(I,{color:"zinc",children:S.length})]}),e.jsxs("button",{onClick:()=>n?x():a(j),className:C("inline-flex items-center gap-1 px-2 py-0.5 rounded-full","text-[11px] font-medium border transition-all select-none",n?"border-sys-cyan/40 bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/15":"border-edge-subtle/50 text-fg-muted hover:border-edge-subtle hover:text-fg-secondary"),title:n?"Deselect all channels":"Select all channels",children:[n?e.jsx(We,{className:"w-3 h-3"}):e.jsx(ot,{className:"w-3 h-3"}),n?"Deselect All":"Select All"]}),f&&e.jsxs(I,{color:"cyan",children:[p.length," selected"]}),e.jsx("div",{className:"flex-1"}),f&&e.jsx("div",{className:"flex items-center gap-1",children:e.jsxs("button",{onClick:()=>y?l():r(),className:C("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-medium border transition-all select-none",y?"border-sys-amber/50 bg-sys-amber/20 text-sys-amber":"border-sys-cyan/40 bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/20"),title:y?"Stop live feed":"Start live feed from selected channels",children:[e.jsx(se,{className:C("w-3 h-3",y&&"fill-current")}),y?"Streaming":"Stream"]})}),e.jsxs("div",{className:"relative max-w-48",children:[e.jsx(Te,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none"}),e.jsx(K,{size:"sm",value:L,onChange:c=>P(c.target.value),placeholder:"City, country, region…",className:"pl-7 w-full font-mono"})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:z.map(c=>{const w=c.continent,g=M.has(w),T=c.countries.reduce((b,B)=>b+B.codes.reduce((D,W)=>{var X;return D+(((X=E.get(W))==null?void 0:X.messageCount)??0)},0),0),G=c.countries.reduce((b,B)=>b+B.codes.length,0),H=c.countries.flatMap(b=>b.codes),Z=H.length>0&&H.every(b=>h.has(b)),ie=H.some(b=>h.has(b));return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[e.jsxs("button",{onClick:()=>o(w),className:"flex items-center gap-1.5 text-left group",children:[e.jsx(de,{className:C("w-3 h-3 text-fg-muted transition-transform duration-150",!g&&"rotate-90")}),e.jsxs("span",{className:"type-data-xs text-fg-secondary font-medium uppercase tracking-wider",children:[wt(c.continent)," ",c.continent]}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 tabular-nums",children:G}),e.jsxs("span",{className:"type-data-xs text-fg-muted/30 tabular-nums",children:[T.toLocaleString()," msgs"]})]}),e.jsx("button",{onClick:b=>{b.stopPropagation(),oe(H)},className:C("inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full","text-[10px] font-medium border transition-all select-none ml-1",Z?y?"border-sys-amber/40 bg-sys-amber/10 text-sys-amber hover:bg-sys-amber/15":"border-sys-cyan/40 bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/15":ie?"border-sys-cyan/30 bg-sys-cyan/5 text-sys-cyan/70 hover:bg-sys-cyan/10":"border-edge-subtle/40 text-fg-muted/60 hover:border-edge-subtle hover:text-fg-secondary"),title:Z?`Deselect all ${c.continent} channels`:`Select all ${c.continent} channels`,children:Z?y?e.jsx(se,{className:"w-2.5 h-2.5"}):e.jsx(ne,{className:"w-2.5 h-2.5"}):e.jsx(re,{className:"w-2.5 h-2.5"})})]}),!g&&e.jsxs("div",{className:"ml-4 flex flex-col gap-1.5",children:[Y.filter(b=>b.continent===c.continent).map(b=>{const B=`${w}/_curated/${b.name}`,D=M.has(B),W=b.resolvedCodes.length>0&&b.resolvedCodes.every($=>h.has($)),X=b.resolvedCodes.some($=>h.has($));return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[e.jsxs("button",{onClick:()=>o(B),className:"flex items-center gap-1.5 text-left",children:[e.jsx(de,{className:C("w-2.5 h-2.5 text-fg-muted/60 transition-transform duration-150",!D&&"rotate-90")}),e.jsxs("span",{className:"text-[11px] text-sys-amber font-medium",children:[b.emoji," ",b.name]}),e.jsx("span",{className:"text-[10px] text-fg-muted/40 tabular-nums",children:b.resolvedCodes.length}),b.frequencyMHz&&e.jsxs("span",{className:"text-[9px] text-fg-muted/30 font-mono",children:[b.frequencyMHz," MHz"]})]}),e.jsx("button",{onClick:$=>{$.stopPropagation(),oe(b.resolvedCodes)},className:C("inline-flex items-center gap-0.5 px-1 py-0.5 rounded-full","text-[9px] font-medium border transition-all select-none",W?y?"border-sys-amber/40 bg-sys-amber/10 text-sys-amber hover:bg-sys-amber/15":"border-sys-cyan/40 bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/15":X?"border-sys-cyan/30 bg-sys-cyan/5 text-sys-cyan/70 hover:bg-sys-cyan/10":"border-edge-subtle/30 text-fg-muted/50 hover:border-edge-subtle hover:text-fg-secondary"),title:W?`Deselect all ${b.name} channels`:`Select all ${b.name} channels`,children:W?y?e.jsx(se,{className:"w-2 h-2"}):e.jsx(ne,{className:"w-2 h-2"}):e.jsx(re,{className:"w-2 h-2"})})]}),!D&&e.jsx("div",{className:"flex flex-wrap gap-1.5 ml-4 mt-0.5",children:b.resolvedCodes.map($=>{const q=E.get($);return q?e.jsx(Ue,{ch:q,selected:h.has(q.iata),streaming:y,onToggle:i},$):null})})]},b.name)}),c.countries.map(({country:b,countryCode:B,codes:D})=>{const W=`${w}/${b}`,X=M.has(W),$=c.countries.length>1||D.length>6,q=D.length>0&&D.every(J=>h.has(J)),He=D.some(J=>h.has(J));return e.jsxs("div",{children:[$&&e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[e.jsxs("button",{onClick:()=>o(W),className:"flex items-center gap-1.5 text-left",children:[e.jsx(de,{className:C("w-2.5 h-2.5 text-fg-muted/60 transition-transform duration-150",!X&&"rotate-90")}),e.jsxs("span",{className:"text-[11px] text-fg-muted",children:[Ut(B)," ",b]}),e.jsx("span",{className:"text-[10px] text-fg-muted/40 tabular-nums",children:D.length})]}),e.jsx("button",{onClick:J=>{J.stopPropagation(),oe(D)},className:C("inline-flex items-center gap-0.5 px-1 py-0.5 rounded-full","text-[9px] font-medium border transition-all select-none",q?y?"border-sys-amber/40 bg-sys-amber/10 text-sys-amber hover:bg-sys-amber/15":"border-sys-cyan/40 bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/15":He?"border-sys-cyan/30 bg-sys-cyan/5 text-sys-cyan/70 hover:bg-sys-cyan/10":"border-edge-subtle/30 text-fg-muted/50 hover:border-edge-subtle hover:text-fg-secondary"),title:q?`Deselect all ${b} channels`:`Select all ${b} channels`,children:q?y?e.jsx(se,{className:"w-2 h-2"}):e.jsx(ne,{className:"w-2 h-2"}):e.jsx(re,{className:"w-2 h-2"})})]}),(!$||!X)&&e.jsx("div",{className:C("flex flex-wrap gap-1.5",$&&"ml-4 mt-0.5"),children:D.map(J=>{const he=E.get(J);return he?e.jsx(Ue,{ch:he,selected:h.has(he.iata),streaming:y,onToggle:i},J):null})})]},b)})]})]},w)})})]})});function Rt(){const s=N(o=>o.name),t=N(o=>o.host),r=N(o=>o.port),l=N(o=>o.basepath),i=N(o=>o.protocol),a=N(o=>o.encryption),x=N(o=>o.validateCertificate),p=N(o=>o.username),U=N(o=>o.password),v=N(o=>o.status),L=N(o=>o.error),P=N(o=>o.messageCount),M=N(o=>o.setName),m=N(o=>o.setHost),A=N(o=>o.setPort),S=N(o=>o.setBasepath),E=N(o=>o.setProtocol),j=N(o=>o.setEncryption),F=N(o=>o.setValidateCertificate),z=N(o=>o.setUsername),Y=N(o=>o.setPassword),h=N(o=>o.connect),n=N(o=>o.disconnect),f=v==="connected",y=v==="connecting",k=!!t&&!f&&!y,R=f||y,V=t?Ke({host:t,port:r,basepath:l,protocol:i}):"",u=d.useCallback(()=>{f?n():h()},[f,h,n]);return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 max-w-3xl",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-end gap-3",children:[e.jsx(_,{label:"Protocol",className:"w-[135px] shrink-0",children:e.jsxs(Re,{value:i,onChange:o=>E(o),disabled:R,"aria-label":"Protocol",className:"[&_button]:h-8 [&_button]:py-0",children:[e.jsx(ge,{value:"wss",children:"wss://"}),e.jsx(ge,{value:"mqtt",children:"mqtt://"})]})}),e.jsx(_,{label:"Host",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",value:t,onChange:o=>m(o.target.value),placeholder:"mqtt.broker.xyz",disabled:R})}),e.jsx(_,{label:"Port",className:"w-20 shrink-0",children:e.jsx(K,{size:"sm",type:"number",value:String(r),onChange:o=>A(Number(o.target.value)||443),disabled:R})}),e.jsx(te,{color:f?"danger":"primary",onClick:u,disabled:!k&&!f,className:C("shrink-0 sm:self-end",y&&"animate-pulse"),children:f?e.jsxs(e.Fragment,{children:[e.jsx(De,{"data-slot":"icon",className:"!w-4 !h-4"})," Disconnect"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{"data-slot":"icon",className:"!w-4 !h-4"})," Connect"]})})]}),e.jsxs(Fe,{children:[e.jsxs(ze,{className:"!px-0 !py-1 !justify-start gap-2 w-auto",icon:e.jsx(be,{className:"w-3.5 h-3.5"}),children:[e.jsx(rt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs uppercase tracking-wider",children:"Connection details"})]}),e.jsx(Ve,{children:e.jsxs("div",{className:"flex flex-col gap-3 pt-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-end gap-3",children:[e.jsx(_,{label:"Name",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",value:s,onChange:o=>M(o.target.value),placeholder:"My Connection",disabled:R})}),e.jsx(_,{label:"Basepath",className:"w-24 shrink-0",children:e.jsx(K,{size:"sm",value:l,onChange:o=>S(o.target.value),placeholder:"ws",disabled:R})}),e.jsxs("div",{className:"flex items-center gap-4 sm:pb-0.5",children:[e.jsx(pe,{enabled:a,onChange:j,label:"TLS",size:"sm",disabled:R}),e.jsx(pe,{enabled:x,onChange:F,label:"Verify cert",size:"sm",disabled:R})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-end gap-3 max-w-md",children:[e.jsx(_,{label:"Username",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",value:p,onChange:o=>z(o.target.value),placeholder:"optional",disabled:R})}),e.jsx(_,{label:"Password",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",type:"password",value:U,onChange:o=>Y(o.target.value),placeholder:"optional",disabled:R})})]})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(I,{color:Pt[v]??"zinc",children:v}),f&&P>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:[P.toLocaleString()," msgs"]}),v==="error"&&L&&e.jsx("span",{className:"type-data-xs text-sys-red truncate max-w-60",title:L,children:L}),V&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/40 truncate min-w-0",title:V,children:V})]}),e.jsx("div",{className:"border-t border-edge-subtle/20 pt-4",children:e.jsx(Mt,{})}),f&&e.jsx("div",{className:"border-t border-edge-subtle/20 pt-4",children:e.jsx(kt,{})})]})}function Oe(s){let t=s.messageCount;for(const r of s.children.values())t+=Oe(r);return t}const Tt=d.memo(function s({node:t,depth:r,onSelect:l,selectedTopic:i}){const[a,x]=d.useState(!1),p=t.children.size>0,U=t.fullPath===i,v=U||i.startsWith(t.fullPath+"/"),L=d.useCallback(A=>{A.stopPropagation(),p&&x(S=>!S)},[p]),P=d.useCallback(()=>{l(t.fullPath),p&&!a&&x(!0)},[t.fullPath,l,p,a]),M=t.lastReceived>0?`${Math.round((Date.now()-t.lastReceived)/1e3)}s ago`:"",m=p?[...t.children.values()].sort((A,S)=>S.messageCount-A.messageCount):[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:C("flex items-center gap-1.5 py-1 px-2 radius-control cursor-pointer select-none",U?"bg-sys-cyan/10 text-sys-cyan hover:bg-sys-cyan/15":v?"bg-sys-cyan/5 hover:bg-sys-cyan/10":"hover:bg-white/10"),style:{paddingLeft:`${r*16+8}px`},onClick:P,role:"treeitem","aria-expanded":p?a:void 0,"aria-selected":U,children:[e.jsx("span",{className:"type-data-xs text-fg-muted tabular-nums flex-shrink-0 w-8 text-right",children:(()=>{const A=Oe(t);return A>0?A.toLocaleString():""})()}),e.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",onClick:p?L:void 0,children:p?e.jsx(de,{className:C("w-3.5 h-3.5 text-fg-muted transition-transform duration-150",a&&"rotate-90")}):e.jsx(it,{className:"w-3 h-3 text-fg-muted/50"})}),e.jsx("span",{className:"font-mono text-xs truncate flex-1",children:t.segment}),M&&e.jsx("span",{className:"type-data-xs text-fg-muted/60 flex-shrink-0 w-14 text-right",children:M})]}),a&&m.map(A=>e.jsx(s,{node:A,depth:r+1,onSelect:l,selectedTopic:i},A.segment))]})});function Bt({onTopicSelect:s,selectedTopic:t}){const l=[...$e().children.values()].sort((i,a)=>a.messageCount-i.messageCount);return l.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-fg-muted type-data-sm",children:"No topics yet"}):e.jsx("div",{className:"overflow-y-auto h-full",role:"tree",children:l.map(i=>e.jsx(Tt,{node:i,depth:0,onSelect:s,selectedTopic:t},i.segment))})}const Dt={advert:"indigo",trace:"cyan",grp_txt:"green",ack:"zinc",path:"amber",txt_msg:"blue"},Ot=d.memo(function({msg:t}){const[r,l]=d.useState(!1),i=new Date(t.timestamp).toLocaleTimeString(),a=t.topic.split("/").slice(-2).join("/");return e.jsxs("div",{className:"px-3 py-2 border-b border-edge-subtle/30 hover:bg-subtle-fill/50 transition-base",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"type-data-xs text-fg-muted tabular-nums flex-shrink-0 w-[72px]",children:i}),e.jsx("span",{className:"font-mono text-xs text-sys-blue truncate flex-1 min-w-0",title:t.topic,children:a}),t.meshcorePacket&&e.jsxs(I,{color:Dt[t.meshcorePacket.type]??"zinc",className:"flex-shrink-0",children:[e.jsx(le,{className:"w-3 h-3 mr-1"}),t.meshcorePacket.type]}),e.jsx("span",{className:"type-data-xs text-fg-muted/60 tabular-nums flex-shrink-0 w-12 text-right",children:t.size<1024?`${t.size}B`:`${(t.size/1024).toFixed(1)}K`}),t.payloadJson&&e.jsx("button",{onClick:()=>l(x=>!x),className:"text-fg-muted hover:text-fg-primary transition-colors flex-shrink-0","aria-label":r?"Collapse":"Expand",children:r?e.jsx(dt,{className:"w-3.5 h-3.5"}):e.jsx(be,{className:"w-3.5 h-3.5"})})]}),!r&&e.jsx("p",{className:"font-mono text-[11px] text-fg-secondary truncate mt-0.5 pl-[80px]",children:t.payloadJson?It(t.payloadJson):t.payloadRaw.slice(0,120)}),r&&t.payloadJson&&e.jsx("pre",{className:"font-mono text-[11px] text-fg-secondary mt-1.5 ml-[80px] p-2 bg-input-bg radius-inner overflow-x-auto max-h-64",children:JSON.stringify(t.payloadJson,null,2)})]})});function It(s){const t=Object.keys(s),r=t.slice(0,4).map(l=>{const i=s[l],a=typeof i=="string"?i:JSON.stringify(i);return`${l}: ${(a??"").slice(0,24)}`}).join(", ");return t.length>4?`{ ${r}, … }`:`{ ${r} }`}function Gt({topicFilter:s}){const t=N(h=>h.messages),r=N(h=>h.paused),l=N(h=>h.setPaused),i=N(h=>h.clearMessages),a=ye(),x=Se(),p=d.useRef(null),[U,v]=d.useState(!0),L=d.useRef(t.length);L.current=t.length;const P=d.useRef(t.length),M=d.useRef(0),[m,A]=d.useState(0);d.useEffect(()=>{const h=setInterval(()=>{const n=L.current-P.current;P.current=L.current,M.current=M.current*.7+n*.3,A(M.current)},1e3);return()=>clearInterval(h)},[]);const S=d.useMemo(()=>s?t.filter(h=>h.topic.startsWith(s)):t,[t,s]),E=ct({count:S.length,getScrollElement:()=>p.current,estimateSize:()=>52,overscan:20});d.useEffect(()=>{U&&S.length>0&&!r&&E.scrollToIndex(S.length-1,{align:"end"})},[S.length,U,r,E]);const j=d.useCallback(()=>{const h=p.current;if(!h)return;const n=h.scrollHeight-h.scrollTop-h.clientHeight<80;v(n)},[]),F=m<.1?"0":m<10?m.toFixed(1):Math.round(m).toLocaleString(),z=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:[F," pkt/s"]}),s&&e.jsx(I,{color:"blue",children:e.jsx("span",{className:"font-mono text-[11px]",children:s})}),x.length>0&&e.jsxs(I,{color:"cyan",children:[e.jsx(ut,{className:"w-3 h-3 mr-1"}),x.length," ch"]}),a.active&&e.jsxs(I,{color:"cyan",children:[e.jsx(le,{className:"w-3 h-3 mr-1"}),a.packetCount," injected"]})]}),Y=e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(te,{plain:!0,onClick:()=>l(!r),title:r?"Resume":"Pause",className:C(!r||"text-sys-amber"),children:r?e.jsx(mt,{"data-slot":"icon",className:"!w-4 !h-4"}):e.jsx(ht,{"data-slot":"icon",className:"!w-4 !h-4"})}),e.jsx(te,{plain:!0,onClick:i,title:"Clear messages",children:e.jsx(pt,{"data-slot":"icon",className:"!w-4 !h-4"})})]});return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(Pe,{icon:e.jsx(xt,{className:"icon-sm"}),title:"Messages",listHeader:!0,titleExtra:z,actions:Y}),e.jsx("div",{ref:p,onScroll:j,className:"flex-1 overflow-y-auto min-h-0",children:S.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-fg-muted type-data-sm",children:t.length===0?"No messages yet — subscribe to a topic":"No messages match filter"}):e.jsx("div",{style:{height:`${E.getTotalSize()}px`,position:"relative"},children:E.getVirtualItems().map(h=>e.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${h.start}px)`},"data-index":h.index,ref:E.measureElement,children:e.jsx(Ot,{msg:S[h.index]})},h.key))})})]})}const Ht=/^v?\d+(?:\.\d+)+(?:[-+].+)?$|^v?\d+$/i;function Ie(s){if(!s||!s.trim())return{family:"unknown",version:""};const r=s.trim().split(/[\s/]+/),l=[],i=[];for(const p of r)Ht.test(p)?i.push(p.replace(/^v/i,"")):l.push(p);const a=l.length>0?l.join(" ").toLowerCase():"(bare)",x=i.join(".");return{family:a,version:x}}function Kt(s){const t=new Map;for(const r of s){const{family:l,version:i}=Ie(r.firmwareVersion);let a=t.get(l);a||(a={count:0,versions:new Map},t.set(l,a)),a.count++;const x=i||"—";a.versions.set(x,(a.versions.get(x)??0)+1)}return[...t.entries()].map(([r,{count:l,versions:i}])=>({family:r,count:l,versions:[...i.entries()].map(([a,x])=>({version:a,count:x})).sort((a,x)=>x.count-a.count)})).sort((r,l)=>l.count-r.count)}const Ft=d.memo(function({observer:t}){const r=t.status==="online",l=t.lastSeen?`${Math.round((Date.now()-t.lastSeen)/1e3)}s ago`:"never";return e.jsx(Q,{compact:!0,children:e.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:C("w-2 h-2 rounded-full flex-shrink-0",r?"bg-sys-green":"bg-fg-muted/30")}),e.jsx("span",{className:"type-data-sm text-fg-primary font-medium truncate flex-1",children:t.name}),e.jsx(I,{color:r?"green":"zinc",children:r?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-3 h-3 mr-1"}),"online"]}):e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"w-3 h-3 mr-1"}),"offline"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsx(ae,{label:"IATA",value:t.iata.toUpperCase()}),e.jsx(ae,{label:"Packets",value:t.packetCount.toLocaleString()}),e.jsx(ae,{label:"Last seen",value:l}),t.firmwareVersion&&e.jsx(ae,{label:"Firmware",value:t.firmwareVersion}),t.radioConfig&&e.jsx(ae,{label:"Radio",value:t.radioConfig})]}),e.jsx("span",{className:"font-mono text-[10px] text-fg-muted/50 truncate mt-auto",title:t.id,children:t.id})]})})});function ae({label:s,value:t}){return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-muted",children:s}),e.jsx("span",{className:"text-fg-secondary tabular-nums truncate",children:t})]})}function zt(s){if(!s)return{};const t=s.split("/");if(t[0]!=="meshcore"||t.length<2)return{};const r=t[1],l=t.length>=3?t[2]:void 0;return{iata:r,pubkey:l}}const Vt=[25,50,100,250];function Wt({topicFilter:s=""}){const t=Le(),r=Se(),[l,i]=d.useState(""),[a,x]=d.useState(null),[p,U]=d.useState(50),[v,L]=d.useState(50),P=d.useMemo(()=>zt(s),[s]),M=d.useMemo(()=>[...t.values()].sort((n,f)=>f.lastSeen-n.lastSeen),[t]),m=d.useMemo(()=>{let n=M;if(P.iata)n=n.filter(f=>!(f.iata.toLowerCase()!==P.iata.toLowerCase()||P.pubkey&&f.id!==P.pubkey));else if(r.length>0){const f=new Set(r.map(y=>y.toLowerCase()));n=n.filter(y=>f.has(y.iata.toLowerCase()))}return n},[M,P,r]),A=d.useMemo(()=>Kt(m),[m]),S=d.useMemo(()=>m.map(n=>({obs:n,parsed:Ie(n.firmwareVersion)})),[m]),E=d.useMemo(()=>{if(!l)return m;const n=l.toLowerCase();return S.filter(({obs:f,parsed:y})=>{var R,V,u;if(y.family.includes(n)||y.version.toLowerCase().includes(n)||(R=f.firmwareVersion)!=null&&R.toLowerCase().includes(n)||f.name.toLowerCase().includes(n)||f.iata.toLowerCase().includes(n)||(V=f.radioConfig)!=null&&V.toLowerCase().includes(n)||f.id.toLowerCase().includes(n))return!0;const k=ee(f.iata);return!!(k.city.toLowerCase().includes(n)||k.country.toLowerCase().includes(n)||k.continent.toLowerCase().includes(n)||(u=k.state)!=null&&u.toLowerCase().includes(n))}).map(({obs:f})=>f)},[m,S,l]),j=d.useMemo(()=>E.slice(0,v),[E,v]),F=E.length>v,z=d.useCallback(n=>{U(n),L(n)},[]),Y=d.useCallback(n=>{i(n),x(null),L(p)},[p]),h=d.useCallback(()=>{L(n=>n+p)},[p]);return m.length===0?e.jsx(Q,{compact:!0,children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-6 text-fg-muted",children:[e.jsx(je,{className:"w-6 h-6 opacity-40"}),e.jsx("span",{className:"type-data-sm",children:"No observers discovered yet"}),e.jsxs("span",{className:"type-data-xs text-fg-muted/60",children:["Subscribe to ",e.jsx("code",{className:"font-mono",children:"meshcore/#"})," to see LetsMesh observers"]})]})}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wider",children:"Observers"}),e.jsx(I,{color:"zinc",children:m.length})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(Ye,{className:"w-3 h-3 text-fg-muted/50"}),A.map(n=>{const f=l.toLowerCase()===n.family,y=a===n.family;return e.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>{f?x(y?null:n.family):(i(n.family),x(null))},className:C("inline-flex items-center gap-1 px-2 py-0.5 rounded-full","font-mono text-[10px] font-medium","border transition-all select-none",f?"border-sys-indigo/50 bg-sys-indigo/15 text-sys-indigo":"border-edge-subtle/40 text-fg-muted hover:border-edge-subtle hover:text-fg-secondary"),title:`${n.count} observer${n.count!==1?"s":""} — ${n.family}${n.versions.length>1?` (${n.versions.length} versions)`:""}`,children:[n.family,e.jsx("span",{className:C("text-[9px] tabular-nums",f?"text-sys-indigo/60":"text-fg-muted/40"),children:n.count}),n.versions.length>1&&e.jsxs("span",{className:C("text-[9px]",f?"text-sys-indigo/40":"text-fg-muted/30"),children:["·",n.versions.length,"v"]})]}),y&&n.versions.map(k=>{const R=l===k.version;return e.jsxs("button",{onClick:()=>i(R?n.family:k.version),className:C("inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full","font-mono text-[9px]","border transition-all select-none",R?"border-sys-blue/50 bg-sys-blue/15 text-sys-blue":"border-edge-subtle/30 text-fg-muted/60 hover:text-fg-muted hover:border-edge-subtle/50"),title:`${k.count} observer${k.count!==1?"s":""} on ${k.version}`,children:[k.version,e.jsx("span",{className:"text-[8px] tabular-nums opacity-60",children:k.count})]},k.version)})]},n.family)})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx("span",{className:"text-[10px] tabular-nums text-fg-muted",children:E.length}),e.jsxs("div",{className:"relative max-w-44",children:[e.jsx(Te,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none"}),e.jsx(K,{size:"sm",value:l,onChange:n=>Y(n.target.value),placeholder:"Region, firmware, name, ID…",className:"pl-7 w-full font-mono text-xs"})]}),e.jsx(Re,{value:p,onChange:z,"aria-label":"Per page",className:"w-[88px] shrink-0 [&_button]:h-8 [&_button]:py-0 [&_button]:text-[11px] [&_button]:tabular-nums",children:Vt.map(n=>e.jsxs(ge,{value:n,children:["Show ",n]},n))})]})]}),E.length===0?e.jsx(Q,{compact:!0,children:e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-fg-muted type-data-xs",children:["No observers match “",l,"”"]})}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{template:"compact",children:j.map(n=>e.jsx(Ne,{span:12,sm:6,lg:4,xl:3,children:e.jsx(Ft,{observer:n})},n.id))}),F&&e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-1",children:[e.jsxs("button",{onClick:h,className:C("inline-flex items-center gap-1.5 px-4 py-1.5 rounded-full","text-[11px] font-medium","border border-edge-subtle/50 text-fg-muted","hover:border-edge-subtle hover:text-fg-secondary hover:bg-subtle-fill/30","transition-all select-none"),children:[e.jsx(be,{className:"w-3 h-3"}),"Show more (",E.length-v," remaining)"]}),e.jsxs("span",{className:"text-[10px] text-fg-muted/40 tabular-nums",children:[j.length," / ",E.length]})]})]})]})}function ce({label:s,children:t,className:r}){return e.jsxs("div",{className:C("flex flex-col gap-1",r),children:[e.jsx("label",{className:"type-data-xs text-fg-muted uppercase tracking-wider",children:s}),t]})}const $t={connected:"green",connecting:"amber",loading:"blue",error:"red",disconnected:"zinc"},Yt=[{tier:"3d",label:"3 Day"},{tier:"7d",label:"7 Day"},{tier:"14d",label:"14 Day"}],Ee=["24h","3d","7d","14d"];function Zt(){const s=O(u=>u.url),t=O(u=>u.port),r=O(u=>u.username),l=O(u=>u.password),i=Ze(),a=Je(),x=Me(),p=Xe(),U=qe(),v=_e(),L=O(u=>u.currentTier),P=O(u=>u.lastFetched),M=O(u=>u.setUrl),m=O(u=>u.setPort),A=O(u=>u.setUsername),S=O(u=>u.setPassword),E=O(u=>u.connect),j=O(u=>u.disconnect),F=O(u=>u.startPolling),z=O(u=>u.stopPolling),Y=O(u=>u.loadTier),h=i==="connected",n=i==="connecting",f=i==="loading",y=h||n||f,k=!!s&&!!r&&!!l&&!y,R=d.useCallback(()=>{h||f?j():E()},[h,f,E,j]),V=Ee.indexOf(L);return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 max-w-3xl",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-end gap-3",children:[e.jsx(ce,{label:"Host",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",value:s,onChange:u=>M(u.target.value),placeholder:"http://192.168.1.100",disabled:y})}),e.jsx(ce,{label:"Port",className:"w-20 shrink-0",children:e.jsx(K,{size:"sm",type:"number",value:String(t),onChange:u=>m(parseInt(u.target.value,10)||8e3),placeholder:"8000",disabled:y})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-end gap-3",children:[e.jsx(ce,{label:"Username",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",value:r,onChange:u=>A(u.target.value),placeholder:"admin",disabled:y})}),e.jsx(ce,{label:"Password",className:"flex-1 min-w-0",children:e.jsx(K,{size:"sm",type:"password",value:l,onChange:u=>S(u.target.value),placeholder:"••••••",disabled:y})}),e.jsx(te,{color:h||f?"danger":"primary",onClick:R,disabled:!k&&!h&&!f,className:C("shrink-0 sm:self-end",n&&"animate-pulse"),children:h||f?e.jsxs(e.Fragment,{children:[e.jsx(De,{"data-slot":"icon",className:"!w-4 !h-4"})," Disconnect"]}):n?e.jsxs(e.Fragment,{children:[e.jsx(Ae,{"data-slot":"icon",className:"!w-4 !h-4 animate-spin"})," Connecting"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{"data-slot":"icon",className:"!w-4 !h-4"})," Connect"]})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(I,{color:$t[i]??"zinc",children:i}),(h||f)&&x>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:[e.jsx(fe,{className:"w-3 h-3 inline mr-1"}),x.toLocaleString()," packets"]}),h&&P&&e.jsxs("span",{className:"type-data-xs text-fg-muted/60 tabular-nums",children:[e.jsx(Nt,{className:"w-3 h-3 inline mr-1"}),new Date(P).toLocaleTimeString()]}),i==="error"&&a&&e.jsx("span",{className:"type-data-xs text-sys-red truncate max-w-60",title:a,children:a})]}),f&&U&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}),e.jsxs("span",{className:"type-data-xs text-sys-blue",children:["Loading",U.phase==="complete"?" complete":"","… ",U.loaded.toLocaleString()," packets"]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill rounded-full overflow-hidden max-w-md",children:e.jsx("div",{className:"h-full bg-sys-blue/60 rounded-full transition-all duration-300",style:{width:`${Math.min(100,(U.chunk||0)*10)}%`}})})]}),h&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pe,{enabled:v,onChange:u=>u?F():z(),label:"Live polling",size:"sm"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:v?"Polling every 8s for new packets":"Polling paused"})]}),h&&p.length>0&&e.jsxs("div",{className:"border-t border-edge-subtle/20 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(le,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wider",children:"Detected Nodes"}),e.jsx(I,{color:"zinc",children:p.length})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(u=>e.jsxs("span",{className:C("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full","font-mono text-[11px] font-medium tracking-wide","border border-sys-blue/30 bg-sys-blue/10 text-sys-blue"),title:`Observer ${u.observer} at ${u.iata}
${u.packetCount.toLocaleString()} packets`,children:[u.iata,e.jsx("span",{className:"text-[10px] text-sys-blue/50",children:u.observer}),e.jsx("span",{className:"text-[10px] text-sys-blue/40 tabular-nums",children:u.packetCount.toLocaleString()})]},u.key))})]}),h&&e.jsxs("div",{className:"border-t border-edge-subtle/20 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(fe,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wider",children:"Historical Depth"}),e.jsx(I,{color:"zinc",children:L})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:Yt.map(({tier:u,label:o})=>{const c=Ee.indexOf(u)<=V,w=Qe.has(u);return e.jsx("button",{onClick:()=>!c&&!w&&void Y(u),disabled:c||w,className:C("inline-flex items-center gap-1 px-2.5 py-1 rounded-full","text-[11px] font-medium border transition-all select-none","disabled:cursor-not-allowed",c?"border-sys-green/30 bg-sys-green/10 text-sys-green/70":"border-edge-subtle/50 text-fg-muted hover:border-sys-blue/40 hover:text-sys-blue hover:bg-sys-blue/5"),title:c?`${o} data loaded`:`Load ${o} history from remote`,children:o},u)})})]})]})}const Ge="pymc:source:protocol";function Jt(){try{if(localStorage.getItem(Ge)==="http")return"http"}catch{}return"mqtt"}function Xt(s){try{localStorage.setItem(Ge,s)}catch{}}function qt({value:s,onChange:t,disabled:r}){return e.jsxs("div",{className:"inline-flex items-center gap-0.5 p-0.5 rounded-full bg-subtle-fill/50 border border-edge-subtle/30",children:[e.jsxs("button",{onClick:()=>t("mqtt"),disabled:r,className:C("inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium transition-all select-none","disabled:opacity-50 disabled:cursor-not-allowed",s==="mqtt"?"bg-sys-cyan/15 text-sys-cyan border border-sys-cyan/30":"text-fg-muted hover:text-fg-secondary hover:bg-subtle-fill/30 border border-transparent"),children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),"MQTT"]}),e.jsxs("button",{onClick:()=>t("http"),disabled:r,className:C("inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium transition-all select-none","disabled:opacity-50 disabled:cursor-not-allowed",s==="http"?"bg-sys-blue/15 text-sys-blue border border-sys-blue/30":"text-fg-muted hover:text-fg-secondary hover:bg-subtle-fill/30 border border-transparent"),children:[e.jsx(me,{className:"w-3.5 h-3.5"}),"HTTP"]})]})}function As(){const[s,t]=d.useState(""),[r,l]=d.useState(Jt),i=N(j=>j.status),a=ye(),x=N(j=>j.stopMqttMode),p=et(),U=Me(),v=O(j=>j.url),L=O(j=>j.disconnect),P=d.useCallback(j=>{t(F=>F===j?"":j)},[]),M=d.useCallback(j=>{l(j),Xt(j)},[]),m=a.active||i==="connected"||p,A=r==="http",S=A?"External Database":"MQTT Subscription",E=A?e.jsx(me,{}):e.jsx(ke,{});return e.jsxs(st,{children:[e.jsxs("div",{className:"relative",style:{isolation:"isolate"},children:[e.jsx(at,{title:S,icon:E,subtitle:A?e.jsxs("div",{className:"flex items-start gap-2 max-w-2xl",children:[e.jsx(fe,{className:"w-3.5 h-3.5 text-sys-blue shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs leading-relaxed text-fg-muted",children:"Connect to a remote pyMC_Repeater database to aggregate external packet data. All packets are ingested for a full mesh view — topology, maps, charts, and decryption hydrate from the combined dataset. Disconnecting clears external data and reverts to local-only."})]}):e.jsxs("div",{className:"flex items-start gap-2 max-w-2xl",children:[e.jsx(tt,{className:"w-3.5 h-3.5 text-sys-amber shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-xs leading-relaxed text-fg-muted",children:["This is a browser-side MQTT downlink subscription for pulling packets into this Console session. It is not an uplink publisher and does not upload your repeater traffic to MQTT. If you are looking for MQTT upload/uplink publishing, use the ",e.jsx("a",{href:"/observer",className:"text-sys-blue hover:underline",children:"Observer"})," option. Downlink data is live-session only and clears on hard refresh or session-cache clear. Don't try this on a phone."]})]})}),e.jsxs("span",{className:"absolute top-1.5 left-[265px] sm:left-[320px] -rotate-12 select-none pointer-events-none",style:{zIndex:9999,opacity:.8},"aria-hidden":"true",children:[e.jsx("svg",{className:"absolute",width:"0",height:"0","aria-hidden":"true",children:e.jsx("defs",{children:e.jsxs("filter",{id:"stamp-distress",children:[e.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.65",numOctaves:"4",seed:"2",result:"noise"}),e.jsx("feColorMatrix",{type:"saturate",values:"0",in:"noise",result:"gray"}),e.jsx("feComponentTransfer",{in:"gray",result:"threshold",children:e.jsx("feFuncA",{type:"discrete",tableValues:"0 0 1 1 1"})}),e.jsx("feComposite",{in:"SourceGraphic",in2:"threshold",operator:"in"})]})})}),e.jsx("span",{className:"inline-block border-[1.5px] border-sys-amber rounded px-1.5 py-px font-black text-sm tracking-[0.06em] uppercase text-sys-amber",style:{filter:"url(#stamp-distress)",mixBlendMode:"soft-light"},children:"BETA"})]})]}),e.jsxs(nt,{ready:!0,children:[e.jsx("div",{className:"mb-3",children:e.jsx(qt,{value:r,onChange:M,disabled:m})}),!A&&a.active&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 mb-2 bg-sys-cyan/10 border border-sys-cyan/30 radius-card",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-4 h-4 text-sys-cyan"}),e.jsx("span",{className:"text-sys-cyan font-medium text-sm",children:"MQTT Mode Active"}),e.jsxs(I,{color:"cyan",children:[a.packetCount.toLocaleString()," packets"]}),a.channel&&e.jsx("span",{className:"font-mono text-xs text-fg-muted",children:a.channel}),a.iatas.length>0&&e.jsx("span",{className:"text-xs text-fg-secondary",children:a.iatas.join(", ")}),a.streaming&&e.jsxs(I,{color:"cyan",children:[e.jsx(se,{className:"w-3 h-3 mr-1 fill-current"}),"Live"]})]}),e.jsx(te,{plain:!0,onClick:x,title:"Exit MQTT mode",className:"text-sys-cyan hover:text-sys-cyan/70",children:e.jsx(xe,{"data-slot":"icon",className:"!w-4 !h-4"})})]}),A&&p&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 mb-2 bg-sys-blue/10 border border-sys-blue/30 radius-card",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4 text-sys-blue"}),e.jsx("span",{className:"text-sys-blue font-medium text-sm",children:"HTTP Source Active"}),e.jsxs(I,{color:"blue",children:[U.toLocaleString()," packets"]}),e.jsx("span",{className:"font-mono text-xs text-fg-muted truncate max-w-48",children:v})]}),e.jsx(te,{plain:!0,onClick:L,title:"Disconnect remote source",className:"text-sys-blue hover:text-sys-blue/70",children:e.jsx(xe,{"data-slot":"icon",className:"!w-4 !h-4"})})]}),A?e.jsx(ue,{template:"auto",children:e.jsx(Q,{compact:!0,children:e.jsx(Zt,{})})}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{template:"auto",children:e.jsx(Q,{compact:!0,children:e.jsx(Rt,{})})}),e.jsxs(ue,{template:"hero-tall",children:[e.jsx(Ne,{span:12,md:4,children:e.jsxs(Q,{noPadding:!0,className:"overflow-hidden",children:[e.jsx(Pe,{icon:e.jsx(le,{className:"icon-sm"}),title:"Topics",listHeader:!0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",style:{height:"calc(100% - 57px)"},children:e.jsx(Bt,{onTopicSelect:P,selectedTopic:s})})]})}),e.jsx(Ne,{span:12,md:8,children:e.jsx(Q,{noPadding:!0,children:e.jsx(Gt,{topicFilter:s})})})]}),i==="connected"&&e.jsx(Wt,{topicFilter:s})]})]})]})}export{As as default};
